diff --git a/src/engine/platform/es5506.cpp b/src/engine/platform/es5506.cpp index ee7db20fa..5a7c01c08 100644 --- a/src/engine/platform/es5506.cpp +++ b/src/engine/platform/es5506.cpp @@ -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.initSamplesong.sampleLen))) { + if (c.value!=DIV_NOTE_NULL) { int sample=ins->amiga.getSample(c.value); chan[c.chan].sampleNote=c.value; if (sample>=0 && samplesong.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 && samplesong.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;