1,160 bytes added,
18:51, 20 August 2006 == Fast plotting routine for MODE 1 ==
This routine is approx. 6 times faster than the OS routine GRA PLOT, because it is dpendent to MODE 1 and doesn't perform range checks. It can draw 10500 pixels per second.
'''Input:''' DE = ''X (0..319)'', HL = ''Y (0..199)''
<pre>
CMASK EQU &B338 ;Adress for colormask
;664/6128: &B6A3
FPLOT LD A, L ;A = Lowbyte Y
AND &X00000111 ;isolate Bit 0..2
LD H, A ;= y MOD 8 to H
XOR L ;A = Bit 3..7 of Y
LD L, A ;= (Y\8)*8 to L
LD C, A ;store in C
LD B, &60 ;B = &C0\2 = Highbyte Screenstart\2
ADD HL, HL ;HL * 2
ADD HL, HL ;HL * 4
ADD HL, BC ;+ BC = Startaddress
ADD HL, HL ;of the raster line
LD A, E ;Lowbyte X to A
SRL D ;calculate X\4, because
RR E ;4 pixel per byte
SRL E
ADD HL, DE ;+ HL = Screenaddress
LD C, &X10001000 ;Bitmask for MODE 1
AND &X00000011 ;A = X MOD 4
JR Z, NSHIFT ;-> = 0, no shift
LD B, A ;loop counter
SHIFT SRL C ;move bitmask to pixel
DJNZ SHIFT ;-position
NSHIFT LD A, (CMASK) ;get color mask
XOR (HL) ;XOR screenbyte
AND C ;AND bitmask
XOR (HL) ;XOR screenbyte
LD (HL), A ;new screenbyte
RET ;done
</pre>