05-08-2005, 08:49 PM
Code:
TYPE fb_FontType
h AS INTEGER
data AS UBYTE PTR
END TYPE
'Unrem the font type you wish to use
EXTERN fb_FontData ALIAS "fb_font_8x8" AS fb_FontType
'EXTERN fb_FontData ALIAS "fb_font_8x14" AS fb_FontType
'EXTERN fb_FontData ALIAS "fb_font_8x16" AS fb_FontType
'allowed = which chars to allow:
'1 = 0-9 and -
'2 = a-z and [Space]
'4 = A-Z and [Space]
'8 = , . - _ : ; ! " # % & / \ ( ) = ? + * < > [Space] '
'16 = § ½ | @ £ $ ⬠{ [ ] } ´ `^ ¨ ~
'31 = all
'enter = escape char, the key to press to exit the input routine
' defaults to enter/return
function GfxInput(text as string, defaultval as string, xl as integer, yl as integer, col as integer, allowed as uinteger = 31, enter = 13 ) as string
dim smallbuff(0, 130) as uinteger
if allowed and 1 then alist$ = alist$ + "0123456789-"
if allowed and 2 then alist$ = alist$ + "abcdefghijklmnopqrstuvwxyz "
if allowed and 4 then alist$ = alist$ + "ABCDEFGHIJKLMNOPQRSTUVWXYZ "
if allowed and 8 then alist$ = alist$ + ",.-_:;!"+chr$(34)+"#%&/\()=?+*<> '"
if allowed and 16 then alist$ = alist$ + "§½|@£$â¬{[]}´`^¨~"
cx = len(text) * 8
GfxPrint text, xl, yl, col
dx = cx
if defaultval <> "" then
nt$ = defaultval
redim smallbuff(len(nt$)-1, 130) as uinteger
for a = 1 to len(nt$)
get (cx+xl, yl)-(cx+xl+8, yl+fb_FontData.h), smallbuff(a-1, 0)
cx=cx+8
next
end if
GfxPrint nt$, dx+xl, yl, col
do
k$ = inkey$
if instr(alist$, k$) then
nt$ = nt$ + k$
redim preserve smallbuff(len(nt$)-1, 130) as uinteger
get (cx+xl, yl)-(cx+xl+8, yl+fb_FontData.h), smallbuff(len(nt$)-1, 0)
GfxPrint k$, xl+cx, yl, col
cx=cx+8
else
if k$ = chr$(8) and len(nt$) > 0 then
nt$ = left$(nt$, len(nt$)-1)
cx=cx-8
put (cx+xl, yl), smallbuff(len(nt$), 0), pset
end if
end if
loop until k$ = chr$(enter)
do: loop until inkey$ =""
GfxInput = nt$
end function
SUB GfxPrint( BYREF text AS STRING, _
BYVAL x AS INTEGER, BYVAL y AS INTEGER, _
BYVAL col AS INTEGER, BYVAL buffer AS ANY PTR = 0 )
DIM row AS INTEGER, i AS INTEGER
DIM bits AS UBYTE PTR
FOR i = 1 TO LEN(text)
bits = fb_FontData.data + (ASC(MID$(text, i, 1)) * fb_FontData.h)
FOR row = 0 TO fb_FontData.h-1
IF (buffer) THEN
LINE buffer, (x + 7, y + row)-(x, y + row), col,,*bits SHL 8
ELSE
LINE (x + 7, y + row)-(x, y + row), col,, *bits SHL 8
END IF
bits += 1
NEXT row
x += 8
NEXT i
END SUB