mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-09 08:33:04 +00:00
Add safety rail.
This commit is contained in:
parent
f41b54de21
commit
589903c43c
@ -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;
|
||||
|
@ -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.
|
||||
|
@ -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 origin, int index, int T, int... Args>
|
||||
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 <int index, int... Args>
|
||||
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<index+1, Args...>();
|
||||
}
|
||||
}
|
||||
|
||||
/// @returns The result of binary searching for the first thing in the template arguments
|
||||
/// is strictly greater than @c location.
|
||||
template <int... Args>
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user