Prev: C0A7 Up: Map Next: C107
C0D4: Test Object Can Be Picked Up
Used by the routine at HandlePickupAndDrop.
Tests if an object is one that can be picked up (of type 5A or 90 to 94) and touches the player. The player is taken to touch the object if they overlap along each axis, with the player lowered by 04 to test along z.
Input
IX Record of the object of the legs of the player
IY Record of the object to test
Output
F Carry flag set if the object can be picked up and touches the player
Return unless the object is one that can be picked up.
TestObjectCanBePickedUp C0D4 LD A,(IY+$00) Fetch the type of the object.
C0D7 CP $5A Jump to TestObjectCanBePickedUp_Overlap if it is type 5A.
C0D9 JR Z,TestObjectCanBePickedUp_Overlap
C0DB SUB $90 Take away 90 from it.
C0DD CP $05 Return with the carry flag clear if it was not one of the five types 90 to 94.
C0DF RET NC
Test whether the player touches the object.
TestObjectCanBePickedUp_Overlap C0E0 PUSH BC Stash BC on the stack.
C0E1 LD BC,$0000 Set the distance moved along x to zero.
C0E4 LD L,C Set the distances moved along y and z to zero.
C0E5 LD H,C
C0E6 CALL TestOverlapInX Jump to TestObjectCanBePickedUp_Done if the objects do not overlap along x.
C0E9 JR NC,TestObjectCanBePickedUp_Done
C0EB CALL TestOverlapInY Jump to TestObjectCanBePickedUp_Done if the objects do not overlap along y.
C0EE JR NC,TestObjectCanBePickedUp_Done
C0F0 LD A,(IX+$03) Lower the player by 04.
C0F3 SUB $04
C0F5 LD (IX+$03),A
C0F8 CALL TestOverlapInZ Test if the objects overlap along z.
C0FB PUSH AF Stash the result on the stack.
C0FC LD A,(IX+$03) Raise the player by 04 again.
C0FF ADD A,$04
C101 LD (IX+$03),A
C104 POP AF Restore the result from the stack.
TestObjectCanBePickedUp_Done C105 POP BC Restore BC from the stack.
C106 RET Return.
View the equivalent code in;
Prev: C0A7 Up: Map Next: C107