mirror of
https://github.com/FranLMSP/rmg-001.git
synced 2024-11-13 21:51:33 +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 timer: Timer,
|
||||||
pub sound: Sound,
|
pub sound: Sound,
|
||||||
pub interrupts: Interrupts,
|
pub interrupts: Interrupts,
|
||||||
|
pub cgb_mode: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bus {
|
impl Bus {
|
||||||
@ -67,6 +68,7 @@ impl Bus {
|
|||||||
timer: Timer::new(),
|
timer: Timer::new(),
|
||||||
sound: Sound::new(),
|
sound: Sound::new(),
|
||||||
interrupts: Interrupts::new(),
|
interrupts: Interrupts::new(),
|
||||||
|
cgb_mode,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hardware registers after the bootrom
|
// 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 {
|
pub fn get(&self, register: Register) -> u16 {
|
||||||
match register {
|
match register {
|
||||||
Register::A => self.a as u16,
|
Register::A => self.a as u16,
|
||||||
@ -818,9 +833,12 @@ pub struct CPU {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CPU {
|
impl CPU {
|
||||||
pub fn new() -> Self {
|
pub fn new(cgb_mode: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
registers: Registers::new(),
|
registers: match cgb_mode {
|
||||||
|
true => Registers::new_cgb(),
|
||||||
|
false => Registers::new(),
|
||||||
|
},
|
||||||
cycles: Cycles(0),
|
cycles: Cycles(0),
|
||||||
last_op_cycles: Cycles(0),
|
last_op_cycles: Cycles(0),
|
||||||
exec_calls_count: 0,
|
exec_calls_count: 0,
|
||||||
|
@ -16,9 +16,11 @@ pub struct Emulator {
|
|||||||
|
|
||||||
impl Emulator {
|
impl Emulator {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
let bus = Bus::new();
|
||||||
|
let cgb_mode = bus.cgb_mode;
|
||||||
Self {
|
Self {
|
||||||
bus: Bus::new(),
|
bus,
|
||||||
cpu: CPU::new(),
|
cpu: CPU::new(cgb_mode),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user