Add memory viewer using imgui_club/imgui_memory_editor.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-03-06 18:00:07 +00:00
commit 03329bba84
6 changed files with 54 additions and 1 deletions

3
.gitmodules vendored
View file

@ -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

View file

@ -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)
@ -66,11 +67,14 @@ target_sources(sa2 PRIVATE
${IMGUI_PATH}/imgui_widgets.cpp
${IMGUI_PATH}/backends/imgui_impl_sdl.cpp
${IMGUI_PATH}/backends/imgui_impl_opengl3.cpp
${IMGUI_CLUB_PATH}/imgui_memory_editor/imgui_memory_editor.h
)
target_include_directories(sa2 PRIVATE
${IMGUI_PATH}
${IMGUI_PATH}/backends
${IMGUI_CLUB_PATH}/imgui_memory_editor
)
target_compile_definitions(sa2 PRIVATE

View file

@ -31,3 +31,5 @@
#include "imgui.h"
#include "imgui_impl_sdl.h"
#include "imgui_impl_opengl3.h"
#include "imgui_memory_editor.h"

@ -0,0 +1 @@
Subproject commit 60275e79c3e0b0568ee1e41486233e958eac2e80

View file

@ -10,6 +10,9 @@
#include "Speaker.h"
#include "Mockingboard.h"
#include "Registry.h"
#include "Memory.h"
#include "Debugger/DebugDefs.h"
namespace
{
@ -43,7 +46,10 @@ namespace sa2
if (ImGui::BeginTabItem("General"))
{
ImGui::Checkbox("Apple Video windowed", &windowed);
ImGui::SameLine(); HelpMarker("Show Apple Video in a separate window.");
ImGui::SameLine(); HelpMarker("Show Apple video in a separate window.");
ImGui::Checkbox("Memory", &myShowMemory);
ImGui::SameLine(); HelpMarker("Show Apple memory.");
ImGui::Checkbox("Show Demo", &myShowDemo);
ImGui::SameLine(); HelpMarker("Show Dear ImGui DemoWindow.");
@ -130,6 +136,11 @@ namespace sa2
showSettings();
}
if (myShowMemory)
{
showMemory();
}
if (myShowDemo)
{
ImGui::ShowDemoWindow(&myShowDemo);
@ -146,6 +157,8 @@ namespace sa2
if (ImGui::BeginMenu("System"))
{
ImGui::MenuItem("Settings", nullptr, &myShowSettings);
ImGui::MenuItem("Memory", nullptr, &myShowMemory);
ImGui::Separator();
ImGui::MenuItem("Demo", nullptr, &myShowDemo);
ImGui::EndMenu();
}
@ -159,4 +172,28 @@ namespace sa2
return menuBarHeight;
}
void ImGuiSettings::showMemory()
{
if (ImGui::Begin("Memory Viewer", &myShowMemory))
{
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();
}
}

View file

@ -16,10 +16,16 @@ namespace sa2
private:
bool myShowDemo = false;
bool myShowSettings = false;
bool myShowMemory = false;
int mySpeakerVolume = 50;
int myMockingboardVolume = 50;
MemoryEditor myMainMemoryEditor;
MemoryEditor myAuxMemoryEditor;
void showSettings();
void showMemory();
};
}