Prev: 49166 Up: Map Next: 49569
49522: 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 49522 LD A,(IY+0) Fetch the graphic number of the object.
49525 SUB 96 Take off the graphic number of the first special object.
49527 CP 7 Compare it with the number of special objects.
49529 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 49530 PUSH BC Stash BC on the stack.
49531 LD BC,0 Set the offset in X to zero.
49534 LD L,C Set the offsets in Y and Z to zero.
49535 LD H,C
49536 CALL TestOverlapInX Test whether the objects overlap in X.
49539 JR NC,TestNearObject_Done Jump to TestNearObject_Done if they do not.
49541 CALL TestOverlapInY Test whether the objects overlap in Y.
49544 JR NC,TestNearObject_Done Jump to TestNearObject_Done if they do not.
49546 LD A,(IX+3) Fetch the Z coordinate of the player.
49549 SUB 4 Take off 4.
49551 LD (IX+3),A Set the new Z coordinate.
49554 CALL TestOverlapInZ Test whether the objects overlap in Z.
49557 PUSH AF Stash the result on the stack.
49558 LD A,(IX+3) Fetch the Z coordinate of the player.
49561 ADD A,4 Add 4 to it.
49563 LD (IX+3),A Set the old Z coordinate.
49566 POP AF Restore the result from the stack.
TestNearObject_Done 49567 POP BC Restore BC from the stack.
49568 RET Return.
View the equivalent code in;
Prev: 49166 Up: Map Next: 49569