more layout work for the VGA Driver
This commit is contained in:
parent
183136103f
commit
f5835bab57
|
@ -3,6 +3,8 @@
|
|||
|
||||
use able_graphics_library::display::parse_display_string;
|
||||
|
||||
const VGA_ADDRESS: *mut u8 = 0xB8000 as *mut u8;
|
||||
|
||||
#[no_mangle]
|
||||
fn start() {
|
||||
// TODO: Initialize the VGA hardware and configure it to the desired video mode
|
||||
|
@ -14,6 +16,7 @@ fn start() {
|
|||
Ok(display) => {
|
||||
let (width, height, bpp, fps) = display;
|
||||
let vga_mode = VGAMode::get_vga_mode(width, height, bpp).unwrap_or(VGAMode::Mode0);
|
||||
let mut vga_state = VGAState::new(vga_mode);
|
||||
}
|
||||
|
||||
Err(err) => match err {
|
||||
|
@ -26,20 +29,20 @@ fn start() {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
enum VGAMode {
|
||||
Mode0, //: 640x480 pixels, 16 colors
|
||||
Mode1, //: 640x480 pixels, 256 colors
|
||||
Mode2, //: 640x480 pixels, 16-bit color
|
||||
Mode3, //: 800x600 pixels, 16 colors
|
||||
Mode4, //: 800x600 pixels, 256 colors
|
||||
Mode5, //: 800x600 pixels, 16-bit color
|
||||
Mode6, //: 1024x768 pixels, 16 colors
|
||||
Mode7, //: 1024x768 pixels, 256 colors
|
||||
Mode8, //: 1024x768 pixels, 16-bit color
|
||||
Mode9, //: 1280x1024 pixels, 16 colors
|
||||
Mode10, //: 1280x1024 pixels, 256 colors
|
||||
Mode11, //1: 1280x1024 pixels, 16-bit color
|
||||
Mode0 = 0, //: 640x480 pixels, 16 colors
|
||||
Mode1 = 1, //: 640x480 pixels, 256 colors
|
||||
Mode2 = 2, //: 640x480 pixels, 16-bit color
|
||||
Mode3 = 3, //: 800x600 pixels, 16 colors
|
||||
Mode4 = 4, //: 800x600 pixels, 256 colors
|
||||
Mode5 = 5, //: 800x600 pixels, 16-bit color
|
||||
Mode6 = 6, //: 1024x768 pixels, 16 colors
|
||||
Mode7 = 7, //: 1024x768 pixels, 256 colors
|
||||
Mode8 = 8, //: 1024x768 pixels, 16-bit color
|
||||
Mode9 = 9, //: 1280x1024 pixels, 16 colors
|
||||
Mode10 = 10, //: 1280x1024 pixels, 256 colors
|
||||
Mode11 = 11, //: 1280x1024 pixels, 16-bit color
|
||||
}
|
||||
impl VGAMode {
|
||||
fn get_vga_mode(width: u32, height: u32, bpp: u32) -> Option<VGAMode> {
|
||||
|
@ -60,3 +63,31 @@ impl VGAMode {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
struct VGAState<'a> {
|
||||
mode: VGAMode,
|
||||
buffer: &'a mut u8,
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
impl<'a> VGAState<'a> {
|
||||
fn new(mode: VGAMode) -> Self {
|
||||
let mut state = Self {
|
||||
mode,
|
||||
buffer: unsafe { &mut *VGA_ADDRESS },
|
||||
};
|
||||
unsafe {
|
||||
state.initialize_hardware();
|
||||
}
|
||||
|
||||
state
|
||||
}
|
||||
unsafe fn set_vga_mode(&mut self, mode: VGAMode) {
|
||||
self.mode = mode;
|
||||
// Set registers here
|
||||
}
|
||||
unsafe fn initialize_hardware(&mut self) {
|
||||
// set vga mode
|
||||
self.set_vga_mode(self.mode)
|
||||
// initalize the graphics lib to be usable
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue