Prev: 45306 Up: Map Next: 45359
45315: Controls: Cursor Joystick
Used by the routine at HandlerControls.
Reads a Cursor joystick, which is mapped onto the keys "5" to "8" and "0".
Output
C Joystick controls
Initialise the controls as "none" in C.
ReadCursorJoystick 45315 LD C,0 Clear the controls in C.
The cursor keys are covered by different ports.
HandleCursorJoystick_Port_F7 45317 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
45319 OUT (253),A
45321 IN A,(254)
Check joystick "LEFT".
ReadCursorJoystick_Left 45323 BIT 4,A Jump to HandleCursorJoystick_Port_EF if "LEFT" (key "5") is not being pressed.
45325 JR NZ,HandleCursorJoystick_Port_EF
45327 SET 0,C Set the "LEFT" bit (bit 0) of the controls in C.
Handle the other port.
HandleCursorJoystick_Port_EF 45329 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
45331 OUT (253),A
45333 IN A,(254)
Check joystick "DOWN".
ReadCursorJoystick_Down 45335 BIT 4,A Jump to ReadCursorJoystick_Up if "DOWN" (key "6") is not being pressed.
45337 JR NZ,ReadCursorJoystick_Up
45339 SET 3,C Set the "DOWN" bit (bit 3) of the controls in C.
Check joystick "UP".
ReadCursorJoystick_Up 45341 BIT 3,A Jump to ReadCursorJoystick_Right if "UP" (key "7") is not being pressed.
45343 JR NZ,ReadCursorJoystick_Right
45345 SET 2,C Set the "UP" bit (bit 2) of the controls in C.
Check joystick "RIGHT".
ReadCursorJoystick_Right 45347 BIT 2,A Jump to ReadCursorJoystick_Fire if "RIGHT" (key "8") is not being pressed.
45349 JR NZ,ReadCursorJoystick_Fire
45351 SET 1,C Set the "RIGHT" bit (bit 1) of the controls in C.
Check joystick "FIRE".
ReadCursorJoystick_Fire 45353 BIT 0,A Return if "FIRE" (key "0") is not being pressed.
45355 RET NZ
45356 SET 4,C Set the "FIRE" bit (bit 4) of the controls in C.
45358 RET Return.
View the equivalent code in;
Prev: 45306 Up: Map Next: 45359