phase reset effects & fix wavetable change
This commit is contained in:
parent
cc87178e41
commit
0ea53fdae5
|
@ -282,6 +282,10 @@ enum DivDispatchCmds {
|
||||||
DIV_CMD_C64_PW_SLIDE,
|
DIV_CMD_C64_PW_SLIDE,
|
||||||
DIV_CMD_C64_CUTOFF_SLIDE,
|
DIV_CMD_C64_CUTOFF_SLIDE,
|
||||||
|
|
||||||
|
DIV_CMD_SID3_PHASE_RESET,
|
||||||
|
DIV_CMD_SID3_NOISE_PHASE_RESET,
|
||||||
|
DIV_CMD_SID3_ENVELOPE_RESET,
|
||||||
|
|
||||||
DIV_CMD_MAX
|
DIV_CMD_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,7 @@ void DivPlatformSID3::updatePanning(int channel)
|
||||||
rWrite(SID3_REGISTER_PAN_RIGHT + channel*SID3_REGISTERS_PER_CHANNEL,chan[channel].panRight);
|
rWrite(SID3_REGISTER_PAN_RIGHT + channel*SID3_REGISTERS_PER_CHANNEL,chan[channel].panRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivPlatformSID3::updateWave()
|
void DivPlatformSID3::updateWave()
|
||||||
{
|
{
|
||||||
int channel = SID3_NUM_CHANNELS - 1;
|
int channel = SID3_NUM_CHANNELS - 1;
|
||||||
|
|
||||||
|
@ -272,10 +272,16 @@ void DivPlatformSID3::updateWave()
|
||||||
|
|
||||||
void DivPlatformSID3::tick(bool sysTick)
|
void DivPlatformSID3::tick(bool sysTick)
|
||||||
{
|
{
|
||||||
|
bool doUpdateWave = false;
|
||||||
|
|
||||||
for (int i=0; i<SID3_NUM_CHANNELS; i++)
|
for (int i=0; i<SID3_NUM_CHANNELS; i++)
|
||||||
{
|
{
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
|
|
||||||
|
bool panChanged = false;
|
||||||
|
bool flagsChanged = false;
|
||||||
|
bool envChanged = false;
|
||||||
|
|
||||||
if(sysTick)
|
if(sysTick)
|
||||||
{
|
{
|
||||||
if(chan[i].pw_slide != 0)
|
if(chan[i].pw_slide != 0)
|
||||||
|
@ -293,11 +299,35 @@ void DivPlatformSID3::tick(bool sysTick)
|
||||||
updateFilter(i, j);
|
updateFilter(i, j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool panChanged = false;
|
if(chan[i].phase_reset_counter >= 0)
|
||||||
bool flagsChanged = false;
|
{
|
||||||
bool envChanged = false;
|
if(chan[i].phase_reset_counter == 0)
|
||||||
|
{
|
||||||
|
chan[i].phaseReset = true;
|
||||||
|
flagsChanged = true;
|
||||||
|
}
|
||||||
|
chan[i].phase_reset_counter--;
|
||||||
|
}
|
||||||
|
if(chan[i].noise_phase_reset_counter >= 0)
|
||||||
|
{
|
||||||
|
if(chan[i].noise_phase_reset_counter == 0)
|
||||||
|
{
|
||||||
|
chan[i].phaseResetNoise = true;
|
||||||
|
flagsChanged = true;
|
||||||
|
}
|
||||||
|
chan[i].noise_phase_reset_counter--;
|
||||||
|
}
|
||||||
|
if(chan[i].envelope_reset_counter >= 0)
|
||||||
|
{
|
||||||
|
if(chan[i].envelope_reset_counter == 0)
|
||||||
|
{
|
||||||
|
chan[i].envReset = true;
|
||||||
|
flagsChanged = true;
|
||||||
|
}
|
||||||
|
chan[i].envelope_reset_counter--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (chan[i].std.vol.had)
|
if (chan[i].std.vol.had)
|
||||||
{
|
{
|
||||||
|
@ -337,7 +367,8 @@ void DivPlatformSID3::tick(bool sysTick)
|
||||||
if(i == SID3_NUM_CHANNELS - 1 && ins->sid3.doWavetable)
|
if(i == SID3_NUM_CHANNELS - 1 && ins->sid3.doWavetable)
|
||||||
{
|
{
|
||||||
chan[i].wavetable = chan[i].std.wave.val & 0xff;
|
chan[i].wavetable = chan[i].std.wave.val & 0xff;
|
||||||
ws.changeWave1(chan[i].wave);
|
ws.changeWave1(chan[i].wavetable, true);
|
||||||
|
doUpdateWave = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -653,9 +684,15 @@ void DivPlatformSID3::tick(bool sysTick)
|
||||||
{
|
{
|
||||||
if (ws.tick())
|
if (ws.tick())
|
||||||
{
|
{
|
||||||
updateWave();
|
doUpdateWave = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(doUpdateWave)
|
||||||
|
{
|
||||||
|
updateWave();
|
||||||
|
doUpdateWave = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformSID3::dispatch(DivCommand c) {
|
int DivPlatformSID3::dispatch(DivCommand c) {
|
||||||
|
@ -1026,6 +1063,15 @@ int DivPlatformSID3::dispatch(DivCommand c) {
|
||||||
filter = abs(c.value2) - 1;
|
filter = abs(c.value2) - 1;
|
||||||
chan[c.chan].filt[filter].cutoff_slide = c.value * (c.value2 > 0 ? 1 : -1) * 16;
|
chan[c.chan].filt[filter].cutoff_slide = c.value * (c.value2 > 0 ? 1 : -1) * 16;
|
||||||
break;
|
break;
|
||||||
|
case DIV_CMD_SID3_PHASE_RESET:
|
||||||
|
chan[c.chan].phase_reset_counter = c.value;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_SID3_NOISE_PHASE_RESET:
|
||||||
|
chan[c.chan].noise_phase_reset_counter = c.value;
|
||||||
|
break;
|
||||||
|
case DIV_CMD_SID3_ENVELOPE_RESET:
|
||||||
|
chan[c.chan].envelope_reset_counter = c.value;
|
||||||
|
break;
|
||||||
case DIV_CMD_SAMPLE_POS:
|
case DIV_CMD_SAMPLE_POS:
|
||||||
chan[c.chan].dacPos=c.value;
|
chan[c.chan].dacPos=c.value;
|
||||||
break;
|
break;
|
||||||
|
@ -1147,6 +1193,10 @@ void DivPlatformSID3::reset() {
|
||||||
chan[i].noiseLFSRMask = (1 << 29) | (1 << 5) | (1 << 3) | 1; //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1
|
chan[i].noiseLFSRMask = (1 << 29) | (1 << 5) | (1 << 3) | 1; //https://docs.amd.com/v/u/en-US/xapp052 for 30 bits: 30, 6, 4, 1
|
||||||
|
|
||||||
chan[i].pw_slide = 0;
|
chan[i].pw_slide = 0;
|
||||||
|
|
||||||
|
chan[i].phase_reset_counter = -1;
|
||||||
|
chan[i].noise_phase_reset_counter = -1;
|
||||||
|
chan[i].envelope_reset_counter = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sampleTick = 0;
|
sampleTick = 0;
|
||||||
|
@ -1194,6 +1244,28 @@ void DivPlatformSID3::setFlags(const DivConfig& flags) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DivChannelPair DivPlatformSID3::getPaired(int ch)
|
||||||
|
{
|
||||||
|
if(chan[ch].phase)
|
||||||
|
{
|
||||||
|
return DivChannelPair("phase", chan[ch].phaseSrc);
|
||||||
|
}
|
||||||
|
if(chan[ch].ring)
|
||||||
|
{
|
||||||
|
if(chan[ch].ringSrc == SID3_NUM_CHANNELS)
|
||||||
|
{
|
||||||
|
return DivChannelPair("ring", ch);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DivChannelPair("ring", chan[ch].ringSrc);
|
||||||
|
}
|
||||||
|
if(chan[ch].sync)
|
||||||
|
{
|
||||||
|
return DivChannelPair("sync", chan[ch].syncSrc);
|
||||||
|
}
|
||||||
|
return DivChannelPair();
|
||||||
|
}
|
||||||
|
|
||||||
int DivPlatformSID3::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
int DivPlatformSID3::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||||
parent=p;
|
parent=p;
|
||||||
dumpWrites=false;
|
dumpWrites=false;
|
||||||
|
|
|
@ -84,6 +84,10 @@ class DivPlatformSID3: public DivDispatch {
|
||||||
|
|
||||||
short pw_slide;
|
short pw_slide;
|
||||||
|
|
||||||
|
short phase_reset_counter;
|
||||||
|
short noise_phase_reset_counter;
|
||||||
|
short envelope_reset_counter;
|
||||||
|
|
||||||
void handleArpNoise(int offset=0)
|
void handleArpNoise(int offset=0)
|
||||||
{
|
{
|
||||||
DivMacroStruct& m = this->std.op[3].am;
|
DivMacroStruct& m = this->std.op[3].am;
|
||||||
|
@ -182,7 +186,10 @@ class DivPlatformSID3: public DivDispatch {
|
||||||
dacSample(-1),
|
dacSample(-1),
|
||||||
phaseInv(0),
|
phaseInv(0),
|
||||||
feedback(0),
|
feedback(0),
|
||||||
pw_slide(0) {}
|
pw_slide(0),
|
||||||
|
phase_reset_counter(-1),
|
||||||
|
noise_phase_reset_counter(-1),
|
||||||
|
envelope_reset_counter(-1) {}
|
||||||
};
|
};
|
||||||
Channel chan[SID3_NUM_CHANNELS];
|
Channel chan[SID3_NUM_CHANNELS];
|
||||||
DivDispatchOscBuffer* oscBuf[SID3_NUM_CHANNELS];
|
DivDispatchOscBuffer* oscBuf[SID3_NUM_CHANNELS];
|
||||||
|
@ -243,6 +250,7 @@ class DivPlatformSID3: public DivDispatch {
|
||||||
const char** getRegisterSheet();
|
const char** getRegisterSheet();
|
||||||
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
||||||
int getOutputCount();
|
int getOutputCount();
|
||||||
|
DivChannelPair getPaired(int ch);
|
||||||
void quit();
|
void quit();
|
||||||
~DivPlatformSID3();
|
~DivPlatformSID3();
|
||||||
};
|
};
|
||||||
|
|
|
@ -279,8 +279,12 @@ const char* cmdName[]={
|
||||||
"SID3_FILTER_MATRIX",
|
"SID3_FILTER_MATRIX",
|
||||||
"SID3_FILTER_ENABLE",
|
"SID3_FILTER_ENABLE",
|
||||||
|
|
||||||
"DIV_CMD_C64_PW_SLIDE",
|
"C64_PW_SLIDE",
|
||||||
"DIV_CMD_C64_CUTOFF_SLIDE",
|
"C64_CUTOFF_SLIDE",
|
||||||
|
|
||||||
|
"SID3_PHASE_RESET",
|
||||||
|
"SID3_NOISE_PHASE_RESET",
|
||||||
|
"SID3_ENVELOPE_RESET",
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!");
|
static_assert((sizeof(cmdName)/sizeof(void*))==DIV_CMD_MAX,"update cmdName!");
|
||||||
|
|
|
@ -761,6 +761,10 @@ void DivEngine::registerSystems() {
|
||||||
{0xAB, {DIV_CMD_C64_CUTOFF_SLIDE, _("ABxx: Filter 3 cutoff slide down"), effectVal, constVal<-3>}},
|
{0xAB, {DIV_CMD_C64_CUTOFF_SLIDE, _("ABxx: Filter 3 cutoff slide down"), effectVal, constVal<-3>}},
|
||||||
{0xAC, {DIV_CMD_C64_CUTOFF_SLIDE, _("ACxx: Filter 4 cutoff slide up"), effectVal, constVal<4>}},
|
{0xAC, {DIV_CMD_C64_CUTOFF_SLIDE, _("ACxx: Filter 4 cutoff slide up"), effectVal, constVal<4>}},
|
||||||
{0xAD, {DIV_CMD_C64_CUTOFF_SLIDE, _("ADxx: Filter 4 cutoff slide down"), effectVal, constVal<-4>}},
|
{0xAD, {DIV_CMD_C64_CUTOFF_SLIDE, _("ADxx: Filter 4 cutoff slide down"), effectVal, constVal<-4>}},
|
||||||
|
|
||||||
|
{0xAE, {DIV_CMD_SID3_PHASE_RESET, _("AExx: Phase reset on tick xx")}},
|
||||||
|
{0xAF, {DIV_CMD_SID3_NOISE_PHASE_RESET, _("AFxx: Noise phase reset on tick xx")}},
|
||||||
|
{0xB0, {DIV_CMD_SID3_ENVELOPE_RESET, _("B0xx: Envelope reset on tick xx")}},
|
||||||
};
|
};
|
||||||
|
|
||||||
const EffectHandler SID3FineDutyHandler(DIV_CMD_C64_FINE_DUTY, _("5xxx: Set pulse width (0 to FFF)"), effectValLong<12>);
|
const EffectHandler SID3FineDutyHandler(DIV_CMD_C64_FINE_DUTY, _("5xxx: Set pulse width (0 to FFF)"), effectValLong<12>);
|
||||||
|
|
|
@ -431,11 +431,11 @@ const FurnaceGUIColors fxColors[256]={
|
||||||
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
|
|
||||||
// B0-BF
|
// B0-BF
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_SYS_PRIMARY,
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||||
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
GUI_COLOR_PATTERN_EFFECT_INVALID,
|
||||||
|
|
Loading…
Reference in a new issue