![]() |
Routines |
| Prev: 30348 | Up: Map | Next: 30638 |
|
Used by the routine at Handler_Plane.
Manages the plane's bomb. When the plane is above Percy, a bomb is dropped which falls downward. When the bomb hits or the explosion timer expires, Percy is damaged. The explosion cycles through animation frames before clearing.
|
||||
|
Check the bomb explosion counter.
|
||||
| Handle_Plane_Bomb | 30483 | LD A,(30638) | Fetch the bomb explosion counter from *Bomb_Explosion_Counter. | |
| 30486 | OR A | Jump to Bomb_Explosion if the counter is non-zero (explosion in progress). | ||
| 30487 | JR NZ,Bomb_Explosion | |||
| 30489 | BIT 7,(IY+3) | Jump to Check_Bomb_Drop if bit 7 of *IY+3 is not set (no bomb active). | ||
| 30493 | JR Z,Check_Bomb_Drop | |||
|
Bomb is falling; update its position.
|
||||
| 30495 | LD IX,56048 | Point IX at Sprite03_2Wide_X_Position (bomb sprite data). | ||
| 30499 | LD (IX+3),20 | Set the bomb sprite frame to 20. | ||
| 30503 | LD A,(IX+1) | Add 3 to the bomb Y position. | ||
| 30506 | ADD A,3 | |||
| 30508 | CP 160 | Jump to Bomb_Hit_Ground if the Y position has reached 160 (hit the ground). | ||
| 30510 | JR NC,Bomb_Hit_Ground | |||
| 30512 | LD (IX+1),A | Write the updated Y position to *IX+1. | ||
| 30515 | PUSH IY | Stash IY on the stack. | ||
| 30517 | LD IX,56000 | Point IX at Percy_X_Position (Percy sprite data). | ||
| 30521 | LD IY,56048 | Point IY at Sprite03_2Wide_X_Position (bomb sprite data). | ||
| 30525 | CALL CheckEggCollision | Call CheckEggCollision to check for collision between the bomb and Percy. | ||
| 30528 | POP IY | Restore IY from the stack. | ||
| 30530 | RET C | Return if there was no collision (carry set). | ||
| 30531 | LD (IY+3),0 | Write 0 to *IY+3 (deactivate the bomb). | ||
| 30535 | LD A,7 | Write 7 to *Bomb_Explosion_Counter (start the explosion counter). | ||
| 30537 | LD (30638),A | |||
| 30540 | RET | Return. | ||
|
Bomb explosion animation is in progress.
|
||||
| Bomb_Explosion | 30541 | DEC A | Decrement the explosion counter. | |
| 30542 | LD (30638),A | Write the updated counter to *Bomb_Explosion_Counter. | ||
| 30545 | OR A | Jump to Bomb_Explosion_Done if the counter has reached zero (explosion finished). | ||
| 30546 | JR Z,Bomb_Explosion_Done | |||
| 30548 | RRA | Divide by two and add 54 to select the explosion animation frame. | ||
| 30549 | ADD A,54 | |||
| 30551 | LD (56003),A | Write the frame to *Percy_Frame_ID (Percy's sprite frame, showing the explosion on Percy). | ||
| 30554 | LD A,R | Use the Memory Refresh Register masked with 7 as a random flicker value. | ||
| 30556 | AND %00000111 | |||
| 30558 | LD (56002),A | Write to *Percy_Colour (Percy's sprite active flag, for flicker effect). | ||
| 30561 | JP PlayHitSound | Jump to PlayHitSound. | ||
|
Explosion complete; register the hit on Percy.
|
||||
| Bomb_Explosion_Done | 30564 | LD A,255 | Write 255 to *FallingState (set collision flag to damage Percy). | |
| 30566 | LD (24487),A | |||
| 30569 | RET | Return. | ||
|
Bomb hit the ground without hitting Percy; deactivate the bomb.
|
||||
| Bomb_Hit_Ground | 30570 | LD (IY+3),0 | Write 0 to *IY+3 (deactivate the bomb). | |
| 30574 | RET | Return. | ||
|
No bomb active; check if the plane should drop one.
|
||||
| Check_Bomb_Drop | 30575 | LD A,R | Use the Memory Refresh Register masked for a random check. | |
| 30577 | AND %00000001 | |||
| 30579 | RET NZ | Return if the random bit is not set (don't drop this frame). | ||
| 30580 | LD A,(56001) | Check if Percy's Y position plus 10 is greater than or equal to the plane's Y position. | ||
| 30583 | ADD A,10 | |||
| 30585 | CP (IX+1) | |||
| 30588 | RET C | Return if Percy is above the plane (carry set). | ||
| 30589 | LD A,(56000) | Mask Percy's X position and store in B. | ||
| 30592 | AND %11111100 | |||
| 30594 | LD B,A | |||
| 30595 | LD A,(IX+0) | Mask the plane's X position with 252 and compare with B. | ||
| 30598 | AND %11111100 | |||
| 30600 | CP B | Return if the X positions don't match (plane not above Percy). | ||
| 30601 | RET NZ | |||
| 30602 | BIT 7,(IY+2) | Return if bit 7 of *IY+2 is not set (plane not active). | ||
| 30606 | RET Z | |||
| 30607 | BIT 7,(IY+0) | Return if bit 7 of *IY+0 is set (plane is stunned). | ||
| 30611 | RET NZ | |||
|
Drop the bomb: set the bomb sprite position and activate it.
|
||||
| 30612 | LD A,(IX+1) | Set the bomb Y position to the plane's Y plus 10. | ||
| 30615 | ADD A,10 | |||
| 30617 | LD (56049),A | Write to *Sprite03_2Wide_Y_Position (bomb Y position). | ||
| 30620 | LD A,(IX+0) | Copy the plane's X position to *Sprite03_2Wide_X_Position (bomb X position). | ||
| 30623 | LD (56048),A | |||
| 30626 | LD A,255 | Write 255 to *Sprite03_2Wide_Colour (bomb sprite active flag). | ||
| 30628 | LD (56050),A | |||
| 30631 | SET 7,(IY+3) | Set bit 7 of *IY+3 (mark bomb as active). | ||
| 30635 | JP PlayHitSound | Jump to PlayHitSound. | ||
| Prev: 30348 | Up: Map | Next: 30638 |