| Prev: 615E | Up: Map | Next: 6249 |
61BB: Check collision against bridges and viewport objects
|
Used by the routines at collision_dispatcher and handle_collision_mode_fuel_depot.
|
||||
|
Checks if the entity (missile or plane) has collided with a bridge or any viewport object. The coordinates to check are read from state_plane_missile_y.
Called in two contexts: (1) when COLLISION_MODE_MISSILE is set, checks missile collision; (2) when called from handle_collision_mode_fuel_depot, checks plane collision with fuel depots.
First checks if a bridge exists (state_bridge_y_position != 0) and whether the Y coordinate is within the bridge's vertical bounds (bridge_y - $16 to bridge_y). If the bridge is hit, awards POINTS_BRIDGE, triggers 6 explosion fragments in a 2x3 grid pattern, increments the player's bridge counter, and clears the bridge.
If no bridge collision, falls through to check_missile_vs_objects to check collision against viewport objects.
|
||||
| check_collision | 61BB | LD BC,($5EF3) | Load entity coordinates from state_plane_missile_y and bridge Y from state_bridge_y_position. | |
| 61BF | LD A,($5F6E) | |||
| 61C2 | CP $00 | If no bridge exists, jump to check_missile_vs_objects to check viewport objects. | ||
| 61C4 | JP Z,check_missile_vs_objects | |||
| 61C7 | LD D,A | Check if entity_Y <= bridge_Y; if not, check objects. | ||
| 61C8 | SUB B | |||
| 61C9 | JP M,check_missile_vs_objects | |||
| 61CC | LD A,D | Check if entity_Y >= bridge_Y - $16; if not, check objects. | ||
| 61CD | SUB $16 | |||
| 61CF | SUB B | |||
| 61D0 | JP P,check_missile_vs_objects | |||
|
Bridge hit - award points and spawn explosions.
|
||||
| 61D3 | LD A,$50 | Award POINTS_BRIDGE to player. | ||
| 61D5 | CALL add_points | |||
| 61D8 | LD A,$0F | Increase activation rate (every 16 frames after bridge destruction). | ||
| 61DA | LD ($5F5F),A | |||
| 61DD | POP DE | Clean up stack and store hit Y to state_collision_y. | ||
| 61DE | POP DE | |||
| 61DF | POP DE | |||
| 61E0 | POP BC | |||
| 61E1 | LD A,D | |||
| 61E2 | LD ($5EF6),A | |||
| 61E5 | LD A,($5F6E) | Set up bottom explosion row: Y = bridge_Y - 4, X = $70, D = 0. | ||
| 61E8 | SUB $04 | |||
| 61EA | LD B,A | |||
| 61EB | LD C,$70 | |||
| 61ED | LD D,$00 | |||
| 61EF | CALL spawn_explosion_fragment | Spawn explosion 1 (bottom-left). | ||
| 61F2 | LD C,$80 | Move to X = $80 and spawn explosion 2 (bottom-right). | ||
| 61F4 | CALL spawn_explosion_fragment | |||
| 61F7 | LD A,B | Move Y - 8 and spawn explosion 3 (middle-right). | ||
| 61F8 | SUB $08 | |||
| 61FA | LD B,A | |||
| 61FB | CALL spawn_explosion_fragment | |||
| 61FE | LD C,$70 | Move to X = $70 and spawn explosion 4 (middle-left). | ||
| 6200 | CALL spawn_explosion_fragment | |||
| 6203 | LD A,B | Move Y - 8 and spawn explosion 5 (top-left). | ||
| 6204 | SUB $08 | |||
| 6206 | LD B,A | |||
| 6207 | CALL spawn_explosion_fragment | |||
| 620A | LD C,$80 | Move to X = $80 and spawn explosion 6 (top-right). | ||
| 620C | CALL spawn_explosion_fragment | |||
| 620F | LD A,($5F6C) | If bridge section is $02, call clear_destroyed_bridge with screen screen_pixels. | ||
| 6212 | CP $02 | |||
| 6214 | LD HL,$4000 | |||
| 6217 | CALL Z,clear_destroyed_bridge | (continued from above). | ||
| 621A | LD A,($5F6C) | If bridge section is $02, call clear_destroyed_bridge with screen $4100. | ||
| 621D | CP $02 | |||
| 621F | LD HL,$4100 | |||
| 6222 | CALL Z,clear_destroyed_bridge | (continued from above). | ||
| 6225 | LD A,$00 | Clear bridge Y position (state_bridge_y_position). | ||
| 6227 | LD ($5F6E),A | |||
| 622A | LD A,$01 | Set bridge destroyed flag (state_bridge_destroyed). | ||
| 622C | LD ($5F6D),A | |||
| 622F | LD BC,($5F8D) | Restore entity coordinates from state_saved_object_coords to state_plane_missile_y. | ||
| 6233 | LD ($5EF3),BC | |||
| 6237 | LD A,($923D) | Check if player 2; if so, jump to next_bridge_player_2. | ||
| 623A | CP $02 | |||
| 623C | JP Z,next_bridge_player_2 | (continued from above). | ||
| next_bridge_player_1 | 623F | LD HL,$5F6A | Increment player 1 bridge counter at state_bridge_player_1 and print. | |
| 6242 | INC (HL) | |||
| 6243 | CALL print_bridge | |||
| 6246 | JP finalize_collision | Finalize collision. | ||
| Prev: 615E | Up: Map | Next: 6249 |