← A167 Update the balls for this frame Map A2D8 → Set a ball's velocity from its heading code
A299: Test for a collision ahead of the ball
Tests the tile-map cell ahead of the ball. A brick there takes the hit on contact.
Input
B offset from the active ball's probe origin to the cell to test
Output
A 1 when the cell blocks, 0 when free
collision_probe A299 LD HL,(ball_cell_ptr) Start from the active ball's probe origin.
A29C LD E,B Offset by B to the cell under test.
A29D LD D,$00
A29F ADD HL,DE
A2A0 LD A,(active_ball) For the missile shot, a wall or border tile arms the retract and reports the cell blocked. Any other tile goes through the normal classification below.
A2A3 OR A
A2A4 JR Z,collision_probe_classify
A2A6 LD A,(missile_shot)
A2A9 OR A
A2AA JR Z,collision_probe_classify
A2AC LD A,(HL)
A2AD CP $20
A2AF JR Z,collision_probe_classify
A2B1 CP $45
A2B3 JR NC,collision_probe_classify
A2B5 LD A,$01
A2B7 LD (fx_retract_arm),A
A2BA RET
collision_probe_classify A2BB LD A,(HL) Read the tile in the cell.
A2BC CP $20 Space? The cell is empty – free.
A2BE JR Z,collision_probe_free
A2C0 CP $45 A solid wall or border – blocked
A2C2 JR C,collision_probe_blocked
A2C4 CP $59 A passable tile – free
A2C6 JR C,collision_probe_free
A2C8 CP $E4 A tile past the brick tiles – free. Anything left is a brick.
A2CA JR NC,collision_probe_free
A2CC XOR A Mark this as a ball hit.
A2CD LD (hit_params),A
A2D0 CALL hit_brick Break, degrade or flash the brick by its class.
collision_probe_blocked A2D3 LD A,$01 Report the cell as solid.
A2D5 RET
collision_probe_free A2D6 XOR A Report the cell as free.
A2D7 RET
← A167 Update the balls for this frame Map A2D8 → Set a ball's velocity from its heading code
Fork me on GitHub