| Prev: 6506 | Up: Map | Next: 6568 |
650A: Handle player death
|
General player death handler. It stops the plane, creates two explosion fragments at the plane's position, animates the explosions over 16 frames, waits for a delay, then determines the next game state based on the current player and remaining lives in single or two-player mode.
|
||||||||||||||||||||||||||||||||||||||||
|
Two-player mode uses alternating turns. After death, the switching logic is:
In single-player mode, the game simply restarts P1 if lives remain, otherwise Game Over.
|
||||||||||||||||||||||||||||||||||||||||
| handle_player_death | 650A | LD A,($5F72) | Load plane X-coordinate | |||||||||||||||||||||||||||||||||||||
| 650D | AND $F8 | Align to 8-pixel boundary (clear lower 3 bits) | ||||||||||||||||||||||||||||||||||||||
| 650F | LD C,A | Store aligned X-coordinate in C register | ||||||||||||||||||||||||||||||||||||||
| 6510 | LD B,$7F | Set fragment Y to PLANE_COORDINATE_Y-1. | ||||||||||||||||||||||||||||||||||||||
| 6512 | LD A,$00 | Stop plane movement: clear scroll speed, missile Y, and missile X. | ||||||||||||||||||||||||||||||||||||||
| 6514 | LD ($5F64),A | |||||||||||||||||||||||||||||||||||||||
| 6517 | LD ($5EF3),A | |||||||||||||||||||||||||||||||||||||||
| 651A | LD ($5EF4),A | |||||||||||||||||||||||||||||||||||||||
| 651D | LD D,$00 | Set explosion frame index to 0. | ||||||||||||||||||||||||||||||||||||||
| 651F | CALL spawn_explosion_fragment | Create first explosion fragment at plane position | ||||||||||||||||||||||||||||||||||||||
| 6522 | LD A,B | Offset Y-coordinate by $05 pixels for second explosion | ||||||||||||||||||||||||||||||||||||||
| 6523 | ADD A,$05 | |||||||||||||||||||||||||||||||||||||||
| 6525 | LD B,A | |||||||||||||||||||||||||||||||||||||||
| 6526 | CALL spawn_explosion_fragment | Create second explosion fragment | ||||||||||||||||||||||||||||||||||||||
| 6529 | LD A,$10 | Set animation frame counter (16 frames). | ||||||||||||||||||||||||||||||||||||||
| animate_explosion_loop | 652B | PUSH AF | Save frame counter | |||||||||||||||||||||||||||||||||||||
| 652C | LD B,$40 | Set outer delay loop counter to $40 (64 iterations) | ||||||||||||||||||||||||||||||||||||||
| explosion_delay_outer | 652E | LD D,$00 | Set inner delay loop counter to $00 (256 iterations) | |||||||||||||||||||||||||||||||||||||
| explosion_delay_inner | 6530 | DEC D | Tight delay loop (256 iterations) | |||||||||||||||||||||||||||||||||||||
| 6531 | JR NZ,explosion_delay_inner | |||||||||||||||||||||||||||||||||||||||
| 6533 | DJNZ explosion_delay_outer | Repeat outer delay loop (64 times) | ||||||||||||||||||||||||||||||||||||||
| 6535 | CALL render_explosions | Render current explosion animation frame | ||||||||||||||||||||||||||||||||||||||
| 6538 | POP AF | Restore and decrement frame counter | ||||||||||||||||||||||||||||||||||||||
| 6539 | DEC A | |||||||||||||||||||||||||||||||||||||||
| 653A | JP NZ,animate_explosion_loop | Repeat animation loop for all 16 frames | ||||||||||||||||||||||||||||||||||||||
| 653D | LD D,$0C | Set final delay counter to $0C (12 iterations) | ||||||||||||||||||||||||||||||||||||||
| 653F | LD A,$00 | |||||||||||||||||||||||||||||||||||||||
| 6541 | LD B,$00 | Initialize inner loop counter to $00 | ||||||||||||||||||||||||||||||||||||||
| final_delay_loop | 6543 | DJNZ final_delay_loop | Triple-nested delay loop for extended pause after explosion | |||||||||||||||||||||||||||||||||||||
| 6545 | DEC A | |||||||||||||||||||||||||||||||||||||||
| 6546 | JR NZ,final_delay_loop | |||||||||||||||||||||||||||||||||||||||
| 6548 | DEC D | |||||||||||||||||||||||||||||||||||||||
| 6549 | JR NZ,final_delay_loop | |||||||||||||||||||||||||||||||||||||||
| 654B | LD A,$00 | Clear control state (reset all button flags) | ||||||||||||||||||||||||||||||||||||||
| 654D | LD ($6BB0),A | Store cleared control state | ||||||||||||||||||||||||||||||||||||||
| 6550 | LD A,($923D) | Load current player number | ||||||||||||||||||||||||||||||||||||||
| 6553 | CP $02 | Check if current player is Player 2 | ||||||||||||||||||||||||||||||||||||||
| 6555 | JP Z,handle_player_2_death | If Player 2, jump to Player 2 death handler | ||||||||||||||||||||||||||||||||||||||
| 6558 | LD A,($923B) | Load Player 1 lives remaining | ||||||||||||||||||||||||||||||||||||||
| 655B | CP $00 | Check if Player 1 has no lives left | ||||||||||||||||||||||||||||||||||||||
| 655D | JP Z,check_player_2_lives | If no lives, jump to check for game over | ||||||||||||||||||||||||||||||||||||||
| 6560 | LD A,($923A) | Load game mode (1 or 2 player) | ||||||||||||||||||||||||||||||||||||||
| 6563 | BIT 0,A | Check if two-player mode is active | ||||||||||||||||||||||||||||||||||||||
| 6565 | JP NZ,switch_to_player_2_in_two_player_mode | If two-player mode, jump to switch to Player 2 | ||||||||||||||||||||||||||||||||||||||
| Prev: 6506 | Up: Map | Next: 6568 |