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 cbd2ec6d7..bf8492814 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ