c64-cartridge

Crates.ioc64-cartridge
lib.rsc64-cartridge
version0.5.0
created_at2025-08-11 13:38:02.919403+00
updated_at2025-08-11 13:38:02.919403+00
descriptionParser for the C64 cartridge format (*.crt)
homepage
repository
max_upload_size
id1790181
size44,286
Alex Kazik (alexkazik)

documentation

README

Dependency status crates.io Downloads Github stars License

crate c64-cartridge

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: alloc
  • alloc: Enable [Data::check_overlap] and [Data8K::check_overlap].

Usage

With defaults (alloc):

[dependencies]
c64-cartridge = "0.1"

Without defaults (alloc):

[dependencies]
c64-cartridge = { version = "0.1", default-features = false }
Commit count: 0

cargo fmt