C64: fix dSID multi-chip
This commit is contained in:
parent
6bbb407863
commit
e8130caa52
|
@ -613,6 +613,24 @@ void DivPlatformC64::setFlags(const DivConfig& flags) {
|
||||||
keyPriority=flags.getBool("keyPriority",true);
|
keyPriority=flags.getBool("keyPriority",true);
|
||||||
testAD=((flags.getInt("testAttack",0)&15)<<4)|(flags.getInt("testDecay",0)&15);
|
testAD=((flags.getInt("testAttack",0)&15)<<4)|(flags.getInt("testDecay",0)&15);
|
||||||
testSR=((flags.getInt("testSustain",0)&15)<<4)|(flags.getInt("testRelease",0)&15);
|
testSR=((flags.getInt("testSustain",0)&15)<<4)|(flags.getInt("testRelease",0)&15);
|
||||||
|
|
||||||
|
// init fake filter table
|
||||||
|
// taken from dSID
|
||||||
|
double cutRatio=-2.0*3.14*(sidIs6581?(((double)oscBuf[0]->rate/44100.0)*(20000.0/256.0)):(12500.0/256.0))/(double)oscBuf[0]->rate;
|
||||||
|
|
||||||
|
for (int i=0; i<2048; i++) {
|
||||||
|
double c=(double)i/8.0+0.2;
|
||||||
|
if (sidIs6581) {
|
||||||
|
if (c<24) {
|
||||||
|
c=2.0*sin(771.78/(double)oscBuf[0]->rate);
|
||||||
|
} else {
|
||||||
|
c=(44100.0/(double)oscBuf[0]->rate)-1.263*(44100.0/(double)oscBuf[0]->rate)*exp(c*cutRatio);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
c=1-exp(c*cutRatio);
|
||||||
|
}
|
||||||
|
fakeCutTable[i]=c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int DivPlatformC64::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
int DivPlatformC64::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ class DivPlatformC64: public DivDispatch {
|
||||||
Channel chan[3];
|
Channel chan[3];
|
||||||
DivDispatchOscBuffer* oscBuf[3];
|
DivDispatchOscBuffer* oscBuf[3];
|
||||||
bool isMuted[3];
|
bool isMuted[3];
|
||||||
|
float fakeCutTable[2048];
|
||||||
struct QueuedWrite {
|
struct QueuedWrite {
|
||||||
unsigned char addr;
|
unsigned char addr;
|
||||||
unsigned char val;
|
unsigned char val;
|
||||||
|
|
|
@ -115,11 +115,17 @@ void dSID_init(struct SID_chip* sid, double clockRate, double samplingRate, int
|
||||||
double prd0 = sid->g.ckr > 9 ? sid->g.ckr : 9;
|
double prd0 = sid->g.ckr > 9 ? sid->g.ckr : 9;
|
||||||
sid->g.Aprd[0] = prd0;
|
sid->g.Aprd[0] = prd0;
|
||||||
sid->g.Astp[0] = ceil(prd0 / 9);
|
sid->g.Astp[0] = ceil(prd0 / 9);
|
||||||
|
|
||||||
|
for (int i=0; i<3; i++) {
|
||||||
|
sid->fakeplp[i]=0;
|
||||||
|
sid->fakepbp[i]=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double dSID_render(struct SID_chip* sid) {
|
double dSID_render(struct SID_chip* sid) {
|
||||||
double flin = 0, output = 0;
|
double flin = 0, output = 0;
|
||||||
double wfout = 0;
|
double wfout = 0;
|
||||||
|
double step = 0;
|
||||||
for (int chn = 0; chn < 3; chn++) {
|
for (int chn = 0; chn < 3; chn++) {
|
||||||
struct SIDVOICE *voic = &((struct SIDMEM *) (sid->M))->v[chn];
|
struct SIDVOICE *voic = &((struct SIDMEM *) (sid->M))->v[chn];
|
||||||
double pgt = (sid->SIDct->ch[chn].Ast & GAT);
|
double pgt = (sid->SIDct->ch[chn].Ast & GAT);
|
||||||
|
@ -142,7 +148,6 @@ double dSID_render(struct SID_chip* sid) {
|
||||||
if (sid->SIDct->ch[chn].rcnt >= 0x8000)
|
if (sid->SIDct->ch[chn].rcnt >= 0x8000)
|
||||||
sid->SIDct->ch[chn].rcnt -= 0x8000;
|
sid->SIDct->ch[chn].rcnt -= 0x8000;
|
||||||
|
|
||||||
static double step;
|
|
||||||
double prd;
|
double prd;
|
||||||
|
|
||||||
if (sid->SIDct->ch[chn].Ast & ATK) {
|
if (sid->SIDct->ch[chn].Ast & ATK) {
|
||||||
|
@ -291,8 +296,6 @@ double dSID_render(struct SID_chip* sid) {
|
||||||
// mostly copypasted from below
|
// mostly copypasted from below
|
||||||
double fakeflin = chnout;
|
double fakeflin = chnout;
|
||||||
double fakeflout = 0;
|
double fakeflout = 0;
|
||||||
static double fakeplp[3] = {0};
|
|
||||||
static double fakepbp[3] = {0};
|
|
||||||
double ctf = sid->g.ctf_table[((sid->M[0x15]&7)|(sid->M[0x16]<<3))&0x7ff];
|
double ctf = sid->g.ctf_table[((sid->M[0x15]&7)|(sid->M[0x16]<<3))&0x7ff];
|
||||||
double reso;
|
double reso;
|
||||||
if (sid->g.model == 8580) {
|
if (sid->g.model == 8580) {
|
||||||
|
@ -300,15 +303,15 @@ double dSID_render(struct SID_chip* sid) {
|
||||||
} else {
|
} else {
|
||||||
reso = (sid->M[0x17] > 0x5F) ? 8.0 / (double) (sid->M[0x17] >> 4) : 1.41;
|
reso = (sid->M[0x17] > 0x5F) ? 8.0 / (double) (sid->M[0x17] >> 4) : 1.41;
|
||||||
}
|
}
|
||||||
double tmp = fakeflin + fakepbp[chn] * reso + fakeplp[chn];
|
double tmp = fakeflin + sid->fakepbp[chn] * reso + sid->fakeplp[chn];
|
||||||
if (sid->M[0x18] & HP)
|
if (sid->M[0x18] & HP)
|
||||||
fakeflout -= tmp;
|
fakeflout -= tmp;
|
||||||
tmp = fakepbp[chn] - tmp * ctf;
|
tmp = sid->fakepbp[chn] - tmp * ctf;
|
||||||
fakepbp[chn] = tmp;
|
sid->fakepbp[chn] = tmp;
|
||||||
if (sid->M[0x18] & BP)
|
if (sid->M[0x18] & BP)
|
||||||
fakeflout -= tmp;
|
fakeflout -= tmp;
|
||||||
tmp = fakeplp[chn] + tmp * ctf;
|
tmp = sid->fakeplp[chn] + tmp * ctf;
|
||||||
fakeplp[chn] = tmp;
|
sid->fakeplp[chn] = tmp;
|
||||||
if (sid->M[0x18] & LP)
|
if (sid->M[0x18] & LP)
|
||||||
fakeflout += tmp;
|
fakeflout += tmp;
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,8 @@ struct SID_chip {
|
||||||
uint8_t M[MemLen];
|
uint8_t M[MemLen];
|
||||||
int16_t lastOut[3];
|
int16_t lastOut[3];
|
||||||
int mute_mask;
|
int mute_mask;
|
||||||
|
double fakeplp[3];
|
||||||
|
double fakepbp[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
double dSID_render(struct SID_chip* sid);
|
double dSID_render(struct SID_chip* sid);
|
||||||
|
|
Loading…
Reference in New Issue