Skip to content

Commit

Permalink
Merge pull request #18076 from hrydgard/after-burner-fix
Browse files Browse the repository at this point in the history
SasAudio: Always reinitialize the VAG decoder on sceSasSetVoice, even if already playing
  • Loading branch information
hrydgard authored Sep 7, 2023
2 parents 942a1c0 + 61af237 commit c08a5d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
16 changes: 8 additions & 8 deletions Core/HLE/sceSas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -363,8 +363,11 @@ 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;
if (v.on) {
v.playing = true;
}
v.vag.Start(vagAddr, size, loop != 0);
return 0;
}

Expand Down Expand Up @@ -401,7 +404,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;
}

Expand All @@ -424,7 +426,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;
}
}

Expand Down Expand Up @@ -466,7 +468,6 @@ static u32 sceSasSetPitch(u32 core, int voiceNum, int pitch) {
__SasDrain();
SasVoice &v = sas->voices[voiceNum];
v.pitch = pitch;
v.ChangedParams(false);
return 0;
}

Expand Down Expand Up @@ -523,7 +524,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;
}

Expand Down
11 changes: 2 additions & 9 deletions Core/HW/SasAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -812,15 +814,6 @@ void SasVoice::KeyOff() {
envelope.KeyOff();
}

void SasVoice::ChangedParams(bool changedVag) {
if (!playing && on) {
playing = true;
if (changedVag)
vag.Start(vagAddr, vagSize, loop);
}
// TODO: restart VAG somehow
}

void SasVoice::DoState(PointerWrap &p) {
auto s = p.Section("SasVoice", 1, 3);
if (!s)
Expand Down
1 change: 0 additions & 1 deletion Core/HW/SasAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ struct SasVoice {
void Reset();
void KeyOn();
void KeyOff();
void ChangedParams(bool changedVag);

void DoState(PointerWrap &p);

Expand Down

0 comments on commit c08a5d3

Please sign in to comment.