From 7a41461883295bd3371a1c5d201be8c6f34c2e43 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 4 Mar 2024 19:50:15 -0500 Subject: [PATCH] memory composition, part 1 --- src/engine/platform/snes.cpp | 3 +++ src/gui/editControls.cpp | 4 ++++ src/gui/gui.h | 20 ++++++++++++++++++++ src/gui/guiConst.cpp | 20 ++++++++++++++++++++ src/gui/memory.cpp | 30 +++++++++++++++++++++++++++++- 5 files changed, 76 insertions(+), 1 deletion(-) diff --git a/src/engine/platform/snes.cpp b/src/engine/platform/snes.cpp index ef1068c3f..90069ebf3 100644 --- a/src/engine/platform/snes.cpp +++ b/src/engine/platform/snes.cpp @@ -971,6 +971,7 @@ void DivPlatformSNES::renderSamples(int sysID) { if (s->loop) { copyOfSampleMem[memPos+actualLength-9]|=3; } + memCompo.entries.push_back(DivMemoryEntry(DIV_MEMORY_SAMPLE,"Sample",i,memPos,memPos+actualLength)); memPos+=actualLength; } if (actualLength -#include +#include "imgui.h" +#include "imgui_internal.h" void FurnaceGUI::drawMemory() { if (nextWindow==GUI_WINDOW_MEMORY) { @@ -29,6 +30,10 @@ void FurnaceGUI::drawMemory() { } if (!memoryOpen) return; if (ImGui::Begin("Memory Composition",&memoryOpen,globalWinFlags)) { + ImDrawList* dl=ImGui::GetWindowDrawList(); + ImGuiWindow* window=ImGui::GetCurrentWindow(); + char tempID[1024]; + for (int i=0; isong.systemLen; i++) { DivDispatch* dispatch=e->getDispatch(i); for (int j=0; j<4; j++) { @@ -36,6 +41,29 @@ void FurnaceGUI::drawMemory() { if (mc==NULL) break; ImGui::Text("%s: %s",e->getSystemName(e->song.system[i]),mc->name.c_str()); + ImGui::SameLine(); + ImGui::Text("%d/%d",(int)mc->used,(int)mc->capacity); + + ImVec2 size=ImVec2(ImGui::GetContentRegionAvail().x,48.0f*dpiScale); + ImVec2 minArea=window->DC.CursorPos; + ImVec2 maxArea=ImVec2( + minArea.x+size.x, + minArea.y+size.y + ); + ImRect rect=ImRect(minArea,maxArea); + ImGuiStyle& style=ImGui::GetStyle(); + ImGui::ItemSize(size,style.FramePadding.y); + snprintf(tempID,1023,"MC%d_%d",i,j); + if (ImGui::ItemAdd(rect,ImGui::GetID(tempID))) { + dl->AddRectFilled(rect.Min,rect.Max,ImGui::GetColorU32(uiColors[GUI_COLOR_MEMORY_BG])); + + if (mc->capacity>0) for (const DivMemoryEntry& k: mc->entries) { + ImVec2 pos1=ImLerp(rect.Min,rect.Max,ImVec2((double)k.begin/(double)mc->capacity,0.0f)); + ImVec2 pos2=ImLerp(rect.Min,rect.Max,ImVec2((double)k.end/(double)mc->capacity,1.0f)); + + dl->AddRectFilled(pos1,pos2,ImGui::GetColorU32(uiColors[GUI_COLOR_MEMORY_FREE+(int)k.type])); + } + } } } }