fix savestate engine to throw errors when a buggy SFORMAT is passed to AddExState, and fix those errors in m015 and m253

This commit is contained in:
zeromus 2012-06-19 20:44:05 +00:00
parent dc0e5b1678
commit 8d885fa94d
3 changed files with 23 additions and 3 deletions

View File

@ -27,8 +27,8 @@ static uint8 *WRAM=NULL;
static uint32 WRAMSIZE;
static SFORMAT StateRegs[]=
{
{&latchea, 2, "LATCHEA"},
{&latched, 1, "LATCHED"},
{&latchea, 2, "AREG"},
{&latched, 1, "DREG"},
{0}
};
@ -64,6 +64,7 @@ static DECLFW(M15Write)
{
latchea=A;
latched=V;
printf("%04X = %02X\n",A,V);
Sync();
}

View File

@ -37,7 +37,7 @@ static SFORMAT StateRegs[]=
{&IRQa, 4, "IRQA"},
{&IRQCount, 4, "IRQC"},
{&IRQLatch, 4, "IRQL"},
{&IRQClock, 4, "IRQCL"},
{&IRQClock, 4, "IRQK"},
{0}
};

View File

@ -842,6 +842,25 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
void AddExState(void *v, uint32 s, int type, char *desc)
{
if(s==~0)
{
SFORMAT* sf = (SFORMAT*)v;
std::map<std::string,bool> names;
while(sf->v)
{
char tmp[5] = {0};
memcpy(tmp,sf->desc,4);
std::string desc = tmp;
if(names.find(desc) != names.end())
{
printf("OH NO!!! YOU HAVE AN INVALID SFORMAT! POST A BUG TICKET ALONG WITH INFO ON THE ROM YOURE USING\n");
exit(0);
}
names[desc] = true;
sf++;
}
}
if(desc)
{
SFMDATA[SFEXINDEX].desc=(char *)FCEU_malloc(strlen(desc)+1);