feat: vt additions
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user