From 264dc80808b6b34c84b007436f29ef16294e7f47 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 8 Apr 2010 20:33:12 +0000 Subject: [PATCH] win32: add feature: dump all memory (new button in memory viewer; inspect debug.cpp for a map of the file) --- desmume/src/debug.cpp | 20 ++++++++++++++++++++ desmume/src/debug.h | 2 ++ desmume/src/windows/memView.cpp | 22 +++++++++++++--------- desmume/src/windows/resource.h | 1 + desmume/src/windows/resources.rc | Bin 913098 -> 913612 bytes 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/desmume/src/debug.cpp b/desmume/src/debug.cpp index c6255d59c..a0ed879e0 100644 --- a/desmume/src/debug.cpp +++ b/desmume/src/debug.cpp @@ -208,6 +208,26 @@ void DEBUG_reset() printf("DEBUG_reset: %08X\n",&DebugStatistics::print); //force a reference to this function } +static void DEBUG_dumpMemory_fill(EMUFILE *fp, u32 size) +{ + static std::vector buf; + buf.resize(size); + memset(&buf[0],0,size); + fp->fwrite(&buf[0],size); +} + +void DEBUG_dumpMemory(EMUFILE* fp) +{ + fp->fseek(0x000000,SEEK_SET); fp->fwrite(MMU.MAIN_MEM,0x800000); //arm9 main mem (8192K) + 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 + fp->fseek(0xC00000,SEEK_SET); fp->fwrite(MMU.ARM9_VMEM,0x800); //OAM + 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) +} + //---------------------------------------------------- std::vector Logger::channels; diff --git a/desmume/src/debug.h b/desmume/src/debug.h index 9a3aeb181..56bb0e0fc 100644 --- a/desmume/src/debug.h +++ b/desmume/src/debug.h @@ -28,6 +28,7 @@ #include "types.h" #include "mem.h" +#include "emufile.h" struct DebugStatistics { @@ -47,6 +48,7 @@ struct DebugStatistics extern DebugStatistics DEBUG_statistics; void DEBUG_reset(); +void DEBUG_dumpMemory(EMUFILE* fp); struct armcpu_t; diff --git a/desmume/src/windows/memView.cpp b/desmume/src/windows/memView.cpp index 37223c57d..df56e8475 100644 --- a/desmume/src/windows/memView.cpp +++ b/desmume/src/windows/memView.cpp @@ -279,6 +279,7 @@ INT_PTR CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } return 1; + case IDC_DUMPALL: case IDC_RAWDUMP: { char fileName[256] = ""; @@ -296,16 +297,19 @@ INT_PTR CALLBACK MemView_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if(GetSaveFileName(&ofn)) { - FILE *f; - u8 memory[0x100]; - MMU_DumpMemBlock(wnd->cpu, wnd->address, 0x100, memory); - - f = fopen(fileName, "ab"); - - fwrite(memory, 0x100, 1, f); - - fclose(f); + if(LOWORD(wParam) == IDC_RAWDUMP) + { + EMUFILE_FILE f(fileName,"ab"); + u8 memory[0x100]; + MMU_DumpMemBlock(wnd->cpu, wnd->address, 0x100, memory); + f.fwrite(memory, 0x100); + } + else + { + EMUFILE_FILE f(fileName,"wb"); + DEBUG_dumpMemory(&f); + } } } return 1; diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index 95647a470..1c0ddace6 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -336,6 +336,7 @@ #define IDC_SYNCHMODE_SYNCH 1013 #define IDC_FIRMWAREBROWSE 1014 #define IDC_VOLUME 1014 +#define IDC_DUMPALL 1014 #define IDC_SYNCHMETHOD_N 1015 #define IDC_FIRMWAREBOOT 1016 #define IDC_SYNCHMETHOD_Z 1016 diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index cbd2ec6d7a4defeda0780d04d9d435d771e7646b..bf8492814d8f9438a1ece97c63d2252abedadc32 100644 GIT binary patch delta 898 zcmX?g*Zj;w^M);q3U-q-xGbhe*fDDGn=u$L=rEW8u_1#wgX#3b8dlToT8B6%FiuX8 zJk6d%jMTv zPV=sq?jXUz0hZW)YC6-WkIW_vM$;EgXEvR_pqGPh`y3laKgQ_+-OOsdhG3T)08}!a(x!j7 z$h>TNPa+RT`<*^!AZ7t#*6nxt*hG{WO(t)ACOY{5w-Vfa0gTf<4sz-M-Di$4ZaO0) zJJfwU4su#S-A7tDn=x1-3}mnXyAK%5o7xX-W7~dU8~dA1U|<;|Lbe?kvfH0HaOTya zxKD?1y52iZmF+r*IQtNhJiTr{8^`pT{hVeHFHQT!rb47YM5i}gWhR(Pu(-Y*==$v! z4s$(lK}`wE+6%b2w-<2nICu_HmxGe`ruGLBJlh{c@MaaDhC3uh0~0gXbO9&UZPNv& MFo|pja@QyW06kL%`v3p{ delta 471 zcmX@}(EQY0^M);q3U<@OY#7C+2QV`#O^>i+)R^8E$-~2J%wRE{v6It5`5cRR+p-R&5co(tB1$YX5d;oio>