ES5506: and now fix 0Cxx

issue #1733
This commit is contained in:
tildearrow 2024-02-02 21:14:13 -05:00
parent f49cc6c7c9
commit 79df7c3de9

View file

@ -719,13 +719,18 @@ void DivPlatformES5506::tick(bool sysTick) {
}
}
// man this code
// part of the reason why it's so messy is because the chip is
// overly complex and because when this pull request was made,
// Furnace still was in an early state with no support for sample
// maps or whatever...
// one day I'll come back and clean this up
int DivPlatformES5506::dispatch(DivCommand c) {
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_ES5506);
bool sampleValid=false;
if (((ins->amiga.useNoteMap) && (c.value>=0 && c.value<120)) ||
((!ins->amiga.useNoteMap) && (ins->amiga.initSample>=0 && ins->amiga.initSample<parent->song.sampleLen))) {
if (c.value!=DIV_NOTE_NULL) {
int sample=ins->amiga.getSample(c.value);
chan[c.chan].sampleNote=c.value;
if (sample>=0 && sample<parent->song.sampleLen) {
@ -741,6 +746,20 @@ int DivPlatformES5506::dispatch(DivCommand c) {
} else {
chan[c.chan].sampleNoteDelta=0;
}
} else {
int sample=ins->amiga.getSample(chan[c.chan].sampleNote);
if (sample>=0 && sample<parent->song.sampleLen) {
sampleValid=true;
chan[c.chan].volMacroMax=ins->type==DIV_INS_AMIGA?64:0xfff;
chan[c.chan].panMacroMax=ins->type==DIV_INS_AMIGA?127:0xfff;
chan[c.chan].pcm.next=ins->amiga.useNoteMap?chan[c.chan].sampleNote:sample;
c.value=ins->amiga.getFreq(chan[c.chan].sampleNote);
chan[c.chan].pcm.note=c.value;
chan[c.chan].filter=ins->es5506.filter;
chan[c.chan].envelope=ins->es5506.envelope;
} else {
chan[c.chan].sampleNoteDelta=0;
}
}
if (!sampleValid) {
chan[c.chan].pcm.index=chan[c.chan].pcm.next=-1;