Skip to main content

PixelProvenance

Struct PixelProvenance 

Source
pub struct PixelProvenance {
Show 19 fields pub scanline: i16, pub dot: u16, pub layer: PixelLayer, pub palette_addr: u16, pub palette_index: u8, pub color: u8, pub color_mask: u8, pub nt_addr: u16, pub at_addr: u16, pub pattern_addr: u16, pub bg_idx: u8, pub bg_pal: u8, pub spr_idx: u8, pub spr_pal: u8, pub sprite_slot: u8, pub sprite_front: bool, pub sprite_zero: bool, pub fine_x: u8, pub fine_y: u8,
}
Expand description

The causal record for one emitted pixel.

Recorded in Ppu::emit_pixel from state already computed there plus the per-tile address cascade described on Ppu::prov_bg_cur. Everything here is an address or a decision the hardware actually made; nothing is reconstructed after the fact, because a reconstruction would silently disagree with the emulator in exactly the corner cases a provenance panel exists to explain.

§Reading it

Self::palette_index indexes straight into WriteAttribution::palette, and Self::nt_addr resolves (through the mapper’s mirroring) to the CIRAM offset for WriteAttribution::ciram — so the two halves of this module compose into “this pixel is this color because instruction X wrote this palette entry and instruction Y wrote this nametable byte”.

Fields§

§scanline: i16

PPU scanline the pixel was emitted on.

§dot: u16

PPU dot the pixel was emitted at. Screen X is dot - 1.

§layer: PixelLayer

Which layer won.

§palette_addr: u16

The exact palette-RAM address read for the final color, pre-mirroring — so $3F10 is reported as $3F10 even though it reads $3F00.

§palette_index: u8

Post-mirroring palette-RAM index of the final color. Indexes WriteAttribution::palette directly.

§color: u8

The 6-bit NES color the palette entry held, before emphasis.

§color_mask: u8

$2001 grayscale + emphasis bits in effect at this pixel (mask & 0xE1), which is what turns Self::color into the RGBA actually written.

§nt_addr: u16

Nametable address of the background tile being displayed at this pixel — not the address v currently holds, which has already advanced two tiles ahead. See Ppu::prov_bg_cur.

§at_addr: u16

Attribute address of the displayed background tile. Carried rather than derived from Self::nt_addr, because an MMC5 vertical split supplies its own attribute address that the standard arithmetic cannot produce.

§pattern_addr: u16

CHR address of the pattern row feeding this pixel — the displayed background tile’s row, or the winning sprite’s row. PATTERN_ADDR_NONE for a backdrop pixel.

§bg_idx: u8

Background pattern bits (0..=3) at this pixel. 0 is transparent.

§bg_pal: u8

Background attribute / palette group (0..=3).

§spr_idx: u8

Sprite pattern bits (0..=3) at this pixel. 0 is transparent.

§spr_pal: u8

Sprite palette group (0..=3).

§sprite_slot: u8

Sprite slot (0..=7) of the winning sprite, or SPRITE_SLOT_NONE.

This is the secondary-OAM slot for the scanline, not the primary OAM sprite number: sprite evaluation copies bytes from primary to secondary OAM without retaining the source index, so the primary index is not available at emit time. The panel matches the slot’s Y/tile/attribute against OAM rather than being handed an index the PPU never kept.

§sprite_front: bool

true when the winning sprite had front priority over the background.

§sprite_zero: bool

true when sprite 0 contributed an opaque pixel here — the condition the sprite-0 hit flag is derived from.

§fine_x: u8

Fine-X scroll in effect (0..=7): which texel column of the displayed background tile this pixel samples.

§fine_y: u8

Fine-Y (0..=7): which texel row of the displayed background tile.

Implementations§

Source§

impl PixelProvenance

Source

pub const fn is_recorded(&self) -> bool

Whether this record was actually emitted, as opposed to being the cleared Default.

Ppu::emit_pixel stamps Self::dot on every pixel it records, and the visible dots are 1..=256 — so dot 0 is unreachable for a real record and is exactly what clear leaves behind. Without this a caller cannot tell a cleared record from a genuine backdrop pixel, and reads a confident “scanline 0, dot 0, backdrop, palette $0000” as fact. That is precisely how the v2.3.2 inspector reported a wiped frame (v2.3.6 workstream 0).

Trait Implementations§

Source§

impl Clone for PixelProvenance

Source§

fn clone(&self) -> PixelProvenance

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for PixelProvenance

Source§

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

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

impl Default for PixelProvenance

Source§

fn default() -> PixelProvenance

Returns the “default value” for a type. Read more
Source§

impl Hash for PixelProvenance

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PixelProvenance

Source§

fn eq(&self, other: &PixelProvenance) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PixelProvenance

Source§

impl Eq for PixelProvenance

Source§

impl StructuralPartialEq for PixelProvenance

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> 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.

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.