dciabrin / ngdevkit

Open source development for Neo-Geo
GNU Lesser General Public License v3.0
262 stars 26 forks source link

06-sound-sample no sound on real hardware with NEOSD #64

Closed khelkun closed 1 year ago

khelkun commented 2 years ago

We've been trying to run 06-sound-sample on Neogeo AES with a NEOSD cartdige.
Someone has already achieved this successfully?

We use neosdconv and it works fine with game roms downloaded from the web. But the 06-sound-sample rom does not have sound although the graphics are there and the buttons trigger on screen.

The issue is presumably about the sound driver MROM.

I thought the problem could be the driver signature which I assume to be the driver ID declared here. So I tried to replace it with %Ver 3.0 by MAKOTO.04/03/10 to SK% which is the "Puzzle De Pon!" sound driver signature according to the wiki.

But it seems this lead is not the right one. Would you have any other ideas or tests to perform please?

dciabrin commented 2 years ago

This might very well be a timing issue in the code on real hardware. I started this default sound driver from scratch so it's very likely that the z80 code does not wait long enough on the ym2612 or something along those line. There's no particular logic for sound driver check/enforcement in the hardware, so tweaking the driver ID won't change anything. I don't think that NEOSD would do any check on it either.

khelkun commented 2 years ago

So this may be related to prepare_wait_in_ram_opcode macro and its usage in the MROM init and the snd_command_01_prepare_for_rom_switch?

dciabrin commented 2 years ago

So this may be related to prepare_wait_in_ram_opcode macro and its usage in the MROM init and the snd_command_01_prepare_for_rom_switch?

So I think that this one shouldn't but the culprit, because unless it's buggy it's just meant to make the z80 read its code from RAM, to leave time to the m68k to initialize everything and switch to whatever z80 code bank is needed.

I'm more thinking something is wrong in https://github.com/dciabrin/ngdevkit/blob/f845e9c40fb9c8f6ee562933fb08a311785667ae/nullsound/driver/ym2610.s, because successive calls to the ym2610 have to respect some latency [1,2] to be effectively honored by the ym2610. And usually the emulators aren't that sensible to that, so we're overlooking some bugs on the real hardware.

[1] http://www.ajworld.net/neogeodev/ym2610am2.html#Status [2] http://www.ajworld.net/neogeodev/ym2610am2.html#RegWriting

dciabrin commented 2 years ago

Also https://wiki.neogeodev.org/index.php?title=Z80/YM2610_interface is probably a more specific answer to my previous comment.

khelkun commented 2 years ago

Cool that seems to be the right lead. I'l try to fix this and send you a PR if I succeed. thanks

dciabrin commented 1 year ago

After an awfully long hiatus, I just noticed that example 06 doesn't seem to run on MAME either. So while it's nothing close to being fixed, at least it doesn't require me from getting my hands on a neosd to test that on real hardware.

dciabrin commented 1 year ago

OK I think https://github.com/dciabrin/ngdevkit/commit/859fc942c3e073780165094c72f192c0bcb9d05d should fix this issue. It looks like the z80 was never initialized properly so it couldn't receive NMI when the 68k was triggering a sound command. I don't have a way to test this fix on real hardware, but Mame is usually pretty spot on for NeoGeo, so I believe this patch should fix the original issue. Closing accordingly.