SHOW:
|
|
- or go back to the newest paste.
| 1 | #include "ti83plus.inc" | |
| 2 | .org $9d95-2 | |
| 3 | .db $bb,$6d | |
| 4 | bcall(_grbufclr) | |
| 5 | pop bc | |
| 6 | ld hl,25 | |
| 7 | push hl | |
| 8 | push hl | |
| 9 | push bc | |
| 10 | ld hl,14 | |
| 11 | ||
| 12 | _cx .equ 0 | |
| 13 | _cy .equ 1 | |
| 14 | _x .equ 2 | |
| 15 | _y .equ 3 | |
| 16 | _err .equ 4 | |
| 17 | _rmask .equ 5 | |
| 18 | _lmask .equ 6 | |
| 19 | _off .equ 7 | |
| 20 | _ptr .equ 8 | |
| 21 | ||
| 22 | ;############################### | |
| 23 | ;draw filled circle | |
| 24 | FilledCircle: | |
| 25 | di | |
| 26 | ld ix,cx | |
| 27 | ld (ix+_x),l | |
| 28 | xor a | |
| 29 | ld (y),a | |
| 30 | ld (off),a | |
| 31 | sub l | |
| 32 | ld (err),a | |
| 33 | pop hl | |
| 34 | pop bc | |
| 35 | ex (sp),hl | |
| 36 | ld (ix+_cx),c | |
| 37 | ld (ix+_cy),l | |
| 38 | ||
| 39 | ld a,l | |
| 40 | sub (ix+_x) | |
| 41 | jr nc,+_ | |
| 42 | xor a | |
| 43 | _: | |
| 44 | ld l,a | |
| 45 | ld a,c | |
| 46 | ;A=cx, L=cy-x | |
| 47 | call GetPtrMask | |
| 48 | ld (rmask),a | |
| 49 | ld (lmask),a | |
| 50 | ld (ptr),hl | |
| 51 | ||
| 52 | Main: | |
| 53 | call RotLMask | |
| 54 | bcall(_grBufCpy) | |
| 55 | call RotRMask | |
| 56 | bcall(_grBufCpy) | |
| 57 | SkipRotate: | |
| 58 | ld a,(x) | |
| 59 | sub (ix+_y) | |
| 60 | jp c,End | |
| 61 | ld a,(err) | |
| 62 | inc (ix+_y) | |
| 63 | add a,(ix+_y) | |
| 64 | ;inc (ix+_y) | |
| 65 | - | jp nz,_skip |
| 65 | + | |
| 66 | ld (err),a | |
| 67 | bit 7,a | |
| 68 | jp nz,Main | |
| 69 | ;draw chunks | |
| 70 | call DrawLChunk | |
| 71 | bcall(_grBufCpy) | |
| 72 | call DrawRChunk | |
| 73 | - | rla |
| 73 | + | |
| 74 | ;change left mask | |
| 75 | ld a,(lmask) | |
| 76 | rlca | |
| 77 | jr nc,+_ | |
| 78 | ld a,%00000001 | |
| 79 | ld (lmask),a | |
| 80 | inc (ix+_off) | |
| 81 | ld hl,(ptr) | |
| 82 | dec hl | |
| 83 | ld (ptr),hl | |
| 84 | jr ++_ | |
| 85 | _: | |
| 86 | ld b,a | |
| 87 | ld a,(lmask) | |
| 88 | cpl | |
| 89 | and b | |
| 90 | - | rra |
| 90 | + | |
| 91 | _: ;change right mask | |
| 92 | ld a,(rmask) | |
| 93 | rrca | |
| 94 | jr nc,+_ | |
| 95 | ld a,%10000000 | |
| 96 | inc (ix+_off) | |
| 97 | ld (rmask),a | |
| 98 | jr ++_ | |
| 99 | _: | |
| 100 | ld b,a | |
| 101 | ld a,(rmask) | |
| 102 | cpl | |
| 103 | and b | |
| 104 | ld (rmask),a | |
| 105 | _: | |
| 106 | ld a,(x) | |
| 107 | dec a | |
| 108 | sub (ix+_y) | |
| 109 | jp c,End | |
| 110 | ;draw left vertical | |
| 111 | ld a,(cy) | |
| 112 | sub (ix+_y) | |
| 113 | ld l,a | |
| 114 | ld a,(y) | |
| 115 | add a,a | |
| 116 | inc a | |
| 117 | ld d,a | |
| 118 | ld a,(cx) | |
| 119 | sub (ix+_x) | |
| 120 | call GetPtrMask | |
| 121 | ld c,a | |
| 122 | ld b,d | |
| 123 | call DrawVertLoop | |
| 124 | bcall(_grBufCpy) | |
| 125 | ;draw right vertical | |
| 126 | ld a,(cy) | |
| 127 | sub (ix+_y) | |
| 128 | ld l,a | |
| 129 | ld a,(y) | |
| 130 | add a,a | |
| 131 | inc a | |
| 132 | ld d,a | |
| 133 | ld a,(cx) | |
| 134 | add a,(ix+_x) | |
| 135 | call GetPtrMask | |
| 136 | ld c,a | |
| 137 | ld b,d | |
| 138 | call DrawVertLoop | |
| 139 | bcall(_grBufCpy) | |
| 140 | ;sub x | |
| 141 | ld a,(err) | |
| 142 | ;dec (ix+_x) | |
| 143 | sub (ix+_x) | |
| 144 | dec (ix+_x) | |
| 145 | sub (ix+_x) | |
| 146 | - | jp nc,SkipRotate |
| 146 | + | |
| 147 | ld hl,(ptr) | |
| 148 | ld de,12 | |
| 149 | - | _skip: |
| 149 | + | |
| 150 | ld (ptr),hl | |
| 151 | jp SkipRotate | |
| 152 | - | jp nc,Main |
| 152 | + | End: |
| 153 | ei | |
| 154 | ret | |
| 155 | ||
| 156 | GetPtrMask: | |
| 157 | ld h,0 | |
| 158 | ld b,h | |
| 159 | ld c,l | |
| 160 | add hl,hl | |
| 161 | add hl,bc | |
| 162 | add hl,hl | |
| 163 | add hl,hl | |
| 164 | ld c,a | |
| 165 | srl c | |
| 166 | srl c | |
| 167 | srl c | |
| 168 | add hl,bc | |
| 169 | ld bc,plotsscreen | |
| 170 | add hl,bc | |
| 171 | and 7 | |
| 172 | ld b,a | |
| 173 | ld a,$80 | |
| 174 | ret z | |
| 175 | _: | |
| 176 | rrca | |
| 177 | djnz -_ | |
| 178 | ret | |
| 179 | ||
| 180 | ||
| 181 | RotLMask: | |
| 182 | ld a,(lmask) | |
| 183 | - | rla |
| 183 | + | rlca |
| 184 | jr nc,+_ | |
| 185 | call DrawLChunk | |
| 186 | ld a,%00000001 | |
| 187 | ld (lmask),a | |
| 188 | ld hl,(ptr) | |
| 189 | dec hl | |
| 190 | ld (ptr),hl | |
| 191 | inc (ix+_off) | |
| 192 | ret | |
| 193 | _: | |
| 194 | ld hl,lmask | |
| 195 | or (hl) | |
| 196 | ld (hl),a | |
| 197 | ret | |
| 198 | ||
| 199 | DrawLChunk: | |
| 200 | ld c,(ix+_lmask) | |
| 201 | ld a,(off) | |
| 202 | or a | |
| 203 | jr nz,+_ | |
| 204 | ld a,(rmask) | |
| 205 | and c | |
| 206 | xor c | |
| 207 | ld c,a | |
| 208 | _: | |
| 209 | ld hl,(ptr) | |
| 210 | ld a,(x) | |
| 211 | add a,a | |
| 212 | inc a | |
| 213 | ld b,a | |
| 214 | jp DrawVertLoop | |
| 215 | ret | |
| 216 | ||
| 217 | RotRMask: | |
| 218 | ld a,(rmask) | |
| 219 | - | rra |
| 219 | + | |
| 220 | jr nc,+_ | |
| 221 | call DrawRChunk | |
| 222 | ld a,%10000000 | |
| 223 | ld (rmask),a | |
| 224 | inc (ix+_off) | |
| 225 | ret | |
| 226 | _: | |
| 227 | ld hl,rmask | |
| 228 | or (hl) | |
| 229 | ld (hl),a | |
| 230 | ret | |
| 231 | ||
| 232 | DrawRChunk: | |
| 233 | ld c,(ix+_rmask) | |
| 234 | ld hl,(ptr) | |
| 235 | ld e,(ix+_off) | |
| 236 | ld d,0 | |
| 237 | add hl,de | |
| 238 | ld a,(x) | |
| 239 | add a,a | |
| 240 | inc a | |
| 241 | ld b,a | |
| 242 | jp DrawVertLoop | |
| 243 | ||
| 244 | DrawVertLoop: | |
| 245 | ;in: B = height, C=mask, HL = pointer | |
| 246 | ;destroys: A, B, DE, HL | |
| 247 | ld de,12 | |
| 248 | _: | |
| 249 | ld a,(hl) | |
| 250 | xor c | |
| 251 | ld (hl), a | |
| 252 | add hl,de | |
| 253 | djnz -_ | |
| 254 | ret | |
| 255 | ||
| 256 | ||
| 257 | ||
| 258 | cx: | |
| 259 | .db 0 | |
| 260 | cy: | |
| 261 | .db 0 | |
| 262 | x: | |
| 263 | .db 0 | |
| 264 | y: | |
| 265 | .db 0 | |
| 266 | err: | |
| 267 | .db 0 | |
| 268 | rmask: | |
| 269 | .db 0 | |
| 270 | lmask: | |
| 271 | .db 0 | |
| 272 | off: | |
| 273 | .db 0 | |
| 274 | ptr: | |
| 275 | .dw 0 |