Prev: 93BE Up: Map Next: 9421
93E3: Handle Blank
The handler for the entity with sprite ID 31 which is always there. While the player is a character it drops the inventory when the pick up key is pressed. The item in the third slot is dropped (see DropItem), the other slots are moved along (see ShiftInventory) and the first slot is emptied. Bit 1 of PickupFlags is set while the key is held down.
Input
IX The entity
Return unless the player is a character.
HandlerBlank 93E3 LD A,($EA90) Fetch the sprite ID of the player from Player.
93E6 DEC A Subtract one to get the ID that starts at zero.
93E7 CP $30 Return if the player is not a character.
93E9 RET NC
Test the pick up key.
93EA LD A,($5E20) Fetch the pickup pressed flag from PickupPressed.
93ED AND A Jump to HandlerBlank_KeyUp if the pick up key is not pressed.
93EE JR Z,HandlerBlank_KeyUp
Skip the drop if this press has already picked up or dropped an item.
93F0 LD A,($5E1F) Fetch the pickup flags from PickupFlags.
93F3 AND %00000011 Keep only bits 0-1.
93F5 JR NZ,HandlerBlank_Finish Jump to HandlerBlank_Finish if this press has already been used.
Mark the key as used and drop the oldest item.
93F7 OR %00000010 Set bit 1.
93F9 LD ($5E1F),A Update the pickup flags in PickupFlags.
93FC CALL DropItem Call DropItem to drop the third item.
93FF CALL ShiftInventory Call ShiftInventory to move the other items along.
Empty the first slot and redraw the inventory.
9402 LD HL,$0000 Write 0000 to the first inventory slot, as the address of no entity and as the sprite ID and attribute.
9405 LD ($5E30),HL
9408 LD ($5E32),HL
940B CALL DrawInventory Call DrawInventory to draw the inventory.
Clear the bit that is set when an item is picked up.
HandlerBlank_Finish 940E LD A,($5E1F) Fetch the pickup flags from PickupFlags.
9411 AND %11111110 Reset bit 0.
9413 LD ($5E1F),A Update the pickup flags in PickupFlags.
9416 RET Return.
The pick up key is up, so allow another drop on the next press.
HandlerBlank_KeyUp 9417 LD A,($5E1F) Fetch the pickup flags from PickupFlags.
941A AND %11111101 Reset bit 1.
941C LD ($5E1F),A Update the pickup flags in PickupFlags.
941F JR HandlerBlank_Finish Jump to HandlerBlank_Finish to finish handling the blank item.
Prev: 93BE Up: Map Next: 9421