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 |
| 6 | + | ld hl,31 |
| 7 | push hl | |
| 8 | push hl | |
| 9 | push bc | |
| 10 | - | ld hl,14 |
| 10 | + | ld hl,31 |
| 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 | dec a | |
| 60 | sub (ix+_y) | |
| 61 | jp c,End | |
| 62 | ld a,(err) | |
| 63 | inc (ix+_y) | |
| 64 | add a,(ix+_y) | |
| 65 | ;inc (ix+_y) | |
| 66 | add a,(ix+_y) | |
| 67 | ld (err),a | |
| 68 | bit 7,a | |
| 69 | - | ;draw chunks |
| 69 | + | |
| 70 | ;draw chunks | |
| 71 | call DrawLChunk | |
| 72 | bcall(_grBufCpy) | |
| 73 | call DrawRChunk | |
| 74 | bcall(_grBufCpy) | |
| 75 | ;change left mask | |
| 76 | ld a,(lmask) | |
| 77 | rlca | |
| 78 | jr nc,+_ | |
| 79 | ld a,%00000001 | |
| 80 | ld (lmask),a | |
| 81 | inc (ix+_off) | |
| 82 | ld hl,(ptr) | |
| 83 | dec hl | |
| 84 | ld (ptr),hl | |
| 85 | jr ++_ | |
| 86 | _: | |
| 87 | ld b,a | |
| 88 | ld a,(lmask) | |
| 89 | cpl | |
| 90 | and b | |
| 91 | ld (lmask),a | |
| 92 | _: ;change right mask | |
| 93 | ld a,(rmask) | |
| 94 | rrca | |
| 95 | jr nc,+_ | |
| 96 | ld a,%10000000 | |
| 97 | inc (ix+_off) | |
| 98 | ld (rmask),a | |
| 99 | jr ++_ | |
| 100 | _: | |
| 101 | ld b,a | |
| 102 | ld a,(rmask) | |
| 103 | cpl | |
| 104 | and b | |
| 105 | ld (rmask),a | |
| 106 | _: | |
| 107 | ld a,(x) | |
| 108 | dec a | |
| 109 | sub (ix+_y) | |
| 110 | - | ;draw left vertical |
| 110 | + | |
| 111 | ;draw left vertical | |
| 112 | ld a,(cy) | |
| 113 | sub (ix+_y) | |
| 114 | ld l,a | |
| 115 | ld a,(y) | |
| 116 | add a,a | |
| 117 | inc a | |
| 118 | ld d,a | |
| 119 | ld a,(cx) | |
| 120 | sub (ix+_x) | |
| 121 | call GetPtrMask | |
| 122 | ld c,a | |
| 123 | ld b,d | |
| 124 | call DrawVertLoop | |
| 125 | - | ;draw right vertical |
| 125 | + | |
| 126 | ;draw right vertical | |
| 127 | ld a,(cy) | |
| 128 | sub (ix+_y) | |
| 129 | ld l,a | |
| 130 | ld a,(y) | |
| 131 | add a,a | |
| 132 | inc a | |
| 133 | ld d,a | |
| 134 | ld a,(cx) | |
| 135 | add a,(ix+_x) | |
| 136 | call GetPtrMask | |
| 137 | ld c,a | |
| 138 | ld b,d | |
| 139 | call DrawVertLoop | |
| 140 | bcall(_grBufCpy) | |
| 141 | ;sub x | |
| 142 | ld a,(err) | |
| 143 | ;dec (ix+_x) | |
| 144 | sub (ix+_x) | |
| 145 | dec (ix+_x) | |
| 146 | sub (ix+_x) | |
| 147 | ld (err),a | |
| 148 | ld hl,(ptr) | |
| 149 | ld de,12 | |
| 150 | add hl,de | |
| 151 | ld (ptr),hl | |
| 152 | jp SkipRotate | |
| 153 | End: | |
| 154 | ei | |
| 155 | ret | |
| 156 | ||
| 157 | GetPtrMask: | |
| 158 | ld h,0 | |
| 159 | ld b,h | |
| 160 | ld c,l | |
| 161 | add hl,hl | |
| 162 | add hl,bc | |
| 163 | add hl,hl | |
| 164 | add hl,hl | |
| 165 | ld c,a | |
| 166 | srl c | |
| 167 | srl c | |
| 168 | srl c | |
| 169 | add hl,bc | |
| 170 | ld bc,plotsscreen | |
| 171 | add hl,bc | |
| 172 | and 7 | |
| 173 | ld b,a | |
| 174 | ld a,$80 | |
| 175 | ret z | |
| 176 | _: | |
| 177 | rrca | |
| 178 | djnz -_ | |
| 179 | ret | |
| 180 | ||
| 181 | ||
| 182 | RotLMask: | |
| 183 | ld a,(lmask) | |
| 184 | rlca | |
| 185 | jr nc,+_ | |
| 186 | call DrawLChunk | |
| 187 | ld a,%00000001 | |
| 188 | ld (lmask),a | |
| 189 | ld hl,(ptr) | |
| 190 | dec hl | |
| 191 | ld (ptr),hl | |
| 192 | inc (ix+_off) | |
| 193 | ret | |
| 194 | _: | |
| 195 | ld hl,lmask | |
| 196 | or (hl) | |
| 197 | ld (hl),a | |
| 198 | ret | |
| 199 | ||
| 200 | DrawLChunk: | |
| 201 | ld c,(ix+_lmask) | |
| 202 | ld a,(off) | |
| 203 | or a | |
| 204 | jr nz,+_ | |
| 205 | ld a,(rmask) | |
| 206 | and c | |
| 207 | xor c | |
| 208 | ld c,a | |
| 209 | _: | |
| 210 | ld hl,(ptr) | |
| 211 | ld a,(x) | |
| 212 | add a,a | |
| 213 | inc a | |
| 214 | ld b,a | |
| 215 | jp DrawVertLoop | |
| 216 | ret | |
| 217 | ||
| 218 | RotRMask: | |
| 219 | ld a,(rmask) | |
| 220 | rrca | |
| 221 | jr nc,+_ | |
| 222 | call DrawRChunk | |
| 223 | ld a,%10000000 | |
| 224 | ld (rmask),a | |
| 225 | inc (ix+_off) | |
| 226 | ret | |
| 227 | _: | |
| 228 | ld hl,rmask | |
| 229 | or (hl) | |
| 230 | ld (hl),a | |
| 231 | ret | |
| 232 | ||
| 233 | DrawRChunk: | |
| 234 | ld c,(ix+_rmask) | |
| 235 | ld a,(off) | |
| 236 | or a | |
| 237 | jr nz,+_ | |
| 238 | ld a,(lmask) | |
| 239 | and c | |
| 240 | xor (ix+_lmask) | |
| 241 | ld (lmask),a | |
| 242 | _: | |
| 243 | ld hl,(ptr) | |
| 244 | ld e,(ix+_off) | |
| 245 | ld d,0 | |
| 246 | add hl,de | |
| 247 | ld a,(x) | |
| 248 | add a,a | |
| 249 | inc a | |
| 250 | ld b,a | |
| 251 | jp DrawVertLoop | |
| 252 | ||
| 253 | DrawVertLoop: | |
| 254 | ;in: B = height, C=mask, HL = pointer | |
| 255 | ;destroys: A, B, DE, HL | |
| 256 | ld de,12 | |
| 257 | _: | |
| 258 | ld a,(hl) | |
| 259 | xor c | |
| 260 | ld (hl), a | |
| 261 | add hl,de | |
| 262 | djnz -_ | |
| 263 | ret | |
| 264 | ||
| 265 | ||
| 266 | ||
| 267 | cx: | |
| 268 | .db 0 | |
| 269 | cy: | |
| 270 | .db 0 | |
| 271 | x: | |
| 272 | .db 0 | |
| 273 | y: | |
| 274 | .db 0 | |
| 275 | err: | |
| 276 | .db 0 | |
| 277 | rmask: | |
| 278 | .db 0 | |
| 279 | lmask: | |
| 280 | .db 0 | |
| 281 | off: | |
| 282 | .db 0 | |
| 283 | ptr: | |
| 284 | .dw 0 |