Crates.io | c64-cartridge |
lib.rs | c64-cartridge |
version | 0.5.0 |
created_at | 2025-08-11 13:38:02.919403+00 |
updated_at | 2025-08-11 13:38:02.919403+00 |
description | Parser for the C64 cartridge format (*.crt) |
homepage | |
repository | |
max_upload_size | |
id | 1790181 |
size | 44,286 |
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
.
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);
}
default
: alloc
alloc
: Enable [Data::check_overlap
] and [Data8K::check_overlap
].With defaults (alloc
):
[dependencies]
c64-cartridge = "0.1"
Without defaults (alloc
):
[dependencies]
c64-cartridge = { version = "0.1", default-features = false }