From 49a45d48cb7e5813390337adf7ed2f9ce4cbc16d Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 18 Jan 2021 02:29:35 -0600 Subject: [PATCH] fix: improve appearance of debug logs --- src/instruction.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/instruction.rs b/src/instruction.rs index c33a464..fcb2399 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -82,7 +82,7 @@ pub enum LDTarget { ByteAtAddressWithOffset(u8), } -#[derive(Debug, Copy, Clone)] +#[derive(Copy, Clone)] pub enum InstrRegisterPair { AF, BC, @@ -2044,7 +2044,7 @@ impl std::fmt::Debug for LDTarget { LDTarget::ImmediateByte(byte) => write!(f, "{:#04X}", byte), LDTarget::RegisterPair(pair) => write!(f, "{:?}", pair), 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-"), + } + } +}