If you’re trying to use ROM calls, then you’ll be better off with the good old RST $10. However, it’s much,
much faster to do it yourself. Here’s arguably the quickest and smallest printer routine I could think of. It’s only 19 bytes (26, if you’re using the attribute address for coordinates):
Code: Select all
ld de,$484a ;AT 10,10 (screen bitmap)
; ld de,$594a ;AT 10,10 (screen attributes)
ld a,"$" ;(some assemblers won’t convert characters to ASCII codes, though)
call printer
ret
printer ;19/26 bytes (bitmap/attr addr)
ld h,0 ;make sure H=0
add a,a ; \
ld l,a ;load L with chr code
add hl,hl ; multiply HL by 8
add hl,hl ; /
ld bc,$3c00 ;add $3c00 to get the base address of character
add hl,bc ;bitmap in ROM (chr code*8+$3c00), load it into HL
; ld a,d
; rla ;
; rla ;convert attr addr to bitmap addr
; rla ;
; and 88
; ld d,a
ld b,8 ;eight lines to draw
char_pr ld a,(hl) ;bitmap into A
ld (de),a ;put on screen
inc l ;next bitmap
inc d ;one line down
djnz char_pr
ret
Uncomment the lines marked "convert attr addr to bitmap addr,” and the second line (“AT 10,10 (screen attributes)”), if you wish to use the attribute address for you character coordinates. The latter is a tad easier to use, as the formula is
$5800 + x-coord × 32 + y-coord:
Code: Select all
ld b,10 ;x coord
ld c,10 ;y coord
ld de,$5800
ld h,e ;zero into H
ld l,b ;x coord into L
add hl,hl ;\
add hl,hl ; \
add hl,hl ; multiply by 32
add hl,hl ; /
add hl,hl ;/
add hl,de ;add $5800
ld d,e ;zero into D
ld e,c ;y coord into E
add hl,de ;add y coord