From 9ce9a84dde39ff62fd77763cde94ed0185ece013 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 17 Aug 2025 15:26:53 -0500 Subject: [PATCH] GUI: loop start/end hints, part 2 --- src/gui/gui.h | 1 + src/gui/guiConst.cpp | 1 + src/gui/sampleEdit.cpp | 101 +++++++++++++++++++++++++++++++++++++---- src/gui/settings.cpp | 1 + 4 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/gui/gui.h b/src/gui/gui.h index f06ade910..cdea368d9 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -463,6 +463,7 @@ enum FurnaceGUIColors { GUI_COLOR_SAMPLE_CHIP_DISABLED, GUI_COLOR_SAMPLE_CHIP_ENABLED, GUI_COLOR_SAMPLE_CHIP_WARNING, + GUI_COLOR_SAMPLE_LOOP_HINT, GUI_COLOR_PAT_MANAGER_NULL, GUI_COLOR_PAT_MANAGER_USED, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 37506ff62..6e49d2473 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -1160,6 +1160,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_SAMPLE_CHIP_DISABLED,"",ImVec4(0.6f,0.6f,0.6f,1.0f)), D(GUI_COLOR_SAMPLE_CHIP_ENABLED,"",ImVec4(0.3f,1.0f,0.3f,1.0f)), D(GUI_COLOR_SAMPLE_CHIP_WARNING,"",ImVec4(1.0f,0.75f,0.3f,1.0f)), + D(GUI_COLOR_SAMPLE_LOOP_HINT,"",ImVec4(1.0f,0.7f,0.0f,0.8f)), D(GUI_COLOR_PAT_MANAGER_NULL,"",ImVec4(0.15f,0.15f,0.15f,1.0f)), D(GUI_COLOR_PAT_MANAGER_USED,"",ImVec4(0.15f,1.0f,0.15f,1.0f)), diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 784485d93..632914980 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -2042,33 +2042,75 @@ void FurnaceGUI::drawSampleEdit() { } dl->PopClipRect(); - //bool displayLoopHintsNES=false; + bool displayLoopHintsNES=false; bool displayLoopHintsSNES=false; - //bool displayLoopHintsAmiga=false; + bool displayLoopHintsAmiga=false; + bool displayLoopHintsGBADMA=false; for (int i=0; isong.systemLen; i++) { - /* if (e->song.system[i]==DIV_SYSTEM_NES) { displayLoopHintsNES=true; - }*/ + } if (e->song.system[i]==DIV_SYSTEM_SNES) { displayLoopHintsSNES=true; } - /*if (e->song.system[i]==DIV_SYSTEM_AMIGA) { + if (e->song.system[i]==DIV_SYSTEM_AMIGA || e->song.system[i]==DIV_SYSTEM_C219) { displayLoopHintsAmiga=true; - }*/ + } + if (e->song.system[i]==DIV_SYSTEM_GBA_DMA) { + displayLoopHintsGBADMA=true; + } } if (displayLoopStartHints) { + if (displayLoopHintsNES) { + if (sampleZoom<3.0) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos)&511)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } if (displayLoopHintsSNES) { - if (sampleZoom<0.5) { + if (sampleZoom<0.75) { for (int i=0; i<(int)(sampleZoom*avail.x); i++) { if (((i+samplePos)&15)==0) { ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); ImVec2 p2=p1; p2.y=rectMax.y; - dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_NEEDLE])); + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } + if (displayLoopHintsAmiga) { + if (sampleZoom<0.35) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos)&1)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } + if (displayLoopHintsGBADMA) { + if (sampleZoom<0.6) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos)&3)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); } } } @@ -2076,15 +2118,54 @@ void FurnaceGUI::drawSampleEdit() { } if (displayLoopEndHints) { + if (displayLoopHintsNES) { + if (sampleZoom<3.0) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos-8)&128)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } if (displayLoopHintsSNES) { - if (sampleZoom<0.5) { + if (sampleZoom<0.75) { for (int i=0; i<(int)(sampleZoom*avail.x); i++) { if (((i+samplePos)&15)==0) { ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); ImVec2 p2=p1; p2.y=rectMax.y; - dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_NEEDLE])); + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } + if (displayLoopHintsAmiga) { + if (sampleZoom<0.35) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos)&1)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); + } + } + } + } + if (displayLoopHintsGBADMA) { + if (sampleZoom<0.6) { + for (int i=0; i<(int)(sampleZoom*avail.x); i++) { + if (((i+samplePos-sample->loopStart)&15)==0) { + ImVec2 p1=ImVec2(rectMin.x+((float)i/sampleZoom),rectMin.y); + ImVec2 p2=p1; + p2.y=rectMax.y; + + dl->AddLine(p1,p2,ImGui::GetColorU32(uiColors[GUI_COLOR_SAMPLE_LOOP_HINT])); } } } diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 704078458..173eb958b 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -4287,6 +4287,7 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_NEEDLE,_("Preview needle")); UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_NEEDLE_PLAYING,_("Playing needles")); UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_LOOP_POINT,_("Loop markers")); + UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_LOOP_HINT,_("Valid loop position hints")); UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_DISABLED,_("Chip select: disabled")); UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_ENABLED,_("Chip select: enabled")); UI_COLOR_CONFIG(GUI_COLOR_SAMPLE_CHIP_WARNING,_("Chip select: enabled (failure)"));