From 18790a90ae7e9b7b6324c2ec931748ad832126cc Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Thu, 17 Sep 2020 21:09:32 -0400 Subject: [PATCH] Ensures timer 2 doesn't use timed behaviour when in pulse mode. --- Components/6522/Implementation/6522Implementation.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Components/6522/Implementation/6522Implementation.hpp b/Components/6522/Implementation/6522Implementation.hpp index 34a21d7f2..df3e22042 100644 --- a/Components/6522/Implementation/6522Implementation.hpp +++ b/Components/6522/Implementation/6522Implementation.hpp @@ -8,6 +8,10 @@ #include "../../../Outputs/Log.hpp" +// As-yet unimplemented (incomplete list): +// +// PB6 count-down mode for timer 2. + namespace MOS { namespace MOS6522 { @@ -280,10 +284,13 @@ template void MOS6522::do_phase2() { registers_.timer_needs_reload = false; registers_.timer[0] = registers_.timer_latch[0]; } else { - registers_.timer[0] --; + -- registers_.timer[0]; } - registers_.timer[1] --; + // Count down timer 2 if it is in timed interrupt mode (i.e. auxiliary control bit 5 is clear). + // TODO: implement count down on PB6 if this bit isn't set. + registers_.timer[1] -= 1 ^ ((registers_.auxiliary_control >> 5)&1); + if(registers_.next_timer[0] >= 0) { registers_.timer[0] = uint16_t(registers_.next_timer[0]); registers_.next_timer[0] = -1;