From 97eb3fe209ac2539b8a8ea2547018615801c01d9 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 20 Sep 2016 22:59:00 +0300 Subject: [PATCH 1/2] Detect games stuck on blank screens --- Tester/main.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/Tester/main.c b/Tester/main.c index 52d797c..94450a4 100755 --- a/Tester/main.c +++ b/Tester/main.c @@ -89,15 +89,29 @@ static void vblank(GB_gameboy_t *gb) } } - if (frames == test_length) { - FILE *f = fopen(bmp_filename, "wb"); - fwrite(&bmp_header, 1, sizeof(bmp_header), f); - fwrite(&bitmap, 1, sizeof(bitmap), f); - fclose(f); - if (!gb->boot_rom_finished) { - GB_log(gb, "Boot ROM did not finish.\n"); + if (frames >= test_length ) { + bool is_screen_blank = false; + if (!(gb->io_registers[GB_IO_LCDC] & 0x80)) { /* LCD is off */ + is_screen_blank = true; + } + else if(!gb->cgb_mode) { /* BG can't be disabled in CGB mode */ + is_screen_blank =!(gb->io_registers[GB_IO_LCDC] & (gb->is_cgb? 3 : 0x23)); + } + + /* Let the test run for an extra 8 frames if the screen is off/disabled */ + if (!is_screen_blank || frames >= test_length + 8) { + FILE *f = fopen(bmp_filename, "wb"); + fwrite(&bmp_header, 1, sizeof(bmp_header), f); + fwrite(&bitmap, 1, sizeof(bitmap), f); + fclose(f); + if (!gb->boot_rom_finished) { + GB_log(gb, "Boot ROM did not finish.\n"); + } + if (is_screen_blank) { + GB_log(gb, "Game probably stuck with blank screen. \n"); + } + running = false; } - running = false; } else if (frames == test_length - 1) { gb->disable_rendering = false; From 6f2b36cacb90a9cc0ec4acb1fa8c8c4c3257b9e7 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 20 Sep 2016 22:59:25 +0300 Subject: [PATCH 2/2] The HALT bug also happens on CGBs, regardless of DMG mode. --- Core/z80_cpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/z80_cpu.c b/Core/z80_cpu.c index 6db9007..b664ace 100644 --- a/Core/z80_cpu.c +++ b/Core/z80_cpu.c @@ -1336,7 +1336,8 @@ void GB_cpu_run(GB_gameboy_t *gb) bool halt_bug = false; if (interrupt) { - halt_bug = gb->halted && !gb->is_cgb; /* Todo: Does this bug happen on a CGB? */ + /* Despite what some online documentations say, the HALT bug also happens on a CGB, in both CGB and DMG modes. */ + halt_bug = gb->halted; gb->halted = false; }