mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 10:12:11 +00:00
Refactor cpu constructor and fix tests
This commit is contained in:
parent
2ca1813939
commit
ba4051bc14
20
src/cpu.rs
20
src/cpu.rs
@ -833,12 +833,22 @@ pub struct CPU {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CPU {
|
impl CPU {
|
||||||
pub fn new(cgb_mode: bool) -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
registers: match cgb_mode {
|
registers: Registers::new(),
|
||||||
true => Registers::new_cgb(),
|
cycles: Cycles(0),
|
||||||
false => Registers::new(),
|
last_op_cycles: Cycles(0),
|
||||||
},
|
exec_calls_count: 0,
|
||||||
|
is_halted: false,
|
||||||
|
ei_delay: false,
|
||||||
|
ime: true,
|
||||||
|
enable_logs: !env::var("CPU_LOG").is_err() || !env::var("CPU_LOGS").is_err(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_cgb() -> Self {
|
||||||
|
Self {
|
||||||
|
registers: Registers::new_cgb(),
|
||||||
cycles: Cycles(0),
|
cycles: Cycles(0),
|
||||||
last_op_cycles: Cycles(0),
|
last_op_cycles: Cycles(0),
|
||||||
exec_calls_count: 0,
|
exec_calls_count: 0,
|
||||||
|
@ -17,10 +17,13 @@ pub struct Emulator {
|
|||||||
impl Emulator {
|
impl Emulator {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let bus = Bus::new();
|
let bus = Bus::new();
|
||||||
let cgb_mode = bus.cgb_mode;
|
let cpu = match bus.cgb_mode {
|
||||||
|
true => CPU::new_cgb(),
|
||||||
|
false => CPU::new(),
|
||||||
|
};
|
||||||
Self {
|
Self {
|
||||||
bus,
|
bus,
|
||||||
cpu: CPU::new(cgb_mode),
|
cpu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user