mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-01 16:31:42 +00:00
Include interrupt information in the disassembler output.
Signed-off-by: Adrian Conlon <adrian.conlon@gmail.com>
This commit is contained in:
parent
f7da03d46b
commit
b8a2db96f4
@ -27,6 +27,7 @@ namespace EightBit {
|
||||
static std::string binary(uint8_t value);
|
||||
static std::string decimal(uint8_t value);
|
||||
static std::string io(uint8_t value);
|
||||
static std::string interrupt(uint8_t value);
|
||||
|
||||
static std::string invalid(uint8_t value);
|
||||
|
||||
|
@ -35,6 +35,10 @@ namespace EightBit {
|
||||
[[nodiscard]] register16_t& DE() final;
|
||||
[[nodiscard]] register16_t& HL() final;
|
||||
|
||||
bool& IME() noexcept { return m_ime; }
|
||||
|
||||
[[nodiscard]] uint8_t enabledInterrupts();
|
||||
[[nodiscard]] uint8_t flaggedInterrupts();
|
||||
[[nodiscard]] uint8_t maskedInterrupts();
|
||||
|
||||
protected:
|
||||
@ -89,8 +93,6 @@ namespace EightBit {
|
||||
|
||||
bool m_prefixCB = false;
|
||||
|
||||
bool& IME() noexcept { return m_ime; }
|
||||
|
||||
[[nodiscard]] auto R(const int r) {
|
||||
ASSUME(r >= 0);
|
||||
ASSUME(r <= 7);
|
||||
|
@ -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();
|
||||
}
|
@ -295,10 +295,16 @@ void EightBit::GameBoy::LR35902::ccf(uint8_t& f, const uint8_t operand) {
|
||||
f = clearBit(f, CF, f & CF);
|
||||
}
|
||||
|
||||
uint8_t EightBit::GameBoy::LR35902::enabledInterrupts() {
|
||||
return BUS().peek(IoRegisters::BASE + IoRegisters::IE);
|
||||
}
|
||||
|
||||
uint8_t EightBit::GameBoy::LR35902::flaggedInterrupts() {
|
||||
return m_bus.IO().peek(IoRegisters::IF);
|
||||
}
|
||||
|
||||
uint8_t EightBit::GameBoy::LR35902::maskedInterrupts() {
|
||||
const auto interruptEnable = BUS().peek(IoRegisters::BASE + IoRegisters::IE);
|
||||
const auto interruptFlags = m_bus.IO().peek(IoRegisters::IF);
|
||||
return interruptEnable & interruptFlags;
|
||||
return enabledInterrupts() & flaggedInterrupts();
|
||||
}
|
||||
|
||||
int EightBit::GameBoy::LR35902::step() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user