Hooray 4K Intro
In the bonus archive of this Hugi issue, you can find the sourcecode of my 4k intro "Hooray".
The reason for writing this intro was just to check out how raytracing worked. I read the sections about raytracing, shading and reflection in the book "Computer Graphics: Principles and Practice", and made a small raytracer in C just to check out how the algorithms worked. Then I started writing the 4k. It's been over 1.5 years since I looked at the source, so I don't remember much of how the program actually works. :) This version is not the party version, and it is therefore slightly larger than 4k. The party-version only worked on graphics-cards with 320x240 16bit mode, and with 640 bytes per scanline. The "release"-version uses Vesa 1.2 640x480 16bit, and it has even got error messages. Both versions use a special VGA-register to duplicate each scanline, so the intro may not look good on some cards, at least not on ATI Mach64. (Still images only cover 1/2 of the screen, and the animations cover 1/4 of it).
My intention from the beginning was to split the intro into several modules. This made the program easier to maintain and I could use several routines (especially the vector-routines) more than once. I think I started with writing the different vector-routines and colour routines, and then I wrote the raytracer engine. I didn't write the vesa-routines in the beginning, because it was easier (and safer) to use mode 13h (320x200, 256 colours) for testing. When I got the raytracer up and running, I was disappointed but not surprised at the speed. But I didn't care, because it was a 4k intro, and I didn't have space (and time :) to speed-optimize critical routines and algorithms.
The animation is precalculated during the intro. The first animation is rendered when the first still image is shown. While the animation runs, the second animation is rendered. Both animations are rendered into XMS memory, and so the intro requires about 2.5 MB free XMS memory. The playback routine is hooked at the timer interrupt (1Ch). The timer frequency is not changed, so the playback rate is 18.2 frames per second. :) The first animation is shown until the rendering of the second is finished. The second animation loops 15 times, and then the last still image is shown.
It was hard to get this intro under 4k. The size of the intro (packed with pklite) was about 4.4kb, when I arrived at Bushparty 4.0. I hoped I would get a better com-packer at the party, and I was right. I got wwpack, and it compressed the intro to a bit under 4k, so I figured I could add some more. I can't remember what I added at the party, but I know for sure that the intro was not 100% finished when I arrived. When the intro was done, it was 50 bytes or something above 4k, so I had to remove some greetings and other text. The party-version was exactly 4096 bytes (packed with wwpack).
When I look at the source now I find parts with very bad code and strange comments. This might confuse you, but I don't care. :)
After the intro had been finished, I started writing a simple raytracer in C++ for using in demos or something, but I never finished it. I also wrote a Java raytracer for a Java programming task at school. The Java raytracer supports boolean objects (combines two objects with boolean operators). It supports the functions "A*B" (A and B) and subtraction ("A*'B" = A and not B). The boolean object can of course use boolean objects as source objects.
- Geir Bjerke (neon/spetsnaz), email@example.com