Prev: 37708 Up: Map Next: 37771
37720: Drop Item
Used by the routines at HandlerPickupItem and HandlerBlank.
Puts the item in the third slot of the inventory (see Inventory_Slot3) back into the room at the position of the player, and makes the sound of dropping. Nothing is done if the slot is empty.
DropItem 37720 LD HL,24120 Point HL at the third inventory slot at Inventory_Slot3.
37723 LD E,(HL) Fetch the low byte of the address of the entity.
37724 INC HL Move on to the next byte.
37725 LD D,(HL) Fetch the high byte of the address of the entity.
37726 INC HL Move on to the next byte.
37727 LD A,D Return if the slot is empty (the address of the entity is zero).
37728 OR E
37729 RET Z
37730 PUSH DE Stash the address of the entity on the stack.
37731 LD A,(HL) Fetch the sprite ID in the slot.
37732 INC HL Move on to the next byte.
37733 LD (DE),A Update the sprite ID of the entity.
37734 INC DE Move on to the room of the entity.
37735 LD A,(60049) Fetch the room of the player from PlayerRoom.
37738 LD (DE),A Update the room of the entity.
37739 INC DE Move on to offset 2 of the entity.
37740 LD A,128 Write 128 to offset 2 of the entity.
37742 LD (DE),A
37743 INC DE Move on to the X position of the entity.
37744 LD A,(60051) Fetch the X position of the player from 60051.
37747 LD (DE),A Update the X position of the entity.
37748 INC DE Move on to the Y position of the entity.
37749 LD A,(60052) Fetch the Y position of the player from 60052.
37752 LD (DE),A Update the Y position of the entity.
37753 INC DE Move on to the attribute of the entity.
37754 LD A,(HL) Fetch the attribute in the slot.
37755 LD (DE),A Update the attribute of the entity.
37756 POP DE Restore the address of the entity from the stack.
37757 CALL SoundsDropItem Call SoundsDropItem to make the sound of dropping.
37760 PUSH IX Stash IX on the stack.
37762 PUSH DE Copy DE into IX, as the entity to draw.
37763 POP IX
37765 CALL DrawEntity Call DrawEntity to draw the entity.
37768 POP IX Restore IX from the stack.
37770 RET Return.
Prev: 37708 Up: Map Next: 37771