.DK4 LDX KTRAN \ Fetch the internal key number of the current key \ press from the key logger buffer STX KL \ Store X in KL, byte #0 of the key logger CPX #&69 \ If COPY is not being pressed, jump to DK2 below, BNE DK2 \ otherwise let's process the configuration keys .FREEZE \ COPY is being pressed, so we enter a loop that \ listens for configuration keys, and we keep looping \ until we detect a DELETE key press. This effectively \ pauses the game when COPY is pressed, and unpauses \ it when DELETE is pressed JSR WSCAN \ Call WSCAN to wait for the vertical sync, so the whole \ screen gets drawn JSR RDKEY \ Scan the keyboard for a key press and return the \ internal key number in X (or 0 for no key press) CPX #&51 \ If "S" is not being pressed, skip to DK6 BNE DK6 LDA #0 \ "S" is being pressed, so set DNOIZ to 0 to turn the STA DNOIZ \ sound on .DK6 LDY #&40 \ We now want to loop through the keys that toggle \ various settings. These have internal key numbers \ between &40 (CAPS LOCK) and &46 ("K"), so we set up \ the first key number in Y to act as a loop counter. \ See subroutine DKS3 for more details on this .DKL4 JSR DKS3 \ Call DKS3 to scan for the key given in Y, and toggle \ the relevant setting if it is pressed INY \ Increment Y to point to the next toggle key IF _SNG45 OR _SOURCE_DISC CPY #&47 \ The last toggle key is &46 (K), so check whether we \ have just done that one ELIF _EXECUTIVE CPY #&49 \ The last toggle key is &48 (:), so check whether we \ have just done that one ENDIF BNE DKL4 \ If not, loop back to check for the next toggle key CPX #&10 \ If "Q" is not being pressed, skip to DK7 BNE DK7 STX DNOIZ \ "Q" is being pressed, so set DNOIZ to X, which is \ non-zero (&10), so this will turn the sound off .DK7 CPX #&70 \ If ESCAPE is not being pressed, skip over the next BNE P%+5 \ instruction JMP DEATH2 \ ESCAPE is being pressed, so jump to DEATH2 to end \ the game CPX #&64 \ If "B" is not being pressed, skip to nobit BNE nobit LDA BSTK \ Toggle the value of BSTK between 0 and &FF EOR #&FF STA BSTK STA JSTK \ Configure JSTK to the same value, so when the Bitstik \ is enabled, so is the joystick STA JSTE \ Configure JSTE to the same value, so when the Bitstik \ is enabled, the joystick is configured with reversed \ channels .nobit CPX #&32 \ If "D" is being pressed, jump to savscr to save a BEQ savscr \ screenshot CPX #&59 \ If DELETE is not being pressed, we are still paused, BNE FREEZE \ so loop back up to keep listening for configuration \ keys, otherwise fall through into the rest of the \ key detection code, which unpauses the game .DK2 LDA QQ11 \ If the current view is non-zero (i.e. not a space BNE out \ view), return from the subroutine (as out contains \ an RTS) LDY #16 \ This is a space view, so now we want to check for all \ the secondary flight keys. The internal key numbers \ are in the keyboard table KYTB from KYTB+8 to \ KYTB+16, and their key logger locations are from KL+8 \ to KL+16. So set a decreasing counter in Y for the \ index, starting at 16, so we can loop through them LDA #&FF \ Set A to &FF so we can store this in the keyboard \ logger for keys that are being pressed .DKL1 LDX KYTB,Y \ Get the internal key number of the Y-th flight key \ the KYTB keyboard table CPX KL \ We stored the key that's being pressed in KL above, \ so check to see if the Y-th flight key is being \ pressed BNE DK1 \ If it is not being pressed, skip to DK1 below STA KL,Y \ The Y-th flight key is being pressed, so set that \ key's location in the key logger to &FF .DK1 DEY \ Decrement the loop counter CPY #7 \ Have we just done the last key? BNE DKL1 \ If not, loop back to process the next key RTS \ Return from the subroutineName: DK4 [Show more] Type: Subroutine Category: Keyboard Summary: Scan for pause, configuration and secondary flight keys Deep dive: The key loggerContext: See this subroutine in context in the source code Variations: See code variations for this subroutine in the different versions References: This subroutine is called as follows: * DKJ1 calls DK4 * savscr calls via FREEZE
Scan for pause and configuration keys, and if this is a space view, also scan for secondary flight controls. Specifically: * Scan for the pause button (COPY) and if it's pressed, pause the game and process any configuration key presses until the game is unpaused (DELETE) * If this is a space view, scan for secondary flight keys and update the relevant bytes in the key logger
Other entry points: FREEZE Rejoin the pause routine after processing a screen save
[X]
Variable BSTK in workspace Parasite variables
Bitstik configuration setting
[X]
Subroutine DEATH2 (category: Start and end)
Reset most of the game and restart from the title screen
[X]
Label DK1 is local to this routine
[X]
Label DK2 is local to this routine
[X]
Label DK6 is local to this routine
[X]
Label DK7 is local to this routine
[X]
Label DKL1 is local to this routine
[X]
Label DKL4 is local to this routine
[X]
Subroutine DKS3 (category: Keyboard)
Toggle a configuration setting and emit a beep
[X]
Variable DNOIZ in workspace Parasite variables
Sound on/off configuration setting
[X]
Variable JSTE in workspace Parasite variables
Reverse both joystick channels configuration setting
[X]
Variable JSTK in workspace Parasite variables
Keyboard or joystick configuration setting
[X]
Variable KTRAN (category: Keyboard)
The key logger buffer that gets updated by the OSWORD 240 command
[X]
Variable KYTB (category: Keyboard)
Lookup table for in-flight keyboard controls
[X]
Subroutine RDKEY (category: Keyboard)
Scan the keyboard for key presses by sending an OSWORD 240 command to the I/O processor
[X]
Subroutine WSCAN (category: Drawing the screen)
Ask the I/O processor to wait for the vertical sync by sending a #wscn command to the I/O processor
[X]
Label nobit is local to this routine
[X]
Subroutine savscr (category: Save and load)
Save a screenshot if CTRL-D is pressed when the game is paused