Prev: 51577 Up: Map Next: 51719
51621: 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 51621 LD A,254 Read from the keyboard;
Port Number Bit
0 1 2 3 4
254 SHIFT Z X C V
51623 CALL ReadKeyboardPort
51626 RRCA Rotate Z into bit 0.
51627 LD C,A Copy it to C.
51628 AND %00000011 Keep only bits 0 and 1.
51630 SRL C Shift C and V into bits 0 and 1.
51632 SRL C
51634 OR C Merge C.
51635 AND %00000011 Keep only bits 0 and 1.
51637 LD C,A Copy them to C.
51638 LD A,127 Read from the keyboard;
Port Number Bit
0 1 2 3 4
127 SPACE SYMBOL SHIFT M N B
51640 CALL ReadKeyboardPort
51643 BIT 1,A Set bit 1 of C if bit 1 of A is set.
51645 JR Z,ReadKeyboard_TestM
51647 SET 1,C
ReadKeyboard_TestM 51649 BIT 2,A Set bit 0 of C if bit 2 of A is set.
51651 JR Z,ReadKeyboard_TestN
51653 SET 0,C
ReadKeyboard_TestN 51655 BIT 3,A Set bit 1 of C if bit 3 of A is set.
51657 JR Z,ReadKeyboard_TestB
51659 SET 1,C
ReadKeyboard_TestB 51661 BIT 4,A Set bit 0 of C if bit 4 of A is set.
51663 JR Z,ReadKeyboard_WalkKeys
51665 SET 0,C
ReadKeyboard_WalkKeys 51667 LD A,189 Read from the keyboard;
Port Number Bit
0 1 2 3 4
189 A / ENTER S / L D / K F / J G / H
51669 CALL ReadKeyboardPort
51672 JR Z,ReadKeyboard_JumpKeys Set bit 2 of C if a key is pressed.
51674 SET 2,C
ReadKeyboard_JumpKeys 51676 LD A,219 Read from the keyboard;
Port Number Bit
0 1 2 3 4
219 Q / P W / O E / I R / U T / Y
51678 CALL ReadKeyboardPort
51681 JR Z,ReadKeyboard_PickUpKeys Set bit 3 of C if a key is pressed.
51683 SET 3,C
ReadKeyboard_PickUpKeys 51685 LD A,231 Read from the keyboard;
Port Number Bit
0 1 2 3 4
231 1 / 0 2 / 9 3 / 8 4 / 7 5 / 6
51687 CALL ReadKeyboardPort
51690 JR Z,ReadControls_Finish Set bit 4 of C if a key is pressed.
51692 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 51694 LD A,126 Read from the keyboard;
Port Number Bit
0 1 2 3 4
126 SHIFT / SPACE Z / SYM X / M C / N V / B
51696 CALL ReadKeyboardPort
51699 AND %00011110 Keep only bits 1-4.
51701 PUSH BC Stash BC on the stack.
51702 LD B,A Copy the keys to B.
51703 LD A,153 Read the keys A to G, Q to T, Y to P and H to ENTER.
51705 CALL ReadKeyboardPort
51708 OR B Merge B.
51709 POP BC Restore BC from the stack.
51710 JR Z,ReadControls_Store Jump to ReadControls_Store if no key is pressed.
51712 SET 5,C Set bit 5 of C.
ReadControls_Store 51714 LD A,C Copy C to A.
51715 LD (23317),A Set ControlsPressed.
51718 RET Return.
View the equivalent code in;
Prev: 51577 Up: Map Next: 51719