GBA: Error check to make sure ROM and BIOS mapping succeed

This commit is contained in:
Jeffrey Pfau 2014-12-09 15:19:51 -08:00
parent 7edf934a59
commit df3f2796f7
1 changed files with 10 additions and 1 deletions

View File

@ -425,6 +425,10 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char
gba->pristineRomSize = vf->seek(vf, 0, SEEK_END); gba->pristineRomSize = vf->seek(vf, 0, SEEK_END);
vf->seek(vf, 0, SEEK_SET); vf->seek(vf, 0, SEEK_SET);
gba->pristineRom = vf->map(vf, SIZE_CART0, MAP_READ); gba->pristineRom = vf->map(vf, SIZE_CART0, MAP_READ);
if (!gba->pristineRom) {
GBALog(gba, GBA_LOG_WARN, "Couldn't map ROM");
return;
}
gba->memory.rom = gba->pristineRom; gba->memory.rom = gba->pristineRom;
gba->activeFile = fname; gba->activeFile = fname;
gba->memory.romSize = gba->pristineRomSize; gba->memory.romSize = gba->pristineRomSize;
@ -437,7 +441,12 @@ void GBALoadROM(struct GBA* gba, struct VFile* vf, struct VFile* sav, const char
void GBALoadBIOS(struct GBA* gba, struct VFile* vf) { void GBALoadBIOS(struct GBA* gba, struct VFile* vf) {
gba->biosVf = vf; gba->biosVf = vf;
gba->memory.bios = vf->map(vf, SIZE_BIOS, MAP_READ); uint32_t* bios = vf->map(vf, SIZE_BIOS, MAP_READ);
if (!bios) {
GBALog(gba, GBA_LOG_WARN, "Couldn't map BIOS");
return;
}
gba->memory.bios = bios;
gba->memory.fullBios = 1; gba->memory.fullBios = 1;
uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS); uint32_t checksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);
GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum); GBALog(gba, GBA_LOG_DEBUG, "BIOS Checksum: 0x%X", checksum);