Porting FreeDO to OS X

General forum for 4DO
darvin
Posts: 4
Joined: Tue Jun 12, 2012 6:04 pm

Porting FreeDO to OS X

Postby darvin » Tue Jun 12, 2012 6:09 pm

I'm porting FreeDO to OS X (in terms of OpenEmu project) https://github.com/darvin/OpenEmu/tree/freedo-core

Status 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
Johnny
Site Admin
Posts: 119
Joined: Thu Oct 27, 2011 1:50 pm

Re: Porting FreeDO to OS X

Postby Johnny » Wed Jun 13, 2012 12:11 am

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.
darvin
Posts: 4
Joined: Tue Jun 12, 2012 6:04 pm

Re: Porting FreeDO to OS X

Postby darvin » Wed Jun 13, 2012 1:52 am

Thanks!
darvin
Posts: 4
Joined: Tue Jun 12, 2012 6:04 pm

Re: Porting FreeDO to OS X

Postby darvin » Wed Jun 13, 2012 2:19 am

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?
darvin
Posts: 4
Joined: Tue Jun 12, 2012 6:04 pm

Re: Porting FreeDO to OS X

Postby darvin » Wed Jun 13, 2012 4:02 am

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
Johnny
Site Admin
Posts: 119
Joined: Thu Oct 27, 2011 1:50 pm

Re: Porting FreeDO to OS X

Postby Johnny » Wed Jun 13, 2012 5:52 am

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.

Return to “General Forum”

Who is online

Users browsing this forum: No registered users and 51 guests