I've spent the past few days exploring some early CGA, EGA and VGA programming. The stuff I missed out on, since I didn't start programming graphics on PC until late in the VGA era.
Up to now, I only knew CGA and EGA from the games I've played. And although I've done some VGA, I had never used the legendary mode X until now.

Anyway, I wrote a blog about some of my findings, also includes some links to useful documents if anyone wants to try for themselves:
http://scalibq.wordpress.com/2011/11/23/just-keeping-it-real-old-skool-style/
Posted on 2011-11-24 02:41:11 by Scali
Here's a quick preview:
http://www.youtube.com/watch?v=kto_SgMma7w
Rotating cube with flatshading in EGA mode.
Posted on 2011-11-27 19:00:47 by Scali
And here are some binaries: http://bohemiq.scali.eu.org/OLDSKOOL.zip
They are 16-bit DOS binaries, compiled for 8088 with no FPU.
They should work in Dosbox (although you might have to increase the cycle count to get them running nicely. For some reason they run fine from the Turbo C++ IDE, but much slower when running standalone).
Posted on 2011-11-28 05:50:43 by Scali
Part 2 of my blog is up:
http://scalibq.wordpress.com/2011/11/29/just-keeping-it-real-part-2/

This time I wrap up the CGA/EGA/VGA stuff, and start on the Amiga.
Part 3 will cover actual polygons being rendered with Amiga hardware.
Posted on 2011-11-29 12:53:26 by Scali
First attempt at a hardware-rendered polygon on Amiga was horrible:
http://www.youtube.com/watch?v=ArriSvIwaS4
All sorts of filling errors, because the boundary lines were not plotted accurately enough.

After a lot of tweaking I arrived at this, seems okay now:
http://www.youtube.com/watch?v=3Qb5mdGkt-o
Posted on 2011-12-01 10:45:55 by Scali
man ur crazy, digging around in the dirt when u know they dont let us near the iron anymore! but i applaud ur lunacy!
On another topic, did u ever get around to documenting ur model file format? I'm currently writing a maya export plugin and I could use a breath of fresh air!
Posted on 2011-12-02 02:27:45 by Homer

man ur crazy, digging around in the dirt when u know they dont let us near the iron anymore! but i applaud ur lunacy!


I suppose I didn't do enough of that as a child :)


On another topic, did u ever get around to documenting ur model file format? I'm currently writing a maya export plugin and I could use a breath of fresh air!


Yes, there is a README.txt included with the BHM stuff on sourceforge, which describes the different chunks that are used in the format:
http://bhmfileformat.svn.sourceforge.net/viewvc/bhmfileformat/trunk/BHM3DSample/README.txt?revision=54&view=markup

The animated claw model is also included in .bhm format, so you could use that as a reference.
Aside from that, you can look at the code of the included 3dsmax exporter to see how the file is built up when exporting it... and of course the sample OpenGL application to see how the file is being imported.

A Maya plugin would be a nice addition. So I am happy to support the development, and if possible, I would like to include it in the project when it is done.
Posted on 2011-12-02 04:48:06 by Scali
Now I can create my own 3D graphic rendering system. Its been 5 years Im studying it. But never understand it, even with help lots of people. Im so dumb, and I always agitated as ussual. But cant help, that is my learning style. In the end, I understand everything. Always what I need to know.
Posted on 2011-12-03 04:40:25 by Farabi
I'm getting there now:
http://www.youtube.com/watch?v=lhV4rJi54Mo

Polygons are rendering, to multiple bitplanes (and yay, it's a real convex poly renderer, not just a triangle renderer). Rotation and perspective projection applied as well.
The fun part is that it's 99% blitter code so far. Truly hardware-accelerated.

I just need to add some finishing touches, such as double-buffering, backface culling, and perhaps flatshading. Oh, and I need to make a full cube out of it, not just 2 planes :)

Edit: deleted the old video. Updated with a new video with double-buffering.
Posted on 2011-12-03 18:52:59 by Scali
Not to hijack this thread, but I have to say, I'm incredibly impressed by your musical abilities.  Your Randy Rhodes Tribute was awesome and I love your guitar sound 8)
Posted on 2011-12-03 21:05:02 by p1ranha

Not to hijack this thread, but I have to say, I'm incredibly impressed by your musical abilities.  Your Randy Rhodes Tribute was awesome and I love your guitar sound 8)


Are you talking to me or to scali? If it is to me, which guitar sound of me did you heard?
Posted on 2011-12-04 05:22:09 by Farabi

Not to hijack this thread, but I have to say, I'm incredibly impressed by your musical abilities.  Your Randy Rhodes Tribute was awesome and I love your guitar sound 8)


Thanks!
Posted on 2011-12-04 07:28:23 by Scali
Blog part 3 is now up:
http://scalibq.wordpress.com/2011/12/04/just-keeping-it-real-part-3/
Posted on 2011-12-04 10:20:58 by Scali
Anyway, with only 256-color, a nice photograph of a leaf looks real, but with our current tech of 24-bit colors, we unable to mimick such a thing. We are far too primitive than we should, compared to nature. We had not understand yet how did something we see flat on our eyes but in fact is a diversall.

Anyway scali, that was an amazing demo.



O scali, youre a master of graphic arts. AMAZING.
Posted on 2011-12-05 00:17:30 by Farabi
Thanks (but let's not get carried away here :) ).
And by the way, I may look into colour reduction for images soon... I've had this idea for years, but never bothered to implement it (much like the oldskool routines here).

Anyway, I have refined my VGA poly routine somewhat:
http://www.youtube.com/watch?v=WTezSDP95Ps

The first version could only handle triangles. I have now extended it to a proper polygon routine, which can handle convex polygons with any amount of vertices (just as the Amiga routine). This was an interesting problem... I might explain a bit more about it in the next blog entry. It seems that it is a bit of a 'forgotten art', since modern GPUs and modeling software works exclusively with triangles. I myself used to just write triangle rasterizers as well. However, in this specific case, being able to render other types of n-gons allows you to exploit the extra fillrate in mode X a lot better.

I have also improved the palette somewhat, to make the shading come out better.
And I found a remarkable amount of small bugs... Because as you know: working code is not bugfree code. There were some bugs in how the lighting and backface culling were performed.

I still need to backport this new polygon code to the CGA and EGA versions... And I still need to fix some final bugs in the Amiga version (and I want to give it the same blue-ish palette and rotations, so that it will look as similar to the VGA version as possible).
And I may look into porting my old 486 DirectDraw renderer back to DOS, so that it will work in dosbox. I still have it on my server: http://bohemiq.scali.eu.org/486compo.exe
However, it doesn't work anymore, since 320x200 videomodes are no longer supported.
If I port the code back to a DOS extender environment, it will work once again.
It is one generation newer than this routine, basically: instead of flatshading and cubes, you get texture mapping and donuts.
Posted on 2011-12-12 15:57:26 by Scali
Right... Another update.
I have backported the poly routine to CGA and EGA as well... Didn't bother to put up YouTube movies of them, but the binaries are updated here:
http://bohemiq.scali.eu.org/OLDSKOOL.zip

There is a bug in dosbox which makes the EGA version look worse than it really is. The palette in dosbox is broken, and has only 16 unique colours, which are repeated 4 times for the total 64-colour EGA palette. The result is that instead of 11 shades of blue, you only get about 4. I've made a simple fix for the dosbox code, but I haven't been able to build a version that can make screenshots or videos, so I guess I'll have to wait for the next release of dosbox.

I have also found the bug in my Amiga code, and I could finish the cube there as well.
It now looks pretty much the same as the VGA one, just slightly higher resolution (it's PAL, so 320x256):
http://www.youtube.com/watch?v=8U4ea0WKAhA

Anyway, I've also backported my old 486 donut to DOS. I used Japheth's HX DOS extender for that: http://www.japheth.de/HX.html
It supports DirectDraw emulation, but I didn't use that. My old build uses a lot of old Visual C runtime DLLs, and I couldn't get it to work as-is. When I tried to rebuild the code with static libs, I noticed that ddraw.lib isn't part of the DirectX SDK anymore.
So I figured I might as well rewrite the code for real DOS with direct VGA code.
And now it works once again, in dosbox:
http://www.youtube.com/watch?v=xE9iifKXvY4

You can download the DOS version here: http://bohemiq.scali.eu.org/486compo.zip
Posted on 2011-12-13 12:54:51 by Scali
Part 4 is now up:
http://scalibq.wordpress.com/2011/12/13/just-keeping-it-real-part-4/
Posted on 2011-12-13 17:24:22 by Scali
Another update, this time from the magical world of EGA, and why you cannot use all 64 palette colours in 320x200 (and how to hack around that):
http://scalibq.wordpress.com/2011/12/17/just-keeping-it-real-part-4-5/
Posted on 2011-12-17 13:53:09 by Scali
And another update... which follows from the earlier one about how the VGA palette can be used in the 16-colour EGA mode:
http://scalibq.wordpress.com/2011/12/21/just-keeping-it-real-part-4-6/

As it turns out, THIS is the secret to F29 Retaliator and Crystal Dream I/II's mega performance.
Posted on 2011-12-21 12:51:30 by Scali
And another update... exploring a few ways to make the polygon filler subpixel-correct:
http://scalibq.wordpress.com/2011/12/28/just-keeping-it-real-part-5/
Conclusion is that the 486-renderer had the most efficient approach anyway, even for more low-end machines. Just a 16.16 fixedpoint iterator is clean and efficient. So much for the Bresenham experiment.
Also an experiment on the Amiga's hardware blitter... It seems that it *might* be possible to get it subpixel-corrected as well, but the proof-of-concept is not 100% yet.
Posted on 2011-12-28 17:15:53 by Scali