Prev: B0B1 Up: Map Next: B0FA
B0D9: Controls: Kempston Joystick
Used by the routine at HandlerControls.
Reads a Kempston joystick from port 1F. A bit is set in the port for each direction or button pressed, which is moved onto the matching bit of the controls.
Output
A Joystick controls
C Joystick controls
ReadKempstonJoystick B0D9 IN A,($1F) Read the joystick port into A.
Initialise the controls as "none" in C.
B0DB LD C,$00 Clear the controls in C.
Check joystick "RIGHT".
ReadKempstonJoystick_Right B0DD BIT 0,A Jump to ReadKempstonJoystick_Left if "RIGHT" is not being pressed.
B0DF JR Z,ReadKempstonJoystick_Left
B0E1 SET 1,C Set the "RIGHT" bit (bit 1) of the controls in C.
Check joystick "LEFT".
ReadKempstonJoystick_Left B0E3 BIT 1,A Jump to ReadKempstonJoystick_Down if "LEFT" is not being pressed.
B0E5 JR Z,ReadKempstonJoystick_Down
B0E7 SET 0,C Set the "LEFT" bit (bit 0) of the controls in C.
Check joystick "DOWN".
ReadKempstonJoystick_Down B0E9 BIT 2,A Jump to ReadKempstonJoystick_Up if "DOWN" is not being pressed.
B0EB JR Z,ReadKempstonJoystick_Up
B0ED SET 3,C Set the "DOWN" bit (bit 3) of the controls in C.
Check joystick "UP".
ReadKempstonJoystick_Up B0EF BIT 3,A Jump to ReadKempstonJoystick_Fire if "UP" is not being pressed.
B0F1 JR Z,ReadKempstonJoystick_Fire
B0F3 SET 2,C Set the "UP" bit (bit 2) of the controls in C.
Check joystick "FIRE".
ReadKempstonJoystick_Fire B0F5 AND %00010000 Keep only bit 4 ("FIRE").
B0F7 OR C Merge the other controls into the "FIRE" bit and store the controls in C.
B0F8 LD C,A
B0F9 RET Return.
View the equivalent code in;
Prev: B0B1 Up: Map Next: B0FA