From 8c706f71a964e091ac46eaa66d5ed1714db4c921 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 9 Mar 2023 02:55:16 -0500 Subject: [PATCH] dev145 - Namco WSG: new noise strategy for C30 --- src/engine/engine.h | 4 ++-- src/engine/fileOps.cpp | 9 +++++++++ src/engine/platform/namcowsg.cpp | 14 +++++++++++--- src/engine/platform/namcowsg.h | 1 + src/gui/sysConf.cpp | 17 +++++++++++++++++ 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/engine/engine.h b/src/engine/engine.h index 32d4c9fa..0c57e2d8 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -47,8 +47,8 @@ #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_END isBusy.unlock(); softLocked=false; -#define DIV_VERSION "0.6pre4-hotfix" -#define DIV_ENGINE_VERSION 144 +#define DIV_VERSION "dev145" +#define DIV_ENGINE_VERSION 145 // for imports #define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_FC 0xff02 diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index c679019a..47e6fcab 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -2678,6 +2678,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) { } } + // Namco C30 noise compat + if (ds.version<145) { + for (int i=0; i>8)&0xff); - rWrite((i<<3)+0x101,((chan[i].freq>>16)&15)|(i<<4)); + if (chan[i].noise && newNoise) { + int noiseFreq=chan[i].freq>>9; + if (noiseFreq<0) noiseFreq=0; + if (noiseFreq>255) noiseFreq=255; + rWrite((i<<3)+0x103,noiseFreq); + } else { + rWrite((i<<3)+0x103,chan[i].freq&0xff); + rWrite((i<<3)+0x102,(chan[i].freq>>8)&0xff); + rWrite((i<<3)+0x101,((chan[i].freq>>16)&15)|(i<<4)); + } } break; } @@ -544,6 +551,7 @@ void DivPlatformNamcoWSG::setFlags(const DivConfig& flags) { for (int i=0; irate=rate; } + newNoise=flags.getBool("newNoise",true); } void DivPlatformNamcoWSG::poke(unsigned int addr, unsigned short val) { diff --git a/src/engine/platform/namcowsg.h b/src/engine/platform/namcowsg.h index b2943413..dcc52549 100644 --- a/src/engine/platform/namcowsg.h +++ b/src/engine/platform/namcowsg.h @@ -49,6 +49,7 @@ class DivPlatformNamcoWSG: public DivDispatch { namco_audio_device* namco; int devType, chans; + bool newNoise; unsigned char regPool[512]; void updateWave(int ch); friend void putDispatchChip(void*,int); diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index ef35cfc4..87b9baed 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -1704,6 +1704,20 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo } break; } + case DIV_SYSTEM_NAMCO_CUS30: { + bool newNoise=flags.getBool("newNoise",true); + + if (InvCheckbox("Compatible noise frequencies",&newNoise)) { + altered=true; + } + + if (altered) { + e->lockSave([&]() { + flags.set("newNoise",newNoise); + }); + } + break; + } case DIV_SYSTEM_SM8521:/* { bool noAntiClick=flags.getBool("noAntiClick",false); @@ -1724,11 +1738,14 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo case DIV_SYSTEM_VBOY: case DIV_SYSTEM_GA20: case DIV_SYSTEM_PV1000: + case DIV_SYSTEM_NAMCO: + case DIV_SYSTEM_NAMCO_15XX: ImGui::Text("nothing to configure"); break; case DIV_SYSTEM_VERA: case DIV_SYSTEM_YMU759: supportsCustomRate=false; + ImGui::Text("nothing to configure"); break; default: { bool sysPal=flags.getInt("clockSel",0);