aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2016-01-19 03:19:13 +0100
committerMartin Kiewitz2016-01-19 03:19:13 +0100
commit05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8 (patch)
treee2f79e3616a5c18d80f2accc9f79058972ea2548 /engines
parentd7420c9128fc9a5b5e38472d05444d82d48d8d13 (diff)
downloadscummvm-rg350-05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8.tar.gz
scummvm-rg350-05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8.tar.bz2
scummvm-rg350-05fb12eb632b316cb7d1a4df8b9d2a7c8d27e2e8.zip
AGI: reverse stereo for Apple IIgs + cleanup
According to Apple IIgs emulator and recorded music on Apple IIgs, it seems that stereo was reversed. Melody in games seems to be playing on left channel and not on the right one.
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/sound_2gs.cpp25
-rw-r--r--engines/agi/sound_2gs.h10
2 files changed, 20 insertions, 15 deletions
diff --git a/engines/agi/sound_2gs.cpp b/engines/agi/sound_2gs.cpp
index e054c16c12..af1ff435a6 100644
--- a/engines/agi/sound_2gs.cpp
+++ b/engines/agi/sound_2gs.cpp
@@ -206,16 +206,16 @@ uint SoundGen2GS::generateOutput() {
// Take envelope and MIDI volume information into account.
// Also amplify.
- s0 *= vol * g->vel / 127 * 80 / 256;
- s1 *= vol * g->vel / 127 * 80 / 256;
+ s0 *= vol * g->velocity / 127 * 80 / 256;
+ s1 *= vol * g->velocity / 127 * 80 / 256;
// Select output channel.
- if (g->osc[0].chn)
+ if (g->osc[0].rightChannel)
outl += s0;
else
outr += s0;
- if (g->osc[1].chn)
+ if (g->osc[1].rightChannel)
outl += s1;
else
outr += s1;
@@ -361,7 +361,7 @@ void SoundGen2GS::advanceMidiPlayer() {
void SoundGen2GS::midiNoteOff(int channel, int note, int velocity) {
// Release keys within the given MIDI channel
for (int i = 0; i < MAX_GENERATORS; i++) {
- if (_generators[i].chn == channel && _generators[i].key == note)
+ if (_generators[i].channel == channel && _generators[i].key == note)
_generators[i].seg = _generators[i].ins->seg;
}
}
@@ -384,8 +384,8 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
velocity = 127;
g->key = note;
- g->vel = velocity * _channels[channel].getVolume() / 127;
- g->chn = channel;
+ g->velocity = velocity * _channels[channel].getVolume() / 127;
+ g->channel = channel;
// Instruments can define different samples to be used based on
// what the key is. Find the correct samples for our key.
@@ -404,7 +404,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
g->osc[0].halt = i->wave[0][wa].halt;
g->osc[0].loop = i->wave[0][wa].loop;
g->osc[0].swap = i->wave[0][wa].swap;
- g->osc[0].chn = i->wave[0][wa].chn;
+ g->osc[0].rightChannel = i->wave[0][wa].rightChannel;
g->osc[1].base = i->base + i->wave[1][wb].offset;
g->osc[1].size = i->wave[1][wb].size;
@@ -413,7 +413,7 @@ void SoundGen2GS::midiNoteOn(int channel, int note, int velocity) {
g->osc[1].halt = i->wave[1][wb].halt;
g->osc[1].loop = i->wave[1][wb].loop;
g->osc[1].swap = i->wave[1][wb].swap;
- g->osc[1].chn = i->wave[1][wb].chn;
+ g->osc[1].rightChannel = i->wave[1][wb].rightChannel;
g->seg = 0;
g->a = 0;
@@ -551,7 +551,12 @@ bool IIgsInstrumentHeader::read(Common::SeekableReadStream &stream, bool ignoreA
wave[i][k].halt = b & 0x1; // Bit 0 = HALT
wave[i][k].loop = !(b & 0x2); // Bit 1 =!LOOP
wave[i][k].swap = (b & 0x6) == 0x6; // Bit 1&2 = SWAP
- wave[i][k].chn = (b >> 4) > 0; // Output channel (left or right)
+ // channels seem to be reversed, verified with emulator + captured apple IIgs music
+ if (b >> 4) {
+ wave[i][k].rightChannel = false; // Bit 4 set = left channel
+ } else {
+ wave[i][k].rightChannel = true; // Bit 4 not set = right channel
+ }
}
}
diff --git a/engines/agi/sound_2gs.h b/engines/agi/sound_2gs.h
index 4eaba528cc..51426e090e 100644
--- a/engines/agi/sound_2gs.h
+++ b/engines/agi/sound_2gs.h
@@ -85,7 +85,7 @@ struct IIgsInstrumentHeader {
bool halt; ///< Oscillator halted?
bool loop; ///< Loop mode?
bool swap; ///< Swap mode?
- bool chn; ///< Output channel (left / right)
+ bool rightChannel; ///< Output channel (left / right)
int16 tune; ///< Fine tune in semitones (8.8 fixed point)
} wave[2][MAX_OSCILLATOR_WAVES];
@@ -122,7 +122,7 @@ struct IIgsSampleHeader {
class IIgsGenerator {
public:
- IIgsGenerator() : ins(NULL), key(-1), chn(-1) {
+ IIgsGenerator() : ins(NULL), key(-1), channel(-1) {
memset(&osc, 0, sizeof(osc));
seg = 0;
a = 0;
@@ -130,8 +130,8 @@ public:
const IIgsInstrumentHeader *ins; ///< Currently used instrument
int key; ///< MIDI key
- int vel; ///< MIDI velocity (& channel volume)
- int chn; ///< MIDI channel
+ int velocity; ///< MIDI velocity (& channel volume)
+ int channel; ///< MIDI channel
struct {
int8 *base; ///< Sample base pointer
uint size; ///< Sample size
@@ -140,7 +140,7 @@ public:
bool halt; ///< Is oscillator halted?
bool loop; ///< Is looping enabled?
bool swap; ///< Is swapping enabled?
- bool chn; ///< Output channel (left / right)
+ bool rightChannel; ///< Output channel (left / right)
} osc[2];
int seg; ///< Current envelope segment
frac_t a; ///< Current envelope amplitude