forked from AbleOS/ableos
65 lines
1.7 KiB
Rust
65 lines
1.7 KiB
Rust
use vga::writers::{Graphics640x480x16, GraphicsWriter};
|
|
|
|
pub enum Color {
|
|
/// Represents the color `Black (0x0)`.
|
|
Black = 0x0,
|
|
/// Represents the color `Blue (0x1)`.
|
|
Blue = 0x1,
|
|
/// Represents the color `Green (0x2)`.
|
|
Green = 0x2,
|
|
/// Represents the color `Cyan (0x3)`.
|
|
Cyan = 0x3,
|
|
/// Represents the color `Red (0x4)`.
|
|
Red = 0x4,
|
|
/// Represents the color `Magenta (0x5)`.
|
|
Magenta = 0x5,
|
|
/// Represents the color `Brown (0x6)`.
|
|
Brown = 0x6,
|
|
/// Represents the color `LightGrey (0x7)`.
|
|
LightGrey = 0x7,
|
|
/// Represents the color `DarkGrey (0x8)`.
|
|
DarkGrey = 0x8,
|
|
/// Represents the color `LightBlue (0x9)`.
|
|
LightBlue = 0x9,
|
|
/// Represents the color `LightGreen (0xA)`.
|
|
LightGreen = 0xA,
|
|
/// Represents the color `LightCyan (0xB)`.
|
|
LightCyan = 0xB,
|
|
/// Represents the color `LightRed (0xC)`.
|
|
LightRed = 0xC,
|
|
/// Represents the color `Pink (0xD)`.
|
|
Pink = 0xD,
|
|
/// Represents the color `Yellow (0xE)`.
|
|
Yellow = 0xE,
|
|
/// Represents the color `White (0xF)`.
|
|
White = 0xF,
|
|
}
|
|
|
|
const VGA_BUFFER_SIZE: usize = 480;
|
|
|
|
pub struct ScreenBuffer {}
|
|
impl ScreenBuffer {
|
|
pub fn initialise() {}
|
|
|
|
pub fn flip_buffer() {
|
|
/*
|
|
before doing anything past here we need to tell the VGA about some things
|
|
*/
|
|
let setup = false;
|
|
if setup {
|
|
use Color::*;
|
|
let dualpixel: u8 = Red as u8;
|
|
|
|
let buff: [u8; VGA_BUFFER_SIZE] = [dualpixel; VGA_BUFFER_SIZE];
|
|
|
|
let buff_ptr = buff.as_ptr();
|
|
let vga_buffer = 0xb8000 as *mut u8;
|
|
|
|
use core::ptr;
|
|
unsafe {
|
|
ptr::copy(buff_ptr, vga_buffer, VGA_BUFFER_SIZE);
|
|
}
|
|
}
|
|
}
|
|
}
|