Prev: 72E9 Up: Map Next: 7325
72F5: Check Bug Robbie Collision
Used by the routine at UpdateBugCommon.
Tests whether a bug is touching Robbie. Robbie only counts when his state is 01 or 02 (empty-handed or carrying a can), so a collision cannot happen while he is exploding.
The two collide when their X positions differ by less than 10 and their Y positions are close enough. The vertical limit is 12 when Robbie is lower down the screen than the bug, or the bug's height (from *IX+07) when the bug is lower down.
Input
IX Bug object
Output
E 00 No collision
E 01 Collision
BugCollision 72F5 LD HL,$5E6C HL=State_Robbie_Active (Robbie).
72F8 LD E,$00 E=00 (the default result, no collision).
72FA LD A,(HL) Fetch Robbie's state.
72FB AND %00111111 Keep only bits 0-5.
72FD DEC A Decrease the state of Robbie by one (zero if he is empty-handed).
72FE JR Z,BugCollision_X Jump to BugCollision_X if Robbie is empty-handed (state 01).
7300 DEC A Decrease A by one again.
7301 RET NZ Return if Robbie is not carrying a can (state 02).
Check the horizontal distance.
BugCollision_X 7302 INC HL A=Robbie's X position (from State_Robbie_Pos_X).
7303 LD A,(HL)
7304 SUB (IX+$01) Subtract the bug's X position.
7307 JP P,BugCollision_Test_X Make sure the difference is positive.
730A NEG
BugCollision_Test_X 730C CP $10 Return if the difference is 10 or more.
730E RET NC
Check the vertical distance.
730F INC HL Move on to Robbie's Y position.
This entry point is used by the routine at CreateBug.
BugCollision_Y 7310 LD A,(HL) A=Robbie's Y position (from State_Robbie_Pos_Y).
7311 SUB (IX+$02) Subtract the bug's Y position.
7314 JP P,BugCollision_SetHeight Jump to BugCollision_SetHeight if Robbie is lower down the screen than the bug.
7317 NEG Make the difference positive.
7319 LD D,(IX+$07) D=the bug's height (from *IX+07).
731C JR BugCollision_Test_Y Jump to BugCollision_Test_Y.
BugCollision_SetHeight 731E LD D,$12 D=12.
BugCollision_Test_Y 7320 CP D Return if the difference is D or more.
7321 RET NC
A collision has been detected.
See Immunity.
7322 LD E,$01 E=01.
7324 RET Return.
Prev: 72E9 Up: Map Next: 7325