Author Topic: Need some help with my libretro port  (Read 14950 times)

Offline barbudreadmon

  • Expert
  • *****
  • Posts: 282
  • Karma: +8/-0
  • lr-fbalpha developer
Re: Need some help with my libretro port
« Reply #45 on: June 01, 2015, 02:49:19 pm »
Going back to "BurnHighCol(r, g, b, 0)" turned the screen from yellow/blue/black to blue/black. Anything else ?

Offline Treble Winner

  • FBA Dev
  • ******
  • Posts: 1805
  • Karma: +104/-0
  • FB Alpha Team
    • http://www.barryharris.me.uk
Re: Need some help with my libretro port
« Reply #46 on: June 02, 2015, 05:47:36 am »
IIRC, it was one of those games that was a pain in the arse to get right with the changes to the M68K core.

Maybe play with the VBlank timing, or CPU interleave? It's pretty difficult to advise when we don't have access to an affected system.

Offline dink

  • Administrator
  • *****
  • Posts: 2624
  • Karma: +224/-0
  • feed the horse yumyum
Re: Need some help with my libretro port
« Reply #47 on: June 02, 2015, 09:40:20 am »
I kinda remember a problem with the new 68k core and Gradius 2: there was a simple case of the interrupt state not being saved in the savestate, causing the loading savestate to make the game crash to the "rom NG" screen.  Also remember iq_132 did some heavy changes to the loading routines on a lot of konami games to use the new BurnLoadRomExt() function - I can see this causing trouble if not implemented correctly.

best regards,
- dink

Offline iq_132

  • Administrator
  • *****
  • Posts: 3565
  • Karma: +374/-0
  • Just a lion with a sword
    • NeoSource
Re: Need some help with my libretro port
« Reply #48 on: June 02, 2015, 04:45:48 pm »
Something that may be causing a problem is the color conversion in KonamiBlendCopy which converts rom 32-bit to whatever. Just a possibility.


Offline barbudreadmon

  • Expert
  • *****
  • Posts: 282
  • Karma: +8/-0
  • lr-fbalpha developer
Re: Need some help with my libretro port
« Reply #49 on: June 07, 2015, 05:13:38 am »
It's pretty difficult to advise when we don't have access to an affected system.
Feel free to build/download retroarch/libretro-fba for your system if you have the time to give it some thought, all CPU/OS seems to be affected with this konami color issue.

Offline gamez fan

  • Expert
  • *****
  • Posts: 513
  • Karma: +13/-1
  • Arcade Addict
Re: Need some help with my libretro port
« Reply #50 on: June 08, 2015, 06:11:32 pm »
I run into the same issues sometimes when porting drivers across to FBL i never know if the palette code will be suitable for the xbox
sometimes i luck out and find a workaround but at the end of the day it's not the FBA dev's problem im not smart enough to recode
to palette handling to xbox standards myself BTW im not having a dig at anyone here just stating my Dev Level!!!

For example i should get this.........

Congo Bongo



But get this instead :D



Obviously the colours aren't mixing correctly somewhere along the line



Offline iq_132

  • Administrator
  • *****
  • Posts: 3565
  • Karma: +374/-0
  • Just a lion with a sword
    • NeoSource
Re: Need some help with my libretro port
« Reply #51 on: June 08, 2015, 06:39:14 pm »
Add this to your DrvDraw function at the top and let me know how it goes.

Code: [Select]
if (DrvRecalc) {
for (INT32 i = 0; i < 0x200; i++) {
DrvPalette[i] = BurnHighCol((Palette[i] >> 16) & 0xff, (Palette[i] >> 8) & 0xff, Palette[i] & 0xff, 0);
}

DrvRecalc = 0;
}


Offline gamez fan

  • Expert
  • *****
  • Posts: 513
  • Karma: +13/-1
  • Arcade Addict
Re: Need some help with my libretro port
« Reply #52 on: June 08, 2015, 06:56:59 pm »
Thanks alota IQ_132 That did the Trick all games in the zaxxon driver are displaying the correct colours in FBL now!!!!.
Maybe the same code or something similar would work  for the konami games in barbudreadmon's FBA Ports..???

might be worth a try in the Gradius 3 driver

Code: [Select]
static inline void DrvRecalcPalette()
{
UINT8 r,g,b;
UINT16 *p = (UINT16*)DrvPalRAM;
for (INT32 i = 0; i < 0x1000 / 2; i++) {
r = (BURN_ENDIAN_SWAP_INT16(p[i]) >> 10) & 0x1f;
g = (BURN_ENDIAN_SWAP_INT16(p[i]) >>  5) & 0x1f;
b = (BURN_ENDIAN_SWAP_INT16(p[i]) >>  0) & 0x1f;

r = (r << 3) | (r >> 2);
g = (g << 3) | (g >> 2);
b = (b << 3) | (b >> 2);

DrvPalette[i] = (r<<16)+(g<<8)+b;
}
}

static INT32 DrvDraw()
{
if (DrvRecalc) {
for (INT32 i = 0; i < 0x200; i++) {
DrvPalette[i] = BurnHighCol((Palette[i] >> 16) & 0xff, (Palette[i] >> 8) & 0xff, Palette[i] & 0xff, 0);
}

DrvRecalc = 0;
}

//if (DrvRecalc) {
//DrvRecalcPalette(); // Remove as the above code now handles this..???
//}

K052109Write(0x1d80,0x10);
K052109Write(0x1f00,0x32);

K052109UpdateScroll();

if (gradius3_priority == 0)
{
if (nSpriteEnable & 1) K052109RenderLayer(1, K052109_OPAQUE, 2);
if (nSpriteEnable & 2) K052109RenderLayer(2, 0, 4);
if (nSpriteEnable & 4) K052109RenderLayer(0, 0, 1);
}
else
{
if (nSpriteEnable & 1) K052109RenderLayer(0, K052109_OPAQUE, 1);
if (nSpriteEnable & 2) K052109RenderLayer(1, 0, 2);
if (nSpriteEnable & 4) K052109RenderLayer(2, 0, 4);
}

if (nBurnLayer & 8) K051960SpritesRender(-1, -1);

KonamiBlendCopy(DrvPalette);

return 0;
}


« Last Edit: June 08, 2015, 07:45:36 pm by iq_132 »

Offline iq_132

  • Administrator
  • *****
  • Posts: 3565
  • Karma: +374/-0
  • Just a lion with a sword
    • NeoSource
Re: Need some help with my libretro port
« Reply #53 on: June 08, 2015, 07:47:23 pm »
Thanks alota IQ_132 That did the Trick all games in the zaxxon driver are displaying the correct colours in FBL now!!!!.
Maybe the same code or something similar would work  for the konami games in barbudreadmon's FBA Ports..???

might be worth a try in the Gradius 3 driver

Code: [Select]
static inline void DrvRecalcPalette()
{
UINT8 r,g,b;
UINT16 *p = (UINT16*)DrvPalRAM;
for (INT32 i = 0; i < 0x1000 / 2; i++) {
r = (BURN_ENDIAN_SWAP_INT16(p[i]) >> 10) & 0x1f;
g = (BURN_ENDIAN_SWAP_INT16(p[i]) >>  5) & 0x1f;
b = (BURN_ENDIAN_SWAP_INT16(p[i]) >>  0) & 0x1f;

r = (r << 3) | (r >> 2);
g = (g << 3) | (g >> 2);
b = (b << 3) | (b >> 2);

DrvPalette[i] = (r<<16)+(g<<8)+b;
}
}

static INT32 DrvDraw()
{
if (DrvRecalc) {
for (INT32 i = 0; i < 0x200; i++) {
DrvPalette[i] = BurnHighCol((Palette[i] >> 16) & 0xff, (Palette[i] >> 8) & 0xff, Palette[i] & 0xff, 0);
}

DrvRecalc = 0;
}

//if (DrvRecalc) {
//DrvRecalcPalette(); // Remove as the above code now handles this..???
//}

K052109Write(0x1d80,0x10);
K052109Write(0x1f00,0x32);

K052109UpdateScroll();

if (gradius3_priority == 0)
{
if (nSpriteEnable & 1) K052109RenderLayer(1, K052109_OPAQUE, 2);
if (nSpriteEnable & 2) K052109RenderLayer(2, 0, 4);
if (nSpriteEnable & 4) K052109RenderLayer(0, 0, 1);
}
else
{
if (nSpriteEnable & 1) K052109RenderLayer(0, K052109_OPAQUE, 1);
if (nSpriteEnable & 2) K052109RenderLayer(1, 0, 2);
if (nSpriteEnable & 4) K052109RenderLayer(2, 0, 4);
}

if (nBurnLayer & 8) K051960SpritesRender(-1, -1);

KonamiBlendCopy(DrvPalette);

return 0;
}




Probably not. The Konami games are a unique case in FBA.


Offline saitoh00

  • Newbies
  • *
  • Posts: 5
  • Karma: +0/-1
Re: Need some help with my libretro port
« Reply #54 on: June 11, 2015, 02:35:44 am »
What could be the problem so that the colors appear differently? In the official version this problem does not occur in the emulator AFBA (android) either.

I wish this problem be corrected, I hope you keep trying to find where is hidden the bug in Konami games, as without their port would not be able to play on many platforms fba.

Offline barbudreadmon

  • Expert
  • *****
  • Posts: 282
  • Karma: +8/-0
  • lr-fbalpha developer
Re: Need some help with my libretro port
« Reply #55 on: June 20, 2015, 03:38:12 am »
After trying a lot of (complex) stuff like reimplementing old KonamiBlendCopy from the old fba-libretro repository, without success, i tried simply changing :
Code: [Select]
PutPix(pBurnDraw + (i * nBurnBpp), BurnHighCol(bmp[i]>>16, (bmp[i]>>8)&0xff, bmp[i]&0xff, 0));to
Code: [Select]
PutPix(pBurnDraw + (i * nBurnBpp), BurnHighCol(bmp[i]>>16, bmp[i]>>8, bmp[i], 0));in KonamiBlendCopy. For whatever reason, it seems it did the trick. Since i'm still kinda a noob at coding C/C++ and emulators, anyone can explain what those "&0xff" are for ?

Offline saitoh00

  • Newbies
  • *
  • Posts: 5
  • Karma: +0/-1
Re: Need some help with my libretro port
« Reply #56 on: June 20, 2015, 04:01:20 am »
Congratulations!!! I'm so glad you were able to solve the problem, when I have some time I get to test your revision.

Offline iq_132

  • Administrator
  • *****
  • Posts: 3565
  • Karma: +374/-0
  • Just a lion with a sword
    • NeoSource
Re: Need some help with my libretro port
« Reply #57 on: June 20, 2015, 07:46:11 am »
After trying a lot of (complex) stuff like reimplementing old KonamiBlendCopy from the old fba-libretro repository, without success, i tried simply changing :
Code: [Select]
PutPix(pBurnDraw + (i * nBurnBpp), BurnHighCol(bmp[i]>>16, (bmp[i]>>8)&0xff, bmp[i]&0xff, 0));to
Code: [Select]
PutPix(pBurnDraw + (i * nBurnBpp), BurnHighCol(bmp[i]>>16, bmp[i]>>8, bmp[i], 0));in KonamiBlendCopy. For whatever reason, it seems it did the trick. Since i'm still kinda a noob at coding C/C++ and emulators, anyone can explain what those "&0xff" are for ?
Each color component in a palette entry is 1 byte in size. An UINT32 (unsigned int) is 4 bytes in size. & 0xff chops off additional data. It's strange, when I added the konami code that mingw I was using had an odd bug that if you didn't chop the data, it would cause a crash. You'll see similar setups in other drivers.


Offline barbudreadmon

  • Expert
  • *****
  • Posts: 282
  • Karma: +8/-0
  • lr-fbalpha developer
Re: Need some help with my libretro port
« Reply #58 on: June 21, 2015, 05:16:05 am »
I tried to replace your line with :
Code: [Select]
PutPix(pBurnDraw + (i * nBurnBpp), BurnHighCol(bmp[i]>>16,(int)((bmp[i]>>8)&0xff),(int)(bmp[i]&0xff), 0));It works too.
Seems to me like gcc don't consider your r/g/b as INT32 after you chopped data, and that's the real issue.
« Last Edit: June 21, 2015, 05:18:20 am by barbudreadmon »

Offline barbudreadmon

  • Expert
  • *****
  • Posts: 282
  • Karma: +8/-0
  • lr-fbalpha developer
Re: Need some help with my libretro port
« Reply #59 on: June 21, 2015, 06:30:00 am »
Ok, i did a few changes in libretro-fba, i reverted KonamiBlendCopy to your original function and did the casting into int in the code handling the BurnHighCol function in libretro-fba, seems cleaner now and it should avoid future issues of the same kind.

Thanks for all your help, now i'll try to handle the next important issue (irem games displaying black screen with no sound on arm, feel free to suggest anything that could come to mind about it).