Correct blank image detection on SGB

This commit is contained in:
Lior Halphon 2021-10-09 22:41:43 +03:00
parent 893d7d162a
commit 6b947c46bc

View File

@ -140,12 +140,24 @@ static void vblank(GB_gameboy_t *gb)
if (frames >= test_length && !gb->disable_rendering) {
bool is_screen_blank = true;
for (unsigned i = GB_get_screen_width(gb) * GB_get_screen_height(gb); i--;) {
if (!gb->sgb) {
for (unsigned i = 160 * 144; i--;) {
if (bitmap[i] != bitmap[0]) {
is_screen_blank = false;
break;
}
}
}
else {
if (gb->sgb->mask_mode == 0) {
for (unsigned i = 160 * 144; i--;) {
if (gb->sgb->screen_buffer[i] != gb->sgb->screen_buffer[0]) {
is_screen_blank = false;
break;
}
}
}
}
/* Let the test run for extra four seconds if the screen is off/disabled */
if (!is_screen_blank || frames >= test_length + 60 * 4) {