From 730561d3a31d77087f0dcdfc113c2f8e70c711a2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 20 Jan 2022 17:54:11 -0500 Subject: [PATCH] arcade: add effects to control AMD/PMD --- papers/doc/7-systems/arcade.md | 2 ++ src/engine/dispatch.h | 2 ++ src/engine/platform/arcade.cpp | 18 ++++++++++++++++-- src/engine/platform/arcade.h | 1 + src/engine/playback.cpp | 8 ++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/papers/doc/7-systems/arcade.md b/papers/doc/7-systems/arcade.md index 6af59b1ea..fd17f91c1 100644 --- a/papers/doc/7-systems/arcade.md +++ b/papers/doc/7-systems/arcade.md @@ -25,6 +25,8 @@ the actual PCM chip had 16 channels, but the number has been cut to 5 in DefleMa - `1Bxx`: set attack of operator 2. - `1Cxx`: set attack of operator 3. - `1Dxx`: set attack of operator 4. +- `1Exx`: set AM depth. +- `1Fxx`: set PM depth. - `20xx`: set PCM frequency. - only works on the PCM channels. - `xx` is a 256th fraction of 31250Hz. diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index 9a0062a20..dc76fe61d 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -35,6 +35,8 @@ enum DivDispatchCmds { DIV_CMD_FM_FB, DIV_CMD_FM_MULT, DIV_CMD_FM_EXTCH, + DIV_CMD_FM_AM_DEPTH, + DIV_CMD_FM_PM_DEPTH, DIV_CMD_GENESIS_LFO, diff --git a/src/engine/platform/arcade.cpp b/src/engine/platform/arcade.cpp index f1483a7c6..9a1661541 100644 --- a/src/engine/platform/arcade.cpp +++ b/src/engine/platform/arcade.cpp @@ -420,6 +420,16 @@ int DivPlatformArcade::dispatch(DivCommand c) { } break; } + case DIV_CMD_FM_AM_DEPTH: { + amDepth=c.value; + immWrite(0x19,amDepth); + break; + } + case DIV_CMD_FM_PM_DEPTH: { + pmDepth=c.value; + immWrite(0x19,0x80|pmDepth); + break; + } case DIV_CMD_STD_NOISE_FREQ: { if (c.chan!=7) break; if (c.value) { @@ -463,6 +473,8 @@ void DivPlatformArcade::forceIns() { for (int i=0; i<13; i++) { chan[i].insChanged=true; } + immWrite(0x19,amDepth); + immWrite(0x19,0x80|pmDepth); } void DivPlatformArcade::notifyInsChange(int ins) { @@ -497,10 +509,12 @@ void DivPlatformArcade::reset() { pcmR=0; sampleBank=0; delay=0; + amDepth=0x7f; + pmDepth=0x7f; //rWrite(0x18,0x10); - immWrite(0x19,0x7f); - immWrite(0x19,0xff); + immWrite(0x19,amDepth); + immWrite(0x19,0x80|pmDepth); //rWrite(0x1b,0x00); extMode=false; diff --git a/src/engine/platform/arcade.h b/src/engine/platform/arcade.h index 0094a4646..cd5c76a40 100644 --- a/src/engine/platform/arcade.h +++ b/src/engine/platform/arcade.h @@ -42,6 +42,7 @@ class DivPlatformArcade: public DivDispatch { int pcmL, pcmR, pcmCycles; unsigned char sampleBank; unsigned char lastBusy; + unsigned char amDepth, pmDepth; ymfm::ym2151* fm_ymfm; ymfm::ym2151::output_data out_ymfm; diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index f474c56dc..1e13b1a9d 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -47,6 +47,8 @@ const char* cmdName[DIV_CMD_MAX]={ "FM_FB", "FM_MULT", "FM_EXTCH", + "FM_AM_DEPTH", + "FM_PM_DEPTH", "GENESIS_LFO", @@ -250,6 +252,12 @@ bool DivEngine::perSystemPostEffect(int ch, unsigned char effect, unsigned char case 0x1d: // AR op4 dispatchCmd(DivCommand(DIV_CMD_FM_AR,ch,3,effectVal&31)); break; + case 0x1e: // UNOFFICIAL: Arcade AM depth + dispatchCmd(DivCommand(DIV_CMD_FM_AM_DEPTH,ch,effectVal&127)); + break; + case 0x1f: // UNOFFICIAL: Arcade PM depth + dispatchCmd(DivCommand(DIV_CMD_FM_PM_DEPTH,ch,effectVal&127)); + break; case 0x20: // PCM frequency or Neo Geo PSG mode if (sysOfChan[ch]==DIV_SYSTEM_ARCADE || sysOfChan[ch]==DIV_SYSTEM_YM2151) { dispatchCmd(DivCommand(DIV_CMD_SAMPLE_FREQ,ch,effectVal));