SHOW:
|
|
- or go back to the newest paste.
| 1 | p_VLine: | |
| 2 | .db __VLineEnd-$-1 | |
| 3 | ld de,plotSScreen | |
| 4 | x_VLineEntry: | |
| 5 | ||
| 6 | ;; de=buff, l=y2, (sp)=ret, (sp+2)=y1, (sp+4)=x | |
| 7 | ;; Rearrange stuff | |
| 8 | ld a,l | |
| 9 | pop hl | |
| 10 | pop bc | |
| 11 | ex (sp),hl | |
| 12 | ||
| 13 | ;; a=y2, c=y1, de=buff, l=x | |
| 14 | - | ;; Check if y1 is offscreen top while calculating y1*2; if so, note and fix it |
| 14 | + | ;; Check if y1 is offscreen top while calculating y1*2; if so, abort if y2 is |
| 15 | ;; too, then fix it | |
| 16 | ld h,0 | |
| 17 | - | jr nc,$+3 |
| 17 | + | |
| 18 | jr nc,$+5 | |
| 19 | or a | |
| 20 | ret m | |
| 21 | - | ;; Check if y2 is offscreen top while calculating y2*2; if so, abort if y1 was |
| 21 | + | |
| 22 | ||
| 23 | - | rla |
| 23 | + | |
| 24 | ;; Check if y2 is offscreen top while calculating y2*2; if so, fix it | |
| 25 | add a,a | |
| 26 | jr nc,$+5 | |
| 27 | ld a,h | |
| 28 | ||
| 29 | ;; a=top-fixed y2*2, c=top-fixed y1*2, de=buff, h=0, l=x | |
| 30 | ;; Check that y2>=y1; if not, swap y1 and y2 | |
| 31 | cp c | |
| 32 | jr nc,$+5 | |
| 33 | ld b,c | |
| 34 | ld c,a | |
| 35 | ld a,b | |
| 36 | ||
| 37 | ;; y1 is now guaranteed to be <=y2 | |
| 38 | ;; a=top-fixed y2*2, c=top-fixed y1*2, de=buff, h=0, l=x | |
| 39 | ;; Check if y1 is offscreen bottom while calculating y1*4; if so, abort | |
| 40 | sla c | |
| 41 | ret c | |
| 42 | ||
| 43 | ;; a=top-fixed y2*2, c=fixed y1*4, de=buff, h=0, l=x | |
| 44 | ;; Check if y2 is offscreen bottom while calculating y2*4; if so, fix it | |
| 45 | add a,a | |
| 46 | jr nc,$+4 | |
| 47 | - | ld a,63 |
| 47 | + | ld a,63*4 |
| 48 | ||
| 49 | ;; Y Clipping complete; y1 and y2 guaranteed to be onscreen | |
| 50 | ;; a=y2*4, c=y1*4, de=buff, h=0, l=x | |
| 51 | ;; Calculate the height of the line | |
| 52 | sub c | |
| 53 | rra | |
| 54 | rra | |
| 55 | inc a | |
| 56 | ld b,a | |
| 57 | ||
| 58 | ;; y2 no longer needed | |
| 59 | ;; a=height, b=height, c=y1*4, de=buff, h=0, l=x | |
| 60 | ;; Calculate x1/8 and add it and y*12 to the buffer pointer | |
| 61 | ex de,hl | |
| 62 | ld a,e | |
| 63 | ld e,c | |
| 64 | ld c,a | |
| 65 | add hl,de | |
| 66 | rra | |
| 67 | add hl,de | |
| 68 | rra | |
| 69 | add hl,de | |
| 70 | rra | |
| 71 | ld e,a | |
| 72 | add hl,de | |
| 73 | ||
| 74 | ||
| 75 | ;; y1 no longer needed | |
| 76 | ;; a=x/8, b=height, c=x, d=0, e=x/8, hl=y1*12+(x/8)+buff | |
| 77 | ;; Check if x is offscreen; if so, abort | |
| 78 | ld e,12 | |
| 79 | cp e | |
| 80 | ret nc | |
| 81 | ||
| 82 | ;; Begin drawing! | |
| 83 | ;; a=x/8, b=height, c=x, de=12, hl=y1*12+(x/8)+buff | |
| 84 | ;; Calculate the mask | |
| 85 | ld a,c | |
| 86 | or %11111000 | |
| 87 | - | ld c,d |
| 87 | + | ld c,$80 |
| 88 | - | scf |
| 88 | + | |
| 89 | rlc c | |
| 90 | - | rl c |
| 90 | + | |
| 91 | jr nz,__VLineMaskLoop | |
| 92 | ||
| 93 | ||
| 94 | ;; a=0, b=height, c=mask, de=12, hl=y1*12+(x/8)+buff | |
| 95 | ;; Draw the line | |
| 96 | __VLineLoop: | |
| 97 | ld a,(hl) | |
| 98 | or c | |
| 99 | ld (hl),a | |
| 100 | add hl,de | |
| 101 | djnz __VLineLoop | |
| 102 | ||
| 103 | ret | |
| 104 | __VLineEnd: |