Prev: E272 Up: Map Next: E2CB
E285: Check Sabreman Contact
Checks whether an object is touching Sabreman.
Nothing is touched if the sprite id of Sabreman is 1D or more (he is dying or being carried), or if bit 6 of his redraw flags is set (he is being carried).
There is contact when the two are in the same room, the x positions differ by less than 10 and the y position of Sabreman, less four, differs from that of the object by less than 0A. A tone is played on contact (see Play_Position_Sound).
Input
IX Object record
Output
C Contact result
Check_Sabreman_Contact E285 LD C,$00 Clear the contact result.
E287 LD A,($8F1A) Fetch the sprite id of Sabreman.
E28A CP $1D Return if it is 1D or more.
E28C RET NC
This entry point is used by the routine at Handle_Guardian.
Check_Sabreman_Contact_Clear_Result E28D LD C,$00 Clear the contact result.
E28F LD A,($8F29) Fetch the redraw flags of Sabreman.
E292 AND %01000000 Keep only bit 6.
E294 RET NZ Return if Sabreman is being carried.
E295 LD HL,$8F1B Point HL at Sabreman_X_Position.
E298 LD A,(HL) Fetch the x position of Sabreman.
E299 SUB (IX+$01) Subtract the x position of the object, and jump to Check_Sabreman_Contact_Check_Width if Sabreman is not to the left of it.
E29C JP P,Check_Sabreman_Contact_Check_Width
E29F SET 7,C Set bit 7 of the contact result, as Sabreman is to the left of the object.
E2A1 NEG Make the difference positive.
Check_Sabreman_Contact_Check_Width E2A3 CP $10 Return if the difference is 10 or more.
E2A5 RET NC
E2A6 INC HL Point HL at the room x of Sabreman.
E2A7 LD A,(HL) Fetch the room x of Sabreman.
E2A8 CP (IX+$02) Return if Sabreman is in a different room x from the object.
E2AB RET NZ
E2AC INC HL Point HL at the y position of Sabreman.
E2AD LD A,(HL) Fetch the y position of Sabreman.
E2AE SUB $04 Subtract four.
E2B0 SUB (IX+$03) Subtract the y position of the object, and jump to Check_Sabreman_Contact_Check_Height if Sabreman is not above it.
E2B3 JP P,Check_Sabreman_Contact_Check_Height
E2B6 NEG Make the difference positive.
E2B8 SET 1,C Set bit 1 of the contact result, as Sabreman is above the object.
Check_Sabreman_Contact_Check_Height E2BA CP $0A Return if the difference is 0A or more.
E2BC RET NC
E2BD INC HL Point HL at the room y of Sabreman.
E2BE LD A,(HL) Fetch the room y of Sabreman.
E2BF CP (IX+$04) Return if Sabreman is in a different room y from the object.
E2C2 RET NZ
E2C3 SET 2,C Set bit 2 of the contact result (contact).
E2C5 PUSH BC Stash the contact result.
E2C6 CALL Play_Position_Sound Play a tone.
E2C9 POP BC Restore the contact result.
E2CA RET Return.
Prev: E272 Up: Map Next: E2CB