Here's the code for that horizontal line drawer I've been working on:
Code:
Currently it'd draw anything that can be drawn in 1 byte of writes.
Code:
xpos .equ appbackupscreen
ypos .equ appbackupscreen+1
len .equ appbackupscreen+2
call ClrScreen
ld ix,xpos
ld (ix),0
ld (ix+1),0
ld (ix+2),8
call HorizLine
bcall(_GrBufCpy)
ret
;start of horizontal line routine.
;Inputs:
;x location: xpos
;y location: ypos
;Length: len
;Outputs:
;A line, leftmost pixel on (xpos,ypos), length equal to len.
;Need to call _GrBufCpy to actually display the line.
;Destroys:
HorizLine:
ld hl,(ypos)
ld h,0
add hl,hl
add hl,hl
ld d,h
ld e,l
add hl,hl
add hl,de ;HL=ypos*12
ld de,(xpos)
ld a,e ;A=xpos
and %00000111 ;A=xpos%8, the bit we need
srl e
srl e
srl e ;E=xpos//8
ld d,0
add hl,de ;HL=ypos*12+xpos//8, the byte we need
ld de,(len-1) ;Gets (len) into D
add a,d ;Check to see if can be drawn in 1 byte
cp 9
jr nc,HNotInAByte ;a>8
jr c,HInAByte ;a<=8
HInAByte:
sub d ;Get back the original A
ld b,d
ld e,1
HLoop1:
sla e
djnz HLoop1
push af
ld a,e
sub 1
ld e,a
pop af ;E-=1
;After this operation, E has the lower D bits as 1
cpl
add a,9
sub d
or a
jr z,HAIsZero
ld b,a ;B=8-A-D
HLoop2:
sla e
djnz HLoop2
HAIsZero:
ld a,e
ld de,PlotSScreen
add hl,de
ld (hl),a
ret
HNotInAByte:
ret
ClrScreen:
;Clears the screen.
sp_save .equ AppBackupScreen
ld (sp_save),sp
di
ld sp,PlotSScreen+768
ld b,64
ld hl,0
ClrLoop:
push hl
push hl
push hl
push hl
push hl
push hl
push hl
push hl
push hl
push hl
push hl
push hl
djnz ClrLoop
ld sp,(sp_save)
ei
bcall(_GrBufCpy)
ret
Currently it'd draw anything that can be drawn in 1 byte of writes.