diff --git a/source/frontends/sdl/imgui/sdlimguiframe.cpp b/source/frontends/sdl/imgui/sdlimguiframe.cpp index 157a7edb..b4b2b9f4 100644 --- a/source/frontends/sdl/imgui/sdlimguiframe.cpp +++ b/source/frontends/sdl/imgui/sdlimguiframe.cpp @@ -190,4 +190,10 @@ namespace sa2 SDLFrame::ProcessSingleEvent(event, quit); } + void SDLImGuiFrame::ResetSpeed() + { + SDLFrame::ResetSpeed(); + mySettings.resetDebuggerCycles(); + } + } diff --git a/source/frontends/sdl/imgui/sdlimguiframe.h b/source/frontends/sdl/imgui/sdlimguiframe.h index 5a8de7b4..91be0a33 100644 --- a/source/frontends/sdl/imgui/sdlimguiframe.h +++ b/source/frontends/sdl/imgui/sdlimguiframe.h @@ -22,6 +22,8 @@ namespace sa2 void UpdateTexture() override; void RenderPresent() override; + void ResetSpeed() override; + protected: void ProcessSingleEvent(const SDL_Event & event, bool & quit) override; diff --git a/source/frontends/sdl/imgui/sdlsettings.cpp b/source/frontends/sdl/imgui/sdlsettings.cpp index 6d601ac2..e6036264 100644 --- a/source/frontends/sdl/imgui/sdlsettings.cpp +++ b/source/frontends/sdl/imgui/sdlsettings.cpp @@ -755,7 +755,7 @@ namespace sa2 void ImGuiSettings::drawDisassemblyTable(SDLFrame * frame) { const ImGuiTableFlags flags = ImGuiTableFlags_RowBg | ImGuiTableFlags_SizingStretchProp | ImGuiTableFlags_BordersOuter | ImGuiTableFlags_ScrollY; - if (ImGui::BeginTable("Disassembly", 9, flags)) + if (ImGui::BeginTable("Disassembly", 10, flags)) { ImGui::PushStyleCompact(); // weigths proportional to column width (including header) @@ -769,6 +769,7 @@ namespace sa2 ImGui::TableSetupColumn("Value", 0, 6); ImGui::TableSetupColumn("Immediate", 0, 9); ImGui::TableSetupColumn("Branch", 0, 6); + ImGui::TableSetupColumn("Cycles", 0, 6); ImGui::TableHeadersRow(); ImGuiListClipper clipper; @@ -882,6 +883,15 @@ namespace sa2 ImGui::TextUnformatted(line.sBranch); } + ImGui::TableNextColumn(); + if (g_nAppMode == MODE_DEBUG) + { + if (myAddressCycles.find(nAddress) != myAddressCycles.end()) + { + ImGui::Text("%d", myAddressCycles[nAddress]); + } + } + nAddress += line.nOpbyte; ImGui::PopID(); } @@ -949,8 +959,16 @@ namespace sa2 } } + void ImGuiSettings::resetDebuggerCycles() + { + myAddressCycles.clear(); + myBaseDebuggerCycles = g_nCumulativeCycles; + } + void ImGuiSettings::showDebugger(SDLFrame * frame) { + myAddressCycles[regs.pc] = g_nCumulativeCycles - myBaseDebuggerCycles; + if (ImGui::Begin("Debugger", &myShowDebugger)) { ImGui::BeginChild("Console", ImVec2(0, -ImGui::GetFrameHeightWithSpacing())); diff --git a/source/frontends/sdl/imgui/sdlsettings.h b/source/frontends/sdl/imgui/sdlsettings.h index 070c8810..55983672 100644 --- a/source/frontends/sdl/imgui/sdlsettings.h +++ b/source/frontends/sdl/imgui/sdlsettings.h @@ -15,6 +15,7 @@ namespace sa2 public: void show(SDLFrame* frame); float drawMenuBar(SDLFrame* frame); + void resetDebuggerCycles(); bool windowed = false; @@ -32,6 +33,9 @@ namespace sa2 int mySpeakerVolume; int myMockingboardVolume; + uint64_t myBaseDebuggerCycles; + std::unordered_map myAddressCycles; + MemoryEditor myMainMemoryEditor; MemoryEditor myAuxMemoryEditor; diff --git a/source/frontends/sdl/sdlframe.h b/source/frontends/sdl/sdlframe.h index f80f7340..90f463b1 100644 --- a/source/frontends/sdl/sdlframe.h +++ b/source/frontends/sdl/sdlframe.h @@ -30,7 +30,7 @@ namespace sa2 void Execute(const DWORD uCycles); void ExecuteOneFrame(const size_t msNextFrame); void ChangeMode(const AppMode_e mode); - void ResetSpeed(); + virtual void ResetSpeed(); virtual void UpdateTexture() = 0; virtual void RenderPresent() = 0;