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: u1616-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: u8Final palette group: BG attribute (0..=3) or sprite palette (0..=3).
is_sprite: booltrue when the pixel came from a sprite (vs. the background).
flip_h: boolSprite horizontal flip (always false for BG pixels).
flip_v: boolSprite vertical flip (always false for BG pixels).
palette_colors: u32Mesen 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: u8Which 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: u8Which 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: u32Mesen 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: u8v1.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: u8Number of valid entries in Self::sprites (0..=4).
Trait Implementations§
Source§impl Clone for HdTileSource
impl Clone for HdTileSource
Source§fn clone(&self) -> HdTileSource
fn clone(&self) -> HdTileSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HdTileSource
impl Debug for HdTileSource
Source§impl Default for HdTileSource
Available on crate feature hd-pack only.
impl Default for HdTileSource
hd-pack only.