Prev: 36705 Up: Map Next: 36752
36714: Controls: Cursor Joystick
Used by the routine at HandlerControls.
Output
A Controls
ReadCursorJoystick 36714 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
36716 OUT (253),A
36718 IN A,(254)
36720 LD C,A Store this value in C temporarily.
Handle "up".
36721 AND %00001000 Keep only bit 3 ("7").
36723 LD E,A Store this value in E.
36724 LD A,C Retrieve C and rotate the bits right twice.
36725 RRCA
36726 RRCA
Handle "down", "right" and "fire".
36727 AND %01000101 Keep only bits 0 ("8"), 2 ("6") and 6 ("0").
36729 OR E Set the bits from E.
36730 LD E,A Store this value back in E.
Handle relocating the "fire" bit.
36731 RRCA Rotate the bits right twice.
36732 RRCA
36733 AND %00010000 Keep only bit 4 ("0").
36735 OR E Set the bits from E.
Filter out the unused bits.
36736 AND %00011111 Keep only bits 0-4.
36738 LD E,A Store this value back in E.
Handle reading "left" from a different port.
36739 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
36741 OUT (253),A
36743 IN A,(254)
Handle relocating the "left" bit.
36745 RRA Rotate the bits right three times.
36746 RRA
36747 RRA
36748 AND %00000010 Keep only bit 1 ("5").
36750 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.
36751 RET Return.
View the equivalent code in;
Prev: 36705 Up: Map Next: 36752