Expand description
A parser for the C64’s cartridge format.
The parser requires that the whole file must be in ram.
To check a cartridge step by step read RawCartridge and RawChip and use their check functions.
The library is no_std.
§Example
let (cartridge, data) = parse_crt(crt_file_slice)?;
// convert to the "usual 8 KiB ROM banking"
let Some(data) = data.into_8k_baking() else { panic!("crt contains RAM and/or not the usual 8 KiB ROM banking") };
// calculate max bank (the unwrap is safe because data guarantees at lest one chip)
let max_bank = data.iter().map(|(chip, _)| chip.bank_number).max().unwrap() as usize;
// create a single memory of all ROM banks
let mut all = vec![0xff; (max_bank + 1) * 0x4000];
for (chip, data) in data {
let mut ofs = chip.bank_number as usize * 0x4000;
if chip.position == Position::High {
ofs += 0x2000;
}
all[ofs..ofs + 0x2000].copy_from_slice(data);
}§Features
default:allocalloc: EnableData::check_overlapandData8K::check_overlap.
§Usage
With defaults (alloc):
[dependencies]
c64-cartridge = "0.5"Without defaults (alloc):
[dependencies]
c64-cartridge = { version = "0.5", default-features = false }Structs§
- Cartridge
- The (simplified) cartridge header.
- Cartridge
Type - Values for
Cartridge.cartridge_hardware_type. - Chip
- A (simplified) chip header.
- Chip8K
- A minimal, chip header for 8 KiB only ROM banking.
- Data
- The data of a
Cartridge. - Data8K
- The data of a
Cartridge. - Iter
- The iterator over all
Chips with their data in the cartridge. - Iter8K
- The iterator over all
Chip8Ks with their data in the cartridge. - RawCartridge
- The cartridge header (in memory/on disk representation).
- RawChip
- A chip header (in memory/on disk representation).
Enums§
- Chip
Type - Values for
Chip.chip_type. - Parse
Error - Possible errors while parsing the crt.
- Position
- The position of a rom data within a bank.
Functions§
- parse_
crt - Parse a crt.
- parse_
crt_ ⚠aligned - Parse a crt from an aligned buffer.