Prev: EB01 Up: Map Next: EB54
EB0F: Action 1 : SWAPFOR. An item can be collected. Swap it for a specific item.
-
Input
HL Points to the object ID that should be swapped
EB0F LD A,$01 Set that the item should be swapped. (EB54)
EB11 LD ($EB54),A
EB14 LD B,(IY-$2D) Get the ID of the least recently picked up object the player has.
EB17 LD C,(HL) Put the ID of the object to swap in C.
EB18 INC HL Ensure HL points to the next place in the action buffer.
EB19 PUSH HL Remember this.
EB1A PUSH IY Remember the current player pointer in IY.
EB1C CALL $AA8C Get the buffer for this object.
EB1F LD A,(IY+$50) Get the ID of the first object held.
EB22 CP C Does it equal this one?
EB23 JR Z,$EB2F Jump forward if it does.
EB25 INC IY Otherwise, temporarily shift IY forward so the second object held appears at the first.
EB27 INC IY
EB29 INC IY
EB2B INC IY
EB2D INC IY
EB2F LD C,(HL) Put the ID of the object in the room in C.
EB30 LD A,(IY+$50) Get the ID of the object to swap (first or second) in A.
EB33 LD (HL),A Swap them round.
EB34 LD (IY+$50),C
EB37 INC HL Move to the flags.
EB38 INC HL
EB39 INC HL
EB3A LD A,(HL) Put the flags in A.
EB3B RES 7,A Reset bit 7, the item has been swapped.
EB3D LD C,A Store this in C.
EB3E LD A,(HL) Put the flags in A.
EB3F AND $80 Clear bit 7.
EB41 OR (IY-$37) Keep the bits set on the current bit mask.
EB44 LD (HL),A Store this.
EB45 LD (IY-$37),C Store the old flags.
EB48 POP IY Restore the original value of IY.
EB4A CALL $E41D Update the inventory.
EB4D CALL $AA7F Play an "item swapped" effect.
EB50 POP HL Restore the place in the buffer to HL.
EB51 JP $EAEB Process more actions.
Prev: EB01 Up: Map Next: EB54