Lynx: fix load LFSR

This commit is contained in:
tildearrow 2024-11-08 02:00:58 -05:00
parent ec40b72740
commit 7c1d8ef4bb
2 changed files with 11 additions and 10 deletions

View file

@ -229,8 +229,9 @@ void DivPlatformLynx::tick(bool sysTick) {
} }
if (chan[i].std.ex1.had) { if (chan[i].std.ex1.had) {
WRITE_LFSR(i, chan[i].std.ex1.val&0xff); chan[i].lfsr=chan[i].std.ex1.val&0xfff;
WRITE_OTHER(i, (chan[i].std.ex1.val&0xf00)>>4); chan[i].freqChanged=true;
chan[i].updateLFSR=true;
} }
if (chan[i].std.phaseReset.had) { if (chan[i].std.phaseReset.had) {
@ -243,8 +244,8 @@ void DivPlatformLynx::tick(bool sysTick) {
chan[i].samplePos=0; chan[i].samplePos=0;
} }
} }
WRITE_LFSR(i, 0); chan[i].freqChanged=true;
WRITE_OTHER(i, 0); chan[i].updateLFSR=true;
} }
} }
@ -262,10 +263,9 @@ void DivPlatformLynx::tick(bool sysTick) {
chan[i].sampleFreq=off*parent->calcFreq(chan[i].sampleBaseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE); chan[i].sampleFreq=off*parent->calcFreq(chan[i].sampleBaseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE);
if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].sampleFreq); if (dumpWrites) addWrite(0xffff0001+(i<<8),chan[i].sampleFreq);
} else { } else {
if (chan[i].lfsr >= 0) { if (chan[i].updateLFSR) {
WRITE_LFSR(i, (chan[i].lfsr&0xff)); WRITE_LFSR(i, (chan[i].lfsr&0xff));
WRITE_OTHER(i, ((chan[i].lfsr&0xf00)>>4)); WRITE_OTHER(i, ((chan[i].lfsr&0xf00)>>4));
chan[i].lfsr=-1;
} }
if (chan[i].std.duty.had) { if (chan[i].std.duty.had) {
chan[i].duty=chan[i].std.duty.val; chan[i].duty=chan[i].std.duty.val;
@ -341,8 +341,7 @@ int DivPlatformLynx::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true; chan[c.chan].freqChanged=true;
chan[c.chan].note=c.value; chan[c.chan].note=c.value;
chan[c.chan].actualNote=c.value; chan[c.chan].actualNote=c.value;
if (chan[c.chan].lfsr<0) chan[c.chan].updateLFSR=true;
chan[c.chan].lfsr=0;
} }
chan[c.chan].active=true; chan[c.chan].active=true;
WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127))); WRITE_VOLUME(c.chan,(isMuted[c.chan]?0:(chan[c.chan].vol&127)));
@ -365,6 +364,7 @@ int DivPlatformLynx::dispatch(DivCommand c) {
case DIV_CMD_LYNX_LFSR_LOAD: case DIV_CMD_LYNX_LFSR_LOAD:
chan[c.chan].freqChanged=true; chan[c.chan].freqChanged=true;
chan[c.chan].lfsr=c.value; chan[c.chan].lfsr=c.value;
chan[c.chan].updateLFSR=true;
break; break;
case DIV_CMD_NOTE_OFF_ENV: case DIV_CMD_NOTE_OFF_ENV:
case DIV_CMD_ENV_RELEASE: case DIV_CMD_ENV_RELEASE:

View file

@ -45,14 +45,14 @@ class DivPlatformLynx: public DivDispatch {
MikeyDuty duty; MikeyDuty duty;
int actualNote, lfsr, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq; int actualNote, lfsr, sample, samplePos, sampleAccum, sampleBaseFreq, sampleFreq;
unsigned char pan; unsigned char pan;
bool pcm, setPos; bool pcm, setPos, updateLFSR;
int macroVolMul; int macroVolMul;
Channel(): Channel():
SharedChannel<signed char>(127), SharedChannel<signed char>(127),
fd(0), fd(0),
duty(0), duty(0),
actualNote(0), actualNote(0),
lfsr(-1), lfsr(0),
sample(-1), sample(-1),
samplePos(0), samplePos(0),
sampleAccum(0), sampleAccum(0),
@ -61,6 +61,7 @@ class DivPlatformLynx: public DivDispatch {
pan(0xff), pan(0xff),
pcm(false), pcm(false),
setPos(false), setPos(false),
updateLFSR(false),
macroVolMul(127) {} macroVolMul(127) {}
}; };
Channel chan[4]; Channel chan[4];