From bab09ea30ac762a64febccda8669f39544947867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 11 Mar 2025 15:35:56 +0100 Subject: [PATCH] Implement sceAtracGetInternalError --- Core/HLE/AtracCtx.h | 2 ++ Core/HLE/AtracCtx2.cpp | 10 ++++++++++ Core/HLE/AtracCtx2.h | 2 ++ Core/HLE/sceAtrac.cpp | 11 ++++++++--- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index c68fef738a..972dfcae9a 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -190,6 +190,8 @@ public: virtual int GetID() const = 0; + virtual u32 GetInternalCodecError() const { return 0; } + PSPPointer context_{}; virtual AtracStatus BufferState() const = 0; diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index 6bdf0bb98d..baf935a72e 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -450,6 +450,7 @@ u32 Atrac2::DecodeData(u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u32 *finish, // Decode failed. *SamplesNum = 0; *finish = 0; + context_->codec.err = 0x20b; // checked on hardware for 0xFF corruption. it's possible that there are more codes. return SCE_ERROR_ATRAC_API_FAIL; // tested. } @@ -482,6 +483,7 @@ u32 Atrac2::DecodeData(u8 *outbuf, u32 outbufPtr, u32 *SamplesNum, u32 *finish, if (info.curOff >= info.dataEnd) { *finish = 1; } + context_->codec.err = 0; return 0; } @@ -590,6 +592,14 @@ int Atrac2::SetData(const Track &track, u32 bufferAddr, u32 readSize, u32 buffer return 0; } +u32 Atrac2::GetInternalCodecError() const { + if (context_.IsValid()) { + return context_->codec.err; + } else { + return 0; + } +} + u32 Atrac2::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) { return 0; } diff --git a/Core/HLE/AtracCtx2.h b/Core/HLE/AtracCtx2.h index 04688c64a9..56b3f90842 100644 --- a/Core/HLE/AtracCtx2.h +++ b/Core/HLE/AtracCtx2.h @@ -53,6 +53,8 @@ public: bool IsNewAtracImpl() const override { return true; } + u32 GetInternalCodecError() const override; + private: void SeekToSample(int sample); diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 9a10b150d5..36b404dbab 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -304,6 +304,7 @@ static u32 sceAtracDecodeData(int atracID, u32 outAddr, u32 numSamplesAddr, u32 return hleNoLog(ret); } +// Likely a bogus brute-forced name? static u32 sceAtracEndEntry() { ERROR_LOG_REPORT(Log::ME, "UNIMPL sceAtracEndEntry()"); return hleNoLog(0); @@ -385,10 +386,14 @@ static u32 sceAtracGetInternalErrorInfo(int atracID, u32 errorAddr) { if (err != 0) { return hleLogError(Log::ME, err); } - ERROR_LOG(Log::ME, "UNIMPL sceAtracGetInternalErrorInfo(%i, %08x)", atracID, errorAddr); + u32 errorCode = atrac->GetInternalCodecError(); if (Memory::IsValidAddress(errorAddr)) - Memory::WriteUnchecked_U32(0, errorAddr); - return 0; + Memory::WriteUnchecked_U32(errorCode, errorAddr); + if (errorCode) { + return hleLogError(Log::ME, 0, "code: %08x", errorCode); + } else { + return hleLogInfo(Log::ME, 0); + } } static u32 sceAtracGetMaxSample(int atracID, u32 maxSamplesAddr) {