|
| 1 | +; -------------------------------------------------------------------------- |
| 2 | +; UpdateObjects4 assembly code provided by RevEng (Mike Saarna) |
| 3 | +; (Use this assembly file if you're using 4 byte sprites. If not, then use) |
| 4 | +; the UpdateObjects assembly file instead.) |
| 5 | +; |
| 6 | +; allows enabling, disabling, setting palette, or graphic for any object |
| 7 | +; in the display lists, given the zone number (Y) and the number of the |
| 8 | +; object in that zone. (X) |
| 9 | +; |
| 10 | +; updated 20200529 - clean-up for release, renaming and changing of routines |
| 11 | +; to macros, support for different zone heights in DisableObject and |
| 12 | +; EnableObject. Addition of SetObjectX and SetObjectY macros. |
| 13 | +; |
| 14 | +; updated 20200301 - Update to support full extended screen height, and up |
| 15 | +; to 40 objects in the zone. Extend the x4table if you need more objects, |
| 16 | +; but really, Maria won't be able to likely draw more than 40. |
| 17 | +; -------------------------------------------------------------------------- |
| 18 | + |
| 19 | + |
| 20 | + ; DisableObject - X=object_X Y=object_Y |
| 21 | + MAC DisableObject |
| 22 | + jsr SetObjectPointer |
| 23 | + ldy #2 ; High Address of graphics |
| 24 | + lda (temp1),y |
| 25 | + if WZONEHEIGHT = 8 |
| 26 | + ora #%00001000 |
| 27 | + endif |
| 28 | + if WZONEHEIGHT = 16 |
| 29 | + ora #%00010000 |
| 30 | + endif |
| 31 | + sta (temp1),y |
| 32 | + ENDM |
| 33 | + |
| 34 | + |
| 35 | + ; EnableObject - X=object_X Y=object_Y |
| 36 | + MAC EnableObject |
| 37 | + jsr SetObjectPointer |
| 38 | + ldy #2 ; High Address of graphics |
| 39 | + lda (temp1),y |
| 40 | + if WZONEHEIGHT = 8 |
| 41 | + and #%11110111 |
| 42 | + endif |
| 43 | + if WZONEHEIGHT = 16 |
| 44 | + and #%11101111 |
| 45 | + endif |
| 46 | + sta (temp1),y |
| 47 | + ENDM |
| 48 | + |
| 49 | + |
| 50 | + MAC SetObjectPalette |
| 51 | + ; SetObjectPalette - X=object_X Y=object_Y {1}=palette |
| 52 | + jsr SetObjectPointer |
| 53 | + ldy #1 ; palette+width is the 2nd byte in the dl object |
| 54 | + lda (temp1),y |
| 55 | + and #%00011111 |
| 56 | + ldx {1} |
| 57 | + ora x32table,x |
| 58 | + sta (temp1),y |
| 59 | + ENDM |
| 60 | + |
| 61 | + |
| 62 | + MAC SetObjectX |
| 63 | + ; SetObjectX - X=object_X Y=object_Y {1}=X-coordinate |
| 64 | + jsr SetObjectPointer |
| 65 | + ldy #3 ; object x-coordinate is the 4th byte in the dl object |
| 66 | + lda {1} |
| 67 | + sta (temp1),y |
| 68 | + ENDM |
| 69 | + |
| 70 | + |
| 71 | + ; SetObjectY - X=object_X Y=object_Y {1}=y coordinate in zone |
| 72 | + MAC SetObjectY |
| 73 | + jsr SetObjectPointer |
| 74 | + ldy #2 ; High Address of graphics |
| 75 | + lda (temp1),y |
| 76 | + if WZONEHEIGHT = 8 |
| 77 | + and #%11111000 |
| 78 | + endif |
| 79 | + if WZONEHEIGHT = 16 |
| 80 | + and #%11110000 |
| 81 | + endif |
| 82 | + ora {1} |
| 83 | + sta (temp1),y |
| 84 | + ENDM |
| 85 | + |
| 86 | + |
| 87 | + MAC SetObjectImageLo |
| 88 | + ; SetObjectImageLo - X=object_X Y=object_Y {1}=index in gfx block |
| 89 | + jsr SetObjectPointer |
| 90 | + ldy #0 ; low address of gfx is the 1st byte in the dl object |
| 91 | + lda {1} |
| 92 | + sta (temp1),y |
| 93 | + ENDM |
| 94 | + |
| 95 | + |
| 96 | + ; SetObjectImage - X=object_X Y=object_Y {1}=gfx_label |
| 97 | + MAC SetObjectImage |
| 98 | + jsr SetObjectPointer |
| 99 | + ldy #0 ; lo Address of graphics |
| 100 | + lda #<{1} |
| 101 | + sta (temp1),y |
| 102 | + ldy #2 ; hi Address of graphics |
| 103 | + lda #>{1} |
| 104 | + sta (temp1),y |
| 105 | + ENDM |
| 106 | + |
| 107 | + ; ********* utility functions and structures follow ********* |
| 108 | + |
| 109 | + jmp UpdateObjectsEnd |
| 110 | + |
| 111 | +SetObjectPointer ; called with X=object_X Y=object_Y |
| 112 | + clc |
| 113 | + lda ZONESTARTLO,y |
| 114 | + adc x4table,x |
| 115 | + sta temp1 |
| 116 | + lda ZONESTARTHI,y |
| 117 | + adc #0 |
| 118 | + sta temp2 |
| 119 | + rts |
| 120 | + |
| 121 | +x4table ; enough entries to support 40 objects per dl |
| 122 | +MULT4IDX SET 0 |
| 123 | + REPEAT 40 |
| 124 | + .byte MULT4IDX |
| 125 | +MULT4IDX SET (MULT4IDX+4) |
| 126 | + REPEND |
| 127 | + |
| 128 | +x32table ; 32 multiplaction for palette values |
| 129 | +MULT32IDX SET 0 |
| 130 | + REPEAT 8 |
| 131 | + .byte MULT32IDX |
| 132 | +MULT32IDX SET (MULT32IDX+32) |
| 133 | + REPEND |
| 134 | + |
| 135 | +ZONESTARTLO |
| 136 | + .byte <ZONE0ADDRESS |
| 137 | + .byte <ZONE1ADDRESS |
| 138 | + .byte <ZONE2ADDRESS |
| 139 | + .byte <ZONE3ADDRESS |
| 140 | + .byte <ZONE4ADDRESS |
| 141 | + .byte <ZONE5ADDRESS |
| 142 | + .byte <ZONE6ADDRESS |
| 143 | + .byte <ZONE7ADDRESS |
| 144 | + .byte <ZONE8ADDRESS |
| 145 | + .byte <ZONE9ADDRESS |
| 146 | + .byte <ZONE10ADDRESS |
| 147 | + .byte <ZONE11ADDRESS |
| 148 | + ifconst ZONE12ADDRESS |
| 149 | + .byte <ZONE12ADDRESS |
| 150 | + endif |
| 151 | + ifconst ZONE13ADDRESS |
| 152 | + .byte <ZONE13ADDRESS |
| 153 | + endif |
| 154 | + ifconst ZONE14ADDRESS |
| 155 | + .byte <ZONE14ADDRESS |
| 156 | + endif |
| 157 | + ifconst ZONE15ADDRESS |
| 158 | + .byte <ZONE15ADDRESS |
| 159 | + endif |
| 160 | + ifconst ZONE16ADDRESS |
| 161 | + .byte <ZONE16ADDRESS |
| 162 | + endif |
| 163 | + ifconst ZONE17ADDRESS |
| 164 | + .byte <ZONE17ADDRESS |
| 165 | + endif |
| 166 | + ifconst ZONE18ADDRESS |
| 167 | + .byte <ZONE18ADDRESS |
| 168 | + endif |
| 169 | + ifconst ZONE19ADDRESS |
| 170 | + .byte <ZONE19ADDRESS |
| 171 | + endif |
| 172 | + ifconst ZONE20ADDRESS |
| 173 | + .byte <ZONE20ADDRESS |
| 174 | + endif |
| 175 | + ifconst ZONE21ADDRESS |
| 176 | + .byte <ZONE21ADDRESS |
| 177 | + endif |
| 178 | + ifconst ZONE22ADDRESS |
| 179 | + .byte <ZONE22ADDRESS |
| 180 | + endif |
| 181 | + ifconst ZONE23ADDRESS |
| 182 | + .byte <ZONE23ADDRESS |
| 183 | + endif |
| 184 | + ifconst ZONE24ADDRESS |
| 185 | + .byte <ZONE24ADDRESS |
| 186 | + endif |
| 187 | + ifconst ZONE25ADDRESS |
| 188 | + .byte <ZONE25ADDRESS |
| 189 | + endif |
| 190 | + ifconst ZONE26ADDRESS |
| 191 | + .byte <ZONE26ADDRESS |
| 192 | + endif |
| 193 | + ifconst ZONE27ADDRESS |
| 194 | + .byte <ZONE27ADDRESS |
| 195 | + endif |
| 196 | + |
| 197 | +ZONESTARTHI |
| 198 | + .byte >ZONE0ADDRESS |
| 199 | + .byte >ZONE1ADDRESS |
| 200 | + .byte >ZONE2ADDRESS |
| 201 | + .byte >ZONE3ADDRESS |
| 202 | + .byte >ZONE4ADDRESS |
| 203 | + .byte >ZONE5ADDRESS |
| 204 | + .byte >ZONE6ADDRESS |
| 205 | + .byte >ZONE7ADDRESS |
| 206 | + .byte >ZONE8ADDRESS |
| 207 | + .byte >ZONE9ADDRESS |
| 208 | + .byte >ZONE10ADDRESS |
| 209 | + .byte >ZONE11ADDRESS |
| 210 | + ifconst ZONE12ADDRESS |
| 211 | + .byte >ZONE12ADDRESS |
| 212 | + endif |
| 213 | + ifconst ZONE13ADDRESS |
| 214 | + .byte >ZONE13ADDRESS |
| 215 | + endif |
| 216 | + ifconst ZONE14ADDRESS |
| 217 | + .byte >ZONE14ADDRESS |
| 218 | + endif |
| 219 | + ifconst ZONE15ADDRESS |
| 220 | + .byte >ZONE15ADDRESS |
| 221 | + endif |
| 222 | + ifconst ZONE16ADDRESS |
| 223 | + .byte >ZONE16ADDRESS |
| 224 | + endif |
| 225 | + ifconst ZONE17ADDRESS |
| 226 | + .byte >ZONE17ADDRESS |
| 227 | + endif |
| 228 | + ifconst ZONE18ADDRESS |
| 229 | + .byte >ZONE18ADDRESS |
| 230 | + endif |
| 231 | + ifconst ZONE19ADDRESS |
| 232 | + .byte >ZONE19ADDRESS |
| 233 | + endif |
| 234 | + ifconst ZONE20ADDRESS |
| 235 | + .byte >ZONE20ADDRESS |
| 236 | + endif |
| 237 | + ifconst ZONE21ADDRESS |
| 238 | + .byte >ZONE21ADDRESS |
| 239 | + endif |
| 240 | + ifconst ZONE22ADDRESS |
| 241 | + .byte >ZONE22ADDRESS |
| 242 | + endif |
| 243 | + ifconst ZONE23ADDRESS |
| 244 | + .byte >ZONE23ADDRESS |
| 245 | + endif |
| 246 | + ifconst ZONE24ADDRESS |
| 247 | + .byte >ZONE24ADDRESS |
| 248 | + endif |
| 249 | + ifconst ZONE25ADDRESS |
| 250 | + .byte >ZONE25ADDRESS |
| 251 | + endif |
| 252 | + ifconst ZONE26ADDRESS |
| 253 | + .byte >ZONE26ADDRESS |
| 254 | + endif |
| 255 | + ifconst ZONE27ADDRESS |
| 256 | + .byte >ZONE27ADDRESS |
| 257 | + endif |
| 258 | + |
| 259 | +UpdateObjectsEnd |
0 commit comments