Prev: EB98 Up: Map Next: EBCD
EB9E: Input Handler: Cursor
Input
HL Points to Data_Control
IX Points to this routine
Output
A The control byte
All the handlers match the outputs of the Kempston Joystick:
Byte Bits Action
01 00000001 Right
02 00000010 Left
04 00000100 Down
08 00001000 Up
10 00010000 Fire
InputHandler_Cursor EB9E LD A,$F7 Read from the keyboard;
Port Number Bit
0 1 2 3 4
F7 1 2 3 4 5
EBA0 IN A,($FE)
EBA2 CPL Invert the bits in A.
EBA3 AND %00010000 Keep only bit 4 ("5" i.e. left).
If "left" has been pressed, add 02 to *HL.
EBA5 JR Z,Cursor_CheckInputs Jump to Cursor_CheckInputs if "5" (left) is not being pressed.
EBA7 INC (HL) Increment *HL by two.
EBA8 INC (HL)
Cursor_CheckInputs EBA9 LD A,$EF Read from the keyboard;
Port Number Bit
0 1 2 3 4
EF 0 9 8 7 6
EBAB IN A,($FE)
If "fire" has been pressed, add 10 to *HL.
EBAD RRA Jump to Cursor_CheckRight if "0" (fire) is not being pressed.
EBAE JR C,Cursor_CheckRight
EBB0 PUSH AF Stash the inputs on the stack.
EBB1 LD A,$10 Add 10 to *HL and write it back.
EBB3 ADD A,(HL)
EBB4 LD (HL),A
EBB5 POP AF Restore the inputs from the stack.
If "right" has been pressed, add 01 to *HL.
Cursor_CheckRight EBB6 RRA Jump to Cursor_CheckUp if "8" (right) is not being pressed.
EBB7 RRA
EBB8 JR C,Cursor_CheckUp
EBBA INC (HL) Increment *HL by one.
If "up" has been pressed, add 08 to *HL.
Cursor_CheckUp EBBB RRA Jump to Cursor_CheckDown if "7" (up) is not being pressed.
EBBC JR C,Cursor_CheckDown
EBBE PUSH AF Stash the inputs on the stack.
EBBF LD A,$08 Add 08 to *HL and write it back.
EBC1 ADD A,(HL)
EBC2 LD (HL),A
EBC3 POP AF Restore the inputs from the stack.
If "down" has been pressed, add 04 to *HL.
Cursor_CheckDown EBC4 RRA Jump to InputHandler_Common if "6" (down) is not being pressed.
EBC5 JR C,InputHandler_Common
EBC7 LD A,$04 Add 04 to *HL and write it back.
EBC9 ADD A,(HL)
EBCA LD (HL),A
EBCB JR InputHandler_Common Jump to InputHandler_Common.
Prev: EB98 Up: Map Next: EBCD