pub fn write(page: Page, col: usize, row: usize, pal8bpp: u8) -> Option<()> {
    // Note(Lokathor): Byte writes to VRAM aren't permitted, we have to jump
    // through some hoops.
    if col < Self::WIDTH && row < Self::HEIGHT {
      let real_index = col + row * Self::WIDTH;
      let rounded_down_index = real_index & !1;
      let address: VolAddress<u16, Safe, Safe> = unsafe {
        match page {
          Page::Zero => Self::PAGE0_INDEXES,
          Page::One => Self::PAGE1_INDEXES,
        }
        .index(rounded_down_index)
        .cast::<u16>()
      };
      if real_index != rounded_down_index {
        // even byte, change the high bits
        let old_val = address.read();
        address.write((old_val & 0xFF) | ((pal8bpp as u16) << 8));
      } else {
        // odd byte, change the low bits
        let old_val = address.read();
        address.write((old_val & 0xFF00) | pal8bpp as u16);
      }
      Some(())
    } else {
      None
    }
  }
/// Writes a color to the pixel specified.
///
/// ## Failure
///
/// Gives `None` if out of bounds
Writes a color to the pixel specified.
Writes a color to the pixel specified .
pub fn write(page: Page, col: usize, row: usize, pal8bpp: u8) -> Option<()> {
    // Note(Lokathor): Byte writes to VRAM aren't permitted, we have to jump
    // through some hoops.
    if col < Self::WIDTH && row < Self::HEIGHT {
      let real_index = col + row * Self::WIDTH;
      let rounded_down_index = real_index & !1;
      let address: VolAddress<u16, Safe, Safe> = unsafe {
        match page {
          Page::Zero => Self::PAGE0_INDEXES,
          Page::One => Self::PAGE1_INDEXES,
        }
        .index(rounded_down_index)
        .cast::<u16>()
      };
      if real_index != rounded_down_index {
        // even byte, change the high bits
        let old_val = address.read();
        address.write((old_val & 0xFF) | ((pal8bpp as u16) << 8));
      } else {
        // odd byte, change the low bits
        let old_val = address.read();
        address.write((old_val & 0xFF00) | pal8bpp as u16);
      }
      Some(())
    } else {
      None
    }
  }
pub fn write ( page : Page , col : usize , row : usize , pal8bpp : u8 ) -> Option < ( ) > { // Note(Lokathor): Byte writes to VRAM aren't permitted, we have to jump // through some hoops. if col < Self :: WIDTH && row < Self :: HEIGHT { let real_index = col + row * Self :: WIDTH ; let rounded_down_index = real_index & ! 1 ; let address : VolAddress < u16 , Safe , Safe > = unsafe { match page { Page :: Zero => Self :: PAGE0_INDEXES , Page :: One => Self :: PAGE1_INDEXES , } . index ( rounded_down_index ) . cast :: < u16 > ( ) } ; if real_index != rounded_down_index { // even byte, change the high bits let old_val = address . read ( ) ; address . write ( ( old_val & 0xFF ) | ( ( pal8bpp as u16 ) << 8 ) ) ; } else { // odd byte, change the low bits let old_val = address . read ( ) ; address . write ( ( old_val & 0xFF00 ) | pal8bpp as u16 ) ; } Some ( ( ) ) } else { None } }
Writes a color to the pixel specified.
Writes a color to the pixel specified .
page
Page
col
usize
row
usize
pal8bpp
u8
page
Page
col
usize
row
usize
pal8bpp
u8
failure
Gives `None` if out of bounds
Gives ` None ` if out of bounds