chore: remove Emulator struct

This commit is contained in:
2021-11-21 05:27:04 -04:00
parent 939c25ce1a
commit 2405fd027f
4 changed files with 80 additions and 129 deletions

View File

@@ -5,7 +5,7 @@ use crate::Cycle;
use bitfield::bitfield;
use std::fmt::{Display, Formatter, Result as FmtResult};
#[derive(Debug, Default)]
#[derive(Debug)]
pub struct Cpu {
pub(crate) bus: Bus,
reg: Registers,
@@ -15,29 +15,13 @@ pub struct Cpu {
}
impl Cpu {
#[allow(dead_code)]
pub(crate) fn without_boot() -> Self {
Self {
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(crate) fn with_boot(rom: [u8; BOOT_SIZE]) -> Self {
pub(crate) fn new(rom: [u8; BOOT_SIZE]) -> Self {
Self {
bus: Bus::with_boot(rom),
..Default::default()
reg: Default::default(),
flags: Default::default(),
ime: Default::default(),
state: Default::default(),
}
}
@@ -69,6 +53,12 @@ impl Cpu {
}
}
impl Default for Cpu {
fn default() -> Self {
Cpu::new(*include_bytes!("../bin/bootix_dmg.bin"))
}
}
impl Cpu {
/// Fetch an [Instruction] from the memory bus
/// (4 cycles)