GB: Fix loading model overrides
Vicki Pfau vi@endrift.com
Sun, 21 Mar 2021 15:54:35 -0700
3 files changed,
40 insertions(+),
36 deletions(-)
M
CHANGES
→
CHANGES
@@ -82,6 +82,7 @@ - Debugger: Call CLI debugger system init
- FFmpeg: Fix some small memory leaks - FFmpeg: Fix encoding of time base - GB: Fix crash when changing ROM while in banked address space + - GB: Fix loading model overrides - GB Video: Fix SGB video logs - GBA: Fix loading multiboot ELF files (fixes mgba.io/i/1949) - GBA: Fix loading subsequent save files (fixes mgba.io/i/2067)
M
src/gb/core.c
→
src/gb/core.c
@@ -443,44 +443,45 @@
struct GBCartridgeOverride override; const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; override.headerCrc32 = doCrc32(cart, sizeof(*cart)); - if (GBOverrideFind(gbcore->overrides, &override) || (doColorOverride && GBOverrideColorFind(&override))) { + bool modelOverride = GBOverrideFind(gbcore->overrides, &override) || (doColorOverride && GBOverrideColorFind(&override)); + if (modelOverride) { GBOverrideApply(gb, &override); - } - - const char* modelGB = mCoreConfigGetValue(&core->config, "gb.model"); - const char* modelSGB = mCoreConfigGetValue(&core->config, "sgb.model"); - const char* modelCGB = mCoreConfigGetValue(&core->config, "cgb.model"); - const char* modelCGBHybrid = mCoreConfigGetValue(&core->config, "cgb.hybridModel"); - const char* modelCGBSGB = mCoreConfigGetValue(&core->config, "cgb.sgbModel"); - if (modelGB || modelCGB || modelSGB || modelCGBHybrid || modelCGBSGB) { - int models = GBValidModels(gb->memory.rom); - switch (models) { - case GB_MODEL_SGB | GB_MODEL_MGB: - if (modelSGB) { - gb->model = GBNameToModel(modelSGB); - } - break; - case GB_MODEL_MGB: - if (modelGB) { - gb->model = GBNameToModel(modelGB); - } - break; - case GB_MODEL_MGB | GB_MODEL_CGB: - if (modelCGBHybrid) { - gb->model = GBNameToModel(modelCGBHybrid); - } - break; - case GB_MODEL_SGB | GB_MODEL_CGB: // TODO: Do these even exist? - case GB_MODEL_MGB | GB_MODEL_SGB | GB_MODEL_CGB: - if (modelCGBSGB) { - gb->model = GBNameToModel(modelCGBSGB); + } else { + const char* modelGB = mCoreConfigGetValue(&core->config, "gb.model"); + const char* modelSGB = mCoreConfigGetValue(&core->config, "sgb.model"); + const char* modelCGB = mCoreConfigGetValue(&core->config, "cgb.model"); + const char* modelCGBHybrid = mCoreConfigGetValue(&core->config, "cgb.hybridModel"); + const char* modelCGBSGB = mCoreConfigGetValue(&core->config, "cgb.sgbModel"); + if (modelGB || modelCGB || modelSGB || modelCGBHybrid || modelCGBSGB) { + int models = GBValidModels(gb->memory.rom); + switch (models) { + case GB_MODEL_SGB | GB_MODEL_MGB: + if (modelSGB) { + gb->model = GBNameToModel(modelSGB); + } + break; + case GB_MODEL_MGB: + if (modelGB) { + gb->model = GBNameToModel(modelGB); + } + break; + case GB_MODEL_MGB | GB_MODEL_CGB: + if (modelCGBHybrid) { + gb->model = GBNameToModel(modelCGBHybrid); + } + break; + case GB_MODEL_SGB | GB_MODEL_CGB: // TODO: Do these even exist? + case GB_MODEL_MGB | GB_MODEL_SGB | GB_MODEL_CGB: + if (modelCGBSGB) { + gb->model = GBNameToModel(modelCGBSGB); + } + break; + case GB_MODEL_CGB: + if (modelCGB) { + gb->model = GBNameToModel(modelCGB); + } + break; } - break; - case GB_MODEL_CGB: - if (modelCGB) { - gb->model = GBNameToModel(modelCGB); - } - break; } } }
M
src/gb/overrides.c
→
src/gb/overrides.c
@@ -638,6 +638,8 @@
void GBOverrideApply(struct GB* gb, const struct GBCartridgeOverride* override) { if (override->model != GB_MODEL_AUTODETECT) { gb->model = override->model; + gb->video.renderer->deinit(gb->video.renderer); + gb->video.renderer->init(gb->video.renderer, gb->model, gb->video.sgbBorders); } if (override->mbc != GB_MBC_AUTODETECT) {