diff --git a/src/gba/gba.c b/src/gba/gba.c index f10ec8c6c..241291d55 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -388,7 +388,7 @@ void GBADetachDebugger(struct GBA* gba) { gba->cpu->components[GBA_COMPONENT_DEBUGGER] = 0; } -void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) { +bool GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname) { GBAUnloadROM(gba); gba->romVf = vf; gba->pristineRomSize = vf->size(vf); @@ -399,7 +399,7 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char gba->pristineRom = vf->map(vf, gba->pristineRomSize, MAP_READ); if (!gba->pristineRom) { GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM"); - return; + return false; } gba->yankedRomSize = 0; gba->memory.rom = gba->pristineRom; @@ -409,6 +409,7 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char gba->romCrc32 = doCrc32(gba->memory.rom, gba->memory.romSize); GBASavedataInit(&gba->memory.savedata, sav); GBAHardwareInit(&gba->memory.hw, &((uint16_t*) gba->memory.rom)[GPIO_REG_DATA >> 1]); + return true; // TODO: error check } diff --git a/src/gba/gba.h b/src/gba/gba.h index e472a14ac..f4f89e5dd 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -166,7 +166,7 @@ void GBASetBreakpoint(struct GBA* gba, struct ARMComponent* component, uint32_t uint32_t* opcode); void GBAClearBreakpoint(struct GBA* gba, uint32_t address, enum ExecutionMode mode, uint32_t opcode); -void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname); +bool GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char* fname); void GBAYankROM(struct GBA* gba); void GBAUnloadROM(struct GBA* gba); void GBALoadBIOS(struct GBA* gba, struct VFile* vf); diff --git a/src/gba/supervisor/context.c b/src/gba/supervisor/context.c index 6a42be653..9351f643e 100644 --- a/src/gba/supervisor/context.c +++ b/src/gba/supervisor/context.c @@ -114,13 +114,16 @@ bool GBAContextLoadBIOSFromVFile(struct GBAContext* context, struct VFile* bios) bool GBAContextStart(struct GBAContext* context) { struct GBAOptions opts = {}; - GBAConfigMap(&context->config, &opts); if (context->renderer) { GBAVideoAssociateRenderer(&context->gba->video, context->renderer); } - GBALoadROM(context->gba, context->rom, context->save, 0); + if (!GBALoadROM(context->gba, context->rom, context->save, 0)) { + return false; + } + + GBAConfigMap(&context->config, &opts); if (opts.useBios && context->bios) { GBALoadBIOS(context->gba, context->bios); }