From 19508c979e0935b89a33668cefa0f60ba31da39b Mon Sep 17 00:00:00 2001 From: Able Date: Sat, 12 Feb 2022 23:17:17 -0600 Subject: [PATCH] main graphics loop --- ableos/Cargo.toml | 4 ++-- ableos/src/graphics/mod.rs | 7 ++++--- ableos/src/kmain.rs | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index 8decda1..9397f58 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -34,8 +34,8 @@ run-args = [ "-drive", "file=disk.qcow2,if=none,id=drive0", -# "-qmp", -# "unix:../qmp-sock,server,nowait" +"-qmp", + "unix:../qmp-sock,server,nowait" ] diff --git a/ableos/src/graphics/mod.rs b/ableos/src/graphics/mod.rs index 59fd69d..3be4afc 100644 --- a/ableos/src/graphics/mod.rs +++ b/ableos/src/graphics/mod.rs @@ -3,7 +3,7 @@ use ab_glyph::{Font, FontRef, Glyph}; use alloc::{boxed::Box, vec, vec::Vec}; use shadeable::{evaluate_shader, pixel_format::Rgba64}; use spin; -use vga::writers::GraphicsWriter; +use vga::{colors::Color16, writers::GraphicsWriter}; #[derive(Debug)] pub struct ScreenSize { @@ -127,7 +127,7 @@ impl ScreenBuffer { // TODO force clear pub fn force_redraw(&mut self) { use shadeable::pixel_format::into_vga_16; - VGAE.lock().clear_screen(into_vga_16(self.clear_color)); + VGAE.lock().clear_screen(vga::colors::Color16::Black); } /// Draw a glyph on the screen at the given position @@ -211,8 +211,9 @@ impl VgaBuffer for ScreenBuffer { for x in 0..self.size.x { use shadeable::pixel_format::into_vga_16; let vga_color = into_vga_16(self.buff[y * self.size.x + x]); + // let vga_color = vga::colors::Color16::Cyan; - if into_vga_16(self.clear_color) != vga_color { + if Color16::Cyan != vga_color { mode.set_pixel(x, y, vga_color); } } diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index b56f07a..0cec6e7 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -1,6 +1,7 @@ #![allow(clippy::empty_loop)] use acpi::AcpiTables; +use x86_64::instructions::interrupts::{disable, enable}; use crate::scratchpad; @@ -86,6 +87,25 @@ pub fn kernel_main() -> ! { start_facepalm(); scratchpad(); + + loop { + disable(); + let mut mode = SCREEN_BUFFER.lock(); + mode.force_redraw(); + + mode.copy_to_buffer(); + mode.clear(); + + mode.draw_char(0, 0, 'v', 0xff00ffff); + + mode.copy_to_buffer(); + drop(mode); + enable() + // sloop::halt(); + } + + // } + sloop() }