From 839dc3cd91169f3155120311633469c8717c31ad Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 5 Oct 2023 04:47:14 -0500 Subject: [PATCH] prepare to add channel pair and mode hints --- src/engine/dispatch.h | 49 ++++++++++++++++++++++++++++++++ src/engine/platform/abstract.cpp | 8 ++++++ src/engine/platform/opl.cpp | 9 ++++++ src/engine/platform/opl.h | 1 + src/gui/gui.cpp | 4 ++- 5 files changed, 70 insertions(+), 1 deletion(-) diff --git a/src/engine/dispatch.h b/src/engine/dispatch.h index ecb2ebc6e..1a8ec347d 100644 --- a/src/engine/dispatch.h +++ b/src/engine/dispatch.h @@ -339,6 +339,40 @@ struct DivDispatchOscBuffer { } }; +struct DivChannelPair { + const char* label; + // -1: none + signed char pairs[8]; + + DivChannelPair(const char* l, signed char p0, signed char p1, signed char p2, signed char p3, signed char p4, signed char p5, signed char p6, signed char p7): + label(l), + pairs{p0,p1,p2,p3,p4,p5,p6,p7} {} + DivChannelPair(const char* l, signed char p): + label(l), + pairs{p,-1,-1,-1,-1,-1,-1,-1} {} + DivChannelPair(): + label(NULL), + pairs{-1,-1,-1,-1,-1,-1,-1,-1} {} +}; + +struct DivChannelModeHints { + const char* hint[4]; + // valid types: + // - 0: disabled + // - 1: volume + // - 2: pitch + // - 3: panning + // - 4: ??? + unsigned char type[4]; + // up to 4 + unsigned char count; + + DivChannelModeHints(): + hint{NULL,NULL,NULL,NULL}, + type{0,0,0,0}, + count(0) {} +}; + class DivEngine; class DivMacroInt; @@ -418,6 +452,21 @@ class DivDispatch { */ virtual unsigned short getPan(int chan); + /** + * get "paired" channels. + * @param chan the channel to query. + * @return a DivChannelPair. + */ + virtual DivChannelPair getPaired(int chan); + + /** + * get channel mode hints. + * @param chan the channel to query. + * @return a DivChannelModeHints. + */ + virtual DivChannelModeHints getModeHints(int chan); + + /** * get currently playing sample (and its position). * @param chan the channel. diff --git a/src/engine/platform/abstract.cpp b/src/engine/platform/abstract.cpp index a06d9caf0..26221ebfd 100644 --- a/src/engine/platform/abstract.cpp +++ b/src/engine/platform/abstract.cpp @@ -37,6 +37,14 @@ unsigned short DivDispatch::getPan(int chan) { return 0; } +DivChannelPair DivDispatch::getPaired(int chan) { + return DivChannelPair(); +} + +DivChannelModeHints DivDispatch::getModeHints(int chan) { + return DivChannelModeHints(); +} + DivMacroInt* DivDispatch::getChanMacroInt(int chan) { return NULL; } diff --git a/src/engine/platform/opl.cpp b/src/engine/platform/opl.cpp index 5a7580a78..52968a1a5 100644 --- a/src/engine/platform/opl.cpp +++ b/src/engine/platform/opl.cpp @@ -1582,6 +1582,15 @@ unsigned short DivPlatformOPL::getPan(int ch) { return ((chan[ch].pan&1)<<8)|((chan[ch].pan&2)>>1); } +DivChannelPair DivPlatformOPL::getPaired(int ch) { + if (oplType==3 && ch<12 && !(ch&1)) { + if (chan[ch].fourOp) { + return DivChannelPair("4OP",ch+1); + } + } + return DivChannelPair(); +} + DivDispatchOscBuffer* DivPlatformOPL::getOscBuffer(int ch) { if (oplType==759 || chipType==8950) { if (ch>=totalChans+1) return NULL; diff --git a/src/engine/platform/opl.h b/src/engine/platform/opl.h index bcc147da1..54cf0c24d 100644 --- a/src/engine/platform/opl.h +++ b/src/engine/platform/opl.h @@ -115,6 +115,7 @@ class DivPlatformOPL: public DivDispatch { void* getChanState(int chan); DivMacroInt* getChanMacroInt(int ch); unsigned short getPan(int chan); + DivChannelPair getPaired(int chan); DivDispatchOscBuffer* getOscBuffer(int chan); unsigned char* getRegisterPool(); int getRegisterPoolSize(); diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4fa69a16a..67d631521 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -6353,6 +6353,7 @@ bool FurnaceGUI::init() { } else { patChannelNames=e->getConfBool("patChannelNames",false); } + patChannelPairs=e->getConfBool("patChannelPairs",true); patChannelHints=e->getConfInt("patChannelHints",0); lockLayout=e->getConfBool("lockLayout",false); #ifdef IS_MOBILE @@ -6893,6 +6894,7 @@ void FurnaceGUI::commitState() { e->setConf("waveEditStyle",waveEditStyle); e->setConf("patExtraButtons",patExtraButtons); e->setConf("patChannelNames",patChannelNames); + e->setConf("patChannelPairs",patChannelPairs); e->setConf("patChannelHints",(int)patChannelHints); e->setConf("lockLayout",lockLayout); e->setConf("fullScreen",fullScreen); @@ -7145,7 +7147,7 @@ FurnaceGUI::FurnaceGUI(): exportFadeOut(5.0), patExtraButtons(false), patChannelNames(false), - patChannelPairs(false), + patChannelPairs(true), patChannelHints(0), newSongFirstFrame(false), oldRowChanged(false),