Impose a minimum length of 4MB for the gamepak memory
Former-commit-id: 08e66bff0bc39968e572b941da84c155a45f31c8
This commit is contained in:
parent
d36da30618
commit
6eab76d52f
|
@ -381,7 +381,7 @@ impl Core {
|
||||||
ArmHalfwordTransferType::UnsignedHalfwords => {
|
ArmHalfwordTransferType::UnsignedHalfwords => {
|
||||||
self.store_16(addr, value as u16, bus)
|
self.store_16(addr, value as u16, bus)
|
||||||
}
|
}
|
||||||
_ => panic!("invalid HS flags for L=0")
|
_ => panic!("invalid HS flags for L=0"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,12 @@ use rustboyadvance_ng::{GBAResult, GameBoyAdvance};
|
||||||
fn run_debug(matches: &ArgMatches) -> GBAResult<()> {
|
fn run_debug(matches: &ArgMatches) -> GBAResult<()> {
|
||||||
let skip_bios = match matches.occurrences_of("skip_bios") {
|
let skip_bios = match matches.occurrences_of("skip_bios") {
|
||||||
0 => false,
|
0 => false,
|
||||||
_ => true
|
_ => true,
|
||||||
};
|
};
|
||||||
|
|
||||||
let bios_bin = read_bin_file(matches.value_of("bios").unwrap_or_default())?;
|
let bios_bin = read_bin_file(matches.value_of("bios").unwrap_or_default())?;
|
||||||
let rom_bin = read_bin_file(matches.value_of("game_rom").unwrap())?;
|
|
||||||
|
|
||||||
let gamepak = Cartridge::new(rom_bin);
|
let gamepak = Cartridge::load(matches.value_of("game_rom").unwrap())?;
|
||||||
println!("loaded rom: {:#?}", gamepak.header);
|
println!("loaded rom: {:#?}", gamepak.header);
|
||||||
|
|
||||||
let mut core = Core::new();
|
let mut core = Core::new();
|
||||||
|
|
|
@ -5,6 +5,8 @@ use crate::arm7tdmi::{
|
||||||
Addr,
|
Addr,
|
||||||
};
|
};
|
||||||
use crate::sysbus::WaitState;
|
use crate::sysbus::WaitState;
|
||||||
|
use crate::util::read_bin_file;
|
||||||
|
use crate::GBAError;
|
||||||
|
|
||||||
/// From GBATEK
|
/// From GBATEK
|
||||||
///
|
///
|
||||||
|
@ -73,13 +75,20 @@ pub struct Cartridge {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cartridge {
|
impl Cartridge {
|
||||||
pub fn new(gamepak: Vec<u8>) -> Cartridge {
|
const MIN_SIZE: usize = 4 * 1024 * 1024;
|
||||||
let header = CartridgeHeader::parse(&gamepak);
|
|
||||||
Cartridge {
|
pub fn load(path: &str) -> Result<Cartridge, GBAError> {
|
||||||
header: header,
|
let mut rom_bin = read_bin_file(path)?;
|
||||||
bytes: gamepak.into_boxed_slice(),
|
if rom_bin.len() < Cartridge::MIN_SIZE {
|
||||||
ws: WaitState::new(5, 5, 8),
|
rom_bin.resize_with(Cartridge::MIN_SIZE, Default::default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let header = CartridgeHeader::parse(&rom_bin);
|
||||||
|
Ok(Cartridge {
|
||||||
|
header: header,
|
||||||
|
bytes: rom_bin.into_boxed_slice(),
|
||||||
|
ws: WaitState::new(5, 5, 8),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue