Update the model enum so comparisons work correctly for SGB PAL and no-SFC SGBs

This commit is contained in:
Lior Halphon 2021-01-16 14:51:06 +02:00
parent 13a1e9d332
commit aa421258b8
2 changed files with 17 additions and 2 deletions

View File

@ -31,8 +31,13 @@
#define GB_MODEL_DMG_FAMILY 0x000 #define GB_MODEL_DMG_FAMILY 0x000
#define GB_MODEL_MGB_FAMILY 0x100 #define GB_MODEL_MGB_FAMILY 0x100
#define GB_MODEL_CGB_FAMILY 0x200 #define GB_MODEL_CGB_FAMILY 0x200
#define GB_MODEL_PAL_BIT 0x1000 #define GB_MODEL_PAL_BIT 0x40
#define GB_MODEL_NO_SFC_BIT 0x2000 #define GB_MODEL_NO_SFC_BIT 0x80
#ifdef GB_INTERNAL
#define GB_MODEL_PAL_BIT_OLD 0x1000
#define GB_MODEL_NO_SFC_BIT_OLD 0x2000
#endif
#ifdef GB_INTERNAL #ifdef GB_INTERNAL
#if __clang__ #if __clang__

View File

@ -163,6 +163,16 @@ static bool verify_and_update_state_compatibility(GB_gameboy_t *gb, GB_gameboy_t
} }
} }
if (save->model & GB_MODEL_PAL_BIT_OLD) {
save->model &= ~GB_MODEL_PAL_BIT_OLD;
save->model |= GB_MODEL_PAL_BIT;
}
if (save->model & GB_MODEL_NO_SFC_BIT_OLD) {
save->model &= ~GB_MODEL_NO_SFC_BIT_OLD;
save->model |= GB_MODEL_NO_SFC_BIT;
}
if (gb->version != save->version) { if (gb->version != save->version) {
GB_log(gb, "The save state is for a different version of SameBoy.\n"); GB_log(gb, "The save state is for a different version of SameBoy.\n");
return false; return false;