From 0c727ff6b761ecf03afafed8e3510c5cc0335216 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 25 Nov 2023 18:02:21 -0500 Subject: [PATCH] YM2612: YMF276-LLE, part 1 --- CMakeLists.txt | 1 + src/engine/platform/genesis.cpp | 16 ++++++++++++---- src/engine/platform/genesis.h | 9 ++++++--- src/gui/settings.cpp | 11 ++++++----- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20e6cf507..4b8a94787 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,6 +491,7 @@ extern/Nuked-OPLL/opll.c extern/opl/opl3.c extern/YM3812-LLE/fmopl2.c extern/YMF262-LLE/fmopl3.c +extern/YMF276-LLE/fmopn2.c src/pch.cpp diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index 4973a323d..633bf2886 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -289,8 +289,14 @@ void DivPlatformGenesis::acquire_ymfm(short** buf, size_t len) { } } +void DivPlatformGenesis::acquire_nuked276(short** buf, size_t len) { + // TODO +} + void DivPlatformGenesis::acquire(short** buf, size_t len) { - if (useYMFM) { + if (useYMFM==2) { + acquire_nuked276(buf,len); + } else if (useYMFM==1) { acquire_ymfm(buf,len); } else { acquire_nuked(buf,len); @@ -1309,7 +1315,9 @@ float DivPlatformGenesis::getPostAmp() { void DivPlatformGenesis::reset() { writes.clear(); memset(regPool,0,512); - if (useYMFM) { + if (useYMFM==2) { + memset(&fm_276,0,sizeof(fmopn2_t)); + } else if (useYMFM==1) { fm_ymfm->reset(); } OPN2_Reset(&fm); @@ -1396,7 +1404,7 @@ int DivPlatformGenesis::getPortaFloor(int ch) { return 0; } -void DivPlatformGenesis::setYMFM(bool use) { +void DivPlatformGenesis::setYMFM(unsigned char use) { useYMFM=use; } @@ -1441,7 +1449,7 @@ void DivPlatformGenesis::setFlags(const DivConfig& flags) { break; } CHECK_CUSTOM_CLOCK; - if (useYMFM) { + if (useYMFM==1) { if (fm_ymfm!=NULL) delete fm_ymfm; if (chipType==1) { fm_ymfm=new ymfm::ym2612(iface); diff --git a/src/engine/platform/genesis.h b/src/engine/platform/genesis.h index 8c9181dc9..82d4301b9 100644 --- a/src/engine/platform/genesis.h +++ b/src/engine/platform/genesis.h @@ -22,7 +22,7 @@ #include "fmshared_OPN.h" #include "sound/ymfm/ymfm_opn.h" - +#include "../../../extern/YMF276-LLE/fmopn2.h" class DivYM2612Interface: public ymfm::ymfm_interface { int setA, setB; @@ -77,6 +77,7 @@ class DivPlatformGenesis: public DivPlatformOPN { DivDispatchOscBuffer* oscBuf[10]; bool isMuted[10]; ym3438_t fm; + fmopn2_t fm_276; ymfm::ym2612* fm_ymfm; ymfm::ym2612::output_data out_ymfm; @@ -84,7 +85,8 @@ class DivPlatformGenesis: public DivPlatformOPN { int softPCMTimer; - bool extMode, softPCM, noExtMacros, useYMFM, canWriteDAC; + bool extMode, softPCM, noExtMacros, canWriteDAC; + unsigned char useYMFM; unsigned char chipType; short dacWrite; @@ -96,6 +98,7 @@ class DivPlatformGenesis: public DivPlatformOPN { inline void processDAC(int iRate); inline void commitState(int ch, DivInstrument* ins); void acquire_nuked(short** buf, size_t len); + void acquire_nuked276(short** buf, size_t len); void acquire_ymfm(short** buf, size_t len); friend void putDispatchChip(void*,int); @@ -116,7 +119,7 @@ class DivPlatformGenesis: public DivPlatformOPN { void tick(bool sysTick=true); void muteChannel(int ch, bool mute); int getOutputCount(); - void setYMFM(bool use); + void setYMFM(unsigned char use); bool keyOffAffectsArp(int ch); bool keyOffAffectsPorta(int ch); float getPostAmp(); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index c7ff6b29b..154b87331 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -127,7 +127,8 @@ const char* arcadeCores[]={ const char* ym2612Cores[]={ "Nuked-OPN2", - "ymfm" + "ymfm", + "YMF276-LLE" }; const char* snCores[]={ @@ -1499,10 +1500,10 @@ void FurnaceGUI::drawSettings() { ImGui::Text("YM2612"); ImGui::TableNextColumn(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::Combo("##YM2612Core",&settings.ym2612Core,ym2612Cores,2)) settingsChanged=true; + if (ImGui::Combo("##YM2612Core",&settings.ym2612Core,ym2612Cores,3)) settingsChanged=true; ImGui::TableNextColumn(); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); - if (ImGui::Combo("##YM2612CoreRender",&settings.ym2612CoreRender,ym2612Cores,2)) settingsChanged=true; + if (ImGui::Combo("##YM2612CoreRender",&settings.ym2612CoreRender,ym2612Cores,3)) settingsChanged=true; ImGui::TableNextRow(); ImGui::TableNextColumn(); @@ -3810,7 +3811,7 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.audioRate,8000,384000); clampSetting(settings.audioChans,1,16); clampSetting(settings.arcadeCore,0,1); - clampSetting(settings.ym2612Core,0,1); + clampSetting(settings.ym2612Core,0,2); clampSetting(settings.snCore,0,1); clampSetting(settings.nesCore,0,1); clampSetting(settings.fdsCore,0,1); @@ -3820,7 +3821,7 @@ void FurnaceGUI::syncSettings() { clampSetting(settings.opl2Core,0,2); clampSetting(settings.opl3Core,0,2); clampSetting(settings.arcadeCoreRender,0,1); - clampSetting(settings.ym2612CoreRender,0,1); + clampSetting(settings.ym2612CoreRender,0,2); clampSetting(settings.snCoreRender,0,1); clampSetting(settings.nesCoreRender,0,1); clampSetting(settings.fdsCoreRender,0,1);