@@ -3,7 +3,7 @@ include '../include/library.inc'
33include '../include/include_library.inc'
44;-------------------------------------------------------------------------------
55
6- library FONTLIBC , 2
6+ library FONTLIBC , 3
77
88;-------------------------------------------------------------------------------
99; Dependencies
@@ -23,7 +23,7 @@ include_library '../graphx/graphx.asm'
2323 export fontlib_GetCursorX
2424 export fontlib_GetCursorY
2525 export fontlib_ShiftCursorPosition
26- export fontlib_SetFont
26+ export fontlib_Deprecated
2727 export fontlib_SetForegroundColor
2828 export fontlib_SetBackgroundColor
2929 export fontlib_SetColors
@@ -78,7 +78,11 @@ include_library '../graphx/graphx.asm'
7878 export fontlib_ScrollWindowUp
7979 export fontlib_Home
8080 export fontlib_HomeUp
81-
81+ ;-------------------------------------------------------------------------------
82+ ; v3 functions
83+ ;-------------------------------------------------------------------------------
84+ ; replacement for fontlib_SetFont
85+ export fontlib_LoadFont
8286
8387;-------------------------------------------------------------------------------
8488CurrentBuffer := ti.mpLcdLpbase
@@ -140,6 +144,11 @@ virtual at 0
140144strucFontPackHeader strucFontPackHeader
141145end virtual
142146
147+ ;-------------------------------------------------------------------------------
148+ ; fontlib_load_options_t
149+
150+ bLoadOption_IgnoreLineSpacing := 0
151+ mLoadOption_IgnoreLineSpacing := 1 shl bLoadOption_IgnoreLineSpacing
143152
144153;-------------------------------------------------------------------------------
145154macro mIsHLLessThanDE?
@@ -404,7 +413,19 @@ fontlib_Home:
404413
405414
406415;-------------------------------------------------------------------------------
407- fontlib_SetFont:
416+ fontlib_Deprecated:
417+ ; formerly fontlib_SetFont
418+ ; performs fontlib_LoadFont(font_data, FONTLIB_IGNORE_LINE_SPACING)
419+ ld hl , arg1
420+ add hl , sp
421+ ld bc , mLoadOption_IgnoreLineSpacing
422+ ld (hl) , bc
423+
424+ ; Fall through to fontlib_LoadFont
425+ assert $ = fontlib_LoadFont
426+
427+ ;-------------------------------------------------------------------------------
428+ fontlib_LoadFont:
408429; Sets the current font to the data at the pointer given
409430; Arguments:
410431; arg0: Pointer to font
@@ -435,12 +456,12 @@ fontlib_SetFont:
435456 or a , a
436457 ret z ; Also unreasonable: a zero-height font
437458 and a , $ 80
438- jr nz , .false
459+ jr nz , .failure
439460 ld a , 63
440461 cp a , (iy + strucFont.spaceAbove)
441- jr c , .false
462+ jr c , .failure
442463 cp a , (iy + strucFont.spaceBelow)
443- jr c , .false
464+ jr c , .failure
444465.validateOffsets:
445466; Now convert offsets into actual pointers
446467; Validate that offset is at least semi-reasonable
@@ -459,21 +480,20 @@ fontlib_SetFont:
459480 add hl , bc
460481 ld (iy + strucFont.bitmapsTablePtr) , hl
461482; Check for the ignore line spacing flag
462- ; Due to a bug, flags must be ignored, and treated as FONTLIB_IGNORE_LINE_SPACING
463- ; ld hl,arg1
464- ; add hl,sp
465- ; ld a,(hl)
466- ; or a,a
467- ; jr z,.true
483+ ld hl , arg1
484+ add hl , sp
485+ bit bLoadOption_IgnoreLineSpacing , (hl)
486+ jr z , .finish_load
468487 lea hl , iy + strucFont.spaceAbove
469488 xor a , a
470489 ld (hl) , a
471490 inc hl
472491 ld (hl) , a
473- .true :
492+ .finish_load :
474493 ld a , 1
475494 ret
476- .false:
495+
496+ .failure:
477497 xor a , a
478498 ret
479499
0 commit comments