Skip to navigation

Elite on the BBC Micro and NES

Charts: TT22

[NES version, Bank 0]

Name: TT22 [Show more] Type: Subroutine Category: Charts Summary: Show the Long-range Chart
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * RedrawCurrentView calls TT22 * TT102 calls TT22 * TT114 calls TT22
.TT22 LDA #$8D ; Clear the screen and set the view type in QQ11 to $8D JSR TT66 ; (Long-range Chart) LDA #77 ; Set the screen height variables for a screen height of JSR SetScreenHeight ; 154 (i.e. 2 * 77) LDA #7 ; Move the text cursor to column 7 STA XC JSR TT81 ; Set the seeds in QQ15 to those of system 0 in the ; current galaxy (i.e. copy the seeds from QQ21 to QQ15) LDA #199 ; Print recursive token 39 ("GALACTIC CHART{galaxy JSR NLIN3 ; number right-aligned to width 3}") on the top row LDA #152 ; Draw a screen-wide horizontal line at pixel row 152 JSR NLIN2 ; for the bottom edge of the chart, so the chart itself ; is 128 pixels high, starting on row 24 and ending on ; row 151 JSR FadeAndHideSprites ; Fade the screen to black and hide all sprites, so we ; can update the screen while it's blacked-out JSR TT14 ; Call TT14 to draw a circle with crosshairs at the ; current system's galactic coordinates LDX #0 ; We're now going to plot each of the galaxy's systems, ; so set up a counter in X for each system, starting at ; 0 and looping through to 255 .TT83 STX XSAV ; Store the counter in XSAV LDA QQ15+3 ; Fetch the s1_hi seed into A, which gives us the ; galactic x-coordinate of this system LSR A ; Set X = s1_hi - (A / 4) + 31 LSR A ; = s1_hi - (s1_hi / 4) + 31 STA T1 ; = 31 + 0.75 * s1_hi LDA QQ15+3 ; SEC ; So this scales the x-coordinate from a range of 0 to SBC T1 ; 255 into a range from 31 to 222, so it fits nicely CLC ; into the Long-range Chart ADC #31 TAX LDY QQ15+4 ; Fetch the s2_lo seed and set bits 4 and 6, storing the TYA ; result in ZZ to give a random number between 80 and ORA #%01010000 ; (but which will always be the same for this system). STA ZZ ; We use this value to determine the size of the point ; for this system on the chart by passing it as the ; distance argument to the PIXEL routine below LDA QQ15+1 ; Fetch the s0_hi seed into A, which gives us the ; galactic y-coordinate of this system LSR A ; Set A = (s0_hi - (A / 4)) / 2 + 32 LSR A ; = (s0_hi - (s0_hi / 4)) / 2 + 32 STA T1 ; = 32 + 0.375 * s1_hi LDA QQ15+1 ; SEC ; So this scales the y-coordinate from a range of 0 to SBC T1 ; 255 into a range from 32 to 127, so it fits nicely LSR A ; into the Long-range Chart CLC ADC #32 STA Y1 ; Store the y-coordinate in Y1 (though this gets ; overwritten by the call to DrawDash, so this has no ; effect) JSR DrawDash ; Draw a 2-pixel dash at pixel coordinate (X, A) JSR TT20 ; We want to move on to the next system, so call TT20 ; to twist the three 16-bit seeds in QQ15 LDX XSAV ; Restore the loop counter from XSAV INX ; Increment the counter BNE TT83 ; If X > 0 then we haven't done all 256 systems yet, so ; loop back up to TT83 LDA #3 ; Set K+2 = 3 to pass to DrawSmallBox as the text row STA K+2 ; on which to draw the top-left corner of the small box LDA #4 ; Set K+3 = 4 to pass to DrawSmallBox as the text column STA K+3 ; on which to draw the top-left corner of the small box LDA #25 ; Set K = 25 to pass to DrawSmallBox as the width of the STA K ; small box LDA #14 ; Set K+1 = 14 to pass to DrawSmallBox as the height of STA K+1 ; the small box JSR DrawSmallBox_b3 ; Draw a box around the chart, with the top-left corner ; at (3, 4), a height of 14 rows, and a width of 25 rows LDA QQ9 ; Set QQ19 to the selected system's x-coordinate STA QQ19 LDA QQ10 ; Set QQ19+1 to the selected system's y-coordinate, LSR A ; halved to fit it into the chart STA QQ19+1 LDA #4 ; Set QQ19+2 to size 4 for the crosshairs size STA QQ19+2 JSR TT103 ; Draw small crosshairs at coordinates (QQ9, QQ10), ; which will draw the crosshairs at our current home ; system LDA #$9D ; Set the view type in QQ11 to $00 (Long-range Chart STA QQ11 ; with the normal font loaded) LDA #143 ; Set the number of pixel rows in the space view to 143, STA Yx2M1 ; so the screen height is correctly set for the ; Short-range Chart in case we switch to it using the ; icon in the icon bar (which toggles between the two ; charts) JMP UpdateView ; Update the view, returning from the subroutine using ; a tail call