ekeeke / Genesis-Plus-GX

An enhanced port of Genesis Plus - accurate & portable Sega 8/16 bit emulator
Other
676 stars 194 forks source link

TMNT Tournament Fighters broken music with nuked YMs #289

Closed p1pkin closed 4 years ago

p1pkin commented 4 years ago

Music is mostly broken in this game if use "nuked ym2612" or "nuked 3438" YM cores, it sounds like wrong music samples or notes played all the time. Notable during gameplay, or in options BGM test, tune #7 is most notable. Issue present in Retroarch with both libretro's core or DLL provided in this repository.

not sure why this might happen, I'd guess something YM register access timings related ?

ekeeke commented 4 years ago

If it does not happen with MAME core, then it's a bug in Nuked core and it should be reported to core author instead as I am just using the latest version that was pulled in from Nuked repository without any changes. I don't have the time or mean to debug other's code, I'm afraid.

nukeykt commented 4 years ago

I think it's timing issue as overclocking emulated ym eliminates missed writes. I'm not sure if fault is on my code or not. MAME core does not requires delays between writes unlike real YM and my core, so it might be CPU timing issue. Maybe YM is not well syncronised with CPU?

ekeeke commented 4 years ago

Well, it should be, otherwise there would be much more game with sound issues I think.

It could still be a timing issue indeed in sound.c interface. I think I noticed some issues with Overdrive 2 demo music because of some mistake in the read functions (I adjust the cycle value to ensure timer flags only get updated if full sample clock was executed but it seems the current code is buggy, at least with this demo were music is slowed down because of that, maybe it's a similar issue here if that game uses FM timers for syncing)

p1pkin commented 4 years ago

otherwise there would be much more game with sound issues I think

I've been told there is number of games with same issues, its just TMNT Fighters was the one which came to mind. I'll post the list of all problematic games if/when I'll get it.

The other game with probably similar issue is Jungle Book: after getting fast a lot of items - music may slowdown and stutter. this happen with "nuked 2612" core only. it is fine if use "nuked 3438" or MAME-derived cores.

nukeykt commented 4 years ago

Jungle Book seems to use GEMS driver. GEMS driver has bug where it occasionally tries to read chip status on invalid port causing slowdowns on discrete YM2612/YM3438, it's fine with ASIC YM3438 and Teradrive's discrete YM3438. Probably most notable example of this issue is EWJ's New Junk City. Other affected game i know is Sonic Spinball

Testsr commented 4 years ago

The problem has been found before.

FIX94 commented 4 years ago

I just happen to notice this issue as well and especially with these konami titles: Lethal Enforcers (Proto) and released builds Teenage Mutant Ninja Turtles: Tournament Fighters Castlevania Bloodlines (Proto), strangely enough fine in released game Double Dribble - The Playoff Edition Lethal Enforcers II - Gun Fighters its noticable right away as the konami logo audio plays completely broken and not anywhere near what it should be. That said, I also noticed in earlier emu revisions, at least the logo played fine, and narrowed it down to this particular line of code: https://github.com/ekeeke/Genesis-Plus-GX/blob/master/core/sound/sound.c#L214 once its changed to just read fm_update(cycles); then at least the logo audio seems to be fine, but even then, theres clearly still some major issue regarding the audio, I noticed this in particular with TMNT and that castlevania proto, that when you just immediately press start before the logo even plays, you will notice theres a lot of static in the audio, and even when you leave the logo playing, there will still be something very wrong with it on the title screen. Sadly I dont know anything really about genesis emulation to really help out... edit: also well, I kept playing around with code and just various dumb stuff I dont understand and I happen to notice that when changing that line that was problematic to something more like this: fm_update(cycles + fm_cycles_ratio + 1); those weird static issues seem to go away and things play more proper, not sure what that means exactly for general timing, just thought it may be worth sharing.

ekeeke commented 4 years ago

As initially suspected, it's indeed the adjustment made to YM synchronization cycle on CPU reads that causes this issue. I reverted to original behavior in https://github.com/ekeeke/Genesis-Plus-GX/commit/791048af4c5ee5688ed3aed1bcd68e8256577668 and verified it fixed BGMs in option menu.