VOGONS


First post, by sinuspi

User metadata
Rank Newbie
Rank
Newbie

I've been playing around with Sierra AGI games, hacking tools to produce advanced Tandy-sound compatible tunes... and came upon a quirk.

The SN76496 chip can supposedly match the channel 3's periodic noise ("buzz") to channel 2's frequency, producing buzzes in tune with the regular notes. Not so in DOSBox 0.74-3, at least - I had to significantly retune the buzz notes in my music files to make them match the rest of the channels. The frequencies simply did not match at all.

So, I went digging in sources. And in the file dosbox/trunk/src/hardware/mame/sn76496.cpp, I found something totally unexpected. In line 358, m_period[3] = ((n&3) == 3)? (m_period[2]<<1) : (1 << (5+(n&3))); channel 3 nicely borrows channel 2's period... but that happens on setting of said period, in sn76496_base_device::write, on a new note. However, in a running DOSBox 0.74-3, I can easily demonstrate that it's enough to set that value on channel 3 once, early, and play more notes on channel 2, and channel 3 will adapt (with its weird frequency response). Looking at this code, it can't possibly do that.

In Lance Ewing's SN76396 emulation, the period is (correctly?) reset to match channel 2 on every cycle, not on a new note.

What's DOSBox 0.74-3 based on, then? Not SourceForge SVN rev 4300? And why on Earth does it do something weird with the frequencies..?

Last edited by sinuspi on 2025-06-12, 23:57. Edited 1 time in total.

Reply 1 of 2, by sinuspi

User metadata
Rank Newbie
Rank
Newbie

I'm an idiot. Just several lines earlier, there's code adjusting channel 3 to match channel 2 when channel 2's frequency changes. So, all's right with the world... PARTIALLY.

The question remains: why doesn't the matched frequency sound matching at all? Why did I have to retune my channel 2 notes, intended to inspire channel 3, to something horrible like assuming an octave is 10.5 notes instead of 12? Periodic noise with a period of twice the base should still sound in tune. And yet... nope! Why? 🙁

Reply 2 of 2, by sinuspi

User metadata
Rank Newbie
Rank
Newbie

Oh dear. Is it the dreaded 15/16 bit shifting in the noise routine..? 😱