From 5263070da50ffaf0111c5fa3673751432b06d138 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sun, 3 May 2009 18:10:30 +0000 Subject: [PATCH] although the last change probably wouldve worked, this fix solves the real problem: save ram didnt close file pointers when roms reset --- desmume/src/NDSSystem.cpp | 6 ++++++ desmume/src/mc.cpp | 8 ++++---- desmume/src/windows/DeSmuME_2005.sln | 3 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index c3ed274a5..f8a0001c1 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -884,6 +884,12 @@ void NDS_Reset(BOOL resetBySavestate) if (!header) return ; + if (MMU.bupmem.fp) + { + fclose(MMU.bupmem.fp); + MMU.bupmem.fp = NULL; + } + lagframecounter=0; LagFrameFlag=0; lastLag=0; diff --git a/desmume/src/mc.cpp b/desmume/src/mc.cpp index 54a8683e5..f4dcb547d 100644 --- a/desmume/src/mc.cpp +++ b/desmume/src/mc.cpp @@ -199,9 +199,9 @@ void mc_reset_com(memory_chip_t *mc) void mc_realloc(memory_chip_t *mc, int type, u32 size) { - if(mc->data) delete[] mc->data; - mc_init(mc, type); - mc_alloc(mc, size); + if(mc->data) delete[] mc->data; + mc_init(mc, type); + mc_alloc(mc, size); } void mc_load_file(memory_chip_t *mc, const char* filename) @@ -213,7 +213,7 @@ void mc_load_file(memory_chip_t *mc, const char* filename) if(movieMode != MOVIEMODE_INACTIVE) { mc->filename = strdup(filename); - file = fopen(filename, "wb+"); + return; } else file = fopen(filename, "rb+"); diff --git a/desmume/src/windows/DeSmuME_2005.sln b/desmume/src/windows/DeSmuME_2005.sln index c1443642b..2eb8ee159 100644 --- a/desmume/src/windows/DeSmuME_2005.sln +++ b/desmume/src/windows/DeSmuME_2005.sln @@ -17,4 +17,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + AMDCaProjectFile = D:\svn\desmume\trunk\desmume\src\windows\CodeAnalyst\DeSmuME_2005.caw + EndGlobalSection EndGlobal