Skip to navigation

Elite on the BBC Micro and NES

Keyboard: DOKEY

[Acorn Electron version]

Name: DOKEY [Show more] Type: Subroutine Category: Keyboard Summary: Scan for the seven primary flight controls Deep dive: The key logger The docking computer
Context: 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: * TT17 calls DOKEY

Scan for the seven primary flight controls, pause and configuration keys, and secondary flight controls, and update the key logger and pitch and roll rates accordingly. Unlike the other versions of Elite, the Electron version doesn't actually read the joystick values from the ADC channels, so although you can configure joysticks using the "K" option when paused, they won't have any effect. All the other joystick code is present, though, so perhaps the intention was to support joysticks at some point?
.DOKEY JSR U% \ Call U% to clear the key logger LDY #7 \ We're going to work our way through the primary flight \ control keys (pitch, roll, speed and laser), so set a \ counter in Y so we can loop through all 7 .DKL2 LDX KYTB,Y \ Call DKS4 to see if the KYTB key at offset Y is being JSR DKS4 \ pressed BPL P%+6 \ If the key isn't being pressed, skip the following two \ instructions LDX #&FF \ Set the key logger for this key to indicate it's being STX KL,Y \ pressed DEY \ Decrement the loop counter BNE DKL2 \ Loop back for the next key, working our way from A at \ KYTB+7 down to ? at KYTB+1 LDX JSTX \ Set X = JSTX, the current roll rate (as shown in the \ RL indicator on the dashboard) LDA #7 \ Set A to 7, which is the amount we want to alter the \ roll rate by if the roll keys are being pressed LDY KL+3 \ If the "<" key is being pressed, then call the BUMP2 BEQ P%+5 \ routine to increase the roll rate in X by A JSR BUMP2 LDY KL+4 \ If the ">" key is being pressed, then call the REDU2 BEQ P%+5 \ routine to decrease the roll rate in X by A, taking JSR REDU2 \ the keyboard auto re-centre setting into account STX JSTX \ Store the updated roll rate in JSTX ASL A \ Double the value of A, to 14 LDX JSTY \ Set X = JSTY, the current pitch rate (as shown in the \ DC indicator on the dashboard) LDY KL+5 \ If the "X" key is being pressed, then call the REDU2 BEQ P%+5 \ routine to decrease the pitch rate in X by A, taking JSR REDU2 \ the keyboard auto re-centre setting into account LDY KL+6 \ If the "S" key is being pressed, then call the BUMP2 BEQ P%+5 \ routine to increase the pitch rate in X by A JSR BUMP2 STX JSTY \ Store the updated roll rate in JSTY \ Fall through into DK4 to scan for other keys