X1-010: fix 17xx PCM - take 2

This commit is contained in:
tildearrow 2022-10-04 00:04:41 -05:00
parent 204af47421
commit 4695659ae4
2 changed files with 10 additions and 5 deletions

View file

@ -476,6 +476,7 @@ void DivPlatformX1_010::tick(bool sysTick) {
}
}
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,2,chan[i].pitch2,chipClock,chan[i].pcm?off:CHIP_FREQBASE);
if (chan[i].fixedFreq) chan[i].freq=chan[i].fixedFreq;
if (chan[i].pcm) {
if (chan[i].freq<1) chan[i].freq=1;
if (chan[i].freq>255) chan[i].freq=255;
@ -554,6 +555,7 @@ int DivPlatformX1_010::dispatch(DivCommand c) {
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
chan[c.chan].baseFreq=NoteX1_010(c.chan,chan[c.chan].note);
chan[c.chan].fixedFreq=0;
chan[c.chan].freqChanged=true;
}
} else {
@ -571,7 +573,8 @@ int DivPlatformX1_010::dispatch(DivCommand c) {
} else {
chan[c.chan].macroInit(NULL);
chan[c.chan].outVol=chan[c.chan].vol;
if ((12*sampleBank+c.value%12)>=parent->song.sampleLen) {
chan[c.chan].sample=12*sampleBank+c.value%12;
if (chan[c.chan].sample<0 || chan[c.chan].sample>=parent->song.sampleLen) {
chWrite(c.chan,0,0); // reset
chWrite(c.chan,1,0);
chWrite(c.chan,2,0);
@ -579,7 +582,7 @@ int DivPlatformX1_010::dispatch(DivCommand c) {
chWrite(c.chan,5,0);
break;
}
DivSample* s=parent->getSample(12*sampleBank+c.value%12);
DivSample* s=parent->getSample(chan[c.chan].sample);
if (isBanked) {
bankSlot[chan[c.chan].bankSlot]=sampleOffX1[chan[c.chan].sample]>>17;
unsigned int bankedOffs=(chan[c.chan].bankSlot<<17)|(sampleOffX1[chan[c.chan].sample]&0x1ffff);
@ -591,12 +594,14 @@ int DivPlatformX1_010::dispatch(DivCommand c) {
int end=(sampleOffX1[chan[c.chan].sample]+s->length8+0xfff)&~0xfff; // padded
chWrite(c.chan,5,(0x100-(end>>12))&0xff);
}
chan[c.chan].baseFreq=(((unsigned int)s->rate)<<4)/(chipClock/512);
// ????
chan[c.chan].fixedFreq=(((unsigned int)s->rate)<<4)/(chipClock/512);
chan[c.chan].freqChanged=true;
}
} else if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
chan[c.chan].baseFreq=NoteX1_010(c.chan,chan[c.chan].note);
chan[c.chan].fixedFreq=0;
chan[c.chan].freqChanged=true;
}
chan[c.chan].active=true;

View file

@ -68,7 +68,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
slide(0),
slidefrac(0) {}
};
int freq, baseFreq, pitch, pitch2, note;
int freq, baseFreq, fixedFreq, pitch, pitch2, note;
int wave, sample, ins;
unsigned char pan, autoEnvNum, autoEnvDen;
bool active, insChanged, envChanged, freqChanged, keyOn, keyOff, inPorta, furnacePCM, pcm;
@ -95,7 +95,7 @@ class DivPlatformX1_010: public DivDispatch, public vgsound_emu_mem_intf {
pitch2=0;
}
Channel():
freq(0), baseFreq(0), pitch(0), pitch2(0), note(0),
freq(0), baseFreq(0), fixedFreq(0), pitch(0), pitch2(0), note(0),
wave(-1), sample(-1), ins(-1),
pan(255), autoEnvNum(0), autoEnvDen(0),
active(false), insChanged(true), envChanged(true), freqChanged(false), keyOn(false), keyOff(false), inPorta(false), furnacePCM(false), pcm(false),