<skip if you're not interested in long boring stories>
I'm working on the intro cinematic for The Core of Light, and the most complex part of this turns out to be getting the data in properly and not writing the assembly code to display the images one after another. Part of it is in greyscale, parts in black and white, every frame needs some data to go with it (frame duration, colour depth, rain animation) and I want to compress my images to fit more in.
At first I tried to use the PHP script I wrote a while ago to convert a greyscale image to two b/w images that Brass can include, but the script turned out not to work for bitmaps that are not made with MS Paint using only the predefined black, white, light grey and dark grey. Sigh So I rewrote most of the script to make it work with 24 bits bitmaps and accept any image with four distinct colours (sorting them by brightness). This unfortunately took me the better part of an evening.
Next up I wrote a script to take a directory full of text files, take the frame settings that are in the text file and put them with an incbmp command for Brass of the relevant image(s) in an include file. So now I finally had an include file with more or less the right settings and all the b/w and greyscale images included that would automatically get generated when I compiled my project, and I wrote a little assembly program to display all the frames, and it worked and I was happy for a while...
But then I wanted to add the total number of frames at the beginning of the include file (so I'd know when to stop), and I realized that the script didn't know the number of frames untill it was done so I'd have to rewrite part of it to add a simple number. I didn't like that. I also wanted to implement compression algorithms and I realized that this would mean writing yet more PHP scripts. I decided that I had to stop connecting ugly hacks together and write a proper tool for this.
</skip if you're not interested in long boring stories>
The end of the story so far is that I'm now writing (or attempting to, I've had way too much interruptions today) a tool that uses an XML file to define a series of image conversions and how to put them into an include file as image data. I've decided to make it as versatile as possible so maybe others can benefit from it too, and so I don't run into more unexpected obstacles.
Basically it'll be a converter to produce .db hex statements from images like so many others, but with a few advantages: this works not only for b/w images but also for four level greyscale (and maybe 8 level later on) simply depending on how many distinct colours you use in your images, it converts all your images at once to one include file instead of one at a time, it reads normal bmp files (probably in all formats, and perhaps also other image formats depending on how easy it will be to implement in C# ), it's a nice command line tool that you can incorporate in your compile process (Latenite or otherwise), and it can be used for much more complex things than "just" including images.
This is the XML file I'm currently working with, to give you an idea of just how versatile this will be if I finish it:
Code: Select all
<?xml version="1.0" encoding="utf-8" ?>
<convertscheme>
<!--
The header node defines the header for the entire include file
Available node names:
text Copied literaly
number_of_images Includes the total number of images ( .db xx )
-->
<header>
<text>; Movie include for The Core of Light
; Copyright Smitemeister Software 2002-2006
</text>
<number_of_images />
</header>
<!--
Every image in the image sequence can be preceded by a header with settings
Use the next node to define the header in bytes or in bits
Available node names:
byte Defines a byte ( .db xx )
bit0 - bit7 Defines bits 0-7 of a byte ( .db (bit0 || bit1 || bit2) etc )
-->
<settings>
<byte>
<bit0>greyscale</bit0>
<bit1>rain</bit1>
</byte>
<byte>timer</byte>
</settings>
<!--
Next up is the actual sequence of images with their parameters
Available nodes:
image Parameter title can be used to add comments in the include
label Adds a label to this image in the include
compression Specify none, RLE, SRL ...
file Filename of image to be included
2 or 4 colours will be determined from the bitmap data but
you'll probably want to use a bit in the image header to specify
the number of colours if you use different colour depths in one
sequence, so the assembly routine can see what's what
all settings Use "yes" or "no" or "true" or "false" to set/reset bits, use
decimal numeric values 0-255 for bytes
-->
<images>
<image title="Test image one">
<label>img1</label>
<compression>none</compression>
<timer>50</timer>
<rain>yes</rain>
<greyscale>yes</greyscale>
<file>test.bmp</file>
</image>
<image title="Test image two">
<label>img2</label>
<compression>none</compression>
<timer>10</timer>
<rain>no</rain>
<greyscale>no</greyscale>
<file>test2.bmp</file>
</image>
</images>
</convertscheme>
Code: Select all
; Movie include for The Core of Light
; Copyright Smitemeister Software 2002-2006
; Number of images:
.db 2
So... would anyone be interested in using something like this? It should be useful for all kinds of image and sprite data.