If you want to write a VU demo for the competition, you'll have to download the current harness, it's already compiled, so all you have to do is run it. Download this file to your favourite directory (your home directory will do). Then type:
tar zxfv vu_coding_contest_2003_ps2linux.tar.gz
cd vu_coding_contest_2003_ps2linux
cd previous_demos
./harness -h
(Tip for Linux newbies: Just type the first few letters of the file, i.e. vu_c and hit Tab. The PS2 realises that only one file begins with vu_c, so it knows which one you mean!)
That will show you the available harness options. Choose the right one for your display, e.g. ./harness -p for PAL, and the harness will load. Press start, and flick through previous demos with L1 and L2. Pay particular attention to all entries marked "Winner!", but especially Mike Day's VUniverse. It's astounding.
2 other demos you should pay attention to are "Basic" and "Dedicated to the one I love". The first is the basic sample we're going to start our learning from, the second is my first ever VU demo, and the kind of thing this tutorial series is going to push you towards.
All competition entries have to co-operate with the harness, so to enter the competition, you have to leave it as it is. All I'm going to do in this tutorial is explain how it gets your VU demo up and running, this isn't an in depth discussion of the harness code.
Competition entries consist of a number of files, but the 2 most important ones are the data file, and the code file. We'll talk about how to make your own later (3: Making your data file, 4: Making your code file). Once you've quit the harness, go over to the plain_harness/demodata directory:
cd ..
cd plain_harness
cd demodata
You will find 4 files in there. 3 of them make up the basic sample: basic.bin, basic.dat, and basic.hlp. The 4th (demotest.ini) is a list loaded by the harness to tell it which files belong to which demo. basic.bin is the code file (note that it's only 32 byte long!), basic.dat is the data file, and basic.hlp is the text file that is displayed if you press SELECT whilst viewing the demo. Prove it to yourself by opening it up in your favourite text editor and altering it, then rerunning the harness.
But what does it do?
So, how does the harness get your creation onto the screen? The harness only does a small number of things to get the demo up and running:
1) Get the data file, and load it into the vu data memory.
2) Get the code file, and load it into the vu instruction memory.
3) Send some information to the last QWord of vu data memory (more on this later)
4) Start VU code execution at address 0 (i.e. the very start of vu instruction memory)
5) When VU code finishes, loop back to step 3.
What's important about the above loop? The data file is only loaded into vu data mem *once*. After you've uploaded your initial data, the harness leaves it alone. If you want to do anything to the data memory during the demo, it has to be done by your program. Also note that the VU code must not loop continuously to itself, it is instead executed every frame. This allows the harness time to kill your demo and load up another one.
The harness loads both your data and code by a 'direct copy', i.e. there's no need to put any extra information like DMAtags into your data file or your code file. If you don't know what a DMAtag is, don't worry, you don't need one to write a VU demo. If you do know what one is, forget about them momentarily :)
The most important part of this lesson to grasp is that your demo will consist of 2 separate files with 2 separate functions. They can be written by different means, using different languages, on different computers, it doesn't matter how they are generated. All you must end up with is a file of 16kb or less that will be loaded once only into data memory at the start of your demo, and a code file of (assembled) VU instructions that will be executed once per frame.
Ready to go and make those files? Before we do it ourselves, let's look at how the basic sample does it. To do that, we need to see what exactly the basic sample actually does.