Skip to main content

AttrAccess

Struct AttrAccess 

Source
pub struct AttrAccess<'a> { /* private fields */ }
Available on crate feature cgb only.
Expand description

Proof that the attribute plane is the grid mapped at the tilemap addresses.

The plane is a second 32 by 32 grid in VRAM bank 1, sharing the tilemap’s addresses. Each byte holds the palette, the flips, the object priority and the tile bank for the cell of the same coordinates. Pan Docs calls these the BG map attributes, but they reach the window too: whichever layer reads a tilemap reads its attributes alongside.

They belong to the cell, not to the tile it names. Two cells showing one tile can be drawn from different palettes, and giving a cell a different tile leaves its attributes where they were.

BgAttr::bank says which VRAM bank the PPU fetches that cell’s tile from, a separate question from which bank the CPU has mapped. edit_attrs settles the second so that a write lands in the plane rather than in the tile indices.

Handed out by edit_attrs and bounded to its closure, the way Access::Direct is. See https://gbdev.io/pandocs/Tile_Maps.html#bg-map-attributes-cgb-mode-only.

Implementations§

Source§

impl AttrAccess<'_>

Source

pub fn set(self, access: Access<'_>, map: Map, x: u8, y: u8, attr: BgAttr)

Give one cell its attributes.

Source

pub fn fill( self, access: Access<'_>, map: Map, x: u8, y: u8, w: u8, h: u8, attr: BgAttr, )

Give every cell of a rectangle the same attributes.

§Panics

As fill.

Source

pub fn write( self, access: Access<'_>, map: Map, x: u8, y: u8, src: AttrGrid<'_>, )

Copy a rectangle of attribute bytes in, its top left at (x, y).

§Panics

As write().

Trait Implementations§

Source§

impl<'a> !Send for AttrAccess<'a>

Source§

impl<'a> !Sync for AttrAccess<'a>

Source§

impl<'a> Clone for AttrAccess<'a>

Source§

fn clone(&self) -> AttrAccess<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for AttrAccess<'a>

Auto Trait Implementations§

§

impl<'a> BankSafe for AttrAccess<'a>

§

impl<'a> Freeze for AttrAccess<'a>

§

impl<'a> RefUnwindSafe for AttrAccess<'a>

§

impl<'a> Unpin for AttrAccess<'a>

§

impl<'a> UnsafeUnpin for AttrAccess<'a>

§

impl<'a> UnwindSafe for AttrAccess<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CellValue for T
where T: Copy + BankSafe,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.