Skip to content

Commit

Permalink
Automatically detect surplus cartridge header
Browse files Browse the repository at this point in the history
  • Loading branch information
twvd committed Nov 5, 2023
1 parent ed34ab3 commit ee1f772
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/bin/souper/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ fn main() -> Result<()> {
let args = Args::parse();

let f = fs::read(args.filename)?;
let load_offset = match f.len() % 1024 {
0 => 0,
0x200 => {
println!("Cartridge contains 0x200 bytes of weird header");
0x200
},
_ => panic!("Illogical cartridge file size: 0x{:08X}", f.len()),
};

let display = SDLRenderer::new(SCREEN_WIDTH, SCREEN_HEIGHT)?;

let bus = Mainbus::<SDLRenderer>::new(&f, args.bustrace, display);
let bus = Mainbus::<SDLRenderer>::new(&f[load_offset..], args.bustrace, display);

let reset = bus.read16(0xFFFC);
let mut cpu = Cpu65816::<Mainbus<SDLRenderer>>::new(bus, reset);
Expand Down

0 comments on commit ee1f772

Please sign in to comment.