Prev: 37822 Up: Map Next: 37921
37859: Handle Blank
The handler for the entity with sprite ID 49 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 37859 LD A,(60048) Fetch the sprite ID of the player from Player.
37862 DEC A Subtract one to get the ID that starts at zero.
37863 CP 48 Return if the player is not a character.
37865 RET NC
Test the pick up key.
37866 LD A,(24096) Fetch the pickup pressed flag from PickupPressed.
37869 AND A Jump to HandlerBlank_KeyUp if the pick up key is not pressed.
37870 JR Z,HandlerBlank_KeyUp
Skip the drop if this press has already picked up or dropped an item.
37872 LD A,(24095) Fetch the pickup flags from PickupFlags.
37875 AND %00000011 Keep only bits 0-1.
37877 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.
37879 OR %00000010 Set bit 1.
37881 LD (24095),A Update the pickup flags in PickupFlags.
37884 CALL DropItem Call DropItem to drop the third item.
37887 CALL ShiftInventory Call ShiftInventory to move the other items along.
Empty the first slot and redraw the inventory.
37890 LD HL,0 Write 0000 to the first inventory slot, as the address of no entity and as the sprite ID and attribute.
37893 LD (24112),HL
37896 LD (24114),HL
37899 CALL DrawInventory Call DrawInventory to draw the inventory.
Clear the bit that is set when an item is picked up.
HandlerBlank_Finish 37902 LD A,(24095) Fetch the pickup flags from PickupFlags.
37905 AND %11111110 Reset bit 0.
37907 LD (24095),A Update the pickup flags in PickupFlags.
37910 RET Return.
The pick up key is up, so allow another drop on the next press.
HandlerBlank_KeyUp 37911 LD A,(24095) Fetch the pickup flags from PickupFlags.
37914 AND %11111101 Reset bit 1.
37916 LD (24095),A Update the pickup flags in PickupFlags.
37919 JR HandlerBlank_Finish Jump to HandlerBlank_Finish to finish handling the blank item.
Prev: 37822 Up: Map Next: 37921