[−][src]Struct rubidium::PALRAM
A ZST for namespacing palette ram related functionality.
The palette ram consists of 2 blocks of 256 Color
values, one for
backgrounds and one for objects.
When selecting a given address within either block of colors, both backgrounds and objects can use either "8-bit per pixel" mode (8bpp) or "4-bit per pixel" mode (4bpp).
- 8bpp: Each color index within a background or object is 8 bits. The 8
bits index into the full block of colors as if it was a single set of 256
elements. Index 0 is counted as the "transparency" index.
base_addr + size_of::<Color>() * index
- 4bpp: Each color index within a background or object is 4 bits. The 4
bits within the image data is an entry into a "palette bank" of 16
entries. The palette bank used for the BG or OBJ overall is determined by
their control bits. Index 0 within a palbank is still considered the
"transparency" index.
base_addr + size_of::<Color>() * (pal_bank << 4 | entry)
Index 0 of the BG palette is a special "backdrop" index. This is the color drawn to a screen pixel when no BG or OBJ is drawing to that location.
Please note that there's only one PALRAM, the 8bpp and 4bpp modes are just two ways to index into the same region of memory. A change to one will affect the other.
Methods
impl PALRAM
[src]
#[must_use]pub const fn bg_8bpp(self, index: u8) -> SimpleVolAddr<Color>
[src]
Gets the address of an 8bpp BG color.
Index 0 is used as transparent in an 8bpp BG. Instead of changing the color displayed in the BG itself, changing index 0 will change the "backdrop" color, which is the default color shown when no BG or OBJ draws to a given screen pixel.
#[must_use]pub const fn obj_8bpp(self, index: u8) -> SimpleVolAddr<Color>
[src]
Get the address of an 8bpp OBJ color.
Index 0 in an 8bpp OBJ is transparent, and setting it will have no effect.
#[must_use]pub const fn backdrop(self) -> SimpleVolAddr<Color>
[src]
Gets the backdrop color address.
This is identical to PALRAM.bg_8bpp(0)
, See bg_8bpp
#[must_use]pub fn bg_4bpp(self, pal_bank: usize, entry: usize) -> SimpleVolAddr<Color>
[src]
#[must_use]pub fn obj_4bpp(self, pal_bank: usize, entry: usize) -> SimpleVolAddr<Color>
[src]
#[must_use]pub const fn bg_4bpp_wrapping(
self,
pal_bank: usize,
entry: usize
) -> SimpleVolAddr<Color>
[src]
self,
pal_bank: usize,
entry: usize
) -> SimpleVolAddr<Color>
Get the address of a 4bpp BG color.
Only uses the lowest 4 bits of each value given, effectively wrapping both
values into the range 0..=15
.
#[must_use]pub const fn obj_4bpp_wrapping(
self,
pal_bank: usize,
entry: usize
) -> SimpleVolAddr<Color>
[src]
self,
pal_bank: usize,
entry: usize
) -> SimpleVolAddr<Color>
Get the address of a 4bpp OBJ color.
Only uses the lowest 4 bits of each value given, effectively wrapping both
values into the range 0..=15
.
Trait Implementations
impl Clone for PALRAM
[src]
fn clone(&self) -> PALRAM
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for PALRAM
[src]
impl Debug for PALRAM
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,