Skip to main content

Access

Enum Access 

Source
pub enum Access<'a> {
#[non_exhaustive]
Direct(PhantomData<&'a ()>), Polled, }
Expand description

How a write reaches video memory.

VRAM at 0x8000 and OAM at 0xFE00 are locked on different schedules: VRAM is reachable except in mode 3, OAM except in modes 2 and 3, and turning the LCD off opens both. See https://gbdev.io/pandocs/Accessing_VRAM_and_OAM.html.

Where the hardware has them locked it ignores writes and reads back 0xFF, so a value written there is lost rather than wrong, and nothing reports it.

Variants§

§

#[non_exhaustive]
Direct(PhantomData<&'a ()>)

The caller is already inside a window where both are open, so writes go straight through.

Minted by Vblank::with and with_lcd_off, and bounded to the closure they run. It is zero-sized and Copy; the lifetime is the only thing stopping it being carried out of the window:

let mut saved: Option<Access> = None;
vblank.with(|d| { saved = Some(d); }); // ERROR: `d` escapes the closure
§

Polled

Wait for the PPU to release video memory before writing, which makes the call safe at any point in the frame.

This reaches far more of the frame than one VBlank does, since HBlank recurs on every line. What it costs is the wait, which a bulk write pays for every byte: one this way can hold the CPU for more than a frame while the picture stays up.

Implementations§

Source§

impl<'a> Access<'a>

Source

pub const unsafe fn assume() -> Self

Mint Direct, asserting that video memory is reachable.

The escape hatch for a context Vblank::with cannot serve, such as a VBlank handler, which is already inside the window it would wait for.

§Safety

The PPU must be in mode 0 or 1, or the LCD off. The returned lifetime is unconstrained, so the caller must bound it to the period that holds.

Trait Implementations§

Source§

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

Source§

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

Source§

impl<'a> Clone for Access<'a>

Source§

fn clone(&self) -> Access<'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 Access<'a>

Auto Trait Implementations§

§

impl<'a> BankSafe for Access<'a>

§

impl<'a> Freeze for Access<'a>

§

impl<'a> RefUnwindSafe for Access<'a>

§

impl<'a> Unpin for Access<'a>

§

impl<'a> UnsafeUnpin for Access<'a>

§

impl<'a> UnwindSafe for Access<'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.