Shift lines up instead of clearing the screen when full

This commit is contained in:
Philipp Oppermann
2020-09-09 19:00:51 +02:00
parent 4d2f18d481
commit dee04d74d6

View File

@@ -45,6 +45,12 @@ impl Writer {
self.buffer.fill(0);
}
fn shift_lines_up(&mut self) {
let offset = self.info.stride * self.info.bytes_per_pixel * 8;
self.buffer.copy_within(offset.., 0);
self.y_pos -= 8;
}
fn width(&self) -> usize {
self.info.horizontal_resolution
}
@@ -61,8 +67,8 @@ impl Writer {
if self.x_pos >= self.width() {
self.newline();
}
if self.y_pos >= (self.height() - 8) {
self.clear();
while self.y_pos >= (self.height() - 8) {
self.shift_lines_up();
}
let rendered = font8x8::BASIC_FONTS
.get(c)