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

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #120 on: October 29, 2016, 12:36:49 PM »
My bad, i assumed our dipswitch parser was wrong because i saw "Service Mode" as a dipswitch value for "Rematches" in armwrest, and a lot of blank/duplicate values, but after launching fba standalone, i notice the same values for the same dipswitch in armwrest, so it seems our parser is actually ok. Is there an issue in armwrest dipswitches or are those normal values ?

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #121 on: November 01, 2016, 09:10:08 AM »
Hello,

Mouse controls don't make much sense to me, i don't understand why we have things like "mouse x-axis", "mouse y-axis", "mouse button 1" and "mouse button 2" for player1 when we use "p2 x-axis", "p2 y-axis", "p2 fire 1" and "p2 fire 2" for player2 on the same game, or why sometimes both players will use the same "mouse x-axis", "mouse y-axis", "mouse button 1" and "mouse button 2" controls, it makes things horrible when i'm trying to handle inputs in fbalpha-libretro. So i did the following patch :
http://pastebin.com/raw/VH4B899H
There are also fixes for duplicate szInfo in quartet and ponpoko (i don't really understand how you deal with it in fba standalone, but duplicate szInfo looks like a bad thing to me, and that won't work well in fbalpha-libretro)

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: Need some help with my libretro port
« Reply #122 on: November 01, 2016, 01:05:05 PM »
My bad, i assumed our dipswitch parser was wrong because i saw "Service Mode" as a dipswitch value for "Rematches" in armwrest, and a lot of blank/duplicate values, but after launching fba standalone, i notice the same values for the same dipswitch in armwrest, so it seems our parser is actually ok. Is there an issue in armwrest dipswitches or are those normal values ?

its actually a bug in the driver, the dip count is wrong for quite a few things d_punchout.cpp, here's a fix: http://pastebin.com/2vWuzmDX

I completely agree with you re: the mouse controls, I think they should be pX x/y-axis instead of mouse x/y-axis, but another dev disagrees with this unfortunately.

re ponpoko and quartet: looks like an oversight, oops! thanks for the heads up.  also, I found that the entry above it has the same issue (Mjleague).

best regards,
- dink

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #123 on: November 01, 2016, 01:53:48 PM »
I completely agree with you re: the mouse controls, I think they should be pX x/y-axis instead of mouse x/y-axis, but another dev disagrees with this unfortunately.
After trying games like loffire and lghost on standalone, i can understand part of it : having both joystick controls on the same mouse make the first boot easier.

I'll just keep in mind that i have to check and replace those mouse controls for every release ;).

Thanks again !

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #124 on: November 06, 2016, 08:47:08 AM »
I have an issue with donpachi on arm (and not on x86) : game segfault after i "insert coin". That did not happen with fba 0.2.97.37

My investigation so far :
- i backported my current libretro's code to fba 0.2.97.37, the game won't crash, so this seems to come from fba codebase.
- i checked for "char" variable in m68k, z80, nmk112 ans msm6295, i didn't find any that should cause an issue.
- i tried bprinting a few things in nmk112, and i got really weird results ! Just adding a few bprint in "NMK112_okibank_write" (nothing else) actually fixed the "insert coin" issue, but the game will then segfault when i "press start", as if adding those bprint actually delayed something which would not be properly initialized without those bprint.
- i tried bprinting "(sekAddress / 2) & 0x1f" and "wordValue & 0xff" in d_donpachi.cpp's "donpachiWriteWord", i got different values on arm/x86 after pressing start (i decided to keep bprint in NMK112_okibank_write for now, makes comparing output easier and both issues must be related anyway), which means musashi returns different results for both arch if i understood well, it sounded like a good start for debugging
- i ported fba 0.2.97.37's musashi to current fba (i had to disable megadrive and define bBurnUseASMCPUEmulation to do that), the game still crash.
- i played around with this bBurnUseASMCPUEmulation value (seemed to me like you changed its default value, and i thought it was kinda related to some x86 asm code), the game still crash.

Any of this ring a bell ? I'm kinda at a loss right now :/

Edit : i also tried enabling/disabling FASTCALL, and playing around with CFLAGS's "-OX"
« Last Edit: November 06, 2016, 08:50:10 AM by barbudreadmon »

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Need some help with my libretro port
« Reply #125 on: November 06, 2016, 09:34:19 AM »
I have an issue with donpachi on arm (and not on x86) : game segfault after i "insert coin". That did not happen with fba 0.2.97.37

My investigation so far :
- i backported my current libretro's code to fba 0.2.97.37, the game won't crash, so this seems to come from fba codebase.
- i checked for "char" variable in m68k, z80, nmk112 ans msm6295, i didn't find any that should cause an issue.
- i tried bprinting a few things in nmk112, and i got really weird results ! Just adding a few bprint in "NMK112_okibank_write" (nothing else) actually fixed the "insert coin" issue, but the game will then segfault when i "press start", as if adding those bprint actually delayed something which would not be properly initialized without those bprint.
- i tried bprinting "(sekAddress / 2) & 0x1f" and "wordValue & 0xff" in d_donpachi.cpp's "donpachiWriteWord", i got different values on arm/x86 after pressing start (i decided to keep bprint in NMK112_okibank_write for now, makes comparing output easier and both issues must be related anyway), which means musashi returns different results for both arch if i understood well, it sounded like a good start for debugging
- i ported fba 0.2.97.37's musashi to current fba (i had to disable megadrive and define bBurnUseASMCPUEmulation to do that), the game still crash.
- i played around with this bBurnUseASMCPUEmulation value (seemed to me like you changed its default value, and i thought it was kinda related to some x86 asm code), the game still crash.

Any of this ring a bell ? I'm kinda at a loss right now :/

Edit : i also tried enabling/disabling FASTCALL, and playing around with CFLAGS's "-OX"
I added an updated Bankswitching system to the MSM6295. I'm going to guess that the problem lies there. :(


Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #126 on: November 06, 2016, 12:53:08 PM »
I added an updated Bankswitching system to the MSM6295. I'm going to guess that the problem lies there. :(
I confirm, speedspn which uses the same msm6295 have the same issue.

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #127 on: November 06, 2016, 01:39:10 PM »
I enabled debug and modfied this :
Code: [Select]
static inline UINT8 MSM6295ReadData(INT32 nChip, UINT32 nAddress)
{
bprintf(PRINT_ERROR, _T("MSM6295ReadData begin\n"));
nAddress &= 0x3ffff;

if (pBankPointer[nChip][(nAddress >> 8)]) {
bprintf(PRINT_ERROR, _T("MSM6295ReadData 1 : %d\n"), pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)]);
return pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)];
} else {
bprintf(PRINT_ERROR, _T("MSM6295ReadData 2\n"));
return 0;
}
bprintf(PRINT_ERROR, _T("MSM6295ReadData end\n"));
}
it crash after "MSM6295ReadData begin" so i guess
Code: [Select]
pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)]is undefined or something ?

Edit : i confirm always returning 0 solve this issue, except i have no sound :/
« Last Edit: November 06, 2016, 01:43:01 PM by barbudreadmon »

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Need some help with my libretro port
« Reply #128 on: November 06, 2016, 02:01:51 PM »

try nAddress / 256 instead of >> 8


Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #129 on: November 06, 2016, 02:15:08 PM »
Same issue, i think
Code: [Select]
pBankPointer[nChip][(nAddress >> 8)] exists, it is
Code: [Select]
pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)] that doesn't seem to exist

Offline iq_132

  • Administrator
  • *****
  • Posts: 3728
  • Karma: +411/-0
  • Definitely not Dink!
    • NeoSource
Re: Need some help with my libretro port
« Reply #130 on: November 06, 2016, 04:07:38 PM »
Same issue, i think
Code: [Select]
pBankPointer[nChip][(nAddress >> 8)] exists, it is
Code: [Select]
pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)] that doesn't seem to exist

I think the problem lies here:

   memset (pBankPointer[nChip], 0, 0x40000/0x100);

try:

   memset (pBankPointer[nChip], 0, (0x40000/0x100) * sizeof(UINT8*));


Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #131 on: November 06, 2016, 04:24:39 PM »
Still no luck :/
I'll try to investigate more tomorrow, perhaps some more output with bprint would help figure out what's happening.

Offline dink

  • Administrator
  • *****
  • Posts: 5014
  • Karma: +449/-1
  • pie? I nearly bought one!
Re: Need some help with my libretro port
« Reply #132 on: November 06, 2016, 07:24:15 PM »
Can you analyze the crash and find which code is causing it?  I know in windows we have DrMingw, which is an amazing tool for finding crash problems.  I'm sure there's something similar for arm, perhaps?

best regards,
- dink
« Last Edit: November 06, 2016, 07:25:31 PM by dink »

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #133 on: November 07, 2016, 09:00:46 AM »
i got the same result through gdb :
Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
0x7310656c in MSM6295ReadData (nAddress=<optimized out>, nChip=1)
    at src/burn/snd/msm6295.cpp:73
73 return pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)];

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1091
  • Karma: +59/-1
  • Helper
Re: Need some help with my libretro port
« Reply #134 on: November 07, 2016, 10:43:45 AM »
Better when built with -O0 :
Code: [Select]
0x729025c4 in MSM6295ReadData (nChip=1, nAddress=72)
    at src/burn/snd/msm6295.cpp:73
73 return pBankPointer[nChip][(nAddress >> 8)][(nAddress & 0xff)];