Skip to navigation

BBC Micro Elite

Stardust in the side views

The algorithms behind the stardust particles in the side views
--------------------------------------------------------------
References: STARS2
  The STARS2 routine moves the stardust sideways according to our speed and
  which side we are looking out of, and applies our current pitch and roll to
  each particle of dust, so the stardust moves correctly when we steer our ship.
  
  Let's look at this process in more detail. It breaks down into three stages:
  
   * Moving the stardust sideways
  
   * Applying pitch to the stardust (rotating around the mid-point)
  
   * Applying roll to the stardust (up and down)
  
  Moving the stardust sideways
  ----------------------------
  First, we want to move the stardust sideways, in the correct direction for
  the current view. The further away the stardust particle (i.e. with a higher
  value of z) the slower it should move, to give a sense of perspective.
  
  These are the calculations:
  
    1. delta_x = 8 * 256 * speed / z_hi
    2. x = x + delta_x
  
  We sign the delta_x value as negative for the left view, where particles go
  from right to left, and positive for the right view, where particles go from
  left to right, and then we add the delta to the x-coordinate to move the
  stardust particle past our side window as we speed along.
  
  Applying pitch to the stardust (rotating)
  -----------------------------------------
  The following calculations apply the current pitch angle beta to the stardust:
  
    3. x = x + beta * y
    4. y = y - beta * x
  
  These are essentially the same as the roll equations from MVS4, just using the
  pitch angle beta, because when we are looking out of the side views, when the
  ship pitches, the side views rotate around the middle, just like the front
  view does when we roll.
  
  Applying roll to the stardust (up/down)
  ---------------------------------------
  The following calculations apply the current roll angle alpha to the stardust:
  
    5. x = x - alpha * x * y
    6. y = y + alpha * y * y + alpha
  
  The significant part here is adding alpha to y (or, more specifically, ALPHA *
  256). This means that as we roll the ship and alpha increases, the stardust
  out of the side view goes up and down, which is pretty intuitive.
  
  The other part is currently a bit of a mystery, along with the pitch
  calculations in STARS1. More analysis needed here...