OPN[A/B/2]?: implement 18xx effect

This commit is contained in:
tildearrow 2022-06-28 01:16:46 -05:00
parent e2449d91f1
commit f483292a88
11 changed files with 92 additions and 5 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

@ -886,6 +886,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

@ -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;