| Routines

24951: 'J' pressed - joystick

The address of this routine is found in the table of keypress handling routines at 60672. It is called from the main loop at 61483 when 'J' is pressed.
24951 | LD A,96 | Message 96: newline
24953 | LD (32722),A | Store this message number at 32722 so that it can be watched in the message queue
24956 | CALL 30154 | Queue the message urgently
24959 | LD A,97 | Message 97: 'JOYSTICK?'
24961 | CALL 30154 | Queue this message urgently
24964 | CALL 30972 | Wait until message 96 (newline) has left the queue (and therefore 'JOYSTICK?' is displayed)
24967 | JR Z,24964
24969 | CALL 60121 | Wait for a keypress and collect its ASCII code in A
24972 | JR Z,24969
24974 | SET 5,A | Convert the keypress to lower case
24976 | LD HL,25019 | Point HL at the keypress offset patch table at 25019
24979 | LD DE,49968 | Point DE at the main keypress offset table
24982 | LD BC,10 | There will be 10 bytes to copy
24985 | CP 107 | Was 'k' pressed?
24987 | JR NZ,25001 | Jump if not
Now HL points at the appropriate keypress offset patch table (25029 if 'i' (Int2) was pressed, or 25019 otherwise), and A holds the input device indicator (107 if 'k' (Kempston) was pressed, or 0 otherwise).
24989 | PUSH HL | Save the pointer to the keypress offset patch table briefly
24990 | LD HL,65530 | Set the input device indicator for future games at 65530
24993 | LD (HL),A
24994 | LD H,127 | Set the input device indicator for the current game at 32762
24996 | LD (HL),A
24997 | POP HL | Restore the address of the keypress offset patch table to HL
24998 | LDIR | Update the entries for keys 0-9 in the keypress offset table
25000 | RET |
Some key other than 'k' (Kempston) was pressed.
25001 | CP 99 | Was 'c' (Cursor) pressed?
25003 | JR Z,25013 | Jump if so
25005 | CP 110 | Was 'n' (None) pressed?
25007 | JR Z,25013 | Jump if so
25009 | LD L,197 | HL=25029 (keypress offset patch table for Int2)
25011 | CP 105 | Set the zero flag if 'i' was pressed
25013 | LD A,0 | 0 indicates that we're not using the Kempston joystick
25015 | JR Z,24989 | Jump if 'i' (Int2) was pressed
25017 | JR 24969 | Otherwise jump back to collect another keypress