Skip to navigation


Universe: TT25

[NES version, Bank 0]

Name: TT25 [Show more] Type: Subroutine Category: Universe Summary: Show the Data on System screen Deep dive: Generating system data Galaxy and system seeds
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * TT102 calls TT25 * TT70 calls via TT72

Other entry points: TT72 Used by TT70 to re-enter the routine after displaying "MAINLY" for the economy type
.TT25 LDA #$96 ; Clear the screen and set the view type in QQ11 to $96 JSR SetNewViewType ; (Data on System) JSR TT111 ; Select the system closest to galactic coordinates ; (QQ9, QQ10) LDX languageIndex ; Move the text cursor to the correct column for the LDA xDataOnSystem,X ; Data on System title in the chosen language STA XC LDA #163 ; Print recursive token 3 ("DATA ON {selected system JSR NLIN3 ; name}" on the top row JSR TTX69 ; Print a paragraph break and set Sentence Case JSR TT146 ; If the distance to this system is non-zero, print ; "DISTANCE", then the distance, "LIGHT YEARS" and a ; paragraph break, otherwise just move the cursor down ; a line LDA languageNumber ; If both bit 1 and bit 2 of languageNumber are clear AND #%00000110 ; then the chosen language is English, so jump to dsys1 BEQ dsys1 ; to skip the following ; If we get here then the chosen language is French or ; German, so we need to print the system economy using ; the PrintTokenAndColon routine to ensure the label is ; in green LDA #194 ; Print recursive token 34 ("ECONOMY") followed by JSR PrintTokenAndColon ; colon, ensuring that the colon is printed in green ; despite being in a 2x2 attribute block set for white ; text JMP dsys2 ; Jump to dsys2 to print the economy type .dsys1 LDA #194 ; Print recursive token 34 ("ECONOMY") followed by JSR TT68 ; a colon JSR TT162 ; Print a space .dsys2 LDA QQ3 ; The system economy is determined by the value in QQ3, ; so fetch it into A. First we work out the system's ; prosperity as follows: ; ; QQ3 = 0 or 5 = %000 or %101 = Rich ; QQ3 = 1 or 6 = %001 or %110 = Average ; QQ3 = 2 or 7 = %010 or %111 = Poor ; QQ3 = 3 or 4 = %011 or %100 = Mainly CLC ; If (QQ3 + 1) >> 1 = %10, i.e. if QQ3 = %011 or %100 ADC #1 ; (3 or 4), then call TT70, which prints "MAINLY " and LSR A ; jumps down to TT72 to print the type of economy CMP #%00000010 BEQ TT70 LDA QQ3 ; If (QQ3 + 1) >> 1 < %10, i.e. if QQ3 = %000, %001 or BCC TT71 ; %010 (0, 1 or 2), then jump to TT71 with A set to the ; original value of QQ3 SBC #5 ; Here QQ3 = %101, %110 or %111 (5, 6 or 7), so subtract CLC ; 5 to bring it down to 0, 1 or 2 (the C flag is already ; set so the SBC will be correct) .TT71 ADC #170 ; A is now 0, 1 or 2, so print recursive token 10 + A. JSR TT27_b2 ; This means that: ; ; QQ3 = 0 or 5 prints token 10 ("RICH ") ; QQ3 = 1 or 6 prints token 11 ("AVERAGE ") ; QQ3 = 2 or 7 prints token 12 ("POOR ") .TT72 LDA QQ3 ; Now to work out the type of economy, which is LSR A ; determined by bit 2 of QQ3, as follows: LSR A ; ; QQ3 bit 2 = 0 = Industrial ; QQ3 bit 2 = 1 = Agricultural ; ; So we fetch QQ3 into A and set A = bit 2 of QQ3 using ; two right shifts (which will work as QQ3 is only a ; 3-bit number) CLC ; Print recursive token 8 + A, followed by a paragraph ADC #168 ; break and Sentence Case, so: JSR TT60 ; ; QQ3 bit 2 = 0 prints token 8 ("INDUSTRIAL") ; QQ3 bit 2 = 1 prints token 9 ("AGRICULTURAL") LDA languageNumber ; If bit 2 of languageNumber is clear then the chosen AND #%00000100 ; language is not French, so jump to dsys3 skip the BEQ dsys3 ; following ; If we get here then the chosen language is French, so ; so we need to print the system government using the ; PrintTokenAndColon routine to ensure the label is in ; green LDA #162 ; Print recursive token 2 ("GOVERNMENT") followed by JSR PrintTokenAndColon ; colon, ensuring that the colon is printed in green ; despite being in a 2x2 attribute block set for white ; text JMP dsys4 ; Jump to dsys4 to print the government type .dsys3 LDA #162 ; Print recursive token 2 ("GOVERNMENT") followed by JSR TT68 ; a colon JSR TT162 ; Print a space .dsys4 LDA QQ4 ; The system's government is determined by the value in ; QQ4, so fetch it into A CLC ; Print recursive token 17 + A, followed by a paragraph ADC #177 ; break and Sentence Case, so: JSR TT60 ; ; QQ4 = 0 prints token 17 ("ANARCHY") ; QQ4 = 1 prints token 18 ("FEUDAL") ; QQ4 = 2 prints token 19 ("MULTI-GOVERNMENT") ; QQ4 = 3 prints token 20 ("DICTATORSHIP") ; QQ4 = 4 prints token 21 ("COMMUNIST") ; QQ4 = 5 prints token 22 ("CONFEDERACY") ; QQ4 = 6 prints token 23 ("DEMOCRACY") ; QQ4 = 7 prints token 24 ("CORPORATE STATE") LDA #196 ; Print recursive token 36 ("TECH.LEVEL") followed by a JSR TT68 ; colon LDX QQ5 ; Fetch the tech level from QQ5 and increment it, as it INX ; is stored in the range 0-14 but the displayed range ; should be 1-15 CLC ; Call pr2 to print the technology level as a 3-digit JSR pr2 ; number without a decimal point (by clearing the C ; flag) JSR TTX69 ; Print a paragraph break and set Sentence Case LDA #193 ; Print recursive token 33 ("TURNOVER"), followed JSR TT68 ; by a colon LDX QQ7 ; Fetch the 16-bit productivity value from QQ7 into LDY QQ7+1 ; (Y X) CLC ; Print (Y X) to 6 digits with no decimal point LDA #6 JSR TT11 JSR TT162 ; Print a space LDA #0 ; Set QQ17 = 0 to switch to ALL CAPS STA QQ17 LDA #'M' ; Print "MCR", followed by a paragraph break and JSR DASC_b2 ; Sentence Case LDA #'C' JSR TT27_b2 LDA #'R' JSR TT60 LDY #0 ; We now print the string in radiusText ("RADIUS"), so ; set a character counter in Y .dsys5 LDA radiusText,Y ; Print the Y-th character from radiusText JSR TT27_b2 INY ; Increment the counter CPY #5 ; Loop back until we have printed the first five letters BCC dsys5 ; of the string LDA radiusText,Y ; Print the last letter of the string, followed by a JSR TT68 ; colon LDA QQ15+5 ; Set A = QQ15+5 LDX QQ15+3 ; Set X = QQ15+3 AND #%00001111 ; Set Y = (A AND %1111) + 11 CLC ADC #11 TAY LDA #5 ; Print (Y X) to 5 digits, not including a decimal JSR TT11 ; point, as the C flag will be clear (as the maximum ; radius will always fit into 16 bits) JSR TT162 ; Print a space LDA #'k' ; Print "km" JSR DASC_b2 LDA #'m' JSR DASC_b2 JSR TTX69 ; Print a paragraph break and set Sentence Case LDA languageNumber ; If both bit 0 and bit 2 of languageNumber are clear AND #%00000101 ; then the chosen language is not English or German, so BEQ dsys6 ; jump to dsys6 skip the following ; If we get here then the chosen language is English or ; German, so we need to print the system population ; using the PrintTokenAndColon routine to ensure the ; label is in green LDA #192 ; Print recursive token 32 ("POPULATION") followed by a JSR PrintTokenAndColon ; colon, ensuring that the colon is printed in green ; despite being in a 2x2 attribute block set for white ; text JMP dsys7 ; Jump to dsys7 to print the population .dsys6 LDA #192 ; Print recursive token 32 ("POPULATION") followed by a JSR TT68 ; colon .dsys7 LDA QQ6 ; Set X = QQ6 / 8 LSR A ; LSR A ; We use this as the population figure, in billions LSR A TAX CLC ; Clear the C flag so we do not print a decimal point in ; the call to pr2+2 LDA #1 ; Set the number of digits to 1 for the call to pr2+2 JSR pr2+2 ; Print the population as a 1-digit number without a ; decimal point LDA #198 ; Print recursive token 38 (" BILLION"), followed by a JSR TT60 ; paragraph break and Sentence Case LDA languageNumber ; If bit 1 of languageNumber is set then the chosen AND #%00000010 ; language is German, so jump to dsys8 skip the BNE dsys8 ; following ; If we get here then the chosen language is French or ; English, so we print the species in brackets LDA #'(' ; Print an opening bracket JSR TT27_b2 .dsys8 LDA QQ15+4 ; Now to calculate the species, so first check bit 7 of BMI TT205 ; s2_lo, and if it is set, jump to TT205 as this is an ; alien species LDA #188 ; Bit 7 of s2_lo is clear, so print recursive token 28 JSR TT27_b2 ; ("HUMAN COLONIAL") JMP TT76 ; Jump to TT76 to print "S)" and a paragraph break, so ; the whole species string is "(HUMAN COLONIALS)" .TT75 LDA QQ15+5 ; This is an alien species, so we take bits 0-1 of AND #%00000011 ; s2_hi, add this to the value of A that we used for CLC ; the third adjective, and take bits 0-2 of the result ADC QQ19 AND #%00000111 ADC #242 ; A = 0 to 7, so print recursive token 82 + A, so: JSR TT27_b2 ; ; A = 0 prints token 82 ("RODENTS") ; A = 1 prints token 83 ("FROGS") ; A = 2 prints token 84 ("LIZARDS") ; A = 3 prints token 85 ("LOBSTERS") ; A = 4 prints token 86 ("BIRDS") ; A = 5 prints token 87 ("HUMANOIDS") ; A = 6 prints token 88 ("FELINES") ; A = 7 prints token 89 ("INSECTS") LDA QQ15+5 ; Now for the second adjective, so shift s2_hi so we get LSR A ; A = bits 5-7 of s2_hi LSR A LSR A LSR A LSR A CMP #6 ; If A >= 6, jump to dsys9 to skip the second adjective BCS dsys9 ADC #230 ; Otherwise A = 0 to 5, so print a space followed by JSR PrintSpaceAndToken ; recursive token 70 + A, so: ; ; A = 0 prints token 70 ("GREEN") and a space ; A = 1 prints token 71 ("RED") and a space ; A = 2 prints token 72 ("YELLOW") and a space ; A = 3 prints token 73 ("BLUE") and a space ; A = 4 prints token 74 ("BLACK") and a space ; A = 5 prints token 75 ("HARMLESS") and a space .dsys9 LDA QQ19 ; Fetch the value that we calculated for the third ; adjective CMP #6 ; If A >= 6, jump to TT76 to skip the third adjective BCS TT76 ADC #236 ; Otherwise A = 0 to 5, so print a space followed by JSR PrintSpaceAndToken ; recursive token 76 + A, so: ; ; A = 0 prints token 76 ("SLIMY") and a space ; A = 1 prints token 77 ("BUG-EYED") and a space ; A = 2 prints token 78 ("HORNED") and a space ; A = 3 prints token 79 ("BONY") and a space ; A = 4 prints token 80 ("FAT") and a space ; A = 5 prints token 81 ("FURRY") and a space JMP TT76 ; Jump to TT76 as we have finished printing the ; species string .TT205 ; In NES Elite, there is no first adjective (in the ; other versions, the first adjective can be "Large", ; "Fierce" or "Small", but this is omitted in NES Elite ; as there isn't space on-screen) LDA QQ15+3 ; In preparation for the third adjective, EOR the high EOR QQ15+1 ; bytes of s0 and s1 and extract bits 0-2 of the result: AND #%00000111 ; STA QQ19 ; A = (s0_hi EOR s1_hi) AND %111 ; ; storing the result in QQ19 so we can use it later LDA languageNumber ; If bit 2 of languageNumber is set, then the chosen AND #%00000100 ; language is French, so jump to TT75 to print the BNE TT75 ; species and then the third adjective, e.g. "Rodents ; Furry" LDA QQ15+5 ; Now for the second adjective, so shift s2_hi so we get LSR A ; A = bits 5-7 of s2_hi LSR A LSR A LSR A LSR A CMP #6 ; If A >= 6, jump to TT206 to skip the second adjective BCS TT206 ADC #230 ; Otherwise A = 0 to 5, so print recursive token JSR spc ; 70 + A, followed by a space, so: ; ; A = 0 prints token 70 ("GREEN") and a space ; A = 1 prints token 71 ("RED") and a space ; A = 2 prints token 72 ("YELLOW") and a space ; A = 3 prints token 73 ("BLUE") and a space ; A = 4 prints token 74 ("BLACK") and a space ; A = 5 prints token 75 ("HARMLESS") and a space .TT206 LDA QQ19 ; Fetch the value that we calculated for the third ; adjective CMP #6 ; If A >= 6, jump to TT207 to skip the third adjective BCS TT207 ADC #236 ; Otherwise A = 0 to 5, so print recursive token JSR spc ; 76 + A, followed by a space, so: ; ; A = 0 prints token 76 ("SLIMY") and a space ; A = 1 prints token 77 ("BUG-EYED") and a space ; A = 2 prints token 78 ("HORNED") and a space ; A = 3 prints token 79 ("BONY") and a space ; A = 4 prints token 80 ("FAT") and a space ; A = 5 prints token 81 ("FURRY") and a space .TT207 LDA QQ15+5 ; Now for the actual species, so take bits 0-1 of AND #%00000011 ; s2_hi, add this to the value of A that we used for CLC ; the third adjective, and take bits 0-2 of the result ADC QQ19 AND #%00000111 ADC #242 ; A = 0 to 7, so print recursive token 82 + A, so: JSR TT27_b2 ; ; A = 0 prints token 82 ("RODENTS") ; A = 1 prints token 83 ("FROGS") ; A = 2 prints token 84 ("LIZARDS") ; A = 3 prints token 85 ("LOBSTERS") ; A = 4 prints token 86 ("BIRDS") ; A = 5 prints token 87 ("HUMANOIDS") ; A = 6 prints token 88 ("FELINES") ; A = 7 prints token 89 ("INSECTS") .TT76 LDA languageNumber ; If bit 1 of languageNumber is set then the chosen AND #%00000010 ; language is German, so jump to dsys10 skip the BNE dsys10 ; following ; If we get here then the chosen language is French or ; English, so we print the species in brackets LDA #')' ; Print a closing bracket JSR TT27_b2 .dsys10 JSR TTX69 ; Print a paragraph break and set Sentence Case ; By this point, ZZ contains the current system number ; which PDESC requires. It gets put there in the TT102 ; routine, which calls TT111 to populate ZZ before ; calling TT25 (this routine) JSR PDESC_b2 ; Call PDESC to print the system's extended description JSR FadeAndHideSprites ; Fade the screen to black and hide all sprites, so we ; can update the screen while it's blacked-out LDA #22 ; Move the text cursor to column 22 STA XC LDA #8 ; Move the text cursor to row 8 STA YC LDA #1 ; These instructions have no effect as the values of K+2 STA K+2 ; and K+3 get overwritten by the call to DrawSystemImage LDA #8 STA K+3 LDX #8 ; Set X = 8 to pass to the call to DrawSystemImage as ; the number of tile columns to draw in the system image LDY #7 ; Set Y = 7 to pass to the call to DrawSystemImage as ; the number of tile rows to draw in the system image JSR DrawSystemImage_b3 ; Call DrawSystemImage to draw the system image JMP UpdateView ; Update the view, returning from the subroutine using ; a tail call