Prev: 8F61 Up: Map Next: 8F90
8F6A: Controls: Cursor Joystick
Used by the routine at HandlerControls.
Output
A Controls
ReadCursorJoystick 8F6A LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
8F6C OUT ($FD),A
8F6E IN A,($FE)
8F70 LD C,A Store this value in C temporarily.
Handle "up".
8F71 AND %00001000 Keep only bit 3 ("7").
8F73 LD E,A Store this value in E.
8F74 LD A,C Retrieve C and rotate the bits right twice.
8F75 RRCA
8F76 RRCA
Handle "down", "right" and "fire".
8F77 AND %01000101 Keep only bits 0 ("8"), 2 ("6") and 6 ("0").
8F79 OR E Set the bits from E.
8F7A LD E,A Store this value back in E.
Handle relocating the "fire" bit.
8F7B RRCA Rotate the bits right twice.
8F7C RRCA
8F7D AND %00010000 Keep only bit 4 ("0").
8F7F OR E Set the bits from E.
Filter out the unused bits.
8F80 AND %00011111 Keep only bits 0-4.
8F82 LD E,A Store this value back in E.
Handle reading "left" from a different port.
8F83 LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
8F85 OUT ($FD),A
8F87 IN A,($FE)
Handle relocating the "left" bit.
8F89 RRA Rotate the bits right three times.
8F8A RRA
8F8B RRA
8F8C AND %00000010 Keep only bit 1 ("5").
8F8E OR E Set the bits from E resulting in;
Key Direction Bit
"8" Right 0
"5" Left 1
"6" Down 2
"7" Up 3
"0" Fire 4
This matches the Kempston Joystick inputs.
8F8F RET Return.
View the equivalent code in;
Prev: 8F61 Up: Map Next: 8F90