Closed greyrogue closed 4 years ago
With a little more testing, I'm not convinced this is correct. I think this might be causing issues with samples in Metal Slug 3. Still testing. I'd like to know why it was changed in MAME.
More testing: --Metal Slug 3 works correctly with this change with two additional changes. The LUT table must wrap instead of clipping. Also, the first sample is being skipped in decoding. With both of those fixed, it works correctly. However, I'm also seeing distortion in KOF 2004 SE. This goes away if not using wrapping (using clipping instead). MAME has this same clipping with KOF 2004 SE. Not sure what correct behavior is now, but I tend to trust Lord Nightmare, who made the change to MAME...
Ok. Confirmed on hardware that KOF 2004 SE distorts. It appears this hack was encoded based on an incorrect emulator implementation. I believe this wrapping code is correct.
Thanks a lot for this fix and for checking the real behavior too.
There are still a few changes in the experimental build of MiSTer Neo Geo that are different from your base version. I'd like to get them back in sync. I am less certain these are correct. This is the one that looks most likely correct to me. Please take a look and comment. This change is based on this: https://github.com/mamedev/mame/blob/master/src/devices/sound/fm.cpp#L2502
I believe this means the value is limited to 12 bits, but wraps, instead of clipping. It looks like a relatively recent intentional change to the code base, which I assume is based on recent findings. As I recall this fixed the sound in something, but I forget where (Metal Slug, maybe?).
It might be better to return this as a 12 bit signed value, rather than a 16 bit signed value (where the top 4 bits are always just sign extended).
This will change audio balance in other places, which are handled in other changes in the MiSTer core. Not sure if you want to look at all the remaining changes at once, or one at a time.