forked from AbleOS/ableos_userland
updates
This commit is contained in:
parent
469325b52a
commit
183136103f
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -356,6 +356,10 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vgable"
|
name = "vgable"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"able_graphics_library",
|
||||||
|
"versioning",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasi"
|
name = "wasi"
|
||||||
|
|
|
@ -6,3 +6,5 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
versioning = { path = "../../../libraries/versioning" }
|
||||||
|
able_graphics_library = { path = "../../../libraries/able_graphics_library" }
|
||||||
|
|
|
@ -1,8 +1,62 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use able_graphics_library::display::parse_display_string;
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
fn start() {
|
fn start() {
|
||||||
// TODO: Initialize the VGA hardware and configure it to the desired video mode
|
// TODO: Initialize the VGA hardware and configure it to the desired video mode
|
||||||
// (e.g. 640x480, 800x600, etc.).
|
// (e.g. 640x480, 800x600, etc.).
|
||||||
|
|
||||||
|
let result = parse_display_string("680x480x32@60");
|
||||||
|
use able_graphics_library::display::DisplayError::*;
|
||||||
|
match result {
|
||||||
|
Ok(display) => {
|
||||||
|
let (width, height, bpp, fps) = display;
|
||||||
|
let vga_mode = VGAMode::get_vga_mode(width, height, bpp).unwrap_or(VGAMode::Mode0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Err(err) => match err {
|
||||||
|
InvalidFormat => panic!("Invalid format"),
|
||||||
|
InvalidWidth => panic!("Invalid width"),
|
||||||
|
InvalidHeight => panic!("Invalid height"),
|
||||||
|
InvalidBPP => panic!("Invalid bpp"),
|
||||||
|
InvalidFPS => panic!("Invalid fps"),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
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
|
||||||
|
}
|
||||||
|
impl VGAMode {
|
||||||
|
fn get_vga_mode(width: u32, height: u32, bpp: u32) -> Option<VGAMode> {
|
||||||
|
match (width, height, bpp) {
|
||||||
|
(640, 480, 4) => Some(VGAMode::Mode0),
|
||||||
|
(640, 480, 8) => Some(VGAMode::Mode1),
|
||||||
|
(640, 480, 16) => Some(VGAMode::Mode2),
|
||||||
|
(800, 600, 4) => Some(VGAMode::Mode3),
|
||||||
|
(800, 600, 8) => Some(VGAMode::Mode4),
|
||||||
|
(800, 600, 16) => Some(VGAMode::Mode5),
|
||||||
|
(1024, 768, 4) => Some(VGAMode::Mode6),
|
||||||
|
(1024, 768, 8) => Some(VGAMode::Mode7),
|
||||||
|
(1024, 768, 16) => Some(VGAMode::Mode8),
|
||||||
|
(1280, 1024, 4) => Some(VGAMode::Mode9),
|
||||||
|
(1280, 1024, 8) => Some(VGAMode::Mode10),
|
||||||
|
(1280, 1024, 16) => Some(VGAMode::Mode11),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use alloc::vec::Vec;
|
||||||
|
|
||||||
pub enum DisplayError {
|
pub enum DisplayError {
|
||||||
InvalidFormat,
|
InvalidFormat,
|
||||||
InvalidWidth,
|
InvalidWidth,
|
||||||
|
@ -18,7 +20,7 @@ pub fn parse_display_string(s: &str) -> Result<(u32, u32, u32, u32), DisplayErro
|
||||||
let height = parts[1]
|
let height = parts[1]
|
||||||
.parse::<u32>()
|
.parse::<u32>()
|
||||||
.map_err(|_| DisplayError::InvalidHeight)?;
|
.map_err(|_| DisplayError::InvalidHeight)?;
|
||||||
let bits = parts[2].split('@').collect();
|
let bits: Vec<&str> = parts[2].split('@').collect();
|
||||||
if bits.len() != 2 {
|
if bits.len() != 2 {
|
||||||
return Err(DisplayError::InvalidFormat);
|
return Err(DisplayError::InvalidFormat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ extern crate alloc;
|
||||||
pub mod buffer;
|
pub mod buffer;
|
||||||
pub mod color;
|
pub mod color;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
|
pub mod display;
|
||||||
pub mod framebuffer;
|
pub mod framebuffer;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod vertex;
|
pub mod vertex;
|
||||||
|
|
Loading…
Reference in a new issue