Skip to content

Commit

Permalink
(bee,super80) Update copy font to cope with different sizes
Browse files Browse the repository at this point in the history
-pragma-define:CLIB_FONT_HEIGHT=xx assets must have that many rows
per character
  • Loading branch information
suborb committed Jul 14, 2023
1 parent 5b385e7 commit f6385d7
Showing 1 changed file with 42 additions and 19 deletions.
61 changes: 42 additions & 19 deletions libsrc/target/shared/copy_font.asm
Original file line number Diff line number Diff line change
@@ -1,31 +1,54 @@

SECTION code_clib
SECTION code_clib

PUBLIC copy_font_8x8
PUBLIC copy_font_8x8

EXTERN CRT_FONT
EXTERN CRT_FONT
EXTERN __CLIB_FONT_HEIGHT


; Copy font in PCG area
; Entry: c = number of characters
; de = address to copy from
; hl = address for PCG
;
;
; PCG takes 16 bytes, for an 8x8 we want to pad 1 at top, 7 at bottom
copy_font_8x8:
copy_1:
ld (hl),0
inc hl
ld b,8
push bc
call filltop
ld b,__CLIB_FONT_HEIGHT
copy_2:
ld a,(de)
ld (hl),a
inc de
inc hl
djnz copy_2
ld b,7
copy_3:
ld (hl),0
inc hl
djnz copy_3
dec c
jr nz,copy_1
ret
ld a,(de)
ld (hl),a
inc c
inc de
inc hl
djnz copy_2
call fillbottom
pop bc
dec c
jr nz,copy_1
ret

filltop:
ld c,0
ld a,__CLIB_FONT_HEIGHT
cp 8
ret nz
ld a,1
jr fill_loop

fillbottom:
ld a,16
sub c
ret c
fill_loop:
and a
ret z
ld (hl),0
inc hl
inc c
dec a
jr fill_loop

0 comments on commit f6385d7

Please sign in to comment.