Prev: 53475 Up: Map Next: 53547
53490: Read Interface 2 Joystick
Reads an Interface 2 joystick. The first joystick is 1 to 5 (left, right, down, up, fire) and the second is 6 to 0. The first row is reversed and the two are combined, so either can be used.
Output
C The controls
Read 1 to 5.
ReadInterface2Joystick 53490 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
53492 CALL ReadKeyboardPort
53495 PUSH BC Stash BC on the stack.
53496 LD B,5 Set a count of 5.
Reverse the five keys into C.
ReadInterface2Joystick_Reverse 53498 RRA Reverse the five keys into C.
53499 RL C
53501 DJNZ ReadInterface2Joystick_Reverse
53503 LD A,C Keep the reversed keys, and restore BC.
53504 POP BC
53505 LD C,A
Read 6 to 0, and combine the two joysticks.
53506 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
53508 CALL ReadKeyboardPort
53511 OR C Combine them with the reversed keys.
53512 LD C,0 Clear the controls.
Set bit 3 if fire is pressed.
53514 BIT 0,A Set bit 3 if fire is pressed.
53516 JR Z,ReadInterface2Joystick_TestUp
53518 SET 3,C
Set bit 2 if up is pressed.
ReadInterface2Joystick_TestUp 53520 BIT 1,A Set bit 2 if up is pressed.
53522 JR Z,ReadInterface2Joystick_TestDown
53524 SET 2,C
Set bit 4 if down is pressed.
ReadInterface2Joystick_TestDown 53526 BIT 2,A Set bit 4 if down is pressed.
53528 JR Z,ReadInterface2Joystick_TestRight
53530 SET 4,C
Set bit 1 if right is pressed.
ReadInterface2Joystick_TestRight 53532 BIT 3,A Set bit 1 if right is pressed.
53534 JR Z,ReadInterface2Joystick_TestLeft
53536 SET 1,C
Set bit 0 if left is pressed.
ReadInterface2Joystick_TestLeft 53538 BIT 4,A Set bit 0 if left is pressed.
53540 JR Z,ReadInterface2Joystick_Finish
53542 SET 0,C
ReadInterface2Joystick_Finish 53544 JP ReadControls_Rotate Jump to ReadControls_Rotate.
View the equivalent code in;
Prev: 53475 Up: Map Next: 53547