This code appears in the following versions (click to see it in the source code):
Code variations between these versions are shown below.
Name: TT17 Type: Subroutine Category: Keyboard
This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.
Other entry points: TJ1 Check for cursor key presses and return the combined deltas for the digital joystick and cursor keys (Master Compact only)
.TT17
The Master version doesn't check for SHIFT being held down in the space view, as it has no effect there (it's only used in the chart views for speeding up the crosshairs).
This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.
LDA QQ11 \ If this not the space view, skip the following three BNE TT17afterall \ instructions to move onto the cursor key logic JSR DOKEY \ This is the space view, so scan the keyboard for \ flight controls and pause keys, (or the equivalent on \ joystick) and update the key logger, setting KL to the \ key pressed TXA \ Transfer the value of the key pressed from X to A RTS \ Return from the subroutine .TT17afterall
In the enhanced versions, the cursor moves more quickly in the chart views if you hold down SHIFT.
See below for more variations related to this code.
This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.
LDX #0 \ Call DKS4 to check whether the SHIFT key is being JSR DKS4 \ pressed STA newlocn \ Store the result (which will have bit 7 set if SHIFT \ is being pressed) in newlocn
The Master Compact release allows you to move the chart crosshairs using the digital joystick, using the TT17X and DJOY routines.
See below for more variations related to this code.
This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.
IF _COMPACT LDX #0 \ Set the initial values for the results, X = Y = 0, LDY #0 \ which we now increase or decrease appropriately ENDIF
Despite never reading the joystick values from the ADC channels, the Electron version still lets the joystick control the crosshairs on the chart views, if joysticks are configured. The result is an uncontrollable crosshair that moves of its own accord, so presumably this is a bug.
Tap on a block to expand it, and tap it again to revert.
Code variation 9 of 19
See variation 7 above for details.
This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.
IF _COMPACT LDA MOS \ If MOS = 0 then this is a Master Compact, so jump to BEQ DJOY \ DJOY to read the digital joystick before rejoining the \ routine below at TJ1 ENDIF LDA JSTY \ Fetch the joystick pitch, ranging from 1 to 255 with \ 128 as the centre point JSR TJS1 \ Call TJS1 just below to set A to a value between -4 \ and +4 depending on the joystick pitch value (moving \ the stick up and down) TAY \ Copy the result into Y
LDA JSTX \ Fetch the joystick roll, ranging from 1 to 255 with \ 128 as the centre point EOR #&FF \ Flip the sign so A = -JSTX, because the joystick roll \ works in the opposite way to moving a cursor on-screen \ in terms of left and right
The Master has different logic around moving the crosshairs on the chart views, though the results appear to be the same.
See below for more variations related to this code.
This variation is blank in the Master version.
TYA \ Copy Y to A
Code variation 12 of 19
See variation 6 above for details.
This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.
BIT newlocn \ If bit 7 of newlocn is clear - in other words, if BPL P%+3 \ SHIFT is not being pressed - then skip the following \ instruction ASL A \ SHIFT is being held down, so double the value of A \ (i.e. SHIFT moves the cursor at double the speed \ when using the joystick)
Code variation 13 of 19
See variation 11 above for details.
This variation is blank in the Master version.
Tap on a block to expand it, and tap it again to revert.
Code variation 14 of 19
See variation 6 above for details.
This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.
BIT newlocn \ If bit 7 of newlocn is clear - in other words, if BPL P%+3 \ SHIFT is not being pressed - then skip the following \ instruction ASL A \ SHIFT is being held down, so double the value of A \ (i.e. SHIFT moves the cursor at double the speed \ when using the joystick
Code variation 15 of 19
See variation 11 above for details.
Tap on a block to expand it, and tap it again to revert.
Code variation 16 of 19
See variation 6 above for details.
This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.
.TJ1
Code variation 18 of 19
See variation 6 above for details.
This variation is blank in the Cassette, Disc (flight) and Electron versions.
Tap on a block to expand it, and tap it again to revert.
RTS \ Return from the subroutine
Code variation 19 of 19
See variation 11 above for details.
This variation is blank in the Cassette, Disc (flight), Disc (docked), 6502 Second Processor and Electron versions.
.TJS1 \ This routine calculates the following: \ \ A = round(A / 16) - 4 \ \ This set A to a value between -4 and +4, given an \ initial value ranging from 1 to 255 with 128 as \ the centre point LSR A \ Set A = A / 16 LSR A \ LSR A \ and C contains the last bit to be shifted out LSR A LSR A ADC #0 \ If that last bit was a 1, this increments A, so \ this effectively implements a rounding function, \ where 0.5 and above get rounded up SBC #3 \ The addition will not overflow, so the C flag is \ clear at this point, so this performs: \ \ A = A - 3 - (1 - C) \ = A - 3 - (1 - 0) \ = A - 3 - 1 \ = A - 4 RTS \ Return from the subroutine