From 1ee4c63bbab0c328f8761b251fff2a596f7d6fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 5 Sep 2023 13:11:43 +0200 Subject: [PATCH 1/4] Logging: __sceCore isn't very interesting, log as verbose --- Core/HLE/sceSas.cpp | 4 ++-- Core/HW/SasAudio.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index c8c726aea81d..b030527f93b5 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -296,7 +296,7 @@ static u32 _sceSasCore(u32 core, u32 outAddr) { __SasEnqueueMix(outAddr); - return hleLogSuccessI(SCESAS, delaySasResult(0)); + return hleLogSuccessVerboseI(SCESAS, delaySasResult(0)); } // Another way of running the mixer, the inoutAddr should be both input and output @@ -315,7 +315,7 @@ static u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int right __SasEnqueueMix(inoutAddr, inoutAddr, leftVolume, rightVolume); - return hleLogSuccessI(SCESAS, delaySasResult(0)); + return hleLogSuccessVerboseI(SCESAS, delaySasResult(0)); } static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loop) { diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 1186e31eee06..e2d845e4779d 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -71,6 +71,8 @@ void VagDecoder::DecodeBlock(const u8 *&read_pointer) { return; } + _dbg_assert_(curBlock_ < numBlocks_); + const u8 *readp = read_pointer; int predict_nr = *readp++; int shift_factor = predict_nr & 0xf; From 9794d5377b84628f41853872d14adcc1e2137cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 5 Sep 2023 13:13:13 +0200 Subject: [PATCH 2/4] Always reinitialize the VAG decoder on sceSasSetVoice, even if already playing. Fixes After Burner. --- Core/HW/SasAudio.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index e2d845e4779d..1eea1cf59319 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -815,12 +815,10 @@ void SasVoice::KeyOff() { } void SasVoice::ChangedParams(bool changedVag) { - if (!playing && on) { + if (type == VOICETYPE_VAG) { playing = true; - if (changedVag) - vag.Start(vagAddr, vagSize, loop); + vag.Start(vagAddr, vagSize, loop); } - // TODO: restart VAG somehow } void SasVoice::DoState(PointerWrap &p) { From 8b32a1e5e2ef640e246757c00dc7e9bac979b8fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 6 Sep 2023 10:31:13 +0200 Subject: [PATCH 3/4] Remove the weird ChangedParams thing entirely and do the straightforward thing --- Core/HLE/sceSas.cpp | 10 ++++------ Core/HW/SasAudio.cpp | 7 ------- Core/HW/SasAudio.h | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index b030527f93b5..df414f436952 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -363,8 +363,9 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo v.type = VOICETYPE_VAG; v.vagAddr = vagAddr; // Real VAG header is 0x30 bytes behind the vagAddr v.vagSize = size; - v.loop = loop ? true : false; - v.ChangedParams(vagAddr == prevVagAddr); + v.loop = loop != 0; + v.playing = true; + v.vag.Start(vagAddr, size, loop != 0); return 0; } @@ -401,7 +402,6 @@ static u32 sceSasSetVoicePCM(u32 core, int voiceNum, u32 pcmAddr, int size, int v.pcmLoopPos = loopPos >= 0 ? loopPos : 0; v.loop = loopPos >= 0 ? true : false; v.playing = true; - v.ChangedParams(pcmAddr == prevPcmAddr); return 0; } @@ -424,7 +424,7 @@ static u32 sceSasSetPause(u32 core, u32 voicebit, int pause) { for (int i = 0; voicebit != 0; i++, voicebit >>= 1) { if (i < PSP_SAS_VOICES_MAX && i >= 0) { if ((voicebit & 1) != 0) - sas->voices[i].paused = pause ? true : false; + sas->voices[i].paused = pause != 0; } } @@ -466,7 +466,6 @@ static u32 sceSasSetPitch(u32 core, int voiceNum, int pitch) { __SasDrain(); SasVoice &v = sas->voices[voiceNum]; v.pitch = pitch; - v.ChangedParams(false); return 0; } @@ -523,7 +522,6 @@ static u32 sceSasSetNoise(u32 core, int voiceNum, int freq) { SasVoice &v = sas->voices[voiceNum]; v.type = VOICETYPE_NOISE; v.noiseFreq = freq; - v.ChangedParams(true); return 0; } diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 1eea1cf59319..17bd31d1501f 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -814,13 +814,6 @@ void SasVoice::KeyOff() { envelope.KeyOff(); } -void SasVoice::ChangedParams(bool changedVag) { - if (type == VOICETYPE_VAG) { - playing = true; - vag.Start(vagAddr, vagSize, loop); - } -} - void SasVoice::DoState(PointerWrap &p) { auto s = p.Section("SasVoice", 1, 3); if (!s) diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index 8680d223c737..6a9ee882b816 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -243,7 +243,6 @@ struct SasVoice { void Reset(); void KeyOn(); void KeyOff(); - void ChangedParams(bool changedVag); void DoState(PointerWrap &p); From 61af237f982d5727b083e8cf09b30ef47f7ad601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 6 Sep 2023 15:45:52 +0200 Subject: [PATCH 4/4] Check v.on for whether to trigger v.playing, like before. --- Core/HLE/sceSas.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index df414f436952..d8a320ee55e2 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -364,7 +364,9 @@ static u32 sceSasSetVoice(u32 core, int voiceNum, u32 vagAddr, int size, int loo v.vagAddr = vagAddr; // Real VAG header is 0x30 bytes behind the vagAddr v.vagSize = size; v.loop = loop != 0; - v.playing = true; + if (v.on) { + v.playing = true; + } v.vag.Start(vagAddr, size, loop != 0); return 0; }