diff --git a/src/boards/mmc1.cpp b/src/boards/mmc1.cpp index 40f1c519..acbbe550 100644 --- a/src/boards/mmc1.cpp +++ b/src/boards/mmc1.cpp @@ -310,6 +310,8 @@ static void GenMMC1Init(CartInfo *info, int prg, int chr, int wram, int battery) if(wram) { WRAM=(uint8*)FCEU_gmalloc(wram*1024); + //mbg 6/17/08 - this shouldve been cleared to re-initialize save ram + memset(WRAM,0,wram*1024); mmc1opts|=1; if(wram>8) mmc1opts|=4; SetupCartPRGMapping(0x10,WRAM,wram*1024,1); diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp index b8f36a66..1d427958 100644 --- a/src/utils/memory.cpp +++ b/src/utils/memory.cpp @@ -29,6 +29,7 @@ ///allocates the specified number of bytes. exits process if this fails void *FCEU_gmalloc(uint32 size) { + void *ret; ret=malloc(size); if(!ret) @@ -36,6 +37,11 @@ void *FCEU_gmalloc(uint32 size) FCEU_PrintError("Error allocating memory! Doing a hard exit."); exit(1); } + //mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first. + //this yields different behavior in debug and release modes. + //specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized + //so we are going to clear it here. + memset(ret,0,size); return ret; } @@ -49,6 +55,11 @@ void *FCEU_malloc(uint32 size) FCEU_PrintError("Error allocating memory!"); return(0); } + //mbg 6/17/08 - sometimes this memory is used as RAM or somesuch without clearing first. + //this yields different behavior in debug and release modes. + //specifically, saveram wasnt getting cleared so the games thought their savefiles were initialized + //so we are going to clear it here. + memset(ret,0,size); return ret; }