Cool! If you've got that structure, getting that to a regular bitmap will be a piece of cake. Check out
Get_Frame_Bitmap in frame.cpp within 4DO's version of the FreeDO core.
The "clut"s are color lookup tables per line. Additionally, sometimes images will use the highest, 16th bit to use a color from the "fixed" clut. The two games I know of that do this are The Horde and Wing Commander III.
Code: Select all
VDLFrame* framePtr = sourceFrame;
for (int line = 0; line < copyHeight; line++)
{
VDLLine* linePtr = &framePtr->lines[line];
short* srcPtr = (short*)linePtr;
bool allowFixedClut = (linePtr->xOUTCONTROLL & 0x2000000) > 0;
for (int pix = 0; pix < copyWidth; pix++)
{
byte bPart = 0;
byte gPart = 0;
byte rPart = 0;
if (*srcPtr == 0)
{
bPart = (byte)(linePtr->xBACKGROUND & 0x1F);
gPart = (byte)((linePtr->xBACKGROUND >> 5) & 0x1F);
rPart = (byte)((linePtr->xBACKGROUND >> 10) & 0x1F);
}
else if (allowFixedClut && (*srcPtr & 0x8000) > 0)
{
bPart = FIXED_CLUTB[(*srcPtr) & 0x1F];
gPart = FIXED_CLUTG[((*srcPtr) >> 5) & 0x1F];
rPart = FIXED_CLUTR[(*srcPtr) >> 10 & 0x1F];
}
else
{
bPart = (byte)(linePtr->xCLUTB[(*srcPtr) & 0x1F]);
gPart = linePtr->xCLUTG[((*srcPtr) >> 5) & 0x1F];
rPart = linePtr->xCLUTR[(*srcPtr) >> 10 & 0x1F];
}
*destPtr++ = bPart;
*destPtr++ = gPart;
*destPtr++ = rPart;
srcPtr++;
}
}
In that code sample I've removed the code that does the autocropping in 4DO to simplify things.