Correct emulation of count overflow in ATTR_CHR, fixes #372

This commit is contained in:
Lior Halphon 2021-04-11 02:38:58 +03:00
parent f24489b983
commit 0c5e15b49d
1 changed files with 2 additions and 1 deletions

View File

@ -269,7 +269,8 @@ static void command_ready(GB_gameboy_t *gb)
#endif
uint8_t x = command->x;
uint8_t y = command->y;
if (x >= 20 || y >= 18 || (count + 3) / 4 > sizeof(gb->sgb->command) - sizeof(*command) - 1) {
count = MIN(count, 20 * 18);
if (x >= 20 || y >= 18) {
/* TODO: Verify with the SFC BIOS */
break;
}