From ccfb3d3407176dde5ce5bc1c5f7a1d0aadecb8ba Mon Sep 17 00:00:00 2001 From: host12prog Date: Thu, 10 Jul 2025 18:06:05 +0700 Subject: [PATCH] support ymfm (NO LLE SUPPORT, WHO NEEDS EMULATION THAT ACCURATE) --- src/engine/dispatchContainer.cpp | 1 + src/engine/platform/ym2203.cpp | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index addbaede8..ceca9598a 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -458,6 +458,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do ((DivPlatformYM2203Ext*)dispatch)->setCombo(eng->getConfInt("opn1Core", 1)); } ((DivPlatformYM2203Ext*)dispatch)->setCSM(1); + ((DivPlatformYM2203Ext*)dispatch)->setExtSSG(1); break; case DIV_SYSTEM_YM2608: dispatch=new DivPlatformYM2608; diff --git a/src/engine/platform/ym2203.cpp b/src/engine/platform/ym2203.cpp index 2d74ab4fc..0265634db 100644 --- a/src/engine/platform/ym2203.cpp +++ b/src/engine/platform/ym2203.cpp @@ -268,6 +268,7 @@ void DivPlatformYM2203::acquire_combo(short** buf, size_t len) { void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) { thread_local int os; + thread_local int os1, os2; ymfm::ym2203::fm_engine* fme=fm->debug_fm_engine(); @@ -310,12 +311,27 @@ void DivPlatformYM2203::acquire_ymfm(short** buf, size_t len) { fm->generate(&fmout); iface.clock(24); - os=((fmout.data[0]*fmVol)>>8)+(((fmout.data[1]+fmout.data[2]+fmout.data[3])*ssgVol)>>8); + os=((fmout.data[0]*fmVol)>>8); if (os<-32768) os=-32768; if (os>32767) os=32767; - - buf[0][h]=os; + if (stereo) { + // so ugly + os1=((fmout.data[1]+((fmout.data[2]*centerVol+fmout.data[3]*sideVol)>>8))*ssgVol)>>8; + os2=((((fmout.data[1]*sideVol+fmout.data[2]*centerVol)>>8)+fmout.data[3])*ssgVol)>>8; + if (os1<-32768) os1=-32768; + if (os1>32767) os1=32767; + if (os2<-32768) os2=-32768; + if (os2>32767) os2=32767; + buf[0][h]=os+os1; + buf[1][h]=os+os2; + } else { + os+=((fmout.data[1]+fmout.data[2]+fmout.data[3])*ssgVol)>>8; + if (os<-32768) os=-32768; + if (os>32767) os=32767; + buf[0][h]=os; + if (extendedSSG) buf[1][h]=os; + } for (int i=0; i<3; i++) { int out=(fmChan[i]->debug_output(0)+fmChan[i]->debug_output(1))<<1; @@ -493,6 +509,7 @@ void DivPlatformYM2203::acquire_lle(short** buf, size_t len) { if (outL>32767) outL=32767; buf[0][h]=outL; + if (extendedSSG) buf[1][h]=outL; } for (int i=0; i<7; i++) {