This commit is contained in:
Andrea Odetti 2021-02-28 17:02:30 +00:00
parent 0459fd3ba9
commit 8d8782946b
8 changed files with 67 additions and 0 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)
@ -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

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

@ -14,6 +14,8 @@
#include "Speaker.h"
#include "Mockingboard.h"
#include "Registry.h"
#include "Memory.h"
#include "Debugger/DebugDefs.h"
#include <iostream>
@ -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)
{

View file

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

View file

@ -46,6 +46,16 @@ namespace
{CPU_65C02, "CPU_65C02"},
{CPU_Z80, "CPU_Z80"},
};
const std::map<AppMode_e, std::string> 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);
}
}

View file

@ -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);
}