diff options
author | Johannes Schickel | 2011-12-11 06:19:54 +0100 |
---|---|---|
committer | Johannes Schickel | 2011-12-11 06:24:33 +0100 |
commit | d14e75cdc7507c041f4fcb5a588107ddc3fb7c53 (patch) | |
tree | e7785c8b990988c0437d7a30570d5f67f6b5c838 /engines | |
parent | 54819a5448f8db1fd4588ebced63a390b9d0134f (diff) | |
download | scummvm-rg350-d14e75cdc7507c041f4fcb5a588107ddc3fb7c53.tar.gz scummvm-rg350-d14e75cdc7507c041f4fcb5a588107ddc3fb7c53.tar.bz2 scummvm-rg350-d14e75cdc7507c041f4fcb5a588107ddc3fb7c53.zip |
CINE: Make findNote behave like in the original.
This also reverts 42fd6975447b99f4a66ec411a62def2b3b49c5d6, which was wrong,
since I misread the assembly. Ooops.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cine/sound.cpp | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/engines/cine/sound.cpp b/engines/cine/sound.cpp index 35c379baee..0328466e76 100644 --- a/engines/cine/sound.cpp +++ b/engines/cine/sound.cpp @@ -249,16 +249,30 @@ private: void PCSoundDriver::findNote(int freq, int *note, int *oct) const { - *note = _noteTableCount - 1; - // It might seem odd that we start with 1 here, but the original has the - // same behavior. - for (int i = 1; i < _noteTableCount; ++i) { - if (_noteTable[i] <= freq) { + if (freq > 0x777) + *oct = 0; + else if (freq > 0x3BB) + *oct = 1; + else if (freq > 0x1DD) + *oct = 2; + else if (freq > 0x0EE) + *oct = 3; + else if (freq > 0x077) + *oct = 4; + else if (freq > 0x03B) + *oct = 5; + else if (freq > 0x01D) + *oct = 6; + else + *oct = 7; + + *note = 11; + for (int i = 0; i < 12; ++i) { + if (_noteTable[*oct * 12 + i] <= freq) { *note = i; break; } } - *oct = *note / 12; } void PCSoundDriver::resetChannel(int channel) { @@ -475,12 +489,11 @@ void AdLibSoundDriverINS::setChannelFrequency(int channel, int frequency) { if (ins->mode == 0 || ins->channel == 6) { int freq, note, oct; findNote(frequency, ¬e, &oct); - if (channel == 6) { - note %= 12; - } + if (channel == 6) + oct = 0; freq = _freqTable[note % 12]; OPLWriteReg(_opl, 0xA0 | channel, freq); - freq = ((note / 12) << 2) | ((freq & 0x300) >> 8); + freq = (oct << 2) | ((freq & 0x300) >> 8); if (ins->mode == 0) { freq |= 0x20; } @@ -543,14 +556,16 @@ void AdLibSoundDriverADL::setChannelFrequency(int channel, int frequency) { findNote(frequency, ¬e, &oct); if (ins->amDepth) { note = ins->amDepth; + oct = note / 12; } if (note < 0) { note = 0; + oct = 0; } freq = _freqTable[note % 12]; OPLWriteReg(_opl, 0xA0 | channel, freq); - freq = ((note / 12) << 2) | ((freq & 0x300) >> 8); + freq = (oct << 2) | ((freq & 0x300) >> 8); if (ins->mode == 0) { freq |= 0x20; } |