Skip to navigation

Elite on the BBC Micro and NES

Version analysis of TT146

This code appears in the following versions (click to see it in the source code):

Code variations between these versions are shown below.

Name: TT146 Type: Subroutine Category: Universe Summary: Print the distance to the selected system in light years
If it is non-zero, print the distance to the selected system in light years. If it is zero, just move the text cursor down a line. Specifically, if the distance in QQ8 is non-zero, print token 31 ("DISTANCE"), then a colon, then the distance to one decimal place, then token 35 ("LIGHT YEARS"). If the distance is zero, move the cursor down one line.
.TT146 LDA QQ8 \ Take the two bytes of the 16-bit value in QQ8 and ORA QQ8+1 \ OR them together to check whether there are any BNE TT63 \ non-zero bits, and if so, jump to TT63 to print the \ distance

Code variation 1 of 1Related to Elite's use of the Tube

This variation is blank in the 6502 Second Processor version.

INC YC \ The distance is zero, so we just move the text cursor RTS \ in YC down by one line and return from the subroutine
.TT63

 LDA #191               \ Print recursive token 31 ("DISTANCE") followed by
 JSR TT68               \ a colon

 LDX QQ8                \ Load (Y X) from QQ8, which contains the 16-bit
 LDY QQ8+1              \ distance we want to show

 SEC                    \ Set the C flag so that the call to pr5 will include a
                        \ decimal point, and display the value as (Y X) / 10

 JSR pr5                \ Print (Y X) to 5 digits, including a decimal point

 LDA #195               \ Set A to the recursive token 35 (" LIGHT YEARS") and
                        \ fall through into TT60 to print the token followed
                        \ by a paragraph break