Prev: C017 Up: Map Next: C0D4
C0A7: Pick Up Object
Used by the routine at HandlePickupAndDrop.
Picks up an object, which is put in the first place of the inventory (until it is moved along to the second place), and removed from the room. The object is changed into the marker that makes DrawObject erase it. If the carried objects are all in use, the oldest one is dropped where the other one was.
Input
IY Record of the object that is being picked up
Copy the object into the first place of the inventory.
PickUpObject C0A7 LD HL,$A722 Start at the first place of the inventory, ObjectsCarried.
C0AA LD A,(IY+$00) Set the type of the object in the inventory.
C0AD LD (HL),A
C0AE INC HL Move on to the flags.
C0AF LD A,(IY+$07) Set the flags of the object.
C0B2 LD (HL),A
C0B3 INC HL Move on to the address of the object in the store.
C0B4 LD E,(IY+$10) Fetch the address of the object in the store.
C0B7 LD D,(IY+$11)
C0BA XOR A Write zero to the store, to say that the object is no longer in the room.
C0BB LD (DE),A
C0BC LD (HL),E Set the address in the inventory.
C0BD INC HL
C0BE LD (HL),D
Erase the object from the room.
C0BF CALL SetWipeAndDrawFlagsForObject Call SetWipeAndDrawFlagsForObject to mark the object to be drawn.
C0C2 LD (IY+$00),$01 Change the object to the type that makes it be erased.
Drop the oldest carried object if the inventory is full.
C0C6 LD HL,$A72E Take the oldest carried object, ObjectsCarried_Oldest.
C0C9 LD A,(HL) Fetch the type of it.
C0CA INC HL
C0CB AND A Jump to DropObject_MoveAlong to move the objects along if it is not in use.
C0CC JR Z,DropObject_MoveAlong
C0CE LD (IY+$00),A Make it the type of the object that is picked up, so that it is dropped here.
C0D1 PUSH HL Stash the address of the flags of the carried object on the stack.
C0D2 JR DropObject_SetUp Jump to DropObject_SetUp to set up the dropped object.
Prev: C017 Up: Map Next: C0D4