diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index d31983741a5f..ab0798409bef 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -244,8 +244,8 @@ void MIPSDebugInterface::toggleBreakpoint(unsigned int address) int MIPSDebugInterface::getColor(unsigned int address, bool darkMode) const { - int colors[6] = { 0xe0FFFF, 0xFFe0e0, 0xe8e8FF, 0xFFe0FF, 0xe0FFe0, 0xFFFFe0 }; - int colorsDark[6] = { ~0xe0FFFF, ~0xFFe0e0, ~0xe8e8FF, ~0xFFe0FF, ~0xe0FFe0, ~0xFFFFe0 }; + uint32_t colors[6] = { 0xFFe0FFFF, 0xFFFFe0e0, 0xFFe8e8FF, 0xFFFFe0FF, 0xFFe0FFe0, 0xFFFFFFe0 }; + uint32_t colorsDark[6] = { 0xFF301010, 0xFF103030, 0xFF403010, 0xFF103000, 0xFF301030, 0xFF101030 }; int n = g_symbolMap->GetFunctionNum(address); if (n == -1) { diff --git a/Core/MIPS/MIPSStackWalk.cpp b/Core/MIPS/MIPSStackWalk.cpp index eb816a6ad0a6..60e38a0658cc 100644 --- a/Core/MIPS/MIPSStackWalk.cpp +++ b/Core/MIPS/MIPSStackWalk.cpp @@ -163,6 +163,11 @@ namespace MIPSStackWalk { std::vector Walk(u32 pc, u32 ra, u32 sp, u32 threadEntry, u32 threadStackTop) { std::vector frames; + + if (!Memory::IsValidAddress(pc) || !Memory::IsValidAddress(sp) || !Memory::IsValidAddress(ra)) { + return frames; + } + StackFrame current; current.pc = pc; current.sp = sp; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index da44e949c0f2..39e0fc23e37c 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -955,7 +955,7 @@ bool EmuScreen::UnsyncKey(const KeyInput &key) { if (UI::IsFocusMovementEnabled() || (imguiVisible_ && imguiInited_)) { // Note: Allow some Vkeys through, so we can toggle the imgui for example (since we actually block the control mapper otherwise in imgui mode). // We need to manually implement it here :/ - if (imguiVisible_ && imguiInited_) { + if (imguiVisible_ && imguiInited_ && (key.flags & (KEY_UP | KEY_DOWN))) { InputMapping mapping(key.deviceId, key.keyCode); std::vector pspButtons; bool mappingFound = KeyMap::InputMappingToPspButton(mapping, &pspButtons); @@ -1643,7 +1643,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { ImGui_ImplThin3d_Init(draw); } - if (imguiVisible_ && imguiInited_) { + if (imguiVisible_ && imguiInited_ && PSP_IsInited()) { _dbg_assert_(imDebugger_); ImGui_ImplPlatform_NewFrame(); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 9adde3ad2ee1..c0d1be38e0f0 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -57,7 +57,7 @@ void DrawRegisterView(MIPSDebugInterface *mipsDebug, bool *open) { ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("FPR")) { + if (ImGui::BeginTabItem("FPU")) { if (ImGui::BeginTable("fpr", 3, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { ImGui::TableSetupColumn("regname", ImGuiTableColumnFlags_WidthFixed); ImGui::TableSetupColumn("value", ImGuiTableColumnFlags_WidthFixed); @@ -79,7 +79,7 @@ void DrawRegisterView(MIPSDebugInterface *mipsDebug, bool *open) { } ImGui::EndTabItem(); } - if (ImGui::BeginTabItem("VPR")) { + if (ImGui::BeginTabItem("VFPU")) { ImGui::Text("TODO"); ImGui::EndTabItem(); } @@ -93,10 +93,10 @@ static const char *ThreadStatusToString(u32 status) { case THREADSTATUS_RUNNING: return "Running"; case THREADSTATUS_READY: return "Ready"; case THREADSTATUS_WAIT: return "Wait"; - case THREADSTATUS_SUSPEND: return "Suspend"; + case THREADSTATUS_SUSPEND: return "Suspended"; case THREADSTATUS_DORMANT: return "Dormant"; case THREADSTATUS_DEAD: return "Dead"; - case THREADSTATUS_WAITSUSPEND: return "WaitSuspend"; + case THREADSTATUS_WAITSUSPEND: return "WaitSuspended"; default: break; } @@ -198,7 +198,7 @@ void DrawCallStacks(MIPSDebugInterface *debug, bool *open) { } void DrawModules(MIPSDebugInterface *debug, bool *open) { - if (!ImGui::Begin("Modules", open)) { + if (!ImGui::Begin("Modules", open) || !g_symbolMap) { ImGui::End(); return; } @@ -379,12 +379,11 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, bool *open, CoreState c while (clipper.Step()) { for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { if (ImGui::Selectable(symCache_[i].name.c_str(), false)) { - disasmView_.setCurAddress(symCache_[i].address); + disasmView_.gotoAddr(symCache_[i].address); disasmView_.scrollAddressIntoView(); } } } - clipper.End(); ImGui::EndListBox(); } diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index a573c1e5e0a3..6975b19e5d4e 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -375,7 +375,7 @@ void ImDisasmView::Draw(ImDrawList *drawList) { ImColor textColor = 0xFFFFFFFF; if (isInInterval(address, line.totalSize, debugger->getPC())) { - backgroundColor = scaleColor(backgroundColor, 1.15f); + backgroundColor = scaleColor(backgroundColor, 1.3f); } if (address >= selectRangeStart_ && address < selectRangeEnd_ && searching_ == false) { @@ -383,7 +383,7 @@ void ImDisasmView::Draw(ImDrawList *drawList) { backgroundColor = ImColor(address == curAddress_ ? 0xFFFF8822 : 0xFFFF9933); textColor = ImColor(0xFF000000); } else { - backgroundColor = ImColor(0xFFC0C0C0); + backgroundColor = ImColor(0xFF606060); } } @@ -404,10 +404,12 @@ void ImDisasmView::Draw(ImDrawList *drawList) { drawList->AddText(ImVec2(rect.left + pixelPositions_.addressStart, rect.top + rowY1 + 2), textColor, addressText); if (isInInterval(address, line.totalSize, debugger->getPC())) { - // Show the current PC with a little square. - drawList->AddRectFilled( - ImVec2(canvas_p0.x + pixelPositions_.opcodeStart - rowHeight_, canvas_p0.y + rowY1 + 2), - ImVec2(canvas_p0.x + pixelPositions_.opcodeStart - 4, canvas_p0.y + rowY1 + rowHeight_ - 2), 0xFFFFFFFF); + // Show the current PC with a little triangle. + drawList->AddTriangleFilled( + ImVec2(canvas_p0.x + pixelPositions_.opcodeStart - rowHeight_ * 0.7f, canvas_p0.y + rowY1 + 2), + ImVec2(canvas_p0.x + pixelPositions_.opcodeStart - rowHeight_ * 0.7f, canvas_p0.y + rowY1 + rowHeight_ - 2), + ImVec2(canvas_p0.x + pixelPositions_.opcodeStart - 4, canvas_p0.y + rowY1 + rowHeight_ * 0.5f), + 0xFFFFFFFF); } // display whether the condition of a branch is met @@ -498,7 +500,8 @@ void ImDisasmView::ScrollRelative(int amount) { ScanVisibleFunctions(); } -void ImDisasmView::followBranch() { +// Follows branches and jumps. +void ImDisasmView::FollowBranch() { DisassemblyLineInfo line; manager.getLine(curAddress_, true, line); @@ -507,7 +510,7 @@ void ImDisasmView::followBranch() { jumpStack_.push_back(curAddress_); gotoAddr(line.info.branchTarget); } else if (line.info.hasRelevantAddress) { - // well, not exactly a branch, but we can do something anyway + // well, not exactly a branch, but we can do something anyway // SendMessage(GetParent(wnd), WM_DEB_GOTOHEXEDIT, line.info.relevantAddress, 0); // SetFocus(wnd); } @@ -644,7 +647,7 @@ void ImDisasmView::onKeyDown(ImGuiKey key) { } return; case VK_RIGHT: - followBranch(); + FollowBranch(); return; case VK_TAB: displaySymbols_ = !displaySymbols_; @@ -797,7 +800,7 @@ void ImDisasmView::PopupMenu() { debugger->setPC(curAddress_); } if (ImGui::MenuItem("Follow branch")) { - followBranch(); + FollowBranch(); } if (ImGui::MenuItem("Run to here")) { // CBreakPoints::AddBreakPoint(pos, true); diff --git a/UI/ImDebugger/ImDisasmView.h b/UI/ImDebugger/ImDisasmView.h index 7cbc232129fc..055e30bb97e4 100644 --- a/UI/ImDebugger/ImDisasmView.h +++ b/UI/ImDebugger/ImDisasmView.h @@ -125,7 +125,7 @@ class ImDisasmView { std::string disassembleRange(u32 start, u32 size); void disassembleToFile(); void search(bool continueSearch); - void followBranch(); + void FollowBranch(); void calculatePixelPositions(); bool getDisasmAddressText(u32 address, char* dest, bool abbreviateLabels, bool showData); void updateStatusBarText(); diff --git a/ext/imgui/imgui_impl_platform.cpp b/ext/imgui/imgui_impl_platform.cpp index 5fa614497e6a..a9b9b8f1705d 100644 --- a/ext/imgui/imgui_impl_platform.cpp +++ b/ext/imgui/imgui_impl_platform.cpp @@ -22,10 +22,10 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) { default: { ImGuiKey keyCode = KeyCodeToImGui(key.keyCode); - if (keyCode == ImGuiKey_None) { - WARN_LOG(Log::System, "Unmapped ImGui keycode conversion from %d", key.keyCode); - } else { + if (keyCode != ImGuiKey_None) { io.AddKeyEvent(keyCode, true); + } else { + WARN_LOG(Log::System, "KeyDown: Unmapped ImGui keycode conversion from %d", key.keyCode); } break; } @@ -33,10 +33,15 @@ void ImGui_ImplPlatform_KeyEvent(const KeyInput &key) { } if (key.flags & KEY_UP) { ImGuiKey keyCode = KeyCodeToImGui(key.keyCode); - io.AddKeyEvent(keyCode, false); + if (keyCode != ImGuiKey_None) { + io.AddKeyEvent(keyCode, false); + } else { + WARN_LOG(Log::System, "KeyUp: Unmapped ImGui keycode conversion from %d", key.keyCode); + } } if (key.flags & KEY_CHAR) { const int unichar = key.unicodeChar; + if (unichar >= 0x20) { // Insert it! (todo: do it with a string insert) char buf[16];