mirror of
https://github.com/transistorfet/moa.git
synced 2024-11-21 19:30:52 +00:00
Fixed the basic IN/OUT instructions on Z80, and basic RETI/RETN
This commit is contained in:
parent
c97b3b8aca
commit
57f9f93cc9
@ -21,6 +21,7 @@ pub struct System {
|
||||
pub debugger: RefCell<Debugger>,
|
||||
|
||||
pub bus: Rc<RefCell<Bus>>,
|
||||
pub buses: HashMap<String, Rc<RefCell<Bus>>>,
|
||||
pub interrupt_controller: RefCell<InterruptController>,
|
||||
|
||||
pub break_signal: Option<EdgeSignal>,
|
||||
@ -37,6 +38,7 @@ impl Default for System {
|
||||
debugger: RefCell::new(Debugger::default()),
|
||||
|
||||
bus: Rc::new(RefCell::new(Bus::default())),
|
||||
buses: HashMap::new(),
|
||||
interrupt_controller: RefCell::new(InterruptController::default()),
|
||||
|
||||
break_signal: None,
|
||||
|
@ -280,12 +280,24 @@ impl Z80 {
|
||||
//},
|
||||
//Instruction::INIR => {
|
||||
//},
|
||||
//Instruction::INic(reg) => {
|
||||
//},
|
||||
Instruction::INic(reg) => {
|
||||
let b = self.get_register_value(Register::B);
|
||||
let c = self.get_register_value(Register::C);
|
||||
let value = self.get_ioport_value(b, c)?;
|
||||
|
||||
self.set_register_value(reg, value);
|
||||
self.set_numeric_flags(value as u16, Size::Byte);
|
||||
self.set_parity_flags(value);
|
||||
self.set_flag(Flags::HalfCarry, false);
|
||||
self.set_flag(Flags::AddSubtract, false);
|
||||
},
|
||||
//Instruction::INicz => {
|
||||
//},
|
||||
//Instruction::INx(u8) => {
|
||||
//},
|
||||
Instruction::INx(n) => {
|
||||
let a = self.get_register_value(Register::A);
|
||||
let value = self.get_ioport_value(a, n)?;
|
||||
self.set_register_value(Register::A, value);
|
||||
},
|
||||
Instruction::JP(addr) => {
|
||||
self.state.pc = addr;
|
||||
},
|
||||
@ -368,13 +380,18 @@ impl Z80 {
|
||||
//},
|
||||
//Instruction::OUTI => {
|
||||
//},
|
||||
//Instruction::OUTic(reg) => {
|
||||
//},
|
||||
Instruction::OUTic(reg) => {
|
||||
let b = self.get_register_value(Register::B);
|
||||
let c = self.get_register_value(Register::C);
|
||||
let value = self.get_register_value(reg);
|
||||
self.set_ioport_value(b, c, value)?;
|
||||
},
|
||||
//Instruction::OUTicz => {
|
||||
//},
|
||||
Instruction::OUTx(_port) => {
|
||||
// TODO this needs to be fixed
|
||||
//println!("OUT ({:x}), {:x} {}", port, self.state.reg[Register::A as usize], self.state.reg[Register::A as usize] as char);
|
||||
Instruction::OUTx(n) => {
|
||||
let a = self.get_register_value(Register::A);
|
||||
let value = self.get_register_value(Register::A);
|
||||
self.set_ioport_value(a, n, value)?;
|
||||
},
|
||||
Instruction::POP(regpair) => {
|
||||
let value = self.pop_word()?;
|
||||
@ -395,10 +412,12 @@ impl Z80 {
|
||||
Instruction::RET => {
|
||||
self.state.pc = self.pop_word()?;
|
||||
},
|
||||
//Instruction::RETI => {
|
||||
//},
|
||||
//Instruction::RETN => {
|
||||
//},
|
||||
Instruction::RETI => {
|
||||
self.state.pc = self.pop_word()?;
|
||||
},
|
||||
Instruction::RETN => {
|
||||
self.state.pc = self.pop_word()?;
|
||||
},
|
||||
Instruction::RETcc(cond) => {
|
||||
if self.get_current_condition(cond) {
|
||||
self.state.pc = self.pop_word()?;
|
||||
@ -728,6 +747,23 @@ impl Z80 {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_ioport_value(&mut self, upper: u8, lower: u8) -> Result<u8, Error> {
|
||||
let addr = ((upper as Address) << 8) | (lower as Address);
|
||||
if let Some(io) = self.ioport.as_mut() {
|
||||
Ok(io.read_u8(self.current_clock, addr)?)
|
||||
} else {
|
||||
Ok(0)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_ioport_value(&mut self, upper: u8, lower: u8, value: u8) -> Result<(), Error> {
|
||||
let addr = ((upper as Address) << 8) | (lower as Address);
|
||||
if let Some(io) = self.ioport.as_mut() {
|
||||
io.write_u8(self.current_clock, addr, value)?
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
fn get_register_value(&mut self, reg: Register) -> u8 {
|
||||
self.state.reg[reg as usize]
|
||||
|
@ -112,13 +112,14 @@ pub struct Z80 {
|
||||
pub decoder: Z80Decoder,
|
||||
pub debugger: Z80Debugger,
|
||||
pub port: BusPort,
|
||||
pub ioport: Option<BusPort>,
|
||||
pub reset: Signal<bool>,
|
||||
pub bus_request: Signal<bool>,
|
||||
pub current_clock: ClockTime,
|
||||
}
|
||||
|
||||
impl Z80 {
|
||||
pub fn new(cputype: Z80Type, frequency: Frequency, port: BusPort) -> Self {
|
||||
pub fn new(cputype: Z80Type, frequency: Frequency, port: BusPort, ioport: Option<BusPort>) -> Self {
|
||||
Self {
|
||||
cputype,
|
||||
frequency,
|
||||
@ -126,6 +127,7 @@ impl Z80 {
|
||||
decoder: Z80Decoder::default(),
|
||||
debugger: Z80Debugger::default(),
|
||||
port,
|
||||
ioport,
|
||||
reset: Signal::new(false),
|
||||
bus_request: Signal::new(false),
|
||||
current_clock: ClockTime::START,
|
||||
|
@ -14,7 +14,7 @@ fn init_decode_test() -> (Z80, System) {
|
||||
system.add_addressable_device(0x0000, wrap_transmutable(mem)).unwrap();
|
||||
|
||||
// Initialize the CPU and make sure it's in the expected state
|
||||
let mut cpu = Z80::new(Z80Type::Z80, Frequency::from_mhz(4), BusPort::new(0, 16, 8, system.bus.clone()));
|
||||
let mut cpu = Z80::new(Z80Type::Z80, Frequency::from_mhz(4), BusPort::new(0, 16, 8, system.bus.clone()), None);
|
||||
cpu.init().unwrap();
|
||||
|
||||
(cpu, system)
|
||||
|
@ -489,7 +489,7 @@ fn init_execute_test() -> (Z80, System) {
|
||||
system.add_addressable_device(0x0000, wrap_transmutable(mem)).unwrap();
|
||||
|
||||
// Initialize the CPU and make sure it's in the expected state
|
||||
let mut cpu = Z80::new(Z80Type::Z80, Frequency::from_mhz(4), BusPort::new(0, 16, 8, system.bus.clone()));
|
||||
let mut cpu = Z80::new(Z80Type::Z80, Frequency::from_mhz(4), BusPort::new(0, 16, 8, system.bus.clone()), None);
|
||||
cpu.init().unwrap();
|
||||
|
||||
(cpu, system)
|
||||
|
@ -82,7 +82,7 @@ pub fn build_genesis<H: Host>(host: &mut H, mut options: SegaGenesisOptions) ->
|
||||
coproc_bus.borrow_mut().insert(0x6000, coproc_register.clone());
|
||||
coproc_bus.borrow_mut().insert(0x7f11, coproc_sn_sound.clone());
|
||||
coproc_bus.borrow_mut().insert(0x8000, coproc_area);
|
||||
let mut coproc = Z80::new(Z80Type::Z80, Frequency::from_hz(3_579_545), BusPort::new(0, 16, 8, coproc_bus));
|
||||
let mut coproc = Z80::new(Z80Type::Z80, Frequency::from_hz(3_579_545), BusPort::new(0, 16, 8, coproc_bus), None);
|
||||
coproc.set_debugging(true);
|
||||
let mut reset = coproc.reset.clone();
|
||||
let mut bus_request = coproc.bus_request.clone();
|
||||
|
@ -42,7 +42,8 @@ pub fn build_trs80<H: Host>(host: &mut H, options: Trs80Options) -> Result<Syste
|
||||
let video = Model1Video::new(host)?;
|
||||
system.add_addressable_device(0x37E0 + 0x420, wrap_transmutable(video)).unwrap();
|
||||
|
||||
let cpu = Z80::new(Z80Type::Z80, options.frequency, BusPort::new(0, 16, 8, system.bus.clone()));
|
||||
// TODO the ioport needs to be hooked up
|
||||
let cpu = Z80::new(Z80Type::Z80, options.frequency, BusPort::new(0, 16, 8, system.bus.clone()), None);
|
||||
//cpu.add_breakpoint(0x0);
|
||||
//cpu.add_breakpoint(0xb55);
|
||||
//cpu.add_breakpoint(0xb76);
|
||||
|
@ -1,4 +1,4 @@
|
||||
Last run on 2023-05-13 at commit cf4e31454b417b361b70fcbf82edf6a1daf62eb8
|
||||
Last run on 2023-05-13 at commit c97b3b8aca39518b1a88a19ba236ac19c1717b25
|
||||
|
||||
00.json completed, all passed!
|
||||
01.json completed, all passed!
|
||||
@ -468,7 +468,7 @@ d7.json completed, all passed!
|
||||
d8.json completed, all passed!
|
||||
d9.json completed, all passed!
|
||||
da.json completed, all passed!
|
||||
db.json completed: 0 passed, 1000 FAILED
|
||||
db.json completed, all passed!
|
||||
dc.json completed, all passed!
|
||||
dd 09.json completed, all passed!
|
||||
dd 19.json completed, all passed!
|
||||
@ -521,68 +521,64 @@ e9.json completed, all passed!
|
||||
ea.json completed, all passed!
|
||||
eb.json completed, all passed!
|
||||
ec.json completed, all passed!
|
||||
ed 40.json completed: 0 passed, 1000 FAILED
|
||||
ed 41.json completed: 0 passed, 1000 FAILED
|
||||
ed 40.json completed, all passed!
|
||||
ed 41.json completed, all passed!
|
||||
ed 42.json completed, all passed!
|
||||
ed 43.json completed, all passed!
|
||||
ed 44.json completed, all passed!
|
||||
ed 45.json completed: 0 passed, 1000 FAILED
|
||||
ed 45.json completed, all passed!
|
||||
ed 46.json completed, all passed!
|
||||
ed 47.json completed, all passed!
|
||||
ed 48.json completed: 0 passed, 1000 FAILED
|
||||
ed 49.json completed: 0 passed, 1000 FAILED
|
||||
ed 48.json completed, all passed!
|
||||
ed 49.json completed, all passed!
|
||||
ed 4a.json completed, all passed!
|
||||
ed 4b.json completed, all passed!
|
||||
ed 4c.json completed, all passed!
|
||||
ed 4d.json completed: 0 passed, 1000 FAILED
|
||||
ed 4d.json completed, all passed!
|
||||
ed 4e.json completed, all passed!
|
||||
ed 4f.json completed, all passed!
|
||||
ed 50.json completed: 0 passed, 1000 FAILED
|
||||
ed 51.json completed: 0 passed, 1000 FAILED
|
||||
ed 50.json completed, all passed!
|
||||
ed 51.json completed, all passed!
|
||||
ed 52.json completed, all passed!
|
||||
ed 53.json completed, all passed!
|
||||
ed 54.json completed, all passed!
|
||||
ed 55.json completed: 0 passed, 1000 FAILED
|
||||
ed 55.json completed, all passed!
|
||||
ed 56.json completed, all passed!
|
||||
ed 57.json completed: 0 passed, 1000 FAILED
|
||||
ed 58.json completed: 0 passed, 1000 FAILED
|
||||
ed 59.json completed: 0 passed, 1000 FAILED
|
||||
ed 58.json completed, all passed!
|
||||
ed 59.json completed, all passed!
|
||||
ed 5a.json completed, all passed!
|
||||
ed 5b.json completed, all passed!
|
||||
ed 5c.json completed, all passed!
|
||||
ed 5d.json completed: 0 passed, 1000 FAILED
|
||||
ed 5d.json completed, all passed!
|
||||
ed 5e.json completed, all passed!
|
||||
ed 5f.json completed: 0 passed, 1000 FAILED
|
||||
ed 60.json completed: 0 passed, 1000 FAILED
|
||||
ed 61.json completed: 0 passed, 1000 FAILED
|
||||
ed 60.json completed, all passed!
|
||||
ed 61.json completed, all passed!
|
||||
ed 62.json completed, all passed!
|
||||
ed 63.json completed, all passed!
|
||||
ed 64.json completed, all passed!
|
||||
ed 65.json completed: 0 passed, 1000 FAILED
|
||||
ed 65.json completed, all passed!
|
||||
ed 66.json completed, all passed!
|
||||
ed 67.json completed: 0 passed, 1000 FAILED
|
||||
ed 68.json completed: 0 passed, 1000 FAILED
|
||||
ed 69.json completed: 0 passed, 1000 FAILED
|
||||
ed 68.json completed, all passed!
|
||||
ed 69.json completed, all passed!
|
||||
ed 6a.json completed, all passed!
|
||||
ed 6b.json completed, all passed!
|
||||
ed 6c.json completed, all passed!
|
||||
ed 6d.json completed: 0 passed, 1000 FAILED
|
||||
ed 6d.json completed, all passed!
|
||||
ed 6e.json completed, all passed!
|
||||
ed 6f.json completed: 0 passed, 1000 FAILED
|
||||
ed 70.json completed: 0 passed, 1000 FAILED
|
||||
ed 71.json completed: 0 passed, 1000 FAILED
|
||||
ed 72.json completed, all passed!
|
||||
ed 73.json completed, all passed!
|
||||
ed 74.json completed, all passed!
|
||||
ed 75.json completed: 0 passed, 1000 FAILED
|
||||
ed 75.json completed, all passed!
|
||||
ed 76.json completed, all passed!
|
||||
ed 77.json completed, all passed!
|
||||
ed 78.json completed: 0 passed, 1000 FAILED
|
||||
ed 79.json completed: 0 passed, 1000 FAILED
|
||||
ed 78.json completed, all passed!
|
||||
ed 79.json completed, all passed!
|
||||
ed 7a.json completed, all passed!
|
||||
ed 7b.json completed, all passed!
|
||||
ed 7c.json completed, all passed!
|
||||
ed 7d.json completed: 0 passed, 1000 FAILED
|
||||
ed 7d.json completed, all passed!
|
||||
ed 7e.json completed, all passed!
|
||||
ed 7f.json completed, all passed!
|
||||
ed a0.json completed, all passed!
|
||||
@ -655,5 +651,5 @@ fd fe.json completed: 0 passed, 1000 FAILED
|
||||
fe.json completed, all passed!
|
||||
ff.json completed, all passed!
|
||||
|
||||
passed: 545963, failed: 108037, total 83%
|
||||
completed in 10m 48s
|
||||
passed: 566963, failed: 83037, total 87%
|
||||
completed in 0m 32s
|
||||
|
@ -0,0 +1,655 @@
|
||||
Last run on 2023-05-13 at commit c97b3b8aca39518b1a88a19ba236ac19c1717b25
|
||||
|
||||
00.json completed, all passed!
|
||||
01.json completed, all passed!
|
||||
02.json completed, all passed!
|
||||
03.json completed, all passed!
|
||||
04.json completed, all passed!
|
||||
05.json completed, all passed!
|
||||
06.json completed, all passed!
|
||||
07.json completed, all passed!
|
||||
08.json completed, all passed!
|
||||
09.json completed, all passed!
|
||||
0a.json completed, all passed!
|
||||
0b.json completed, all passed!
|
||||
0c.json completed, all passed!
|
||||
0d.json completed, all passed!
|
||||
0e.json completed, all passed!
|
||||
0f.json completed, all passed!
|
||||
10.json completed, all passed!
|
||||
100.json completed, all passed!
|
||||
101.json completed, all passed!
|
||||
11.json completed, all passed!
|
||||
12.json completed, all passed!
|
||||
13.json completed, all passed!
|
||||
14.json completed, all passed!
|
||||
15.json completed, all passed!
|
||||
16.json completed, all passed!
|
||||
17.json completed, all passed!
|
||||
18.json completed, all passed!
|
||||
19.json completed, all passed!
|
||||
1a.json completed, all passed!
|
||||
1b.json completed, all passed!
|
||||
1c.json completed, all passed!
|
||||
1d.json completed, all passed!
|
||||
1e.json completed, all passed!
|
||||
1f.json completed, all passed!
|
||||
20.json completed, all passed!
|
||||
21.json completed, all passed!
|
||||
22.json completed: 999 passed, 1 FAILED
|
||||
23.json completed, all passed!
|
||||
24.json completed, all passed!
|
||||
25.json completed, all passed!
|
||||
26.json completed, all passed!
|
||||
27.json completed: 0 passed, 1000 FAILED
|
||||
28.json completed, all passed!
|
||||
29.json completed, all passed!
|
||||
2a.json completed, all passed!
|
||||
2b.json completed, all passed!
|
||||
2c.json completed, all passed!
|
||||
2d.json completed, all passed!
|
||||
2e.json completed, all passed!
|
||||
2f.json completed, all passed!
|
||||
30.json completed, all passed!
|
||||
31.json completed, all passed!
|
||||
32.json completed, all passed!
|
||||
33.json completed, all passed!
|
||||
34.json completed, all passed!
|
||||
35.json completed, all passed!
|
||||
36.json completed, all passed!
|
||||
37.json completed, all passed!
|
||||
38.json completed, all passed!
|
||||
39.json completed, all passed!
|
||||
3a.json completed, all passed!
|
||||
3b.json completed, all passed!
|
||||
3c.json completed, all passed!
|
||||
3d.json completed, all passed!
|
||||
3e.json completed, all passed!
|
||||
3f.json completed, all passed!
|
||||
40.json completed, all passed!
|
||||
41.json completed, all passed!
|
||||
42.json completed, all passed!
|
||||
43.json completed, all passed!
|
||||
44.json completed, all passed!
|
||||
45.json completed, all passed!
|
||||
46.json completed, all passed!
|
||||
47.json completed, all passed!
|
||||
48.json completed, all passed!
|
||||
49.json completed, all passed!
|
||||
4a.json completed, all passed!
|
||||
4b.json completed, all passed!
|
||||
4c.json completed, all passed!
|
||||
4d.json completed, all passed!
|
||||
4e.json completed, all passed!
|
||||
4f.json completed, all passed!
|
||||
50.json completed, all passed!
|
||||
51.json completed, all passed!
|
||||
52.json completed, all passed!
|
||||
53.json completed, all passed!
|
||||
54.json completed, all passed!
|
||||
55.json completed, all passed!
|
||||
56.json completed, all passed!
|
||||
57.json completed, all passed!
|
||||
58.json completed, all passed!
|
||||
59.json completed, all passed!
|
||||
5a.json completed, all passed!
|
||||
5b.json completed, all passed!
|
||||
5c.json completed, all passed!
|
||||
5d.json completed, all passed!
|
||||
5e.json completed, all passed!
|
||||
5f.json completed, all passed!
|
||||
60.json completed, all passed!
|
||||
61.json completed, all passed!
|
||||
62.json completed, all passed!
|
||||
63.json completed, all passed!
|
||||
64.json completed, all passed!
|
||||
65.json completed, all passed!
|
||||
66.json completed, all passed!
|
||||
67.json completed, all passed!
|
||||
68.json completed, all passed!
|
||||
69.json completed, all passed!
|
||||
6a.json completed, all passed!
|
||||
6b.json completed, all passed!
|
||||
6c.json completed, all passed!
|
||||
6d.json completed, all passed!
|
||||
6e.json completed, all passed!
|
||||
6f.json completed, all passed!
|
||||
70.json completed, all passed!
|
||||
71.json completed, all passed!
|
||||
72.json completed, all passed!
|
||||
73.json completed, all passed!
|
||||
74.json completed, all passed!
|
||||
75.json completed, all passed!
|
||||
76.json completed, all passed!
|
||||
77.json completed, all passed!
|
||||
78.json completed, all passed!
|
||||
79.json completed, all passed!
|
||||
7a.json completed, all passed!
|
||||
7b.json completed, all passed!
|
||||
7c.json completed, all passed!
|
||||
7d.json completed, all passed!
|
||||
7e.json completed, all passed!
|
||||
7f.json completed, all passed!
|
||||
80.json completed, all passed!
|
||||
81.json completed, all passed!
|
||||
82.json completed, all passed!
|
||||
83.json completed, all passed!
|
||||
84.json completed, all passed!
|
||||
85.json completed, all passed!
|
||||
86.json completed, all passed!
|
||||
87.json completed, all passed!
|
||||
88.json completed, all passed!
|
||||
89.json completed, all passed!
|
||||
8a.json completed, all passed!
|
||||
8b.json completed, all passed!
|
||||
8c.json completed, all passed!
|
||||
8d.json completed, all passed!
|
||||
8e.json completed, all passed!
|
||||
8f.json completed, all passed!
|
||||
90.json completed, all passed!
|
||||
91.json completed, all passed!
|
||||
92.json completed, all passed!
|
||||
93.json completed, all passed!
|
||||
94.json completed, all passed!
|
||||
95.json completed, all passed!
|
||||
96.json completed, all passed!
|
||||
97.json completed, all passed!
|
||||
98.json completed, all passed!
|
||||
99.json completed, all passed!
|
||||
9a.json completed, all passed!
|
||||
9b.json completed, all passed!
|
||||
9c.json completed, all passed!
|
||||
9d.json completed, all passed!
|
||||
9e.json completed, all passed!
|
||||
9f.json completed, all passed!
|
||||
a0.json completed, all passed!
|
||||
a1.json completed, all passed!
|
||||
a2.json completed, all passed!
|
||||
a3.json completed, all passed!
|
||||
a4.json completed, all passed!
|
||||
a5.json completed, all passed!
|
||||
a6.json completed, all passed!
|
||||
a7.json completed, all passed!
|
||||
a8.json completed, all passed!
|
||||
a9.json completed, all passed!
|
||||
aa.json completed, all passed!
|
||||
ab.json completed, all passed!
|
||||
ac.json completed, all passed!
|
||||
ad.json completed, all passed!
|
||||
ae.json completed, all passed!
|
||||
af.json completed, all passed!
|
||||
b0.json completed, all passed!
|
||||
b1.json completed, all passed!
|
||||
b2.json completed, all passed!
|
||||
b3.json completed, all passed!
|
||||
b4.json completed, all passed!
|
||||
b5.json completed, all passed!
|
||||
b6.json completed, all passed!
|
||||
b7.json completed, all passed!
|
||||
b8.json completed, all passed!
|
||||
b9.json completed, all passed!
|
||||
ba.json completed, all passed!
|
||||
bb.json completed, all passed!
|
||||
bc.json completed, all passed!
|
||||
bd.json completed, all passed!
|
||||
be.json completed, all passed!
|
||||
bf.json completed, all passed!
|
||||
c0.json completed, all passed!
|
||||
c1.json completed, all passed!
|
||||
c2.json completed, all passed!
|
||||
c3.json completed, all passed!
|
||||
c4.json completed, all passed!
|
||||
c5.json completed, all passed!
|
||||
c6.json completed, all passed!
|
||||
c7.json completed, all passed!
|
||||
c8.json completed, all passed!
|
||||
c9.json completed, all passed!
|
||||
ca.json completed, all passed!
|
||||
cb 00.json completed, all passed!
|
||||
cb 01.json completed, all passed!
|
||||
cb 02.json completed, all passed!
|
||||
cb 03.json completed, all passed!
|
||||
cb 04.json completed, all passed!
|
||||
cb 05.json completed, all passed!
|
||||
cb 06.json completed, all passed!
|
||||
cb 07.json completed, all passed!
|
||||
cb 08.json completed, all passed!
|
||||
cb 09.json completed, all passed!
|
||||
cb 0a.json completed, all passed!
|
||||
cb 0b.json completed, all passed!
|
||||
cb 0c.json completed, all passed!
|
||||
cb 0d.json completed, all passed!
|
||||
cb 0e.json completed, all passed!
|
||||
cb 0f.json completed, all passed!
|
||||
cb 10.json completed, all passed!
|
||||
cb 11.json completed, all passed!
|
||||
cb 12.json completed, all passed!
|
||||
cb 13.json completed, all passed!
|
||||
cb 14.json completed, all passed!
|
||||
cb 15.json completed, all passed!
|
||||
cb 16.json completed, all passed!
|
||||
cb 17.json completed, all passed!
|
||||
cb 18.json completed, all passed!
|
||||
cb 19.json completed, all passed!
|
||||
cb 1a.json completed, all passed!
|
||||
cb 1b.json completed, all passed!
|
||||
cb 1c.json completed, all passed!
|
||||
cb 1d.json completed, all passed!
|
||||
cb 1e.json completed, all passed!
|
||||
cb 1f.json completed, all passed!
|
||||
cb 20.json completed, all passed!
|
||||
cb 21.json completed, all passed!
|
||||
cb 22.json completed, all passed!
|
||||
cb 23.json completed, all passed!
|
||||
cb 24.json completed, all passed!
|
||||
cb 25.json completed, all passed!
|
||||
cb 26.json completed, all passed!
|
||||
cb 27.json completed, all passed!
|
||||
cb 28.json completed, all passed!
|
||||
cb 29.json completed, all passed!
|
||||
cb 2a.json completed, all passed!
|
||||
cb 2b.json completed, all passed!
|
||||
cb 2c.json completed, all passed!
|
||||
cb 2d.json completed, all passed!
|
||||
cb 2e.json completed, all passed!
|
||||
cb 2f.json completed, all passed!
|
||||
cb 38.json completed, all passed!
|
||||
cb 39.json completed, all passed!
|
||||
cb 3a.json completed, all passed!
|
||||
cb 3b.json completed, all passed!
|
||||
cb 3c.json completed, all passed!
|
||||
cb 3d.json completed, all passed!
|
||||
cb 3e.json completed, all passed!
|
||||
cb 3f.json completed, all passed!
|
||||
cb 40.json completed: 244 passed, 756 FAILED
|
||||
cb 41.json completed: 238 passed, 762 FAILED
|
||||
cb 42.json completed: 262 passed, 738 FAILED
|
||||
cb 43.json completed: 223 passed, 777 FAILED
|
||||
cb 44.json completed: 244 passed, 756 FAILED
|
||||
cb 45.json completed: 253 passed, 747 FAILED
|
||||
cb 46.json completed: 239 passed, 761 FAILED
|
||||
cb 47.json completed: 249 passed, 751 FAILED
|
||||
cb 48.json completed: 256 passed, 744 FAILED
|
||||
cb 49.json completed: 244 passed, 756 FAILED
|
||||
cb 4a.json completed: 234 passed, 766 FAILED
|
||||
cb 4b.json completed: 250 passed, 750 FAILED
|
||||
cb 4c.json completed: 252 passed, 748 FAILED
|
||||
cb 4d.json completed: 248 passed, 752 FAILED
|
||||
cb 4e.json completed: 254 passed, 746 FAILED
|
||||
cb 4f.json completed: 253 passed, 747 FAILED
|
||||
cb 50.json completed: 256 passed, 744 FAILED
|
||||
cb 51.json completed: 268 passed, 732 FAILED
|
||||
cb 52.json completed: 261 passed, 739 FAILED
|
||||
cb 53.json completed: 281 passed, 719 FAILED
|
||||
cb 54.json completed: 238 passed, 762 FAILED
|
||||
cb 55.json completed: 243 passed, 757 FAILED
|
||||
cb 56.json completed: 254 passed, 746 FAILED
|
||||
cb 57.json completed: 263 passed, 737 FAILED
|
||||
cb 58.json completed: 252 passed, 748 FAILED
|
||||
cb 59.json completed: 244 passed, 756 FAILED
|
||||
cb 5a.json completed: 254 passed, 746 FAILED
|
||||
cb 5b.json completed: 242 passed, 758 FAILED
|
||||
cb 5c.json completed: 233 passed, 767 FAILED
|
||||
cb 5d.json completed: 256 passed, 744 FAILED
|
||||
cb 5e.json completed: 256 passed, 744 FAILED
|
||||
cb 5f.json completed: 258 passed, 742 FAILED
|
||||
cb 60.json completed: 265 passed, 735 FAILED
|
||||
cb 61.json completed: 236 passed, 764 FAILED
|
||||
cb 62.json completed: 258 passed, 742 FAILED
|
||||
cb 63.json completed: 256 passed, 744 FAILED
|
||||
cb 64.json completed: 231 passed, 769 FAILED
|
||||
cb 65.json completed: 234 passed, 766 FAILED
|
||||
cb 66.json completed: 252 passed, 748 FAILED
|
||||
cb 67.json completed: 251 passed, 749 FAILED
|
||||
cb 68.json completed: 237 passed, 763 FAILED
|
||||
cb 69.json completed: 251 passed, 749 FAILED
|
||||
cb 6a.json completed: 253 passed, 747 FAILED
|
||||
cb 6b.json completed: 265 passed, 735 FAILED
|
||||
cb 6c.json completed: 236 passed, 764 FAILED
|
||||
cb 6d.json completed: 230 passed, 770 FAILED
|
||||
cb 6e.json completed: 237 passed, 763 FAILED
|
||||
cb 6f.json completed: 264 passed, 736 FAILED
|
||||
cb 70.json completed: 245 passed, 755 FAILED
|
||||
cb 71.json completed: 238 passed, 762 FAILED
|
||||
cb 72.json completed: 248 passed, 752 FAILED
|
||||
cb 73.json completed: 261 passed, 739 FAILED
|
||||
cb 74.json completed: 260 passed, 740 FAILED
|
||||
cb 75.json completed: 247 passed, 753 FAILED
|
||||
cb 76.json completed: 252 passed, 748 FAILED
|
||||
cb 77.json completed: 238 passed, 762 FAILED
|
||||
cb 78.json completed: 243 passed, 757 FAILED
|
||||
cb 79.json completed: 242 passed, 758 FAILED
|
||||
cb 7a.json completed: 262 passed, 738 FAILED
|
||||
cb 7b.json completed: 246 passed, 754 FAILED
|
||||
cb 7c.json completed: 256 passed, 744 FAILED
|
||||
cb 7d.json completed: 251 passed, 749 FAILED
|
||||
cb 7e.json completed: 258 passed, 742 FAILED
|
||||
cb 7f.json completed: 260 passed, 740 FAILED
|
||||
cb 80.json completed, all passed!
|
||||
cb 81.json completed, all passed!
|
||||
cb 82.json completed, all passed!
|
||||
cb 83.json completed, all passed!
|
||||
cb 84.json completed, all passed!
|
||||
cb 85.json completed, all passed!
|
||||
cb 86.json completed, all passed!
|
||||
cb 87.json completed, all passed!
|
||||
cb 88.json completed, all passed!
|
||||
cb 89.json completed, all passed!
|
||||
cb 8a.json completed, all passed!
|
||||
cb 8b.json completed, all passed!
|
||||
cb 8c.json completed, all passed!
|
||||
cb 8d.json completed, all passed!
|
||||
cb 8e.json completed, all passed!
|
||||
cb 8f.json completed, all passed!
|
||||
cb 90.json completed, all passed!
|
||||
cb 91.json completed, all passed!
|
||||
cb 92.json completed, all passed!
|
||||
cb 93.json completed, all passed!
|
||||
cb 94.json completed, all passed!
|
||||
cb 95.json completed, all passed!
|
||||
cb 96.json completed, all passed!
|
||||
cb 97.json completed, all passed!
|
||||
cb 98.json completed, all passed!
|
||||
cb 99.json completed, all passed!
|
||||
cb 9a.json completed, all passed!
|
||||
cb 9b.json completed, all passed!
|
||||
cb 9c.json completed, all passed!
|
||||
cb 9d.json completed, all passed!
|
||||
cb 9e.json completed, all passed!
|
||||
cb 9f.json completed, all passed!
|
||||
cb a0.json completed, all passed!
|
||||
cb a1.json completed, all passed!
|
||||
cb a2.json completed, all passed!
|
||||
cb a3.json completed, all passed!
|
||||
cb a4.json completed, all passed!
|
||||
cb a5.json completed, all passed!
|
||||
cb a6.json completed, all passed!
|
||||
cb a7.json completed, all passed!
|
||||
cb a8.json completed, all passed!
|
||||
cb a9.json completed, all passed!
|
||||
cb aa.json completed, all passed!
|
||||
cb ab.json completed, all passed!
|
||||
cb ac.json completed, all passed!
|
||||
cb ad.json completed, all passed!
|
||||
cb ae.json completed, all passed!
|
||||
cb af.json completed, all passed!
|
||||
cb b0.json completed, all passed!
|
||||
cb b1.json completed, all passed!
|
||||
cb b2.json completed, all passed!
|
||||
cb b3.json completed, all passed!
|
||||
cb b4.json completed, all passed!
|
||||
cb b5.json completed, all passed!
|
||||
cb b6.json completed, all passed!
|
||||
cb b7.json completed, all passed!
|
||||
cb b8.json completed, all passed!
|
||||
cb b9.json completed, all passed!
|
||||
cb ba.json completed, all passed!
|
||||
cb bb.json completed, all passed!
|
||||
cb bc.json completed, all passed!
|
||||
cb bd.json completed, all passed!
|
||||
cb be.json completed, all passed!
|
||||
cb bf.json completed, all passed!
|
||||
cb c0.json completed, all passed!
|
||||
cb c1.json completed, all passed!
|
||||
cb c2.json completed, all passed!
|
||||
cb c3.json completed, all passed!
|
||||
cb c4.json completed, all passed!
|
||||
cb c5.json completed, all passed!
|
||||
cb c6.json completed, all passed!
|
||||
cb c7.json completed, all passed!
|
||||
cb c8.json completed, all passed!
|
||||
cb c9.json completed, all passed!
|
||||
cb ca.json completed, all passed!
|
||||
cb cb.json completed, all passed!
|
||||
cb cc.json completed, all passed!
|
||||
cb cd.json completed, all passed!
|
||||
cb ce.json completed, all passed!
|
||||
cb cf.json completed, all passed!
|
||||
cb d0.json completed, all passed!
|
||||
cb d1.json completed, all passed!
|
||||
cb d2.json completed, all passed!
|
||||
cb d3.json completed, all passed!
|
||||
cb d4.json completed, all passed!
|
||||
cb d5.json completed, all passed!
|
||||
cb d6.json completed, all passed!
|
||||
cb d7.json completed, all passed!
|
||||
cb d8.json completed, all passed!
|
||||
cb d9.json completed, all passed!
|
||||
cb da.json completed, all passed!
|
||||
cb db.json completed, all passed!
|
||||
cb dc.json completed, all passed!
|
||||
cb dd.json completed, all passed!
|
||||
cb de.json completed, all passed!
|
||||
cb df.json completed, all passed!
|
||||
cb e0.json completed, all passed!
|
||||
cb e1.json completed, all passed!
|
||||
cb e2.json completed, all passed!
|
||||
cb e3.json completed, all passed!
|
||||
cb e4.json completed, all passed!
|
||||
cb e5.json completed, all passed!
|
||||
cb e6.json completed, all passed!
|
||||
cb e7.json completed, all passed!
|
||||
cb e8.json completed, all passed!
|
||||
cb e9.json completed, all passed!
|
||||
cb ea.json completed, all passed!
|
||||
cb eb.json completed, all passed!
|
||||
cb ec.json completed, all passed!
|
||||
cb ed.json completed, all passed!
|
||||
cb ee.json completed, all passed!
|
||||
cb ef.json completed, all passed!
|
||||
cb f0.json completed, all passed!
|
||||
cb f1.json completed, all passed!
|
||||
cb f2.json completed, all passed!
|
||||
cb f3.json completed, all passed!
|
||||
cb f4.json completed, all passed!
|
||||
cb f5.json completed, all passed!
|
||||
cb f6.json completed, all passed!
|
||||
cb f7.json completed, all passed!
|
||||
cb f8.json completed, all passed!
|
||||
cb f9.json completed, all passed!
|
||||
cb fa.json completed, all passed!
|
||||
cb fb.json completed, all passed!
|
||||
cb fc.json completed, all passed!
|
||||
cb fd.json completed, all passed!
|
||||
cb fe.json completed, all passed!
|
||||
cb ff.json completed, all passed!
|
||||
cc.json completed, all passed!
|
||||
cd.json completed, all passed!
|
||||
ce.json completed, all passed!
|
||||
cf.json completed, all passed!
|
||||
d0.json completed, all passed!
|
||||
d1.json completed, all passed!
|
||||
d2.json completed, all passed!
|
||||
d3.json completed, all passed!
|
||||
d4.json completed, all passed!
|
||||
d5.json completed, all passed!
|
||||
d6.json completed, all passed!
|
||||
d7.json completed, all passed!
|
||||
d8.json completed, all passed!
|
||||
d9.json completed, all passed!
|
||||
da.json completed, all passed!
|
||||
db.json completed, all passed!
|
||||
dc.json completed, all passed!
|
||||
dd 09.json completed, all passed!
|
||||
dd 19.json completed, all passed!
|
||||
dd 29.json completed, all passed!
|
||||
dd 36.json completed, all passed!
|
||||
dd 39.json completed, all passed!
|
||||
dd 46.json completed, all passed!
|
||||
dd 4e.json completed, all passed!
|
||||
dd 56.json completed, all passed!
|
||||
dd 5e.json completed, all passed!
|
||||
dd 66.json completed, all passed!
|
||||
dd 6e.json completed, all passed!
|
||||
dd 70.json completed, all passed!
|
||||
dd 71.json completed, all passed!
|
||||
dd 72.json completed, all passed!
|
||||
dd 73.json completed, all passed!
|
||||
dd 74.json completed, all passed!
|
||||
dd 75.json completed, all passed!
|
||||
dd 77.json completed, all passed!
|
||||
dd 7e.json completed, all passed!
|
||||
dd 8e.json completed, all passed!
|
||||
dd 9e.json completed, all passed!
|
||||
dd ae.json completed, all passed!
|
||||
dd b6.json completed, all passed!
|
||||
dd be.json completed, all passed!
|
||||
dd c6.json completed: 0 passed, 1000 FAILED
|
||||
dd ce.json completed: 0 passed, 1000 FAILED
|
||||
dd d6.json completed: 0 passed, 1000 FAILED
|
||||
dd de.json completed: 0 passed, 1000 FAILED
|
||||
dd e1.json completed, all passed!
|
||||
dd e3.json completed, all passed!
|
||||
dd e5.json completed, all passed!
|
||||
dd e6.json completed: 0 passed, 1000 FAILED
|
||||
dd e9.json completed, all passed!
|
||||
dd ee.json completed: 0 passed, 1000 FAILED
|
||||
dd f9.json completed, all passed!
|
||||
dd fe.json completed: 0 passed, 1000 FAILED
|
||||
de.json completed, all passed!
|
||||
df.json completed, all passed!
|
||||
e0.json completed, all passed!
|
||||
e1.json completed, all passed!
|
||||
e2.json completed, all passed!
|
||||
e3.json completed, all passed!
|
||||
e4.json completed, all passed!
|
||||
e5.json completed, all passed!
|
||||
e6.json completed, all passed!
|
||||
e7.json completed, all passed!
|
||||
e8.json completed, all passed!
|
||||
e9.json completed, all passed!
|
||||
ea.json completed, all passed!
|
||||
eb.json completed, all passed!
|
||||
ec.json completed, all passed!
|
||||
ed 40.json completed, all passed!
|
||||
ed 41.json completed, all passed!
|
||||
ed 42.json completed, all passed!
|
||||
ed 43.json completed, all passed!
|
||||
ed 44.json completed, all passed!
|
||||
ed 45.json completed, all passed!
|
||||
ed 46.json completed, all passed!
|
||||
ed 47.json completed, all passed!
|
||||
ed 48.json completed, all passed!
|
||||
ed 49.json completed, all passed!
|
||||
ed 4a.json completed, all passed!
|
||||
ed 4b.json completed, all passed!
|
||||
ed 4c.json completed, all passed!
|
||||
ed 4d.json completed, all passed!
|
||||
ed 4e.json completed, all passed!
|
||||
ed 4f.json completed, all passed!
|
||||
ed 50.json completed, all passed!
|
||||
ed 51.json completed, all passed!
|
||||
ed 52.json completed, all passed!
|
||||
ed 53.json completed, all passed!
|
||||
ed 54.json completed, all passed!
|
||||
ed 55.json completed, all passed!
|
||||
ed 56.json completed, all passed!
|
||||
ed 57.json completed: 0 passed, 1000 FAILED
|
||||
ed 58.json completed, all passed!
|
||||
ed 59.json completed, all passed!
|
||||
ed 5a.json completed, all passed!
|
||||
ed 5b.json completed, all passed!
|
||||
ed 5c.json completed, all passed!
|
||||
ed 5d.json completed, all passed!
|
||||
ed 5e.json completed, all passed!
|
||||
ed 5f.json completed: 0 passed, 1000 FAILED
|
||||
ed 60.json completed, all passed!
|
||||
ed 61.json completed, all passed!
|
||||
ed 62.json completed, all passed!
|
||||
ed 64.json completed, all passed!
|
||||
ed 65.json completed, all passed!
|
||||
ed 66.json completed, all passed!
|
||||
ed 67.json completed: 0 passed, 1000 FAILED
|
||||
ed 68.json completed, all passed!
|
||||
ed 69.json completed, all passed!
|
||||
ed 6a.json completed, all passed!
|
||||
ed 6c.json completed, all passed!
|
||||
ed 6d.json completed, all passed!
|
||||
ed 6e.json completed, all passed!
|
||||
ed 6f.json completed: 0 passed, 1000 FAILED
|
||||
ed 72.json completed, all passed!
|
||||
ed 73.json completed, all passed!
|
||||
ed 74.json completed, all passed!
|
||||
ed 75.json completed, all passed!
|
||||
ed 76.json completed, all passed!
|
||||
ed 77.json completed, all passed!
|
||||
ed 78.json completed, all passed!
|
||||
ed 79.json completed, all passed!
|
||||
ed 7a.json completed, all passed!
|
||||
ed 7b.json completed, all passed!
|
||||
ed 7c.json completed, all passed!
|
||||
ed 7d.json completed, all passed!
|
||||
ed 7e.json completed, all passed!
|
||||
ed 7f.json completed, all passed!
|
||||
ed a0.json completed, all passed!
|
||||
ed a1.json completed: 0 passed, 1000 FAILED
|
||||
ed a2.json completed: 0 passed, 1000 FAILED
|
||||
ed a3.json completed: 0 passed, 1000 FAILED
|
||||
ed a8.json completed, all passed!
|
||||
ed a9.json completed: 0 passed, 1000 FAILED
|
||||
ed aa.json completed: 0 passed, 1000 FAILED
|
||||
ed ab.json completed: 0 passed, 1000 FAILED
|
||||
ed b0.json completed, all passed!
|
||||
ed b1.json completed: 0 passed, 1000 FAILED
|
||||
ed b2.json completed: 0 passed, 1000 FAILED
|
||||
ed b3.json completed: 0 passed, 1000 FAILED
|
||||
ed b8.json completed, all passed!
|
||||
ed b9.json completed: 0 passed, 1000 FAILED
|
||||
ed ba.json completed: 0 passed, 1000 FAILED
|
||||
ed bb.json completed: 0 passed, 1000 FAILED
|
||||
ee.json completed, all passed!
|
||||
ef.json completed, all passed!
|
||||
f0.json completed, all passed!
|
||||
f1.json completed, all passed!
|
||||
f2.json completed, all passed!
|
||||
f3.json completed, all passed!
|
||||
f4.json completed, all passed!
|
||||
f5.json completed, all passed!
|
||||
f6.json completed, all passed!
|
||||
f7.json completed, all passed!
|
||||
f8.json completed, all passed!
|
||||
f9.json completed, all passed!
|
||||
fa.json completed, all passed!
|
||||
fb.json completed, all passed!
|
||||
fc.json completed, all passed!
|
||||
fd 09.json completed: 0 passed, 1000 FAILED
|
||||
fd 19.json completed: 0 passed, 1000 FAILED
|
||||
fd 29.json completed: 0 passed, 1000 FAILED
|
||||
fd 36.json completed, all passed!
|
||||
fd 39.json completed: 0 passed, 1000 FAILED
|
||||
fd 46.json completed, all passed!
|
||||
fd 4e.json completed, all passed!
|
||||
fd 56.json completed, all passed!
|
||||
fd 5e.json completed, all passed!
|
||||
fd 66.json completed, all passed!
|
||||
fd 6e.json completed, all passed!
|
||||
fd 70.json completed, all passed!
|
||||
fd 71.json completed, all passed!
|
||||
fd 72.json completed, all passed!
|
||||
fd 73.json completed, all passed!
|
||||
fd 74.json completed, all passed!
|
||||
fd 75.json completed, all passed!
|
||||
fd 77.json completed, all passed!
|
||||
fd 7e.json completed, all passed!
|
||||
fd 8e.json completed, all passed!
|
||||
fd 9e.json completed, all passed!
|
||||
fd ae.json completed, all passed!
|
||||
fd b6.json completed, all passed!
|
||||
fd be.json completed, all passed!
|
||||
fd c6.json completed: 0 passed, 1000 FAILED
|
||||
fd ce.json completed: 0 passed, 1000 FAILED
|
||||
fd d6.json completed: 0 passed, 1000 FAILED
|
||||
fd de.json completed: 0 passed, 1000 FAILED
|
||||
fd e1.json completed, all passed!
|
||||
fd e3.json completed: 999 passed, 1 FAILED
|
||||
fd e5.json completed, all passed!
|
||||
fd e6.json completed: 0 passed, 1000 FAILED
|
||||
fd e9.json completed, all passed!
|
||||
fd ee.json completed: 0 passed, 1000 FAILED
|
||||
fd f9.json completed, all passed!
|
||||
fd fe.json completed: 0 passed, 1000 FAILED
|
||||
fe.json completed, all passed!
|
||||
ff.json completed, all passed!
|
||||
|
||||
passed: 566963, failed: 83037, total 87%
|
||||
completed in 0m 33s
|
@ -1,6 +1,8 @@
|
||||
|
||||
const DEFAULT_RAD_TESTS: &str = "tests/jsmoo/misc/tests/GeneratedTests/z80/v1/";
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::cell::RefCell;
|
||||
use std::io::prelude::*;
|
||||
use std::fmt::{Debug, UpperHex};
|
||||
use std::path::PathBuf;
|
||||
@ -11,7 +13,7 @@ use clap::{Parser, ArgEnum};
|
||||
use flate2::read::GzDecoder;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
use moa_core::{System, Error, MemoryBlock, BusPort, Frequency, Address, Addressable, Steppable, wrap_transmutable};
|
||||
use moa_core::{System, Error, MemoryBlock, Bus, BusPort, Frequency, Address, Addressable, Steppable, wrap_transmutable};
|
||||
|
||||
use moa_z80::{Z80, Z80Type};
|
||||
use moa_z80::state::Flags;
|
||||
@ -87,6 +89,13 @@ struct TestState {
|
||||
ram: Vec<(u16, u8)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct TestPort {
|
||||
addr: u16,
|
||||
value: u8,
|
||||
atype: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct TestCase {
|
||||
name: String,
|
||||
@ -94,6 +103,8 @@ struct TestCase {
|
||||
initial_state: TestState,
|
||||
#[serde(rename(deserialize = "final"))]
|
||||
final_state: TestState,
|
||||
#[serde(default)]
|
||||
ports: Vec<TestPort>,
|
||||
}
|
||||
|
||||
impl TestState {
|
||||
@ -123,25 +134,36 @@ impl TestCase {
|
||||
self.initial_state.dump();
|
||||
println!("final:");
|
||||
self.final_state.dump();
|
||||
|
||||
println!("ports: ");
|
||||
for port in self.ports.iter() {
|
||||
println!("{:04x} {:02x} {}", port.addr, port.value, port.atype);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn init_execute_test(cputype: Z80Type, state: &TestState) -> Result<(Z80, System), Error> {
|
||||
fn init_execute_test(cputype: Z80Type, state: &TestState, ports: &[TestPort]) -> Result<(Z80, System, Rc<RefCell<Bus>>), Error> {
|
||||
let mut system = System::default();
|
||||
|
||||
// Insert basic initialization
|
||||
let data = vec![0; 0x01000000];
|
||||
let mem = MemoryBlock::new(data);
|
||||
let mem = MemoryBlock::new(vec![0; 0x1_0000]);
|
||||
system.add_addressable_device(0x00000000, wrap_transmutable(mem)).unwrap();
|
||||
|
||||
// Set up IOREQ as memory space
|
||||
let io_ram = wrap_transmutable(MemoryBlock::new(vec![0; 0x10000]));
|
||||
let io_bus = Rc::new(RefCell::new(Bus::default()));
|
||||
io_bus.borrow_mut().set_ignore_unmapped(true);
|
||||
io_bus.borrow_mut().insert(0x0000, io_ram.clone());
|
||||
|
||||
let port = BusPort::new(0, 16, 8, system.bus.clone());
|
||||
let mut cpu = Z80::new(cputype, Frequency::from_mhz(10), port);
|
||||
let ioport = BusPort::new(0, 16, 8, io_bus.clone());
|
||||
let mut cpu = Z80::new(cputype, Frequency::from_mhz(10), port, Some(ioport));
|
||||
cpu.state.status = Status::Running;
|
||||
|
||||
load_state(&mut cpu, &mut system, state)?;
|
||||
load_state(&mut cpu, &mut system, io_bus.clone(), state, ports)?;
|
||||
|
||||
Ok((cpu, system))
|
||||
Ok((cpu, system, io_bus))
|
||||
}
|
||||
|
||||
fn assert_value<T>(actual: T, expected: T, message: &str) -> Result<(), Error>
|
||||
@ -155,7 +177,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
fn load_state(cpu: &mut Z80, system: &mut System, initial: &TestState) -> Result<(), Error> {
|
||||
fn load_state(cpu: &mut Z80, system: &mut System, io_bus: Rc<RefCell<Bus>>, initial: &TestState, ports: &[TestPort]) -> Result<(), Error> {
|
||||
cpu.state.reg[0] = initial.b;
|
||||
cpu.state.reg[1] = initial.c;
|
||||
cpu.state.reg[2] = initial.d;
|
||||
@ -183,12 +205,17 @@ fn load_state(cpu: &mut Z80, system: &mut System, initial: &TestState) -> Result
|
||||
system.get_bus().write_u8(system.clock, *addr as u64, *byte)?;
|
||||
}
|
||||
|
||||
// Load data bytes into io space
|
||||
for port in ports.iter() {
|
||||
io_bus.borrow_mut().write_u8(system.clock, port.addr as u64, port.value)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const IGNORE_FLAG_MASK: u8 = Flags::F3 as u8 | Flags::F5 as u8;
|
||||
|
||||
fn assert_state(cpu: &Z80, system: &System, expected: &TestState, check_extra_flags: bool) -> Result<(), Error> {
|
||||
fn assert_state(cpu: &Z80, system: &System, io_bus: Rc<RefCell<Bus>>, expected: &TestState, check_extra_flags: bool, ports: &[TestPort]) -> Result<(), Error> {
|
||||
assert_value(cpu.state.reg[0], expected.b, "b")?;
|
||||
assert_value(cpu.state.reg[1], expected.c, "c")?;
|
||||
assert_value(cpu.state.reg[2], expected.d, "d")?;
|
||||
@ -223,22 +250,30 @@ fn assert_state(cpu: &Z80, system: &System, expected: &TestState, check_extra_fl
|
||||
assert_value(actual, *byte, &format!("ram at {:x}", addr))?;
|
||||
}
|
||||
|
||||
// Load data bytes into io space
|
||||
for port in ports.iter() {
|
||||
if port.atype == "w" {
|
||||
let actual = io_bus.borrow_mut().read_u8(system.clock, port.addr as u64)?;
|
||||
assert_value(actual, port.value, &format!("port value at {:x}", port.addr))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn step_cpu_and_assert(cpu: &mut Z80, system: &System, case: &TestCase, check_extra_flags: bool) -> Result<(), Error> {
|
||||
fn step_cpu_and_assert(cpu: &mut Z80, system: &System, io_bus: Rc<RefCell<Bus>>, case: &TestCase, check_extra_flags: bool) -> Result<(), Error> {
|
||||
let _clock_elapsed = cpu.step(&system)?;
|
||||
|
||||
assert_state(&cpu, &system, &case.final_state, check_extra_flags)?;
|
||||
assert_state(&cpu, &system, io_bus, &case.final_state, check_extra_flags, &case.ports)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_test(case: &TestCase, args: &Args) -> Result<(), Error> {
|
||||
let (mut cpu, system) = init_execute_test(Z80Type::Z80, &case.initial_state).unwrap();
|
||||
let (mut cpu, system, io_bus) = init_execute_test(Z80Type::Z80, &case.initial_state, &case.ports).unwrap();
|
||||
let mut initial_cpu = cpu.clone();
|
||||
|
||||
let result = step_cpu_and_assert(&mut cpu, &system, case, args.check_extra_flags);
|
||||
let result = step_cpu_and_assert(&mut cpu, &system, io_bus, case, args.check_extra_flags);
|
||||
|
||||
match result {
|
||||
Ok(()) => Ok(()),
|
||||
|
7
todo.txt
7
todo.txt
@ -1,4 +1,11 @@
|
||||
|
||||
* I like making address adapters like this (below)
|
||||
* you could have busport take a closure or something which translates the address, and returns an error that will be passed up if it occurs
|
||||
in order to implement the correct behaviour for address exceptions in 68k, transparently
|
||||
|
||||
* should you make a means of storing different kinds of buses?
|
||||
* should you make buses hide their RcRefCell?
|
||||
|
||||
* address repeater on ym2612 doesn't seem to work the same, when it's on the 68000 device. The Z80 device doesn't have an affect, but maybe it's not being used
|
||||
* sound doesn't work on a lot of games... is it a problem with the Z80 accessing the YM2612, or the lack of YM timers? or something else?
|
||||
* make the ym generate audio in sync so the DAC timings can be more accurate
|
||||
|
Loading…
Reference in New Issue
Block a user