From 2bfb84cd1eab23ff1acc473d639b929a5331de6f Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 6 Mar 2022 14:18:18 -0500 Subject: [PATCH 1/5] AY: add 1.10 and 2.10 rates --- src/engine/platform/ay.cpp | 6 ++++++ src/engine/platform/ay8930.cpp | 6 ++++++ src/engine/song.h | 2 ++ src/gui/gui.cpp | 8 ++++++++ 4 files changed, 22 insertions(+) diff --git a/src/engine/platform/ay.cpp b/src/engine/platform/ay.cpp index 2bcada1e..0777fca8 100644 --- a/src/engine/platform/ay.cpp +++ b/src/engine/platform/ay.cpp @@ -491,6 +491,12 @@ void DivPlatformAY8910::setFlags(unsigned int flags) { case 8: chipClock=COLOR_PAL*3.0/16.0; break; + case 9: + chipClock=COLOR_PAL/4.0; + break; + case 10: + chipClock=2097152; + break; default: chipClock=COLOR_NTSC/2.0; break; diff --git a/src/engine/platform/ay8930.cpp b/src/engine/platform/ay8930.cpp index 040800af..d87045a6 100644 --- a/src/engine/platform/ay8930.cpp +++ b/src/engine/platform/ay8930.cpp @@ -552,6 +552,12 @@ void DivPlatformAY8930::setFlags(unsigned int flags) { case 8: chipClock=COLOR_PAL*3.0/16.0; break; + case 9: + chipClock=COLOR_PAL/4.0; + break; + case 10: + chipClock=2097152; + break; default: chipClock=COLOR_NTSC/2.0; break; diff --git a/src/engine/song.h b/src/engine/song.h index d1e255d9..e4bd428b 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -194,6 +194,8 @@ struct DivSong { // - 6: 0.89MHz (Sunsoft 5B) // - 7: 1.67MHz // - 8: 0.83MHz (Sunsoft 5B on PAL) + // - 9: 1.10MHz (Gamate/VIC-20 PAL) + // - 10: 2.097152MHz (Game Boy) // - bit 4-5: chip type (ignored on AY8930) // - 0: AY-3-8910 or similar // - 1: YM2149 diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index fa890038..fb3e6fc3 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -4818,6 +4818,14 @@ bool FurnaceGUI::loop() { e->setSysFlags(i,(flags&(~15))|8,restart); updateWindowTitle(); } + if (ImGui::RadioButton("1.10MHz (Gamate/VIC-20 PAL)",(flags&15)==9)) { + e->setSysFlags(i,(flags&(~15))|9,restart); + updateWindowTitle(); + } + if (ImGui::RadioButton("2^21Hz (Game Boy)",(flags&15)==10)) { + e->setSysFlags(i,(flags&(~15))|10,restart); + updateWindowTitle(); + } if (e->song.system[i]==DIV_SYSTEM_AY8910) { ImGui::Text("Chip type:"); if (ImGui::RadioButton("AY-3-8910",(flags&0x30)==0)) { From 3b8388d90cd3f1308e3d508e7b8c318ef149ab4e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 6 Mar 2022 14:39:20 -0500 Subject: [PATCH 2/5] YM2151/2610/2612/Game Boy: fix panning - UNTESTED --- src/engine/platform/arcade.cpp | 4 ++-- src/engine/platform/gb.cpp | 1 + src/engine/platform/genesis.cpp | 14 ++++---------- src/engine/platform/genesisext.cpp | 16 +++++----------- src/engine/platform/ym2610.cpp | 14 ++++---------- src/engine/platform/ym2610b.cpp | 14 ++++---------- src/engine/platform/ym2610bext.cpp | 16 +++++----------- src/engine/platform/ym2610ext.cpp | 16 +++++----------- 8 files changed, 30 insertions(+), 65 deletions(-) diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index 15a25517..1af99eb7 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -495,8 +495,8 @@ int DivPlatformArcade::dispatch(DivCommand c) { chan[c.chan].ins=c.value; break; case DIV_CMD_PANNING: { - chan[c.chan].chVolL=((c.value>>4)==1); - chan[c.chan].chVolR=((c.value&15)==1); + chan[c.chan].chVolL=((c.value>>4)>0); + chan[c.chan].chVolR=((c.value&15)>0); if (isMuted[c.chan]) { rWrite(chanOffs[c.chan]+ADDR_LR_FB_ALG,(chan[c.chan].state.alg&7)|(chan[c.chan].state.fb<<3)); } else { diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index f02ea197..a2b53ef7 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -340,6 +340,7 @@ int DivPlatformGB::dispatch(DivCommand c) { case DIV_CMD_PANNING: { lastPan&=~(0x11<0)|(((c.value>>4)>0)<<4) lastPan|=c.value<0)|(((c.value>>4)>0)<<1); } rWrite(chanOffs[c.chan]+ADDR_LRAF,(isMuted[c.chan]?0:(chan[c.chan].pan<<6))|(chan[c.chan].state.fms&7)|((chan[c.chan].state.ams&3)<<4)); break; diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index 364505db..02305a9a 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -106,16 +106,10 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) { opChan[ch].ins=c.value; break; case DIV_CMD_PANNING: { - switch (c.value) { - case 0x01: - opChan[ch].pan=1; - break; - case 0x10: - opChan[ch].pan=2; - break; - default: - opChan[ch].pan=3; - break; + if (c.value==0) { + opChan[ch].pan=3; + } else { + opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1); } // TODO: ??? rWrite(chanOffs[2]+0xb4,(opChan[ch].pan<<6)|(chan[2].state.fms&7)|((chan[2].state.ams&3)<<4)); @@ -378,4 +372,4 @@ void DivPlatformGenesisExt::quit() { } DivPlatformGenesisExt::~DivPlatformGenesisExt() { -} \ No newline at end of file +} diff --git a/src/engine/platform/ym2610.cpp b/src/engine/platform/ym2610.cpp index dd2447da..1bd460fa 100644 --- a/src/engine/platform/ym2610.cpp +++ b/src/engine/platform/ym2610.cpp @@ -892,16 +892,10 @@ int DivPlatformYM2610::dispatch(DivCommand c) { chan[c.chan].ins=c.value; break; case DIV_CMD_PANNING: { - switch (c.value) { - case 0x01: - chan[c.chan].pan=1; - break; - case 0x10: - chan[c.chan].pan=2; - break; - default: - chan[c.chan].pan=3; - break; + if (c.value==0) { + chan[c.chan].pan=3; + } else { + chan[c.chan].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1); } if (c.chan>12) { immWrite(0x11,isMuted[c.chan]?0:(chan[c.chan].pan<<6)); diff --git a/src/engine/platform/ym2610b.cpp b/src/engine/platform/ym2610b.cpp index 27bb2afb..a6bcf9ac 100644 --- a/src/engine/platform/ym2610b.cpp +++ b/src/engine/platform/ym2610b.cpp @@ -955,16 +955,10 @@ int DivPlatformYM2610B::dispatch(DivCommand c) { chan[c.chan].ins=c.value; break; case DIV_CMD_PANNING: { - switch (c.value) { - case 0x01: - chan[c.chan].pan=1; - break; - case 0x10: - chan[c.chan].pan=2; - break; - default: - chan[c.chan].pan=3; - break; + if (c.value==0) { + chan[c.chan].pan=3; + } else { + chan[c.chan].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1); } if (c.chan>14) { immWrite(0x11,isMuted[c.chan]?0:(chan[c.chan].pan<<6)); diff --git a/src/engine/platform/ym2610bext.cpp b/src/engine/platform/ym2610bext.cpp index f48fe19a..5b3c3872 100644 --- a/src/engine/platform/ym2610bext.cpp +++ b/src/engine/platform/ym2610bext.cpp @@ -97,16 +97,10 @@ int DivPlatformYM2610BExt::dispatch(DivCommand c) { opChan[ch].ins=c.value; break; case DIV_CMD_PANNING: { - switch (c.value) { - case 0x01: - opChan[ch].pan=1; - break; - case 0x10: - opChan[ch].pan=2; - break; - default: - opChan[ch].pan=3; - break; + if (c.value==0) { + opChan[ch].pan=3; + } else { + opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1); } DivInstrument* ins=parent->getIns(opChan[ch].ins); // TODO: ??? @@ -334,4 +328,4 @@ void DivPlatformYM2610BExt::quit() { } DivPlatformYM2610BExt::~DivPlatformYM2610BExt() { -} \ No newline at end of file +} diff --git a/src/engine/platform/ym2610ext.cpp b/src/engine/platform/ym2610ext.cpp index aff4bbf3..5e633eb2 100644 --- a/src/engine/platform/ym2610ext.cpp +++ b/src/engine/platform/ym2610ext.cpp @@ -97,16 +97,10 @@ int DivPlatformYM2610Ext::dispatch(DivCommand c) { opChan[ch].ins=c.value; break; case DIV_CMD_PANNING: { - switch (c.value) { - case 0x01: - opChan[ch].pan=1; - break; - case 0x10: - opChan[ch].pan=2; - break; - default: - opChan[ch].pan=3; - break; + if (c.value==0) { + opChan[ch].pan=3; + } else { + opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1); } DivInstrument* ins=parent->getIns(opChan[ch].ins); // TODO: ??? @@ -334,4 +328,4 @@ void DivPlatformYM2610Ext::quit() { } DivPlatformYM2610Ext::~DivPlatformYM2610Ext() { -} \ No newline at end of file +} From e10abe08589b3bb4663f759e88f44c00df33fcbf Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 6 Mar 2022 14:41:00 -0500 Subject: [PATCH 3/5] NO --- src/engine/platform/gb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/platform/gb.cpp b/src/engine/platform/gb.cpp index a2b53ef7..942032e3 100644 --- a/src/engine/platform/gb.cpp +++ b/src/engine/platform/gb.cpp @@ -340,7 +340,7 @@ int DivPlatformGB::dispatch(DivCommand c) { case DIV_CMD_PANNING: { lastPan&=~(0x11<0)|(((c.value>>4)>0)<<4) + c.value=((c.value&15)>0)|(((c.value>>4)>0)<<4); lastPan|=c.value< Date: Sun, 6 Mar 2022 17:42:51 -0500 Subject: [PATCH 4/5] Amiga: temporarily disable bus limit simulation --- src/engine/platform/amiga.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/amiga.cpp b/src/engine/platform/amiga.cpp index 3ee2fd39..c5face68 100644 --- a/src/engine/platform/amiga.cpp +++ b/src/engine/platform/amiga.cpp @@ -84,7 +84,7 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le } else { chan[i].sample=-1; } - if (chan[i].freq<124) { + /*if (chan[i].freq<124) { if (++chan[i].busClock>=512) { unsigned int rAmount=(124-chan[i].freq)*2; if (chan[i].audPos>=rAmount) { @@ -92,7 +92,7 @@ void DivPlatformAmiga::acquire(short* bufL, short* bufR, size_t start, size_t le } chan[i].busClock=0; } - } + }*/ chan[i].audSub+=MAX(114,chan[i].freq); } } From 2f9d1e8c0f3fac7f7b8971e4f1d3a7882ddef2b7 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 6 Mar 2022 18:10:12 -0500 Subject: [PATCH 5/5] i'll finish this later --- src/engine/platform/opl.cpp | 26 ++++++++++++++++++++++++-- src/engine/platform/opl.h | 7 ++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index bb195a47..ebf7dc92 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -30,7 +30,6 @@ // N = invalid #define N 255 -/* const unsigned char slotsOPL2[4][20]={ {0, 1, 2, 6, 7, 8, 12, 13, 14}, // OP1 {3, 4, 5, 9, 10, 11, 15, 16, 17}, // OP2 @@ -45,6 +44,10 @@ const unsigned char slotsOPL2Drums[4][20]={ {N, N, N, N, N, N, N, N, N, N, N} }; +const unsigned char chanMapOPL2[20]={ + 0, 1, 2, 3, 4, 5, 6, 7, 8, N, N, N, N, N, N, N, N, N, N, N +}; + const unsigned char slotsOPL3[4][20]={ {0, 6, 1, 7, 2, 8, 18, 24, 19, 25, 20, 26, 30, 31, 32, 12, 13, 14}, // OP1 {3, 9, 4, 10, 5, 11, 21, 27, 22, 28, 23, 29, 33, 34, 35, 15, 16, 17}, // OP2 @@ -58,7 +61,10 @@ const unsigned char slotsOPL3Drums[4][20]={ {6, N, 7, N, 8, N, 24, N, 25, N, 26, N, N, N, N, N, N, N, N, N}, // OP3 {9, N, 10, N, 11, N, 27, N, 28, N, 29, N, N, N, N, N, N, N, N, N} // OP4 }; -*/ + +const unsigned char chanMapOPL3[20]={ + 0, 3, 1, 4, 2, 5, 9, 12, 10, 13, 11, 14, 15, 16, 17, 6, 7, 8, N, N +}; #undef N @@ -773,6 +779,22 @@ void DivPlatformOPL::setYMFM(bool use) { useYMFM=use; } +void DivPlatformOPL::setOPLType(int type) { + switch (type) { + case 1: case 2: + slotsNonDrums=(const unsigned char**)slotsOPL2; + slotsDrums=(const unsigned char**)slotsOPL2Drums; + chanMap=chanMapOPL2; + break; + case 3: + slotsNonDrums=(const unsigned char**)slotsOPL3; + slotsDrums=(const unsigned char**)slotsOPL3Drums; + chanMap=chanMapOPL3; + break; + } + oplType=type; +} + void DivPlatformOPL::setFlags(unsigned int flags) { /* if (flags==3) { diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index c4248192..ab6226a4 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -64,7 +64,11 @@ class DivPlatformOPL: public DivDispatch { }; std::queue writes; opl3_chip fm; - int delay; + const unsigned char** slotsNonDrums; + const unsigned char** slotsDrums; + const unsigned char** slots; + const unsigned char* chanMap; + int delay, oplType; unsigned char lastBusy; unsigned char regPool[512]; @@ -103,6 +107,7 @@ class DivPlatformOPL: public DivDispatch { void muteChannel(int ch, bool mute); bool isStereo(); void setYMFM(bool use); + void setOPLType(int type); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); void toggleRegisterDump(bool enable);