diff --git a/src/engine/platform/fmshared_OPN.h b/src/engine/platform/fmshared_OPN.h index 610e6160..e24b9cb3 100644 --- a/src/engine/platform/fmshared_OPN.h +++ b/src/engine/platform/fmshared_OPN.h @@ -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), diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index 1b017922..2a7b2c8d 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -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 diff --git a/src/engine/platform/ym2203.h b/src/engine/platform/ym2203.h index 2a3f292f..0e0da7e4 100644 --- a/src/engine/platform/ym2203.h +++ b/src/engine/platform/ym2203.h @@ -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(); }; diff --git a/src/engine/platform/ym2608.h b/src/engine/platform/ym2608.h index f6dfc21a..d1100ce9 100644 --- a/src/engine/platform/ym2608.h +++ b/src/engine/platform/ym2608.h @@ -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(); }; diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index 5aa13499..2a3b00ac 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -1275,7 +1275,7 @@ bool DivPlatformYM2610::keyOffAffectsArp(int ch) { } void DivPlatformYM2610::notifyInsChange(int ins) { - for (int i=0; i { +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 diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index 00adbdd1..28c69353 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -1342,7 +1342,7 @@ bool DivPlatformYM2610B::keyOffAffectsArp(int ch) { } void DivPlatformYM2610B::notifyInsChange(int ins) { - for (int i=0; i { +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 diff --git a/src/engine/platform/ym2610shared.h b/src/engine/platform/ym2610shared.h index 487412d5..79dde4ab 100644 --- a/src/engine/platform/ym2610shared.h +++ b/src/engine/platform/ym2610shared.h @@ -44,11 +44,11 @@ class DivYM2610Interface: public ymfm::ymfm_interface { sampleBank(0) {} }; -template 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 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 class DivPlatformYM2610Base: public DivPlatformOPN { CHECK_CUSTOM_CLOCK; noExtMacros=flags.getBool("noExtMacros",false); rate=chipClock/16; - for (int i=0; irate=rate; } } @@ -231,7 +228,7 @@ template class DivPlatformYM2610Base: public DivPlatformOPN { ayFlags.set("chipType",1); dumpWrites=false; skipRegisterWrites=false; - for (int i=0; i class DivPlatformYM2610Base: public DivPlatformOPN { } void quit() { - for (int i=0; iquit(); @@ -262,12 +259,8 @@ template 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 diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 3a9ff950..5a612382 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -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");