2021-12-06 23:04:08 +00:00
|
|
|
|
2023-06-11 03:28:40 +00:00
|
|
|
use moa_core::{System, Error, Frequency, MemoryBlock, Debuggable, Device};
|
2022-09-25 06:14:03 +00:00
|
|
|
use moa_core::host::Host;
|
2021-12-06 23:04:08 +00:00
|
|
|
|
2022-09-25 06:14:03 +00:00
|
|
|
use moa_m68k::{M68k, M68kType};
|
2021-12-06 23:04:08 +00:00
|
|
|
|
2022-09-25 06:14:03 +00:00
|
|
|
use crate::peripherals::video::MacVideo;
|
|
|
|
use crate::peripherals::mainboard::Mainboard;
|
2021-12-06 23:04:08 +00:00
|
|
|
|
|
|
|
|
|
|
|
pub fn build_macintosh_512k<H: Host>(host: &mut H) -> Result<System, Error> {
|
2023-03-06 04:19:49 +00:00
|
|
|
let mut system = System::default();
|
2021-12-06 23:04:08 +00:00
|
|
|
|
|
|
|
/*
|
2021-12-13 20:00:24 +00:00
|
|
|
use crate::peripherals::mos6522::Mos6522;
|
|
|
|
use crate::peripherals::z8530::Z8530;
|
|
|
|
use crate::peripherals::macintosh::iwm::IWM;
|
|
|
|
|
2021-12-06 23:04:08 +00:00
|
|
|
let mut ram = MemoryBlock::new(vec![0; 0x00100000]);
|
|
|
|
ram.load_at(0, "binaries/macintosh/Macintosh 128k.rom")?;
|
|
|
|
let boxed_ram = wrap_transmutable(ram);
|
|
|
|
//system.add_addressable_device(0x00000000, boxed_ram.clone())?;
|
|
|
|
//system.add_addressable_device(0x00600000, boxed_ram)?;
|
|
|
|
|
|
|
|
let mut rom = MemoryBlock::load("binaries/macintosh/Macintosh 128k.rom")?;
|
|
|
|
rom.read_only();
|
|
|
|
let boxed_rom = wrap_transmutable(rom);
|
|
|
|
//system.add_addressable_device(0x00400000, wrap_transmutable(rom))?;
|
|
|
|
|
|
|
|
|
|
|
|
// The ROM accesses 0xf80000 to look for the debugger, and then accesses 0xf0000 which is the phase area
|
|
|
|
let misc = MemoryBlock::new(vec![0; 0x100000]);
|
|
|
|
system.add_addressable_device(0x00f00000, wrap_transmutable(misc))?;
|
|
|
|
|
2023-05-04 05:42:24 +00:00
|
|
|
let video = MacVideo::new(host)?;
|
2021-12-06 23:04:08 +00:00
|
|
|
system.add_device("video", wrap_transmutable(video)).unwrap();
|
|
|
|
|
|
|
|
let scc1 = Z8530::new();
|
|
|
|
//launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
|
|
|
//launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
|
|
|
system.add_addressable_device(0x009FFFF0, wrap_transmutable(scc1))?;
|
|
|
|
|
|
|
|
let scc2 = Z8530::new();
|
|
|
|
//launch_terminal_emulator(serial.port_a.connect(Box::new(SimplePty::open()?))?);
|
|
|
|
//launch_slip_connection(serial.port_b.connect(Box::new(SimplePty::open()?))?);
|
|
|
|
system.add_addressable_device(0x00BFFFF0, wrap_transmutable(scc2))?;
|
|
|
|
|
|
|
|
let iwm = IWM::new();
|
2022-10-02 04:01:56 +00:00
|
|
|
let adapter = AddressRightShifter::new(wrap_transmutable(iwm), 9);
|
2021-12-06 23:04:08 +00:00
|
|
|
system.add_addressable_device(0x00DFE1FF, wrap_transmutable(adapter))?;
|
|
|
|
|
|
|
|
//let via = wrap_transmutable(Mos6522::new());
|
|
|
|
let mainboard = Mainboard::new(boxed_ram, boxed_rom);
|
|
|
|
system.add_addressable_device(0x00000000, mainboard.bus.clone())?;
|
|
|
|
let mainboard_boxed = wrap_transmutable(mainboard);
|
|
|
|
system.add_device("via", mainboard_boxed.clone())?;
|
2022-10-02 04:01:56 +00:00
|
|
|
let adapter = AddressRightShifter::new(mainboard_boxed, 9);
|
2021-12-06 23:04:08 +00:00
|
|
|
system.add_addressable_device(0x00EFE000, wrap_transmutable(adapter))?;
|
|
|
|
*/
|
|
|
|
|
2021-12-13 20:00:24 +00:00
|
|
|
let ram = MemoryBlock::new(vec![0; 0x00080000]);
|
2021-12-06 23:04:08 +00:00
|
|
|
let mut rom = MemoryBlock::load("binaries/macintosh/Macintosh 512k.rom")?;
|
|
|
|
rom.read_only();
|
|
|
|
|
2023-05-04 05:42:24 +00:00
|
|
|
let video = MacVideo::new(host)?;
|
2023-06-08 03:44:14 +00:00
|
|
|
system.add_device("video", Device::new(video)).unwrap();
|
2021-12-06 23:04:08 +00:00
|
|
|
|
2023-06-08 03:44:14 +00:00
|
|
|
let mainboard = Mainboard::new(Device::new(ram), Device::new(rom))?;
|
|
|
|
system.add_addressable_device(0x00000000, Device::new(mainboard))?;
|
2021-12-06 23:04:08 +00:00
|
|
|
|
|
|
|
|
2023-06-11 03:28:40 +00:00
|
|
|
let mut cpu = M68k::from_type(M68kType::MC68000, Frequency::from_hz(7_833_600), system.bus.clone(), 0);
|
2021-12-06 23:04:08 +00:00
|
|
|
|
|
|
|
//cpu.enable_tracing();
|
|
|
|
//system.enable_debugging();
|
|
|
|
//cpu.add_breakpoint(0x10781a);
|
|
|
|
//cpu.add_breakpoint(0x40002a);
|
|
|
|
//cpu.add_breakpoint(0x400694); // Ram Test
|
|
|
|
|
|
|
|
//cpu.add_breakpoint(0x400170); // Failed, loops infinitely
|
|
|
|
cpu.add_breakpoint(0x4000f4); // Failed, should show the sad mac
|
|
|
|
//cpu.add_breakpoint(0x4006ae);
|
|
|
|
//cpu.add_breakpoint(0x400706);
|
|
|
|
//cpu.add_breakpoint(0x400722); // end of ram test
|
|
|
|
|
|
|
|
//cpu.add_breakpoint(0x40026c); // System Initialization
|
|
|
|
//cpu.add_breakpoint(0x402adc);
|
|
|
|
//cpu.add_breakpoint(0x40078e);
|
|
|
|
//cpu.add_breakpoint(0x40080a);
|
|
|
|
|
|
|
|
//cpu.add_breakpoint(0x400448);
|
|
|
|
//cpu.add_breakpoint(0x40040a); // InitROMCore (set up trap dispatch table)
|
|
|
|
//cpu.add_breakpoint(0x402acc); // InitMem
|
|
|
|
|
|
|
|
//cpu.add_breakpoint(0x40045c);
|
|
|
|
//cpu.add_breakpoint(0x400614); // Start of InitIO
|
|
|
|
cpu.add_breakpoint(0x40062a); // Loop in InitIO
|
|
|
|
//cpu.add_breakpoint(0x400648);
|
|
|
|
//cpu.add_breakpoint(0x40064c);
|
|
|
|
//cpu.add_breakpoint(0x4014a6); // DrvrInstall
|
|
|
|
//cpu.add_breakpoint(0x401262); // $A000 handler, which is where the rom write happens
|
|
|
|
//cpu.add_breakpoint(0x4012ec);
|
|
|
|
//cpu.add_breakpoint(0x40133a);
|
|
|
|
|
|
|
|
// Issue of writing to 0x100000 which doesn't exist
|
|
|
|
cpu.add_breakpoint(0x400d62);
|
|
|
|
|
|
|
|
cpu.add_breakpoint(0x400464); // Boot Screen
|
|
|
|
|
|
|
|
/*
|
|
|
|
use crate::devices::Addressable;
|
|
|
|
use crate::cpus::m68k::state::M68kState;
|
|
|
|
for i in 0..=65535 {
|
|
|
|
cpu.state = M68kState::new();
|
|
|
|
system.get_bus().write_beu16(0, i).unwrap();
|
|
|
|
match cpu.decode_next(&system) {
|
|
|
|
Ok(()) => { println!("TestCase {{ cpu: M68kType::MC68000, data: &[{:#06X}]\tins: Some({:?}) }},", i, cpu.decoder.instruction); },
|
|
|
|
Err(_) => { println!("TestCase {{ cpu: M68kType::MC68000, data: &[{:#06X}]\tins: None }},", i); },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
panic!("");
|
|
|
|
*/
|
|
|
|
|
2023-06-08 03:44:14 +00:00
|
|
|
system.add_interruptable_device("cpu", Device::new(cpu))?;
|
2021-12-06 23:04:08 +00:00
|
|
|
|
|
|
|
Ok(system)
|
|
|
|
}
|
|
|
|
|