pub fn parse(bytes: &[u8]) -> Result<(Cartridge, Box<dyn Mapper>), RomError>Expand description
Parse an iNES 1.0 / NES 2.0 ROM file.
Validates the magic, detects the format, applies the appropriate sizing
rules, slices out the trainer (if any), PRG-ROM, and CHR-ROM, and returns
a fully populated Cartridge plus a constructed dyn Mapper ready for
the bus to consume.
ยงErrors
RomError::Truncatedif the file is shorter than the declared sections.RomError::BadMagicif the first 4 bytes are not"NES\x1A".RomError::UnsupportedMapperif the mapper id is outside the supported set listed at crate level.RomError::InvalidConfigfor inconsistent header fields (e.g., exponent overflow).