Prev: D150 Up: Map Next: D1BE
D17C: Read Keyboard
Used by the routine at ReadControls.
Reads the controls from the keyboard. Left is X, V, M or B, right is C or N, up is any key from A to G or from H to ENTER, fire is any key from Q to T or from Y to P, and down is any key from 1 to 5 or from 6 to 0.
Output
C The controls
Read left and right from CAPS SHIFT to V.
ReadKeyboard D17C LD A,$FE Read from the keyboard;
Port Number Bit
0 1 2 3 4
FE CAPS SHIFT Z X C V
D17E CALL ReadKeyboardPort
D181 RRCA Move X to bit 0 and C to bit 1.
D182 RRCA
D183 BIT 2,A Set bit 0 if V is pressed.
D185 JR Z,ReadKeyboard_Movement
D187 SET 0,A
Keep left and right, and read SPACE to B.
ReadKeyboard_Movement D189 AND %00000011 Keep bits 0 and 1.
D18B LD C,A Put them in C.
D18C LD A,$7F Read from the keyboard;
Port Number Bit
0 1 2 3 4
7F SPACE SYMBOL SHIFT M N B
D18E CALL ReadKeyboardPort
D191 BIT 2,A Set bit 0 if M is pressed.
D193 JR Z,ReadKeyboard_TestN
D195 SET 0,C
Set bit 1 if N is pressed.
ReadKeyboard_TestN D197 BIT 3,A Set bit 1 if N is pressed.
D199 JR Z,ReadKeyboard_TestB
D19B SET 1,C
Set bit 0 if B is pressed.
ReadKeyboard_TestB D19D BIT 4,A Set bit 0 if B is pressed.
D19F JR Z,ReadKeyboard_MiddleRows
D1A1 SET 0,C
Set bit 2 if any key from A to G or H to ENTER is pressed.
ReadKeyboard_MiddleRows D1A3 LD A,$BD Read from the keyboard;
Port Number Bit
0 1 2 3 4
BD A or H S or J D or K F or L G or ENTER
D1A5 CALL ReadKeyboardPort
D1A8 JR Z,ReadKeyboard_TopRows Set bit 2 if any key is pressed.
D1AA SET 2,C
Set bit 3 if any key from Q to T or Y to P is pressed.
ReadKeyboard_TopRows D1AC LD A,$DB Read from the keyboard;
Port Number Bit
0 1 2 3 4
DB Q or Y W or U E or I R or O T or P
D1AE CALL ReadKeyboardPort
D1B1 JR Z,ReadKeyboard_NumberRows Set bit 3 if any key is pressed.
D1B3 SET 3,C
Set bit 4 if any key from 1 to 5 or 6 to 0 is pressed.
ReadKeyboard_NumberRows D1B5 LD A,$E7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
E7 1 or 6 2 or 7 3 or 8 4 or 9 5 or 0
D1B7 CALL ReadKeyboardPort
D1BA JR Z,ReadControls_Rotate Set bit 4 if any key is pressed.
D1BC SET 4,C
Continue on to ReadControls_Rotate.
View the equivalent code in;
Prev: D150 Up: Map Next: D1BE