Compare commits

...

3 Commits

Author SHA1 Message Date
b7de519e47
Fix the ROM's reload command 2023-01-28 08:20:02 -06:00
5c0edf982a
Fix the ROM's enable byte location 2023-01-28 08:19:43 -06:00
d679e8710d
Change BusErrorCause's Display impl to use Self 2023-01-28 08:18:37 -06:00
2 changed files with 11 additions and 11 deletions

View File

@ -36,11 +36,11 @@ pub enum BusErrorCause {
impl Display for BusErrorCause {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
BusErrorCause::ReadingByte => f.write_str("reading byte from"),
BusErrorCause::ReadingWord => f.write_str("reading word from"),
BusErrorCause::WritingByte => f.write_str("writing byte to"),
BusErrorCause::WritingWord => f.write_str("writing word to"),
BusErrorCause::ReadingInstruction => f.write_str("reading instruction at"),
Self::ReadingByte => f.write_str("reading byte from"),
Self::ReadingWord => f.write_str("reading word from"),
Self::WritingByte => f.write_str("writing byte to"),
Self::WritingWord => f.write_str("writing word to"),
Self::ReadingInstruction => f.write_str("reading instruction at"),
}
}
}

View File

@ -81,8 +81,8 @@ impl Card for Rom {
match address {
(0..=0xEF) => NullableResult::Ok(self.ram[address as usize]),
(0xF0..=0xF1) => NullableResult::Ok(u16_get_be_byte(self.start, address - 0xF0)),
0xF2 => NullableResult::Ok(self.enabled as u8),
(0xFE..=0xFF) => NullableResult::Ok(u16_get_be_byte(ID, address - 0xFE)),
0xF3 => NullableResult::Ok(self.enabled as u8),
(0xFE..=0xFF) => NullableResult::Ok(u16_get_be_byte(0x1, address - 0xFE)),
_ => NullableResult::Null,
}
}
@ -95,7 +95,7 @@ impl Card for Rom {
(0xF0..=0xF1) => {
self.start = u16_set_be_byte(self.start, address - 0xF0, data);
}
0xF2 => {
0xF3 => {
self.enabled = data > 0;
}
_ => (),
@ -114,11 +114,11 @@ impl Card for Rom {
println!("Read ROM image file {}", cmd[1]);
} else if cmd[0] == "reload" {
if let Some(file_name) = &self.file_name {
let mut file = File::open(cmd[1])
.map_err(|e| anyhow!("Couldn't open ROM image file {} ({})", cmd[1], e))?;
let mut file = File::open(file_name)
.map_err(|e| anyhow!("Couldn't open ROM image file {} ({})", file_name, e))?;
self.data.clear();
file.read_to_end(&mut self.data)
.map_err(|e| anyhow!("Failed to read ROM image file {} ({})", cmd[1], e))?;
.map_err(|e| anyhow!("Failed to read ROM image file {} ({})", file_name, e))?;
println!("Reloaded ROM image file {}", file_name);
} else {
println!("No ROM image file to reload");