| Prev: 678E | Up: Map | Next: 6831 |
6794: Finalize collision and erase missile sprite
|
Used by the routines at handle_collision_mode_fighter, check_collision, next_bridge_player_2, check_missile_vs_objects and animate_plane_missile.
|
||||
|
Called after a successful collision to clean up the game state. Erases the missile sprite from the screen, resets the collision mode to COLLISION_MODE_NONE, clears the missile coordinates, and resets CONTROLS_BIT_SPEED_NOT_FAST.
If in GAMEPLAY_MODE_REFUEL, jumps to handle_player_death instead.
The sprite frame selection uses the X coordinate's lower 3 bits to choose the correct pixel-aligned erasure frame (1-4).
|
||||
| finalize_collision | 6794 | LD BC,($5EF3) | Load missile coordinates from state_plane_missile_y and call blending_mode_or_or to set OR blending. | |
| 6798 | CALL blending_mode_or_or | |||
| 679B | LD A,($5F68) | If GAMEPLAY_MODE_REFUEL, jump to handle_player_death. | ||
| 679E | CP $06 | |||
| 67A0 | JP Z,handle_player_death | |||
| 67A3 | LD A,$00 | Reset collision mode in state_collision_mode to NONE. | ||
| 67A5 | LD ($5EF5),A | |||
| 67A8 | LD A,$01 | Set up sprite parameters: width=1, base=sprite_missile_trail, frame_size=8. | ||
| 67AA | LD HL,$8451 | |||
| 67AD | LD DE,$0008 | |||
| 67B0 | LD A,C | Calculate frame index from X coordinate's lower 3 bits. | ||
| 67B1 | AND $07 | |||
| 67B3 | SRL A | |||
| 67B5 | INC A | |||
| 67B6 | OR A | |||
| 67B7 | SBC HL,DE | Prepare for frame selection loop. | ||
| finalize_collision_erase_missile_loop | 67B9 | ADD HL,DE | Select correct frame by adding frame_size A times. | |
| 67BA | DEC A | |||
| 67BB | JR NZ,finalize_collision_erase_missile_loop | |||
| 67BD | LD A,($673C) | If first missile pass, call advance_object to advance position. | ||
| 67C0 | CP $01 | |||
| 67C2 | CALL Z,advance_object | |||
| 67C5 | LD ($8B0E),HL | Store sprite pointer and coordinates to rendering vars. | ||
| 67C8 | LD ($8B0C),BC | |||
| 67CC | LD ($8B0A),BC | |||
| 67D0 | LD A,$01 | Set sprite dimensions: width=1, frame_size=8, height=8, attrs=$0C. | ||
| 67D2 | LD BC,$0008 | |||
| 67D5 | LD DE,$080C | |||
| 67D8 | LD HL,$82F5 | Erase missile sprite. | ||
| 67DB | CALL render_object | |||
| 67DE | LD HL,$6BB0 | Reset CONTROLS_BIT_SPEED_NOT_FAST in state_controls. | ||
| 67E1 | RES 1,(HL) | |||
| 67E3 | LD BC,($5EF3) | Reload coordinates from state_plane_missile_y, then clear them. | ||
| 67E7 | LD HL,$0000 | |||
| 67EA | LD ($5EF3),HL | |||
| 67ED | LD A,B | Calculate residue Y position (missile_Y - 6). | ||
| 67EE | SUB $06 | |||
| 67F0 | LD B,A | |||
| 67F1 | CP $06 | |||
| 67F3 | RET Z | |||
| 67F4 | LD A,($5F72) | Set X = plane_X + 4 for centered erasure. | ||
| 67F7 | ADD A,$04 | |||
| 67F9 | LD C,A | |||
| 67FA | LD HL,$8451 | Set up sprite parameters for residue erasure. | ||
| 67FD | LD DE,$0008 | |||
| 6800 | LD A,C | |||
| 6801 | AND $07 | |||
| 6803 | SRL A | Same frame selection as missile loop above (X lower 3 bits). | ||
| 6805 | INC A | |||
| 6806 | OR A | |||
| 6807 | SBC HL,DE | |||
| finalize_collision_erase_residue_loop | 6809 | ADD HL,DE | ||
| 680A | DEC A | |||
| 680B | JR NZ,finalize_collision_erase_residue_loop | |||
| 680D | LD A,($5EF6) | Calculate remaining height from state_collision_y; return if zero. | ||
| 6810 | LD D,A | |||
| 6811 | LD A,$08 | |||
| 6813 | SUB D | |||
| 6814 | CP $00 | |||
| 6816 | RET Z | |||
| 6817 | LD D,A | Set height and attributes (height in D, attrs=$0C in E). | ||
| 6818 | LD E,$0C | |||
| 681A | LD A,$01 | Store sprite params and call render_object to erase residue. | ||
| 681C | LD ($8B0E),HL | |||
| 681F | LD HL,$82F5 | |||
| 6822 | LD ($8B0C),BC | |||
| 6826 | LD ($8B0A),BC | |||
| 682A | LD BC,$0000 | |||
| 682D | CALL render_object | |||
| 6830 | RET | |||
| Prev: 678E | Up: Map | Next: 6831 |