From b4a7f0f5b7447e5127b65f025102c2452be3a00a Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 3 Jun 2022 16:13:57 -0500 Subject: [PATCH] YM2612: - C S M - CSM only available with Nuked core may not work on VGM export if you compress VGM (removes timer A writes) --- TODO.md | 2 -- src/engine/platform/genesis.cpp | 22 ------------------- src/engine/platform/genesisext.cpp | 35 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 24 deletions(-) diff --git a/TODO.md b/TODO.md index c5c1ca0e0..2dc7bb8ef 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ # to-do for 0.6pre1 -- additional YM2612 features - - CSM - MSM6258 pitch and clock select - Game Boy envelope macro/sequence - rewrite the system name detection function anyway diff --git a/src/engine/platform/genesis.cpp b/src/engine/platform/genesis.cpp index f240997cd..2368fc0b5 100644 --- a/src/engine/platform/genesis.cpp +++ b/src/engine/platform/genesis.cpp @@ -512,28 +512,6 @@ void DivPlatformGenesis::tick(bool sysTick) { } } - if (extMode && softPCM) { - if (chan[7].freqChanged) { - chan[7].freq=parent->calcFreq(chan[7].baseFreq,chan[7].pitch,true,0,chan[7].pitch2,chipClock,CHIP_DIVIDER); - int wf=0x400-chan[7].freq; - printf("freq: %d\n",wf); - immWrite(0x24,wf>>2); - immWrite(0x25,wf&3); - chan[7].freqChanged=false; - } - - if (chan[7].keyOn) { - printf("CSM key on\n"); - immWrite(0x27,0x81); - chan[7].keyOn=false; - } - if (chan[7].keyOff) { - printf("CSM key off\n"); - immWrite(0x27,0x40); - chan[7].keyOff=false; - } - } - for (int i=0; i<7; i++) { if (i==2 && extMode) continue; if (chan[i].freqChanged) { diff --git a/src/engine/platform/genesisext.cpp b/src/engine/platform/genesisext.cpp index 8b4629b94..e105f5604 100644 --- a/src/engine/platform/genesisext.cpp +++ b/src/engine/platform/genesisext.cpp @@ -23,6 +23,7 @@ #include "genesisshared.h" +#define CHIP_DIVIDER 72 #define CHIP_FREQBASE 9440540 int DivPlatformGenesisExt::dispatch(DivCommand c) { @@ -446,9 +447,43 @@ void DivPlatformGenesisExt::tick(bool sysTick) { opChan[i].keyOn=false; } } + + if (extMode && softPCM) { + if (chan[7].freqChanged) { + chan[7].freq=parent->calcFreq(chan[7].baseFreq,chan[7].pitch,true,0,chan[7].pitch2,chipClock,CHIP_DIVIDER); + if (chan[7].freq<1) chan[7].freq=1; + if (chan[7].freq>1024) chan[7].freq=1024; + int wf=0x400-chan[7].freq; + immWrite(0x24,wf>>2); + immWrite(0x25,wf&3); + chan[7].freqChanged=false; + } + + if (chan[7].keyOff || chan[7].keyOn) { + writeNoteOn=true; + for (int i=0; i<4; i++) { + writeMask|=opChan[i].active<<(4+i); + } + } + } + if (writeNoteOn) { + if (chan[7].active) { // CSM + writeMask^=0xf0; + } immWrite(0x28,writeMask); } + + if (extMode && softPCM) { + if (chan[7].keyOn) { + immWrite(0x27,0x81); + chan[7].keyOn=false; + } + if (chan[7].keyOff) { + immWrite(0x27,0x40); + chan[7].keyOff=false; + } + } } void DivPlatformGenesisExt::forceIns() {