Pass backplane to card command function

This commit is contained in:
pjht 2024-03-09 12:25:55 -06:00
parent bf21b98498
commit 6b09e92ae7
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A
6 changed files with 8 additions and 10 deletions

View File

@ -148,7 +148,7 @@ impl Backplane {
.get(card_num as usize)
.ok_or_else(|| anyhow!("Card {} does not exist", card_num))?
.borrow_mut()
.cmd(cmd)
.cmd(cmd, &self)
}
pub fn read_word(&self, address: u32, supervisor: bool) -> Result<u16, BusError> {

View File

@ -112,7 +112,7 @@ pub trait Card: Debug + Display + mopa::Any {
NullableResult::Ok(())
}
fn cmd(&mut self, _cmd: &[&str]) -> anyhow::Result<()> {
fn cmd(&mut self, _cmd: &[&str], _backplane: &Backplane) -> anyhow::Result<()> {
Ok(())
}

View File

@ -1690,7 +1690,7 @@ impl M68K {
} else {
Ok(pc.wrapping_sub((-d as u16).into()))
}
},
}
EffectiveAddress::AbsoluteShort(x) => Ok(u32::from(x)),
EffectiveAddress::AbsoluteLong(x) => Ok(x),
EffectiveAddress::DataReg(_)

View File

@ -3,7 +3,7 @@ use std::fmt::Display;
use nullable_result::NullableResult;
use crate::{
backplane::Backplane,
backplane::{self, Backplane},
card::{u16_get_be_byte, u32_get_be_byte, u32_set_be_byte, Card, Mmu},
m68k::BusError,
register,
@ -114,7 +114,7 @@ impl Card for MmuCard {
NullableResult::Ok(())
}
fn cmd(&mut self, cmd: &[&str]) -> anyhow::Result<()> {
fn cmd(&mut self, cmd: &[&str], backplane: &Backplane) -> anyhow::Result<()> {
if cmd[0] == "debug" && cmd.len() >= 2 {
self.print_debug = cmd[1].parse()?;
}

View File

@ -7,9 +7,7 @@ use serde::Deserialize;
use toml::Value;
use crate::{
card::{u16_get_be_byte, u16_set_be_byte, Card},
m68k::BusError,
register,
backplane::{self, Backplane}, card::{u16_get_be_byte, u16_set_be_byte, Card}, m68k::BusError, register
};
const ID: u16 = 1;
@ -99,7 +97,7 @@ impl Card for Rom {
NullableResult::Ok(())
}
fn cmd(&mut self, cmd: &[&str]) -> anyhow::Result<()> {
fn cmd(&mut self, cmd: &[&str], _backplane: &Backplane) -> anyhow::Result<()> {
if cmd[0] == "load" && cmd.len() >= 2 {
let mut file = File::open(cmd[1])
.map_err(|e| anyhow!("Couldn't open ROM image file {} ({})", cmd[1], e))?;

View File

@ -139,7 +139,7 @@ impl Card for Storage {
NullableResult::Ok(())
}
fn cmd(&mut self, cmd: &[&str]) -> anyhow::Result<()> {
fn cmd(&mut self, cmd: &[&str], _backplane: &Backplane) -> anyhow::Result<()> {
if cmd[0] == "load" && cmd.len() >= 2 {
let file = File::open(cmd[1])
.map_err(|e| anyhow!("Couldn't open disk image file {} ({})", cmd[1], e))?;