fix a bug which caused mmc1 (and maybe other mappers) not to re-initialize their save ram whenever they were replayed multiple times in release mode

This commit is contained in:
zeromus 2008-06-17 08:12:48 +00:00
parent b82c266971
commit 742969facb
2 changed files with 13 additions and 0 deletions

View File

@ -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);

View File

@ -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;
}