Found a release-version crash error when looking up the mapper name for the message log(which was tied to message display). Fixing it required renaming a typedef struct to stop confusing the debugger/compiler, and then making a simple loop that tests against the listed mapper number instead of the array number.

This commit is contained in:
ugetab 2010-04-20 17:11:24 +00:00
parent efa51e4d35
commit 4ff3aed35b
1 changed files with 16 additions and 4 deletions

View File

@ -534,9 +534,9 @@ typedef struct {
char* name;
int number;
void (*init)(CartInfo *);
} BMAPPING;
} BMAPPINGLocal;
static BMAPPING bmap[] = {
static BMAPPINGLocal bmap[] = {
{"NROM", 0, NROM_Init},
{"MMC1", 1, Mapper1_Init},
{"UNROM", 2, UNROM_Init},
@ -829,8 +829,20 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
FCEU_printf("%02x",iNESCart.MD5[x]);
FCEU_printf("\n");
}
char* mappername = "Not Listed";
for(int mappertest=0;mappertest< (sizeof bmap / sizeof bmap[0]) - 1;mappertest++)
{
if (bmap[mappertest].number == MapperNo) {
mappername = bmap[mappertest].name;
break;
}
}
FCEU_printf(" Mapper #: %d\n Mapper name: %s\n Mirroring: %s\n",
MapperNo, bmap[MapperNo].name, Mirroring==2?"None(Four-screen)":Mirroring?"Vertical":"Horizontal");
MapperNo, mappername, Mirroring==2?"None(Four-screen)":Mirroring?"Vertical":"Horizontal");
if(head.ROM_type&2) FCEU_printf(" Battery-backed.\n");
if(head.ROM_type&4) FCEU_printf(" Trained.\n");
@ -1439,7 +1451,7 @@ static void iNESPower(void)
static int NewiNES_Init(int num)
{
BMAPPING *tmp=bmap;
BMAPPINGLocal *tmp=bmap;
if(GameInfo->type == GIT_VSUNI)
AddExState(FCEUVSUNI_STATEINFO, ~0, 0, 0);