From f8380d2d4c4a2a6d78b4c5d3f99fa21208052b03 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 8 Aug 2021 22:32:41 -0400 Subject: [PATCH] Add 8250 feature of 'count, regardless'. --- Components/6526/Implementation/6526Implementation.hpp | 8 ++++---- Components/6526/Implementation/6526Storage.hpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Components/6526/Implementation/6526Implementation.hpp b/Components/6526/Implementation/6526Implementation.hpp index dabdbf353..46eb3ef81 100644 --- a/Components/6526/Implementation/6526Implementation.hpp +++ b/Components/6526/Implementation/6526Implementation.hpp @@ -79,10 +79,10 @@ void MOS6526::write(int address, uint8_t value) { break; // Counters; writes set the reload values. - case 4: counter_[0].template set_reload<0>(value); break; - case 5: counter_[0].template set_reload<8>(value); break; - case 6: counter_[1].template set_reload<0>(value); break; - case 7: counter_[1].template set_reload<8>(value); break; + case 4: counter_[0].template set_reload<0, personality == Personality::P8250>(value); break; + case 5: counter_[0].template set_reload<8, personality == Personality::P8250>(value); break; + case 6: counter_[1].template set_reload<0, personality == Personality::P8250>(value); break; + case 7: counter_[1].template set_reload<8, personality == Personality::P8250>(value); break; // Time-of-day clock. case 8: tod_.template write<0>(value); break; diff --git a/Components/6526/Implementation/6526Storage.hpp b/Components/6526/Implementation/6526Storage.hpp index cb3277d23..d193e87b2 100644 --- a/Components/6526/Implementation/6526Storage.hpp +++ b/Components/6526/Implementation/6526Storage.hpp @@ -189,12 +189,19 @@ struct MOS6526Storage { uint16_t value = 0; uint8_t control = 0; - template void set_reload(uint8_t v) { + template void set_reload(uint8_t v) { reload = (reload & (0xff00 >> shift)) | uint16_t(v << shift); if constexpr (shift == 8) { - if(!(control&1)) { + // This seems to be a special 8250 feature per the Amiga + // Hardware Reference Manual; cf. Appendix F. + if(is_8250) { + control |= 1; pending |= ReloadInOne; + } else { + if(!(control&1)) { + pending |= ReloadInOne; + } } }