VOGONS


CMS/Gameblaster Rewrite and accuracy

Topic actions

First post, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I was busy rewriting the cms/gameblaster stuff a bit

But I was wondering how accurate is the current implementation in dosbox. From what I see dosbox assumes the cms to run at 8mhz while the real thing should run at 7.1ish mhz using the same isa clock as the adlib uses. I'm lacking an actual gameblaster/cms card or addon chips so I can't really compare but I would assume that would have quite an impact on tone frequencies.

During a very early version of dosbox I also once made a simple gameblaster emulation that used sinewaves instead of squarewaves and I always thought that sounded much more appealing as well, might make that an extra option. Maybe a bit of low pass filtering might also make it sound a bit more authentic considering the way it does the actual sound generating but that can wait.

Reply 1 of 32, by Scali

User metadata
Rank l33t
Rank
l33t

Well, it doesn't look like there's any crystal at all on the GameBlaster, so I guess the only clock it could use is the ISA one.

Speaking of accuracy... I'd like to point out that the GameBlaster should be able to do sample playback in a way similar to the SN76489 in the PCjr/Tandy. This requires more accurate emulation than what standard DOSBox has.
A fix for this was made in DOSBox-X a while ago.

http://scalibq.wordpress.com/just-keeping-it- … ro-programming/

Reply 2 of 32, by PhilsComputerLab

User metadata
Rank l33t++
Rank
l33t++

So if one overclocks the ISA bus, would the frequency of the CMS change?

Harekiet, I have a few recordings I can provide to help? They are mostly in YT videos, but I could do fresh ones on a 386.

YouTube, Facebook, Website

Reply 4 of 32, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Yeh I imagined it should have been mentioned before already somewhere but it's difficult finding things through all the posts.

Overclocking the ISA shouldn't be problem since that clock line runs it's own crystal.
As for recording some test samples you'd probably want some test program or wasn't there some cms organ music player where you could just run a few frequencies on 1 channel.

Reply 5 of 32, by PhilsComputerLab

User metadata
Rank l33t++
Rank
l33t++

I was thinking of some popular games like Monkey Island, Last Crusade, Space Quest III.

YouTube, Facebook, Website

Reply 6 of 32, by keropi

User metadata
Rank l33t++
Rank
l33t++

@Harekiet
do you have suitable SB and all you miss are the CMS anr/or GAL chips?

🎵 🎧 PCMIDI MPU , OrpheusII , Action Rewind , Megacard and 🎶GoldLib soundcard website

Reply 7 of 32, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

@phil
I think most of those have already have recordings on youtube, although some might have already been from dosbox. But you might see some effects of the low pass filter when just sticking to 1 channel doing a simple square wave.

@keropi
I have a sb2.0 without the cms and gal chips. Should have collected hardware earlier before it all got rare 😀

Reply 9 of 32, by PhilsComputerLab

User metadata
Rank l33t++
Rank
l33t++

Yea, lots of these are done with DOSBox.

I had a quick look, here is Monkey Island: https://youtu.be/Fr-84mjV3CI?t=1m30s

I remember that the pitch right at the start was quite different compared with DOSBox.

YouTube, Facebook, Website

Reply 10 of 32, by kazblox

User metadata
Rank Newbie
Rank
Newbie

The SAA1099 code is already accurate, it's the clock that needs to be corrected.

On the hand, the MCUs on the card need to be dumped as well and need to be emulated in the card interface, because they do weird detection behaviors with the Tandy 1000 and a generic 486....

Reply 11 of 32, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

I have a SB with soldered CMS chips and one with just empty sockets (CT1350).

It's been a while but I recall I traced the CMS clock source to be the ISA bus OSC signal 14318180 Hz and it was divided by two with a 74LS74 flip-flop. So you can consider that 7159090 Hz master clock for CMS chips confirmed.

I also started reverse engineering it a bit, but I did not go into it very far. All I could confirm is that CMS emulators back then did not emulate all features of the chip, but those features were never used by games anyway. I think it had something to do with volume envelope affecting all channels instead of one, and how not to just sum noise and tone together, it's some kind of bit operation like AND.

I also figured out the register values for note frequencies in PC Game Programming Encyclopedia were calculated and rounded correctly, but I did not measure them.

If there's anything I can help, just let me know. I'm well armed with logic analyzers and oscilloscopes.

Too bad the .VGM format has no CMS chip support, so my feature request would be to have DosBox output .DRO-like format for recording CMS music.

Were you planning to run the CMS emulator at 27965 Hz sampling rate and generate samples in that domain? I think at the highest octave the tone generators run at 3579545 MHz to allow the 9-bit upcounters to toggle the tone bit for clean square wave, but downsampling from 3579545 MHz to 44.1/48 kHz may not be so practical, so some corners can be cut 😀

Reply 12 of 32, by Great Hierophant

User metadata
Rank l33t
Rank
l33t

It is Irritating to hear all that wrong CMS music on Youtube, knowing the pitch is off. The patch fixes the issue, but you have to be able to compile DOSBox. I have a great deal of respect Youtube content creators who do not use emulators.

http://nerdlypleasures.blogspot.com/ - Nerdly Pleasures - My Retro Gaming, Computing & Tech Blog

Reply 13 of 32, by Harekiet

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Thanks to Keropi I've also got an sb2.0 with cms and gal chips going now! Hooked up the scope to confirm the frequency and it's indeed the 7 something mhz thing.
I tried scoping out the actual output pins of the cms chip but it's some much higher frequency pwm output and it's passing through a bunch of filtering stages where I kinda lost track of it all. I guess you could simulate a much higher frequency pwm output but with all the filtering is there really any point?
I couldn't really scope out the inputs as they go into the final amplifier chip, need smaller clips or solder some pins on dunno. In a way I wonder how clean the actual input signal is before it goes in there and what effect it has before it goes out the jack and if you could just simply simulate it all with a cheapish lowpass filter.

I made a little test tool to setup some frequencies in different channels and the current implementation seems pretty accurate once you run it at the right base frequency.
The only thing you notice in the real thing is the voltage of the output sagging with low frequency outputs when you just record it. With a 27hz frequency which is the lowest it can go you see this.
https://dl.dropboxusercontent.com/u/3873490/d … sbox/cms/t0.png
Dunno if the age of the capacitors have much influence on that. I should try to output and record a square wave from my laptop to the pc.

I thought the square wave of the pc speaker in dosbox had a similar output idea with the voltage going back to the middle over time.

Reply 15 of 32, by Jepael

User metadata
Rank Oldbie
Rank
Oldbie

From that picture, I estimate with pulse height of 91 pixels, exponential decay height of 70 pixels, during a time of 18.3ms, the whole system (including your recording equipment) has a first order low pass filter cutoff frequency at about 12-13 Hz.

It would help if someone with real GameBlaster would take pictures where component values are seen, and also from the bottom side of PCB to see where the copper traces go. From the top side images, R1 and R2 are 1k5 output resistors. C1 and C11 are the main AC coupling caps to amplifier chip. But what's between them is not quite clear.

Yes the volume envelope should be a 16-level pulse width modulation running at clock/128 or 55930Hz in a PC, and it should be equivalent to just have 16 amplitude levels at tone frequency. So perhaps not worth emulating the PWM.

But the only point for using high sampling rates (or faking it with some multiphase blep) would be the part where the tone toggles at the programmed amount of 1.79MHz clock ticks divided down by octave. If generating a 440Hz square wave which ends up at 44100 Hz sampling rate, it is not technically or sonically correct to just sometimes toggle every 50 and sometimes every 51 samples, that's jitter.

Edit:
I should learn to write. Or think. I mean:
- 12-13 Hz high pass filter from DC blocking caps. Not low-pass..
- 55930 Hz is the PWM chopping ("sampling") rate, but as there are 16 levels, the PWM chopper most likely runs at clk/8 rate, 895 kHz.

Edit 2:
-After simulating in Audacity, it's more like 17 Hz high pass filter.

Reply 16 of 32, by OPLx

User metadata
Rank Member
Rank
Member
kazblox wrote:

The SAA1099 code is already accurate, it's the clock that needs to be corrected.

On the hand, the MCUs on the card need to be dumped as well and need to be emulated in the card interface, because they do weird detection behaviors with the Tandy 1000 and a generic 486....

Aside from the incorrect clock frequency, the current DOSBox 0.74 implementation (which seems to use the MAME sources) has incorrect (buggy?) emulation of the SAA1099's envelope generators. The emulation "kind of" works, but if you play around with the envelope generator settings on real hardware you should be able to hear the difference.

Having said that, SAASound (http://simonowen.com/sam/saasound/) is very accurate, though its implementation is locked at the 8MHz clock; not surprising as it seems the target was for the SimCoupe emulator.

Though (it seems) most of the applications that used the Gameblaster didn't take advantage of the envelope generators, if at all possible, I think support for the feature should be there. 😀

Reply 17 of 32, by OPLx

User metadata
Rank Member
Rank
Member
Jepael wrote:

Too bad the .VGM format has no CMS chip support, so my feature request would be to have DosBox output .DRO-like format for recording CMS music.

The VGM format recently(?) added support for the SAA1099 ... but unfortunately the hardware that they are used on is clocked different from the Gameblaster (http://vgmrips.net/packs/chip/saa1099). I have a hypothesis that it might be possible to play the VGM files on a under DOSBox or on real hardware if one adjusts the frequency values sent to the chip. I haven't tried it myself though ...

Reply 18 of 32, by kazblox

User metadata
Rank Newbie
Rank
Newbie
OPLx wrote:

but unfortunately the hardware that they are used on is clocked different from the Gameblaster

Frequency can be adjustable for SAA1099 VGMs like every other VGM. Which means you can adjust an SAA1099 VGM to have the exact frequency of a Game Blaster.

Reply 19 of 32, by OPLx

User metadata
Rank Member
Rank
Member
kazblox wrote:
OPLx wrote:

but unfortunately the hardware that they are used on is clocked different from the Gameblaster

Frequency can be adjustable for SAA1099 VGMs like every other VGM. Which means you can adjust an SAA1099 VGM to have the exact frequency of a Game Blaster.

I hope it's that simple ... but I have the feeling that it won't be since the actual values sent to the frequency registers from the VGM are based off of the input clock. If I ever manage to get a chance, I might try that or something to see what works. Thank you for the suggestion! 😀