.DKS3 TXA ; Copy the ASCII code of the key that has been pressed ; into A CMP TGINT,Y ; If the pressed key doesn't match the configuration key BNE Dk3 ; for option Y (as listed in the TGINT table), then jump ; to Dk3 to return from the subroutine LDA DAMP,Y ; The configuration keys listed in TGINT correspond to EOR #$FF ; the configuration option settings from DAMP onwards, STA DAMP,Y ; so to toggle a setting, we fetch the existing byte ; from DAMP+Y, invert it and put it back (0 means no ; and $FF means yes in the configuration bytes, so ; this toggles the setting) JSR BELL ; Make a beep sound so we know something has happened TYA ; Store Y and A on the stack so we can retrieve them PHA ; below LDY #20 ; Wait for 20/50 of a second (0.4 seconds) on PAL JSR DELAY ; systems, or 20/60 of a second (0.33 seconds) on NTSC PLA ; Restore A and Y from the stack TAY .Dk3 RTS ; Return from the subroutineName: DKS3 [Show more] Type: Subroutine Category: Keyboard Summary: Toggle a configuration setting and emit a beepContext: See this subroutine in context in the source code References: This subroutine is called as follows: * DK4 calls DKS3
This is called when the game is paused and a key is pressed that changes the game's configuration. Specifically, this routine toggles the configuration settings for the following keys: * RUN/STOP toggles keyboard flight damping (0) * A toggles keyboard auto-recentre (1) * X toggles author names on start-up screen (2) * F toggles flashing console bars (3) * Y toggles reverse joystick Y channel (4) * J toggles reverse both joystick channels (5) * K toggles keyboard and joystick (6) * M toggles docking music (7) * T toggles current media between tape and disk (8) * P toggles planetary details (9) * C toggles whether docking music can be toggled (10) * E swaps the docking and title music (11) * B toggles whether sounds are played during music (12) The numbers in brackets are the configuration options that we pass in Y. We pass the ASCII code of the key that has been pressed in X, and the option to check it against in Y, so this routine is typically called in a loop that loops through the various configuration option.
Arguments: X The internal number of the key that's been pressed Y The number of the configuration option to check against from the list above (i.e. Y must be from 0 to 12)
[X]
Subroutine BELL (category: Sound)
Make a standard system beep
[X]
Variable DAMP in workspace Option variables
Keyboard damping configuration setting
[X]
Subroutine DELAY (category: Utility routines)
Wait for a specified time, in either 1/50s of a second (on PAL systems) or 1/60s of a second (on NTSC systems)
[X]
Label Dk3 is local to this routine
[X]
Variable TGINT (category: Keyboard)
The keys used to toggle configuration settings when the game is paused