Prev: C8FF Up: Map Next: C954
C91B: Read Interface 2 Joystick
Reads the controls from the Interface 2 joysticks, which are the keys 1 to 5 for the first joystick and 6 to 0 for the second joystick. The joysticks use the keys left, right, down, up and fire in that order, so the keys of the first joystick are reversed to put them in the same order as the keys of the second joystick.
Output
C The controls
Reverse the keys 1 to 5.
ReadInterface2Joystick C91B LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
C91D CALL ReadKeyboardPort
C920 PUSH BC Stash BC on the stack.
C921 LD B,$05 Set B to 05.
ReadInterface2Joystick_Reverse C923 RRA Rotate A right.
C924 RL C Rotate C left.
C926 DJNZ ReadInterface2Joystick_Reverse Jump to ReadInterface2Joystick_Reverse until B is zero.
C928 LD A,C Copy C to A.
C929 POP BC Restore BC from the stack.
C92A LD C,A Copy it to C.
Merge the keys 6 to 0.
C92B LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
C92D CALL ReadKeyboardPort
C930 OR C Merge C.
C931 LD C,$00 Set C to 00.
C933 BIT 0,A Set bit 3 of C if bit 0 of A is set.
C935 JR Z,ReadInterface2Joystick_TestUp
C937 SET 3,C
ReadInterface2Joystick_TestUp C939 BIT 1,A Set bit 2 of C if bit 1 of A is set.
C93B JR Z,ReadInterface2Joystick_TestDown
C93D SET 2,C
ReadInterface2Joystick_TestDown C93F BIT 2,A Set bit 4 of C if bit 2 of A is set.
C941 JR Z,ReadInterface2Joystick_TestRight
C943 SET 4,C
ReadInterface2Joystick_TestRight C945 BIT 3,A Set bit 1 of C if bit 3 of A is set.
C947 JR Z,ReadInterface2Joystick_TestLeft
C949 SET 1,C
ReadInterface2Joystick_TestLeft C94B BIT 4,A Set bit 0 of C if bit 4 of A is set.
C94D JR Z,ReadInterface2Joystick_Finish
C94F SET 0,C
ReadInterface2Joystick_Finish C951 JP ReadControls_Finish Jump to ReadControls_Finish.
View the equivalent code in;
Prev: C8FF Up: Map Next: C954