Code:
LG_Font_Base:
' Note gl_x char space need be 12 , not normal 24 when using chr else too big a gap space _
' Code for "-" Asci 45 : note -gl_i(0) is ASCI CHR CODE , 90 real values _
pokecode $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$3F,$FC,$00,$3F,$FC,$00,$3F,$FC,_
$00,$3F,$FC,$00,$3F,$FC,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,_
$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
Code:
'=================== FONT COMMON ROUTINE - pokecode use ==========================
' Assumes gl_x, gl_y,X_scan,Y_scan,Font_lookup
' ALL FONTS MUST BE gl_x = 8 , 16 , 24 etc
' Inv_font = 0 = normal 1= inverse
Font_Common:
x_save = gl_x ' save the gl_x start point value
y_save = gl_y ' save the gl_y start point value
gl_yb = y_save + Y_scan ' number of y scans for the char from y starting point(0)
gl_xb = 0
Address = 0
if Font_lookup = 1 then
@ GetAddress _LG_Font_Base, _Font_Base_Address ; gets base start address of LG_font into Font_Base_Address varable
Font_Index = (LG_font - 45)* (90*2) ' remove the ascii chr value 45 offset 0 * font chr length x 2 cos of RETLW INSTRUCTION for each byte read in index
endif
if Font_lookup = 2 then ' remove the offset of the first symbol $2D / 45 so start at 0
@ GetAddress _Med_Font_Base, _Font_Base_Address
Font_Index = (Med_font - 45)* (40*2) ' remove the ascii chr value 45 offset * font chr length in index
endif
Address = Font_Base_Address + Font_Index 'gets you to the start of the glyph
for gl_y = y_save to gl_yb ' y scan lines, start to finish values
gl_x = x_save ' clear x position to start point (keep it an 8bit multiple)
gosub gl_gaddr ' Set address
for gl_xb = 1 to X_scan ' gl_x byte x X scan bytes on each line
peekcode Address,gl_byte ' read the indexed byte in
glcd_msb = gl_byte
glcd_cmd = DATA_WR_INC ' write and increment
gosub send_1 ' send to glcd
Address = Address+2 ' inc address here +2 cos each byte includes , as data start at 0 not 1 as per lookup tables previously
next gl_xb ' next byte of font
next gl_y ' next scan line of font
gl_y = y_save ' Restore the Y location
gl_x = x_save ' Restore the X location
return
Bookmarks