VOGONS

Common searches


First post, by ezzetabi2

User metadata
Rank Newbie
Rank
Newbie

I had an attack of nostalgia and I wanted to play the old Delphine game `Fade to Black' when I noticed the stereo output channels were swapped.
So I made a small patch to the .74 mixer code so now it can swap the audio output channels.

Maybe anyone is interested, so it is here.
Sorry for the second registration, but I forgot the email I used to the first one...

I put it inline so also guests can eventually download it.

diff -ru dosbox-0.74.bak/src/dosbox.cpp dosbox-0.74/src/dosbox.cpp
--- dosbox-0.74.bak/src/dosbox.cpp 2010-09-01 21:20:45.000000000 +0200
+++ dosbox-0.74/src/dosbox.cpp 2010-09-01 21:31:33.000000000 +0200
@@ -448,6 +448,9 @@
Pbool = secprop->Add_bool("nosound",Property::Changeable::OnlyAtStart,false);
Pbool->Set_help("Enable silent mode, sound is still emulated though.");

+ Pbool = secprop->Add_bool("swapstereo",Property::Changeable::OnlyAtStart,false);
+ Pbool->Set_help("Swaps the left and right stereo channels.");
+
Pint = secprop->Add_int("rate",Property::Changeable::OnlyAtStart,44100);
Pint->Set_values(rates);
Pint->Set_help("Mixer sample rate, setting any device's rate higher than this will probably lower their sound quality.");
diff -ru dosbox-0.74.bak/src/hardware/mixer.cpp dosbox-0.74/src/hardware/mixer.cpp
--- dosbox-0.74.bak/src/hardware/mixer.cpp 2010-09-01 21:20:45.000000000 +0200
+++ dosbox-0.74/src/hardware/mixer.cpp 2010-09-01 21:35:50.000000000 +0200
@@ -72,6 +72,7 @@
bool nosound;
Bit32u freq;
Bit32u blocksize;
+ bool swapstereo;
} mixer;

Bit8u MixTemp[MIXER_BUFSIZE];
@@ -167,6 +168,9 @@
Bitu mixpos=mixer.pos+done;
freq_index&=MIXER_REMAIN;
Bitu pos=0;Bitu new_pos;
+ int offset[2];
+ offset[0] = mixer.swapstereo ? 1:0;
+ offset[1] = mixer.swapstereo ? 0:1;

goto thestart;
for (;;) {
@@ -180,15 +184,15 @@
if ( sizeof( Type) == 1) {
if (!signeddata) {
if (stereo) {
- diff[0]=(((Bit8s)(data[pos*2+0] ^ 0x80)) << 8)-last[0];
- diff[1]=(((Bit8s)(data[pos*2+1] ^ 0x80)) << 8)-last[1];
+ diff[0]=(((Bit8s)(data[pos*2+offset[0]] ^ 0x80)) << 8)-last[0];
+ diff[1]=(((Bit8s)(data[pos*2+offset[1]] ^ 0x80)) << 8)-last[1];
} else {
diff[0]=(((Bit8s)(data[pos] ^ 0x80)) << 8)-last[0];
}
} else {
if (stereo) {
- diff[0]=(data[pos*2+0] << 8)-last[0];
- diff[1]=(data[pos*2+1] << 8)-last[1];
+ diff[0]=(data[pos*2+offset[0]] << 8)-last[0];
+ diff[1]=(data[pos*2+offset[1]] << 8)-last[1];
} else {
diff[0]=(data[pos] << 8)-last[0];
}
@@ -198,8 +202,8 @@
if (signeddata) {
if (stereo) {
if (nativeorder) {
- diff[0]=data[pos*2+0]-last[0];
- diff[1]=data[pos*2+1]-last[1];
Show last 25 lines
+							diff[0]=data[pos*2+offset[0]]-last[0];
+ diff[1]=data[pos*2+offset[1]]-last[1];
} else {
if ( sizeof( Type) == 2) {
diff[0]=(Bit16s)host_readw((HostPt)&data[pos*2+0])-last[0];
@@ -223,8 +227,8 @@
} else {
if (stereo) {
if (nativeorder) {
- diff[0]=(Bits)data[pos*2+0]-32768-last[0];
- diff[1]=(Bits)data[pos*2+1]-32768-last[1];
+ diff[0]=(Bits)data[pos*2+offset[0]]-32768-last[0];
+ diff[1]=(Bits)data[pos*2+offset[1]]-32768-last[1];
} else {
if ( sizeof( Type) == 2) {
diff[0]=(Bits)host_readw((HostPt)&data[pos*2+0])-32768-last[0];
@@ -621,6 +625,7 @@
mixer.freq=section->Get_int("rate");
mixer.nosound=section->Get_bool("nosound");
mixer.blocksize=section->Get_int("blocksize");
+ mixer.swapstereo=section->Get_bool("swapstereo");

/* Initialize the internal stuff */
mixer.channels=0;