Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p_HorizLine:
- .db __HorizLineEnd-$-1
- ld de,plotSScreen
- x_HorizLineEntry:
- ;; de=buff, hl=x2, (sp)=ret, (sp+2)=x1, (sp+4)=y
- pop af
- pop bc
- ld h,c
- pop bc
- push af
- ;; c=y, de=buff, h=x1, l=x2
- ;; Check if x1 is offscreen left; if so, note and fix it
- ld b,0
- ld a,h
- rla
- jr nc,$+3
- ld h,b
- ;; carry=x1 offscreen, b=0, c=y, de=buff, h=left-fixed x1, l=x2
- ;; Check if x2 is offscreen left; if so, abort if x1 was too, then fix it
- bit 7,l
- jr z,$+4
- ret c
- ld l,b
- ;; b=0, c=y, de=buff, h=left-fixed x1, l=left-fixed x2
- ;; Check if x1 is offscreen right, and if so, abort if x2 is too, then fix it
- ld a,95
- cp h
- jr nc,$+5
- cp l
- ret nc
- ld h,a
- ;; a=95, b=0, c=y, de=buff, h=fixed x1, l=left-fixed x2
- ;; Check if x2 is offscreen right, and if so, fix it
- cp l
- jr nc,$+3
- ld l,a
- ;; X Clipping complete; x1 and x2 guaranteed to be onscreen
- ;; a=95, b=0, c=y, de=buff, h=x1, l=x2
- ;; Ensure that x1<=x2
- ld a,h
- cp l
- jr c,$+5
- ld a,l
- ld l,h
- ld h,a
- x_HorizLineEntry2:
- ;; a=x1, b=0, c=y, de=buff, h=x1, l=x2
- ;; Abort if y is offscreen, add y*12 to buffer, and add x1/8 to buffer
- ;; y is rotated left while x1 is rotated right so rra can be used for x1
- sla c
- ret c
- rra
- sla c
- ret c
- rra
- ex de,hl
- add hl,bc
- rra
- add hl,bc
- add hl,bc
- ld c,a
- add hl,bc
- ;; y no longer needed
- ;; a=x1/8, b=0, c=x1/8, d=x1, e=x2, hl=y*12+(x/8)+buff
- ld c,7
- ld a,d
- and c
- jr z,__HorizLineLeft8
- ld b,a
- ld a,1
- __HorizLineLeftLoop:
- rrca
- djnz __HorizLineFirstLoop
- __HorizLineLeft8:
- dec a
- or (hl)
- ld b,a
- ld a,d
- or c
- inc c
- sub e
- jr c,__HorizLineRight ;???
- __HorizLineMidLoop:
- ld (hl),b
- inc hl
- ld b,$FF
- sub c
- jr nc,__HorizLineMidLoop
- __HorizLineRight:
- add a,c ;???
- ret z ;???
- ld b,a
- ld a,1
- __HorizLineRightLoop:
- rlca
- djnz __HorizLineRightLoop
- dec a
- and b
- or (hl)
- ld (hl),a
- ret
- __HorizLineEnd:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement