Prev: C554 Up: Map Next: C5B4
C55F: Check Player Collision
Checks whether the object at IX is touching the player. Nothing touches the player until the player has finished materialising, or when the player is dead.
Input
IX Object
Output
IY The player
F The carry flag is set if the object is touching the player
CheckPlayerCollision C55F LD A,($BC02) Return if the player is still materialising.
C562 SUB $70
C564 AND A
C565 RET NZ
C566 LD IY,$BC8E Use the player as the second object.
C56A LD A,(IY+$00) Return if the player is dead.
C56D SUB $10
C56F CP $20
C571 RET NC
This entry point is used by the routines at CheckShotHit and CheckOverlapWithNextObject.
Checks whether two objects overlap along both axes. The overlap is measured from the centres of the objects, using half of the width and the depth of the object at IY and the full width and depth of the object at IX.
CheckObjectsOverlap C572 LD A,(IY+$08) Add half of the width of the second object to the width of the first object, to find the distance along the X axis within which they overlap.
C575 SRL A
C577 ADD A,(IX+$08)
C57A LD C,A
C57B LD B,$00
C57D LD L,(IX+$01) Fetch the X positions of the two objects.
C580 LD H,(IX+$02)
C583 LD E,(IY+$01)
C586 LD D,(IY+$02)
C589 AND A Subtract one from the other to get the distance between the objects.
C58A SBC HL,DE
C58C CALL C,NegateHL Turn the distance round if it is negative, so that it is positive.
C58F AND A Subtract the distance within which the objects overlap.
C590 SBC HL,BC
C592 RET NC Return with the carry flag clear if the objects do not overlap along the X axis.
C593 LD A,(IY+$09) Add half of the depth of the second object to the depth of the first object, to find the distance along the Y axis within which they overlap.
C596 SRL A
C598 ADD A,(IX+$09)
C59B LD C,A
C59C LD B,$00
C59E LD L,(IX+$03) Fetch the Y positions of the two objects.
C5A1 LD H,(IX+$04)
C5A4 LD E,(IY+$03)
C5A7 LD D,(IY+$04)
C5AA AND A Subtract one from the other to get the distance between the objects.
C5AB SBC HL,DE
C5AD CALL C,NegateHL Turn the distance round if it is negative, so that it is positive.
C5B0 AND A Subtract the distance within which the objects overlap.
C5B1 SBC HL,BC
C5B3 RET Return with the carry flag set if the objects overlap along the Y axis as well, which means they are touching.
Prev: C554 Up: Map Next: C5B4