Prev: B103 Up: Map Next: B1A3
B11C: Read Keyboard
Used by the routine at ReadControls.
Reads the keyboard. The keys C, M and B turn right, and X, V and N turn left. Any of A, S, D, F, G, Enter, L, K, J and H moves forward. The keys O, U, Q, E and T fire the second weapon, and P, I, Y, W and R fire the first one. Z, Symbol Shift and all of the number keys use the action key.
Output
A The controls
C The controls
ReadKeyboard B11C LD A,$FE Read from the keyboard;
Port Number Bit
0 1 2 3 4
FE SHIFT Z X C V
B11E CALL ReadKeys
B121 PUSH BC Save BC.
B122 RRCA Move the keys Z, X, C and V into the lowest bits...
B123 AND $0E ...and keep X, C and V.
B125 LD C,A Keep the keys X, C and V.
B126 AND $03 Keep X, which turns left...
B128 SRL C ...and move C and V down by two bits.
B12A SRL C Shift C into the right-turn bit and V into the left-turn bit.
B12C OR C Combine them, so that C turns right and X or V turn left...
B12D AND $03 ...and keep just the bits for turning.
B12F LD C,A
B130 LD A,$7F Read from the keyboard;
Port Number Bit
0 1 2 3 4
7F SPACE SYMBOL SHIFT M N B
B132 CALL ReadKeys
B135 RRA Move the keys Symbol Shift, M, N and B into the lowest bits...
B136 AND $0E ...and keep M, N and B.
B138 LD B,A Keep the keys M, N and B.
B139 RR B Rotate the keys round, so that N turns left and M turns right...
B13B RLA Shift the next key in.
B13C RR B Rotate the keys that are left.
B13E RLA Shift the next key in.
B13F AND $03 ...keep just the bits for turning and combine them with the others.
B141 OR C
B142 LD C,A Keep the turning bits.
B143 RR B Do the same for the last of the keys, so that B turns right...
B145 RLA Shift the last key in.
B146 RR B Rotate the keys that are left.
B148 RLA Shift the last key in.
B149 AND $03 ...keep just the bits for turning and combine them with the others.
B14B OR C
B14C POP BC Restore BC.
B14D LD C,A Keep the bits for turning.
B14E LD A,$BD Read from the keyboard;
Port Number Bit
0 1 2 3 4
BD A / ENTER S / L D / K F / J G / H
B150 CALL ReadKeys
B153 AND $1F Jump if none of them is pressed.
B155 JR Z,ReadKeyboard_ReadPToY
B157 SET 2,C Set the bit for moving forward.
ReadKeyboard_ReadPToY B159 LD A,$DF Read from the keyboard;
Port Number Bit
0 1 2 3 4
DF P O I U Y
B15B CALL ReadKeys
B15E LD B,A Keep the keys P to Y.
B15F AND $0A Jump if neither O nor U is pressed.
B161 JR Z,ReadKeyboard_CheckPIY
B163 SET 3,C Set the bit for firing the second weapon.
ReadKeyboard_CheckPIY B165 LD A,B Fetch the keys again.
B166 AND $15 Jump if none of P, I and Y is pressed.
B168 JR Z,ReadKeyboard_ReadQToT
B16A SET 4,C Set the bit for firing the first weapon.
ReadKeyboard_ReadQToT B16C LD A,$FB Read from the keyboard;
Port Number Bit
0 1 2 3 4
FB Q W E R T
B16E CALL ReadKeys
B171 LD B,A Keep the keys Q to T.
B172 AND $15 Jump if none of Q, E and T is pressed.
B174 JR Z,ReadKeyboard_CheckQET
B176 SET 3,C Set the bit for firing the second weapon.
ReadKeyboard_CheckQET B178 LD A,B Fetch the keys again.
B179 AND $0A Jump if neither W nor R is pressed.
B17B JR Z,ReadKeyboard_Controls
B17D SET 4,C Set the bit for firing the first weapon.
ReadKeyboard_Controls B17F LD A,($9625) Fetch the controls that have not been used yet...
B182 OR C ...and add the new ones.
B183 LD C,A Keep the controls.
B184 RES 6,C Clear the bit for the action key.
B186 LD A,$7E Read from the keyboard;
Port Number Bit
0 1 2 3 4
7E SHIFT / SPACE Z / SYM X / M C / N V / B
B188 CALL ReadKeys
B18B AND $02 Jump if neither Z nor Symbol Shift is pressed.
B18D JR Z,ReadKeyboard_ReadNumbers
B18F SET 6,C Set the bit for the action key.
ReadKeyboard_ReadNumbers B191 LD A,$E7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
E7 1 / 0 2 / 9 3 / 8 4 / 7 5 / 6
B193 CALL ReadKeys
B196 AND $1F Jump if none of the number keys is pressed.
B198 JR Z,ReadKeyboard_Store
B19A SET 6,C Set the bit for the action key.
ReadKeyboard_Store B19C LD A,C Fetch the controls...
B19D LD ($9625),A ...and store them.
B1A0 POP BC Restore BC.
B1A1 LD C,A Return the controls in C as well.
B1A2 RET Return.
Prev: B103 Up: Map Next: B1A3