The graphics side of things is very Open GL-ish, albeit with one fewer dimension! The matrices are 3x3, so technically it can do 3D, but none of the code is really set up for that.
Here's an example of a piece of code to draw a box:
Code: Select all
.glBegin(GL_POLYGON) .glTexCoord(0, 0) .glVertex(-40, -20) .glTexCoord(63, 0) .glReflect(GL_REFLECT_Y) ; +40, -20 .glTexCoord(63, 31) .glReflect(GL_REFLECT_BOTH) ; +40, +20 .glTexCoord(0, 31) .glReflect(GL_REFLECT_X) ; -40, +20 .glEnd()
The macro's beginning with a period are just for convenience when the arguments to the routines are immediate values. They can be rewritten using manual LDs and CALLs.
.glReflect() is an optimisation for symmetrical shapes, although I need to implement vertex lists before it becomes really useful.
Keyboard input is done using a slightly modified version (to allow it to work in an interrupt routine better) of the event-driven keyboard handler in the Programming Help section.
I have also been working on some code for a C-style printf routine (this is why it's becoming a generic library!). It's not yet finished, so not in the demo, but at the moment I have the raw code to produce decimal representations of 32-bit integer values and also arbitrary x.y fixed point values. I just can't work out the best way to put this in a format specifier! The best I can come up with is: "%03.6dw[24.8]" (a 32-bit 24.8 fixed point value, using at least 3 decimal digits for the integer part - left padded with zeros - and 6 digits in the fractional part).
You can download a zip file containing the current source and a pre-assembled binary. The source is written for TASM (why do I get the feeling I'm the only one still using this!), so good luck!
There is also an animated GIF (caution - almost half a megabyte).
The keys are:
Left/Right - rotate
2nd* + Left/Right/Up/Down - translate
Plus/Minus - scale
Enter - cycle drawing mode
Clear* - toggle texture mapping (affects polygons only)
Mode - exit
* In PindurTI, left shift is [2nd], right shift is [clear].