mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-03-06 14:27:44 +00:00
Add option to dump the contents of RAM to a file
This commit is contained in:
parent
0aefdf4753
commit
4e62b32d60
|
@ -1228,6 +1228,15 @@ void UpdateMemoryCards()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DumpRAM(const char* filename)
|
||||||
|
{
|
||||||
|
auto fp = FileSystem::OpenManagedCFile(filename, "wb");
|
||||||
|
if (!fp)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return std::fwrite(Bus::g_ram, Bus::RAM_SIZE, 1, fp.get()) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
bool HasMedia()
|
bool HasMedia()
|
||||||
{
|
{
|
||||||
return g_cdrom.HasMedia();
|
return g_cdrom.HasMedia();
|
||||||
|
@ -1333,7 +1342,8 @@ bool RemoveMediaPathFromPlaylist(u32 index)
|
||||||
|
|
||||||
if (GetMediaPlaylistIndex() == index)
|
if (GetMediaPlaylistIndex() == index)
|
||||||
{
|
{
|
||||||
g_host_interface->AddFormattedOSDMessage(10.0f, "Removing current media from playlist, removing media from CD-ROM.");
|
g_host_interface->AddFormattedOSDMessage(10.0f,
|
||||||
|
"Removing current media from playlist, removing media from CD-ROM.");
|
||||||
g_cdrom.RemoveMedia();
|
g_cdrom.RemoveMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,9 @@ void UpdateControllerSettings();
|
||||||
void ResetControllers();
|
void ResetControllers();
|
||||||
void UpdateMemoryCards();
|
void UpdateMemoryCards();
|
||||||
|
|
||||||
|
/// Dumps RAM to a file.
|
||||||
|
bool DumpRAM(const char* filename);
|
||||||
|
|
||||||
bool HasMedia();
|
bool HasMedia();
|
||||||
bool InsertMedia(const char* path);
|
bool InsertMedia(const char* path);
|
||||||
void RemoveMedia();
|
void RemoveMedia();
|
||||||
|
|
|
@ -662,6 +662,13 @@ void MainWindow::connectSignals()
|
||||||
else
|
else
|
||||||
m_host_interface->stopDumpingAudio();
|
m_host_interface->stopDumpingAudio();
|
||||||
});
|
});
|
||||||
|
connect(m_ui.actionDumpRAM, &QAction::triggered, [this]() {
|
||||||
|
const QString filename = QFileDialog::getSaveFileName(this, tr("Destination File"));
|
||||||
|
if (filename.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_host_interface->dumpRAM(filename);
|
||||||
|
});
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowVRAM, "Debug", "ShowVRAM");
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowVRAM, "Debug", "ShowVRAM");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowGPUState, "Debug", "ShowGPUState");
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowGPUState, "Debug", "ShowGPUState");
|
||||||
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowCDROMState, "Debug",
|
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.actionDebugShowCDROMState, "Debug",
|
||||||
|
|
|
@ -149,9 +149,10 @@
|
||||||
<addaction name="menuCPUExecutionMode"/>
|
<addaction name="menuCPUExecutionMode"/>
|
||||||
<addaction name="menuRenderer"/>
|
<addaction name="menuRenderer"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDumpAudio"/>
|
|
||||||
<addaction name="actionDebugDumpCPUtoVRAMCopies"/>
|
<addaction name="actionDebugDumpCPUtoVRAMCopies"/>
|
||||||
<addaction name="actionDebugDumpVRAMtoCPUCopies"/>
|
<addaction name="actionDebugDumpVRAMtoCPUCopies"/>
|
||||||
|
<addaction name="actionDumpAudio"/>
|
||||||
|
<addaction name="actionDumpRAM"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDebugShowVRAM"/>
|
<addaction name="actionDebugShowVRAM"/>
|
||||||
<addaction name="actionDebugShowGPUState"/>
|
<addaction name="actionDebugShowGPUState"/>
|
||||||
|
@ -484,6 +485,11 @@
|
||||||
<string>Dump Audio</string>
|
<string>Dump Audio</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionDumpRAM">
|
||||||
|
<property name="text">
|
||||||
|
<string>Dump RAM...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionDebugShowGPUState">
|
<action name="actionDebugShowGPUState">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
|
@ -1026,6 +1026,24 @@ void QtHostInterface::stopDumpingAudio()
|
||||||
StopDumpingAudio();
|
StopDumpingAudio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtHostInterface::dumpRAM(const QString& filename)
|
||||||
|
{
|
||||||
|
if (!isOnWorkerThread())
|
||||||
|
{
|
||||||
|
QMetaObject::invokeMethod(this, "dumpRAM", Q_ARG(const QString&, filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System::IsShutdown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const std::string filename_str = filename.toStdString();
|
||||||
|
if (System::DumpRAM(filename_str.c_str()))
|
||||||
|
ReportFormattedMessage("RAM dumped to '%s'", filename_str.c_str());
|
||||||
|
else
|
||||||
|
ReportFormattedMessage("Failed to dump RAM to '%s'", filename_str.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
void QtHostInterface::saveScreenshot()
|
void QtHostInterface::saveScreenshot()
|
||||||
{
|
{
|
||||||
if (!isOnWorkerThread())
|
if (!isOnWorkerThread())
|
||||||
|
|
|
@ -151,6 +151,7 @@ public Q_SLOTS:
|
||||||
void setAudioOutputMuted(bool muted);
|
void setAudioOutputMuted(bool muted);
|
||||||
void startDumpingAudio();
|
void startDumpingAudio();
|
||||||
void stopDumpingAudio();
|
void stopDumpingAudio();
|
||||||
|
void dumpRAM(const QString& filename);
|
||||||
void saveScreenshot();
|
void saveScreenshot();
|
||||||
void redrawDisplayWindow();
|
void redrawDisplayWindow();
|
||||||
void toggleFullscreen();
|
void toggleFullscreen();
|
||||||
|
|
|
@ -904,6 +904,7 @@ void SDLHostInterface::DrawQuickSettingsMenu()
|
||||||
|
|
||||||
void SDLHostInterface::DrawDebugMenu()
|
void SDLHostInterface::DrawDebugMenu()
|
||||||
{
|
{
|
||||||
|
const bool system_valid = System::IsValid();
|
||||||
Settings::DebugSettings& debug_settings = g_settings.debugging;
|
Settings::DebugSettings& debug_settings = g_settings.debugging;
|
||||||
bool settings_changed = false;
|
bool settings_changed = false;
|
||||||
|
|
||||||
|
@ -931,6 +932,9 @@ void SDLHostInterface::DrawDebugMenu()
|
||||||
settings_changed |= ImGui::MenuItem("Dump CPU to VRAM Copies", nullptr, &debug_settings.dump_cpu_to_vram_copies);
|
settings_changed |= ImGui::MenuItem("Dump CPU to VRAM Copies", nullptr, &debug_settings.dump_cpu_to_vram_copies);
|
||||||
settings_changed |= ImGui::MenuItem("Dump VRAM to CPU Copies", nullptr, &debug_settings.dump_vram_to_cpu_copies);
|
settings_changed |= ImGui::MenuItem("Dump VRAM to CPU Copies", nullptr, &debug_settings.dump_vram_to_cpu_copies);
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Dump RAM...", nullptr, nullptr, system_valid))
|
||||||
|
DoDumpRAM();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
settings_changed |= ImGui::MenuItem("Show VRAM", nullptr, &debug_settings.show_vram);
|
settings_changed |= ImGui::MenuItem("Show VRAM", nullptr, &debug_settings.show_vram);
|
||||||
|
@ -1511,6 +1515,22 @@ void SDLHostInterface::DoChangeDisc()
|
||||||
System::ResetPerformanceCounters();
|
System::ResetPerformanceCounters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SDLHostInterface::DoDumpRAM()
|
||||||
|
{
|
||||||
|
Assert(!System::IsShutdown());
|
||||||
|
|
||||||
|
nfdchar_t* path = nullptr;
|
||||||
|
if (!NFD_SaveDialog("bin", nullptr, &path) || !path || std::strlen(path) == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (System::DumpRAM(path))
|
||||||
|
AddFormattedOSDMessage(5.0f, "Dumped RAM to '%s'", path);
|
||||||
|
else
|
||||||
|
AddFormattedOSDMessage(10.0f, "Failed to dump RAM to '%s'", path);
|
||||||
|
|
||||||
|
System::ResetPerformanceCounters();
|
||||||
|
}
|
||||||
|
|
||||||
void SDLHostInterface::Run()
|
void SDLHostInterface::Run()
|
||||||
{
|
{
|
||||||
while (!m_quit_request)
|
while (!m_quit_request)
|
||||||
|
|
|
@ -79,6 +79,7 @@ private:
|
||||||
void DrawImGuiWindows() override;
|
void DrawImGuiWindows() override;
|
||||||
void DoStartDisc();
|
void DoStartDisc();
|
||||||
void DoChangeDisc();
|
void DoChangeDisc();
|
||||||
|
void DoDumpRAM();
|
||||||
|
|
||||||
void HandleSDLEvent(const SDL_Event* event);
|
void HandleSDLEvent(const SDL_Event* event);
|
||||||
void ProcessEvents();
|
void ProcessEvents();
|
||||||
|
|
Loading…
Reference in a new issue