mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
ImDebugger: Add function to dump raw at3 frames from the atrac tool.
This commit is contained in:
@@ -310,8 +310,13 @@ void __KernelMemoryInit()
|
||||
kernelMemory.Init(PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), false);
|
||||
userMemory.Init(PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), false);
|
||||
volatileMemory.Init(PSP_GetVolatileMemoryStart(), PSP_GetVolatileMemoryEnd() - PSP_GetVolatileMemoryStart(), false);
|
||||
Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase());
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetKernelMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInit");
|
||||
|
||||
Memory::Memset(PSP_GetKernelMemoryBase(), 0, PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase());
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetKernelMemoryBase(), PSP_GetKernelMemoryEnd() - PSP_GetKernelMemoryBase(), "MemInitK");
|
||||
|
||||
Memory::Memset(PSP_GetUserMemoryBase(), 0, PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase());
|
||||
NotifyMemInfo(MemBlockFlags::WRITE, PSP_GetUserMemoryBase(), PSP_GetUserMemoryEnd() - PSP_GetUserMemoryBase(), "MemInitU");
|
||||
|
||||
INFO_LOG(Log::sceKernel, "Kernel and user memory pools initialized");
|
||||
|
||||
vplWaitTimer = CoreTiming::RegisterEvent("VplTimeout", __KernelVplTimeout);
|
||||
|
||||
@@ -1066,6 +1066,23 @@ void DrawAudioDecodersView(ImConfig &cfg, ImControl &control) {
|
||||
ImGui::Text("can't access sas state");
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->BufferState() == ATRAC_STATUS_ALL_DATA_LOADED) {
|
||||
if (ImGui::Button("Save to disk...")) {
|
||||
System_BrowseForFileSave(cfg.requesterToken, "Save AT3 file", "song.at3", BrowseFileType::ATRAC3, [=](const std::string &filename, int) {
|
||||
const u8 *data = Memory::GetPointerRange(info.buffer, info.bufferByte);
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
FILE *file = File::OpenCFile(Path(filename), "wb");
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
fwrite(data, 1, info.bufferByte, file);
|
||||
fclose(file);
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ImGui::Text("loop: %d", ctx->LoopNum());
|
||||
}
|
||||
@@ -1591,6 +1608,13 @@ static void DrawSymbols(const MIPSDebugInterface *debug, ImConfig &cfg, ImContro
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
void ImAtracToolWindow::Load() {
|
||||
if (File::ReadBinaryFileToString(Path(atracPath_), &data_)) {
|
||||
track_.reset(new Track());
|
||||
AnalyzeAtracTrack((const u8 *)data_.data(), (u32)data_.size(), track_.get(), &error_);
|
||||
}
|
||||
}
|
||||
|
||||
void ImAtracToolWindow::Draw(ImConfig &cfg) {
|
||||
if (!ImGui::Begin("Atrac Tool", &cfg.atracToolOpen) || !g_symbolMap) {
|
||||
ImGui::End();
|
||||
@@ -1600,18 +1624,15 @@ void ImAtracToolWindow::Draw(ImConfig &cfg) {
|
||||
ImGui::InputText("File", atracPath_, sizeof(atracPath_));
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Choose...")) {
|
||||
System_BrowseForFile(cfg.requesterToken, "Choose AT3 file", BrowseFileType::ATRAC3, [&](const std::string &filename, int) {
|
||||
System_BrowseForFile(cfg.requesterToken, "Choose AT3 file", BrowseFileType::ATRAC3, [this](const std::string &filename, int) {
|
||||
truncate_cpy(atracPath_, filename);
|
||||
Load();
|
||||
}, nullptr);
|
||||
}
|
||||
|
||||
if (strlen(atracPath_) > 0) {
|
||||
if (ImGui::Button("Load")) {
|
||||
track_.reset(new Track());
|
||||
std::string data;
|
||||
if (File::ReadBinaryFileToString(Path(atracPath_), &data)) {
|
||||
AnalyzeAtracTrack((const u8 *)data.data(), (u32)data.size(), track_.get(), &error_);
|
||||
}
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1622,6 +1643,24 @@ void ImAtracToolWindow::Draw(ImConfig &cfg) {
|
||||
ImGui::Text("First valid sample: %08x", track_->FirstSampleOffsetFull());
|
||||
}
|
||||
|
||||
if (data_.size()) {
|
||||
if (ImGui::Button("Dump 64 raw frames")) {
|
||||
std::string firstFrames = data_.substr(track_->dataByteOffset, track_->bytesPerFrame * 64);
|
||||
System_BrowseForFileSave(cfg.requesterToken, "Save .at3raw", "at3.raw", BrowseFileType::ANY, [firstFrames](const std::string &filename, int) {
|
||||
FILE *f = File::OpenCFile(Path(filename), "wb");
|
||||
if (f) {
|
||||
fwrite(firstFrames.data(), 1, firstFrames.size(), f);
|
||||
fclose(f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (ImGui::Button("Unload")) {
|
||||
data_.clear();
|
||||
track_.reset(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (!error_.empty()) {
|
||||
ImGui::TextUnformatted(error_.c_str());
|
||||
}
|
||||
@@ -2458,6 +2497,7 @@ void ImConfig::SyncConfig(IniFile *ini, bool save) {
|
||||
sync.Sync("logConfigOpen", &logConfigOpen, false);
|
||||
sync.Sync("luaConsoleOpen", &luaConsoleOpen, false);
|
||||
sync.Sync("utilityModulesOpen", &utilityModulesOpen, false);
|
||||
sync.Sync("atracToolOpen", &atracToolOpen, false);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
char name[64];
|
||||
snprintf(name, sizeof(name), "memory%dOpen", i + 1);
|
||||
|
||||
@@ -192,10 +192,12 @@ struct Track;
|
||||
class ImAtracToolWindow {
|
||||
public:
|
||||
void Draw(ImConfig &cfg);
|
||||
void Load();
|
||||
|
||||
char atracPath_[1024]{};
|
||||
std::unique_ptr<Track> track_;
|
||||
std::string error_;
|
||||
std::string data_;
|
||||
};
|
||||
|
||||
enum class ImCmd {
|
||||
|
||||
Reference in New Issue
Block a user