Prev: 92E0 Up: Map Next: 9326
92F5: Pick a collectable up
The playthroughs that build the code map never reach this, so the automatic pass leaves it as data. It is not: the bytes decode cleanly as code from the first byte, and forcing it here costs nothing -- the round-trip check still reassembles the whole game byte for byte, which it could not do if the split were wrong.
The handler for sprites $80 to $8E -- the keys and the objects that kill the four big monsters. Like the food it does nothing but wait: every frame it asks whether the player is standing on it, and only then acts.
Picking something up is not free. The player can hold three things, and taking a fourth pushes the oldest out, so the three calls at the end run in the order they have to: DROP_CARRIED first, while the item about to be lost can still be read, then SHIFT_CARRIED to make room, then REMEMBER_CARRIED to put the new one at the front.
Input
IX The collectable
PICK_UP 92F5 CALL ACTOR_TO_WORKSPACE Position and sprite into the workspace.
92F8 LD A,($5E20) Two gates before anything else is considered.
92FB AND A
92FC JR Z,CLEAR_DRAW_FLAG
92FE LD A,($5E1F)
9301 AND $03
9303 JR NZ,DRAW_AT_POSITION
9305 LD A,($EA90) And the player has to actually be in play, the same $01-$30 test CHECK_HIT makes.
9308 DEC A
9309 CP $30
930B JR NC,DRAW_AT_POSITION
930D CALL NEAR_PLAYER Standing on it?
9310 JR NC,DRAW_AT_POSITION
9312 LD A,($5E1F) Mark this press of the pick-up key as used (bit 1), and a pick-up as done this pass (bit 0), so PUT_DOWN does not act on the same press.
9315 OR $03
9317 LD ($5E1F),A
931A CALL DROP_CARRIED Put the oldest of the three back into the world...
931D CALL SHIFT_CARRIED ...shift the other two along...
9320 CALL REMEMBER_CARRIED ...and record the new one at the front.
9323 JP DRAW_INVENTORY
Prev: 92E0 Up: Map Next: 9326