Skip to content

Commit

Permalink
Blank out border.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomHarte committed Aug 6, 2024
1 parent 1977675 commit 05f0a12
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions OSBindings/Mac/Clock SignalTests/CPCShakerTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,37 @@ void end_scan() override {
const int step = (src_pixels << 16) / dst_pixels;
int position = 0;

for(int x = scan_.end_points[0].x / WidthDivider; x < scan_.end_points[1].x / WidthDivider; x++) {
raw_image_[line_ * ImageWidth + x] = data_[position >> 16];
const auto x1 = scan_.end_points[0].x / WidthDivider;
const auto x2 = scan_.end_points[1].x / WidthDivider;

uint8_t *const line = &raw_image_[line_ * ImageWidth];
if(x_ < x1) {
std::fill(&line[x_], &line[x1], 0);
}
for(int x = x1; x < x2; x++) {
line[x] = data_[position >> 16];
position += step;
}
x_ = x2;
}
void announce(Event event, bool, const Scan::EndPoint &, uint8_t) override {
switch(event) {
case Event::EndHorizontalRetrace: ++line_; break;
case Event::EndVerticalRetrace: line_ = 0; break;
case Event::EndHorizontalRetrace: {
if(line_ == ImageHeight - 1) break;

if(x_ < ImageWidth) {
uint8_t *const line = &raw_image_[line_ * ImageWidth];
std::fill(&line[x_], &line[ImageWidth], 0);
}

++line_;
x_ = 0;
} break;
case Event::EndVerticalRetrace:
std::fill(&raw_image_[line_ * ImageWidth], &raw_image_[ImageHeight * ImageWidth], 0);
line_ = 0;
x_ = 0;
break;
default: break;
}
}
Expand Down Expand Up @@ -90,6 +112,7 @@ void announce(Event event, bool, const Scan::EndPoint &, uint8_t) override {
Scan scan_;
std::array<uint8_t, 2048> data_;
int line_ = 0;
int x_ = 0;

static constexpr int ImageWidth = 914;
static constexpr int ImageHeight = 312;
Expand Down

0 comments on commit 05f0a12

Please sign in to comment.