From 8a33093ff03b36669d7cd86cc3453eb9665ec418 Mon Sep 17 00:00:00 2001 From: qbix79 Date: Tue, 2 May 2017 14:14:46 +0000 Subject: [PATCH] Correct oscillator frequency used in the gameblaster. Thanks OPLx, Great Hierophant and NewRisingSun. Reported on VOGONS: 38350. git-svn-id: svn://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4010 67dff46e-583c-4055-8ee1-d6b00ecfda6c --- src/hardware/gameblaster.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hardware/gameblaster.cpp b/src/hardware/gameblaster.cpp index 267ada733..dffda0d0a 100644 --- a/src/hardware/gameblaster.cpp +++ b/src/hardware/gameblaster.cpp @@ -32,6 +32,8 @@ #define RIGHT 0x01 #define CMS_BUFFER_SIZE 128 #define CMS_RATE 22050 +/*#define MASTER_CLOCK 14318180/2 */ +#define MASTER_CLOCK 7159090 typedef Bit8u UINT8; @@ -205,9 +207,9 @@ static void saa1099_update(int chip, INT16 **buffer, int length) { switch (saa->noise_params[ch]) { - case 0: saa->noise[ch].freq = 31250.0 * 2; break; - case 1: saa->noise[ch].freq = 15625.0 * 2; break; - case 2: saa->noise[ch].freq = 7812.5 * 2; break; + case 0: saa->noise[ch].freq = MASTER_CLOCK/256 * 2; break; + case 1: saa->noise[ch].freq = MASTER_CLOCK/512 * 2; break; + case 2: saa->noise[ch].freq = MASTER_CLOCK/1024 * 2; break; case 3: saa->noise[ch].freq = saa->channels[ch * 3].freq; break; } } @@ -221,7 +223,7 @@ static void saa1099_update(int chip, INT16 **buffer, int length) for (ch = 0; ch < 6; ch++) { if (saa->channels[ch].freq == 0.0) - saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) / + saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) / (511.0 - (double)saa->channels[ch].frequency); /* check the actual position in the square wave */ @@ -229,7 +231,7 @@ static void saa1099_update(int chip, INT16 **buffer, int length) while (saa->channels[ch].counter < 0) { /* calculate new frequency now after the half wave is updated */ - saa->channels[ch].freq = (double)((2 * 15625) << saa->channels[ch].octave) / + saa->channels[ch].freq = (double)((2 * MASTER_CLOCK/512) << saa->channels[ch].octave) / (511.0 - (double)saa->channels[ch].frequency); saa->channels[ch].counter += sample_rate;