From d8daeb1169b8b70fe05bae7806e984961f8dd486 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 27 Oct 2023 18:08:37 -0500 Subject: [PATCH] GUI: channel status, part 4 --- src/engine/dispatch.h | 9 ++++++ src/engine/platform/snes.cpp | 57 ++++++++++++++++++++++++++++++++++++ src/engine/platform/snes.h | 1 + src/gui/gui.h | 10 ++++++- src/gui/guiConst.cpp | 9 ++++++ src/gui/pattern.cpp | 34 +++++++++++++++++++-- src/gui/settings.cpp | 9 ++++++ 7 files changed, 126 insertions(+), 3 deletions(-) diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index cff298353..2f6b7c04a 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -396,6 +396,15 @@ struct DivChannelModeHints { // - 9: misc 1 // - 10: misc 2 // - 11: misc 3 + // - 12: attack + // - 13: decay + // - 14: sustain + // - 15: release + // - 16: dec linear + // - 17: dec exp + // - 18: inc linear + // - 19: inc bent + // - 20: direct unsigned char type[4]; // up to 4 unsigned char count; diff --git a/src/engine/platform/snes.cpp b/src/engine/platform/snes.cpp index ae1746678..63d5923e3 100644 --- a/src/engine/platform/snes.cpp +++ b/src/engine/platform/snes.cpp @@ -710,6 +710,63 @@ DivChannelPair DivPlatformSNES::getPaired(int ch) { return DivChannelPair(); } +DivChannelModeHints DivPlatformSNES::getModeHints(int ch) { + DivChannelModeHints ret; + ret.count=1; + ret.hint[0]="-"; + ret.type[0]=0; + + const SPC_DSP::voice_t* v=dsp.get_voice(ch); + if (v!=NULL) { + if (v->regs[5]&128) { + switch (v->env_mode) { + case SPC_DSP::env_attack: + ret.hint[0]="A"; + ret.type[0]=12; + break; + case SPC_DSP::env_decay: + ret.hint[0]="D"; + ret.type[0]=13; + break; + case SPC_DSP::env_sustain: + ret.hint[0]="S"; + ret.type[0]=14; + break; + case SPC_DSP::env_release: + ret.hint[0]="R"; + ret.type[0]=15; + break; + } + } else { + if (v->regs[7]&128) { + switch (v->regs[7]&0x60) { + case 0: + ret.hint[0]="d"; + ret.type[0]=16; + break; + case 32: + ret.hint[0]="X"; + ret.type[0]=17; + break; + case 64: + ret.hint[0]="I"; + ret.type[0]=18; + break; + case 96: + ret.hint[0]="B"; + ret.type[0]=19; + break; + } + } else { + ret.hint[0]="V"; + ret.type[0]=20; + } + } + } + + return ret; +} + DivSamplePos DivPlatformSNES::getSamplePos(int ch) { if (ch>=8) return DivSamplePos(); if (!chan[ch].active) return DivSamplePos(); diff --git a/src/engine/platform/snes.h b/src/engine/platform/snes.h index 277a06c95..8c48c6c72 100644 --- a/src/engine/platform/snes.h +++ b/src/engine/platform/snes.h @@ -102,6 +102,7 @@ class DivPlatformSNES: public DivDispatch { DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); DivChannelPair getPaired(int chan); + DivChannelModeHints getModeHints(int chan); DivSamplePos getSamplePos(int ch); DivDispatchOscBuffer* getOscBuffer(int chan); unsigned char* getRegisterPool(); diff --git a/src/gui/gui.h b/src/gui/gui.h index 1bca9f066..7a17624db 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -321,7 +321,15 @@ enum FurnaceGUIColors { GUI_COLOR_PATTERN_STATUS_MISC1, GUI_COLOR_PATTERN_STATUS_MISC2, GUI_COLOR_PATTERN_STATUS_MISC3, - + GUI_COLOR_PATTERN_STATUS_ATTACK, + GUI_COLOR_PATTERN_STATUS_DECAY, + GUI_COLOR_PATTERN_STATUS_SUSTAIN, + GUI_COLOR_PATTERN_STATUS_RELEASE, + GUI_COLOR_PATTERN_STATUS_DEC_LINEAR, + GUI_COLOR_PATTERN_STATUS_DEC_EXP, + GUI_COLOR_PATTERN_STATUS_INC, + GUI_COLOR_PATTERN_STATUS_BENT, + GUI_COLOR_PATTERN_STATUS_DIRECT, GUI_COLOR_PATTERN_PAIR, GUI_COLOR_SAMPLE_BG, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index fdfc323ed..55a638d6c 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -1004,6 +1004,15 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_PATTERN_STATUS_MISC1,"",ImVec4(1.0f,0.5f,0.0f,1.0f)), D(GUI_COLOR_PATTERN_STATUS_MISC2,"",ImVec4(0.7f,0.5f,1.0f,1.0f)), D(GUI_COLOR_PATTERN_STATUS_MISC3,"",ImVec4(1.0f,0.1f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_ATTACK,"",ImVec4(1.0f,0.1f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_DECAY,"",ImVec4(1.0f,0.1f,1.0f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_SUSTAIN,"",ImVec4(0.1f,1.0f,1.0f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_RELEASE,"",ImVec4(0.1f,0.2f,1.0f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_DEC_LINEAR,"",ImVec4(1.0f,1.0f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_DEC_EXP,"",ImVec4(1.0f,0.5f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_INC,"",ImVec4(1.0f,1.0f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_BENT,"",ImVec4(1.0f,0.5f,0.1f,1.0f)), + D(GUI_COLOR_PATTERN_STATUS_DIRECT,"",ImVec4(0.2f,1.0f,0.2f,1.0f)), D(GUI_COLOR_PATTERN_PAIR,"",ImVec4(0.6f,0.8f,1.0f,1.0f)), diff --git a/src/gui/pattern.cpp b/src/gui/pattern.cpp index d3666240e..215949ebb 100644 --- a/src/gui/pattern.cpp +++ b/src/gui/pattern.cpp @@ -1039,14 +1039,44 @@ void FurnaceGUI::drawPattern() { hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DSP]; break; case 8: - hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC1]; + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_NOTE]; break; case 9: - hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC2]; + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC1]; break; case 10: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC2]; + break; + case 11: hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_MISC3]; break; + case 12: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_ATTACK]; + break; + case 13: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DECAY]; + break; + case 14: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_SUSTAIN]; + break; + case 15: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_RELEASE]; + break; + case 16: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DEC_LINEAR]; + break; + case 17: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DEC_EXP]; + break; + case 18: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_INC]; + break; + case 19: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_BENT]; + break; + case 20: + hintColor=uiColors[GUI_COLOR_PATTERN_STATUS_DIRECT]; + break; default: hintColor=uiColors[GUI_COLOR_TEXT]; break; diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 7e8a85a5b..d325b4821 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3381,6 +3381,15 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_MISC1,"Status: misc color 1"); UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_MISC2,"Status: misc color 2"); UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_MISC3,"Status: misc color 3"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_ATTACK,"Status: attack"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_DECAY,"Status: decay"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_SUSTAIN,"Status: sustain"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_RELEASE,"Status: release"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_DEC_LINEAR,"Status: decrease linear"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_DEC_EXP,"Status: decrease exp"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_INC,"Status: increase"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_BENT,"Status: bent"); + UI_COLOR_CONFIG(GUI_COLOR_PATTERN_STATUS_DIRECT,"Status: direct"); ImGui::TreePop(); } if (ImGui::TreeNode("Sample Editor")) {