Skip to content

Commit 9282932

Browse files
committed
Minor fixes
Oscillator reload, noise channel counter overflow
1 parent d5d3183 commit 9282932

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Tedsound.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#endif
88

99
#define PRECISION 0
10-
#define OSCRELOADVAL (0x3FF << PRECISION)
10+
#define OSCRELOADVAL (0x400 << PRECISION)
1111
#define AMP(X) ((unsigned int)(17.0f * pow(double(X), 1.5f)))
1212

1313
unsigned int TED::masterVolume;
@@ -248,12 +248,20 @@ void TED::renderSound(unsigned int nrsamples, short *buffer)
248248
oscCount[0] = OscReload[0] + (oscCount[0] - OSCRELOADVAL);
249249
}
250250
// Channel 2
251+
static bool channelOverFlow = false;
251252
if (dcOutput[1]) {
252253
FlipFlop[1] = 1;
253-
} else if ((oscCount[1] += oscStep) >= OSCRELOADVAL) {
254-
NoiseCounter = (NoiseCounter + 1) % 255;
255-
FlipFlop[1] ^= 1;
256-
oscCount[1] = OscReload[1] + (oscCount[1] - OSCRELOADVAL);
254+
}
255+
else {
256+
if (channelOverFlow)
257+
NoiseCounter = (NoiseCounter + 1) % 255;
258+
if ((oscCount[1] += oscStep) >= OSCRELOADVAL) {
259+
channelOverFlow = true;
260+
FlipFlop[1] ^= 1;
261+
oscCount[1] = OscReload[1] + (oscCount[1] - OSCRELOADVAL);
262+
}
263+
else
264+
channelOverFlow = false;
257265
}
258266
int s1on = (Snd1Status && FlipFlop[0]);
259267
int s2on = (Snd2Status && FlipFlop[1]);

0 commit comments

Comments
 (0)