diff --git a/Core/HLE/AtracCtx.h b/Core/HLE/AtracCtx.h index 8f2bf38fda..0212aa0884 100644 --- a/Core/HLE/AtracCtx.h +++ b/Core/HLE/AtracCtx.h @@ -291,6 +291,7 @@ public: } u8 *BufferStart(); + void DoState(PointerWrap &p) override; void WriteContextToPSPMem() override; diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 9f74b329a9..f4d99f6313 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -75,13 +75,20 @@ static const int atracDecodeDelay = 2300; -const int PSP_NUM_ATRAC_IDS = 6; static bool atracInited = true; static AtracBase *atracContexts[PSP_NUM_ATRAC_IDS]; static u32 atracContextTypes[PSP_NUM_ATRAC_IDS]; static int atracLibVersion = 0; static u32 atracLibCrc = 0; +// For debugger only. +const AtracBase *__AtracGetCtx(int i, u32 *type) { + if (type) { + *type = atracContextTypes[i]; + } + return atracContexts[i]; +} + void __AtracInit() { _assert_(sizeof(SceAtracContext) == 256); diff --git a/Core/HLE/sceAtrac.h b/Core/HLE/sceAtrac.h index f29c59f798..e0bf3ec86c 100644 --- a/Core/HLE/sceAtrac.h +++ b/Core/HLE/sceAtrac.h @@ -85,6 +85,12 @@ struct SceAtracContext { SceAtracIdInfo info; }; +const int PSP_NUM_ATRAC_IDS = 6; + +class AtracBase; + +const AtracBase *__AtracGetCtx(int i, u32 *type); + // External interface used by sceSas. u32 AtracSasAddStreamData(int atracID, u32 bufPtr, u32 bytesToAdd); u32 AtracSasDecodeData(int atracID, u8* outbuf, u32 outbufPtr, u32 *SamplesNum, u32* finish, int *remains); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 1432305539..aa15f8fec6 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -17,6 +17,7 @@ #include "Common/System/Request.h" #include "Core/HLE/sceAtrac.h" +#include "Core/HLE/AtracCtx.h" // Threads window #include "Core/HLE/sceKernelThread.h" @@ -134,8 +135,17 @@ void DrawThreadView(ImConfig &cfg) { cfg.selectedThread = i; } if (ImGui::IsItemClicked(ImGuiMouseButton_Right)) { + cfg.selectedThread = i; ImGui::OpenPopup("threadPopup"); } + ImGui::TableNextColumn(); + ImGui::Text("%08x", thread.curPC); + ImGui::TableNextColumn(); + ImGui::Text("%08x", thread.entrypoint); + ImGui::TableNextColumn(); + ImGui::Text("%d", thread.priority); + ImGui::TableNextColumn(); + ImGui::Text("%s", ThreadStatusToString(thread.status)); if (ImGui::BeginPopup("threadPopup")) { DebugThreadInfo &thread = info[i]; ImGui::Text("Thread: %s", thread.name); @@ -147,14 +157,6 @@ void DrawThreadView(ImConfig &cfg) { } ImGui::EndPopup(); } - ImGui::TableNextColumn(); - ImGui::Text("%08x", thread.curPC); - ImGui::TableNextColumn(); - ImGui::Text("%08x", thread.entrypoint); - ImGui::TableNextColumn(); - ImGui::Text("%d", thread.priority); - ImGui::TableNextColumn(); - ImGui::Text("%s", ThreadStatusToString(thread.status)); ImGui::PopID(); } @@ -163,6 +165,45 @@ void DrawThreadView(ImConfig &cfg) { ImGui::End(); } +void DrawAtracView(ImConfig &cfg) { + if (!ImGui::Begin("sceAtrac contexts", &cfg.atracOpen)) { + ImGui::End(); + return; + } + + if (ImGui::BeginTable("atracs", 5, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { + ImGui::TableSetupColumn("Type", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("OutChans", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("CurrentSample", ImGuiTableColumnFlags_WidthFixed); + ImGui::TableSetupColumn("RemainingFrames", ImGuiTableColumnFlags_WidthFixed); + + ImGui::TableHeadersRow(); + + for (int i = 0; i < PSP_NUM_ATRAC_IDS; i++) { + u32 type = 0; + const AtracBase *atracBase = __AtracGetCtx(i, &type); + ImGui::TableNextRow(); + ImGui::TableNextColumn(); + + if (!atracBase) { + ImGui::Text("-", type); + continue; + } + + ImGui::Text("%d", type); + ImGui::TableNextColumn(); + ImGui::Text("%d", atracBase->GetOutputChannels()); + ImGui::TableNextColumn(); + ImGui::Text("%d", atracBase->CurrentSample()); + ImGui::TableNextColumn(); + ImGui::Text("%d", atracBase->RemainingFrames()); + } + + ImGui::EndTable(); + } + ImGui::End(); +} + void DrawCallStacks(MIPSDebugInterface *debug, bool *open) { if (!ImGui::Begin("Callstacks", open)) { ImGui::End(); @@ -335,6 +376,7 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug) { ImGui::Checkbox("Callstacks", &cfg_.callstackOpen); ImGui::Checkbox("HLE Modules", &cfg_.modulesOpen); ImGui::Checkbox("HLE Threads", &cfg_.threadsOpen); + ImGui::Checkbox("sceAtrac", &cfg_.atracOpen); ImGui::EndMenu(); } ImGui::EndMainMenuBar(); @@ -364,6 +406,10 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug) { DrawModules(mipsDebug, cfg_); } + if (cfg_.atracOpen) { + DrawAtracView(cfg_); + } + DrawHLEModules(cfg_); } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 214f318c29..389088deb6 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -56,7 +56,7 @@ struct ImConfig { bool callstackOpen = true; bool modulesOpen = true; bool hleModulesOpen = false; - bool atracOpen = false; + bool atracOpen = true; // HLE explorer settings // bool filterByUsed = true;