diff --git a/Machines/Commodore/Plus4/Plus4.cpp b/Machines/Commodore/Plus4/Plus4.cpp index 9c18940e5..3e7279970 100644 --- a/Machines/Commodore/Plus4/Plus4.cpp +++ b/Machines/Commodore/Plus4/Plus4.cpp @@ -174,7 +174,7 @@ public: if(isReadOperation(operation)) { switch(address) { case 0xff00: *value = timers_.read<0>(); break; - case 0xff01: *value = timers_.read<1 >(); break; + case 0xff01: *value = timers_.read<1>(); break; case 0xff02: *value = timers_.read<2>(); break; case 0xff03: *value = timers_.read<3>(); break; case 0xff04: *value = timers_.read<4>(); break; diff --git a/Machines/Commodore/Plus4/Video.hpp b/Machines/Commodore/Plus4/Video.hpp index 4db263222..ba91923e2 100644 --- a/Machines/Commodore/Plus4/Video.hpp +++ b/Machines/Commodore/Plus4/Video.hpp @@ -191,7 +191,7 @@ public: } const auto next = Numeric::upper_bound< - 0, 3, 288, 290, 296, 304, 307, 315, 328, 336, 344, 358, 376, 384, 390, 400, 416, 424, 432, 440, 451, 465 + 0, 3, 288, 290, 296, 304, 307, 315, 328, 336, 344, 358, 368, 376, 384, 390, 400, 416, 424, 432, 440, 451, 465 >(horizontal_counter_); const auto period = std::min(next - horizontal_counter_, ticks_remaining); @@ -295,7 +295,13 @@ public: case 408: horizontal_burst_ = false; break; // Burst end. case 416: horizontal_blank_ = false; break; // Horizontal blanking end. - case 424: // Increment character position reload. + case 368: + if(raster_interrupt_ == vertical_counter_) { + interrupts_.apply(Interrupts::Flag::Raster); + } + break; + + case 424: // Increment character position reload; also interrput time. break; case 440: // Video shift register start. diff --git a/Numeric/UpperBound.hpp b/Numeric/UpperBound.hpp index f00d08a80..bc735ca5e 100644 --- a/Numeric/UpperBound.hpp +++ b/Numeric/UpperBound.hpp @@ -16,7 +16,7 @@ namespace Numeric { /// E.g. @c at_index<0, 3, 5, 6, 7, 8, 9>() returns the `3 - 0` = 4th element from the /// list 5, 6, 7, 8, 9, i.e. 8. template -int at_index() { +constexpr int at_index() { if constexpr (origin == index || sizeof...(Args) == 0) { return T; } else { @@ -40,10 +40,22 @@ int upper_bound_bounded(int location) { } } +template +constexpr int is_ordered() { + if constexpr (sizeof...(Args) == index + 1) { + return true; + } else { + return + (at_index<0, index, Args...>() < at_index<0, index+1, Args...>()) && + is_ordered(); + } +} + /// @returns The result of binary searching for the first thing in the template arguments /// is strictly greater than @c location. template int upper_bound(int location) { + static_assert(is_ordered<0, Args...>(), "Template arguments must be in ascending order."); return upper_bound_bounded<0, sizeof...(Args), Args...>(location); }