Page 1 of 1

Beasts and Bumpkins MFB files (unknown RLE compression)

Posted: Sun Mar 16, 2008 1:58 am
by Rheini
Need some help with these graphic files from an older 2D-game Beasts and Bumpkins.
It uses DirectDraw (if this helps somehow).
The files seem to contain static graphics as well as animations. Mix.dat and reflect.dat might be some sort of palette, but I'm not sure.

Re: Beasts and Bumpkins MFB files

Posted: Sun Mar 23, 2008 11:42 pm
by Rheini
Current status:

Code: Select all

char magic[3]; // "MFB"
char version[3]; // should be 101d (= 65h)
ushort width; // is the width of a single image
ushort height; // is the height of a single image
ushort uk3; // not used?
ushort uk4; // not used?
ushort flags; // bit 2 means compressed, 1 and 4 are unknown
ushort numImages; // number of images

if((flags & 2) == 0) // uncompressed data
{
	struct {
		struct {
			byte data[width];
		} lines[height] <optimize=false>;
	} images[numImages] <optimize=false>;
}
else // compressed data
{
	struct {
		uint size;
		byte data[size];
	} images[numImages]<optimize=false>;
}

Re: Beasts and Bumpkins MFB files

Posted: Tue Apr 01, 2008 8:46 pm
by Rheini
The compression used is something along the lines of RLE. One color in the palette will be the transparency, which will occur a lot.

Re: Beasts and Bumpkins MFB files

Posted: Tue Nov 10, 2009 7:05 pm
by Rheini
Mix.dat and reflect.dat are lookup tables for reflection etc.
The images use palettes stored in the main game executable.
Unfortunately I still don't know the RLE algorithm :(

Re: Beasts and Bumpkins MFB files (unknown RLE compression)

Posted: Sat Nov 14, 2009 3:44 pm
by GameZelda

Code: Select all

/**
 * Uncompress a Beast and Bumpkins RLE-encoded data block.
 *
 * [in] in: The input (compressed) data.
 * [in] inSize: The size of the input data.
 * [out] out: The output (uncompressed) data.
 * [out] outSize: The size of the output data.
 *
 * (For images, outSize = width * height).
 *
 * TODO: Add bounds checking.
 */
bool unRLE(const uint8_t *in, size_t inSize, uint8_t *out, size_t outSize)
{
    size_t inPos = 0, outPos = 0;
    uint8_t copyByte = in[0];

    while (outPos < outSize)
    {
        if (in[inPos] == copyByte)
        {
            uint8_t count = in[inPos + 1];
            inPos += 2;

            while (count--)
                out[outPos++] = copyByte;
        }
        else
        {
            out[outPos++] = in[inPos++];
        }
    }

    return true;
}
The palettes are in the resources section of the EXE.

Re: Beasts and Bumpkins MFB files (unknown RLE compression)

Posted: Sun Nov 15, 2009 3:28 pm
by Rheini
Woohoo thanks a lot!
Did you find it out by disassembling or just with the file?

Re: Beasts and Bumpkins MFB files (unknown RLE compression)

Posted: Tue Dec 29, 2009 4:14 pm
by Rheini
Works like a charm :)

Image