Fix AY89x0 regression
This commit is contained in:
parent
89ece073f6
commit
b8d2c51a14
5 changed files with 147 additions and 105 deletions
|
|
@ -115,7 +115,7 @@ const unsigned char dacLogTableAY[256]={
|
|||
|
||||
void DivPlatformAY8910::runDAC() {
|
||||
for (int i=0; i<3; i++) {
|
||||
if (chan[i].active && chan[i].psgMode.dac && chan[i].dac.sample!=-1) {
|
||||
if (chan[i].active && chan[i].currPSGMode.dac && chan[i].dac.sample!=-1) {
|
||||
chan[i].dac.period+=chan[i].dac.rate;
|
||||
bool end=false;
|
||||
bool changed=false;
|
||||
|
|
@ -215,22 +215,22 @@ void DivPlatformAY8910::acquire(short* bufL, short* bufR, size_t start, size_t l
|
|||
void DivPlatformAY8910::updateOutSel(bool immediate) {
|
||||
if (immediate) {
|
||||
immWrite(0x07,
|
||||
~((chan[0].psgMode.getTone())|
|
||||
((chan[1].psgMode.getTone())<<1)|
|
||||
((chan[2].psgMode.getTone())<<2)|
|
||||
((chan[0].psgMode.getNoise())<<2)|
|
||||
((chan[1].psgMode.getNoise())<<3)|
|
||||
((chan[2].psgMode.getNoise())<<4)|
|
||||
~((chan[0].currPSGMode.getTone())|
|
||||
((chan[1].currPSGMode.getTone())<<1)|
|
||||
((chan[2].currPSGMode.getTone())<<2)|
|
||||
((chan[0].currPSGMode.getNoise())<<2)|
|
||||
((chan[1].currPSGMode.getNoise())<<3)|
|
||||
((chan[2].currPSGMode.getNoise())<<4)|
|
||||
((!ioPortA)<<6)|
|
||||
((!ioPortB)<<7)));
|
||||
} else {
|
||||
rWrite(0x07,
|
||||
~((chan[0].psgMode.getTone())|
|
||||
((chan[1].psgMode.getTone())<<1)|
|
||||
((chan[2].psgMode.getTone())<<2)|
|
||||
((chan[0].psgMode.getNoise())<<2)|
|
||||
((chan[1].psgMode.getNoise())<<3)|
|
||||
((chan[2].psgMode.getNoise())<<4)|
|
||||
~((chan[0].currPSGMode.getTone())|
|
||||
((chan[1].currPSGMode.getTone())<<1)|
|
||||
((chan[2].currPSGMode.getTone())<<2)|
|
||||
((chan[0].currPSGMode.getNoise())<<2)|
|
||||
((chan[1].currPSGMode.getNoise())<<3)|
|
||||
((chan[2].currPSGMode.getNoise())<<4)|
|
||||
((!ioPortA)<<6)|
|
||||
((!ioPortB)<<7)));
|
||||
}
|
||||
|
|
@ -243,13 +243,13 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
if (chan[i].std.vol.had) {
|
||||
chan[i].outVol=MIN(15,chan[i].std.vol.val)-(15-(chan[i].vol&15));
|
||||
if (chan[i].outVol<0) chan[i].outVol=0;
|
||||
if (!chan[i].psgMode.dac) {
|
||||
if (!chan[i].nextPSGMode.dac) {
|
||||
if (isMuted[i]) {
|
||||
rWrite(0x08+i,0);
|
||||
} else if (intellivision && (chan[i].psgMode.getEnvelope())) {
|
||||
} else if (intellivision && (chan[i].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+i,(chan[i].outVol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -263,14 +263,17 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
rWrite(0x06,31-chan[i].std.duty.val);
|
||||
}
|
||||
if (chan[i].std.wave.had) {
|
||||
if (!chan[i].psgMode.dac) {
|
||||
chan[i].psgMode.val=(chan[i].std.wave.val+1)&7;
|
||||
if (!chan[i].nextPSGMode.dac) {
|
||||
chan[i].nextPSGMode.val=(chan[i].std.wave.val+1)&7;
|
||||
if (chan[i].active) {
|
||||
chan[i].currPSGMode.val=chan[i].nextPSGMode.val;
|
||||
}
|
||||
if (isMuted[i]) {
|
||||
rWrite(0x08+i,0);
|
||||
} else if (intellivision && (chan[i].psgMode.getEnvelope())) {
|
||||
} else if (intellivision && (chan[i].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+i,(chan[i].outVol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+i,(chan[i].outVol&15)|((chan[i].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -285,7 +288,7 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
}
|
||||
if (chan[i].std.phaseReset.had) {
|
||||
if (chan[i].std.phaseReset.val==1) {
|
||||
if (chan[i].psgMode.dac) {
|
||||
if (chan[i].nextPSGMode.dac) {
|
||||
if (dumpWrites) addWrite(0xffff0002+(i<<8),0);
|
||||
DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_AY);
|
||||
chan[i].dac.sample=ins->amiga.getSample(chan[i].note);
|
||||
|
|
@ -336,12 +339,12 @@ void DivPlatformAY8910::tick(bool sysTick) {
|
|||
if (chan[i].keyOn) {
|
||||
//rWrite(16+i*5+1,((chan[i].duty&3)<<6)|(63-(ins->gb.soundLen&63)));
|
||||
//rWrite(16+i*5+2,((chan[i].vol<<4))|(ins->gb.envLen&7)|((ins->gb.envDir&1)<<3));
|
||||
if (chan[i].psgMode.val==0) {
|
||||
chan[i].psgMode.val=1;
|
||||
if (!chan[i].nextPSGMode.dac) {
|
||||
chan[i].currPSGMode.val=chan[i].nextPSGMode.val;
|
||||
}
|
||||
}
|
||||
if (chan[i].keyOff) {
|
||||
chan[i].psgMode.val=0;
|
||||
chan[i].currPSGMode.val=0;
|
||||
rWrite(0x08+i,0);
|
||||
}
|
||||
rWrite((i)<<1,chan[i].freq&0xff);
|
||||
|
|
@ -392,11 +395,11 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
case DIV_CMD_NOTE_ON: {
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_AY);
|
||||
if (!parent->song.disableSampleMacro && (ins->type==DIV_INS_AMIGA || ins->amiga.useSample)) {
|
||||
chan[c.chan].psgMode.dac=true;
|
||||
chan[c.chan].nextPSGMode.dac=true;
|
||||
} else if (chan[c.chan].dac.furnaceDAC) {
|
||||
chan[c.chan].psgMode.dac=false;
|
||||
chan[c.chan].nextPSGMode.dac=false;
|
||||
}
|
||||
if (chan[c.chan].psgMode.dac) {
|
||||
if (chan[c.chan].nextPSGMode.dac) {
|
||||
if (skipRegisterWrites) break;
|
||||
if (!parent->song.disableSampleMacro && (ins->type==DIV_INS_AMIGA || ins->amiga.useSample)) {
|
||||
chan[c.chan].dac.sample=ins->amiga.getSample(c.value);
|
||||
|
|
@ -445,6 +448,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
}
|
||||
chan[c.chan].dac.furnaceDAC=false;
|
||||
}
|
||||
chan[c.chan].currPSGMode.dac=chan[c.chan].nextPSGMode.dac;
|
||||
break;
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
|
|
@ -458,13 +462,13 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) {
|
||||
chan[c.chan].outVol=chan[c.chan].vol;
|
||||
}
|
||||
if (!chan[c.chan].psgMode.dac) {
|
||||
if (!chan[c.chan].nextPSGMode.dac) {
|
||||
if (isMuted[c.chan]) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
} else if (intellivision && (chan[c.chan].psgMode.getEnvelope())) {
|
||||
} else if (intellivision && (chan[c.chan].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -472,7 +476,7 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
case DIV_CMD_NOTE_OFF:
|
||||
chan[c.chan].dac.sample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002+(c.chan<<8),0);
|
||||
chan[c.chan].psgMode.dac=false;
|
||||
chan[c.chan].nextPSGMode.dac=false;
|
||||
chan[c.chan].keyOff=true;
|
||||
chan[c.chan].active=false;
|
||||
chan[c.chan].macroInit(NULL);
|
||||
|
|
@ -486,15 +490,15 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
if (!chan[c.chan].std.vol.has) {
|
||||
chan[c.chan].outVol=c.value;
|
||||
}
|
||||
if (!chan[c.chan].psgMode.dac) {
|
||||
if (!chan[c.chan].nextPSGMode.dac) {
|
||||
if (isMuted[c.chan]) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
} else {
|
||||
if (chan[c.chan].active) {
|
||||
if (intellivision && (chan[c.chan].psgMode.getEnvelope())) {
|
||||
if (intellivision && (chan[c.chan].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -545,16 +549,19 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_STD_NOISE_MODE:
|
||||
if (!chan[c.chan].psgMode.dac) {
|
||||
if (!chan[c.chan].nextPSGMode.dac) {
|
||||
if (c.value<16) {
|
||||
chan[c.chan].psgMode.val=(c.value+1)&7;
|
||||
chan[c.chan].nextPSGMode.val=(c.value+1)&7;
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].currPSGMode.val=chan[c.chan].nextPSGMode.val;
|
||||
}
|
||||
if (isMuted[c.chan]) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
} else if (chan[c.chan].active) {
|
||||
if (intellivision && (chan[c.chan].psgMode.getEnvelope())) {
|
||||
if (intellivision && (chan[c.chan].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].outVol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].outVol&15)|((chan[c.chan].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+c.chan,(chan[c.chan].outVol&15)|((chan[c.chan].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -567,16 +574,19 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
ayEnvMode=c.value>>4;
|
||||
rWrite(0x0d,ayEnvMode);
|
||||
if (c.value&15) {
|
||||
chan[c.chan].psgMode.envelope|=1;
|
||||
chan[c.chan].nextPSGMode.envelope|=1;
|
||||
} else {
|
||||
chan[c.chan].psgMode.envelope&=~1;
|
||||
chan[c.chan].nextPSGMode.envelope&=~1;
|
||||
}
|
||||
if (!chan[c.chan].nextPSGMode.dac && chan[c.chan].active) {
|
||||
chan[c.chan].currPSGMode.val=chan[c.chan].nextPSGMode.val;
|
||||
}
|
||||
if (isMuted[c.chan]) {
|
||||
rWrite(0x08+c.chan,0);
|
||||
} else if (intellivision && (chan[c.chan].psgMode.getEnvelope())) {
|
||||
} else if (intellivision && (chan[c.chan].nextPSGMode.getEnvelope())) {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&0xc)<<2);
|
||||
} else {
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+c.chan,(chan[c.chan].vol&15)|((chan[c.chan].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_AY_ENVELOPE_LOW:
|
||||
|
|
@ -614,7 +624,10 @@ int DivPlatformAY8910::dispatch(DivCommand c) {
|
|||
immWrite(14+(c.value?1:0),(c.value?portBVal:portAVal));
|
||||
break;
|
||||
case DIV_CMD_SAMPLE_MODE:
|
||||
chan[c.chan].psgMode.dac=(c.value>0)?1:0;
|
||||
chan[c.chan].nextPSGMode.dac=(c.value>0)?1:0;
|
||||
if (chan[c.chan].active) {
|
||||
chan[c.chan].currPSGMode.dac=chan[c.chan].nextPSGMode.dac;
|
||||
}
|
||||
break;
|
||||
case DIV_CMD_SAMPLE_BANK:
|
||||
sampleBank=c.value;
|
||||
|
|
@ -650,13 +663,13 @@ void DivPlatformAY8910::muteChannel(int ch, bool mute) {
|
|||
isMuted[ch]=mute;
|
||||
if (isMuted[ch]) {
|
||||
rWrite(0x08+ch,0);
|
||||
} else if (chan[ch].active && chan[ch].psgMode.dac) {
|
||||
} else if (chan[ch].active && chan[ch].nextPSGMode.dac) {
|
||||
rWrite(0x08+ch,chan[ch].dac.out);
|
||||
} else {
|
||||
if (intellivision && (chan[ch].psgMode.getEnvelope()) && chan[ch].active) {
|
||||
if (intellivision && (chan[ch].nextPSGMode.getEnvelope()) && chan[ch].active) {
|
||||
rWrite(0x08+ch,(chan[ch].vol&0xc)<<2);
|
||||
} else if (chan[ch].active) {
|
||||
rWrite(0x08+ch,(chan[ch].outVol&15)|((chan[ch].psgMode.getEnvelope())<<2));
|
||||
rWrite(0x08+ch,(chan[ch].outVol&15)|((chan[ch].nextPSGMode.getEnvelope())<<2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue