All about the Star Wars-esque scroll text in the Tube-based version of Elite
The 6502 Second Processor has a unique demo mode that only appears in this version. It shows off the improved speed of the 3MHz 65C02 processor that sits at the heart of the famous wedge-shaped expansion box, though as you can't escape from the demo once it has started, it can get a bit annoying for seasoned players. Still, it's a bit of fun, if only for the first few times you see it...
The demo starts automatically if you leave the game idling at the title screen, or you can trigger it manually by pressing TAB. It is controlled by the DEMON routine, which has the following stages:
- "ACORNSOFT PRESENTS" scrolls up the screen like the opening of Star Wars
- The Elite logo appears from behind the camera, moving fowards into view and tilted back so it appears on-edge, with the bottom of the logo pointing towards the camera
- It then tilts forwards until it's fully vertical in front of the camera
- A Cobra Mk III flies in slowly from behind the camera at the top of the screen
- The Cobra fires its lasers at the logo, which explodes, and the Cobra flies on, in a clockwise roll, before pausing at the top of the screen
- "BY IAN BELL AND DAVID BRABEN" scrolls up the screen
- The camera speeds forward, the Cobra starts to fly again, pitching upwards as the camera overtakes it while it flies off the top of the screen
- "THE GALAXY IS IN TURMOIL, THE NAVY FAR AWAY AS THE EMPIRE CRUMBLES" scrolls up the screen
- An Adder appears in the middle of the screen and flies towards and past the camera, diving down and rolling clockwise just before it hits us
Interestingly, the game uses the existing spawning and ship-drawing routines to create the entire demo - even the scrolling text that rolls up the screen is made up of a set of lines in space that are displayed using the standard line-drawing buffer of the 6502 Second Processor version. Our Cobra Mk III is effectively a camera, speeding up, slowing down and panning when required, and the Elite logo is stored as a ship, with its own data block, vertices, faces and edges, just like every other ship. Perhaps that's why it slows down a bit as more text appears on-screen - there are lots more lines on-screen than in your average ship battle.
The ship-drawing routines are covered in plenty of detail elsewhere, so let's take a look at the scroll text in more detail.
Displaying the scroll text
The scroll text is implemented by the SLIDE routine.The first step is to write the scroll text onto a 2D canvas, laid out like this, starting with the first words in the top-left, as you would expect when writing on a piece of paper:
(0, 254) (256, 254) +------------+ | | ^ | On-screen | | | | | scroll direction |............| | ^ : : | : : BALI : Off-screen : | : : V : : +------------+ (0, 0) (256, 0)
Note that the y-axis is in the same direction as in the 3D space view, so the (0, 0) origin is in the bottom left, and y-coordinates get larger as you move up the canvas (and x increases towards the right, as you would expect).
BALI is a counter that goes from 254 to 2, and can be thought of as the y-coordinate of our eyes as we read through the scroll text from top to bottom, or, alternatively, how much of the canvas has yet to appear on-screen as the canvas scrolls into view.
Now take a point (X1, Y1) in the 2D scroll text canvas, like this:
X1 <---> +------------+ | | | x | | | ^ ^ | | | | | | | | Y1 - BALI | | | | |............| | v ^ : : | | : : | Y1 BALI : Off-screen : | | : : | v : : | +------------+ v
If Y1 < BALI, the point is off the bottom of the screen, so let's assume that Y1 >= BALI. This means that the value of Y1 - BALI is 0 for points at the bottom of the visible section, and higher for points near the top.
We can project the point (X1, Y1) onto the Star Wars scroll text to get a 3D space coordinate (x, y, z), with each coordinate being calculated as follows:
x = (x_sign x_hi x_lo) = X1 - 128
The x calculation moves the point (X1, Y1) to the left so the scroll text is in the centre, right in front of the camera (i.e. it shifts the x-coordinate range from 0-255 to -128 to +127).
y = (y_sign y_hi y_lo) = (Y1 - BALI) - 128
The y calculation moves the point (X1, Y1) down so that points at the bottom of the visible part of the canvas (those just appearing) will be at a space y-coordinate of -128, so the scroll text appears to come in from just below the bottom of the screen.
z = (z_sign z_hi z_lo) = ((Y1 - BALI) * 4 div 256) + #D
The z calculation tips the top of the 2D canvas away from the viewer by giving points higher up the canvas (i.e. those with higher y-coordinates) a higher z-coordinate, so the top of the canvas is further away (as the z-coordinate is into the screen). The #D configuration variable is the z-distance of the bottom of the visible part of the canvas as it scrolls into view. The scroll text then looks like a flat canvas disappearing into the distance because the z-coordinate is in a linear relationship with the y-coordinate (i.e. z = ky + d where k and d are constants).
We then project this space coordinate onto the screen for drawing, using the same process as when we draw ships. Couple this with some tables that we can use to store the projected lines, so they can be erased again later, and we can scroll the text in a Star Wars style by simply counting BALI from 254 down to 2, reprojecting the canvas and redrawing the scroll text with each new value.