Prev: 60312 Up: Map Next: 60365
60318: 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
1 00000001 Right
2 00000010 Left
4 00000100 Down
8 00001000 Up
16 00010000 Fire
InputHandler_Cursor 60318 LD A,247 Read from the keyboard;
Port Number Bit
0 1 2 3 4
247 1 2 3 4 5
60320 IN A,(254)
60322 CPL Invert the bits in A.
60323 AND %00010000 Keep only bit 4 ("5" i.e. left).
If "left" has been pressed, add 2 to *HL.
60325 JR Z,Cursor_CheckInputs Jump to Cursor_CheckInputs if "5" (left) is not being pressed.
60327 INC (HL) Increment *HL by two.
60328 INC (HL)
Cursor_CheckInputs 60329 LD A,239 Read from the keyboard;
Port Number Bit
0 1 2 3 4
239 0 9 8 7 6
60331 IN A,(254)
If "fire" has been pressed, add 16 to *HL.
60333 RRA Jump to Cursor_CheckRight if "0" (fire) is not being pressed.
60334 JR C,Cursor_CheckRight
60336 PUSH AF Stash the inputs on the stack.
60337 LD A,16 Add 16 to *HL and write it back.
60339 ADD A,(HL)
60340 LD (HL),A
60341 POP AF Restore the inputs from the stack.
If "right" has been pressed, add 1 to *HL.
Cursor_CheckRight 60342 RRA Jump to Cursor_CheckUp if "8" (right) is not being pressed.
60343 RRA
60344 JR C,Cursor_CheckUp
60346 INC (HL) Increment *HL by one.
If "up" has been pressed, add 8 to *HL.
Cursor_CheckUp 60347 RRA Jump to Cursor_CheckDown if "7" (up) is not being pressed.
60348 JR C,Cursor_CheckDown
60350 PUSH AF Stash the inputs on the stack.
60351 LD A,8 Add 8 to *HL and write it back.
60353 ADD A,(HL)
60354 LD (HL),A
60355 POP AF Restore the inputs from the stack.
If "down" has been pressed, add 4 to *HL.
Cursor_CheckDown 60356 RRA Jump to InputHandler_Common if "6" (down) is not being pressed.
60357 JR C,InputHandler_Common
60359 LD A,4 Add 4 to *HL and write it back.
60361 ADD A,(HL)
60362 LD (HL),A
60363 JR InputHandler_Common Jump to InputHandler_Common.
Prev: 60312 Up: Map Next: 60365