Fascinating 256 colors VGA
The paint program I used most often in 1993 was Microsoft Paint, bundled with Windows 3.11. Oh, these ugly 16 colors. At least Paint came with easy to use dithering support, which I used extensively in my recreation of Schloss Moritzburg near Dresden, based on a photo in a calendar I found hanging in my parents living room. But I knew there was more potential hidden in the machine I was poking at, and I wanted to use the 256 colors VGA palette I could see in games and so easily access in Q-Basic. But how? I had no access to Deluxe Paint or GrafX2, didn't even knew they existed.
Coding BASIC was the only way I knew. So I started writing my own VGA paint program, fixed to 320 by 200 pixels, but finally unleashing the exciting potential to use 256 colors the same time. You could use the mouse to select some basic tools from an icon toolbar at the top of the screen, and draw at the bottom. Only basic tools were supported, mostly drawing pixels, rectangles, lines and circles. The toolbar could be hidden with a key press. There was a color selection bar directly below the toolbar, but no way to change the default VGA palette. Files were stored and loaded from raw 64,000 bytes memory dumps (320 by 200 pixels, 1 byte each). I always wanted to use GIF but had no idea how I could create files in this format. Some years later I mastered BMP and PCX, even invented my own run-length encoded »VPP« and »VPA« icon library file formats, but these formats did not made it into that first paint program.
I stopped coding and using my VGA painter when I discovered Autodesk Animator 1.0 and used it as a paint program. To that point, I remember having a simple tool to lighten and darken pixels, but no other tools to manipulate existing pixels of an image. The most complex tool was a fill bucket. I knew the feature from Windows' Paint as well as BASIC's
PAINT command, which allowed to fill an irregular region with a color. I had to rewrite this because my PowerBASIC had no build in support for the 256 colors VGA mode, and I had no idea how the original command worked. I tried different things including an extremely slow recursive approach that hit BASIC's stack boundaries very fast, and resulted in interesting incomplete patterns.
And so this story ends before it really started. I never drew anything meaningful, at least nothing that lasted. I remember being fascinated by pixel artists that managed to draw lifelike chrome reflections, tried that for myself (with chrome elements from a washing machine) and failed. The only images from that days that made it into my archive were drawn, you may have guessed it, with Windows Paint and Autodesk Animator 1.0.
VPA-Paint and my VPA icon archive file format (1995)
VPA is short for »VGA picture archive« and is a very simple file format I came up with to store sets of 256 color icons. I still found the VPA-Paint editor for these icon libraries in my archives, along with two sample libraries, one with mouse cursors and the other containing the icons for the editor itself. The file format starts with a three bytes header: the total number of icons in the archive as well as the width and height of each icon, all values ranging from 0 to 255. After that three bytes header the icons followed as raw data, 1 byte per pixel in the default VGA palette. And that's it. No compression, not even palette information was stored. The byte ranges would, technically, allow for huge image archives ranging up to 16 megabytes in total. However, there was a much lower limitation. When using one of these icon archives in a BASIC program I loaded the whole file into a string. The individual icons in the archive could then be referenced by number and extracted with simple and sufficiently fast
MID$ string manipulations. The downside of this simple aproach was that the maximum string length in a PowerBASIC program was 32 kilobytes, set via configuration or a
$STRING 32 compiler switch at the start of the program. This means an archive of 16 by 16 pixel icons was maxed-out at 127 icons, and a 32 by 32 pixel archive could at most contain 31 icons. I guess it was mostly because of the missing palette that I found my own file format to limited and did not used it further.
My run-length encoded VPP file format
My VPP file format, short for »VGA packed picture«, is an other code experiment that's heavily bound to the VGA graphics mode 13 with 320 by 200 pixels and 256 colors, and therefore very limited. Again, the file starts with a three bytes header, this time a 16 bit width (with the high byte first) and an 8 bit height. Again, I was not thinking about the useless zero and simply used the values as they are, which means the maximum image size in this file format is 65.535 by 255 pixels. Again, there is nothing else, no palette, not even an end-of-file marker. Images either used the default VGA palette or a generated or even animated palette, depending on the program where the image was used in. The data bytes are interpreted as follows:
- All values from 0 to 254 are single pixels in that color.
- Value 255 directly followed by 0 is a single »escaped« pixel in color 255.
- Value 255 followed by a value other than 0 marks 3-byte blocks that encode sequences of identical pixels. The marker byte is followed by the length (1 to 255) and the actual color (0 to 255).
The encoder makes sure that only sequences of 4 or more identical pixels as well as sequences of two or more pixels of color 255 are run-length encoded, which means I just found an other optimization I missed when I came up with that file format specification 18 years ago: I could have used an offset of 1 for the byte encoding the length, allowing it to range to 256, possibly saving a few more bytes.
The compression ratio of my file format was a little bit better than PCX, which made me quite proud. (But when you realize PCX was originally build for a very specific 4-bit use case this is not so impressive any more.) However, because the format had very limited use outside of a few graphics demos I wrote, – you could not even open it with other software – I barely used it. The bigest use of a modified 4-bit variant of the same file format can be found in the real.fake release list I compiled in 1999.