Compare commits

..

2 Commits

Author SHA1 Message Date
Simon Gellis b62046045d Support reading VBX files in cart 2025-08-07 21:15:30 -04:00
Simon Gellis 6687b1f12f Fix SRAM addressable range 2025-08-07 21:09:16 -04:00
1 changed files with 8 additions and 3 deletions

View File

@ -34,9 +34,14 @@ impl Cart {
.truncate(false)
.open(sram_path(file_path, sim_id))?;
let sram_file_size = if contents.sram_small_bus {
contents.sram_size * 2
} else {
contents.sram_size
};
let sram = if sram_file.metadata()?.len() == 0 {
// new SRAM file, randomize the contents
let mut sram = vec![0; contents.sram_size];
let mut sram = vec![0; sram_file_size];
let mut rng = rand::rng();
for dst in sram
.iter_mut()
@ -46,9 +51,9 @@ impl Cart {
}
sram
} else {
let mut sram = Vec::with_capacity(contents.sram_size);
let mut sram = Vec::with_capacity(sram_file_size);
sram_file.read_to_end(&mut sram)?;
sram.resize(contents.sram_size, 0);
sram.resize(sram_file_size, 0);
sram
};