Skip to navigation


Version analysis of HFS2

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

Code variations between these versions are shown below.

Name: HFS2 Type: Subroutine Category: Drawing circles Summary: Draw the launch or hyperspace tunnel
The animation gets drawn like this. First, we draw a circle of radius 8 at the centre, and then double the radius, draw another circle, double the radius again and draw a circle, and we keep doing this until the radius is bigger than 160 (which goes beyond the edge of the screen, which is 256 pixels wide, equivalent to a radius of 128). We then repeat this whole process for an initial circle of radius 9, then radius 10, all the way up to radius 15. This has the effect of making the tunnel appear to be racing towards us as we hurtle out into hyperspace or through the space station's docking tunnel.

Code variation 1 of 6A variation in the comments only

This variation is blank in the Electron version.

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

The hyperspace effect is done in a full mode 5 screen, which makes the rings all coloured and zig-zaggy, while the launch screen is in the normal monochrome mode 4 screen.
The hyperspace effect is done in a full mode 2 screen, which makes the rings all coloured and zig-zaggy, while the launch screen is in the normal four-colour mode 1 screen.

Arguments: A The step size of the straight lines making up the rings (4 for launch, 8 for hyperspace)

Code variation 2 of 6A variation in the comments only

This variation is blank in the Cassette and Electron versions.

Other entry points: HFS1 Don't clear the screen, and draw 8 concentric rings with the step size in STP
.HFS2 STA STP \ Store the step size in A

Code variation 3 of 6Specific to an individual platform

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

JSR TTX66 \ Clear the screen and draw a border box
LDA QQ11 \ Store the current view type in QQ11 on the stack PHA LDA #0 \ Clear the top part of the screen, draw a border box, JSR TT66 \ and set the current view type in QQ11 to 0 (the space \ view) PLA \ Restore the view type from the stack STA QQ11

Code variation 4 of 6Related to an advanced feature

The original versions of Elite draw 16 concentric rings for hyperspace, while the advanced versions draw 8.

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

JSR HFS1 \ Call HFS1 below and then fall through into the same \ routine, so this effectively runs HFS1 twice, and as \ HFS1 draws 8 concentric rings, this means we draw 16 \ of them in all
.HFS1

Code variation 5 of 6Minor and very low-impact

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

LDA #128 \ Set K3 = 128 (the x-coordinate of the centre of the STA K3 \ screen)
LDX #X \ Set K3 = #X (the x-coordinate of the centre of the STX K3 \ screen)
 LDX #Y                 \ Set K4 = #Y (the y-coordinate of the centre of the
 STX K4                 \ screen)

Code variation 6 of 6Minor and very low-impact

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

ASL A \ Set A = 0 STA XX4 \ Set XX4 = 0, which we will use as a counter for \ drawing eight concentric rings STA K3+1 \ Set the high bytes of K3(1 0) and K4(1 0) to 0 STA K4+1
LDX #0 \ Set X = 0 STX XX4 \ Set XX4 = 0, which we will use as a counter for \ drawing eight concentric rings STX K3+1 \ Set the high bytes of K3(1 0) and K4(1 0) to 0 STX K4+1
.HFL5

 JSR HFL1               \ Call HFL1 below to draw a set of rings, with each one
                        \ twice the radius of the previous one, until they won't
                        \ fit on-screen

 INC XX4                \ Increment the counter and fetch it into X
 LDX XX4

 CPX #8                 \ If we haven't drawn 8 sets of rings yet, loop back to
 BNE HFL5               \ HFL5 to draw the next ring

 RTS                    \ Return from the subroutine

.HFL1

 LDA XX4                \ Set K to the ring number in XX4 (0-7) + 8, so K has
 AND #7                 \ a value of 8 to 15, which we will use as the starting
 CLC                    \ radius for our next set of rings
 ADC #8
 STA K

.HFL2

 LDA #1                 \ Set LSP = 1 to reset the ball line heap
 STA LSP

 JSR CIRCLE2            \ Call CIRCLE2 to draw a circle with the centre at
                        \ (K3(1 0), K4(1 0)) and radius K

 ASL K                  \ Double the radius in K

 BCS HF8                \ If the radius had a 1 in bit 7 before the above shift,
                        \ then doubling K will means the circle will no longer
                        \ fit on the screen (which is width 256), so jump to
                        \ HF8 to stop drawing circles

 LDA K                  \ If the radius in K <= 160, loop back to HFL2 to draw
 CMP #160               \ another one
 BCC HFL2

.HF8

 RTS                    \ Return from the subroutine