Prev: 9398 Up: Map Next: 93E3
93BE: Read Controls
Used by the routines at HandlerWizard, ControlPlayer, HandlerSerf and HandlerKnight.
Reads the controls that were chosen in GameOptions. A bit is reset when the control is used: bit 0 is right, bit 1 is left, bit 2 is down, bit 3 is up and bit 4 is fire. The keyboard uses W, Q, E, R and T, the cursor keys are read by ReadCursorKeys and otherwise the Kempston joystick is read.
Output
A The state of the controls
ReadControls 93BE LD A,($5E00) Fetch the controls that were chosen from GameOptions.
93C1 AND %00000110 Keep only bits 1-2.
93C3 JR Z,ReadControls_Keyboard Jump to ReadControls_Keyboard if the keyboard is used.
93C5 CP $04 Jump to ReadCursorKeys if the cursor keys are used.
93C7 JR Z,ReadCursorKeys
93C9 IN A,($1F) Read the Kempston joystick.
93CB CPL Flip the bits, so that a reset bit is a control which is used.
93CC RET Return.
ReadControls_Keyboard 93CD LD A,$FB Read from the keyboard;
Port Number Bit
0 1 2 3 4
FB Q W E R T
93CF OUT ($FD),A
93D1 IN A,($FE)
93D3 LD C,A Keep the keys in C.
93D4 RRA Rotate A right, to move W (right) to bit 0.
93D5 AND %00000001 Keep only bit 0.
93D7 LD E,A Keep right in E.
93D8 LD A,C Fetch the keys.
93D9 RLA Rotate A left, to move Q (left) to bit 1.
93DA AND %00000010 Keep only bit 1.
93DC OR E Combine left with right.
93DD LD E,A Keep right and left in E.
93DE LD A,C Fetch the keys.
93DF AND %00011100 Keep only bits 2-4 (E is down, R is up and T is fire).
93E1 OR E Combine down, up and fire with right and left.
93E2 RET Return.
View the equivalent code in;
Prev: 9398 Up: Map Next: 93E3