From d87970f4adb65d237b57c42a5a2241fafefc4713 Mon Sep 17 00:00:00 2001 From: owomomo Date: Mon, 10 Jun 2019 17:25:37 +0800 Subject: [PATCH] ... --- src/file.cpp | 6 +++--- src/ines.cpp | 16 ++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index a75ca968..9860d87e 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -261,9 +261,9 @@ FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext FILE *ipsfile=0; FCEUFILE *fceufp=0; - bool read = (std::string)mode == "rb"; - bool write = (std::string)mode == "wb"; - if((read&&write) || (!read&&!write)) + bool read = !strcmp(mode, "rb"); + bool write = !strcmp(mode, "wb"); + if(read && write || !read && !write) { FCEU_PrintError("invalid file open mode specified (only wb and rb are supported)"); return 0; diff --git a/src/ines.cpp b/src/ines.cpp index 41727e74..1443b23f 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -63,7 +63,7 @@ static int iNES_Init(int num); static int MapperNo = 0; -static int iNES2 = 0; +int iNES2 = 0; static DECLFR(TrainerRead) { return(trainerpoo[A & 0x1FF]); @@ -443,13 +443,8 @@ static int not_power2[] = { 53, 198, 228 }; -typedef struct { - char *name; - int32 number; - void (*init)(CartInfo *); -} BMAPPINGLocal; -static BMAPPINGLocal bmap[] = { +BMAPPINGLocal bmap[] = { {"NROM", 0, NROM_Init}, {"MMC1", 1, Mapper1_Init}, {"UNROM", 2, UNROM_Init}, @@ -729,12 +724,9 @@ static BMAPPINGLocal bmap[] = { int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) { struct md5_context md5; - if (FCEU_fread(&head, 1, 16, fp) != 16) + if (FCEU_fread(&head, 1, 16, fp) != 16 || memcmp(&head, "NES\x1A", 4)) return 0; - - if (memcmp(&head, "NES\x1a", 4)) - return 0; - + head.cleanup(); memset(&iNESCart, 0, sizeof(iNESCart));