![]() |
Routines |
| Prev: 46176 | Up: Map | Next: 46382 |
|
Write 17 type-228 slots from World_Slot_1 using the actor X/Y at DE and ROM bytes addressed by RandomNumber.
|
||||||||
|
Point HL at the first world slot.
|
||||||||
| FillDebrisSlots | 46274 | LD HL,24744 | HL=World_Slot_1. | |||||
| 46277 | LD BC,1809 | Set B to 7 bytes to clear and C to 17 slots. | ||||||
|
Point HL' at ROM using RandomNumber as the low byte.
|
||||||||
| 46280 | EXX | Switch to the shadow registers. | ||||||
| 46281 | LD A,(24128) | Fetch RandomNumber. | ||||||
| 46284 | LD L,A | Copy it into the low byte of HL'. | ||||||
| 46285 | LD H,0 | Clear the high byte of HL'. | ||||||
| 46287 | EXX | Switch back. | ||||||
|
Write type 228 and copy the three-byte X/Y seed.
|
||||||||
| FillDebrisSlots_Loop | 46288 | PUSH BC | Stash the slot counters on the stack. | |||||
| 46289 | LD (HL),228 | Write type 228. | ||||||
| 46291 | INC HL | Skip the screen-column byte. | ||||||
| 46292 | INC HL | |||||||
| 46293 | LD A,(DE) | Fetch the low world X. | ||||||
| 46294 | LD (HL),A | Write it. | ||||||
| 46295 | INC DE | Advance the seed pointer. | ||||||
| 46296 | INC HL | Advance the slot pointer. | ||||||
| 46297 | LD A,(DE) | Fetch the high world X. | ||||||
| 46298 | LD (HL),A | Write it. | ||||||
| 46299 | INC HL | Advance the slot pointer. | ||||||
| 46300 | INC DE | Advance the seed pointer. | ||||||
| 46301 | LD A,(DE) | Fetch the Y. | ||||||
| 46302 | LD (HL),A | Write it. | ||||||
| 46303 | DEC DE | Rewind the seed pointer by two bytes. | ||||||
| 46304 | DEC DE | |||||||
| 46305 | INC HL | Advance to the speed byte. | ||||||
|
Take the next ROM byte as the speed.
|
||||||||
| 46306 | EXX | Switch to the shadow registers. | ||||||
| 46307 | LD A,(HL) | Fetch the next ROM byte from *HL'. | ||||||
| 46308 | INC HL | Advance HL'. | ||||||
| 46309 | AND A | Jump to FillDebrisSlots_PositiveSpeed if it is positive. | ||||||
| 46310 | JP P,FillDebrisSlots_PositiveSpeed | |||||||
| 46313 | OR %11111100 | Set bits 2-7. | ||||||
| FillDebrisSlots_WriteSpeed | 46315 | EXX | Switch back. | |||||
| 46316 | LD (HL),A | Write the speed. | ||||||
| 46317 | INC HL | Advance to the thrust byte. | ||||||
|
Force the thrust into the range 251-254.
|
||||||||
| 46318 | EXX | Switch to the shadow registers. | ||||||
| 46319 | LD A,(HL) | Fetch the next ROM byte from *HL'. | ||||||
| 46320 | INC HL | Advance HL'. | ||||||
| 46321 | AND %00000011 | Keep only bits 0-1. | ||||||
| 46323 | OR %11111100 | Set bits 2-7. | ||||||
| 46325 | SUB 1 | Subtract 1. | ||||||
| 46327 | EXX | Switch back. | ||||||
| 46328 | LD (HL),A | Write the thrust. | ||||||
| 46329 | INC HL | Advance to the colour byte. | ||||||
|
Colour is bits 0-2 of the next ROM byte (0 and 1 become WHITE), plus BRIGHT.
|
||||||||
| 46330 | EXX | Switch to the shadow registers. | ||||||
| 46331 | LD A,(HL) | Fetch the next ROM byte from *HL'. | ||||||
| 46332 | INC HL | Advance HL'. | ||||||
| 46333 | AND %00000111 | Keep only bits 0-2. | ||||||
| 46335 | CP 2 | Jump to FillDebrisSlots_SetBright if it is at least 2. | ||||||
| 46337 | JR NC,FillDebrisSlots_SetBright | |||||||
| 46339 | LD A,7 | A=WHITE. | ||||||
| FillDebrisSlots_SetBright | 46341 | OR %01000000 | Set bit 6. | |||||
| 46343 | EXX | Switch back. | ||||||
| 46344 | LD (HL),A | Write the colour. | ||||||
| 46345 | INC HL | Skip the flags byte. | ||||||
| 46346 | INC HL | |||||||
|
Clear the next 7 bytes.
|
||||||||
| FillDebrisSlots_ClearBytes | 46347 | LD (HL),0 | Write 0. | |||||
| 46349 | INC HL | Advance the slot pointer. | ||||||
| 46350 | DJNZ FillDebrisSlots_ClearBytes | Decrease the counter by one and jump back to FillDebrisSlots_ClearBytes until it is zero. | ||||||
|
Write the sprite delay and its reload value, then step to the next slot.
|
||||||||
| 46352 | EXX | Switch to the shadow registers. | ||||||
| 46353 | LD A,(HL) | Fetch the next ROM byte from *HL'. | ||||||
| 46354 | INC HL | Advance HL'. | ||||||
| 46355 | AND %00000111 | Keep only bits 0-2. | ||||||
| 46357 | INC A | Increase it by one. | ||||||
| 46358 | EXX | Switch back. | ||||||
| 46359 | LD (HL),A | Write the sprite delay. | ||||||
| 46360 | INC HL | Advance the slot pointer. | ||||||
| 46361 | LD (HL),A | Write the same value as the delay reload. | ||||||
| 46362 | LD A,L | Advance HL by 7 to the next slot. | ||||||
| 46363 | ADD A,7 | |||||||
| 46365 | LD L,A | |||||||
| 46366 | LD A,H | |||||||
| 46367 | ADC A,0 | |||||||
| 46369 | LD H,A | |||||||
|
Loop until every slot has been written, then initialise the explosion.
|
||||||||
| 46370 | POP BC | Restore the slot counters from the stack. | ||||||
| 46371 | DEC C | Decrease the remaining slot count by one. | ||||||
| 46372 | JR NZ,FillDebrisSlots_Loop | Jump back to FillDebrisSlots_Loop if there are slots left. | ||||||
| 46374 | JP InitialiseExplosion_3 | Jump to InitialiseExplosion_3. | ||||||
|
Positive ROM speeds become 1-4.
|
||||||||
| FillDebrisSlots_PositiveSpeed | 46377 | AND %00000011 | Keep only bits 0-1. | |||||
| 46379 | INC A | Increase it by one. | ||||||
| 46380 | JR FillDebrisSlots_WriteSpeed | Jump to FillDebrisSlots_WriteSpeed. | ||||||
| Prev: 46176 | Up: Map | Next: 46382 |