Skip to navigation

Elite on the BBC Micro and NES

Status: STATUS

[NES version, Bank 0]

Name: STATUS [Show more] Type: Subroutine Category: Status Summary: Show the Status Mode screen Deep dive: Combat rank
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawSpaceViewInNMI calls STATUS * RedrawCurrentView calls STATUS * TT102 calls STATUS
.wearedocked ; We call this from STATUS below if we are docked LDA #205 ; Print extended token 205 ("DOCKED") and return from JSR DETOK_b2 ; the subroutine using a tail call JSR TT67 ; Print a newline JMP st6+3 ; Jump down to st6+3, to print recursive token 125 and ; continue to the rest of the Status Mode screen .STATUS LDA #$98 ; Clear the screen and set the view type in QQ11 to $98 JSR SetNewViewType ; (Status Mode) JSR SetSelectedSystem ; Set the selected system to the nearest system, if we ; don't already have a selected system LDA #7 ; Move the text cursor to column 7 STA XC LDA #126 ; Print recursive token 126, which prints the top JSR NLIN3 ; four lines of the Status Mode screen: ; ; COMMANDER {commander name} ; ; ; Present System : {current system name} ; Hyperspace System : {selected system name} ; Condition : ; ; and draw a horizontal line at pixel row 19 to box ; in the title JSR GetStatusCondition ; Set X to our ship's status condition STX previousCondition ; Store the status condition in previousCondition, so ; we keep an eye on changes in our condition LDA #230 ; Start off by setting A to token 70 ("GREEN") DEX ; If the status condition in X is 0, then we are docked, BMI wearedocked ; so jump to wearedocked BEQ st6 ; So if X = 0, there are no ships in the vicinity, so ; jump to st6 to print "Green" for our ship's condition LDY ENERGY ; Otherwise we have ships in the vicinity, so we load ; our energy levels into Y CPY #128 ; Set the C flag if Y >= 128, so C is set if we have ; more than half of our energy banks charged ADC #1 ; Add 1 + C to A, so if C is not set (i.e. we have low ; energy levels) then A is set to token 231 ("RED"), ; and if C is set (i.e. we have healthy energy levels) ; then A is set to token 232 ("YELLOW") .st6 JSR plf ; Print the text token in A (which contains our ship's ; condition) followed by a newline LDA languageNumber ; If bit 2 of languageNumber is clear then the chosen AND #%00000100 ; language is not French, so jump to stat1 to skip the BEQ stat1 ; following (as the screen has a different layout in ; French) JSR PrintLegalStatus ; Print the current legal status JSR PrintCombatRank ; Print the current combat rank LDA #5 ; Print control code 5, which prints the next JSR plf ; two lines of the Status Mode screen: ; ; Fuel: {fuel level} Light Years ; Cash: {cash} Cr ; ; followed by a newline JMP stat2 ; Jump to stat2 to skip the following .stat1 JSR PrintCombatRank ; Print the current combat rank LDA #5 ; Print control code 5, which prints the next JSR plf ; two lines of the Status Mode screen: ; ; Fuel: {fuel level} Light Years ; Cash: {cash} Cr ; ; followed by a newline JSR PrintLegalStatus ; Print the current legal status .stat2 LDA #18 ; Print recursive token 132, which prints the next bit JSR PrintTokenCrTab ; of the Status Mode screen: ; ; EQUIPMENT: ; ; followed by a newline and the correct indent for ; Status Mode entries in the chosen language INC YC ; Move the text cursor down one row LDA ESCP ; If we don't have an escape pod fitted (i.e. ESCP is BEQ P%+7 ; zero), skip the following two instructions LDA #112 ; We do have an escape pod fitted, so print recursive JSR PrintTokenCrTab ; token 112 ("ESCAPE POD"), followed by a newline and ; the correct indent for Status Mode entries in the ; chosen language LDA BST ; If we don't have fuel scoops fitted, skip the BEQ P%+7 ; following two instructions LDA #111 ; We do have fuel scoops fitted, so print recursive JSR PrintTokenCrTab ; token 111 ("FUEL SCOOPS"), followed by a newline and ; the correct indent for Status Mode entries in the ; chosen language LDA ECM ; If we don't have an E.C.M. fitted, skip the following BEQ P%+7 ; two instructions LDA #108 ; We do have an E.C.M. fitted, so print recursive token JSR PrintTokenCrTab ; 108 ("E.C.M.SYSTEM"), followed by a newline and the ; correct indent for Status Mode entries in the chosen ; language LDA #113 ; We now cover the four pieces of equipment whose flags STA XX4 ; are stored in BOMB through BOMB+3, and whose names ; correspond with text tokens 113 through 116: ; ; BOMB+0 = BOMB = token 113 = Energy bomb ; BOMB+1 = ENGY = token 114 = Energy unit ; BOMB+2 = DKCMP = token 115 = Docking computer ; BOMB+3 = GHYP = token 116 = Galactic hyperdrive ; ; We can print these out using a loop, so we set XX4 to ; 113 as a counter (and we also set A as well, to pass ; through to plf2) .stqv TAY ; Fetch byte BOMB+0 through BOMB+4 for values of XX4 LDX BOMB-113,Y ; from 113 through 117 BEQ P%+5 ; If it is zero then we do not own that piece of ; equipment, so skip the next instruction JSR PrintTokenCrTab ; Print the recursive token in A from 113 ("ENERGY ; BOMB") through 116 ("GALACTIC HYPERSPACE "), followed ; by a newline and the correct indent for Status Mode ; entries in the chosen language INC XX4 ; Increment the counter (and A as well) LDA XX4 CMP #117 ; If A < 117, loop back up to stqv to print the next BCC stqv ; piece of equipment LDX #0 ; Now to print our ship's lasers, so set a counter in X ; to count through the four views (0 = front, 1 = rear, ; 2 = left, 3 = right) .st STX CNT ; Store the view number in CNT LDY LASER,X ; Fetch the laser power for view X, and if we do not BEQ st1 ; have a laser fitted to that view, jump to st1 to move ; on to the next one LDA languageNumber ; If bit 2 of languageNumber is set then the chosen AND #%00000100 ; language is French, so jump to stat3 to skip the BNE stat3 ; following (as the screen has a different layout in ; French) TXA ; Print recursive token 96 + X, which will print from 96 CLC ; ("FRONT") through to 99 ("RIGHT"), followed by a space ADC #96 JSR spc .stat3 LDA #103 ; Set A to token 103 ("PULSE LASER") LDX CNT ; Retrieve the view number from CNT that we stored above LDY LASER,X ; Set Y = the laser power for view X CPY #128+POW ; If the laser power for view X is not #POW+128 (beam BNE P%+4 ; laser), skip the next LDA instruction LDA #104 ; This sets A = 104 if the laser in view X is a beam ; laser (token 104 is "BEAM LASER") CPY #Armlas ; If the laser power for view X is not #Armlas (military BNE P%+4 ; laser), skip the next LDA instruction LDA #117 ; This sets A = 117 if the laser in view X is a military ; laser (token 117 is "MILITARY LASER") CPY #Mlas ; If the laser power for view X is not #Mlas (mining BNE P%+4 ; laser), skip the next LDA instruction LDA #118 ; This sets A = 118 if the laser in view X is a mining ; laser (token 118 is "MINING LASER") JSR TT27_b2 ; Print the text token in A (which contains the laser ; type) LDA languageNumber ; If bit 2 of languageNumber is clear then the chosen AND #%00000100 ; language is not French, so jump to stat4 to skip the BEQ stat4 ; following (as the screen has a different layout in ; French) LDA CNT ; Retrieve the view number from CNT that we stored above CLC ; Print recursive token 96 + A, which will print from 96 ADC #96 ; ("FRONT") through to 99 ("RIGHT"), followed by a space JSR PrintSpaceAndToken .stat4 JSR PrintCrTab ; Print a newline and the correct indent for Status Mode ; entries in the chosen language .st1 LDX CNT ; Increment the counter in X and CNT to point to the INX ; next view CPX #4 ; If this isn't the last of the four views, jump back up BCC st ; to st to print out the next one LDA #24 ; Move the text cursor to column 24 STA XC LDX languageIndex ; Move the text cursor to the correct row for the LDA yHeadshot,X ; commander image in the chosen language STA YC JSR GetHeadshotType_b4 ; Set S to the headshot number for the current combat ; rank and status condition, in the range 0 to 13 LDA S ; Set A to %1000xxxx where %xxxx is the headshot number ORA #%10000000 ; in the range 0 to 13 CMP imageSentToPPU ; Set the processor flags according to whether ; imageSentToPPU already has this value STA imageSentToPPU ; Set imageSentToPPU to A BEQ stat5 ; If imageSentToPPU already had this value then we are ; already showing this image on-screen, so jump to stat5 ; to skip the following instruction as there's no need ; to fade the screen out when the image isn't changing JSR FadeAndHideSprites ; Fade the screen to black and hide all sprites, so we ; can update the screen while it's blacked-out .stat5 JSR DrawCmdrImage_b6 ; Draw the commander image as a coloured face image in ; front of a greyscale headshot image, with optional ; embellishments ; Fall through into UpdateView to update the view