Merge branch 'master' into es5506_alt

This commit is contained in:
cam900 2022-07-02 13:28:49 +09:00 committed by GitHub
commit f3b9c6dde6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
647 changed files with 4326 additions and 256 deletions

View file

@ -104,12 +104,14 @@ class DivPlatformOPN: public DivPlatformFMBase {
double fmFreqBase;
unsigned int fmDivBase;
unsigned int ayDiv;
bool extSys;
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32):
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false):
DivPlatformFMBase(),
fmFreqBase(f),
fmDivBase(d),
ayDiv(a) {}
ayDiv(a),
extSys(isExtSys) {}
};

View file

@ -344,13 +344,17 @@ void DivPlatformGenesis::acquire(short* bufL, short* bufR, size_t start, size_t
}
void DivPlatformGenesis::tick(bool sysTick) {
for (int i=0; i<6; i++) {
for (int i=0; i<(softPCM?7:6); i++) {
if (i==2 && extMode) continue;
chan[i].std.next();
if (chan[i].std.vol.had) {
chan[i].outVol=VOL_SCALE_LOG(chan[i].vol,MIN(127,chan[i].std.vol.val),127);
for (int j=0; j<4; j++) {
int inVol=chan[i].std.vol.val;
if (chan[i].furnaceDac && inVol>0) {
inVol+=63;
}
chan[i].outVol=VOL_SCALE_LOG(chan[i].vol,MIN(127,inVol),127);
if (i<6) for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (isMuted[i]) {
@ -383,7 +387,9 @@ void DivPlatformGenesis::tick(bool sysTick) {
if (chan[i].std.panL.had) {
chan[i].pan=chan[i].std.panL.val&3;
rWrite(chanOffs[i]+ADDR_LRAF,(IS_REALLY_MUTED(i)?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
if (i<6) {
rWrite(chanOffs[i]+ADDR_LRAF,(IS_REALLY_MUTED(i)?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
}
}
if (chan[i].std.pitch.had) {
@ -396,6 +402,8 @@ void DivPlatformGenesis::tick(bool sysTick) {
chan[i].freqChanged=true;
}
if (i>=6) continue;
if (chan[i].std.phaseReset.had) {
if (chan[i].std.phaseReset.val==1 && chan[i].active) {
chan[i].keyOn=true;
@ -640,9 +648,20 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
chan[c.chan].dacPeriod=0;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=parent->calcBaseFreq(1,1,c.value,false);
chan[c.chan].portaPause=false;
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
}
chan[c.chan].furnaceDac=true;
chan[c.chan].macroInit(ins);
if (!chan[c.chan].std.vol.will) {
chan[c.chan].outVol=chan[c.chan].vol;
}
// ???
//chan[c.chan].keyOn=true;
chan[c.chan].active=true;
} else { // compatible mode
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].note=c.value;
@ -893,6 +912,13 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
if (extSys) {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
}
break;
}
case DIV_CMD_FM_LFO: {
if (c.chan>=6) break;
lfoValue=(c.value&7)|((c.value>>4)<<3);

View file

@ -34,6 +34,10 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
}
int ch=c.chan-2;
int ordch=orderedOps[ch];
if (!extMode) {
c.chan=2;
return DivPlatformGenesis::dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
@ -173,6 +177,11 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
opChan[ch].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
break;
}
case DIV_CMD_FM_LFO: {
lfoValue=(c.value&7)|((c.value>>4)<<3);
rWrite(0x22,lfoValue);
@ -489,7 +498,7 @@ void DivPlatformGenesisExt::forceIns() {
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (i==2) { // extended channel
if (i==2 && extMode) { // extended channel
if (isOpMuted[j]) {
rWrite(baseAddr+0x40,127);
} else if (isOutput[chan[i].state.alg][j]) {
@ -592,6 +601,7 @@ int DivPlatformGenesisExt::init(DivEngine* parent, int channels, int sugRate, un
for (int i=0; i<4; i++) {
isOpMuted[i]=false;
}
extSys=true;
reset();
return 13;

View file

@ -299,18 +299,39 @@ void DivPlatformOPL::acquire_nuked(short* bufL, short* bufR, size_t start, size_
}
}
for (int i=0; i<chans; i++) {
unsigned char ch=outChanMap[i];
if (ch==255) continue;
oscBuf[i]->data[oscBuf[i]->needle]=0;
if (fm.channel[i].out[0]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[0];
if (fm.rhy&0x20) {
for (int i=0; i<melodicChans+1; i++) {
unsigned char ch=outChanMap[i];
if (ch==255) continue;
oscBuf[i]->data[oscBuf[i]->needle]=0;
if (fm.channel[i].out[0]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[0];
}
if (fm.channel[i].out[1]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[1];
}
oscBuf[i]->data[oscBuf[i]->needle]<<=1;
oscBuf[i]->needle++;
}
if (fm.channel[i].out[1]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[1];
// special
oscBuf[melodicChans+1]->data[oscBuf[melodicChans+1]->needle++]=fm.slot[16].out*6;
oscBuf[melodicChans+2]->data[oscBuf[melodicChans+2]->needle++]=fm.slot[14].out*6;
oscBuf[melodicChans+3]->data[oscBuf[melodicChans+3]->needle++]=fm.slot[17].out*6;
oscBuf[melodicChans+4]->data[oscBuf[melodicChans+4]->needle++]=fm.slot[13].out*6;
} else {
for (int i=0; i<chans; i++) {
unsigned char ch=outChanMap[i];
if (ch==255) continue;
oscBuf[i]->data[oscBuf[i]->needle]=0;
if (fm.channel[i].out[0]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[0];
}
if (fm.channel[i].out[1]!=NULL) {
oscBuf[i]->data[oscBuf[i]->needle]+=*fm.channel[ch].out[1];
}
oscBuf[i]->data[oscBuf[i]->needle]<<=1;
oscBuf[i]->needle++;
}
oscBuf[i]->data[oscBuf[i]->needle]<<=1;
oscBuf[i]->needle++;
}
if (os[0]<-32768) os[0]=-32768;
@ -601,8 +622,9 @@ void DivPlatformOPL::tick(bool sysTick) {
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq)*2,chan[i].pitch2,chipClock,CHIP_FREQBASE);
if (chan[i].fixedFreq>0) chan[i].freq=chan[i].fixedFreq;
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>131071) chan[i].freq=131071;
int freqt=toFreq(chan[i].freq)+chan[i].pitch2;
int freqt=toFreq(chan[i].freq);
chan[i].freqH=freqt>>8;
chan[i].freqL=freqt&0xff;
immWrite(chanMap[i]+ADDR_FREQ,chan[i].freqL);
@ -1517,7 +1539,7 @@ void DivPlatformOPL::reset() {
}
*/
if (downsample) {
const unsigned int downsampledRate=(unsigned int)(49716.0*(double(rate)/chipRateBase));
const unsigned int downsampledRate=(unsigned int)((double)rate*rate/chipRateBase);
OPL3_Reset(&fm,downsampledRate);
} else {
OPL3_Reset(&fm,rate);
@ -1647,7 +1669,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
slots=drums?slotsDrums:slotsNonDrums;
chanMap=drums?chanMapOPL2Drums:chanMapOPL2;
outChanMap=outChanMapOPL2;
chipFreqBase=9440540*0.25;
chipFreqBase=32768*72;
chans=9;
melodicChans=drums?6:9;
totalChans=drums?11:9;
@ -1661,7 +1683,7 @@ void DivPlatformOPL::setOPLType(int type, bool drums) {
slots=drums?slotsDrums:slotsNonDrums;
chanMap=drums?chanMapOPL3Drums:chanMapOPL3;
outChanMap=outChanMapOPL3;
chipFreqBase=9440540;
chipFreqBase=32768*288;
chans=18;
melodicChans=drums?15:18;
totalChans=drums?20:18;
@ -1713,9 +1735,6 @@ void DivPlatformOPL::setFlags(unsigned int flags) {
default:
case 1: case 2: case 8950:
switch (flags&0xff) {
case 0x00:
chipClock=COLOR_NTSC;
break;
case 0x01:
chipClock=COLOR_PAL*4.0/5.0;
break;
@ -1731,15 +1750,15 @@ void DivPlatformOPL::setFlags(unsigned int flags) {
case 0x05:
chipClock=3500000.0;
break;
default:
chipClock=COLOR_NTSC;
break;
}
rate=chipClock/72;
chipRateBase=double(rate);
chipRateBase=rate;
break;
case 3:
switch (flags&0xff) {
case 0x00:
chipClock=COLOR_NTSC*4.0;
break;
case 0x01:
chipClock=COLOR_PAL*16.0/5.0;
break;
@ -1752,33 +1771,36 @@ void DivPlatformOPL::setFlags(unsigned int flags) {
case 0x04:
chipClock=15000000.0;
break;
default:
chipClock=COLOR_NTSC*4.0;
break;
}
rate=chipClock/288;
chipRateBase=double(rate);
chipRateBase=rate;
break;
case 4:
switch (flags&0xff) {
case 0x02:
chipClock=33868800.0;
break;
case 0x00:
chipClock=COLOR_NTSC*8.0;
break;
case 0x01:
chipClock=COLOR_PAL*32.0/5.0;
break;
case 0x02:
chipClock=33868800.0;
break;
default:
chipClock=COLOR_NTSC*8.0;
break;
}
chipRateBase=double(chipClock)/684.0;
rate=chipClock/768;
chipRateBase=chipClock/684;
break;
case 759:
rate=48000;
chipRateBase=double(rate);
chipRateBase=rate;
chipClock=rate*288;
break;
}
for (int i=0; i<18; i++) {
for (int i=0; i<20; i++) {
oscBuf[i]->rate=rate;
}
}
@ -1829,7 +1851,7 @@ int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, unsigned int f
for (int i=0; i<20; i++) {
isMuted[i]=false;
}
for (int i=0; i<18; i++) {
for (int i=0; i<20; i++) {
oscBuf[i]=new DivDispatchOscBuffer;
}
setFlags(flags);
@ -1847,7 +1869,7 @@ int DivPlatformOPL::init(DivEngine* p, int channels, int sugRate, unsigned int f
}
void DivPlatformOPL::quit() {
for (int i=0; i<18; i++) {
for (int i=0; i<20; i++) {
delete oscBuf[i];
}
if (adpcmChan>=0) {

View file

@ -75,7 +75,7 @@ class DivPlatformOPL: public DivDispatch {
}
};
Channel chan[20];
DivDispatchOscBuffer* oscBuf[18];
DivDispatchOscBuffer* oscBuf[20];
bool isMuted[20];
struct QueuedWrite {
unsigned short addr;
@ -95,7 +95,7 @@ class DivPlatformOPL: public DivDispatch {
const unsigned char** slots;
const unsigned short* chanMap;
const unsigned char* outChanMap;
double chipFreqBase, chipRateBase;
int chipFreqBase, chipRateBase;
int delay, chipType, oplType, chans, melodicChans, totalChans, adpcmChan, sampleBank;
unsigned char lastBusy;
unsigned char drumState;

View file

@ -97,6 +97,10 @@ const unsigned char drumSlot[11]={
0, 0, 0, 0, 0, 0, 6, 7, 8, 8, 7
};
const unsigned char visMapOPLL[9]={
6, 7, 8, 3, 4, 5, 0, 1, 2
};
void DivPlatformOPLL::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
static int o[2];
static int os;
@ -124,10 +128,18 @@ void DivPlatformOPLL::acquire_nuked(short* bufL, short* bufR, size_t start, size
OPLL_Clock(&fm,o);
unsigned char nextOut=cycleMapOPLL[fm.cycles];
if ((nextOut>=6 && properDrums) || !isMuted[nextOut]) {
oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=(o[0]+o[1])<<6;
os+=(o[0]+o[1]);
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=(o[0]+o[1])<<6;
} else {
oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=0;
if (vrc7 || (fm.rm_enable&0x20)) oscBuf[nextOut]->data[oscBuf[nextOut]->needle++]=0;
}
}
if (!(vrc7 || (fm.rm_enable&0x20))) for (int i=0; i<9; i++) {
unsigned char ch=visMapOPLL[i];
if ((i>=6 && properDrums) || !isMuted[ch]) {
oscBuf[ch]->data[oscBuf[ch]->needle++]=(fm.output_ch[i])<<6;
} else {
oscBuf[ch]->data[oscBuf[ch]->needle++]=0;
}
}
os*=50;

View file

@ -48,12 +48,15 @@ const char* DivPlatformSMS::getEffectName(unsigned char effect) {
}
void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_t len) {
int o=0;
int oL=0;
int oR=0;
for (size_t h=start; h<start+len; h++) {
if (!writes.empty()) {
QueuedWrite w=writes.front();
if (w.addr==0) {
YMPSG_Write(&sn_nuked,w.val);
} else if (w.addr==1) {
YMPSG_WriteStereo(&sn_nuked,w.val);
}
writes.pop();
}
@ -73,10 +76,13 @@ void DivPlatformSMS::acquire_nuked(short* bufL, short* bufR, size_t start, size_
YMPSG_Clock(&sn_nuked);
YMPSG_Clock(&sn_nuked);
YMPSG_Clock(&sn_nuked);
o=YMPSG_GetOutput(&sn_nuked);
if (o<-32768) o=-32768;
if (o>32767) o=32767;
bufL[h]=bufR[h]=o;
YMPSG_GetOutput(&sn_nuked,&oL,&oR);
if (oL<-32768) oL=-32768;
if (oL>32767) oL=32767;
if (oR<-32768) oR=-32768;
if (oR>32767) oR=32767;
bufL[h]=oL;
bufR[h]=oR;
for (int i=0; i<4; i++) {
if (isMuted[i]) {
oscBuf[i]->data[oscBuf[i]->needle++]=0;

View file

@ -20,8 +20,8 @@ void
psg_reset(struct VERA_PSG* psg)
{
memset(psg->channels, 0, sizeof(psg->channels));
psg->noiseState=1;
psg->noiseOut=0;
psg->noiseOut = 0;
psg->noiseState = 1;
}
void
@ -54,10 +54,14 @@ render(struct VERA_PSG* psg, int16_t *left, int16_t *right)
{
int l = 0;
int r = 0;
psg->noiseOut=((psg->noiseOut<<1)|(psg->noiseState&1))&63;
psg->noiseState=(psg->noiseState<<1)|(((psg->noiseState>>1)^(psg->noiseState>>2)^(psg->noiseState>>4)^(psg->noiseState>>15))&1);
for (int i = 0; i < 16; i++) {
// In FPGA implementation, noise values are generated every system clock and
// the channel update is run sequentially. So, even if both two channels are
// fetching a noise value in the same sample, they should have different values
psg->noiseOut = ((psg->noiseOut << 1) | (psg->noiseState & 1)) & 63;
psg->noiseState = (psg->noiseState << 1) | (((psg->noiseState >> 1) ^ (psg->noiseState >> 2) ^ (psg->noiseState >> 4) ^ (psg->noiseState >> 15)) & 1);
struct VERAChannel *ch = &psg->channels[i];
unsigned new_phase = (ch->phase + ch->freq) & 0x1FFFF;
@ -87,11 +91,11 @@ render(struct VERA_PSG* psg, int16_t *left, int16_t *right)
r += val;
}
if (ch->left || ch->right) {
ch->lastOut=val;
} else {
ch->lastOut=0;
}
if (ch->left || ch->right) {
ch->lastOut = val;
} else {
ch->lastOut = 0;
}
}
*left = l;
@ -104,6 +108,6 @@ psg_render(struct VERA_PSG* psg, int16_t *bufL, int16_t *bufR, unsigned num_samp
while (num_samples--) {
render(psg, bufL, bufR);
bufL++;
bufR++;
bufR++;
}
}

View file

@ -74,10 +74,10 @@ const char* DivPlatformSoundUnit::getEffectName(unsigned char effect) {
return "1Dxx: Set cutoff sweep boundary";
break;
case 0x1e:
return "17xx: Set phase reset period low byte";
return "1Exx: Set phase reset period low byte";
break;
case 0x1f:
return "18xx: Set phase reset period high byte";
return "1Fxx: Set phase reset period high byte";
break;
case 0x20:
return "20xx: Toggle frequency sweep (bit 0-6: speed; bit 7: direction is up)";

View file

@ -659,6 +659,13 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
if (extSys) {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
}
break;
}
case DIV_CMD_FM_FB: {
if (c.chan>2) break;
chan[c.chan].state.fb=c.value&7;

View file

@ -34,6 +34,10 @@ int DivPlatformYM2203Ext::dispatch(DivCommand c) {
}
int ch=c.chan-2;
int ordch=orderedOps[ch];
if (!extMode) {
c.chan=2;
return DivPlatformYM2203::dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
@ -151,6 +155,11 @@ int DivPlatformYM2203Ext::dispatch(DivCommand c) {
opChan[ch].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;
@ -514,6 +523,7 @@ int DivPlatformYM2203Ext::init(DivEngine* parent, int channels, int sugRate, uns
for (int i=0; i<4; i++) {
isOpMuted[i]=false;
}
extSys=true;
reset();
return 9;

View file

@ -988,6 +988,13 @@ int DivPlatformYM2608::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
if (extSys) {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
}
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;

View file

@ -34,6 +34,10 @@ int DivPlatformYM2608Ext::dispatch(DivCommand c) {
}
int ch=c.chan-2;
int ordch=orderedOps[ch];
if (!extMode) {
c.chan=2;
return DivPlatformYM2608::dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
@ -151,6 +155,11 @@ int DivPlatformYM2608Ext::dispatch(DivCommand c) {
opChan[ch].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;
@ -528,6 +537,7 @@ int DivPlatformYM2608Ext::init(DivEngine* parent, int channels, int sugRate, uns
for (int i=0; i<4; i++) {
isOpMuted[i]=false;
}
extSys=true;
reset();
return 19;

View file

@ -1032,6 +1032,13 @@ int DivPlatformYM2610::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
if (extSys) {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
}
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;

View file

@ -1014,6 +1014,13 @@ int DivPlatformYM2610B::dispatch(DivCommand c) {
chan[c.chan].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
if (extSys) {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
}
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;

View file

@ -34,6 +34,10 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) {
}
int ch=c.chan-2;
int ordch=orderedOps[ch];
if (!extMode) {
c.chan=2;
return DivPlatformYM2610B::dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
@ -151,6 +155,11 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) {
opChan[ch].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;
@ -427,7 +436,7 @@ void DivPlatformYM2610BExt::forceIns() {
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (i==2) { // extended channel
if (i==2 && extMode) { // extended channel
if (isOpMuted[j]) {
rWrite(baseAddr+0x40,127);
} else if (isOutput[chan[i].state.alg][j]) {
@ -528,6 +537,7 @@ int DivPlatformYM2610BExt::init(DivEngine* parent, int channels, int sugRate, un
for (int i=0; i<4; i++) {
isOpMuted[i]=false;
}
extSys=true;
reset();
return 19;

View file

@ -34,6 +34,10 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) {
}
int ch=c.chan-1;
int ordch=orderedOps[ch];
if (!extMode) {
c.chan=2;
return DivPlatformYM2610::dispatch(c);
}
switch (c.cmd) {
case DIV_CMD_NOTE_ON: {
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
@ -151,6 +155,11 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) {
opChan[ch].freqChanged=true;
break;
}
case DIV_CMD_FM_EXTCH: {
extMode=c.value;
immWrite(0x27,extMode?0x40:0);
break;
}
case DIV_CMD_FM_LFO: {
rWrite(0x22,(c.value&7)|((c.value>>4)<<3));
break;
@ -427,7 +436,7 @@ void DivPlatformYM2610Ext::forceIns() {
for (int j=0; j<4; j++) {
unsigned short baseAddr=chanOffs[i]|opOffs[j];
DivInstrumentFM::Operator& op=chan[i].state.op[j];
if (i==1) { // extended channel
if (i==1 && extMode) { // extended channel
if (isOpMuted[j]) {
rWrite(baseAddr+0x40,127);
} else if (isOutput[chan[i].state.alg][j]) {
@ -528,6 +537,7 @@ int DivPlatformYM2610Ext::init(DivEngine* parent, int channels, int sugRate, uns
for (int i=0; i<4; i++) {
isOpMuted[i]=false;
}
extSys=true;
reset();
return 17;