Jump to: navigation, search

Programming:Fast plot

1,112 bytes added, 05:12, 24 August 2006
RET ;done
== Fast plotting routine for MODE 0 ==
Converted from the above by [[User:Executioner|The Executioner]]
'''Input:''' DE = ''X (0..159)'', HL = ''Y (0..199)''
CMASK EQU &B338 ;Adress for colormask
;664/6128: &B6A3
FPLOT LD A, L ;A = Lowbyte Y
AND %00000111 ;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
SRL D ;calculate X\2, because
RR E ;2 pixel per byte, Carry is X MOD 2
LD C, %10101010 ;Bitmask for MODE 1
JR NC, NSHIFT ;-> = 0, no shift
SHIFT LD C, %01010101 ;other bitmask for right pixel
NSHIFT ADD HL, DE ;+ HL = Screenaddress
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
NOTE: This MODE 1 code won't assemble with WinAPE/Maxam unless the &X is replaced by % to denote binary numbers.