Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
08146 Sound Minor Always Dec 10, 2021, 22:45 Jan 7, 2022, 00:41
Tester ayjanu View Status Public Platform MAME (Self-compiled)
Assigned To aaron Resolution Fixed OS Linux (64-bit)
Status [?] Resolved Driver
Version 0.238 Fixed in Version 0.239 Build 64-bit
Fixed in Git Commit d187a28 Github Pull Request #
Summary 08146: contra and clones: Sound and music is slightly too slow
Description As I originally thought this was a timing issue with the end credits, my bug report initially reflected that. However, now it's clear to me that it's an issue with the sound timing being a little too slow (thanks to MetalGod for bringing this to my attention). I'll leave this video up, because it's still relevant.


EDIT: I have attached a zip file of savestates, demonstrating the slower speed of the credits music (where I first noticed what I thought was a timing bug) across all 10 sets currently emulated by MAME. A variable number of continues were used (from 0 to 2), although this has no bearing upon the bug. DIP switch settings were kept at their default values.
Steps To Reproduce
Additional Information On a side note, I also tested both gryzor clones, and not only is the music too slow in those clones as well, but the "The End" screen also seems to end prematurely in both variants, a couple of seconds before the game over music finishes playing. Might be worth looking into that as well.
Github Commit
Flags Verified with Original
Regression Version
Affected Sets / Systems contra and clones
Attached Files
zip file icon mame_0238_contra_end_credits_savestates.zip (60,058 bytes) Dec 12, 2021, 23:25 Uploaded by ayjanu
Relationships
related to 07078Resolvedaaron  tmnt, tmntua, tmntj: Sound or gameplay is slow if comparing with arcade 
related to 03737Resolvedaaron  salamand, lifefrce: Music speed is slow. 
related to 00413Resolvedaaron  crimfght: The speed of the music is playing ever so slightly too slowly. 
parent of 01232Resolvedaaron  aliens: Comparing to the pcb, the music in mame is slower. 
parent of 04825Resolvedaaron  vendetta: In MAME the music tempo is slower than real PCB 
parent of 03754Resolvedaaron  scontra, scontraj: Flaws in sound emulation 
Notes
23
User avatar
No.19541
MetalGod
Senior Tester
Dec 13, 2021, 00:36
Probably related with 07078... among many other bug reports about slow music timing in konami games.
User avatar
No.19542
ayjanu
Tester
Dec 13, 2021, 02:11
edited on: Dec 13, 2021, 02:17
You know what? I think you're probably right about that; now that I listen really closely, the music does sound slightly faster in that video. Thanks for clearing that up; I'll update the description and such.
User avatar
No.19543
Fujix
Administrator
Dec 13, 2021, 06:23
Can be related with 03737.
User avatar
No.19544
ayjanu
Tester
Dec 13, 2021, 06:35
edited on: Dec 13, 2021, 06:37
Yes, I would agree with that too. This all definitely seems indicative of a larger problem somewhere. Thank you Fujix (and MetalGod too).
User avatar
No.19545
kmg
Senior Tester
Dec 13, 2021, 08:32
There's also The Simpsons that was mentioned on MAMEWorld just the other day. In the opening montage the slightly slower music in MAME makes Lisa's saxophone playing come in around a second after the animation of her playing.
User avatar
No.19546
ayjanu
Tester
Dec 13, 2021, 13:08
edited on: Dec 13, 2021, 20:30
...Wow. That just blew my mind. I remember seeing that in MAME, and finding it kinda weird. Now that we're having this discussion, it all makes perfect sense. Thanks. Do all of these early games share anything in common that can be adjusted in the code (such as a similar CPU family, or some code between them that makes the sound slow like this), or will they all have to be corrected individually?

EDIT: I see that Contra uses the YM2151 for its sound processing, and I've also taken the time to read up on some of these other bug reports from the past. Is it simply how the YM2151 is implemented across each of the games, that's the problem? It would seem to me that, if overclocking the chip leads to breakage in other games, then something might be different regarding how the chip is used, across each of the games, or perhaps different "groups" of the games. I'm not certain; just hypothesizing here.
User avatar
No.19549
Ace
Tester
Dec 15, 2021, 05:54
edited on: Dec 15, 2021, 05:56
I encountered this slow music bug on a number of Konami games even when attempting to get both Iron Horse (which uses the YM2203 rather than the YM2151) and Jackal working on an FPGA. It seems the origin of this issue is an error in the timer behavior of both OPM and OPN family FM chips. With the YM2151, it's specifically timer B which appears to have an issue as the lower 4 bits are supposed to be free-running. If these bits aren't free-running in MAME, it's likely the root cause of slow music in a number of Konami games with the YM2151.
For reference, Jose Tejada's JT51 is what I used for Jackal and this is how the timers are modeled after being fixed to correct the slow music problem: https://github.com/jotego/jt51/blob/master/hdl/jt51_timers.v
He also has his own FPGA clone of Contra which has the correct music speed after this fix.
Hope this helps.
User avatar
No.19550
aaron
Developer
Dec 15, 2021, 23:52
Please test with this PR: https://github.com/mamedev/mame/pull/8988 and let me know how things line up/compare.
User avatar
No.19551
ayjanu
Tester
Dec 16, 2021, 03:01
Okay, aaron - I'll compile a fresh build with your commit and report back. Will edit my post once I've had a chance to test it. Thanks to Ace as well. Hopefully our combined efforts will have paid off.
User avatar
No.19552
Steve Coomber
Tester
Dec 16, 2021, 11:56
Seems to have fixed everything that I have tried. The Simpsons intro music is timed perfectly now. Great job!
User avatar
No.19553
MetalGod
Senior Tester
Dec 16, 2021, 16:03
Thanks to Jotego for fixing this in the Mr. FPGA and to Aaron for integrating it into MAME.
This closes a lot of bug reports.
User avatar
No.19554
ayjanu
Tester
Dec 16, 2021, 16:12
Yes - I can confirm that the timing is fixed now, with Contra as well! Steve Coomber is also correct about The Simpsons intro, and I even had time to test out 03754, and can confirm that the timing is correct there, too. Yes - thank you, everyone!
User avatar
No.19555
StHiryu
Tester
Dec 16, 2021, 16:38
edited on: Dec 16, 2021, 16:38
Someone can check this 06764? Since the game uses YM2151 too.
User avatar
No.19556
ayjanu
Tester
Dec 16, 2021, 18:55
edited on: Dec 16, 2021, 19:34
StHiryu: Yes, I'd be happy to test it, and report back.
EDIT: Yes, bug 06764 has also been fixed.
User avatar
No.19558
MetalGod
Senior Tester
Dec 16, 2021, 20:50
Bugs 00413, 01232, 04825, 03754 should be checked as well.
User avatar
No.19559
ayjanu
Tester
Dec 16, 2021, 21:08
edited on: Dec 16, 2021, 21:37
I can confirm that bug 03754 is definitely resolved, as is bug 00413. I will test the other ones as well, or others can.
EDIT: Bug 01232 is also fixed now, as well as bug 04825. So all of those bugs have been resolved. Are there any others that anyone would like me to test?
User avatar
No.19561
StHiryu
Tester
Dec 17, 2021, 01:06
edited on: Dec 17, 2021, 01:08
Please try the 08116 if you can. Really not related but maybe fixed with Aaron's commit.
User avatar
No.19562
ayjanu
Tester
Dec 17, 2021, 01:18
edited on: Dec 17, 2021, 04:13
Okay - I just took a look at it. I'll try it. Not sure if it's changed, but it's worth a try.
EDIT: Alright, I just got done testing Bad Dudes vs Dragon Ninja, for the bug you asked about, StHiryu. You are correct; bug 08116 is not related to this bug. I tested the ending music, and it still sounds a bit overdriven to me, so that hasn't been fixed with Aaron's patch. If there's any other bugs that you or others want me to test, however, please let me know. I'd be willing to test as many as you all want.
User avatar
No.19565
MetalGod
Senior Tester
Dec 17, 2021, 12:21
edited on: Dec 17, 2021, 12:22
Despite being solved, I'm leaving this bug report opened for now, just for debate and communication with testers and devs. I'll close it later.
It seems all related bug reports have already being tested anyway.
User avatar
No.19566
MetalGod
Senior Tester
Dec 17, 2021, 12:27
There are 2 more bug reports that are related with voice samples. I don't know if these are related.
Bugs are 03919 and 03738
User avatar
No.19567
ayjanu
Tester
Dec 17, 2021, 13:41
edited on: Dec 17, 2021, 14:21
Thank you for leaving it open for now, MetalGod. Go ahead and close it when you see fit. As for the other bugs, I'll test them very soon, and report back what I find.
EDIT: Neither bug 03919, nor 03738, appear to be fixed with Aaron's patch, so they are not related. If there's any more you'd like me to test though, I'd be glad to.
User avatar
No.19588
Ace
Tester
Dec 23, 2021, 16:42
Bugs 03738 and 03919 deal with emulation issues pertaining to the VLM5030 and are completely unrelated to the Yamaha FM timers. 03919, in particular, is due to emulation inaccuracies with the VLM5030 in general, which I would suggest to rebuild based on this gate-level VHDL model made by Arnim Laeuger of FPGAArcade: https://github.com/FPGAArcade/replay_common/tree/master/lib/sound/vlm5030

I couldn't actually test Aaron's commit for the YM2151's timers because for some reason, whenever I try to compile MAME under Linux, the compiles crash my PC, then keep failing. I will have to suggest one thing pertaining to bug 07927 as it's also related to the timer inaccuracies: https://mametesters.org/view.php?id=7927

Provided Jackal runs at the correct speed, the timer fix should prevent the music from stopping without needing to overclock the secondary CPU, which in itself mangles the notes. In short, the CPU overclock should be removed.
User avatar
No.19617
MetalGod
Senior Tester
Jan 3, 2022, 14:51
Adding Ace's last comment to bugs 3738 and 3919.

Closing this one.