pub struct Header {
pub offset: usize,
pub copier_prefix: usize,
pub map_mode: MapMode,
pub fast_rom: bool,
pub region: Region,
pub coprocessor: Coprocessor,
pub rom_size: usize,
pub sram_size: usize,
pub has_battery: bool,
}Expand description
A parsed SNES internal header.
Detection scores every candidate offset ($7FC0 / $FFC0 / $40FFC0, after copier-prefix
skip) and keeps the highest-scoring one. See Header::detect.
Fields§
§offset: usizeThe byte offset the header was found at, relative to the copier-prefix-stripped ROM
(LoROM $7FC0 / HiROM $FFC0 / ExHiROM $40FFC0).
copier_prefix: usizeThe number of leading bytes that are a copier prefix (0 or 512); the board ROM is the image with these bytes stripped.
map_mode: MapModeThe base map mode.
fast_rom: boolWhether the cart runs the FastROM (3.58 MHz) access window ($xFD5 bit 4).
region: RegionThe console region.
coprocessor: CoprocessorThe on-cart coprocessor (or Coprocessor::None).
rom_size: usizeROM size in bytes (the actual image size after copier strip, not the header claim).
sram_size: usizeSRAM (battery save-RAM) size in bytes (0 if none).
has_battery: boolWhether the cart is battery-backed (has persistent SRAM / RTC).
Implementations§
Source§impl Header
impl Header
Sourcepub fn detect(rom: &[u8]) -> Result<Self, HeaderError>
pub fn detect(rom: &[u8]) -> Result<Self, HeaderError>
Detect the internal header in a raw ROM image.
Skips a 512-byte copier prefix when len % 0x8000 == 0x200, then scores each candidate
offset and keeps the highest. A non-zero score is required, so an all-zero / garbage
image yields HeaderError::NoValidHeader.
§Errors
HeaderError::TooSmall if the (de-prefixed) image can’t hold a single 32 KiB bank, or
HeaderError::NoValidHeader if no candidate offset scores above zero.