ImDebugger: Add atrac context viewer

This commit is contained in:
Henrik Rydgård 2024-11-15 15:52:09 +01:00
parent 7c16e332e8
commit 2eaffcf510
5 changed files with 70 additions and 10 deletions

View File

@ -291,6 +291,7 @@ public:
}
u8 *BufferStart();
void DoState(PointerWrap &p) override;
void WriteContextToPSPMem() override;

View File

@ -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);

View File

@ -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);

View File

@ -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_);
}

View File

@ -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;