Prev: 45233 Up: Map Next: 45306
45273: Controls: Kempston Joystick
Used by the routine at HandlerControls.
Reads a Kempston joystick from port 31. 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 45273 IN A,(31) Read the joystick port into A.
Initialise the controls as "none" in C.
45275 LD C,0 Clear the controls in C.
Check joystick "RIGHT".
ReadKempstonJoystick_Right 45277 BIT 0,A Jump to ReadKempstonJoystick_Left if "RIGHT" is not being pressed.
45279 JR Z,ReadKempstonJoystick_Left
45281 SET 1,C Set the "RIGHT" bit (bit 1) of the controls in C.
Check joystick "LEFT".
ReadKempstonJoystick_Left 45283 BIT 1,A Jump to ReadKempstonJoystick_Down if "LEFT" is not being pressed.
45285 JR Z,ReadKempstonJoystick_Down
45287 SET 0,C Set the "LEFT" bit (bit 0) of the controls in C.
Check joystick "DOWN".
ReadKempstonJoystick_Down 45289 BIT 2,A Jump to ReadKempstonJoystick_Up if "DOWN" is not being pressed.
45291 JR Z,ReadKempstonJoystick_Up
45293 SET 3,C Set the "DOWN" bit (bit 3) of the controls in C.
Check joystick "UP".
ReadKempstonJoystick_Up 45295 BIT 3,A Jump to ReadKempstonJoystick_Fire if "UP" is not being pressed.
45297 JR Z,ReadKempstonJoystick_Fire
45299 SET 2,C Set the "UP" bit (bit 2) of the controls in C.
Check joystick "FIRE".
ReadKempstonJoystick_Fire 45301 AND %00010000 Keep only bit 4 ("FIRE").
45303 OR C Merge the other controls into the "FIRE" bit and store the controls in C.
45304 LD C,A
45305 RET Return.
View the equivalent code in;
Prev: 45233 Up: Map Next: 45306