Page 1 of 1
Porting FreeDO to OS X
Posted: Tue Jun 12, 2012 6:09 pm
by darvin
I'm porting FreeDO to OS X (in terms of OpenEmu project)
https://github.com/darvin/OpenEmu/tree/freedo-coreStatus is all working, except of video output.
I need some assistance in converting of this structure from FreeDO core:
Code: Select all
struct VDLLine
//VDLP Line - one VDLP line per patent
{
unsigned short line[320*4];//,line2[320*2*16];
unsigned char xCLUTB[32];
unsigned char xCLUTG[32];
unsigned char xCLUTR[32];
unsigned int xOUTCONTROLL;
unsigned int xCLUTDMA;
unsigned int xBACKGROUND;
};
struct VDLFrame
{
VDLLine lines[240*4];
unsigned int srcw,srch;
};
to some simple video buffer
Re: Porting FreeDO to OS X
Posted: Wed Jun 13, 2012 12:11 am
by Johnny
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.
Re: Porting FreeDO to OS X
Posted: Wed Jun 13, 2012 1:52 am
by darvin
Thanks!
Re: Porting FreeDO to OS X
Posted: Wed Jun 13, 2012 2:19 am
by darvin
Yeah, it works! I got pretty crappy image, but its working! Thanks!
what is native resolution (without any scaling) of 3do console? how much colors?
Re: Porting FreeDO to OS X
Posted: Wed Jun 13, 2012 4:02 am
by darvin
Also turns out my input implementation not really works.
Is GetPbusLength should return the same value each time if pbus changed, and 0 if pbus wasn't change? what is that value?
is int16_t pbus[8] proper size for pbus?
my current implementation looks like (HEX):
48008200800080008000800080008000 - button left on device 0 pressed
48008100800080008000800080008000 - button A on device 0 pressed
Re: Porting FreeDO to OS X
Posted: Wed Jun 13, 2012 5:52 am
by Johnny
PBUSLength can be the same every time. I don't recall the specifics, though. JohnnyInputPlugin.cs from 4DO would point you in the right direction.