Hands up those of you who knows and Amiga owner. Keep your hands up if they laugh at the lack of games and demos. Yes - too many hands. Well, the Arc is fighting back. A magazine demo with four layers of parallax, a parallax scrolling landscape and a scroll- text. All in under 7k. Beat that on your 16bit.
{\ 123}P}The demo has to be contender for 'Succinct program of the year' - using just one screen bank (80k), and the 64k for the BASIC program and variables. Despite the low memory requirements, the processor is working overtime - it could quite possibly have 'arm-ache' afterwards.
{\ 123}P}What is Parallax?
{\ 123}P}Parallax is the current 'fashion' in demos. It basically means that you have several 'layers' (or levels) of scenery, stars or whatever, all scrolling around the screen at different rates. This can give the impression of movement (nearer objects moving faster than distant ones). In a starfield, the parallax can be enhanced by dimming the stars as they get farther away.
{\ 123}P}There are several different methods of plotting parallax - some of which are too complicated to go into here. The two I used, however, are far simpler. For the stars, all that was needed was a 'table' with an entry for each star. An entry consisted of the x and y coordinates, the colour and speed of movement. A section of code went through the table, calculating screen addresses and plotted a pixel of the given colour at that address. After plotting, the x coordinate was decremented by the speed, and negatives were caught and sent back to the other side of the screen. This created a continual field of stars, moving at different speeds.
{\ 123}P}The 'moon landscape' at the bottom of the screen used (obviously) a different technique. The left half must be a mirror image of the right, and is drawn first by a basic procedure. A machine code routine is then used to scroll it - the top is scrolled at 8 pixels/Vsync, the bottom is scrolled at half that. This creates the parallax.
{\ 123}P}The Scrolly
{\ 123}P}This was the most difficult part of the entire demo. I initially tried using OS_WriteC (equivalent to VDU), but this was far too slow. Instead, I extracted the definition of each character using OS_Word 10, and then converted each definition into a small machine code program. Each separate code segment 'drew' a different character onto the screen. This speeded things up tremendously, and then it was simply a matter of adding the 'Mexican Wave' style ripple. This was easily done by changing the y position of each character.
{\ 123}P}Anyone who knows the basics of ARM programming can write a demo. The easiest way to start off is by just doing a little. Just try a star field at first, perhaps. Don't worry if it doesn't work, programs hardly ever do first time around. If you persevere, almost anything can be achieved. The best part of writing a program is seeing it working at the end.