diff --git a/.gitmodules b/.gitmodules index 81796f89..75c53dc3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "source/frontends/sdl/imgui/imgui"] path = source/frontends/sdl/imgui/imgui url = ../../ocornut/imgui +[submodule "source/frontends/sdl/imgui/imgui_club"] + path = source/frontends/sdl/imgui/imgui_club + url = ../../ocornut/imgui_club diff --git a/source/frontends/sdl/CMakeLists.txt b/source/frontends/sdl/CMakeLists.txt index 2a30dbaf..66922fbc 100644 --- a/source/frontends/sdl/CMakeLists.txt +++ b/source/frontends/sdl/CMakeLists.txt @@ -4,6 +4,7 @@ find_package(SDL2 REQUIRED) pkg_search_module(SDL2_IMAGE REQUIRED SDL2_image) pkg_search_module(GLES2 REQUIRED glesv2) set(IMGUI_PATH "imgui/imgui") +set(IMGUI_CLUB_PATH "imgui/imgui_club") add_executable(sa2) @@ -69,6 +70,7 @@ target_sources(sa2 PRIVATE target_include_directories(sa2 PRIVATE ${IMGUI_PATH} ${IMGUI_PATH}/backends + ${IMGUI_CLUB_PATH}/imgui_memory_editor ) target_compile_definitions(sa2 PRIVATE diff --git a/source/frontends/sdl/imgui/gles.h b/source/frontends/sdl/imgui/gles.h index 61a55181..80bef59e 100644 --- a/source/frontends/sdl/imgui/gles.h +++ b/source/frontends/sdl/imgui/gles.h @@ -31,3 +31,5 @@ #include "imgui.h" #include "imgui_impl_sdl.h" #include "imgui_impl_opengl3.h" + +#include "imgui_memory_editor.h" diff --git a/source/frontends/sdl/imgui/imgui_club b/source/frontends/sdl/imgui/imgui_club new file mode 160000 index 00000000..60275e79 --- /dev/null +++ b/source/frontends/sdl/imgui/imgui_club @@ -0,0 +1 @@ +Subproject commit 60275e79c3e0b0568ee1e41486233e958eac2e80 diff --git a/source/frontends/sdl/imgui/sdlimguiframe.cpp b/source/frontends/sdl/imgui/sdlimguiframe.cpp index 63516e82..742738b3 100644 --- a/source/frontends/sdl/imgui/sdlimguiframe.cpp +++ b/source/frontends/sdl/imgui/sdlimguiframe.cpp @@ -14,6 +14,8 @@ #include "Speaker.h" #include "Mockingboard.h" #include "Registry.h" +#include "Memory.h" +#include "Debugger/DebugDefs.h" #include @@ -155,6 +157,7 @@ namespace sa2 if (ImGui::BeginMenu("System")) { ImGui::MenuItem("Settings", nullptr, &mySettings.showSettings); + ImGui::MenuItem("Memory", nullptr, &mySettings.showMemory); ImGui::MenuItem("Demo", nullptr, &mySettings.showDemo); ImGui::EndMenu(); } @@ -197,6 +200,9 @@ namespace sa2 ImGui::Checkbox("Apple Video windowed", &mySettings.windowed); ImGui::SameLine(); HelpMarker("Show Apple Video in a separate window."); + ImGui::Checkbox("Show Memory", &mySettings.showMemory); + ImGui::SameLine(); HelpMarker("Show Apple ][ memroy pages."); + ImGui::Checkbox("Show Demo", &mySettings.showDemo); ImGui::SameLine(); HelpMarker("Show Dear ImGui DemoWindow."); @@ -244,6 +250,11 @@ namespace sa2 const eCpuType cpu = GetMainCpu(); ImGui::Selectable(getCPUName(cpu).c_str()); + ImGui::TableNextColumn(); + ImGui::Selectable("Mode"); + ImGui::TableNextColumn(); + ImGui::Selectable(getModeName(g_nAppMode).c_str()); + ImGui::EndTable(); } @@ -276,6 +287,33 @@ namespace sa2 } } + void SDLImGuiFrame::ShowMemory() + { + if (mySettings.showMemory) + { + if (ImGui::Begin("Memory Viewer", &mySettings.showMemory)) + { + if (ImGui::BeginTabBar("Memory")) + { + if (ImGui::BeginTabItem("Main")) + { + void * mainBase = MemGetMainPtr(0); + myMainMemoryEditor.DrawContents(mainBase, _6502_MEM_LEN); + ImGui::EndTabItem(); + } + if (ImGui::BeginTabItem("AUX")) + { + void * auxBase = MemGetAuxPtr(0); + myMainMemoryEditor.DrawContents(auxBase, _6502_MEM_LEN); + ImGui::EndTabItem(); + } + ImGui::EndTabBar(); + } + } + ImGui::End(); + } + } + void SDLImGuiFrame::RenderPresent() { ImGui_ImplOpenGL3_NewFrame(); @@ -283,6 +321,7 @@ namespace sa2 ImGui::NewFrame(); ShowSettings(); + ShowMemory(); if (mySettings.showDemo) { diff --git a/source/frontends/sdl/imgui/sdlimguiframe.h b/source/frontends/sdl/imgui/sdlimguiframe.h index 28a786fe..e30e61ce 100644 --- a/source/frontends/sdl/imgui/sdlimguiframe.h +++ b/source/frontends/sdl/imgui/sdlimguiframe.h @@ -30,6 +30,7 @@ namespace sa2 void ClearBackground(); void DrawAppleVideo(); void ShowSettings(); + void ShowMemory(); struct ImGuiSettings { @@ -37,6 +38,7 @@ namespace sa2 bool windowed = false; bool showDemo = false; bool showSettings = false; + bool showMemory = false; int speakerVolume = 50; int mockingboardVolume = 50; }; @@ -50,6 +52,8 @@ namespace sa2 ImTextureID myTexture; ImGuiSettings mySettings; + MemoryEditor myMainMemoryEditor; + MemoryEditor myAuxMemoryEditor; }; } diff --git a/source/frontends/sdl/imgui/settingshelper.cpp b/source/frontends/sdl/imgui/settingshelper.cpp index d379493d..bb45b17d 100644 --- a/source/frontends/sdl/imgui/settingshelper.cpp +++ b/source/frontends/sdl/imgui/settingshelper.cpp @@ -46,6 +46,16 @@ namespace {CPU_65C02, "CPU_65C02"}, {CPU_Z80, "CPU_Z80"}, }; + + const std::map modes = + { + {MODE_LOGO, "MODE_LOGO"}, + {MODE_PAUSED, "MODE_PAUSED"}, + {MODE_RUNNING, "MODE_RUNNING"}, + {MODE_DEBUG, "MODE_DEBUG"}, + {MODE_STEPPING, "MODE_STEPPING"}, + {MODE_BENCHMARK, "MODE_BENCHMARCK"}, + }; } namespace sa2 @@ -66,4 +76,9 @@ namespace sa2 return cpuTypes.at(cpu); } + const std::string & getModeName(AppMode_e mode) + { + return modes.at(mode); + } + } diff --git a/source/frontends/sdl/imgui/settingshelper.h b/source/frontends/sdl/imgui/settingshelper.h index 3ca651d3..e5a13db7 100644 --- a/source/frontends/sdl/imgui/settingshelper.h +++ b/source/frontends/sdl/imgui/settingshelper.h @@ -12,5 +12,6 @@ namespace sa2 const std::string & getCardName(SS_CARDTYPE card); const std::string & getApple2Name(eApple2Type type); const std::string & getCPUName(eCpuType cpu); + const std::string & getModeName(AppMode_e mode); }