Prev: 6FB4 Up: Map Next: 6FFD
6FD7: 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 6FD7 LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
6FD9 OUT ($FD),A
6FDB IN A,($FE)
6FDD LD C,A Keep the key states in C.
6FDE AND %00001000 Keep only bit 3 ("7", up).
6FE0 LD E,A Keep the result in E.
6FE1 LD A,C Fetch the key states.
6FE2 RRCA Rotate A right twice.
6FE3 RRCA
6FE4 AND %01000101 Keep only bit 0 ("8", right), bit 2 ("6", down) and bit 6 ("0", fire).
6FE6 OR E Combine with E.
6FE7 LD E,A Keep the result in E.
6FE8 RRCA Rotate A right twice, which moves the fire bit to bit 4.
6FE9 RRCA
6FEA AND %00010000 Keep only bit 4.
6FEC OR E Combine with E.
6FED AND %00011111 Keep only bits 0-4.
6FEF LD E,A Keep the result in E.
6FF0 LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
6FF2 OUT ($FD),A
6FF4 IN A,($FE)
6FF6 RRA Move the "5" key (left) into bit 1.
6FF7 RRA
6FF8 RRA
6FF9 AND %00000010 Keep only bit 1.
6FFB OR E Combine with E.
6FFC RET Return.
View the equivalent code in;
Prev: 6FB4 Up: Map Next: 6FFD