Prev: 28596 Up: Map Next: 28669
28631: Controls: Cursor Joystick
Used by the routine at ReadControls.
Reads the cursor joystick, which uses the keys "5" (left), "6" (down), "7" (up), "8" (right) and "0" (fire). The bits of the result are the same as those which are returned by ReadControls.
Output
A The controls (see ReadControls)
ReadCursorJoystick 28631 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
28633 OUT (253),A
28635 IN A,(254)
28637 LD C,A Keep the key states in C.
28638 AND %00001000 Keep only bit 3 ("7", up).
28640 LD E,A Keep the result in E.
28641 LD A,C Fetch the key states.
28642 RRCA Rotate A right twice.
28643 RRCA
28644 AND %01000101 Keep only bit 0 ("8", right), bit 2 ("6", down) and bit 6 ("0", fire).
28646 OR E Combine with E.
28647 LD E,A Keep the result in E.
28648 RRCA Rotate A right twice, which moves the fire bit to bit 4.
28649 RRCA
28650 AND %00010000 Keep only bit 4.
28652 OR E Combine with E.
28653 AND %00011111 Keep only bits 0-4.
28655 LD E,A Keep the result in E.
28656 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
28658 OUT (253),A
28660 IN A,(254)
28662 RRA Move the "5" key (left) into bit 1.
28663 RRA
28664 RRA
28665 AND %00000010 Keep only bit 1.
28667 OR E Combine with E.
28668 RET Return.
View the equivalent code in;
Prev: 28596 Up: Map Next: 28669