more comments in LFO code
This commit is contained in:
parent
1d4e6ab2bd
commit
6bf1cc1da1
@ -131,55 +131,69 @@ h0590:
|
|||||||
void Synth::runLFO() {
|
void Synth::runLFO() {
|
||||||
// compute a loop's worth of LFO
|
// compute a loop's worth of LFO
|
||||||
|
|
||||||
uint16_t a, b, c, d;
|
uint16_t bc, ea;
|
||||||
uint16_t bc, hl, ea, tos;
|
|
||||||
|
|
||||||
// 074e
|
// 074e
|
||||||
ea = ff4d; // lfo value
|
ea = ff4d; // lfo value
|
||||||
bc = lfoRateTable[patchRam.lfoRate];
|
bc = lfoRateTable[patchRam.lfoRate];
|
||||||
|
|
||||||
|
// bit zero is low for rising slope, high for falling
|
||||||
if (!(ff4a & 0x01)) goto h078b;
|
if (!(ff4a & 0x01)) goto h078b;
|
||||||
|
|
||||||
|
// 075b DSUBNB EA, BC subtract BC from EA, skip next instruction if EA < BC
|
||||||
|
// 075d JRE 079a routine that handles flipping from down to up
|
||||||
ea -= bc;
|
ea -= bc;
|
||||||
if (ea < bc) goto h079a;
|
if (ea < bc) goto h079a;
|
||||||
h075f:
|
|
||||||
ff4d = ea;
|
|
||||||
if (!(ff4a & 0x02)) goto h07a2;
|
|
||||||
|
|
||||||
// 0765
|
h075f:
|
||||||
|
ff4d = ea; // LFO output variable
|
||||||
|
|
||||||
|
// bit one seems to be used to represent negative values of LFO
|
||||||
|
if (!(ff4a & 0x02)) goto h07a2; // routine that adds on 0x2000 to ea
|
||||||
|
|
||||||
|
// 0765 LFO is negative (bit 1 is high) so invert the value of EA
|
||||||
|
// so that we have a positive-only LFO running from 0 to 0x3fff
|
||||||
bc = ea;
|
bc = ea;
|
||||||
ea = 0x2000;
|
ea = 0x2000;
|
||||||
ea -= bc;
|
ea -= bc;
|
||||||
h076b:
|
h076b:
|
||||||
bc = ea;
|
bc = ea; // BC now contains an LFO range from 0 to 0x3fff, always positive
|
||||||
if (patchRam.switch2 & 0x01) {
|
if (patchRam.switch2 & 0x01) { // LFO Manual?
|
||||||
bc = 0x3fff;
|
bc = 0x3fff; // fixed maximum value
|
||||||
}
|
}
|
||||||
|
|
||||||
bc = (bc * patchRam.pwmLfo) >> 7;
|
// 0771
|
||||||
bc = 0x3fff - bc;
|
bc = (bc * patchRam.pwmLfo) >> 7; // scale by PWM pot amount
|
||||||
|
|
||||||
|
// 077d
|
||||||
|
bc = 0x3fff - bc; // invert so pot = 0 gives 0x3fff
|
||||||
|
|
||||||
|
// test if squarewave is on or off - if it's off set PW to 0
|
||||||
if (!(patchRam.switch1 & 0x08)) bc = 0x0000; // square off
|
if (!(patchRam.switch1 & 0x08)) bc = 0x0000; // square off
|
||||||
|
|
||||||
|
// final computed PWM value
|
||||||
ff4f = bc;
|
ff4f = bc;
|
||||||
|
|
||||||
// 078a
|
// 078a
|
||||||
goto h07a9;
|
goto h07a9;
|
||||||
|
|
||||||
h078b:
|
h078b:
|
||||||
|
// BC contains rate, EA contains LFO value
|
||||||
ea += bc;
|
ea += bc;
|
||||||
if (ea & 0xe000) {
|
if (ea & 0xe000) { // if we've exceeded 0x1fff
|
||||||
ea = 0x1fff;
|
ea = 0x1fff; // clamp
|
||||||
ff4a++;
|
ff4a++; // increment the flags
|
||||||
}
|
}
|
||||||
goto h075f;
|
goto h075f; // store in LFO output variable
|
||||||
|
|
||||||
h079a:
|
h079a:
|
||||||
ea = 0;
|
ea = 0; // output is close (enough) to zero, clamp
|
||||||
ff4a++;
|
ff4a++; // increment the flags
|
||||||
goto h075f;
|
goto h075f; // store in LFO output variable
|
||||||
|
|
||||||
h07a2:
|
h07a2: // LFO output is positive
|
||||||
ea += 0x2000;
|
ea += 0x2000; // add on 0x2000 to scale PWM to 0 - 0x3fff
|
||||||
goto h076b;
|
goto h076b; // jump back to scale LFO amount
|
||||||
|
|
||||||
h07a9:
|
h07a9:
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user