Skip to navigation

Version analysis of FLIP

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

Code variations between these versions are shown below.

Name: FLIP Type: Subroutine Category: Stardust Summary: Reflect the stardust particles in the screen diagonal and redraw the stardust field
Swap the x- and y-coordinates of all the stardust particles and draw the new set of particles. Called by LOOK1 when we switch views. This is a quick way of making the stardust field in the new view feel different without having to generate a whole new field. If you look carefully at the stardust field when you switch views, you can just about see that the new field is a reflection of the previous field in the screen diagonal, i.e. in the line from bottom left to top right. This is the line where x = y when the origin is in the middle of the screen, and positive x and y are right and up, which is the coordinate system we use for stardust).

Code variation 1 of 3A variation in the comments only

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

\LDA MJ \ These instructions are commented out in the original \BNE FLIP-1 \ source. They would have the effect of not swapping the \ stardust if we had mis-jumped into witchspace

Code variation 2 of 3Related to the screen mode

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

LDA #DUST \ Switch to stripe 3-2-3-2, which is cyan/red in the STA COL \ space view

Code variation 3 of 3Related to the Electron version

The Electron version only shows 10 stardust particles at once, compared to 20 in the Master version or 18 in the other versions.

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

LDY NOSTM \ Set Y to the current number of stardust particles, so \ we can use it as a counter through all the stardust
LDY #NOST \ Set Y to the number of stardust particles, so we can \ use it as a counter through all the stardust

 LDX SY,Y               \ Copy the Y-th particle's y-coordinate from SY+Y into X

 LDA SX,Y               \ Copy the Y-th particle's x-coordinate from SX+Y into
 STA Y1                 \ both Y1 and the particle's y-coordinate

 TXA                    \ Copy the Y-th particle's original y-coordinate into
 STA X1                 \ both X1 and the particle's x-coordinate, so the x- and
 STA SX,Y               \ y-coordinates are now swapped and (X1, Y1) contains
                        \ the particle's new coordinates

 LDA SZ,Y               \ Fetch the Y-th particle's distance from SZ+Y into ZZ

 JSR PIXEL2             \ Draw a stardust particle at (X1,Y1) with distance ZZ

 DEY                    \ Decrement the counter to point to the next particle of
                        \ stardust

 BNE FLL1               \ Loop back to FLL1 until we have moved all the stardust
                        \ particles

 RTS                    \ Return from the subroutine