make OPN channel offsets common

This commit is contained in:
tildearrow 2022-12-24 00:15:15 -05:00
parent 5ecc79f8b9
commit 85d43a84a7
10 changed files with 31 additions and 32 deletions

View file

@ -146,6 +146,8 @@ class DivPlatformOPN: public DivPlatformFMBase {
pan(3) {}
};
const int extChanOffs, psgChanOffs, adpcmAChanOffs, adpcmBChanOffs, chanNum;
double fmFreqBase;
unsigned int fmDivBase;
unsigned int ayDiv;
@ -157,8 +159,13 @@ class DivPlatformOPN: public DivPlatformFMBase {
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false, unsigned char cc=255):
DivPlatformOPN(int ext, int psg, int adpcmA, int adpcmB, int chanCount, double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false, unsigned char cc=255):
DivPlatformFMBase(),
extChanOffs(ext),
psgChanOffs(psg),
adpcmAChanOffs(adpcmA),
adpcmBChanOffs(adpcmB),
chanNum(chanCount),
fmFreqBase(f),
fmDivBase(d),
ayDiv(a),

View file

@ -126,7 +126,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
DivPlatformGenesis():
DivPlatformOPN(9440540.0, 72, 32, false, 7) {}
DivPlatformOPN(2, 6, 6, 6, 6, 9440540.0, 72, 32, false, 7) {}
~DivPlatformGenesis();
};
#endif

View file

@ -77,7 +77,7 @@ class DivPlatformYM2203: public DivPlatformOPN {
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
DivPlatformYM2203():
DivPlatformOPN(4720270.0, 36, 16),
DivPlatformOPN(2, 3, 6, 6, 6, 4720270.0, 36, 16),
prescale(0x2d) {}
~DivPlatformYM2203();
};

View file

@ -97,7 +97,7 @@ class DivPlatformYM2608: public DivPlatformOPN {
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
DivPlatformYM2608():
DivPlatformOPN(9440540.0, 72, 32),
DivPlatformOPN(2, 6, 9, 15, 16, 9440540.0, 72, 32),
prescale(0x2d) {}
~DivPlatformYM2608();
};

View file

@ -1275,7 +1275,7 @@ bool DivPlatformYM2610::keyOffAffectsArp(int ch) {
}
void DivPlatformYM2610::notifyInsChange(int ins) {
for (int i=0; i<chanNum; i++) {
for (int i=0; i<16; i++) {
if (chan[i].ins==ins) {
chan[i].insChanged=true;
}

View file

@ -22,7 +22,7 @@
#include "ym2610shared.h"
class DivPlatformYM2610: public DivPlatformYM2610Base<14> {
class DivPlatformYM2610: public DivPlatformYM2610Base {
protected:
const unsigned short chanOffs[4]={
0x01, 0x02, 0x101, 0x102
@ -60,7 +60,7 @@ class DivPlatformYM2610: public DivPlatformYM2610Base<14> {
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
DivPlatformYM2610():
DivPlatformYM2610Base<14>(1,4,7,13) {}
DivPlatformYM2610Base(1,4,7,13,14) {}
~DivPlatformYM2610();
};
#endif

View file

@ -1342,7 +1342,7 @@ bool DivPlatformYM2610B::keyOffAffectsArp(int ch) {
}
void DivPlatformYM2610B::notifyInsChange(int ins) {
for (int i=0; i<chanNum; i++) {
for (int i=0; i<16; i++) {
if (chan[i].ins==ins) {
chan[i].insChanged=true;
}

View file

@ -22,7 +22,7 @@
#include "ym2610shared.h"
class DivPlatformYM2610B: public DivPlatformYM2610Base<16> {
class DivPlatformYM2610B: public DivPlatformYM2610Base {
protected:
const unsigned short chanOffs[6]={
0x00, 0x01, 0x02, 0x100, 0x101, 0x102
@ -56,7 +56,7 @@ class DivPlatformYM2610B: public DivPlatformYM2610Base<16> {
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit();
DivPlatformYM2610B():
DivPlatformYM2610Base<16>(2,6,9,15) {}
DivPlatformYM2610Base(2,6,9,15,16) {}
~DivPlatformYM2610B();
};
#endif

View file

@ -44,11 +44,11 @@ class DivYM2610Interface: public ymfm::ymfm_interface {
sampleBank(0) {}
};
template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
class DivPlatformYM2610Base: public DivPlatformOPN {
protected:
OPNChannelStereo chan[ChanNum];
DivDispatchOscBuffer* oscBuf[ChanNum];
bool isMuted[ChanNum];
OPNChannelStereo chan[16];
DivDispatchOscBuffer* oscBuf[16];
bool isMuted[16];
ymfm::ym2610b* fm;
ymfm::ym2610b::output_data fmout;
@ -72,9 +72,6 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
unsigned char writeADPCMAOff, writeADPCMAOn;
int globalADPCMAVolume;
const int extChanOffs, psgChanOffs, adpcmAChanOffs, adpcmBChanOffs;
const int chanNum=ChanNum;
double NOTE_OPNB(int ch, int note) {
if (ch>=adpcmBChanOffs) { // ADPCM
return NOTE_ADPCMB(note);
@ -221,7 +218,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
CHECK_CUSTOM_CLOCK;
noExtMacros=flags.getBool("noExtMacros",false);
rate=chipClock/16;
for (int i=0; i<ChanNum; i++) {
for (int i=0; i<16; i++) {
oscBuf[i]->rate=rate;
}
}
@ -231,7 +228,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
ayFlags.set("chipType",1);
dumpWrites=false;
skipRegisterWrites=false;
for (int i=0; i<ChanNum; i++) {
for (int i=0; i<16; i++) {
isMuted[i]=false;
oscBuf[i]=new DivDispatchOscBuffer;
}
@ -253,7 +250,7 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
}
void quit() {
for (int i=0; i<ChanNum; i++) {
for (int i=0; i<16; i++) {
delete oscBuf[i];
}
ay->quit();
@ -262,12 +259,8 @@ template<int ChanNum> class DivPlatformYM2610Base: public DivPlatformOPN {
delete[] adpcmBMem;
}
DivPlatformYM2610Base(int ext, int psg, int adpcmA, int adpcmB):
DivPlatformOPN(9440540.0, 72, 32),
extChanOffs(ext),
psgChanOffs(psg),
adpcmAChanOffs(adpcmA),
adpcmBChanOffs(adpcmB) {}
DivPlatformYM2610Base(int ext, int psg, int adpcmA, int adpcmB, int chanCount):
DivPlatformOPN(ext,psg,adpcmA,adpcmB,chanCount,9440540.0, 72, 32) {}
};
#endif

View file

@ -65,7 +65,11 @@
FM_CHIP_DEBUG; \
ImGui::Text("- fmFreqBase: %.f",ch->fmFreqBase); \
ImGui::Text("- fmDivBase: %d",ch->fmDivBase); \
ImGui::Text("- ayDiv: %d",ch->ayDiv);
ImGui::Text("- ayDiv: %d",ch->ayDiv); \
ImGui::Text("- extChanOffs: %d",ch->extChanOffs); \
ImGui::Text("- psgChanOffs: %d",ch->psgChanOffs); \
ImGui::Text("- adpcmAChanOffs: %d",ch->adpcmAChanOffs); \
ImGui::Text("- adpcmBChanOffs: %d",ch->adpcmBChanOffs); \
#define COMMON_CHIP_DEBUG_BOOL \
ImGui::TextColored(ch->skipRegisterWrites?colorOn:colorOff,">> SkipRegisterWrites"); \
@ -97,11 +101,6 @@
ImGui::Text("- writeADPCMAOff: %d",ch->writeADPCMAOff); \
ImGui::Text("- writeADPCMAOn: %d",ch->writeADPCMAOn); \
ImGui::Text("- globalADPCMAVolume: %d",ch->globalADPCMAVolume); \
ImGui::Text("- extChanOffs: %d",ch->extChanOffs); \
ImGui::Text("- psgChanOffs: %d",ch->psgChanOffs); \
ImGui::Text("- adpcmAChanOffs: %d",ch->adpcmAChanOffs); \
ImGui::Text("- adpcmBChanOffs: %d",ch->adpcmBChanOffs); \
ImGui::Text("- chanNum: %d",ch->chanNum); \
FM_OPN_CHIP_DEBUG_BOOL; \
ImGui::TextColored(ch->extMode?colorOn:colorOff,">> ExtMode");