Struct VgaBuffer

Source
pub struct VgaBuffer { /* private fields */ }
Expand description

Containa a pointer to slice of Vga buffer.

Implementations§

Source§

impl VgaBuffer

Source

pub const VGA_ADDR: usize = 753_664usize

Source

pub const WIDTH: usize = 80usize

Source

pub const HIGH: usize = 25usize

Source

pub const LENGTH: usize = 2_000usize

Source

pub const VGA_PTR: *mut VgaChar = {0xb8000 as *mut VgaChar}

Source

pub const fn to_index(y: usize, x: usize) -> usize

This static methode converts 2D index to 1D index.

Source

pub const fn to_yx(index: usize) -> (usize, usize)

This static methode converts 1D index to 2D index.

Source

pub fn new() -> Self

Construct a VgaBuffer.

Source

pub unsafe fn set_vgachar(&mut self, vchar: VgaChar, y: usize, x: usize)

Set VgaChar to (y,x) coordinates. Uncheck range.

Source

pub unsafe fn get_vgachar(&self, y: usize, x: usize) -> VgaChar

Get VgaChar at (y,x) coordinates. Uncheck range.

Source

pub fn as_slice<'a>(&self) -> &'a [VgaChar]

Video buffer to a slice.

Source

pub fn as_mut_slice<'a>(&'a mut self) -> &'a mut [VgaChar]

Video buffer to a mutable slice.

let mut vga_buffer = VgaBuffer::new()
let buffer_slice = vga_buffer.as_mut_slice();
for vchar_ref in buffer_slice.iter_mut()
{
	let mut vchar = vchar_ref.get_volatile();
	vchar.codepoint = 0u8;
	vchar_ref.set_volatile(vchar);
}

Trait Implementations§

Source§

impl Debug for VgaBuffer

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl VgaBufferHal for VgaBuffer

Source§

type Item = VgaChar

Source§

fn set(&mut self, item: Self::Item, y: usize, x: usize)

Setter interface.
Source§

fn get(&self, y: usize, x: usize) -> Self::Item

Getter interface.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.