More small improvements
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include <Debugger.hpp>
|
||||
#include <imgui.h>
|
||||
#include <execution>
|
||||
|
||||
char const* regNames[] = {
|
||||
"zero", "at", "v0", "v1",
|
||||
@@ -101,7 +100,7 @@ void Debugger::RegisterView() {
|
||||
if (!n64::Core::GetRegs().cop0.MapVAddr(n64::Cop0::LOAD, vaddr + row * 0x10 + col, paddr))
|
||||
continue;
|
||||
|
||||
u32 val = n64::Core::GetMem().Read<u32>(paddr);
|
||||
const u32 val = n64::Core::GetMem().Read<u32>(paddr);
|
||||
|
||||
ImGui::TableSetColumnIndex(col+0);
|
||||
ImGui::Text("%02X", (val >> 24) & 0xff);
|
||||
@@ -145,22 +144,22 @@ void Debugger::RegisterView() {
|
||||
|
||||
bool Debugger::render() {
|
||||
n64::Core &core = n64::Core::GetInstance();
|
||||
n64::Registers& regs = core.GetRegs();
|
||||
bool ret = true;
|
||||
const n64::Registers& regs = n64::Core::GetRegs();
|
||||
|
||||
if(!enabled)
|
||||
return false;
|
||||
|
||||
static s64 startAddr = 0xFFFF'FFFF'8000'0000;
|
||||
int step = 4, stepFast = 256;
|
||||
constexpr int step = 4;
|
||||
constexpr int stepFast = 256;
|
||||
|
||||
if(!ImGui::Begin("Debugger", &enabled)) {
|
||||
ret = false;
|
||||
goto EXIT;
|
||||
ImGui::End();
|
||||
return false;
|
||||
}
|
||||
|
||||
ImGui::BeginDisabled(followPC);
|
||||
ImGui::InputScalar("Address", ImGuiDataType_S64, (void*)&startAddr, (void*)&step, (void*)&stepFast, "%016lX", ImGuiInputTextFlags_CharsHexadecimal);
|
||||
ImGui::InputScalar("Address", ImGuiDataType_S64, &startAddr, &step, &stepFast, "%016lX", ImGuiInputTextFlags_CharsHexadecimal);
|
||||
ImGui::EndDisabled();
|
||||
|
||||
ImGui::Text("Follow program counter:");
|
||||
@@ -179,23 +178,23 @@ bool Debugger::render() {
|
||||
core.ToggleBreakpoint(startAddr);
|
||||
}
|
||||
|
||||
auto disasmTableFlags = ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter |
|
||||
constexpr auto disasmTableFlags = ImGuiTableFlags_SizingFixedSame | ImGuiTableFlags_Resizable | ImGuiTableFlags_BordersOuter |
|
||||
ImGuiTableFlags_BordersV | ImGuiTableFlags_ContextMenuInBody;
|
||||
|
||||
if(!ImGui::BeginTable("Disassembly", columns.size(), disasmTableFlags)) {
|
||||
ret = false;
|
||||
goto EXIT;
|
||||
ImGui::End();
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i = 0; i < columns.size(); i++)
|
||||
ImGui::TableSetupColumn(columns[i].name);
|
||||
for(auto &[name, _] : columns)
|
||||
ImGui::TableSetupColumn(name);
|
||||
|
||||
ImGui::TableHeadersRow();
|
||||
|
||||
for(u64 addr = startAddr; addr < startAddr + MAX_LINES_OF_DISASM * sizeof(u32); addr += sizeof(u32)) {
|
||||
for(auto addr = startAddr; addr < startAddr + MAX_LINES_OF_DISASM * sizeof(u32); addr += sizeof(u32)) {
|
||||
auto disasm = Disassembler::GetInstance().Disassemble(addr);
|
||||
auto addrIsCurrent = addr == regs.nextPC;
|
||||
auto addrIsBreakpoint = core.breakpoints.contains(addr);
|
||||
const auto addrIsCurrent = addr == regs.nextPC;
|
||||
const auto addrIsBreakpoint = core.breakpoints.contains(addr);
|
||||
ImColor colorChoice = ImGui::GetStyle().Colors[ImGuiCol_TableRowBg];
|
||||
ImColor colorChoiceAlt = ImGui::GetStyle().Colors[ImGuiCol_TableRowBgAlt];
|
||||
if(addrIsCurrent) {
|
||||
@@ -212,9 +211,9 @@ bool Debugger::render() {
|
||||
ImGui::PushStyleColor(ImGuiCol_TableRowBgAlt, colorChoiceAlt.Value);
|
||||
|
||||
ImGui::TableNextRow();
|
||||
for(int i = 0; i < columns.size(); i++) {
|
||||
ImGui::TableSetColumnIndex(i);
|
||||
columns[i].func(addr, disasm);
|
||||
for(int i = 0; auto &[_, func] : columns) {
|
||||
ImGui::TableSetColumnIndex(i++);
|
||||
func(addr, disasm);
|
||||
}
|
||||
|
||||
ImGui::PopStyleColor();
|
||||
@@ -225,7 +224,6 @@ bool Debugger::render() {
|
||||
|
||||
RegisterView();
|
||||
|
||||
EXIT:
|
||||
ImGui::End();
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ class Debugger final {
|
||||
static constexpr auto MAX_LINES_OF_DISASM = 150;
|
||||
|
||||
struct Column {
|
||||
const char* name;
|
||||
const char* name = nullptr;
|
||||
void (*func)(s64, Disassembler::DisassemblyResult&) = nullptr;
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ class Debugger final {
|
||||
Column{"Instruction", &InstructionFunc},
|
||||
};
|
||||
public:
|
||||
void RegisterView();
|
||||
static void RegisterView();
|
||||
bool followPC = true;
|
||||
void Open(bool wantFollowPC = true) { enabled = true; followPC = wantFollowPC; }
|
||||
void Close() { enabled = false; }
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include <SettingsWindow.hpp>
|
||||
#include <log.hpp>
|
||||
#include <Options.hpp>
|
||||
#include <imgui.h>
|
||||
#include <ranges>
|
||||
@@ -31,7 +30,7 @@ bool SettingsWindow::render() {
|
||||
applyEnabled = false;
|
||||
Options::GetInstance().Apply();
|
||||
|
||||
for (auto &tab : tabs | std::views::values) {
|
||||
for (const auto &tab : tabs | std::views::values) {
|
||||
tab->modified = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user