108 lines
4.3 KiB
Diff
108 lines
4.3 KiB
Diff
diff --git a/src/devices/graphical_debug/debug.rs b/src/devices/graphical_debug/debug.rs
|
|
index 4b684c8a..e3fe0472 100644
|
|
--- a/src/devices/graphical_debug/debug.rs
|
|
+++ b/src/devices/graphical_debug/debug.rs
|
|
@@ -29,0 +30,3 @@ impl DebugDisplay {
|
|
+ const CHAR_WIDTH: usize = 8;
|
|
+ const CHAR_HEIGHT: usize = 16;
|
|
+
|
|
@@ -43,2 +46,2 @@ impl DebugDisplay {
|
|
- let w = display.width / 8;
|
|
- let h = display.height / 16;
|
|
+ let w = display.width / Self::CHAR_WIDTH;
|
|
+ let h = display.height / Self::CHAR_HEIGHT;
|
|
@@ -54,0 +58,21 @@ impl DebugDisplay {
|
|
+ fn scroll_up(&mut self) {
|
|
+ let stride = self.display.stride;
|
|
+ let width = self.display.width;
|
|
+ let total_height = self.display.height;
|
|
+ let scroll_px = Self::CHAR_HEIGHT;
|
|
+
|
|
+ unsafe {
|
|
+ let ptr = self.display.onscreen_ptr;
|
|
+ for row in 0..total_height - scroll_px {
|
|
+ ptr::copy(
|
|
+ ptr.add((row + scroll_px) * stride),
|
|
+ ptr.add(row * stride),
|
|
+ width,
|
|
+ );
|
|
+ }
|
|
+ for row in total_height - scroll_px..total_height {
|
|
+ ptr::write_bytes(ptr.add(row * stride), 0, width);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
@@ -59 +83,5 @@ impl DebugDisplay {
|
|
- self.y = (self.y + 1) % self.h;
|
|
+ self.y += 1;
|
|
+ if self.y >= self.h {
|
|
+ self.scroll_up();
|
|
+ self.y = self.h - 1;
|
|
+ }
|
|
@@ -67 +94,0 @@ impl DebugDisplay {
|
|
- // Byte 0x1B starts ESC sequence
|
|
@@ -72 +98,0 @@ impl DebugDisplay {
|
|
- // Ignore other nonprintable characters
|
|
@@ -77 +102,0 @@ impl DebugDisplay {
|
|
- // '[' after ESC starts CSI sequence
|
|
@@ -82 +106,0 @@ impl DebugDisplay {
|
|
- // Capture any bytes after ESC
|
|
@@ -87 +110,0 @@ impl DebugDisplay {
|
|
- // Byte 0x40 to 0x7E ends CSI
|
|
@@ -92 +114,0 @@ impl DebugDisplay {
|
|
- // Capture any bytes after CSI
|
|
@@ -96 +117,0 @@ impl DebugDisplay {
|
|
- // Allow any other bytes
|
|
@@ -102 +122,0 @@ impl DebugDisplay {
|
|
- self.clear_row((self.y + 1) % self.h);
|
|
@@ -105 +125 @@ impl DebugDisplay {
|
|
- self.char(self.x * 8, self.y * 16, b as char, 0xFFFFFF);
|
|
+ self.char(self.x * Self::CHAR_WIDTH, self.y * Self::CHAR_HEIGHT, b as char, 0xFFFFFF);
|
|
@@ -112 +132 @@ impl DebugDisplay {
|
|
- for row in y * 16..(y + 1) * 16 {
|
|
+ for row in y * Self::CHAR_HEIGHT..(y + 1) * Self::CHAR_HEIGHT {
|
|
@@ -123 +142,0 @@ impl DebugDisplay {
|
|
- /// Draw a character
|
|
@@ -125,7 +144,8 @@ impl DebugDisplay {
|
|
- if x + 8 <= self.display.width && y + 16 <= self.display.height {
|
|
- let phys_y = y % self.display.height;
|
|
- let mut dst = unsafe {
|
|
- self.display
|
|
- .onscreen_ptr
|
|
- .add(phys_y * self.display.stride + x)
|
|
- };
|
|
+ if x + Self::CHAR_WIDTH > self.display.width || y + Self::CHAR_HEIGHT > self.display.height {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ let font_i = Self::CHAR_HEIGHT * (character as usize);
|
|
+ if font_i + Self::CHAR_HEIGHT > FONT.len() {
|
|
+ return;
|
|
+ }
|
|
@@ -133,6 +152,0 @@ impl DebugDisplay {
|
|
- let font_i = 16 * (character as usize);
|
|
- if font_i + 16 <= FONT.len() {
|
|
- for row in 0..16 {
|
|
- let row_data = FONT[font_i + row];
|
|
- for col in 0..8 {
|
|
- if (row_data >> (7 - col)) & 1 == 1 {
|
|
@@ -139,0 +154,7 @@ impl DebugDisplay {
|
|
+ let ptr = self.display.onscreen_ptr;
|
|
+ let stride = self.display.stride;
|
|
+ for row in 0..Self::CHAR_HEIGHT {
|
|
+ let row_data = FONT[font_i + row];
|
|
+ let dst = ptr.add((y + row) * stride + x);
|
|
+ for col in 0..Self::CHAR_WIDTH {
|
|
+ if (row_data >> (Self::CHAR_WIDTH - 1 - col)) & 1 == 1 {
|
|
@@ -144,9 +164,0 @@ impl DebugDisplay {
|
|
-
|
|
- let next_phys_y = (phys_y + row + 1) % self.display.height;
|
|
- dst = unsafe {
|
|
- self.display
|
|
- .onscreen_ptr
|
|
- .add(next_phys_y * self.display.stride + x)
|
|
- };
|
|
- }
|
|
- }
|