From 8c2b3ba438816cc8034b2eec95a97edec01bcbf2 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 20 Oct 2024 18:04:08 -0500 Subject: [PATCH] OPN: fix possible crash when CSM is off --- src/engine/platform/ym2203.h | 2 +- src/engine/platform/ym2203ext.cpp | 2 ++ src/engine/platform/ym2608.h | 2 +- src/engine/platform/ym2610shared.h | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/engine/platform/ym2203.h b/src/engine/platform/ym2203.h index 41315659d..ca7dcacda 100644 --- a/src/engine/platform/ym2203.h +++ b/src/engine/platform/ym2203.h @@ -94,7 +94,7 @@ class DivPlatformYM2203: public DivPlatformOPN { int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); void quit(); DivPlatformYM2203(): - DivPlatformOPN(2, 3, 6, 6, 6, 4720270.0, 36, 16), + DivPlatformOPN(2, 3, 6, 6, 6, 4720270.0, 36, 16, false, 6), prescale(0x2d), isCSM(0) {} ~DivPlatformYM2203(); diff --git a/src/engine/platform/ym2203ext.cpp b/src/engine/platform/ym2203ext.cpp index a3932d527..9e4da8d24 100644 --- a/src/engine/platform/ym2203ext.cpp +++ b/src/engine/platform/ym2203ext.cpp @@ -787,6 +787,8 @@ void DivPlatformYM2203Ext::setCSM(bool isCSM) { this->isCSM=isCSM?1:0; if (isCSM) { csmChan=3; + } else { + csmChan=6; } } diff --git a/src/engine/platform/ym2608.h b/src/engine/platform/ym2608.h index d226821a7..a8861b557 100644 --- a/src/engine/platform/ym2608.h +++ b/src/engine/platform/ym2608.h @@ -125,7 +125,7 @@ class DivPlatformYM2608: public DivPlatformOPN { void setCSM(bool isCSM); void quit(); DivPlatformYM2608(): - DivPlatformOPN(2, 6, 9, 15, 16, 9440540.0, 72, 32), + DivPlatformOPN(2, 6, 9, 15, 16, 9440540.0, 72, 32, false, 16), prescale(0x2d), isCSM(0) {} ~DivPlatformYM2608(); diff --git a/src/engine/platform/ym2610shared.h b/src/engine/platform/ym2610shared.h index bcec11829..2e6d738ea 100644 --- a/src/engine/platform/ym2610shared.h +++ b/src/engine/platform/ym2610shared.h @@ -364,7 +364,7 @@ class DivPlatformYM2610Base: public DivPlatformOPN { } DivPlatformYM2610Base(int ext, int psg, int adpcmA, int adpcmB, int chanCount): - DivPlatformOPN(ext,psg,adpcmA,adpcmB,chanCount,9440540.0, 72, 32) {} + DivPlatformOPN(ext,psg,adpcmA,adpcmB,chanCount,9440540.0, 72, 32, false, 16) {} }; #endif