From 283ba780905bdc2aabbbce688517606b07a18226 Mon Sep 17 00:00:00 2001 From: OBattler Date: Tue, 8 Jul 2025 09:19:02 +0200 Subject: [PATCH] Slow PIT: convert BCD counts to binary when passing them to the speaker. --- src/pit.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pit.c b/src/pit.c index a283d1205..15de2ba86 100644 --- a/src/pit.c +++ b/src/pit.c @@ -358,8 +358,18 @@ ctr_load(ctr_t *ctr) else ctr_set_state_1(ctr); - if (ctr->load_func != NULL) - ctr->load_func(ctr->m, ctr->l ? ctr->l : 0x10000); + if (ctr->load_func != NULL) { + uint32_t count = ctr->l ? ctr->l : 0x10000; + if (ctr->bcd) { + uint32_t bcd_count = (((count >> 16) & 0xf) * 10000) | + (((count >> 12) & 0xf) * 1000 ) | + (((count >> 8 ) & 0xf) * 100 ) | + (((count >> 4 ) & 0xf) * 10 ) | + (count & 0xf); + ctr->load_func(ctr->m, bcd_count); + } else + ctr->load_func(ctr->m, ctr->l ? ctr->l : 0x10000); + } pit_log("Counter loaded, state = %i, gate = %i, latch = %i\n", ctr->state, ctr->gate, ctr->latch); }