From 25b51362e9fcfd1b70615051cea05541be750e74 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 24 Feb 2020 00:33:45 +0200 Subject: [PATCH] Safety first --- Core/save_state.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/save_state.c b/Core/save_state.c index 8f10152..fd7d814 100644 --- a/Core/save_state.c +++ b/Core/save_state.c @@ -267,6 +267,7 @@ int GB_load_state(GB_gameboy_t *gb, const char *path) gb->oam_fifo.write_end &= 0xF; gb->object_low_line_address &= gb->vram_size & ~1; gb->fetcher_x &= 0x1f; + gb->fetcher_state &= 7; if (gb->object_priority == GB_OBJECT_PRIORITY_UNDEFINED) { gb->object_priority = gb->cgb_mode? GB_OBJECT_PRIORITY_INDEX : GB_OBJECT_PRIORITY_X; @@ -378,6 +379,7 @@ int GB_load_state_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t le gb->oam_fifo.write_end &= 0xF; gb->object_low_line_address &= gb->vram_size & ~1; gb->fetcher_x &= 0x1f; + gb->fetcher_state &= 7; if (gb->object_priority == GB_OBJECT_PRIORITY_UNDEFINED) { gb->object_priority = gb->cgb_mode? GB_OBJECT_PRIORITY_INDEX : GB_OBJECT_PRIORITY_X;