|
| 1 | +#include "Watcher.hpp" |
| 2 | +#include "../Chipset/CPU.hpp" |
| 3 | +#include "../Chipset/Chipset.hpp" |
| 4 | +#include "../Peripheral/BatteryBackedRAM.hpp" |
| 5 | +#include "imgui/imgui.h" |
| 6 | +#include <cstdint> |
| 7 | +#include <cstdio> |
| 8 | + |
| 9 | +void Watcher::DrawWindow() { |
| 10 | + ImGui::Begin("Watcher"); |
| 11 | + ImGui::Text("Stack Trace"); |
| 12 | + ImGui::BeginChild("##stack_trace", ImVec2(0, 8 * ImGui::GetTextLineHeight())); |
| 13 | + casioemu::Chipset &chipset = emu->chipset; |
| 14 | + casioemu::CPU &cpu = chipset.cpu; |
| 15 | + std::string s = cpu.GetBacktrace(); |
| 16 | + ImGui::InputTextMultiline("##as", (char *)s.c_str(), s.size(), ImVec2(ImGui::GetWindowWidth(), 0), ImGuiInputTextFlags_ReadOnly); |
| 17 | + ImGui::EndChild(); |
| 18 | + ImGui::Text("Registers"); |
| 19 | + ImGui::BeginChild("##registers"); |
| 20 | + ImGui::Text("r0 %02X | r1 %02X | r2 %02X | r3 %02X | PSW %02X | LR %01X:%04X", cpu.reg_r[ 0] & 0xff, cpu.reg_r[ 1] & 0xff, cpu.reg_r[ 2] & 0xff, cpu.reg_r[ 3] & 0xff, cpu.reg_psw & 0xff, cpu.reg_lcsr & 0xf, cpu.reg_lr & 0xffff); |
| 21 | + ImGui::Text("r4 %02X | r5 %02X | r6 %02X | r7 %02X | EPSW1 %02X | ELR1 %01X:%04X", cpu.reg_r[ 4] & 0xff, cpu.reg_r[ 5] & 0xff, cpu.reg_r[ 6] & 0xff, cpu.reg_r[ 7] & 0xff, cpu.reg_epsw[1] & 0xff, cpu.reg_ecsr[1] & 0xf, cpu.reg_elr[1] & 0xffff); |
| 22 | + ImGui::Text("r8 %02X | r9 %02X | r10 %02X | r11 %02X | EPSW2 %02X | ELR2 %01X:%04X", cpu.reg_r[ 8] & 0xff, cpu.reg_r[ 9] & 0xff, cpu.reg_r[10] & 0xff, cpu.reg_r[11] & 0xff, cpu.reg_epsw[2] & 0xff, cpu.reg_ecsr[2] & 0xf, cpu.reg_elr[2] & 0xffff); |
| 23 | + ImGui::Text("r12 %02X | r13 %02X | r14 %02X | r15 %02X | EPSW3 %02X | ELR3 %01X:%04X", cpu.reg_r[12] & 0xff, cpu.reg_r[13] & 0xff, cpu.reg_r[14] & 0xff, cpu.reg_r[15] & 0xff, cpu.reg_epsw[3] & 0xff, cpu.reg_ecsr[3] & 0xf, cpu.reg_elr[3] & 0xffff); |
| 24 | + ImGui::Text("SP %04X, EA %04X, ELVL %01X, PC %01X:%04X", cpu.reg_sp & 0xffff, cpu.reg_ea & 0xffff, cpu.reg_psw & 3, cpu.reg_csr & 0xf, cpu.reg_pc & 0xffff); |
| 25 | + ImGui::EndChild(); |
| 26 | + ImGui::End(); |
| 27 | +} |
0 commit comments