call _clrLCD ;clears the screen
This may be the shortest way to
clear the screen but it sure isn't the fastest. This
routine has to switch ROM pages to be run which
takes time. the following code is the fastest but
is about 10 bytes longer. It clears (loads with l
which was just cleared) byte A first. After
that it copies the cleared byte A to byte B, increases
both so we now are going to load the recently cleared
byte B into byte C and so on.
Some people do ld (hl),$00
but since we just cleared l with ld hl,$fc00 ,
we can just use ld (hl),l saving one byte.
| clear_screen:
ld hl,$fc00 ;start of video memory
ld (hl),l ;l=$00 so we clear (hl)
ld de,$fc01 ;2nd byte in video mem
ld bc,1023 ;size of video mem-1
; since de is start+1
ldir ;copy already cleared
; byte from hl into de
; then increase so hl
; points to what was
; just cleared and de
; the byte after
ret ;we're done
| |