Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- p_VLine:
- .db __VLineEnd-$-1
- ld de,plotSScreen
- x_VLineEntry:
- ;; de=buff, l=y2, (sp)=ret, (sp+2)=y1, (sp+4)=x
- ;; Rearrange stuff
- ld a,l
- pop hl
- pop bc
- ex (sp),hl
- ;; a=y2, c=y1, de=buff, l=x
- ;; Check if y1 is offscreen top; if so, note and fix it
- ld h,0
- sla c
- jr nc,$+3
- ld c,h
- ;; carry=y1 offscreen, a=y2, c=top-fixed y1, de=buff, h=0, l=x
- ;; Check if y2 is offscreen top; if so, abort if y1 was too, then fix it
- rla
- jr nc,$+5
- rra
- ret c
- ld a,h
- ;; y1 is now guaranteed to be <=y2
- ;; a=top-fixed y2, c=top-fixed y1, de=buff, h=0, l=x
- ;; Check that y2>=y1; if not, swap y1 and y2
- cp c
- jr nc,$+5
- ld b,c
- ld c,a
- ld a,b
- ;; a=top-fixed y2, c=top-fixed y1, de=buff, h=0, l=x
- ;; Check if y1 is offscreen bottom; if so, abort
- sla c
- ret c
- ld c,a
- ;; a=top-fixed y2, c=fixed y1, de=buff, h=0, l=x
- ;; Check if y2 is offscreen bottom; if so, fix it
- rla
- jr nc,$+4
- ld a,63
- ;; Y Clipping complete; y1 and y2 guaranteed to be onscreen
- ;; a=y2, c=y1, de=buff, h=0, l=x
- ;; Calculate the height of the line
- sub c
- rra
- rra
- inc a
- ld b,a
- ;; y2 no longer needed
- ;; a=height, b=height, c=y1, de=buff, h=0, l=x
- ;; Calculate x1/8 and add it and y*12 to the buffer pointer
- ex de,hl
- ld a,e
- ld e,c
- ld c,a
- add hl,de
- rra
- add hl,de
- rra
- add hl,de
- rra
- ld e,a
- add hl,de
- ;; a=x/8, b=height, c=x, d=0, e=x/8, hl=y1*12+(x/8)+buff
- ;; Check if x is offscreen; if so, abort
- ld e,12
- cp e
- ret nc
- ;; Begin drawing!
- ;; a=x/8, b=height, c=x, de=12, hl=y1*12+(x/8)+buff
- ;; Calculate the mask
- ld a,c
- or %11111000
- ld c,d
- scf
- __VLineMaskLoop:
- rl c
- inc a
- jr nz,__VLineMaskLoop
- ;; a=0, b=height, c=mask, de=12, hl=y1*12+(x/8)+buff
- ;; Draw the line
- __VLineLoop:
- ld a,(hl)
- or c
- ld (hl),a
- add hl,de
- djnz __VLineLoop
- ret
- __VLineEnd:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement