Files
Creatures File Formats
The following information was discovered by David Chess:
Here's
some stuff I've figured out about the formats of various files used in
the game.
This is just from poking around inside the files, and it
could easily be wrong;
don't go messing up an active game because you
trusted me!
Back up any files before you play with them, for instance.
This information will be mostly useless unless you're skilled at poking
around in binary files.
So if you're not, don't worry if it doesn't all
make sense!
Palettes
The
file PALETTE.DTA, in the Palettes directory under the main Creatures
directory,
is the palette that the numbers in the various game images
are to be displayed with.
It's just 768 bytes, three bytes for each of the 256 colors.
But if you want to use them as the palette in a BMP file in the obvious way, you need to take each triple of numbers, reverse it
(third byte first, first byte last), and multiply each byte of the result by four.
This seems to give a good picture, anyway.
If you replace this file with a different palette, you can recolor Albia;
see my general technical stuff page for a palette file that lets you play with Albia before Ted Turner got to it...
(There's another PALETTE.DTA in the Images directory, but as far as I've been able to tell so far it doesn't do anything.)
Sprites
Many
files with extension "SPR" are composite sprite files, and I'll
describe their format next.
Note that not all SPR files in Creatures
have this format!
The SPR files that are just single static logo-like
images, like GENE.SPR, aren't this kind of composite.
But things like
the .SPR files that store the various body-part images for a given norn
are composite SPR files.
A composite SPR file starts with a
two-byte value that says how many images there are in the file.
(The
value is stored least-significant-byte-first, like all Intel values;
that's true of all multi-byte values I'll mention here.)
Then there's
one index entry for each of the included images, then there's the data
for each of the images.
Each index entry for an image starts with a
four-byte number that gives the offset in the file of the start of the
image data;
Then there's a two-byte value that gives the width of the
image,
Then a two-byte value giving the height of the image.
The
data for the images is one byte per pixel, to be used with the palette
in PALETTE.DTA as described above.
The size of the data for an image is
just the width times the height, as listed in the index entry for that
image.
That's all.
----------
For
the next couple of formats, let me define a data structure that I'll
call an "lstring" (some Pascal compilers call them that).
An lstring is
a one-byte length count, followed by that many bytes of data.
So a
zero-length lstring is just a 00 byte, the name "Fred" is a 04 byte
followed by the four ASCII characters "F", "r", "e", "d", and like
that.
Unlike C strings, lstrings aren't terminated by a zero (or by
anything else); you just use the length byte.
These are used in the photo albums, the graveyard, the register, and probably some other files I haven't looked at yet.
The Photo Albums
The
"nnnnnnnn.Photo Album" files hold the photo album for each registered
norn (see the Register format below for how to relate the nnnnnnnn to
the norn's name),
They have a format as follows:
First there's a two-byte value giving the number of photos in this album.
Then for each photo there's a data structure as follows:
An lstring giving the time and date the photo was taken,
A four-byte value giving the width of the image,
A four-byte value giving the height of the image,
A four-byte value whose function I don't know but it always seems to be equal to the width of the image,
The
image data itself (it seems to be two bytes shorter than it ought to
be, which I don't quite understand; I suspect I'm wrong about something
in here),
Then two more lstrings representing the two captions that each picture can have.
One last note: the image data in the Photo Album files seems to be
upside down with respect to the image data in the composite SPR files.
The
Photo Album files have images stored bottom-up, lowest line first,
whereas the SPR files have them top-down, highest line first.
Go
figure! My guess is that the two parts of the program were written by
different people.
The Graveyard
Stored in a file called "The Graveyard", has exactly the same format as a Photo Album!
The time/date string stored with a picture gives both birth time/date and death time/date.
The first lstring after the image is the norn's name, and the second one after the image is the epitaph.
For every entry in "The Graveyard", there must also be an entry in the file "Album".
I think that the format of "Album" is:
One four-byte quantity giving the count of the number of Norns in the graveyard,
Then after that many four-byte quantities which can only be 1 or 0 (1 if there's a picture and 0 if not?),
Then many lstrings giving the names of the Norns in the graveyard.
The Register
Starts with (surprise, surprise) a two-byte value giving the number of entries in the file.
This is followed by one entry for each registered norn.
Each norn's entry consists of ten lstrings.
The first is the (usually eight-number) register code for the norn (used as the filename of Photo Album files, for instance).
The second is the norn's name.
The third and fourth are the register codes for the norn's father and mother (respectively).
The fifth is the norn's birthdate and time.
The
sixth is the norn's birthplace, although the files I've looked at
always just have the string "The birthplace" in this field.
The last four lstrings are the owner's name and address and stuff, from that part of the "Register Birth" applet.
The
register codes used in the Register and the filenames of Photo Album
files are, by the way, just the ASCII expansions of the norn's genetic
moniker spelled backwards.
So for instance Danielle's moniker is 7OVZ. 7OVZ backwards is ZVO7, and the ASCII expansion of that is 5a564f37.
And
sure enough that's exactly Danielle's register code as reflected in the
register, and her photo album is "5a564f37.Photo Album".
There
are some glitches in this having to do with norns that have two
different monikers due to having been multiply imported,
and with the
register bugs in Creatures 1.0.0, but this is the basic rule.