Safety first

This commit is contained in:
Lior Halphon 2020-02-24 00:33:45 +02:00
parent 3864ff37e1
commit 25b51362e9
1 changed files with 2 additions and 0 deletions

View File

@ -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;