Prev: 53404 Up: Map Next: 53546
53448: 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 53448 LD A,254 Read from the keyboard;
Port Number Bit
0 1 2 3 4
254 SHIFT Z X C V
53450 CALL ReadKeyboardPort
53453 RRCA Move Z into bit 0.
53454 LD C,A Stash the keys in C.
53455 AND %00000011 Keep Z and X.
53457 SRL C Move C and V into bits 0 and 1.
53459 SRL C
53461 OR C Combine them with Z and X.
53462 AND %00000011 Keep the left and right bits.
53464 LD C,A Stash them in C.
53465 LD A,127 Read from the keyboard;
Port Number Bit
0 1 2 3 4
127 SPACE SYMBOL SHIFT M N B
53467 CALL ReadKeyboardPort
53470 BIT 1,A Set the right control if symbol shift is pressed.
53472 JR Z,ReadKeyboard_TestM
53474 SET 1,C
ReadKeyboard_TestM 53476 BIT 2,A Set the left control if M is pressed.
53478 JR Z,ReadKeyboard_TestN
53480 SET 0,C
ReadKeyboard_TestN 53482 BIT 3,A Set the right control if N is pressed.
53484 JR Z,ReadKeyboard_TestB
53486 SET 1,C
ReadKeyboard_TestB 53488 BIT 4,A Set the left control if B is pressed.
53490 JR Z,ReadKeyboard_WalkKeys
53492 SET 0,C
ReadKeyboard_WalkKeys 53494 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
53496 CALL ReadKeyboardPort
53499 JR Z,ReadKeyboard_JumpKeys Set the walk control if any of them is pressed.
53501 SET 2,C
ReadKeyboard_JumpKeys 53503 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
53505 CALL ReadKeyboardPort
53508 JR Z,ReadKeyboard_PickUpKeys Set the jump control if any of them is pressed.
53510 SET 3,C
ReadKeyboard_PickUpKeys 53512 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
53514 CALL ReadKeyboardPort
53517 JR Z,ReadControls_Finish Set the pick up control if any of them is pressed.
53519 SET 4,C
This entry point is used by the routines at ReadControls, ReadInterface2Joystick, ReadKempstonJoystick and ReadCursorJoystick.
Reads 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 53521 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
53523 CALL ReadKeyboardPort
53526 AND %00011110 Keep the keys Z, X, C, V, symbol shift, M, N and B.
53528 PUSH BC Stash BC on the stack.
53529 LD B,A Stash the keys in B.
53530 LD A,153 Read the keys SHIFT to V, 1 to 5, 6 to 0 and SPACE to B.
53532 CALL ReadKeyboardPort
53535 OR B Combine the keys.
53536 POP BC Restore BC from the stack.
53537 JR Z,ReadControls_Store Jump to ReadControls_Store if no key is pressed.
53539 SET 5,C Set the directional pick up control.
ReadControls_Store 53541 LD A,C Fetch the controls.
53542 LD (23477),A Store them at ControlsPressed.
53545 RET Return.
View the equivalent code in;
Prev: 53404 Up: Map Next: 53546