diff options
author | Simon Howard | 2009-10-25 17:07:55 +0000 |
---|---|---|
committer | Simon Howard | 2009-10-25 17:07:55 +0000 |
commit | 14bcdd1008db070bc4a12be73e3f692c1990966e (patch) | |
tree | 2ca97805fa87bc0574cf3cc2d972b53fbdd98cdb | |
parent | a8e79308562fbcea7a39ed1846329959cbf343b3 (diff) | |
download | chocolate-doom-14bcdd1008db070bc4a12be73e3f692c1990966e.tar.gz chocolate-doom-14bcdd1008db070bc4a12be73e3f692c1990966e.tar.bz2 chocolate-doom-14bcdd1008db070bc4a12be73e3f692c1990966e.zip |
Emulate odd octave 7 behavior of Vanilla Doom.
Subversion-branch: /branches/opl-branch
Subversion-revision: 1725
-rw-r--r-- | src/i_oplmusic.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/i_oplmusic.c b/src/i_oplmusic.c index 474877d4..89e73f1a 100644 --- a/src/i_oplmusic.c +++ b/src/i_oplmusic.c @@ -739,6 +739,26 @@ static unsigned int FrequencyForVoice(opl_voice_t *voice) sub_index = (freq_index - 284) % (12 * 32); octave = (freq_index - 284) / (12 * 32); + // Once the seventh octave is reached, things break down. + // We can only go up to octave 7 as a maximum anyway (the OPL + // register only has three bits for octave number), but for the + // notes in octave 7, the first five bits have octave=7, the + // following notes have octave=6. This 7/6 pattern repeats in + // following octaves (which are technically impossible to + // represent anyway). + + if (octave >= 7) + { + if (sub_index < 5) + { + octave = 7; + } + else + { + octave = 6; + } + } + // Calculate the resulting register value to use for the frequency. return frequency_curve[sub_index + 284] | (octave << 10); |