GTK2: add crude 'dump memory' button to tools

the offsets in the dump file are as follows (code snippet taken
from the dump function and annotated with locations from gbatek:

                0x2000000
        fp.fseek(0x000000,SEEK_SET); fp.fwrite(MMU.MAIN_MEM,0x800000); //arm9 main mem (8192K)

  4       DTCM            027C0000h 16KB   -     -    -    R/W
or 0x800000 or 0xb000000 . DTCM location in real NDS varies, as the program can select where
it's mapped to, apparently.

        fp.fseek(0x900000,SEEK_SET); fp.fwrite(MMU.ARM9_DTCM,0x4000); //arm9 DTCM (16K)
        fp.fseek(0xA00000,SEEK_SET); fp.fwrite(MMU.ARM9_ITCM,0x8000); //arm9 ITCM (32K)
        fp.fseek(0xB00000,SEEK_SET); fp.fwrite(MMU.ARM9_LCD,0xA4000); //LCD mem 656K

  0       I/O and VRAM    04000000h 64MB   -     -    R/W  R/W

        fp.fseek(0xC00000,SEEK_SET); fp.fwrite(MMU.ARM9_VMEM,0x800); //OAM
                 0xc000bc

        fp.fseek(0xD00000,SEEK_SET); fp.fwrite(MMU.ARM7_ERAM,0x10000); //arm7 WRAM (64K)
        fp.fseek(0xE00000,SEEK_SET); fp.fwrite(MMU.ARM7_WIRAM,0x10000); //arm7 wifi RAM ?
        fp.fseek(0xF00000,SEEK_SET); fp.fwrite(MMU.SWIRAM,0x8000); //arm9/arm7 shared WRAM (32KB)
This commit is contained in:
rofl0r 2021-10-24 15:33:31 +00:00
parent b1ffe0ae76
commit d1d626f221
1 changed files with 68 additions and 0 deletions

View File

@ -132,6 +132,7 @@ static void ImportBackupDialog();
static void OpenNdsDialog();
static void SaveStateDialog();
static void LoadStateDialog();
static void DumpRamDialog();
void Launch();
void Pause();
static void ResetSaveStateTimes();
@ -368,6 +369,8 @@ static const char *ui_description =
" <menuitem action='editjoyctrls'/>"
" </menu>"
" <menu action='ToolsMenu'>"
" <menuitem action='dumpram'/>"
" <separator/>"
" <menuitem action='ioregs'/>"
" <separator/>"
" <menu action='LayersMenu'>"
@ -449,6 +452,7 @@ static const GtkActionEntry action_entries[] = {
{ "editjoyctrls", NULL, "Edit _Joystick controls",NULL, NULL, Edit_Joystick_Controls },
{ "ToolsMenu", NULL, "_Tools" },
{ "dumpram", NULL, "Dump ram to ...", NULL, NULL, DumpRamDialog },
{ "LayersMenu", NULL, "View _Layers" },
{ "HelpMenu", NULL, "_Help" },
@ -1256,6 +1260,70 @@ static void SaveStateDialog()
gtk_widget_destroy(pFileSelection);
}
static void DumpRamDialog()
{
GtkFileFilter *pFilter_ds, *pFilter_any;
GtkWidget *pFileSelection;
GtkWidget *pParent;
gchar *sPath;
if (desmume_running())
Pause();
pParent = GTK_WIDGET(pWindow);
pFilter_ds = gtk_file_filter_new();
gtk_file_filter_add_pattern(pFilter_ds, "*.bin");
gtk_file_filter_set_name(pFilter_ds, "raw file (.bin)");
pFilter_any = gtk_file_filter_new();
gtk_file_filter_add_pattern(pFilter_any, "*");
gtk_file_filter_set_name(pFilter_any, "All files");
/* Creating the selection window */
pFileSelection = gtk_file_chooser_dialog_new("Save memdump To ...",
GTK_WINDOW(pParent),
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
NULL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (pFileSelection), TRUE);
/* Only the dialog window is accepting events: */
gtk_window_set_modal(GTK_WINDOW(pFileSelection), TRUE);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_ds);
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(pFileSelection), pFilter_any);
/* Showing the window */
switch(gtk_dialog_run(GTK_DIALOG(pFileSelection))) {
case GTK_RESPONSE_OK:
sPath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(pFileSelection));
{
EMUFILE_FILE f(sPath,"wb");
DEBUG_dumpMemory(f);
/*
if(savestate_save(sPath) == false ) {
GtkWidget *pDialog = gtk_message_dialog_new(GTK_WINDOW(pFileSelection),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
"Unable to save :\n%s", sPath);
gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog);
} else {
gtk_action_set_sensitive(gtk_action_group_get_action(action_group, "run"), TRUE);
}
*/
}
g_free(sPath);
break;
default:
break;
}
gtk_widget_destroy(pFileSelection);
}
static void RecordAV_x264()
{
GtkFileFilter *pFilter_mkv, *pFilter_mp4, *pFilter_any;