From 696dbed9f83c3738a449c3686ef7fd5178b1f236 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sat, 4 Nov 2023 20:14:06 +0800 Subject: [PATCH 1/6] Add AtracDecodeDataRemainFrameHack Return less than 1 RemainFrame in AtracDecodeDataRemain to get valid data,then psp will call sceAtracAddStreamData and sceAtracGetStreamDataInfo. --- Core/Compatibility.cpp | 1 + Core/Compatibility.h | 1 + Core/HLE/sceAtrac.cpp | 5 ++++- assets/compat.ini | 9 ++++++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index 29a8874039a4..775d180517b9 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -134,6 +134,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "Fontltn12Hack", &flags_.Fontltn12Hack); CheckSetting(iniFile, gameID, "LoadCLUTFromCurrentFrameOnly", &flags_.LoadCLUTFromCurrentFrameOnly); CheckSetting(iniFile, gameID, "ForceUMDReadSpeed", &flags_.ForceUMDReadSpeed); + CheckSetting(iniFile, gameID, "AtracDecodeDataRemainFrameHack", &flags_.AtracDecodeDataRemainFrameHack); } void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index a917d17e5e22..731fe5380d18 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -104,6 +104,7 @@ struct CompatFlags { bool Fontltn12Hack; bool LoadCLUTFromCurrentFrameOnly; bool ForceUMDReadSpeed; + bool AtracDecodeDataRemainFrameHack; }; struct VRCompat { diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 3ca2541f7369..4c4e27eb9c50 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1380,8 +1380,11 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 if (Memory::IsValidAddress(finishFlagAddr)) Memory::Write_U32(finish, finishFlagAddr); // On error, no remaining frame value is written. - if (ret == 0 && Memory::IsValidAddress(remainAddr)) + if (ret == 0 && Memory::IsValidAddress(remainAddr)){ + if (PSP_CoreParameter().compat.flags().AtracDecodeDataRemainFrameHack && remains > 0) + remains--; Memory::Write_U32(remains, remainAddr); + } } DEBUG_LOG(ME, "%08x=sceAtracDecodeData(%i, %08x, %08x[%08x], %08x[%08x], %08x[%d])", ret, atracID, outAddr, numSamplesAddr, numSamples, diff --git a/assets/compat.ini b/assets/compat.ini index 59909df931a1..b0dc3ad8f6d4 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1645,4 +1645,11 @@ SYPH04036 = true # Prototype? ULES00590 = true ULJM05075 = true #Sengoku Musou 3Z Special DLC see #9993 -ULJM06024 = true \ No newline at end of file +ULJM06024 = true + +[AtracDecodeDataRemainFrameHack] +#Return less than 1 RemainFrame in AtracDecodeDataRemain to get valid data,then psp will call sceAtracAddStreamData and sceAtracGetStreamDataInfo. + +# Kaitou Apricot see #15233 +ULJM05276 = true +NPJH50167 = true From 46291c7b3e371a136a9f108e3248c67c838b0a2f Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 5 Nov 2023 18:17:28 +0800 Subject: [PATCH 2/6] Add more information in sceAtracGetLoopStatus --- Core/HLE/sceAtrac.cpp | 3 +-- assets/compat.ini | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 4c4e27eb9c50..901258bb284e 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1534,7 +1534,6 @@ static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) { ERROR_LOG(ME, "sceAtracGetLoopStatus(%i, %08x, %08x): no data", atracID, loopNumAddr, statusAddr); return ATRAC_ERROR_NO_DATA; } else { - DEBUG_LOG(ME, "sceAtracGetLoopStatus(%i, %08x, %08x)", atracID, loopNumAddr, statusAddr); if (Memory::IsValidAddress(loopNumAddr)) Memory::Write_U32(atrac->loopNum_, loopNumAddr); // return audio's loopinfo in at3 file @@ -1545,7 +1544,7 @@ static u32 sceAtracGetLoopStatus(int atracID, u32 loopNumAddr, u32 statusAddr) { Memory::Write_U32(0, statusAddr); } } - return 0; + return hleLogDebug(ME, 0); } static u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr) { diff --git a/assets/compat.ini b/assets/compat.ini index b0dc3ad8f6d4..9105d17a3770 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1648,7 +1648,7 @@ ULJM05075 = true ULJM06024 = true [AtracDecodeDataRemainFrameHack] -#Return less than 1 RemainFrame in AtracDecodeDataRemain to get valid data,then psp will call sceAtracAddStreamData and sceAtracGetStreamDataInfo. +#Return less than 1 RemainFrame in sceAtracDecodeData to get valid data,then psp will call sceAtracAddStreamData and sceAtracGetStreamDataInfo. # Kaitou Apricot see #15233 ULJM05276 = true From 889bfa234e5004989050351375a7a1d01d6ad809 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Sun, 5 Nov 2023 20:28:37 +0800 Subject: [PATCH 3/6] Add sceAtracGetNextSample logging information --- Core/HLE/sceAtrac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 901258bb284e..2e13991453b5 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1633,7 +1633,7 @@ static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) { numSamples = atrac->SamplesPerFrame(); if (Memory::IsValidAddress(outNAddr)) Memory::Write_U32(numSamples, outNAddr); - DEBUG_LOG(ME, "sceAtracGetNextSample(%i, %08x): %d samples left", atracID, outNAddr, numSamples); + DEBUG_LOG(ME, "sceAtracGetNextSample(%i, %08x): %d samples left currentSample %d endSample %d", atracID, outNAddr, numSamples, atrac->currentSample_, atrac->endSample_); } } return 0; From 3a6e8145a76d821692b6c2a668c45371b41e5bcc Mon Sep 17 00:00:00 2001 From: sum2012 Date: Mon, 6 Nov 2023 01:47:32 +0800 Subject: [PATCH 4/6] Add more information about decode fail --- Core/HLE/sceAtrac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 2e13991453b5..c4c268a115bc 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -596,12 +596,12 @@ struct Atrac { av_free_packet(packet_); #endif if (bytes_read == AVERROR_PATCHWELCOME) { - ERROR_LOG(ME, "Unsupported feature in ATRAC audio."); + ERROR_LOG(ME, "Unsupported feature in ATRAC audio. currentSample %d endSample %d", currentSample_, endSample_); // Let's try the next packet. packet_->size = 0; return ATDECODE_BADFRAME; } else if (bytes_read < 0) { - ERROR_LOG_REPORT(ME, "avcodec_decode_audio4: Error decoding audio %d / %08x", bytes_read, bytes_read); + ERROR_LOG_REPORT(ME, "avcodec_decode_audio4: Error decoding audio %d / %08x currentSample %d endSample %d", bytes_read, bytes_read, currentSample_, endSample_); failedDecode_ = true; return ATDECODE_FAILED; } From 44df7dd8d7e85e4dcd4513b72d16d908065b5450 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 16 Nov 2023 06:04:18 +0800 Subject: [PATCH 5/6] Revert "Add more information about decode fail" This reverts commit 3a6e8145a76d821692b6c2a668c45371b41e5bcc. --- Core/HLE/sceAtrac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index c4c268a115bc..2e13991453b5 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -596,12 +596,12 @@ struct Atrac { av_free_packet(packet_); #endif if (bytes_read == AVERROR_PATCHWELCOME) { - ERROR_LOG(ME, "Unsupported feature in ATRAC audio. currentSample %d endSample %d", currentSample_, endSample_); + ERROR_LOG(ME, "Unsupported feature in ATRAC audio."); // Let's try the next packet. packet_->size = 0; return ATDECODE_BADFRAME; } else if (bytes_read < 0) { - ERROR_LOG_REPORT(ME, "avcodec_decode_audio4: Error decoding audio %d / %08x currentSample %d endSample %d", bytes_read, bytes_read, currentSample_, endSample_); + ERROR_LOG_REPORT(ME, "avcodec_decode_audio4: Error decoding audio %d / %08x", bytes_read, bytes_read); failedDecode_ = true; return ATDECODE_FAILED; } From 18e86cd44253824e49fd1b2092685828b0f0ca21 Mon Sep 17 00:00:00 2001 From: sum2012 Date: Thu, 16 Nov 2023 06:04:35 +0800 Subject: [PATCH 6/6] Revert "Add sceAtracGetNextSample logging information" This reverts commit 889bfa234e5004989050351375a7a1d01d6ad809. --- Core/HLE/sceAtrac.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 2e13991453b5..901258bb284e 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -1633,7 +1633,7 @@ static u32 sceAtracGetNextSample(int atracID, u32 outNAddr) { numSamples = atrac->SamplesPerFrame(); if (Memory::IsValidAddress(outNAddr)) Memory::Write_U32(numSamples, outNAddr); - DEBUG_LOG(ME, "sceAtracGetNextSample(%i, %08x): %d samples left currentSample %d endSample %d", atracID, outNAddr, numSamples, atrac->currentSample_, atrac->endSample_); + DEBUG_LOG(ME, "sceAtracGetNextSample(%i, %08x): %d samples left", atracID, outNAddr, numSamples); } } return 0;