First post, by TheGreatCodeholio
- Rank
- Oldbie
I was writing some code just for the hell of it to initialize and play sound through the (fake) GUS provided by DOSBox. The Gravis SDK documents a panning register, but DOSBox doesn't seem to be emulating it at all. Everything is stuck in center, no matter how you modify the panning register. [DOSBox 0.74]
I did a quick hack to hardware/gus.cpp to modify how the panning register is emulated. I noticed the original code computes a 16-step log from 0 to 15 but then applies it to both L and R in a mirrored fashion that might as well not have any effect. I modified it to zero out entries 0...7 of the pantable and then compute 8 steps on the other side, with the 15th entry as large as possible to silence the channel. It's probably not quite accurate and might be far away from what the actual GUS does but it seems to bring out stereo music in a lot of old DOS demos.
new code:
src/hardware/gus.cpp
void WritePanPot(Bit8u val) {
PanPot = val;
if ((val & 0xf) >= 8 ) PanLeft = pantable[val & 0xf];
else PanLeft = 0;
if ((val & 0xf) < 7) PanRight = pantable[0xf - (val & 0xf)];
else PanRight = 0;
UpdateVolumes();
}
....................
// Generate logarithmic to linear volume conversion tables
static void MakeTables(void) {
int i;
double out = (double)(1 << 13);
for (i=4095;i>=0;i--) {
vol16bit=(Bit16s)out;
out/=1.002709201; /* 0.0235 dB Steps */
}
for (i=0;i < 8;i++)
pantable = 0;
for (i=8;i < 15;i++)
pantable=(Bit32u)(-128.0*(log((double)(15-i)/7.0)/log(2.0))*(double)(1 << RAMP_FRACT));
/* if the program cranks the pan register all the way, ensure the
* opposite channel is crushed to silence */
pantable[15] = 1UL << 30UL;
}
Also before I forget, I think I also found a typo in sblaster.cpp that affects 2-bit ADPCM decoding. Is the last row of scaleMap[] supposed to be "6, 48, -16, -48" ?