Skip to navigation


Version analysis of hyp

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: hyp Type: Subroutine Category: Flight Summary: Start the hyperspace process
Called when "H" or CTRL-H is pressed during flight. Checks the following: * We are in space * We are not already in a hyperspace countdown If CTRL is being held down, we jump to Ghy to engage the galactic hyperdrive, otherwise we check that: * The selected system is not the current system * We have enough fuel to make the jump and if all the pre-jump checks are passed, we print the destination on-screen and start the countdown.

Code variation 1 of 13A variation in the comments only

This variation is blank in the Cassette and Electron versions.

Other entry points: TTX111 Used to rejoin this routine from the call to TTX110
.hyp

Code variation 2 of 13A variation in the labels only

This variation is blank in the Disc (flight) and Disc (docked) versions.

Tap on a block to expand it, and tap it again to revert.

LDA QQ12 \ If we are docked (QQ12 = &FF) then jump to hy6 to BNE hy6 \ print an error message and return from the subroutine \ using a tail call (as we can't hyperspace when docked)
LDA QQ12 \ If we are docked (QQ12 = &FF) then jump to dockEd to BNE dockEd \ print an error message and return from the subroutine \ using a tail call (as we can't hyperspace when docked)
 LDA QQ22+1             \ Fetch QQ22+1, which contains the number that's shown
                        \ on-screen during hyperspace countdown

Code variation 3 of 13Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

BNE zZ+1 \ If it is non-zero, return from the subroutine (as zZ+1 \ contains an RTS), as there is already a countdown in \ progress
ORA QQ12 \ If we are docked (QQ12 = &FF) or there is already a BNE zZ+1 \ countdown in progress, then return from the subroutine \ using a tail call (as zZ+1 contains an RTS), as we \ can't hyperspace when docked, or there is already a \ countdown in progress
BEQ P%+3 \ If it is zero, skip the next instruction RTS \ The count is non-zero, so return from the subroutine
IF _IB_SUPERIOR BNE zZ+1 \ If it is non-zero, return from the subroutine (as zZ+1 \ contains an RTS), as there is already a countdown in \ progress ELIF _IB_ACORNSOFT BNE Ghy-1 \ If it is non-zero, return from the subroutine (as \ Ghy-1 contains an RTS), as there is already a \ countdown in progress ENDIF

Code variation 4 of 13Related to the screen mode

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

Tap on a block to expand it, and tap it again to revert.

LDA #CYAN \ The count is zero, so switch to colour 3, which is STA COL \ cyan in the space view
LDA #CYAN \ The count is zero, so send a #SETCOL CYAN command to JSR DOCOL \ the I/O processor to switch to colour 3, which is cyan \ in the space view

Code variation 5 of 13Related to the Electron version

Galactic hyperspace does not work in the original Acornsoft release as the game checks for a CAPS-LOCK-H keypress instead of CTRL-H, and this combination does not work properly.

Tap on a block to expand it, and tap it again to revert.

JSR CTRL \ Scan the keyboard to see if CTRL is currently pressed
IF _SNG47 JSR CTRL \ Scan the keyboard to see if CTRL is currently pressed ELIF _COMPACT JSR CTRLmc \ Scan the keyboard to see if CTRL is currently pressed ENDIF
IF _IB_SUPERIOR LDX #1 \ Set X to the internal key number for CTRL JSR DKS4 \ Scan the keyboard to see if the key in X (i.e. CTRL) \ is currently pressed ELIF _IB_ACORNSOFT JSR CAPSL \ Scan the keyboard to see if CAPS LOCK is currently \ pressed ENDIF
 BMI Ghy                \ If it is, then the galactic hyperdrive has been
                        \ activated, so jump to Ghy to process it

Code variation 6 of 13Minor and very low-impact

This variation is blank in the Cassette and Electron versions.

Tap on a block to expand it, and tap it again to revert.

LDA QQ11 \ If the current view is 0 (i.e. the space view) then BEQ TTX110 \ jump to TTX110, which calls TT111 to set the current \ system to the nearest system to (QQ9, QQ10), and jumps \ back into this routine at TTX111 below AND #%11000000 \ If neither bit 6 nor 7 of the view type is set - so BEQ zZ+1 \ this is neither the Short-range or Long-range Chart - \ then return from the subroutine (as zZ+1 contains an \ RTS)
LDA QQ11 \ If the current view is 0 (i.e. the space view) then BNE P%+5 \ jump to TTX110, which calls TT111 to set the current JMP TTX110 \ system to the nearest system to (QQ9, QQ10), and jumps \ back into this routine at TTX111 below
LDA QQ11 \ If the current view is 0 (i.e. the space view) then BEQ TTX110 \ jump to TTX110, which calls TT111 to set the current \ system to the nearest system to (QQ9, QQ10), and jumps \ back into this routine at TTX111 below AND #%11000000 \ If either bit 6 or 7 of the view type is set - so BNE P%+3 \ this is either the Short-range or Long-range Chart - \ then skip the following instruction RTS \ This is not a chart view, so return from the \ subroutine
 JSR hm                 \ This is a chart view, so call hm to redraw the chart
                        \ crosshairs

Code variation 7 of 13A variation in the labels only

This variation is blank in the Cassette and Electron versions.

.TTX111 \ If we get here then the current view is either the \ space view or a chart

Code variation 8 of 13Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

LDA QQ8 \ If both bytes of the distance to the selected system ORA QQ8+1 \ in QQ8 are zero, return from the subroutine (as zZ+1 BEQ zZ+1 \ contains an RTS), as the selected system is the \ current system
LDA QQ8 \ If either byte of the distance to the selected system ORA QQ8+1 \ in QQ8 are zero, skip the next instruction to make a BNE P%+3 \ copy of the destination seeds in safehouse RTS \ The selected system is the same as the current system, \ so return from the subroutine
IF _IB_SUPERIOR LDA QQ8 \ If both bytes of the distance to the selected system ORA QQ8+1 \ in QQ8 are zero, return from the subroutine (as zZ+1 BEQ zZ+1 \ contains an RTS), as the selected system is the \ current system ELIF _IB_ACORNSOFT LDA QQ8 \ If both bytes of the distance to the selected system ORA QQ8+1 \ in QQ8 are zero, return from the subroutine (as Ghy-1 BEQ Ghy-1 \ contains an RTS), as the selected system is the \ current system ENDIF

Code variation 9 of 13Other (e.g. bug fix, optimisation)

Part of the bug fix for the "hyperspace while docking" bug (see below).

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

LDX #5 \ We now want to copy those seeds into safehouse, so we \ so set a counter in X to copy 6 bytes .sob LDA QQ15,X \ Copy the X-th byte of QQ15 into the X-th byte of STA safehouse,X \ safehouse DEX \ Decrement the loop counter BPL sob \ Loop back to copy the next byte until we have copied \ all six seed bytes

Code variation 10 of 13Specific to an individual platform

Tap on a block to expand it, and tap it again to revert.

LDA #7 \ Move the text cursor to column 7, row 23 (in the STA XC \ middle of the bottom text row) LDA #23 STA YC
LDA #7 \ Move the text cursor to column 7, row 22 (in the STA XC \ middle of the bottom text row) LDA #22 STA YC
LDA #7 \ Move the text cursor to column 7, row 23 (in the JSR DOXC \ middle of the bottom text row) LDA #23 JSR DOYC
 LDA #0                 \ Set QQ17 = 0 to switch to ALL CAPS
 STA QQ17

 LDA #189               \ Print recursive token 29 ("HYPERSPACE ")
 JSR TT27

Code variation 11 of 13Related to the 6502SP version

If infinite jump range is enabled in the Executive version, you can jump to anywhere in the entire galaxy.

This variation is blank in the Cassette, Disc (flight), Disc (docked), Master and Electron versions.

IF _EXECUTIVE BIT JUMP \ If infinite jump range is configured, then jump down BMI goTT147+3 \ to IJUMP so we do the jump whatever the distance ENDIF

Code variation 12 of 13Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

LDA QQ8+1 \ If the high byte of the distance to the selected BNE TT147 \ system in QQ8 is > 0, then it is definitely too far to \ jump (as our maximum range is 7.0 light years, or a \ value of 70 in QQ8(1 0)), so jump to TT147 to print \ "RANGE?" and return from the subroutine using a tail \ call
LDA QQ8+1 \ If the high byte of the distance to the selected BNE goTT147 \ system in QQ8 is > 0, then it is definitely too far to \ jump (as our maximum range is 7.0 light years, or a \ value of 70 in QQ8(1 0)), so jump to TT147 via goTT147 \ to print "RANGE?" and return from the subroutine using \ a tail call
 LDA QQ14               \ Fetch our current fuel level from Q114 into A

Code variation 13 of 13Minor and very low-impact

Tap on a block to expand it, and tap it again to revert.

CMP QQ8 \ If our fuel reserves are less than the distance to the BCC TT147 \ selected system, then we don't have enough fuel for \ this jump, so jump to TT147 to print "RANGE?" and \ return from the subroutine using a tail call
CMP QQ8 \ If our fuel reserves are greater than or equal to the BCS P%+5 \ distance to the selected system, then we have enough \ fuel for this jump, so skip the following instruction \ to start the hyperspace countdown .goTT147 JMP TT147 \ We don't have enough fuel to reach the destination, so \ jump to TT147 to print "RANGE?" and return from the \ subroutine using a tail call
 LDA #'-'               \ Print a hyphen
 JSR TT27

 JSR cpl                \ Call cpl to print the name of the selected system

                        \ Fall through into wW to start the hyperspace countdown