1
0
Fork 0
forked from koniifer/ableos

main graphics loop

This commit is contained in:
Able 2022-02-12 23:17:17 -06:00
parent b21c53fa82
commit 19508c979e
3 changed files with 26 additions and 5 deletions

View file

@ -34,8 +34,8 @@ run-args = [
"-drive", "-drive",
"file=disk.qcow2,if=none,id=drive0", "file=disk.qcow2,if=none,id=drive0",
# "-qmp", "-qmp",
# "unix:../qmp-sock,server,nowait" "unix:../qmp-sock,server,nowait"
] ]

View file

@ -3,7 +3,7 @@ use ab_glyph::{Font, FontRef, Glyph};
use alloc::{boxed::Box, vec, vec::Vec}; use alloc::{boxed::Box, vec, vec::Vec};
use shadeable::{evaluate_shader, pixel_format::Rgba64}; use shadeable::{evaluate_shader, pixel_format::Rgba64};
use spin; use spin;
use vga::writers::GraphicsWriter; use vga::{colors::Color16, writers::GraphicsWriter};
#[derive(Debug)] #[derive(Debug)]
pub struct ScreenSize { pub struct ScreenSize {
@ -127,7 +127,7 @@ impl ScreenBuffer {
// TODO force clear // TODO force clear
pub fn force_redraw(&mut self) { pub fn force_redraw(&mut self) {
use shadeable::pixel_format::into_vga_16; 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 /// 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 { for x in 0..self.size.x {
use shadeable::pixel_format::into_vga_16; use shadeable::pixel_format::into_vga_16;
let vga_color = into_vga_16(self.buff[y * self.size.x + x]); 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); mode.set_pixel(x, y, vga_color);
} }
} }

View file

@ -1,6 +1,7 @@
#![allow(clippy::empty_loop)] #![allow(clippy::empty_loop)]
use acpi::AcpiTables; use acpi::AcpiTables;
use x86_64::instructions::interrupts::{disable, enable};
use crate::scratchpad; use crate::scratchpad;
@ -86,6 +87,25 @@ pub fn kernel_main() -> ! {
start_facepalm(); start_facepalm();
scratchpad(); 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() sloop()
} }