Skip to navigation

Elite on the BBC Micro and NES

Version analysis of ypl

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

Code variations between these versions are shown below.

Name: ypl Type: Subroutine Category: Universe Summary: Print the current system name
Print control code 2 (the current system name).
Other entry points: ypl-1 Contains an RTS
.ypl

Code variation 1 of 2Related to the BBC Micro disc version

If we jump into witchspace, the disc version still displays the original system name as the "Present system" in the Status Mode screen, while the other versions just show a blank name.

This variation is blank in the Disc (flight), Disc (docked) and Electron versions.

Tap on a block to expand it, and tap it again to revert.

LDA MJ \ Check the mis-jump flag at MJ, and if it is non-zero BNE cmn-1 \ then we are in witchspace, and witchspace doesn't have \ a system name, so return from the subroutine (cmn-1 \ contains an RTS)
BIT MJ \ Check the mis-jump flag at MJ, and if bit 7 is set BMI ypl16 \ then we are in witchspace, and witchspace doesn't have \ a system name, so jump to ypl16 to return from the \ subroutine
 JSR TT62               \ Call TT62 below to swap the three 16-bit seeds in
                        \ QQ2 and QQ15 (before the swap, QQ2 contains the seeds
                        \ for the current system, while QQ15 contains the seeds
                        \ for the selected system)

 JSR cpl                \ Call cpl to print out the system name for the seeds
                        \ in QQ15 (which now contains the seeds for the current
                        \ system)

                        \ Now we fall through into the TT62 subroutine, which
                        \ will swap QQ2 and QQ15 once again, so everything goes
                        \ back into the right place, and the RTS at the end of
                        \ TT62 will return from the subroutine

.TT62

 LDX #5                 \ Set up a counter in X for the three 16-bit seeds we
                        \ want to swap (i.e. 6 bytes)

.TT78

 LDA QQ15,X             \ Swap byte X between QQ2 and QQ15
 LDY QQ2,X
 STA QQ2,X
 STY QQ15,X

 DEX                    \ Decrement the loop counter

 BPL TT78               \ Loop back for the next byte to swap

Code variation 2 of 2A variation in the labels only

This variation is blank in the Cassette, Disc (flight), Disc (docked) and Electron versions.

.ypl16
 RTS                    \ Once all bytes are swapped, return from the
                        \ subroutine