TUI font

General FreeBASIC programming questions.
Post Reply
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

TUI font

Post by angros47 »

Years ago I tried to make a font for a TUI in QBASIC.

http://www.petesqbsite.com/phpBB3/viewt ... 37c#p20107

I tried porting it to FreeBasic:

Code: Select all

type Font
  w as long
  h as long
  d as any ptr
end type

enum
  FB_FONT_8 = 0,
  FB_FONT_14
  FB_FONT_16
end enum

extern Fonts(2)  alias "__fb_font"  as Font


sub EditChar cdecl(byref f as Font, c as ubyte, ...)
	Dim As cva_list args
	cva_start(args,c)
	dim as long y,yend,code
	dim row as ubyte ptr
	yend=f.h

	code=c:code*=f.h:row=f.d+code
	for y = 1 to yend
		*row=cva_arg(args, ubyte)
		row+=1
	next

PRINT c;": ";:COLOR 15,1: PRINT CHR$(c); : COLOR 15, 0: PRINT "  "; 
end sub

'screenres 640,480 ',32
screen 12


editchar (Fonts(FB_FONT_16),145, 0 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255)
editchar (Fonts(FB_FONT_16),146, 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),178, 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255)
editchar (Fonts(FB_FONT_16),185, 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248 , 248)
editchar (Fonts(FB_FONT_16),186, 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8)
editchar (Fonts(FB_FONT_16),187, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 240 , 8 , 24 , 24 , 56 , 120 , 120 , 248 , 248)
editchar (Fonts(FB_FONT_16),188, 248 , 248 , 248 , 248 , 248 , 248 , 248 , 240 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),189, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),190, 0 , 255 , 255 , 255 , 255 , 255 , 3 , 251 , 3 , 255 , 255 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),191, 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128)
editchar (Fonts(FB_FONT_16),192, 0 , 127 , 127 , 127 , 127 , 127 , 96 , 111 , 96 , 127 , 127 , 127 , 127 , 127 , 127 , 0)
editchar (Fonts(FB_FONT_16),193, 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1)
editchar (Fonts(FB_FONT_16),194, 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),195, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255)
editchar (Fonts(FB_FONT_16),196, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 7 , 8 , 8 , 8 , 8 , 8 , 8 , 8 , 8)
editchar (Fonts(FB_FONT_16),197, 255 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128)
editchar (Fonts(FB_FONT_16),198, 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 128 , 255)
editchar (Fonts(FB_FONT_16),199, 0 , 255 , 255 , 255 , 254 , 252 , 248 , 240 , 224 , 192 , 255 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),200, 0 , 255 , 255 , 255 , 255 , 192 , 224 , 240 , 248 , 252 , 254 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),210, 8 , 8 , 9 , 9 , 11 , 11 , 15 , 7 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),211, 255 , 255 , 255 , 255 , 255 , 255 , 255 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),212, 0 , 0 , 3 , 12 , 16 , 32 , 64 , 64 , 64 , 32 , 16 , 12 , 3 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),213, 0 , 0 , 3 , 12 , 17 , 39 , 79 , 79 , 79 , 39 , 17 , 12 , 3 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),214, 0 , 0 , 63 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 32 , 63 , 31 , 0 , 0)
editchar (Fonts(FB_FONT_16),215, 0 , 0 , 63 , 32 , 32 , 32 , 32 , 36 , 35 , 33 , 32 , 32 , 63 , 31 , 0 , 0)
editchar (Fonts(FB_FONT_16),216, 0 , 127 , 127 , 127 , 127 , 126 , 120 , 96 , 120 , 126 , 127 , 127 , 127 , 127 , 127 , 0)
editchar (Fonts(FB_FONT_16),217, 0 , 127 , 127 , 113 , 112 , 112 , 112 , 112 , 112 , 112 , 112 , 113 , 127 , 127 , 127 , 0)
editchar (Fonts(FB_FONT_16),224, 0 , 0 , 192 , 48 , 8 , 4 , 2 , 2 , 2 , 4 , 8 , 48 , 192 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),225, 0 , 0 , 192 , 48 , 136 , 228 , 242 , 242 , 242 , 228 , 136 , 48 , 192 , 0 , 0 , 0)
editchar (Fonts(FB_FONT_16),226, 0 , 0 , 248 , 8 , 12 , 12 , 12 , 12 , 12 , 12 , 12 , 12 , 252 , 252 , 0 , 0)
editchar (Fonts(FB_FONT_16),227, 0 , 0 , 248 , 8 , 44 , 76 , 204 , 140 , 140 , 12 , 12 , 12 , 252 , 252 , 0 , 0)
editchar (Fonts(FB_FONT_16),230, 0 , 255 , 255 , 255 , 255 , 127 , 63 , 31 , 15 , 7 , 255 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),231, 0 , 255 , 255 , 255 , 255 , 7 , 15 , 31 , 63 , 127 , 255 , 255 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),232, 0 , 255 , 255 , 199 , 7 , 7 , 7 , 7 , 7 , 7 , 7 , 199 , 255 , 255 , 255 , 0)
editchar (Fonts(FB_FONT_16),233, 0 , 255 , 255 , 255 , 255 , 63 , 15 , 3 , 15 , 63 , 255 , 255 , 255 , 255 , 255 , 0)



PRINT
Print chr(187,189,189,189,189,189,189,196)
Print chr(185);:color 0,15: PRINT"Button";:COLOR 15,0: PRINT chr(186)
Print chr(188,211,211,211,211,211,211,210)
PRINT
PRINT "Radio button:";CHR(224,212) + CHR (225,213);
PRINT SPACE(50)
PRINT "Check box:";CHR(226,214) + CHR (227,215);

sleep
Last edited by angros47 on Jul 02, 2022 19:29, edited 1 time in total.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: TUI font

Post by paul doe »

Very nice. Remember that at the moment only cdecl procedures can be variadic:

Code: Select all

sub EditChar cdecl(byref f as Font, c as ubyte, ...) '' Otherwise it doesn't compile
/' ... '/
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: TUI font

Post by angros47 »

Right, I forgot, because it compiles perfectly under Linux, since cdecl is the standard here.

So, if we want to split the hair, your comment should have been "'' Otherwise it doesn't compile on Windows"
SARG
Posts: 1757
Joined: May 27, 2005 7:15
Location: FRANCE

Re: TUI font

Post by SARG »

On 64bit Linux/Windows it doesn't matter as no calling convention. In this case it's ignored.
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: TUI font

Post by dodicat »

for
screenres 640,480
shouldn't
width 640\8,480\16
be applied.
Win 10.
Otherwise the font defaults to 8 by 12, and the radio buttons and check boxes are wrong.
marcov
Posts: 3455
Joined: Jun 16, 2005 9:45
Location: Netherlands
Contact:

Re: TUI font

Post by marcov »

angros47 wrote: Jul 02, 2022 19:31 Right, I forgot, because it compiles perfectly under Linux, since cdecl is the standard here.
That's a FB choice. E.g. FPC uses Register, which is more fastcall like on linux/x86.
Post Reply