irixxxx / picodrive

Fast MegaDrive/MegaCD/32X emulator
Other
47 stars 24 forks source link

sound: fix ym2612 address handling #91

Closed notaz closed 1 year ago

notaz commented 1 year ago

I already fixed this back in 2017 with 151df6adf9d63c9b8c8a61946243800610ac3a65, but forgot about ym2612_write_local(). Fixes missing sounds in Overdrive2.

notaz commented 1 year ago

Was surprised how well Overdrive2 worked already, so this motivated me to hunt down this remaining issue.

irixxxx commented 1 year ago

I actually put some work into getting Overdrive 2 working. I guess a lot of that work is only relevant for exactly this, but I actually felt challenged ;-)

irixxxx commented 1 year ago

Open problems with OD2, to my knowledge:

Drop me a note if you find any other problems. I surely might have a look at it. BTW, my MD1 is one of those having problems with the debug register - OD2 is looking much better in picodrive than on my hardware.

notaz commented 1 year ago

My MD1 is also having problems in some scenes, and shows the warning about "plane instabilities" (which do actually happen on plane mixing+sprites scene). Occasionally (perhaps <1/10 runs) it even completely crashes for me (shows a register dump with "OD2 BSOD"), I wonder what exactly happens there. Supposedly the demo doesn't work properly on at least 30% megadrives (by Titan's own estimate) so no surprise.

Personally I wouldn't care about those few lines, I haven't even noticed that issue. What hits me more is the audio issues that still remain, for example wrong effects in spaceship piloting scene near the beginning. It's not super obvious but I have seen the demo so many times that slight sound differences stick out to me.

Ok while writing this I investigated further. The effect is on channel 4 that has SSG-EG enabled.

Could be related to SLOT->ssgn or something.

irixxxx commented 1 year ago

It's really tight on timing. Mix it up even only a tiny bit, and it crashes in picodrive as well. Just saving and loading is sufficient in some places.

I basically gave up on those flickering lines. It's barely noticeable. It's a timing issue, the 68k just isn't synchronous to the scanline at the start of the frame. It magically heals itself within some 3 scanlines. I don't think it's really worth diving further into it.

As for the sound, have you used the arm assembly or the C version? Sound is possibly incorrect after loading a state, since it doesn't save the internal state of the FM, it only saves the register values. I reckon that's why the sound is off when using run-ahead with libretro. Save/Load is on my todo list for some time, but it is some work since it spans a lot of the source. I haven't yet come around to tackle it.

notaz commented 1 year ago

Sound is possibly incorrect after loading a state, since it doesn't save the internal state of the FM, it only saves the register values.

Actually this is not quite true, YM2612PicoStateSave2/YM2612PicoStateLoad2 tries to stick some of the internal state into unused register space (I guess I did it that way to maintain savestate compatibility).

Now that I came back to this code it's quite horrible from maintenance point of view, especially trying to stuff all the bits everywhere to try to keep stuff in registers in asm code. Looking at it now I wonder if all this stuffing hasn't wasted more cycles than saved on the asm side.