Prev: 34640 Up: Map Next: 34743
34684: HandleInput
Reads the keyboard and moves the corridor cursor. Calls the key-scanner at 34636, which packs five keys into 33682 (set bit = pressed): bit 0 = key 8, bit 1 = key 5, bit 2 = key 7, bit 3 = key 6, bit 4 = key 0 (action).
While the action key is held the border flashes yellow/black; on RELEASE control jumps to 34840, which dispatches through RoomDispatchTable on the current room mode (31252) — this is how a room's action handler / menu is opened.
Otherwise: key 6 -> 34743 (advance the cursor along the corridor), key 7 -> 34788 (retreat), and keys 8/5 move between rows when the room view has more than one row (mode != 0).
Used by the routine at 36457.
34684 CALL 34636 scan keyboard → 33642 bitmask
34687 LD A,(33682) A = key bitmask (33642)
34690 AND A any key pressed?
34691 RET Z no: return immediately
34692 BIT 4,A action/fire key held?
34694 JR Z,34716 no: check directional keys
34696 XOR A A = 0 (border black)
34697 EX AF,AF' save border colour to A'
34698 CALL 34636 re-scan keyboard (wait for release)
34701 LD A,(33682) read updated key state
34704 BIT 4,A action key still held?
34706 JP Z,34840 released: open the room-action dispatch
34709 EX AF,AF' restore A' border colour
34710 XOR 6 toggle between 0 (black) and 6 (yellow)
34712 OUT (254),A flash border
34714 JR 34697 repeat until key released
34716 BIT 3,A key 6 (advance)?
34718 JR NZ,34743 yes: advance cursor along the corridor
34720 BIT 2,A key 7 (retreat)?
34722 JR NZ,34788 yes: retreat cursor along the corridor
34724 AND 3 key 5 or key 8 (row movement)?
34726 RET Z no directional key: return
34727 LD A,(31252) A = room mode (31252)
34730 AND A mode 0 = single-row corridor (no up/down)
34731 RET Z in single-row mode: up/down keys ignored
34732 LD A,(33685) A = cell value under the cursor ($8395)
34735 CP 61 column 61 = leftmost valid position
34737 RET Z at left wall: cannot move
34738 CALL 34743 move one step (shares forward-move code)
34741 JR 34732 keep moving while at edge
Prev: 34640 Up: Map Next: 34743