Nuked-OPN2 + ymfm combo option for all OPN chips

modified Nuked doing FM and ymfm doing SSG/ADPCM
This commit is contained in:
tildearrow 2022-12-24 02:29:37 -05:00
parent 85d43a84a7
commit 6cce918c02
24 changed files with 19122 additions and 20 deletions

View file

@ -233,6 +233,112 @@ const char** DivPlatformYM2610::getRegisterSheet() {
}
void DivPlatformYM2610::acquire(short* bufL, short* bufR, size_t start, size_t len) {
if (useCombo) {
acquire_combo(bufL,bufR,start,len);
} else {
acquire_ymfm(bufL,bufR,start,len);
}
}
void DivPlatformYM2610::acquire_combo(short* bufL, short* bufR, size_t start, size_t len) {
static int os[2];
static short ignored[2];
ymfm::ssg_engine* ssge=fm->debug_ssg_engine();
ymfm::adpcm_a_engine* aae=fm->debug_adpcm_a_engine();
ymfm::adpcm_b_engine* abe=fm->debug_adpcm_b_engine();
ymfm::ssg_engine::output_data ssgOut;
ymfm::adpcm_a_channel* adpcmAChan[6];
for (int i=0; i<6; i++) {
adpcmAChan[i]=aae->debug_channel(i);
}
for (size_t h=start; h<start+len; h++) {
os[0]=0; os[1]=0;
// Nuked part
for (int i=0; i<24; i++) {
if (!writes.empty()) {
if (--delay<1 && !(fm->read(0)&0x80)) {
QueuedWrite& w=writes.front();
if (w.addr<=0x1c || (w.addr>=0x100 && w.addr<=0x12d)) {
// ymfm write
fm->write(0x0+((w.addr>>8)<<1),w.addr);
fm->write(0x1+((w.addr>>8)<<1),w.val);
regPool[w.addr&0x1ff]=w.val;
writes.pop_front();
delay=32;
} else {
// Nuked write
if (w.addrOrVal) {
OPN2_Write(&fm_nuked,0x1+((w.addr>>8)<<1),w.val);
regPool[w.addr&0x1ff]=w.val;
writes.pop_front();
} else {
lastBusy++;
if (fm_nuked.write_busy==0) {
OPN2_Write(&fm_nuked,0x0+((w.addr>>8)<<1),w.addr);
w.addrOrVal=true;
}
}
}
}
}
OPN2_Clock(&fm_nuked,ignored);
}
os[0]=(
(fm_nuked.pan_l[1]?fm_nuked.ch_out[1]:0)+
(fm_nuked.pan_l[2]?fm_nuked.ch_out[2]:0)+
(fm_nuked.pan_l[4]?fm_nuked.ch_out[4]:0)+
(fm_nuked.pan_l[5]?fm_nuked.ch_out[5]:0)
);
os[1]=(
(fm_nuked.pan_r[1]?fm_nuked.ch_out[1]:0)+
(fm_nuked.pan_r[2]?fm_nuked.ch_out[2]:0)+
(fm_nuked.pan_r[4]?fm_nuked.ch_out[4]:0)+
(fm_nuked.pan_r[5]?fm_nuked.ch_out[5]:0)
);
os[0]>>=1;
os[1]>>=1;
// ymfm part
fm->generate(&fmout);
os[0]+=fmout.data[0]+(fmout.data[2]>>1);
if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767;
os[1]+=fmout.data[1]+(fmout.data[2]>>1);
if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767;
bufL[h]=os[0];
bufR[h]=os[1];
for (int i=0; i<psgChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=fm_nuked.ch_out[bchOffs[i]];
}
ssge->get_last_out(ssgOut);
for (int i=psgChanOffs; i<adpcmAChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=ssgOut.data[i-psgChanOffs];
}
for (int i=adpcmAChanOffs; i<adpcmBChanOffs; i++) {
oscBuf[i]->data[oscBuf[i]->needle++]=adpcmAChan[i-adpcmAChanOffs]->get_last_out(0)+adpcmAChan[i-adpcmAChanOffs]->get_last_out(1);
}
oscBuf[adpcmBChanOffs]->data[oscBuf[adpcmBChanOffs]->needle++]=abe->get_last_out(0)+abe->get_last_out(1);
}
}
void DivPlatformYM2610::acquire_ymfm(short* bufL, short* bufR, size_t start, size_t len) {
static int os[2];
ymfm::ym2610::fm_engine* fme=fm->debug_fm_engine();
@ -254,13 +360,13 @@ void DivPlatformYM2610::acquire(short* bufL, short* bufR, size_t start, size_t l
for (size_t h=start; h<start+len; h++) {
os[0]=0; os[1]=0;
if (!writes.empty()) {
if (--delay<1) {
if (--delay<1 && !(fm->read(0)&0x80)) {
QueuedWrite& w=writes.front();
fm->write(0x0+((w.addr>>8)<<1),w.addr);
fm->write(0x1+((w.addr>>8)<<1),w.val);
regPool[w.addr&0x1ff]=w.val;
writes.pop_front();
delay=4;
delay=1;
}
}