Prev: C979 Up: Map Next: CA07
C9A5: Read Keyboard
Used by the routine at ReadControls.
Reads the controls from the keyboard. Left is Z, C, M or B, right is X, V, symbol shift or N, walking forward is any key of the rows A to G and H to ENTER, jumping is any key of the rows Q to T and Y to P, and picking up and dropping an object is any key of the rows 1 to 5 and 6 to 0.
Output
C The controls
Left and right from the bottom row.
ReadKeyboard C9A5 LD A,$FE Read from the keyboard;
Port Number Bit
0 1 2 3 4
FE SHIFT Z X C V
C9A7 CALL ReadKeyboardPort
C9AA RRCA Rotate Z into bit 0.
C9AB LD C,A Copy it to C.
C9AC AND %00000011 Keep only bits 0 and 1.
C9AE SRL C Shift C and V into bits 0 and 1.
C9B0 SRL C
C9B2 OR C Merge C.
C9B3 AND %00000011 Keep only bits 0 and 1.
C9B5 LD C,A Copy them to C.
C9B6 LD A,$7F Read from the keyboard;
Port Number Bit
0 1 2 3 4
7F SPACE SYMBOL SHIFT M N B
C9B8 CALL ReadKeyboardPort
C9BB BIT 1,A Set bit 1 of C if bit 1 of A is set.
C9BD JR Z,ReadKeyboard_TestM
C9BF SET 1,C
ReadKeyboard_TestM C9C1 BIT 2,A Set bit 0 of C if bit 2 of A is set.
C9C3 JR Z,ReadKeyboard_TestN
C9C5 SET 0,C
ReadKeyboard_TestN C9C7 BIT 3,A Set bit 1 of C if bit 3 of A is set.
C9C9 JR Z,ReadKeyboard_TestB
C9CB SET 1,C
ReadKeyboard_TestB C9CD BIT 4,A Set bit 0 of C if bit 4 of A is set.
C9CF JR Z,ReadKeyboard_WalkKeys
C9D1 SET 0,C
ReadKeyboard_WalkKeys C9D3 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
C9D5 CALL ReadKeyboardPort
C9D8 JR Z,ReadKeyboard_JumpKeys Set bit 2 of C if a key is pressed.
C9DA SET 2,C
ReadKeyboard_JumpKeys C9DC LD A,$DB Read from the keyboard;
Port Number Bit
0 1 2 3 4
DB Q / P W / O E / I R / U T / Y
C9DE CALL ReadKeyboardPort
C9E1 JR Z,ReadKeyboard_PickUpKeys Set bit 3 of C if a key is pressed.
C9E3 SET 3,C
ReadKeyboard_PickUpKeys C9E5 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
C9E7 CALL ReadKeyboardPort
C9EA JR Z,ReadControls_Finish Set bit 4 of C if a key is pressed.
C9EC SET 4,C
This entry point is used by the routines at ReadControls, ReadInterface2Joystick, ReadKempstonJoystick and ReadCursorJoystick.
Read the keys that pick up and drop an object when a joystick with directional control is in use. The keys that count are Z, X, C, V, A to G, H to ENTER, Q to T and Y to P.
ReadControls_Finish C9EE 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
C9F0 CALL ReadKeyboardPort
C9F3 AND %00011110 Keep only bits 1-4.
C9F5 PUSH BC Stash BC on the stack.
C9F6 LD B,A Copy the keys to B.
C9F7 LD A,$99 Read the keys A to G, Q to T, Y to P and H to ENTER.
C9F9 CALL ReadKeyboardPort
C9FC OR B Merge B.
C9FD POP BC Restore BC from the stack.
C9FE JR Z,ReadControls_Store Jump to ReadControls_Store if no key is pressed.
CA00 SET 5,C Set bit 5 of C.
ReadControls_Store CA02 LD A,C Copy C to A.
CA03 LD ($5B15),A Set ControlsPressed.
CA06 RET Return.
View the equivalent code in;
Prev: C979 Up: Map Next: CA07