From 8cda5aee20e8d8eb4be70ddecd2b44ce89b036aa Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 6 May 2020 03:43:37 +0200 Subject: [PATCH] PIT counters' null_count variables are now set to 1 on counter reload to make sure the readouts after counter reload are correct, fixes MR BIOS'es on interpreter (still broken on the recompiler because of another issue specifically related to the PIT on the recompiler), among other things. --- src/pit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pit.c b/src/pit.c index 91691d5bc..b04f23001 100644 --- a/src/pit.c +++ b/src/pit.c @@ -368,7 +368,7 @@ ctr_latch_status(ctr_t *ctr) static void ctr_latch_count(ctr_t *ctr) { - int count = (ctr->latch || (ctr->state == 1)) ? ctr->l : ctr->count; + int count = (ctr->latch || ctr->null_count || (ctr->state == 1)) ? ctr->l : ctr->count; switch (ctr->rm & 0x03) { case 0x00: @@ -575,6 +575,8 @@ pit_write(uint16_t addr, uint8_t val, void *priv) case 1: case 2: /* the actual timers */ ctr = &dev->counters[t]; + /* Reloading timer count, so set null_count to 1. */ + ctr->null_count = 1; switch (ctr->wm) { case 0: @@ -642,7 +644,7 @@ pit_read(uint16_t addr, void *priv) break; } - count = (ctr->state == 1) ? ctr->l : ctr->count; + count = (ctr->null_count || (ctr->state == 1)) ? ctr->l : ctr->count; if (ctr->latched) { ret = (ctr->rl) >> ((ctr->rm & 0x80) ? 8 : 0);