Prev: 37600 Up: Map Next: 37670
37621: Handle Pickup Item
The handler for the items that the player can pick up (sprite IDs 128 to 142). If the pick up key is not pressed then ClearPickupFlag clears the flag for it. Otherwise nothing is done if another item has just been picked up (bits 0-1 of PickupFlags), or if the player is not a character, or if the player is not touching the item (see CheckPlayerTouching). If they are, the flags are set, the item that has been carried the longest is dropped (see DropItem), the others move along (see ShiftInventory), the item is picked up (see PickUpItem) and the inventory is drawn by DrawInventory.
Input
IX The item entity
HandlerPickupItem 37621 CALL StoreEntity Call StoreEntity to save the position of the item.
37624 LD A,(24096) Fetch the pickup pressed flag from PickupPressed.
37627 AND A Jump to ClearPickupFlag if the pick up key is not pressed.
37628 JR Z,ClearPickupFlag
37630 LD A,(24095) Fetch the pickup flags from PickupFlags.
37633 AND %00000011 Keep only bits 0-1.
37635 JR NZ,SetItemAttributes Jump to SetItemAttributes if an item has just been picked up.
37637 LD A,(60048) Fetch the sprite ID of the player from Player.
37640 DEC A Subtract one to get the ID that starts at zero.
37641 CP 48 Jump to SetItemAttributes if the player is not a character.
37643 JR NC,SetItemAttributes
37645 CALL CheckPlayerTouching Call CheckPlayerTouching to see whether the player is touching the item.
37648 JR NC,SetItemAttributes Jump to SetItemAttributes if not.
37650 LD A,(24095) Fetch the pickup flags from PickupFlags.
37653 OR %00000011 Set bits 0-1.
37655 LD (24095),A Update the pickup flags in PickupFlags.
37658 CALL DropItem Call DropItem to drop the third item.
37661 CALL ShiftInventory Call ShiftInventory to move the other items along.
37664 CALL PickUpItem Call PickUpItem to pick up the item.
37667 JP DrawInventory Jump to DrawInventory to draw the inventory.
Prev: 37600 Up: Map Next: 37670