Prev: C554 Up: Map Next: C5B4
C55F: Does the thing at IX touch the knight?
Never while he is appearing (ARRIVING short of $70), nor unless his legs are standing or walking (graphics 16-47): not while he vanishes. TOUCH_TEST, the rest, is the overlap test every touching test in the game ends with, IX against IY: along U the distance between them, the whole 16-bit positions, must be less than IX's half-size plus half of IY's; the same along V; carry if both. The positions carry the cell, so things in neighbouring cells meet across the line between them.
Input
IX the thing
Output
F carry if touching
TOUCHING_KNIGHT C55F LD A,(ARRIVING) still appearing: no
C562 SUB $70
C564 AND A
C565 RET NZ
C566 LD IY,KNIGHT IY = his legs; not standing or walking: no
C56A LD A,(IY+$00)
C56D SUB $10
C56F CP $20
C571 RET NC
This entry point is used by the routines at ANTIBODY_TOUCHING and OBJECT_STRIKE.
TOUCH_TEST C572 LD A,(IY+$08) TOUCH_TEST: C = half IY's half-size in U, plus IX's
C575 SRL A
C577 ADD A,(IX+$08)
C57A LD C,A
C57B LD B,$00
C57D LD L,(IX+$01) HL = how far apart they are along U, made positive
C580 LD H,(IX+$02)
C583 LD E,(IY+$01)
C586 LD D,(IY+$02)
C589 AND A
C58A SBC HL,DE
C58C CALL C,NEGATE_HL
C58F AND A not closer than C: no
C590 SBC HL,BC
C592 RET NC
C593 LD A,(IY+$09) the same along V; carry if closer
C596 SRL A
C598 ADD A,(IX+$09)
C59B LD C,A
C59C LD B,$00
C59E LD L,(IX+$03)
C5A1 LD H,(IX+$04)
C5A4 LD E,(IY+$03)
C5A7 LD D,(IY+$04)
C5AA AND A
C5AB SBC HL,DE
C5AD CALL C,NEGATE_HL
C5B0 AND A
C5B1 SBC HL,BC
C5B3 RET
Prev: C554 Up: Map Next: C5B4