Prev: 8598 Up: Map Next: 85EA
85B2: Has this monster caught the player?
Compares the monster IX points at against the player's record at $EA90: same room, and within 12 pixels on both axes. Confirmed by breaking here and collecting IX -- it is only ever one of the eight monster records at $EE60-$EED0, tested against the fixed player address.
Input
IX The monster to test
E 1 if it has the player, 0 if not
CHECK_HIT 85B2 LD A,($EA91) Cheapest rejection first: a monster in another room cannot touch anything.
85B5 LD E,$00
85B7 CP (IX+$01)
85BA RET NZ
85BB LD A,($EA90) $31 is not an arbitrary threshold: sprite codes $01-$30 are the three playable characters, sixteen codes each (see ACTOR_HANDLERS), so "non-zero and below $31" means "$EA90 currently holds a player". It reads $66 while the game is still bringing the player into the room, which is what stops them being killed before they exist.
85BE AND A
85BF RET Z
85C0 CP $31
85C2 RET NC
85C3 LD A,($EA93) |dx|, via negate-if-negative rather than a signed compare.
85C6 SUB (IX+$03)
85C9 JP P,CHECK_HIT_0
85CC NEG
CHECK_HIT_0 85CE CP $0C Within 12 pixels horizontally, or no hit.
85D0 RET NC
85D1 LD A,($EA94) The same for |dy|.
85D4 SUB (IX+$04)
85D7 JP P,CHECK_HIT_1
85DA NEG
CHECK_HIT_1 85DC CP $0C
85DE RET NC
85DF LD A,$01 Record the hit where the caller can find it...
85E1 LD ($EA92),A
85E4 CALL PLAY_SOUND_CAUGHT ...and make a noise about it.
85E7 LD E,$01
85E9 RET
Prev: 8598 Up: Map Next: 85EA