chore(gui): implement basic disassembler

Also implement CPU and Interrupt debug information.

Of note:
1. IE and IRQ status boxes are slightly misaligned
2. Whenever the disassembler accidentally reads into game data rather
   than executable code the emulator crashes
   * Thus I should turn Instruction decoding into a Result<> rather than
     panic on failure
This commit is contained in:
2021-11-30 10:23:06 -04:00
parent 4a1a21a08f
commit 90d2da9272
4 changed files with 262 additions and 2 deletions

View File

@@ -485,3 +485,42 @@ pub(crate) enum ImeState {
Pending,
Enabled,
}
pub(crate) mod dbg {
use super::{Cpu, ImeState, RegisterPair};
pub(crate) fn flags(cpu: &Cpu) -> u8 {
cpu.flags.into()
}
pub(crate) fn af(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::AF)
}
pub(crate) fn bc(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::BC)
}
pub(crate) fn de(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::DE)
}
pub(crate) fn hl(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::HL)
}
pub(crate) fn sp(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::SP)
}
pub(crate) fn pc(cpu: &Cpu) -> u16 {
cpu.register_pair(RegisterPair::PC)
}
pub(crate) fn ime(cpu: &Cpu) -> bool {
match cpu.ime {
ImeState::Enabled => true,
_ => false,
}
}
}