From 818e7a99bd04be41b0cebf3af51a1c994e085ff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 8 Mar 2025 23:52:35 +0100 Subject: [PATCH] minor refactor --- Core/HLE/AtracCtx.cpp | 8 ++++++++ Core/HLE/AtracCtx.h | 1 - Core/HLE/AtracCtx2.cpp | 27 +-------------------------- Core/HLE/AtracCtx2.h | 2 +- Core/HLE/sceAtrac.cpp | 2 ++ Core/HLE/sceAtrac.h | 3 ++- 6 files changed, 14 insertions(+), 29 deletions(-) diff --git a/Core/HLE/AtracCtx.cpp b/Core/HLE/AtracCtx.cpp index 761117fa40..96e2156a01 100644 --- a/Core/HLE/AtracCtx.cpp +++ b/Core/HLE/AtracCtx.cpp @@ -234,6 +234,14 @@ void Track::DebugLog() { } int AnalyzeAtracTrack(u32 addr, u32 size, Track *track) { + // 72 is about the size of the minimum required data to even be valid. + + // TODO: Validate stuff more. + if (Memory::ReadUnchecked_U32(addr) != RIFF_CHUNK_MAGIC) { + ERROR_LOG(Log::ME, "Couldn't find RIFF header"); + return SCE_ERROR_ATRAC_UNKNOWN_FORMAT; + } + struct RIFFFmtChunk { u16_le fmtTag; u16_le channels; diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index e36e4c85bd..ae292b748f 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -356,6 +356,5 @@ private: u32 bufferValidBytes_ = 0; u32 bufferHeaderSize_ = 0; - // Refactor? int atracID_ = -1; }; diff --git a/Core/HLE/AtracCtx2.cpp b/Core/HLE/AtracCtx2.cpp index 8b4be5cb4a..3ed3e91a0b 100644 --- a/Core/HLE/AtracCtx2.cpp +++ b/Core/HLE/AtracCtx2.cpp @@ -9,31 +9,6 @@ // Windows\x64\debug\PPSSPPHeadless.exe --root pspautotests/tests/../ -o --compare --timeout=30 --graphics=software pspautotests/tests/audio/atrac/... --ignore pspautotests/tests/audio/atrac/second/resetting.prx --ignore pspautotests/tests/audio/atrac/second/replay.prx // // See the big comment in sceAtrac.cpp for an overview of the different modes of operation. -// -// Test cases -// -// Halfway buffer -// -// * None found yet -// -// All-data-loaded -// -// * MotoGP (menu music with specified loop). Simple repeated calls to sceAtracDecodeData -// * Archer MacLean's Mercury (in-game, not menu) -// * Crisis Core -// -// Streaming -// -// - Good ones (early) -// * Everybody's Golf 2 (0x2000 buffer size, loop from end) -// * Burnout Legends (no loop, 0x1800 buffer size) -// * Suicide Barbie -// - Others -// * Bleach -// * God of War: Chains of Olympus -// * Ape Academy 2 (bufsize 8192) -// * Half Minute Hero (bufsize 65536) -// * Flatout (tricky! needs investigation) Atrac2::Atrac2(int atracID, u32 contextAddr, int codecType) { @@ -85,7 +60,7 @@ int Atrac2::SetData(const Track &track, u32 buffer, u32 readSize, u32 bufferSize } else { bufferState_ = ATRAC_STATUS_HALFWAY_BUFFER; } - return hleLogDebug(Log::ME, 0); + return 0; } u32 Atrac2::SetSecondBuffer(u32 secondBuffer, u32 secondBufferSize) { diff --git a/Core/HLE/AtracCtx2.h b/Core/HLE/AtracCtx2.h index 65a743650a..b2afd4614e 100644 --- a/Core/HLE/AtracCtx2.h +++ b/Core/HLE/AtracCtx2.h @@ -4,10 +4,10 @@ #include "Core/HLE/AtracCtx.h" - class Atrac2 : public AtracBase { public: Atrac2(int atracID, u32 contextAddr, int codecType); + void DoState(PointerWrap &p) override; int GetID() const override { return 0; } diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index d136338664..1fbe2fe617 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -129,6 +129,7 @@ void __AtracNotifyLoadModule(int version, u32 crc, u32 bssAddr, int bssSize) { g_atracBSS = bssAddr; g_atracMaxContexts = atracLibVersion <= 0x101 ? 4 : 6; // Need to figure out where the cutoff is. _dbg_assert_(bssSize >= g_atracMaxContexts * sizeof(SceAtracContext)); + NotifyMemInfo(MemBlockFlags::ALLOC, g_atracBSS, g_atracMaxContexts * sizeof(SceAtracContext), "AtracContext"); } void __AtracNotifyUnloadModule() { @@ -137,6 +138,7 @@ void __AtracNotifyUnloadModule() { INFO_LOG(Log::ME, "Atrac module unloaded."); g_atracBSS = 0; g_atracMaxContexts = 6; // TODO: We should make this zero here. + NotifyMemInfo(MemBlockFlags::FREE, g_atracBSS, g_atracMaxContexts * sizeof(SceAtracContext), "AtracContext"); } static u32 GetAtracContextAddress(int atracID) { diff --git a/Core/HLE/sceAtrac.h b/Core/HLE/sceAtrac.h index 5fff1a062e..316a1acb9c 100644 --- a/Core/HLE/sceAtrac.h +++ b/Core/HLE/sceAtrac.h @@ -79,7 +79,8 @@ struct SceAtracIdInfo { u32_le bufferByte; // 64 u32_le secondBufferByte; // 68 // make sure the size is 128 - u8 unk[56]; + u8 unk[52]; + u32_le atracID; }; struct SceAtracContext {