Include interrupt information in the disassembler output.

Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2020-11-12 16:22:44 +00:00
parent f7da03d46b
commit b8a2db96f4
4 changed files with 38 additions and 5 deletions

View File

@@ -31,6 +31,9 @@ std::string EightBit::GameBoy::Disassembler::state(LR35902& cpu) {
auto h = cpu.H();
auto l = cpu.L();
const auto maskedInterrupts = cpu.maskedInterrupts();
const auto ime = cpu.IME();
std::ostringstream output;
output
@@ -42,6 +45,12 @@ std::string EightBit::GameBoy::Disassembler::state(LR35902& cpu) {
<< " " << "D=" << hex(d) << " " << "E=" << hex(e)
<< " " << "H=" << hex(h) << " " << "L=" << hex(l);
// Interrupt handling
output << " IME:" << (ime ? "I" : "-");
output << " IE:" << interrupt(cpu.enabledInterrupts());
output << " IF:" << interrupt(cpu.flaggedInterrupts());
output << " (" << interrupt(cpu.maskedInterrupts()) << ")";
return output.str();
}
@@ -683,3 +692,18 @@ std::string EightBit::GameBoy::Disassembler::io(uint8_t value) {
return hex(value);
}
}
std::string EightBit::GameBoy::Disassembler::interrupt(uint8_t value) {
std::ostringstream output;
const auto ik = value & IoRegisters::KeypadPressed;
output << (ik ? "K" : "-");
const auto is = value & IoRegisters::SerialTransfer;
output << (is ? "S" : "-");
const auto it = value & IoRegisters::TimerOverflow;
output << (it ? "T" : "-");
const auto id = value & IoRegisters::DisplayControlStatus;
output << (id ? "D" : "-");
const auto iv = value & IoRegisters::VerticalBlank;
output << (iv ? "V" : "-");
return output.str();
}