![]() |
Routines |
Prev: 26222 | Up: Map |
|
||||||||||||||||
26224 | PUSH AF | Save the sniper's animatory state | ||||||||||||||
26225 | LD A,D | A=sniper's next y-coordinate (34-37) | ||||||||||||||
26226 | EXX | |||||||||||||||
26227 | PUSH AF | Save the sniper's next y-coordinate | ||||||||||||||
26228 | LD C,3 | There are three columns in the sniper's sprite | ||||||||||||||
26230 | SUB 33 | E'=1 (sniper is at full height), 2 (sniper is at half-height), 3 (only the sniper's head is visible), or 4 (the sniper has ducked out of sight) | ||||||||||||||
26232 | LD E,A | |||||||||||||||
26233 | CPL | D'=5-E' (number of rows of the sniper's sprite that will be filled with non-blank tiles) | ||||||||||||||
26234 | ADD A,6 | |||||||||||||||
26236 | LD D,A | |||||||||||||||
The next section of code modifies the sprite tile references for animatory states 54/182 column by column.
|
||||||||||||||||
26237 | LD H,215 | 215 is the base page for sprite tile references | ||||||||||||||
26239 | LD B,D | B=number of non-blank tiles to initialise in this column | ||||||||||||||
26240 | LD L,162 | Animatory state 162 (gangster) will be used as a template for the sniper's sprite | ||||||||||||||
26242 | LD A,(HL) | Collect a sprite tile reference from the template | ||||||||||||||
26243 | LD L,182 | Copy the sprite tile reference into place | ||||||||||||||
26245 | LD (HL),A | |||||||||||||||
26246 | INC H | Move down a row | ||||||||||||||
26247 | DJNZ 26240 | Jump back until all non-blank rows in this column have been done | ||||||||||||||
26249 | LD A,E | A=number of blank rows in the sniper's sprite (1-4) | ||||||||||||||
26250 | AND A | Are there any? | ||||||||||||||
26251 | JR Z,26259 | Jump if not (this jump is never made) | ||||||||||||||
26253 | LD B,E | Fill the remaining slots in this column with blank tiles | ||||||||||||||
26254 | LD (HL),0 | |||||||||||||||
26256 | INC H | |||||||||||||||
26257 | DJNZ 26254 | |||||||||||||||
26259 | DEC C | Have we done all three columns yet? | ||||||||||||||
26260 | JR NZ,26239 | Jump back if not | ||||||||||||||
26262 | POP AF | Restore the sniper's next y-coordinate (34-37) to A | ||||||||||||||
26263 | JR NC,26323 | Jump unless the sniper is firing | ||||||||||||||
The sniper is firing, so some further modifications to the sniper's sprite are required.
|
||||||||||||||||
26265 | LD H,217 | Set the reference for tile 2 to 234 | ||||||||||||||
26267 | LD (HL),234 | |||||||||||||||
26269 | INC H | Set the reference for tile 3 to 0 (blank tile) | ||||||||||||||
26270 | LD (HL),0 | |||||||||||||||
26272 | LD H,222 | Set the reference for tile 7 to 235 | ||||||||||||||
26274 | LD (HL),235 | |||||||||||||||
Now we initialise a bullet.
|
||||||||||||||||
26276 | LD HL,32706 | Point HL' at the third byte of bullet buffer 1 (at 32704) | ||||||||||||||
26279 | SUB 18 | D=16 or 17 (bullet's initial screen y-coordinate) | ||||||||||||||
26281 | LD D,A | |||||||||||||||
26282 | LD A,(HL) | Is bullet buffer 1 at 32704 already being used? | ||||||||||||||
26283 | AND A | |||||||||||||||
26284 | JR Z,26288 | Jump if not | ||||||||||||||
26286 | LD L,198 | Point HL' at the third byte of bullet buffer 2 | ||||||||||||||
26288 | LD (HL),D | Store the bullet's initial screen y-coordinate | ||||||||||||||
26289 | LD A,(32766) | A=x-coordinate of the leftmost column of the play area on screen | ||||||||||||||
26292 | LD B,A | Copy this to B' | ||||||||||||||
26293 | INC L | Point HL' at the fourth byte of the bullet buffer | ||||||||||||||
26294 | CALL 61823 | Get a random number in A | ||||||||||||||
26297 | AND 112 | Keep only bits 4-6 | ||||||||||||||
26299 | ADD A,4 | The initial pixel row at which the bullet will be drawn inside a cell is 4 | ||||||||||||||
26301 | LD (HL),A | Initialise bits 0-6 of the fourth byte of the bullet buffer | ||||||||||||||
26302 | POP AF | Restore the sniper's animatory state to A | ||||||||||||||
26303 | PUSH AF | Save the animatory state again | ||||||||||||||
26304 | AND 128 | Keep only bit 7 (the direction bit) | ||||||||||||||
26306 | OR (HL) | Initialise bit 7 of the fourth byte of the bullet buffer (the bullet's direction bit) | ||||||||||||||
26307 | LD (HL),A | |||||||||||||||
26308 | DEC L | Store the x-coordinate of the leftmost column of the play area on screen in the first byte of the bullet buffer | ||||||||||||||
26309 | DEC L | |||||||||||||||
26310 | DEC L | |||||||||||||||
26311 | LD (HL),B | |||||||||||||||
26312 | INC L | Point HL' at the second byte of the bullet buffer | ||||||||||||||
26313 | EXX | |||||||||||||||
26314 | RLCA | Set the carry flag if the sniper is facing right | ||||||||||||||
26315 | LD A,E | A=sniper's x-coordinate | ||||||||||||||
26316 | EXX | |||||||||||||||
26317 | JR NC,26321 | Jump if the sniper is facing left | ||||||||||||||
26319 | INC A | Add 2 to the sniper's x-coordinate | ||||||||||||||
26320 | INC A | |||||||||||||||
26321 | SUB B | Subtract the x-coordinate of the leftmost column of the play area on screen to obtain the bullet's initial screen x-coordinate | ||||||||||||||
26322 | LD (HL),A | Store this in the second byte of the bullet buffer | ||||||||||||||
26323 | EXX | |||||||||||||||
26324 | POP AF | Restore the sniper's animatory state to A | ||||||||||||||
26325 | JP 59861 | Update the sniper's animatory state and location and update the SRB |
Prev: 26222 | Up: Map |