chore: improve debug logs

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-01-18 02:47:41 -06:00
parent 49a45d48cb
commit 207bcfea30
1 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,5 @@
use super::cpu::{Cpu, Flags, Register, RegisterPair}; use super::cpu::{Cpu, Flags, Register, RegisterPair};
use std::convert::TryFrom; use std::{convert::TryFrom, fmt::Debug};
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub enum Instruction { pub enum Instruction {
@ -55,7 +55,7 @@ pub enum JPTarget {
ImmediateWord(u16), ImmediateWord(u16),
} }
#[derive(Debug, Copy, Clone)] #[derive(Copy, Clone)]
pub enum Registers { pub enum Registers {
Byte(InstrRegister), Byte(InstrRegister),
Word(RegisterPair), Word(RegisterPair),
@ -2076,3 +2076,12 @@ impl std::fmt::Debug for InstrRegisterPair {
} }
} }
} }
impl std::fmt::Debug for Registers {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
Registers::Byte(reg) => write!(f, "{:?}", reg),
Registers::Word(pair) => write!(f, "{:?}", pair),
}
}
}