Prev: E77A Up: Map Next: E7E9
E79B: See if a player wants to swap character, and do so if they can
Used by the routine at 8184.
E79B LD A,$F7 Get keyboard input from 1 - 5.
E79D IN A,($FE)
E79F OR $E0 Set the top three bits, to ensure all bits are set if no key is pressed.
E7A1 XOR $FF Were no keys pressed?
E7A3 RET Z Return if so.
A key was pressed. Work out what to do.
E7A4 LD B,(IY+$0F) Put the current character's room (BC76) in B.
E7A7 PUSH IY Remember the original pointer in IY.
E7A9 LD IY,$BC67 Point IY at the first character buffer (Wally). (BC67)
E7AD RRCA Was this key pressed? (Loops from 1 - 5.)
E7AE JR C,$E7B4 Jump if so.
E7B0 INC IY Otherwise move to the next entry and loop back.
E7B2 JR $E7AD
Found the character to switch to, can it be done?
E7B4 LD A,(IY+$0F) Get the character's room.
E7B7 CP B Is it this one?
E7B8 JR Z,$E7C0 Yes, so we can switch.
E7BA CALL $BA6E Otherwise, print "{character} is in {room}"
@labe l=Change Character_3
E7BD POP IY Clear up the stack and return.
E7BF RET
The character is in the same room, so the switch can be made.
E7C0 CALL $A921 Is this character the current one.
E7C3 JR Z,$E7BD If so, clear up the stack and return - there's nothing to do.
The character is in the room and it's not the current one, so switch.
E7C5 LD ($B09D),IY Set the current character pointer (B09D) to this one.
E7C9 POP IY Clear up the stack.
E7CB LD A,B Put the room in A.
E7CC CALL $AC69 Get the "next rooms" table for this room.
E7CF LD A,(HL) Put the first byte (room) in the buffer at BCD0.
E7D0 LD (IY+$69),A
E7D3 INC HL Put the second byte (destination co-ordinate) at BCCB.
E7D4 LD A,(HL)
E7D5 LD (IY+$64),A
E7D8 INC HL Put the third byte (target co-ordinate) at BCDA
E7D9 LD A,(HL)
E7DA LD (IY+$73),A
E7DD LD (IY+$6E),$05 Set the previous room to 5 (?)
E7E1 LD IY,($B09D) Point IY to the selected character.
E7E5 CALL $E3FD Refresh the status bar to reflect the new current character.
E7E8 RET Return.
Prev: E77A Up: Map Next: E7E9