fix: improve appearance of debug logs

This commit is contained in:
Rekai Nyangadzayi Musuka 2021-01-18 02:29:35 -06:00
parent 9203b61533
commit 49a45d48cb
1 changed files with 17 additions and 2 deletions

View File

@ -82,7 +82,7 @@ pub enum LDTarget {
ByteAtAddressWithOffset(u8), ByteAtAddressWithOffset(u8),
} }
#[derive(Debug, Copy, Clone)] #[derive(Copy, Clone)]
pub enum InstrRegisterPair { pub enum InstrRegisterPair {
AF, AF,
BC, BC,
@ -2044,7 +2044,7 @@ impl std::fmt::Debug for LDTarget {
LDTarget::ImmediateByte(byte) => write!(f, "{:#04X}", byte), LDTarget::ImmediateByte(byte) => write!(f, "{:#04X}", byte),
LDTarget::RegisterPair(pair) => write!(f, "{:?}", pair), LDTarget::RegisterPair(pair) => write!(f, "{:?}", pair),
LDTarget::ByteAtAddressWithOffset(byte) => { LDTarget::ByteAtAddressWithOffset(byte) => {
write!(f, "[0xFF00 + {:#04X}, {:#06X}]", byte, 0xFF00 + byte as u16) write!(f, "[0xFF00 + {:#04X}]", byte)
} }
} }
} }
@ -2061,3 +2061,18 @@ impl std::fmt::Debug for MATHTarget {
} }
} }
} }
impl std::fmt::Debug for InstrRegisterPair {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match *self {
InstrRegisterPair::AF => f.write_str("AF"),
InstrRegisterPair::BC => f.write_str("BC"),
InstrRegisterPair::DE => f.write_str("DE"),
InstrRegisterPair::HL => f.write_str("HL"),
InstrRegisterPair::SP => f.write_str("SP"),
InstrRegisterPair::PC => f.write_str("PC"),
InstrRegisterPair::IncrementHL => f.write_str("HL+"),
InstrRegisterPair::DecrementHL => f.write_str("HL-"),
}
}
}