From 38187bac7a5f1fca58f82f64af06881e1999dc68 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 15 Oct 2014 01:41:50 -0700 Subject: [PATCH 1/3] Rename crc32 to doCrc32 to avoid symbol naming conflicts --- src/gba/gba.c | 2 +- src/util/crc32.c | 2 +- src/util/crc32.h | 2 +- src/util/patch-ups.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gba/gba.c b/src/gba/gba.c index 745ee5ac9..46bd6941d 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -403,7 +403,7 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char gba->memory.rom = gba->pristineRom; gba->activeFile = fname; gba->memory.romSize = gba->pristineRomSize; - gba->romCrc32 = crc32(gba->memory.rom, gba->memory.romSize); + gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize); GBASavedataInit(&gba->memory.savedata, sav); GBAGPIOInit(&gba->memory.gpio, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]); _checkOverrides(gba, ((struct GBACartridge*) gba->memory.rom)->id); diff --git a/src/util/crc32.c b/src/util/crc32.c index afa54022e..77c1715f1 100644 --- a/src/util/crc32.c +++ b/src/util/crc32.c @@ -94,7 +94,7 @@ static uint32_t crc32Table[] = { 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; -uint32_t crc32(const void* buf, size_t size) { +uint32_t doCrc32(const void* buf, size_t size) { return updateCrc32(0, buf, size); } diff --git a/src/util/crc32.h b/src/util/crc32.h index 98dc46ec0..5ff4d151d 100644 --- a/src/util/crc32.h +++ b/src/util/crc32.h @@ -5,7 +5,7 @@ struct VFile; -uint32_t crc32(const void* buf, size_t size); +uint32_t doCrc32(const void* buf, size_t size); uint32_t updateCrc32(uint32_t crc, const void* buf, size_t size); uint32_t fileCrc32(struct VFile* file, size_t endOffset); diff --git a/src/util/patch-ups.c b/src/util/patch-ups.c index 63ee8dcf7..999fdf299 100644 --- a/src/util/patch-ups.c +++ b/src/util/patch-ups.c @@ -90,7 +90,7 @@ bool _UPSApplyPatch(struct Patch* patch, void* out, size_t outSize) { } patch->vf->seek(patch->vf, 0, SEEK_SET); - if (crc32(out, outSize) != goodCrc32) { + if (doCrc32(out, outSize) != goodCrc32) { return false; } return true; From 4cf5b533fb460a21c492c706692cbf94fdffd6ec Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 15 Oct 2014 02:13:34 -0700 Subject: [PATCH 2/3] Fix overlooked crc32 call --- src/gba/gba.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gba/gba.c b/src/gba/gba.c index 46bd6941d..8516efa21 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -443,7 +443,7 @@ void GBAApplyPatch(struct GBA* gba, struct Patch* patch) { return; } gba->memory.romSize = patchedSize; - gba->romCrc32 = crc32(gba->memory.rom, gba->memory.romSize); + gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize); } void GBATimerUpdateRegister(struct GBA* gba, int timer) { From 70f94db208293a100b46bda90d6c9b6f720de6c1 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Wed, 15 Oct 2014 02:13:46 -0700 Subject: [PATCH 3/3] Fix some uninitialized reads --- src/gba/gba.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gba/gba.c b/src/gba/gba.c index 8516efa21..2a756b9d8 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -124,6 +124,7 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) { GBAInterruptHandlerInit(&cpu->irqh); GBAMemoryInit(gba); + GBASavedataInit(&gba->memory.savedata, 0); gba->video.p = gba; GBAVideoInit(&gba->video); @@ -151,6 +152,8 @@ static void GBAInit(struct ARMCore* cpu, struct ARMComponent* component) { gba->logLevel = GBA_LOG_INFO | GBA_LOG_WARN | GBA_LOG_ERROR | GBA_LOG_FATAL; gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS); + + gba->busyLoop = -1; } void GBADestroy(struct GBA* gba) {