Skip to content

Commit

Permalink
Rewrote core into libraries/system, using the emulator-hal interfaces
Browse files Browse the repository at this point in the history
This is the proof-of-concept using computie, since it only needs one
peripheral and the m68k cpu, which was already rewritten and tested
  • Loading branch information
transistorfet committed Jun 24, 2024
1 parent 342bb8a commit aa0336c
Show file tree
Hide file tree
Showing 19 changed files with 1,675 additions and 115 deletions.
19 changes: 17 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"emulator/core",
"emulator/libraries/system",
"emulator/frontends/common",
"emulator/frontends/console",
"emulator/frontends/minifb",
Expand Down
26 changes: 26 additions & 0 deletions emulator/core/src/devices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ pub trait Addressable {
}
}

impl<T> Addressable for &mut T
where
T: Addressable + ?Sized,
{
#[inline]
fn size(&self) -> usize {
T::size(self)
}

#[inline]
fn read(
&mut self,
now: Instant,
addr: Address,
data: &mut [u8],
) -> Result<(), Error> {
T::read(self, now, addr, data)
}

#[inline]
fn write(&mut self, now: Instant, addr: Address, data: &[u8]) -> Result<(), Error> {
T::write(self, now, addr, data)
}
}

#[inline]
pub fn read_beu16(data: &[u8]) -> u16 {
(data[0] as u16) << 8 | (data[1] as u16)
Expand Down Expand Up @@ -220,6 +245,7 @@ pub fn wrap_transmutable<T: Transmutable + 'static>(value: T) -> TransmutableBox
Rc::new(RefCell::new(Box::new(value)))
}


static NEXT_ID: AtomicUsize = AtomicUsize::new(1);

#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
Expand Down
5 changes: 3 additions & 2 deletions emulator/frontends/console/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ simple_logger = "4"
femtos = "0.1"

moa-core = { path = "../../core" }
moa-system = { path = "../../libraries/system" }
moa-host = { path = "../../libraries/host" }
moa-common = { path = "../common", features = ["tty"] }

moa-debugger = { path = "../../libraries/debugger" }
moa-systems-genesis = { path = "../../systems/genesis" }
#moa-debugger = { path = "../../libraries/debugger" }
#moa-systems-genesis = { path = "../../systems/genesis" }
moa-systems-computie = { path = "../../systems/computie" }
moa-m68k = { path = "../../cpus/m68k", features = ["moa"] }
moa-peripherals-generic = { path = "../../peripherals/generic" }
Expand Down
8 changes: 5 additions & 3 deletions emulator/frontends/console/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use clap::{Command, Arg, ArgAction, ArgMatches};
use std::io::{self, Write};
use femtos::Duration;

use moa_core::{Error, System};
use moa_debugger::{Debugger, DebugControl};
use moa_system::{Error, System};
//use moa_debugger::{Debugger, DebugControl};
use moa_host::{Host, HostError, Tty, ControllerEvent, Audio, DummyAudio, FrameReceiver, EventSender};

pub struct ConsoleFrontend;
Expand Down Expand Up @@ -75,9 +75,10 @@ impl ConsoleFrontend {
.unwrap();

// Run the main loop
let mut debugger = Debugger::default();
//let mut debugger = Debugger::default();
let mut run_debugger = matches.get_flag("debugger");
loop {
/*
if run_debugger {
run_debugger = false;
Expand All @@ -99,6 +100,7 @@ impl ConsoleFrontend {
}
}
}
*/

match system.run_for_duration(Duration::MAX - system.clock.as_duration()) {
Ok(()) => {},
Expand Down
15 changes: 15 additions & 0 deletions emulator/libraries/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "moa-system"
version = "0.1.0"
edition = "2021"

[dependencies]
log = "0.4"
femtos = "0.1"
thiserror = "1.0"
moa-host = { path = "../host" }
emulator-hal = { path = "../emulator-hal/emulator-hal", features = ["femtos"] }

[features]
default = ["std"]
std = []
Loading

0 comments on commit aa0336c

Please sign in to comment.