ca84b5dac8
This was mostly lifted from my "tihello" example, but it required significant adjustments. This commit also introduces a font management system. A lot of fonts are available online, but sources aren't always clear so to avoid copyright landmines, I re-created my first 5x7 font from scratch. As it is now, this resulting ROM gets "Collapse OS>" to be displayed on the LCD screen. Much work still left to do. ref #41
33 lines
702 B
NASM
33 lines
702 B
NASM
; Font management
|
|
;
|
|
; There can only ever be one active font.
|
|
;
|
|
; *** Defines ***
|
|
; FNT_DATA: Pointer to the beginning of the binary font data to work with.
|
|
; FNT_WIDTH: Width of the font.
|
|
; FNT_HEIGHT: Height of the font.
|
|
;
|
|
; *** Code ***
|
|
|
|
; If A is in the range 0x20-0x7e, make HL point to the beginning of the
|
|
; corresponding glyph and set Z to indicate success.
|
|
; If A isn't in the range, do nothing and unset Z.
|
|
fntGet:
|
|
cp 0x20
|
|
ret c ; A < 0x20. Z was unset by cp
|
|
cp 0x7f
|
|
jr nc, unsetZ ; A >= 0x7f. Z might be set
|
|
|
|
push af ; --> lvl 1
|
|
push bc ; --> lvl 2
|
|
sub 0x20
|
|
ld hl, FNT_DATA
|
|
ld b, FNT_HEIGHT
|
|
.loop:
|
|
call addHL
|
|
djnz .loop
|
|
pop bc ; <-- lvl 2
|
|
pop af ; <-- lvl 1
|
|
cp a ; set Z
|
|
ret
|