04-18-2012, 01:40 PM
Code:
SUB plotPoint (x as uByte, y as uByte)
ASM
ld d,a ;'X
ld a, 191
sub (IX+7) ;' y
jr c, plotPoint_end
ld l,a
ld h,ScreenTables/256
ld a,(HL)
inc h
ld l,(HL)
ld h,a
; now we're on the right row on screen.
ld a,d
RRCA ; divide column by 8 for bytes.
RRCA
RRCA
AND 31
add a,l
ld l,a
ld a, d
and 7
ld b, a
inc b
ld a, 1
plotPoint_loop:
rrca
djnz plotPoint_loop
ld b, a
ld a, (hl)
or b
ld (hl), a
plotPoint_end:
END ASM
END SUB
Using screen address tables shaves this down to 6.42 seconds for 50,000 points plotted. That's not too bad, all told.
(screentables.asm is available elsewhere in the forum, I promise!)
Considering that quite a few routines can use the screen lookup tables, 512 bytes of screen tables isn't crazy for a solid speedup (and of course, if you are using a shadow screen, then you could either rewrite a bit, or make screen tables that point to your shadow screen memory).
Not sure requiring rotate tables, which is much bigger, is a win, here for one loop removal.