feat: implement ability to boot straigt to cartridge

This commit is contained in:
2020-12-23 19:39:37 -06:00
parent 1502cc3ec2
commit 2a234f4d14
6 changed files with 212 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
use super::bus::Bus;
use super::instruction::Instruction;
#[derive(Debug, Copy, Clone, Default)]
#[derive(Debug, Clone, Default)]
pub struct Cpu {
bus: Bus,
reg: Registers,
@@ -15,6 +15,25 @@ impl Cpu {
Default::default()
}
pub fn new_without_boot() -> Self {
Self {
bus: Bus::without_boot(),
reg: Registers {
a: 0x01,
b: 0x00,
c: 0x13,
d: 0x00,
e: 0xD8,
h: 0x01,
l: 0x4D,
sp: 0xFFFE,
pc: 0x0100,
},
flags: 0xb0.into(),
..Default::default()
}
}
pub fn ime(&self) -> bool {
self.ime
}
@@ -26,6 +45,10 @@ impl Cpu {
pub fn inc_pc(&mut self) {
self.reg.pc += 1;
}
pub fn load_cartridge(&mut self, path: &str) {
self.bus.load_cartridge(path);
}
}
impl Cpu {