From 4ff3aed35bee8a4e9697946b6e8c550d97e898d1 Mon Sep 17 00:00:00 2001 From: ugetab Date: Tue, 20 Apr 2010 17:11:24 +0000 Subject: [PATCH] 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. --- src/ines.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ines.cpp b/src/ines.cpp index 8733b06a..acc83db1 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -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);