Prev: 45067 Up: Map Next: 45165
45116: Controls: Left
Used by the routines at 45215, 61383 and 63673.
Output
A 0 for no press and 1 for pressed
Controls_Left 45116 LD A,(45787) If Game_Options is zero then jump to Controls_Left_Keyboard.
45119 OR A
45120 JR Z,Controls_Left_Keyboard
45122 CP 1 If Game_Options is not 1 then jump to Controls_Left_Sinclair.
45124 JR NZ,Controls_Left_Sinclair
Handle Kempston Joystick.
45126 IN A,(31) Read from Kempston Joystick.
45128 BIT 1,A If bit 1 is not set/ "LEFT" is being pressed then jump to Controls_Pressed_Left.
45130 JR NZ,Controls_Pressed_Left
45132 JR Controls_NoPress_Left Jump to Controls_NoPress_Left.
Handle Sinclair Joystick.
Controls_Left_Sinclair 45134 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
45136 IN A,(254)
45138 BIT 4,A If bit 4 is not set jump to Controls_NoPress_Left.
45140 JR NZ,Controls_NoPress_Left
Key was pressed so return A=1.
Controls_Pressed_Left 45142 LD A,1 A=1.
45144 RET Return.
Handle Keyboard controls.
Controls_Left_Keyboard 45145 LD A,251 Read from the keyboard;
Port Number Bit
0 1 2 3 4
251 Q W E R T
45147 IN A,(254)
Filter out the keys leaving only: Q, E and T.
45149 OR %11101010 Set bits 1, 3, 5-7.
45151 LD B,A Store the result in B.
45152 LD A,223 Read from the keyboard;
Port Number Bit
0 1 2 3 4
223 P O I U Y
45154 IN A,(254)
Filter out the keys leaving only: O and U.
45156 OR %11110101 Set bits 0, 2, 4-7.
45158 AND B Merge in the bits from B.
45159 CP 255 If the result is not 255 jump to Controls_Pressed_Left.
45161 JR NZ,Controls_Pressed_Left
No key was pressed so return A=0.
Controls_NoPress_Left 45163 XOR A A=0.
45164 RET Return.
Prev: 45067 Up: Map Next: 45165