1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-20 14:29:11 +00:00

Add asserts.

This commit is contained in:
Thomas Harte 2025-01-05 22:45:09 -05:00
parent 9a6780616b
commit c4f4ca3f90

View File

@ -993,6 +993,7 @@ private:
template <int length, bool is_leftovers>
void draw_2bpp_segment(uint16_t *const target, const uint16_t *colours) {
constexpr int leftover = is_leftovers && (length & 1);
static_assert(length + leftover <= 8);
if(target) {
const auto pixels = output_.pixels();
// Intention: skip first output if leftover is 1, but still do the correct
@ -1007,8 +1008,10 @@ private:
if constexpr (length + leftover >= 8) target[7 - leftover] = colours[(pixels >> 0) & 3];
}
if(is_leftovers) {
output_.advance_pixels(length + leftover);
if constexpr (is_leftovers) {
constexpr int shift_distance = length + leftover;
static_assert(!(shift_distance&1));
output_.advance_pixels(shift_distance);
} else {
output_.advance_pixels(length & ~1);
}