Skip to navigation

Elite on the BBC Micro and NES

Stardust: FLIP

[NES version, Bank 0]

Name: FLIP [Show more] Type: Subroutine Category: Stardust Summary: Reflect the stardust particles in the screen diagonal
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * LOOK1 calls FLIP

Swap the x- and y-coordinates of all the stardust 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).
.FLIP LDY NOSTM ; Set Y to the current number of stardust particles, so ; we can use it as a counter through all the stardust .FLL1 SETUP_PPU_FOR_ICON_BAR ; If the PPU has started drawing the icon bar, configure ; the PPU to use nametable 0 and pattern table 0 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 SY,Y ; the particle's y-coordinate TXA ; Copy the Y-th particle's original y-coordinate into STA SX,Y ; the particle's x-coordinate, so the x- and ; y-coordinates are now swapped LDA SZ,Y ; Fetch the Y-th particle's distance from SZ+Y into ZZ STA 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