From e71154b7e0d2de833c3c1a56f9744812166634da Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 16 Oct 2017 20:48:39 +0300 Subject: [PATCH 1/3] =?UTF-8?q?Fixed=20set=5Fcolor=5Fcorrection=20breaking?= =?UTF-8?q?=20DMG=E2=80=99s=20palette?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Core/display.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/display.c b/Core/display.c index 42c43b6..4466e34 100755 --- a/Core/display.c +++ b/Core/display.c @@ -289,9 +289,11 @@ void GB_palette_changed(GB_gameboy_t *gb, bool background_palette, uint8_t index void GB_set_color_correction_mode(GB_gameboy_t *gb, GB_color_correction_mode_t mode) { gb->color_correction_mode = mode; - for (unsigned i = 0; i < 32; i++) { - GB_palette_changed(gb, false, i * 2); - GB_palette_changed(gb, true, i * 2); + if (gb->is_cgb) { + for (unsigned i = 0; i < 32; i++) { + GB_palette_changed(gb, false, i * 2); + GB_palette_changed(gb, true, i * 2); + } } } From 19c382c9e079dcd748bf102bc142fa78ca8cbf35 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 3 Dec 2017 21:07:34 +0200 Subject: [PATCH 2/3] Fixed ei_sequence test --- Core/z80_cpu.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Core/z80_cpu.c b/Core/z80_cpu.c index 072b1a7..16dbd08 100644 --- a/Core/z80_cpu.c +++ b/Core/z80_cpu.c @@ -1064,7 +1064,7 @@ static void ld_a_da16(GB_gameboy_t *gb, uint8_t opcode) static void di(GB_gameboy_t *gb, uint8_t opcode) { /* DI is NOT delayed, not even on a CGB. Mooneye's di_timing-GS test fails on a CGB - for different reasons.*/ + for different reasons. */ GB_advance_cycles(gb, 4); gb->ime = false; } @@ -1073,8 +1073,9 @@ static void ei(GB_gameboy_t *gb, uint8_t opcode) { /* ei is actually "disable interrupts for one instruction, then enable them". */ GB_advance_cycles(gb, 4); - gb->ime = false; - gb->ime_toggle = true; + if (!gb->ime && !gb->ime_toggle) { + gb->ime_toggle = true; + } } static void ld_hl_sp_r8(GB_gameboy_t *gb, uint8_t opcode) From f0e772ca977b148a8a695ffc79ad0e5a3c6b4aac Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 22 Dec 2017 21:58:31 +0200 Subject: [PATCH 3/3] Fixed: Loading states in DMG mode results in a black screen --- Core/display.c | 2 +- Core/save_state.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/display.c b/Core/display.c index 4466e34..f9533ba 100755 --- a/Core/display.c +++ b/Core/display.c @@ -279,7 +279,7 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color) void GB_palette_changed(GB_gameboy_t *gb, bool background_palette, uint8_t index) { - if (!gb->rgb_encode_callback) return; + if (!gb->rgb_encode_callback || !gb->is_cgb) return; uint8_t *palette_data = background_palette? gb->background_palettes_data : gb->sprite_palettes_data; uint16_t color = palette_data[index & ~1] | (palette_data[index | 1] << 8); diff --git a/Core/save_state.c b/Core/save_state.c index 24604c1..933b417 100644 --- a/Core/save_state.c +++ b/Core/save_state.c @@ -303,6 +303,11 @@ int GB_load_state_from_buffer(GB_gameboy_t *gb, const uint8_t *buffer, size_t le gb->rumble_callback(gb, gb->rumble_state); } + for (unsigned i = 0; i < 32; i++) { + GB_palette_changed(gb, false, i * 2); + GB_palette_changed(gb, true, i * 2); + } + return 0; }