Skip to main content

HdTileSource

Struct HdTileSource 

Source
pub struct HdTileSource {
    pub chr_addr: u16,
    pub palette: u8,
    pub is_sprite: bool,
    pub flip_h: bool,
    pub flip_v: bool,
    pub palette_colors: u32,
    pub offset_x: u8,
    pub offset_y: u8,
    pub chr_tile_index: u32,
    pub color_mask: u8,
    pub sprites: [HdSprite; 4],
    pub sprite_count: u8,
}
Expand description

v1.2.0 beta.2 (Workstream C3) — per-pixel HD-pack tile-source record.

One entry per visible pixel (parallel to Ppu::index_framebuffer), populated in the pixel-emit path only when the hd-pack cargo feature is enabled. It records the identity of the CHR tile that produced the pixel — the 16-byte pattern-table tile base address (in PPU $0000..=$1FFF pattern space, fine-Y masked off), the 2-bit attribute/sprite palette, the sprite flip flags, and whether the source was a sprite or the background.

It is pure output telemetry: it mirrors data the renderer already computed, reads no new VRAM, and changes no emulation state — so it is byte-identical with the feature on or off and is never serialized into a save-state. The frontend’s Mesen-style HD-pack loader groups these by 8×8 screen cell, hashes the referenced CHR bytes, and substitutes hi-res replacement tiles at blit time. See docs/ppu-2c02.md §HD-pack tile-source export.

Fields§

§chr_addr: u16

16-byte CHR tile base address in pattern space ($0000..=$1FF0, low nibble always 0). tile = (addr >> 4) & 0xFF, table = addr & 0x1000. 0xFFFF marks a transparent / universal-background pixel (no tile).

§palette: u8

Final palette group: BG attribute (0..=3) or sprite palette (0..=3).

§is_sprite: bool

true when the pixel came from a sprite (vs. the background).

§flip_h: bool

Sprite horizontal flip (always false for BG pixels).

§flip_v: bool

Sprite vertical flip (always false for BG pixels).

§palette_colors: u32

Mesen PaletteColors: the tile’s active palette packed as the HD-pack tile-identity key expects. BG = pr[base+3] | pr[base+2]<<8 | pr[base+1]<<16 | pr[0]<<24; sprite = 0xFF000000 | pr[base+3] | pr[base+2]<<8 | pr[base+1]<<16 (top byte 0xFF = the sprite/BG discriminator). Part of the CHR-RAM/CHR-ROM tile key (HdNesPpu.h:119/167).

§offset_x: u8

Which texel COLUMN (0..=7) of the 8x8 tile this screen pixel samples — Mesen OffsetX (HdNesPpu.h:172). For BG it folds in fine-X scroll ((fineX + (pixel_x & 7)) & 7); for a sprite it is the column within the sprite tile. The HD compositor samples the replacement at this column so the high-def tile tracks the scrolled / sprite position pixel-for-pixel (flips are applied at sample time). Output-only.

§offset_y: u8

Which texel ROW (0..=7) of the 8x8 tile this screen pixel samples — Mesen OffsetY. BG = fine-Y; sprite = the row within the sprite tile.

§chr_tile_index: u32

Mesen CHR-ROM TileIndex: the ABSOLUTE post-banking CHR-ROM tile number (chr_phys(addr) / 16) for a CHR-ROM cart, or HD_CHR_RAM when CHR is RAM (the tile is content-hashed instead). The HD-pack key uses TileIndex ^ PaletteColors for CHR-ROM and CalculateHash(palette ++ data) for CHR-RAM (Mesen HdTileKey). Captured at fetch (the only point with mapper access). Output-only.

§color_mask: u8

v1.8.9 — the $2001 grayscale + emphasis bits at this pixel (mask.bits() & 0xE1: bit 0 = grayscale, bits 5-7 = R/G/B emphasis). The HD compositor re-applies them to the replacement texel (Mesen ProcessGrayscaleAndEmphasis) so HD tiles track grayscale / emphasis fades like the base frame, which already has them baked in. Output-only.

§sprites: [HdSprite; 4]

v1.8.9 — every opaque sprite covering this pixel (up to 4), front-to-back, for Mesen spriteAtPosition / spriteNearby (which match ANY covering sprite, including ones a higher-priority BG occludes). sprites[0] is the front-most. The existing is_sprite + tile fields still describe the VISIBLE pixel (the winning layer); these add the hidden layers. Output-only.

§sprite_count: u8

Number of valid entries in Self::sprites (0..=4).

Trait Implementations§

Source§

impl Clone for HdTileSource

Source§

fn clone(&self) -> HdTileSource

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 Copy for HdTileSource

Source§

impl Debug for HdTileSource

Source§

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

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

impl Default for HdTileSource

Available on crate feature hd-pack only.
Source§

fn default() -> Self

A blank record: no tile, and the CHR-RAM sentinel (so an unwritten / default record is content-keyed, never mistaken for CHR-ROM tile 0).

Source§

impl Eq for HdTileSource

Source§

impl PartialEq for HdTileSource

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for HdTileSource

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.