use enum for readability, fixes, tweaks, new chip cases

This commit is contained in:
Eknous-P 2024-08-18 23:01:24 +04:00
parent e50b3438f2
commit e549d09360
3 changed files with 71 additions and 39 deletions

View file

@ -235,26 +235,26 @@ const char* fxColorsNames[]={
_N("Miscellaneous") _N("Miscellaneous")
}; };
const char* chanNames[]={ const char* chanNames[CHANNEL_TYPE_MAX+1]={
"FM", _N("FM"),
"Pulse", _N("Pulse"),
"Noise", _N("Noise"),
"Wavetable", _N("Wavetable"),
"Sample", _N("Sample"),
// the "freaks": // the "freaks":
"Square", _N("Square"),
"Triangle", // nes _N("Triangle"), // NES
"Ext. Operator", _N("Saw"), // VRC6
"Drums", _N("Ext. Operator"),
"Slope", // powernoiseee _N("Drums"),
"VERA", // Daviiid!! _N("Slope"), // PowerNoise
_N("Wave"), // not wavetable (VERA, 5E01)
"Channel", // if neither _N("Channel"), // if neither
"Channels" // in case this makes l10n easier _N("Channels") // in case this makes l10n easier
}; };
// because someone will complain about the ordering unsigned char chanNamesHierarchy[CHANNEL_TYPE_MAX+1]={0,5,1,3,6,7,2,10,11,9,4,8,12,13};
unsigned char chanNamesHierarchy[]={0,5,1,2,3,6,9,10,8,4,7,11,12};
const FurnaceGUIColors fxColors[256]={ const FurnaceGUIColors fxColors[256]={
GUI_COLOR_PATTERN_EFFECT_MISC, // 00 GUI_COLOR_PATTERN_EFFECT_MISC, // 00

View file

@ -19,6 +19,27 @@
// guiConst: constants used in the GUI like arrays, strings and other stuff // guiConst: constants used in the GUI like arrays, strings and other stuff
enum FurnaceGUIChanTypes {
// the first five match DivChanTypes, do not change order!
CHANNEL_TYPE_FM,
CHANNEL_TYPE_PULSE,
CHANNEL_TYPE_NOISE,
CHANNEL_TYPE_WAVETABLE,
CHANNEL_TYPE_SAMPLE,
CHANNEL_TYPE_SQUARE,
CHANNEL_TYPE_TRIANGLE,
CHANNEL_TYPE_SAW,
CHANNEL_TYPE_OPERATOR,
CHANNEL_TYPE_DRUMS,
CHANNEL_TYPE_SLOPE,
CHANNEL_TYPE_WAVE,
CHANNEL_TYPE_OTHER,
CHANNEL_TYPE_MAX
};
struct FurnaceGUIActionDef { struct FurnaceGUIActionDef {
const char* name; const char* name;
const char* friendlyName; const char* friendlyName;

View file

@ -303,9 +303,10 @@ void FurnaceGUI::drawSystemChannelInfo(const DivSysDef* whichDef) {
void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) { void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {
String info=""; String info="";
// same order as chanNames // same order as chanNames
// helper: FM|PU|NO|WA|SA|SQ|TR|OP|DR|SL|VE|CH // helper: FM|PU|NO|WA|SA|SQ|TR|SW|OP|DR|SL|VE|CH
unsigned char chanCount[12]; unsigned char chanCount[CHANNEL_TYPE_MAX];
memset(chanCount,0,sizeof(chanCount)); memset(chanCount,0,CHANNEL_TYPE_MAX);
// count channel types
for (int i=0; i<whichDef->channels; i++) { for (int i=0; i<whichDef->channels; i++) {
switch (whichDef->chanInsType[i][0]) { switch (whichDef->chanInsType[i][0]) {
case DIV_INS_STD: // square case DIV_INS_STD: // square
@ -313,23 +314,24 @@ void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {
case DIV_INS_TED: case DIV_INS_TED:
case DIV_INS_VIC: case DIV_INS_VIC:
case DIV_INS_T6W28: case DIV_INS_T6W28:
case DIV_INS_PV1000:
if (whichDef->id==0xfd) { // dummy if (whichDef->id==0xfd) { // dummy
chanCount[11]++; chanCount[CHANNEL_TYPE_OTHER]++;
break; break;
} }
if (whichDef->id==0x9f) { // zx sfx if (whichDef->id==0x9f) { // zx sfx
chanCount[1]++; chanCount[CHANNEL_TYPE_PULSE]++;
break; break;
} }
if (whichDef->chanTypes[i]==DIV_CH_NOISE) { // sn/t6w noise if (whichDef->chanTypes[i]==DIV_CH_NOISE) { // sn/t6w noise
chanCount[2]++; chanCount[CHANNEL_TYPE_NOISE]++;
} else { // DIV_CH_PULSE, any sqr chan } else { // DIV_CH_PULSE, any sqr chan
chanCount[5]++; chanCount[CHANNEL_TYPE_SQUARE]++;
} }
break; break;
case DIV_INS_NES: case DIV_INS_NES:
if (whichDef->chanTypes[i]==DIV_CH_WAVE) { if (whichDef->chanTypes[i]==DIV_CH_WAVE) {
chanCount[6]++; // triangle chanCount[whichDef->id==0xf1?CHANNEL_TYPE_WAVE:CHANNEL_TYPE_TRIANGLE]++; // triangle, wave for 5E01
} else { } else {
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
} }
@ -338,46 +340,53 @@ void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {
case DIV_INS_OPL: case DIV_INS_OPL:
case DIV_INS_OPLL: case DIV_INS_OPLL:
if (whichDef->chanTypes[i]==DIV_CH_OP) { if (whichDef->chanTypes[i]==DIV_CH_OP) {
chanCount[0]++; // opl3 4op chanCount[CHANNEL_TYPE_FM]++; // opl3 4op
break; break;
} }
if (whichDef->chanTypes[i]==DIV_CH_NOISE) { if (whichDef->chanTypes[i]==DIV_CH_NOISE) {
chanCount[8]++; // drums chanCount[CHANNEL_TYPE_DRUMS]++; // drums
} else { } else {
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
} }
break; break;
case DIV_INS_FM: case DIV_INS_FM:
if (whichDef->chanTypes[i]==DIV_CH_OP) { if (whichDef->chanTypes[i]==DIV_CH_OP) {
chanCount[7]++; // ext. ops chanCount[CHANNEL_TYPE_OPERATOR]++; // ext. ops
} else if (whichDef->chanTypes[i]==DIV_CH_NOISE) { } else if (whichDef->chanTypes[i]==DIV_CH_NOISE) {
break; // csm timer break; // csm timer
} else { } else {
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
} }
break; break;
case DIV_INS_ADPCMA:
case DIV_INS_ADPCMB:
chanCount[CHANNEL_TYPE_SAMPLE]++;
break;
case DIV_INS_VRC6_SAW:
chanCount[CHANNEL_TYPE_SAW]++;
break;
case DIV_INS_POWERNOISE_SLOPE: case DIV_INS_POWERNOISE_SLOPE:
chanCount[9]++; chanCount[CHANNEL_TYPE_SLOPE]++;
break; break;
case DIV_INS_QSOUND: case DIV_INS_QSOUND:
chanCount[4]++; chanCount[CHANNEL_TYPE_SAMPLE]++;
break; break;
case DIV_INS_NDS: case DIV_INS_NDS:
if (whichDef->chanTypes[i]!=DIV_CH_PCM) { // the psg chans can also play samples?? if (whichDef->chanTypes[i]!=DIV_CH_PCM) { // the psg chans can also play samples??
chanCount[4]++; chanCount[CHANNEL_TYPE_SAMPLE]++;
} }
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
break; break;
case DIV_INS_VERA: case DIV_INS_VERA:
if (whichDef->chanTypes[i]==DIV_CH_PULSE) { if (whichDef->chanTypes[i]==DIV_CH_PULSE) {
chanCount[10]++; chanCount[CHANNEL_TYPE_WAVE]++;
} else { // sample chan } else { // sample chan
chanCount[4]++; chanCount[CHANNEL_TYPE_SAMPLE]++;
} }
break; break;
case DIV_INS_DAVE: case DIV_INS_DAVE:
if (whichDef->chanTypes[i]==DIV_CH_WAVE) { if (whichDef->chanTypes[i]==DIV_CH_WAVE) {
chanCount[11]++; chanCount[CHANNEL_TYPE_OTHER]++;
} else { } else {
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
} }
@ -388,25 +397,27 @@ void FurnaceGUI::drawSystemChannelInfoText(const DivSysDef* whichDef) {
case DIV_INS_SU: case DIV_INS_SU:
case DIV_INS_POKEY: case DIV_INS_POKEY:
case DIV_INS_MIKEY: case DIV_INS_MIKEY:
chanCount[11]++; case DIV_INS_BIFURCATOR:
case DIV_INS_SID2:
chanCount[CHANNEL_TYPE_OTHER]++;
break; break;
default: default:
chanCount[whichDef->chanTypes[i]]++; chanCount[whichDef->chanTypes[i]]++;
break; break;
} }
} }
// generate string
for (int j=0; j<12; j++) { for (int j=0; j<CHANNEL_TYPE_MAX; j++) {
unsigned char i=chanNamesHierarchy[j]; unsigned char i=chanNamesHierarchy[j];
if (chanCount[i]==0) continue; if (chanCount[i]==0) continue;
if (info.length()!=0) { if (info.length()!=0) {
info+=", "; info+=", ";
} }
if (i==11) { if (i==CHANNEL_TYPE_OTHER) {
if (chanCount[i]>1) { if (chanCount[i]>1) {
info+=fmt::sprintf("%d %s",chanCount[i],chanNames[12]); info+=fmt::sprintf("%d %s",chanCount[i],chanNames[CHANNEL_TYPE_OTHER+1]);
} else { } else {
info+=fmt::sprintf("%d %s",chanCount[i],chanNames[11]); info+=fmt::sprintf("%d %s",chanCount[i],chanNames[CHANNEL_TYPE_OTHER]);
} }
continue; continue;
} }