barbudreadmon / fbalpha-backup-dontuse-ty

Deprecated port of Final Burn Alpha to Libretro (v0.2.97.43).
61 stars 43 forks source link

Cheevos support #182

Closed leiradel closed 5 years ago

leiradel commented 6 years ago

Hi @barbudreadmon

I took a look in the source code and this core doesn't support achievements. Is it possible to implement the RETRO_ENVIRONMENT_SET_MEMORY_MAPS environment call, or the retro_get_memory_data/size functions?

salvadorc17 commented 6 years ago

So the question is whats wrong with old method, it was working fine, and did make it usable for the most important arcade system.

meleu commented 6 years ago

@salvadorc17 answer here.

barbudreadmon commented 6 years ago

In no-meminspector-log.txt i see :

Moved recent file 0 to front "mslugx" - 13 - 27 Registered 0 bytes at 0x00000000 Installed 0 bytes at 0x00000000

Does that mean the core is reporting a size of 0 with a buffer filled with 0 ? If so then either my conditions are wrong (which would be weird, that kind of condition is all over the code), or retro_get_memory_data/retro_get_memory_size are called before the game is initialized (which is done in retro_load_game) CPS1/CPS2 are also reporting a size of 0 with a buffer filled with 0 ?

andres-asm commented 6 years ago

It's called after load game but before the first retro_run, so maybe it's an empty buffer at frame 0?

meleu commented 6 years ago

@barbudreadmon

CPS1/CPS2 are also reporting a size of 0 with a buffer filled with 0 ?

I think yes. Check the log: nocrash-cps1-log.txt

EDIT: by the way, the Moved recent file 0 to front "mslugx" - 13 - 27 is just saying that this game was added to the recently loaded files menu. The 0 is because my "history" was empty.

leiradel commented 6 years ago

It's also called after retro_load_game but before retro_run in RALibretro.

andres-asm commented 6 years ago

Yes the API indicates it must be called before the first retro_run call

barbudreadmon commented 6 years ago

@fr500 even if the buffer is empty at frame 0, retro_get_memory_size should report a size of 0x00010000 if my nHardwareFlag == HARDWARE_SNK_NEOGEO condition is true.

leiradel commented 6 years ago

This is a problem for CPS1 and CPS2:

src/burner/libretro/libretro.cpp: In function 'void* retro_get_memory_data(unsigned int)':
src/burner/libretro/libretro.cpp:1847:24: warning: pointer of type 'void *' used in arithmetic [-Wpointer-arith]
    return (state_ptr + offset);
                        ^~~~~~

I'm testing Neo Geo now.

leiradel commented 6 years ago

nHardwareFlag has a bogus value of -2063532032 so it fails all the ifs:

Moved recent file 0 to front "mslug" - 13 - 27
retro_get_memory_size -2063532032
retro_get_memory_data -2063532032
retro_get_memory_size -2063532032
Registered       0 bytes at 0x00000000
Installed        0 bytes at 0x00000000
retro_get_memory_size -2063532032

The value in hexadecimal is 0x85010000. 0x85000000 doesn't correspond to any prefix in burn.h so BurnDrvGetHardwareCode is returning an invalid value in retro_get_memory_data/size.

barbudreadmon commented 6 years ago

Yeah, i noticed and was working on it, seems like some system actually needs something like (nHardwareCode & (HARDWARE_PUBLIC_MASK - HARDWARE_PREFIX_CARTRIDGE)) instead of (nHardwareCode & HARDWARE_PUBLIC_MASK), neogeo was one of them.

My last commit should fix both issues, i hope RA will work now.

leiradel commented 6 years ago

Also, The Punisher is returning HARDWARE_CAPCOM_CPS1_QSOUND, so maybe we need a mask of 0x7F000000?

salvadorc17 commented 6 years ago

Now i found cause of issue, memory data is added but never updated. So this method will not work because is not updating the reported ram. With the previous method it worked because the run functions was allowing that for each driver.

barbudreadmon commented 6 years ago

Ok, what about the new one ?

meleu commented 6 years ago

@barbudreadmon your last commit makes RALibretro "freeze" right after loading a game.

Here are the logs:

CPS1: cps1-freeze-log.txt

NeoGeo: neogeo-freeze-log.txt

leiradel commented 6 years ago

I'll only be able to test later today, but mainram_ptr is initialized to NULL at the top of burn_get_mainram_ptr_cb, and then memcpy(mainram_ptr, pba->Data, pba->nLen) is executed just below. This will cause a crash, or am I missing something?

Also, even if mainram_ptr points to a block of memory at least the size of pba->nLen, won't we get a copy of the System RAM, frozen in time at the instant memcpy is executed?

leiradel commented 6 years ago

He, I've just seen @meleu 's comment. Yeah, I believe it's the issue with mainram_ptr.

barbudreadmon commented 6 years ago

What about now ?

meleu commented 6 years ago

@barbudreadmon @leiradel

https://www.youtube.com/watch?v=MdN0NXgjsn8

EDIT: in other words, yes!! it's working fine now!!!

barbudreadmon commented 6 years ago

@meleu Even the previous achievements from mslugx work ?

meleu commented 6 years ago

didn't check trying to earn them. I only checked the addresses and they seem to be fine. will make more tests later.

meleu commented 6 years ago

@barbudreadmon good news: yeah, it's working as expected!! Huge thanks for that!

Look the latest fbalpha commit hash on the bottom left "signature": fbalpha-works

leiradel commented 6 years ago

@meleu everything is ok in RALibretro too, right?

meleu commented 6 years ago

@leiradel yep yep. RALibretro is running fine with fbalpha 8eabf37

barbudreadmon commented 6 years ago

@meleu @leiradel Nice, i'll make some changes to how size is handled this evening (i'll retrieve it from pba->nLen in burn_get_mainram_ptr_cb, it will make the code in retro_get_memory_size simpler).

leiradel commented 6 years ago

Awsome @barbudreadmon let us know when the changes are in so we can test again.

Should we keep this issue open as new drivers get support for achievements, or should we open one issue for each driver the community asks for achievements support?

barbudreadmon commented 6 years ago

Let me know if my changes broke something. I guess we can keep this issue open for future request.

barbudreadmon commented 6 years ago

Also removed the cast to UINT8 now that we don't need arithmetic anymore.

meleu commented 6 years ago

I'm going to make some tests now.

barbudreadmon commented 6 years ago

I did one last change, it doesn't seem to me like BurnAreaScan was needed again in retro_get_memory_data as long as it is called once in fba_init

meleu commented 6 years ago

@barbudreadmon I've launched a bunch of games, for Neo Geo, CPS1, CPS2 and CPS3.

Neo Geo, CPS-1 and CPS-2 are running 100% fine.

CPS-3 is fine but when I open the Memory Inspector RALibretro crashes. Here are the crash logs:

playing "Street Fighter III: 3rd Impact" and then open Memory Inspector: cps3-sfiii3-freeze-meminspector-log.txt

playing "JoJo's Bizarre Adventure" and then open Memory Inspector: cps3-jojoba-crash-meminspector-log.txt

barbudreadmon commented 6 years ago

CPS-3 is not implemented yet.

leiradel commented 6 years ago

I'll add CPS1 and 2 to the list of supported drivers

meleu commented 6 years ago

Alright then.

A curiosity: the memory size is the same for NeGeo, CPS1 and CPS2?

All of them show the same amount of RAM when opening the Memory Inspector (it says "aware of 65536 RAM locations").

barbudreadmon commented 6 years ago

A curiosity: the memory size is the same for NeGeo, CPS1 and CPS2?

Yes it is, their hardware is extremely similar.

CPS-3 will be 512k, and that's probably one of the biggest in fba, i'll add the support this week-end

meleu commented 6 years ago

@barbudreadmon is this serious?! e502e80

barbudreadmon commented 6 years ago

@meleu Why ? Is there something wrong with cps3 ?

leiradel commented 6 years ago

@barbudreadmon I think that @meleu is just excited about having CPS3 support, and not that he's dismissing the implementation. It's hard to communicate using a foreign language.

meleu commented 6 years ago

oh, sorry about the confusion. @leiradel is right, I'm excited! :sweat_smile:

Is that commit adding support for CPS-3?

barbudreadmon commented 6 years ago

@meleu it should, let me know if there is any issue

meleu commented 6 years ago

@barbudreadmon oh yeah!! Opened Memory Inspector while running "Street Fighter III: 3rd Impact" and everything seems to be working fine!

Ntemis commented 6 years ago

@barbudreadmon i know this is irrelevant somehow but i felled the urge to ask about Capcom ZN1/ZN2, Namco System 11/12 and Taito FX1, support possible?

andres-asm commented 6 years ago

FBA doesn't emulate any of those, please keep the discussion on-topic, this is not a forum

On Fri, Mar 23, 2018 at 5:19 PM, Demetris Ierokipides < notifications@github.com> wrote:

@barbudreadmon http:///barbudreadmon i know this is irrelevant somehow but i felled the urge to ask about Capcom ZN1/ZN2, Namco System 11/12 and Taito FX1, support possible?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libretro/fbalpha/issues/182#issuecomment-375813267, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpC0JchJs3fzYT_ChUx5gidx-nj638Cks5thXTsgaJpZM4SYpne .

barbudreadmon commented 6 years ago

Today i heard there was some incompatibility with RetroAchievements in neogeo games when changing bioses. Is that true ? Any idea what could be the issue ? Let me know if i can help with it.

meleu commented 6 years ago

@barbudreadmon it's intentional. We enforce the achievement developers to not allow their achievements trigger when using UniBIOS. The reason is on our docs: http://docs.retroachievements.org/Console-Specific-Tips/#mandatory-unibios-protection

I'm not sure if it should be worked out on your end... Is it possible for the core know if the Achievements feature is enabled on RetroArch? Does it worth to spend your time coding such cheat protection in the core?

Maybe it's better let we at RetroAchievements deal with it and on your end just let users know about the protection we use.

leiradel commented 6 years ago

Libretro cores know nothing about achievements so it must be worked around on Retro Achievements.

Maybe we could deal with this in RALibretro but cheaters could just use RetroArch.

barbudreadmon commented 6 years ago

Ok, i don't see any problem if it's intentional then.

andres-asm commented 6 years ago

Maybe on detection disable hardcore mode :)

meleu commented 6 years ago

If going through this way I would suggest disable the Achievements feature as a whole. Even in softcore things like infinite lives/grenades/credits/whatever shouldn't be allowed.

barbudreadmon commented 6 years ago

I guess there is no way for the core to detect if retroachievements are enabled ? It would allow me to disable unibios.