#[non_exhaustive]pub struct Cartridge {Show 15 fields
pub prg_rom: Box<[u8]>,
pub chr_rom: Box<[u8]>,
pub mapper_id: u16,
pub submapper: u8,
pub mirroring: Mirroring,
pub region: Region,
pub console_type: ConsoleType,
pub vs_ppu_type: VsPpuType,
pub vs_dual_system: bool,
pub prg_ram_size: u32,
pub chr_ram_size: u32,
pub has_battery: bool,
pub has_trainer: bool,
pub is_nes2: bool,
pub nametable_wiring_bits: u8,
}Expand description
Concrete iNES / NES 2.0 cartridge value.
prg_rom and chr_rom are read-only ROM banks. prg_ram_size and
chr_ram_size are requested sizes; mapper implementations allocate the
matching RAM buffers in their constructors.
Field set follows docs/cartridge-format.md §Public API. mapper (the
boxed dyn Mapper from docs/mappers.md) is constructed by
crate::parse and stored on the cartridge separately from this metadata
header so the metadata is cheap to clone.
#[non_exhaustive] since v3.0.0 (T-API-EXTENSIBLE): outside this crate a
cartridge comes from crate::parse (or the other loaders), or from
Cartridge::synthetic for a device with no cartridge header; set the
public fields that differ afterwards. A later header field is then not a
break, as nametable_wiring_bits was at v2.9.9.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.prg_rom: Box<[u8]>PRG-ROM bytes. Length is a multiple of 16 KiB for standard sizes; may be irregular when the NES 2.0 exponent-multiplier encoding is used.
chr_rom: Box<[u8]>CHR-ROM bytes. Empty when the cartridge uses CHR-RAM (length 0).
mapper_id: u1612-bit mapper id (iNES 1.0 only uses the low 8 bits).
submapper: u84-bit submapper id (NES 2.0 only; always 0 for iNES 1.0).
mirroring: MirroringInitial mirroring as selected by the header.
region: RegionRegion from NES 2.0 byte 12; defaults to Region::Ntsc for iNES 1.0.
console_type: ConsoleTypeConsole type from NES 2.0 byte 7; always ConsoleType::Nes for iNES 1.0.
vs_ppu_type: VsPpuTypeVs. System PPU type from NES 2.0 byte 13 (low nibble), valid only when
console_type == ConsoleType::VsSystem; VsPpuType::None otherwise.
vs_dual_system: boolTrue when the header marks a Vs. DualSystem board (NES 2.0 byte-13
high nibble = Vs. hardware type 5/6). Detection only; the two-CPU/two-PPU
emulation is a documented v2.0 deferral.
prg_ram_size: u32Requested PRG-RAM size in bytes.
chr_ram_size: u32Requested CHR-RAM size in bytes (0 if the cart ships with CHR-ROM only).
has_battery: boolTrue if the cartridge has non-volatile save data: battery-backed PRG-RAM per the header, or (v2.9.6) a self-flashable board’s flash (mappers 30 and 111), set by the loader whatever the header’s bit says.
has_trainer: boolTrue if a 512-byte trainer was present in the file (loaded at $7000-$71FF).
is_nes2: boolTrue if the file format is NES 2.0 (vs. iNES 1.0).
nametable_wiring_bits: u8The raw iNES byte-6 nametable bits, byte6 & 0x09 (bit 3 four-screen,
bit 0 the arrangement bit), before Self::mirroring folds them.
Mappers 30 (UNROM 512) and 218 (Magic Floor) wire CIRAM from these
bits directly, so two headers that both say FourScreen can build
different machines; v2.9.9 carries the bits so the movie and netplay
board check can tell them apart (core re-audit NC-10). Zero for
formats without an iNES header (FDS, NSF).
Implementations§
Source§impl Cartridge
impl Cartridge
Sourcepub fn synthetic(mapper_id: u16, prg_ram_size: u32, chr_ram_size: u32) -> Self
pub fn synthetic(mapper_id: u16, prg_ram_size: u32, chr_ram_size: u32) -> Self
v3.0.0 — metadata for a machine whose program does not come from a cartridge header (the FDS, an NSF player): empty PRG/CHR-ROM, NTSC, horizontal mirroring, a stock NES, no battery, trainer or NES 2.0 header, and the given mapper id and RAM sizes. The bus consults little of it for such a machine; the device owns its own storage. Set any field that differs after construction.
Sourcepub fn uses_chr_ram(&self) -> bool
pub fn uses_chr_ram(&self) -> bool
Returns true when this cartridge ships PRG-ROM only (no CHR-ROM bank).