Skip to content
This repository has been archived by the owner on Feb 12, 2021. It is now read-only.

Commit

Permalink
Correct oscillator frequency used in the gameblaster. Thanks OPLx, Gr…
Browse files Browse the repository at this point in the history
…eat 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
  • Loading branch information
qbix79 committed May 2, 2017
1 parent 3ab9a9a commit 8a33093
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/hardware/gameblaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -221,15 +223,15 @@ 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 */
saa->channels[ch].counter -= saa->channels[ch].freq;
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;
Expand Down

0 comments on commit 8a33093

Please sign in to comment.