mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-10 12:11:32 +00:00
CPU Registers for CGB mode
This commit is contained in:
parent
abac2b3bf3
commit
eb0f61aebd
@ -36,6 +36,7 @@ pub struct Bus {
|
||||
pub timer: Timer,
|
||||
pub sound: Sound,
|
||||
pub interrupts: Interrupts,
|
||||
pub cgb_mode: bool,
|
||||
}
|
||||
|
||||
impl Bus {
|
||||
@ -67,6 +68,7 @@ impl Bus {
|
||||
timer: Timer::new(),
|
||||
sound: Sound::new(),
|
||||
interrupts: Interrupts::new(),
|
||||
cgb_mode,
|
||||
};
|
||||
|
||||
// Hardware registers after the bootrom
|
||||
|
22
src/cpu.rs
22
src/cpu.rs
@ -87,6 +87,21 @@ impl Registers {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_cgb() -> Self {
|
||||
Self {
|
||||
a: 0x11,
|
||||
f: 0x00,
|
||||
b: 0x00,
|
||||
c: 0x00,
|
||||
d: 0xFF,
|
||||
e: 0x56,
|
||||
h: 0x00,
|
||||
l: 0x0D,
|
||||
sp: 0xFFFE,
|
||||
pc: 0x0100,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self, register: Register) -> u16 {
|
||||
match register {
|
||||
Register::A => self.a as u16,
|
||||
@ -818,9 +833,12 @@ pub struct CPU {
|
||||
}
|
||||
|
||||
impl CPU {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(cgb_mode: bool) -> Self {
|
||||
Self {
|
||||
registers: Registers::new(),
|
||||
registers: match cgb_mode {
|
||||
true => Registers::new_cgb(),
|
||||
false => Registers::new(),
|
||||
},
|
||||
cycles: Cycles(0),
|
||||
last_op_cycles: Cycles(0),
|
||||
exec_calls_count: 0,
|
||||
|
@ -16,9 +16,11 @@ pub struct Emulator {
|
||||
|
||||
impl Emulator {
|
||||
pub fn new() -> Self {
|
||||
let bus = Bus::new();
|
||||
let cgb_mode = bus.cgb_mode;
|
||||
Self {
|
||||
bus: Bus::new(),
|
||||
cpu: CPU::new(),
|
||||
bus,
|
||||
cpu: CPU::new(cgb_mode),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user