Skip to navigation


Version analysis of SOLAR

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

Code variations between these versions are shown below.

Name: SOLAR Type: Subroutine Category: Universe Summary: Set up various aspects of arriving in a new system

Code variation 1 of 6A variation in the comments only

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

Halve our legal status, update the missile indicators, and set up data blocks and slots for the planet and sun.
Halve our legal status, update the missile indicators, and set up the data block and slot for the planet.
.SOLAR

Code variation 2 of 6Related to the Master version

The Master version runs an extra bit of code when arriving in a new system that is responsible for breeding any Trumbles in the hold, though as there are no Trumbles in the BBC versions of the game, this never actually breeds anything.

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

LDA TRIBBLE \ If we have no Trumbles in the hold, skip to nobirths BEQ nobirths \ If we get here then we have Trumbles in the hold, so \ this is where they breed (though we never get here in \ the Master version as the number of Trumbles is always \ zero) LDA #0 \ Trumbles eat food and narcotics during the hyperspace STA QQ20 \ journey, so zero the amount of food and narcotics in STA QQ20+6 \ the hold JSR DORND \ Take the number of Trumbles from TRIBBLE(1 0), add a AND #15 \ random number between 4 and 15, and double the result, ADC TRIBBLE \ storing the resulting number in TRIBBLE(1 0) ORA #4 \ ROL A \ We start with the low byte STA TRIBBLE ROL TRIBBLE+1 \ And then do the high byte BPL P%+5 \ If bit 7 of the high byte is set, then rotate the high ROR TRIBBLE+1 \ byte back to the right, so the number of Trumbles is \ always positive .nobirths
 LSR FIST               \ Halve our legal status in FIST, making us less bad,
                        \ and moving bit 0 into the C flag (so every time we
                        \ arrive in a new system, our legal status improves a
                        \ bit)

 JSR ZINF               \ Call ZINF to reset the INWK ship workspace, which
                        \ doesn't affect the C flag

 LDA QQ15+1             \ Fetch s0_hi

Code variation 3 of 6Related to a standard feature

When generating system data in the cassette and Electron versions, the initial position of the planet is calculated using bits 0-2 of the system's s0_hi seed, but in the other versions only bits 0-1 of s0_hi are used.

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

AND #%00000111 \ Extract bits 0-2 (which also happen to determine the \ economy), which will be between 0 and 7 ADC #6 \ Add 6 + C, and divide by 2, to get a result between 3 LSR A \ and 7, at the same time shifting bit 0 of the result \ of the addition into the C flag
AND #%00000011 \ Extract bits 0-1 (which also help to determine the \ economy), which will be between 0 and 3 ADC #3 \ Add 3 + C, to get a result between 3 and 7, clearing \ the C flag in the process
 STA INWK+8             \ Store the result in z_sign in byte #6

Code variation 4 of 6Related to a standard feature

In the cassette and Electron versions, the initial position of the planet can be to the upper right or lower left, but in the other versions it's always to the upper right.

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

ROR A \ Halve A, rotating in the C flag, which was previously STA INWK+2 \ bit 0 of s0_hi + 6 + C, so when this is stored in both STA INWK+5 \ x_sign and y_sign, it moves the planet to the upper \ right or lower left
ROR A \ Halve A, rotating in the C flag (which is clear) and STA INWK+2 \ store in both x_sign and y_sign, moving the planet to STA INWK+5 \ the upper right
 JSR SOS1               \ Call SOS1 to set up the planet's data block and add it
                        \ to FRIN, where it will get put in the first slot as
                        \ it's the first one to be added to our local bubble of
                        \ this new system's universe

Code variation 5 of 6Related to the Electron version

As there is no sun in the Electron version, there is no need to set up its position and distance on arrival in a new system.

This variation is blank in the Electron version.

LDA QQ15+3 \ Fetch s1_hi, extract bits 0-2, set bits 0 and 7 and AND #%00000111 \ store in z_sign, so the sun is behind us at a distance ORA #%10000001 \ of 1 to 7 STA INWK+8 LDA QQ15+5 \ Fetch s2_hi, extract bits 0-1 and store in x_sign and AND #%00000011 \ y_sign, so the sun is either dead centre in our rear STA INWK+2 \ laser crosshairs, or off to the top left by a distance STA INWK+1 \ of 1 or 2 when we look out the back LDA #0 \ Set the pitch and roll counters to 0 (no rotation) STA INWK+29 STA INWK+30

Code variation 6 of 6A variation in the comments only

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

LDA #129 \ Set A = 129, the ship type for the sun JSR NWSHP \ Call NWSHP to set up the sun's data block and add it \ to FRIN, where it will get put in the second slot as \ it's the second one to be added to our local bubble \ of this new system's universe
LDA #129 \ Set A = 129, the ship type for the placeholder, so \ there isn't a space station, but there is a non-zero \ ship type to indicate this JSR NWSHP \ Call NWSHP to set up the new data block and add it \ to FRIN, where it will get put in the second slot as \ we just cleared out the second slot, and the first \ slot is already taken by the planet