Prev: C00E Up: Map Next: C1A1
C172: Test Object Can Be Picked Up
Used by the routine at HandlePickupAndDrop.
Tests whether an object is a special object that the player is on or close to. The routine continues at TestNearObject.
Input
IX Address of the player
IY Address of the object
Output
F Carry flag set if the object can be picked up
TestObjectCanBePickedUp C172 LD A,(IY+$00) Fetch the graphic number of the object.
C175 SUB $60 Take off the graphic number of the first special object.
C177 CP $07 Compare it with the number of special objects.
C179 RET NC Return if the object is not a special object.
This entry point is used by the routine at HandleExtraLife.
Test whether the player is standing on, or next to, the object.
TestNearObject C17A PUSH BC Stash BC on the stack.
C17B LD BC,$0000 Set the offset in X to zero.
C17E LD L,C Set the offsets in Y and Z to zero.
C17F LD H,C
C180 CALL TestOverlapInX Test whether the objects overlap in X.
C183 JR NC,TestNearObject_Done Jump to TestNearObject_Done if they do not.
C185 CALL TestOverlapInY Test whether the objects overlap in Y.
C188 JR NC,TestNearObject_Done Jump to TestNearObject_Done if they do not.
C18A LD A,(IX+$03) Fetch the Z coordinate of the player.
C18D SUB $04 Take off 04.
C18F LD (IX+$03),A Set the new Z coordinate.
C192 CALL TestOverlapInZ Test whether the objects overlap in Z.
C195 PUSH AF Stash the result on the stack.
C196 LD A,(IX+$03) Fetch the Z coordinate of the player.
C199 ADD A,$04 Add 04 to it.
C19B LD (IX+$03),A Set the old Z coordinate.
C19E POP AF Restore the result from the stack.
TestNearObject_Done C19F POP BC Restore BC from the stack.
C1A0 RET Return.
View the equivalent code in;
Prev: C00E Up: Map Next: C1A1