mirror of
https://github.com/transistorfet/moa.git
synced 2025-02-13 07:30:28 +00:00
Refactored to separate out the commands, and machine configs
Machine definitions are now in their own module and can be optionally compiled in, and there is now a console and soon to be gui version of the compiled binary, with individual binaries for each machine
This commit is contained in:
parent
e81a5d430a
commit
8d39d84545
9
frontends/moa-console/Cargo.toml
Normal file
9
frontends/moa-console/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "moa-console"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
default-run = "moa-computie"
|
||||
|
||||
[dependencies]
|
||||
moa = { path = "../../", features = ["tty"] }
|
||||
|
10
frontends/moa-console/src/bin/moa-computie.rs
Normal file
10
frontends/moa-console/src/bin/moa-computie.rs
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
use moa_console::ConsoleFrontend;
|
||||
use moa::machines::computie::run_computie;
|
||||
|
||||
fn main() {
|
||||
let mut frontend = ConsoleFrontend;
|
||||
|
||||
run_computie(&mut frontend);
|
||||
}
|
||||
|
16
frontends/moa-console/src/lib.rs
Normal file
16
frontends/moa-console/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
use moa::error::Error;
|
||||
use moa::host::frontend::{Frontend, SharedCanvas, SharedAudio};
|
||||
|
||||
pub struct ConsoleFrontend;
|
||||
|
||||
impl Frontend for ConsoleFrontend {
|
||||
fn get_canvas(&mut self) -> Result<SharedCanvas, Error> {
|
||||
Err(Error::new("Console frontend doesn't support canvas"))
|
||||
}
|
||||
|
||||
fn get_audio(&mut self) -> Result<SharedAudio, Error> {
|
||||
Err(Error::new("Console frontend doesn't support audio"))
|
||||
}
|
||||
}
|
||||
|
11
src/host/frontend/mod.rs
Normal file
11
src/host/frontend/mod.rs
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
pub mod traits;
|
||||
|
||||
pub use self::traits::{
|
||||
Frontend,
|
||||
Canvas,
|
||||
SharedCanvas,
|
||||
Audio,
|
||||
SharedAudio,
|
||||
};
|
||||
|
21
src/host/frontend/traits.rs
Normal file
21
src/host/frontend/traits.rs
Normal file
@ -0,0 +1,21 @@
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::error::Error;
|
||||
|
||||
pub trait Canvas {
|
||||
fn draw_bitmap(&mut self, x: u32, y: u32, bitmap: &[u8]);
|
||||
}
|
||||
|
||||
pub trait Audio {
|
||||
|
||||
}
|
||||
|
||||
pub type SharedCanvas = Arc<Mutex<Box<dyn Canvas>>>;
|
||||
pub type SharedAudio = Arc<Mutex<Box<dyn Audio>>>;
|
||||
|
||||
pub trait Frontend {
|
||||
fn get_canvas(&mut self) -> Result<SharedCanvas, Error>;
|
||||
fn get_audio(&mut self) -> Result<SharedAudio, Error>;
|
||||
}
|
||||
|
@ -1,3 +1,6 @@
|
||||
|
||||
pub mod frontend;
|
||||
|
||||
#[cfg(feature = "tty")]
|
||||
pub mod tty;
|
||||
|
||||
|
14
src/lib.rs
Normal file
14
src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#[macro_use]
|
||||
pub mod error;
|
||||
pub mod memory;
|
||||
pub mod timers;
|
||||
pub mod devices;
|
||||
pub mod interrupts;
|
||||
pub mod system;
|
||||
|
||||
pub mod host;
|
||||
pub mod cpus;
|
||||
pub mod peripherals;
|
||||
pub mod machines;
|
||||
|
@ -1,32 +1,18 @@
|
||||
|
||||
#[macro_use]
|
||||
mod error;
|
||||
mod memory;
|
||||
mod timers;
|
||||
mod devices;
|
||||
mod interrupts;
|
||||
mod system;
|
||||
|
||||
mod host;
|
||||
mod cpus;
|
||||
mod peripherals;
|
||||
|
||||
use crate::system::System;
|
||||
use crate::memory::MemoryBlock;
|
||||
use crate::peripherals::ata::AtaDevice;
|
||||
use crate::cpus::m68k::{M68k, M68kType};
|
||||
use crate::peripherals::mc68681::MC68681;
|
||||
use crate::host::frontend::Frontend;
|
||||
use crate::devices::wrap_transmutable;
|
||||
|
||||
fn main() {
|
||||
run_computie();
|
||||
}
|
||||
use crate::cpus::m68k::{M68k, M68kType};
|
||||
use crate::peripherals::ata::AtaDevice;
|
||||
use crate::peripherals::mc68681::MC68681;
|
||||
|
||||
fn run_computie() {
|
||||
|
||||
pub fn run_computie(frontend: &mut dyn Frontend) {
|
||||
let mut system = System::new();
|
||||
|
||||
let monitor = MemoryBlock::load("binaries/monitor.bin").unwrap();
|
||||
//let monitor = MemoryBlock::load("binaries/monitor-68030.bin").unwrap();
|
||||
for byte in monitor.contents.iter() {
|
||||
print!("{:02x} ", byte);
|
||||
}
|
||||
@ -34,7 +20,6 @@ fn run_computie() {
|
||||
|
||||
let mut ram = MemoryBlock::new(vec![0; 0x00100000]);
|
||||
ram.load_at(0, "binaries/kernel.bin").unwrap();
|
||||
//ram.load_at(0, "binaries/kernel-68030.bin").unwrap();
|
||||
system.add_addressable_device(0x00100000, wrap_transmutable(ram)).unwrap();
|
||||
|
||||
let mut ata = AtaDevice::new();
|
||||
@ -48,7 +33,41 @@ fn run_computie() {
|
||||
|
||||
|
||||
let mut cpu = M68k::new(M68kType::MC68010);
|
||||
//let mut cpu = M68k::new(M68kType::MC68030);
|
||||
|
||||
//cpu.enable_tracing();
|
||||
//cpu.add_breakpoint(0x10781a);
|
||||
//cpu.add_breakpoint(0x10bc9c);
|
||||
//cpu.add_breakpoint(0x106a94);
|
||||
//cpu.add_breakpoint(0x1015b2);
|
||||
//cpu.add_breakpoint(0x103332);
|
||||
//cpu.decoder.dump_disassembly(&mut system, 0x100000, 0x2000);
|
||||
//cpu.decoder.dump_disassembly(&mut system, 0x2ac, 0x200);
|
||||
|
||||
system.add_interruptable_device(wrap_transmutable(cpu)).unwrap();
|
||||
system.run_loop();
|
||||
}
|
||||
|
||||
pub fn run_computie_k30(frontend: &mut dyn Frontend) {
|
||||
let mut system = System::new();
|
||||
|
||||
let monitor = MemoryBlock::load("binaries/monitor-68030.bin").unwrap();
|
||||
system.add_addressable_device(0x00000000, wrap_transmutable(monitor)).unwrap();
|
||||
|
||||
let mut ram = MemoryBlock::new(vec![0; 0x00100000]);
|
||||
ram.load_at(0, "binaries/kernel-68030.bin").unwrap();
|
||||
system.add_addressable_device(0x00100000, wrap_transmutable(ram)).unwrap();
|
||||
|
||||
let mut ata = AtaDevice::new();
|
||||
ata.load("binaries/disk-with-partition-table.img").unwrap();
|
||||
system.add_addressable_device(0x00600000, wrap_transmutable(ata)).unwrap();
|
||||
|
||||
let mut serial = MC68681::new();
|
||||
launch_terminal_emulator(serial.port_a.open().unwrap());
|
||||
//launch_slip_connection(serial.port_b.open().unwrap());
|
||||
system.add_addressable_device(0x00700000, wrap_transmutable(serial)).unwrap();
|
||||
|
||||
|
||||
let mut cpu = M68k::new(M68kType::MC68030);
|
||||
|
||||
//cpu.enable_tracing();
|
||||
//cpu.add_breakpoint(0x10781a);
|
||||
@ -83,4 +102,3 @@ pub fn launch_slip_connection(name: String) {
|
||||
Command::new("sudo").args(["sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward"]).status().unwrap();
|
||||
}
|
||||
|
||||
|
3
src/machines/mod.rs
Normal file
3
src/machines/mod.rs
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
pub mod computie;
|
||||
|
6
todo.txt
6
todo.txt
@ -1,4 +1,10 @@
|
||||
|
||||
* should the frontend and simulator parts be separated so that the simulator part can be a library package?
|
||||
* it should be call something other than canvas because it'll have input as well
|
||||
* how will you get the canvas/app shared object between the sim thread and the io thread? It kind of has to be passed through the system-creation
|
||||
functions (an only if they need them), which raises questions about how to configure things. It'd be nice if you could still run the same hardware
|
||||
simulated without using a frontend
|
||||
|
||||
* can you eventually make the system connections all configurable via a config file?
|
||||
* test using mpsc to pass messages with the tty IO thread, and test if it's slower than what you have now
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user