mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-23 02:01:32 +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 {
|
||||
pub fn new(cgb_mode: bool) -> Self {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
registers: match cgb_mode {
|
||||
true => Registers::new_cgb(),
|
||||
false => Registers::new(),
|
||||
},
|
||||
registers: Registers::new(),
|
||||
cycles: Cycles(0),
|
||||
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),
|
||||
last_op_cycles: Cycles(0),
|
||||
exec_calls_count: 0,
|
||||
|
@ -17,10 +17,13 @@ pub struct Emulator {
|
||||
impl Emulator {
|
||||
pub fn new() -> Self {
|
||||
let bus = Bus::new();
|
||||
let cgb_mode = bus.cgb_mode;
|
||||
let cpu = match bus.cgb_mode {
|
||||
true => CPU::new_cgb(),
|
||||
false => CPU::new(),
|
||||
};
|
||||
Self {
|
||||
bus,
|
||||
cpu: CPU::new(cgb_mode),
|
||||
cpu,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user