From b468c9bdae4c5e75e3e39d6f7ff8672696f810f6 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Thu, 29 Aug 2024 13:09:39 +0200 Subject: [PATCH] aica: reset CA to 0 when disabling channel due to AEG CA was reset to 0 for non-looping sound when ending, but not for looping ones when they reach full attenuation. This confuses some games. Disable the channel when it reaches full attenuation and reset CA to 0. Revert a7702c622a5855ff6fe95699bd97b5603997567e Issue #1602 Better fix for Issues #472, #483, #1180, #1249, #1030 (partial) --- core/hw/aica/sgc_if.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/hw/aica/sgc_if.cpp b/core/hw/aica/sgc_if.cpp index 171b6189e..aca25a1bf 100755 --- a/core/hw/aica/sgc_if.cpp +++ b/core/hw/aica/sgc_if.cpp @@ -528,6 +528,7 @@ struct ChannelEx enabled=false; SetAegState(EG_Release); AEG.SetValue(0x3FF); + CA = 0; } void enable() @@ -854,8 +855,8 @@ struct ChannelEx { switch (offset) { - case 0x00: - case 0x01: + case 0x00: // PCMS, SA + case 0x01: // KYONEX, KYONB, SSCTL, LPCTL, PCMS UpdateStreamStep(); if (offset == 0 || size == 2) UpdateSA(); @@ -872,8 +873,8 @@ struct ChannelEx } break; - case 0x04: - case 0x05: + case 0x04: // SA + case 0x05: // SA UpdateSA(); break; @@ -1219,7 +1220,7 @@ void AegStep(ChannelEx* ch) if (ch->AEG.GetValue() >= 0x3FF) { aeg_printf("[%d]AEG_step : EG_Release End @ %x", ch->ChannelNumber, ch->AEG.GetValue()); - ch->AEG.SetValue(0x3FF); + ch->disable(); } break; } @@ -1440,8 +1441,8 @@ void ReadCommonReg(u32 reg,bool byte) CommonData->EG = aeg; //AEG is only 10 bits, FEG is 13 bits CommonData->SGC=Chans[chan].AEG.state; - if (! (byte && reg==0x2810)) - Chans[chan].loop.looped=0; + if (!byte || reg == 0x2811) + Chans[chan].loop.looped = 0; } break; case 0x2814: //CA