Skip to main content

unif_to_ines

Function unif_to_ines 

Source
pub fn unif_to_ines(img: &UnifImage) -> Vec<u8> ⓘ
Expand description

Synthesize an equivalent NES 2.0 image from a parsed UNIF, so the standard crate::parse path builds the crate::Cartridge + mapper with zero duplicated mapper construction.

PRG is zero-padded to a 16 KiB multiple and CHR to 8 KiB; empty CHR encodes a CHR-RAM board (8 KiB CHR-RAM via NES 2.0 byte 11). NES 2.0 (not iNES 1.0) is used deliberately: it preserves the region (byte 12) the TVCI chunk gave us, and its byte-9 size MSB nibbles represent the large multicart PRG banks (> 255 × 16 KiB) that iNES 1.0 cannot. Every board in the table maps to a mapper id ≤ 255, well within range.