Skip to navigation


Flight: hyp

[Acorn Electron version]

Name: hyp [Show more] Type: Subroutine Category: Flight Summary: Start the hyperspace process
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: * TT102 calls hyp

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.
.hyp 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 QQ22+1 \ Fetch QQ22+1, which contains the number that's shown \ on-screen during hyperspace countdown 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 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 JSR hm \ This is a chart view, so call hm to redraw the chart \ crosshairs 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 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 #0 \ Set QQ17 = 0 to switch to ALL CAPS STA QQ17 LDA #189 \ Print recursive token 29 ("HYPERSPACE ") JSR TT27 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 QQ14 \ Fetch our current fuel level from Q114 into A 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 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