From f6b45d3d9bee96d661fcfc5a19f63d21379bcbee Mon Sep 17 00:00:00 2001 From: tildearrow Date: Thu, 21 Jul 2022 15:21:29 -0500 Subject: [PATCH] GUI: add Namco C163 chip name option --- CONTRIBUTING.md | 5 +++++ src/engine/engine.h | 1 + src/engine/sysDef.cpp | 17 ++++++++++++++--- src/gui/gui.h | 4 +++- src/gui/insEdit.cpp | 2 +- src/gui/settings.cpp | 15 ++++++++++++++- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97efdf8cd..51903d8b7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,6 +53,11 @@ the coding style is described here: - don't use `auto` unless needed. - use `String` for `std::string` (this is typedef'd in ta-utils.h). - prefer using operator for String (std::string) comparisons (a==""). +- if you have to work with C strings, only use safe C string operations: + - snprintf + - strncpy + - strncat + - any other operation which specifies a limit some files (particularly the ones in `src/engine/platform/sound` and `extern/`) don't follow this style. diff --git a/src/engine/engine.h b/src/engine/engine.h index 4bf4cb65d..896c083a2 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -355,6 +355,7 @@ class DivEngine { short vibTable[64]; int reversePitchTable[4096]; int pitchTable[4096]; + char c163NameCS[1024]; int midiBaseChan; bool midiPoly; size_t midiAgeCounter; diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index a5b689b2b..25e35227f 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -54,7 +54,7 @@ std::vector& DivEngine::getPossibleInsTypes() { return possibleInsTypes; } -// TODO: rewrite this function (again). it's an unreliable mess. +// TODO: deprecate when I add "system name" field in the file. String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) { switch (song.systemLen) { case 0: @@ -177,7 +177,9 @@ String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) { return "Famicom Disk System"; } if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_N163) { - return "Famicom + Namco C163"; + String ret="Famicom + "; + ret+=getConfString("c163Name","Namco C163"); + return ret; } if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_MMC5) { return "Famicom + MMC5"; @@ -205,7 +207,11 @@ String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) { String ret=""; for (int i=0; i0) ret+=" + "; - ret+=getSystemName(song.system[i]); + if (song.system[i]==DIV_SYSTEM_N163) { + ret+=getConfString("c163Name","Namco C163"); + } else { + ret+=getSystemName(song.system[i]); + } } return ret; @@ -213,6 +219,11 @@ String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) { const char* DivEngine::getSystemName(DivSystem sys) { if (sysDefs[sys]==NULL) return "Unknown"; + if (sys==DIV_SYSTEM_N163) { + String c1=getConfString("c163Name","Namco C163"); + strncpy(c163NameCS,c1.c_str(),1023); + return c163NameCS; + } return sysDefs[sys]->name; } diff --git a/src/gui/gui.h b/src/gui/gui.h index 656b358e5..851e10aa1 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -1099,6 +1099,7 @@ class FurnaceGUI { String audioDevice; String midiInDevice; String midiOutDevice; + String c163Name; std::vector initialSys; Settings(): @@ -1201,7 +1202,8 @@ class FurnaceGUI { patFontPath(""), audioDevice(""), midiInDevice(""), - midiOutDevice("") {} + midiOutDevice(""), + c163Name("") {} } settings; char finalLayoutPath[4096]; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 18e286802..81626b777 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -3063,7 +3063,7 @@ void FurnaceGUI::drawInsEdit() { ImGui::EndDisabled(); ImGui::EndTabItem(); } - if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("Namco 163")) { + if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem(settings.c163Name.c_str())) { if (ImGui::InputInt("Waveform##WAVE",&ins->n163.wave,1,10)) { PARAMETER if (ins->n163.wave<0) ins->n163.wave=0; if (ins->n163.wave>=e->song.waveLen) ins->n163.wave=e->song.waveLen-1; diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 9984e4996..2d05ab5ac 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1156,6 +1156,12 @@ void FurnaceGUI::drawSettings() { ImGui::Separator(); + ImGui::Text("N163/C163 chip name"); + ImGui::SameLine(); + ImGui::InputTextWithHint("##C163Name","Namco C163",&settings.c163Name); + + ImGui::Separator(); + bool insEditColorizeB=settings.insEditColorize; if (ImGui::Checkbox("Colorize instrument editor using instrument type",&insEditColorizeB)) { settings.insEditColorize=insEditColorizeB; @@ -1453,7 +1459,11 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPL,"FM (OPL)"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_FDS,"FDS"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_VBOY,"Virtual Boy"); - UI_COLOR_CONFIG(GUI_COLOR_INSTR_N163,"Namco 163"); + // special case + String c163Label=fmt::sprintf("%s##CC_GUI_COLOR_INSTR_N163",settings.c163Name); + if (ImGui::ColorEdit4(c163Label.c_str(),(float*)&uiColors[GUI_COLOR_INSTR_N163])) { + applyUISettings(false); + } UI_COLOR_CONFIG(GUI_COLOR_INSTR_SCC,"Konami SCC"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPZ,"FM (OPZ)"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEY,"POKEY"); @@ -1972,6 +1982,8 @@ void FurnaceGUI::syncSettings() { settings.audioDevice=e->getConfString("audioDevice",""); settings.midiInDevice=e->getConfString("midiInDevice",""); settings.midiOutDevice=e->getConfString("midiOutDevice",""); + // I'm sorry, but the C163 education program has failed... + settings.c163Name=e->getConfString("c163Name","Namco C163"); settings.audioQuality=e->getConfInt("audioQuality",0); settings.audioBufSize=e->getConfInt("audioBufSize",1024); settings.audioRate=e->getConfInt("audioRate",44100); @@ -2194,6 +2206,7 @@ void FurnaceGUI::commitSettings() { e->setConf("audioDevice",settings.audioDevice); e->setConf("midiInDevice",settings.midiInDevice); e->setConf("midiOutDevice",settings.midiOutDevice); + e->setConf("c163Name",settings.c163Name); e->setConf("audioQuality",settings.audioQuality); e->setConf("audioBufSize",settings.audioBufSize); e->setConf("audioRate",settings.audioRate);