High pitch explosions for Xevious and Galaga

lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

I've noticed that in Xevious both the player and bomb explosions seem to play at too high a speed. In Galaga there appears to be a similar issue with the player explosion. In MAME with the same ROMs they seem ok.
lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

Looks like the explosions are generated with the 54xx. Researching a bit it looks like the CPUs are supposed to run at 3072000Hz and the 54xx at half that. Perhaps the 54xx is running at the CPUs speed instead making the explosions fast? That would sound about right at least.
User avatar
macro
Core Developer
Posts: 141
Joined: Sun May 24, 2020 4:12 pm
Been thanked: 171 times

Re: High pitch explosions for Xevious and Galaga

Unread post by macro »

having a quick look at the galaga code, it time slices an 18Mhz clock across 6 zones, each CPU uses 1 slice, so 3Mhz equivalent and the 54xx / mb88 is only enabled every 8th occurence of slice 0 - so 375Khz
Did I do something useful?

buy me a coffee
lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

Thanks for looking macro. I see that now as cs54xx_ena_div is three bits and is incremented once each time through the six slots. This must work differently than it does in MAME as the 54xx runs at 1/2 the CPU speed there and sounds correct. I'd expect it to be slow on the MiSTer at 1/8 CPU and not fast.
User avatar
macro
Core Developer
Posts: 141
Joined: Sun May 24, 2020 4:12 pm
Been thanked: 171 times

Re: High pitch explosions for Xevious and Galaga

Unread post by macro »

Just double checked Mame, and it seems the clock passed to the MB54xx should be 1.5Mhz (half the CPU clock), but then that clock is divided by 6 in the actual MB54xx code - so it should be 1/12 of the master clock overall

so at the moment it is 1/8 * 3Mhz = 375Khz

but it should be 1/2 * 1/6 * 3Mhz = 250khz

so not quite half, but definitely lower. change the 3 bit counter to 4 bit and activate / zero counter when it reaches '1011' (11!) instead.

so code changes to (something like)

from:
if slot = "000" and cs54xx_ena_div = "000" then cs54xx_ena <= '1'; end if;

to:
if slot = "000" and cs54xx_ena_div = "1011" then
cs54xx_ena_div <= "0000";
cs54xx_ena <= '1';
end if;

and don't forget to knock the signal up to 3 downto 0

Have made the change on my copy, and it still makes noises in the right place, whether it has slowed it sufficiently I'll leave to others to check.

I attached the changed file to the issue in github, couldn't see how I could do a pull request for it (not that used to github!)
Did I do something useful?

buy me a coffee
lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

Yeah, I actually got motivated enough this morning to try and finally get a dev environment on my Mac so I could play around. I ended up with a Docker solution that works. I decided to see what would happen if I simply cut the speed in half by making cs54xx_ena_div four bits. With that it still sadly had less low end than MAME but I could tell it played longer (too long). I recorded and measured each. MAME was about 2.7 seconds, The MiSTer was originally about 1.8 seconds, and did indeed stretch to about 3.6 seconds with my modified version.

I believe you're right with the speed although I think you want a value of 1100 instead of 1011 for the check of cs54xx_ena_div. Using that I get a play length of about 2.7 seconds or the same as MAME.

It still doesn't sound right to me so there must be more to it. It's better though and almost certainly the right speed at least.

I'm going to try this same thing with Xevious. It has two explosions and they both sound even worse than Galaga to me.
lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

Xevious is worse with a speed of 750kHz. 250kHz gives me the same speed explosion as MAME. PR for Xevious is here if you want to take a look.
dshadoff
Core Developer
Posts: 547
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 20 times
Been thanked: 145 times

Re: High pitch explosions for Xevious and Galaga

Unread post by dshadoff »

I have to ask this question, because it so often turns up as being relevant:
- While the MiSTer core may not be correct, how can you be sure that MAME is correct ?

It would be ideal to corroborate with an actual arcade board.

MAME generally gets the major points correct, and has been an excellent resource over the decades for general information, but is quite often incorrect on the finer details - particularly those which may have been put into their emulation in the early days, and just assumed to be correct.
lagomorph
Posts: 15
Joined: Mon Jul 06, 2020 2:18 pm
Has thanked: 2 times
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by lagomorph »

That's a good point and I'm not absolutely sure it's correct. About the most I can say is that MAME sounds right to my ears but that's subjective of course. Looks like the MAME 54xx simulation code came along later and originally they used samples. At least their 54xx sounds pretty close to the samples.

The MiSTer cores still don't sound quite as good as those samples so there's more going on than just the speed. The samples have much more bass.
dshadoff
Core Developer
Posts: 547
Joined: Sun May 24, 2020 9:30 pm
Has thanked: 20 times
Been thanked: 145 times

Re: High pitch explosions for Xevious and Galaga

Unread post by dshadoff »

There's a pretty good overlap between the MiSTer community and arcade board owners; perhaps somebody owns this board and can perform some sort of comparison - ideally, actual data acquisition via oscilloscope or recordings.
ash2fpga
Posts: 237
Joined: Tue May 26, 2020 6:20 pm
Has thanked: 62 times
Been thanked: 28 times

Re: High pitch explosions for Xevious and Galaga

Unread post by ash2fpga »

On a open source "game recreation" project I used to be involved with, Youtube videos were sometimes sourced for reference (source of truth). A quick search on Youtube, for xevious arcade and for galaga arcade, shows some videos of people playing on arcade cabs (possibly original h/w). It might be worth taking a quick look there for comparison.
mhartman
Posts: 96
Joined: Fri Jul 03, 2020 1:26 pm
Has thanked: 47 times
Been thanked: 20 times

Re: High pitch explosions for Xevious and Galaga

Unread post by mhartman »

If anyone needs a sample from an original Galaga board let me know. I love the Galaga version on MiSTer, but the explosion is so off from the original (it is a bit disconcerting). I would be awesome to get it corrected.
alanswx
Core Developer
Posts: 300
Joined: Sun May 24, 2020 6:55 pm
Has thanked: 5 times
Been thanked: 154 times

Re: High pitch explosions for Xevious and Galaga

Unread post by alanswx »

Please watch YouTube videos of the original games. Also some of these boards shipped with different value parts throughout their life and sounded different depending on the board. See galaxian.
mhartman
Posts: 96
Joined: Fri Jul 03, 2020 1:26 pm
Has thanked: 47 times
Been thanked: 20 times

Re: High pitch explosions for Xevious and Galaga

Unread post by mhartman »

alanswx wrote: Fri Feb 19, 2021 6:58 pm Please watch YouTube videos of the original games. Also some of these boards shipped with different value parts throughout their life and sounded different depending on the board. See galaxian.
I’ve owned several Galagas over the years (and even more PCBs). The explosion on mister is nothing like any of the originals. Again, I appreciate the work that everyone has done. The explosion is not right though.
alanswx
Core Developer
Posts: 300
Joined: Sun May 24, 2020 6:55 pm
Has thanked: 5 times
Been thanked: 154 times

Re: High pitch explosions for Xevious and Galaga

Unread post by alanswx »

I am sure it needs to be fixed. Just not copied from mame necessarily.
mhartman
Posts: 96
Joined: Fri Jul 03, 2020 1:26 pm
Has thanked: 47 times
Been thanked: 20 times

Re: High pitch explosions for Xevious and Galaga

Unread post by mhartman »

alanswx wrote: Fri Feb 19, 2021 8:45 pm I am sure it needs to be fixed. Just not copied from mame necessarily.
Agreed. If someone has the know how to implement it, I’m happy to send them a sample directly from one or two of my original Galaga PCBs.
alanswx
Core Developer
Posts: 300
Joined: Sun May 24, 2020 6:55 pm
Has thanked: 5 times
Been thanked: 154 times

Re: High pitch explosions for Xevious and Galaga

Unread post by alanswx »

It would be great if you could post some samples here. Thank you.
mhartman
Posts: 96
Joined: Fri Jul 03, 2020 1:26 pm
Has thanked: 47 times
Been thanked: 20 times

Re: High pitch explosions for Xevious and Galaga

Unread post by mhartman »

alanswx wrote: Fri Feb 19, 2021 9:24 pm It would be great if you could post some samples here. Thank you.
Cool. Here are all of the Galaga sounds sampled directly from an original Midway Galaga PCB (if you boot with the test switch on, you can play the sounds individually with the fire button). I used PCB speaker out to a speaker-to-line converter into a recording interface, so this is a pure recording straight from the PCB to digital. The sounds were recorded making sure to avoid clipping or distortion. I also cleaned the background noise using a mild digital filter once I imported to my pc.

I had to attach as a .zip file because mp3s aren't allowed as attachments.

Enjoy!
Attachments
Galaga Sounds (direct sample from PCB).zip
(2.54 MiB) Downloaded 170 times
alanswx
Core Developer
Posts: 300
Joined: Sun May 24, 2020 6:55 pm
Has thanked: 5 times
Been thanked: 154 times

Re: High pitch explosions for Xevious and Galaga

Unread post by alanswx »

lagomorph wrote: Sat Dec 05, 2020 7:43 pm Xevious is worse with a speed of 750kHz. 250kHz gives me the same speed explosion as MAME. PR for Xevious is here if you want to take a look.
i think i might have made this mistake when I patched it for Super Xevious. Thank you for the fix.
SteelRush
Posts: 17
Joined: Sun Aug 30, 2020 1:44 am
Been thanked: 1 time

Re: High pitch explosions for Xevious and Galaga

Unread post by SteelRush »

If examining a real Galaga PCB would benefit a developer, I have a dead board I would donate to get this right. No repairs have been attempted, so it likely is fixable in the right hands.
mhartman
Posts: 96
Joined: Fri Jul 03, 2020 1:26 pm
Has thanked: 47 times
Been thanked: 20 times

Re: High pitch explosions for Xevious and Galaga

Unread post by mhartman »

Hi all,

Regarding the Galaga explosion, I had a conversation with a friend of mine who is an expert in this area. Here is a summary of his thoughts:

The 54XX custom chip outputs digital white noise, usually that would be a stream of 0's and 1's randomly distributed (https://en.wikipedia.org/wiki/White_noise). However, the 54xx outputs 4bit values, so you can think of that as white noise with a 'volume' of 1-3.

The mistake that many make (including the current MiSTer core) is assuming that data is regular digital audio, and that it can be mixed directly with the output of the Namco sound circuitry. A look at the Galaga schematics reveals that the 54xx output is fed through 3 different single-pole op-amp filters, each with slightly different passive components. The analog result of each op-amp is then summed together to form the 'explosion' sound. The sum of all these parts is that Galaga's code controls the 'volume' of the 54xx white noise to create an explosion with a couple different crescendos, and then fades out gently.

Feeding a stream of digital white noise into an op-amp filter was a common method of generating explosions, bangs, and pops in early 80s arcade hardware. The op-amp acts an active low-pass filter, amplifying the digital noise with a frequency response designed to avoid sharp pops and clicks.

MAME handles the Galaga explosion pretty well. Over the years, they have implemented modeling of various analog sound circuits, including op-amps. Given the complexity, MiSTer's best approach would probably be to use a digital sample. It's definitely possible to do the analog modeling needed in FPGA to emulate op-amp filters, but it is quite specialized work.


Unfortunately, he doesn't have the availability to help out on the MiSTer core, but hopefully the info will help the community with the Galaga explosion (and sounds in other games from this era). He was incredibly generous with his time and expertise to review the code and schematics and provide this explanation. Also, if a sample-based approach is adopted, please feel free to use the Galaga explosion(s) from the file that I uploaded above.

Regards,
Mike
Post Reply