diff --git a/members/oxide/src/main.rs b/members/oxide/src/main.rs index 057fcf0..bd18d7e 100644 --- a/members/oxide/src/main.rs +++ b/members/oxide/src/main.rs @@ -19,9 +19,9 @@ fn panic(_info: &PanicInfo) -> ! { unsafe { __PANIC_HANDLER_WAS_LINKED__DO_NOT_DEFINE() }; } -use core::{arch::asm, panic::PanicInfo}; +use core::{arch::asm, hint::black_box, panic::PanicInfo}; -use crate::vga::VgaBuffer; +use crate::vga::{ColorNibble, VgaBuffer, VgaColor}; pub mod multiboot2; pub mod vga; @@ -39,6 +39,7 @@ fn start() -> ! { vga.write_at(2, 3, b'Y'); let mut vt = vga::vt::Writer::new(vga); + vt.set_color(VgaColor::new(ColorNibble::BLUE, ColorNibble::GREEN)); vt.put_at(10, 5); vt.slide(); vt.write(b"testinggg"); @@ -48,5 +49,20 @@ fn start() -> ! { // } // } + for _ in 0..=5 { + sleep_short(); + vt.slide(); + } + + sleep_short(); + vt.reset_screen(); + unsafe { asm!("hlt", "ud2", options(noreturn)) }; } + +fn sleep_short() { + let mut n = 0_u64; + while n < 100_000_000 { + black_box(n += 1); + } +} diff --git a/members/oxide/src/vga/mod.rs b/members/oxide/src/vga/mod.rs index b19cbb1..891ecfa 100644 --- a/members/oxide/src/vga/mod.rs +++ b/members/oxide/src/vga/mod.rs @@ -75,7 +75,7 @@ impl ColorNibble { pub const MAGENTA: Self = Self(0b0101); pub const GRAY: Self = Self(0b1000); - pub const GRAY2: Self = Self(0b0111); + pub const LIGHT_GRAY: Self = Self(0b0111); pub const LIGHT_RED: Self = Self(0b1100); pub const LIGHT_GREEN: Self = Self(0b1010); diff --git a/members/oxide/src/vga/vt.rs b/members/oxide/src/vga/vt.rs index d44de4c..252a964 100644 --- a/members/oxide/src/vga/vt.rs +++ b/members/oxide/src/vga/vt.rs @@ -39,6 +39,19 @@ where self.pos = (M::WIDTH.min(col), M::HEIGHT.min(row)); } + pub fn set_color(&mut self, color: VgaColor) { + self.cur_color = color; + } + + pub fn reset_screen(&mut self) { + for row in self.vga.as_cell_array() { + for cell in row { + cell.0 = b' '; + cell.1 = *self.cur_color; + } + } + } + pub fn write(&mut self, data: &[u8]) { const BAD_CHAR_COL: VgaColor = VgaColor::new(ColorNibble::WHITE, ColorNibble::RED);