Prev: 92E0 Up: Map Next: 9326
92F5: Handle Pickup Item
The handler for the items that the player can pick up (sprite IDs 80 to 8E). 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 92F5 CALL StoreEntity Call StoreEntity to save the position of the item.
92F8 LD A,($5E20) Fetch the pickup pressed flag from PickupPressed.
92FB AND A Jump to ClearPickupFlag if the pick up key is not pressed.
92FC JR Z,ClearPickupFlag
92FE LD A,($5E1F) Fetch the pickup flags from PickupFlags.
9301 AND %00000011 Keep only bits 0-1.
9303 JR NZ,SetItemAttributes Jump to SetItemAttributes if an item has just been picked up.
9305 LD A,($EA90) Fetch the sprite ID of the player from Player.
9308 DEC A Subtract one to get the ID that starts at zero.
9309 CP $30 Jump to SetItemAttributes if the player is not a character.
930B JR NC,SetItemAttributes
930D CALL CheckPlayerTouching Call CheckPlayerTouching to see whether the player is touching the item.
9310 JR NC,SetItemAttributes Jump to SetItemAttributes if not.
9312 LD A,($5E1F) Fetch the pickup flags from PickupFlags.
9315 OR %00000011 Set bits 0-1.
9317 LD ($5E1F),A Update the pickup flags in PickupFlags.
931A CALL DropItem Call DropItem to drop the third item.
931D CALL ShiftInventory Call ShiftInventory to move the other items along.
9320 CALL PickUpItem Call PickUpItem to pick up the item.
9323 JP DrawInventory Jump to DrawInventory to draw the inventory.
Prev: 92E0 Up: Map Next: 9326