Skip to navigation


Flight: TT18

[NES version, Bank 0]

Name: TT18 [Show more] Type: Subroutine Category: Flight Summary: Try to initiate a jump into hyperspace
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * TT102 calls TT18

Try to go through hyperspace. Called from TT102 in the main loop when the hyperspace countdown has finished.
.TT18 JSR ResetMusicAfterNMI ; Wait for the next NMI before resetting the current ; tune to 0 (no tune) and stopping the music LDA QQ14 ; Subtract the distance to the selected system (in QQ8) SEC ; from the amount of fuel in our tank (in QQ14) into A SBC QQ8 BCS P%+4 ; If the subtraction didn't overflow, skip the next ; instruction LDA #0 ; The subtraction overflowed, so set A = 0 so we don't ; end up with a negative amount of fuel STA QQ14 ; Store the updated fuel amount in QQ14 LDA QQ11 ; If this is not the space view, then jump to hypr1 to BNE hypr1 ; skip drawing the hyperspace tunnel, but still make the ; hyperspace sound JSR ClearScanner ; Remove all ships from the scanner and hide the scanner ; sprites JSR LL164_b6 ; Call LL164 to show the hyperspace tunnel and make the ; hyperspace sound JMP hypr2 ; Jump to hypr2 to skip the following, as we already ; the hyperspace sound in LL164 .hypr1 JSR MakeHyperSound ; Make the hyperspace sound for when we are not in the ; space view .hypr2 LDA controller1Up ; If either of the up or down buttons are being pressed, ORA controller1Down ; then jump to MJP to force a mis-jump BMI MJP .ee5 JSR DORND ; Set A and X to random numbers CMP #253 ; If A >= 253 (0.78% chance) then jump to MJP to trigger BCS MJP ; a mis-jump into witchspace JSR hyp1 ; Jump straight to the system at (QQ9, QQ10) JSR WaitForNMI ; Wait until the next NMI interrupt has passed (i.e. the ; next VBlank) JSR RES2 ; Reset a number of flight variables and workspaces JSR SOLAR ; Halve our legal status, update the missile indicators, ; and set up data blocks and slots for the planet and ; sun