GUI: add Namco C163 chip name option

This commit is contained in:
tildearrow 2022-07-21 15:21:29 -05:00
parent 5aa287eece
commit f6b45d3d9b
6 changed files with 38 additions and 6 deletions

View file

@ -53,6 +53,11 @@ the coding style is described here:
- don't use `auto` unless needed. - don't use `auto` unless needed.
- use `String` for `std::string` (this is typedef'd in ta-utils.h). - use `String` for `std::string` (this is typedef'd in ta-utils.h).
- prefer using operator for String (std::string) comparisons (a==""). - 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. some files (particularly the ones in `src/engine/platform/sound` and `extern/`) don't follow this style.

View file

@ -355,6 +355,7 @@ class DivEngine {
short vibTable[64]; short vibTable[64];
int reversePitchTable[4096]; int reversePitchTable[4096];
int pitchTable[4096]; int pitchTable[4096];
char c163NameCS[1024];
int midiBaseChan; int midiBaseChan;
bool midiPoly; bool midiPoly;
size_t midiAgeCounter; size_t midiAgeCounter;

View file

@ -54,7 +54,7 @@ std::vector<DivInstrumentType>& DivEngine::getPossibleInsTypes() {
return possibleInsTypes; 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) { String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) {
switch (song.systemLen) { switch (song.systemLen) {
case 0: case 0:
@ -177,7 +177,9 @@ String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) {
return "Famicom Disk System"; return "Famicom Disk System";
} }
if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_N163) { 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) { if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_MMC5) {
return "Famicom + MMC5"; return "Famicom + MMC5";
@ -205,14 +207,23 @@ String DivEngine::getSongSystemName(bool isMultiSystemAcceptable) {
String ret=""; String ret="";
for (int i=0; i<song.systemLen; i++) { for (int i=0; i<song.systemLen; i++) {
if (i>0) ret+=" + "; if (i>0) ret+=" + ";
if (song.system[i]==DIV_SYSTEM_N163) {
ret+=getConfString("c163Name","Namco C163");
} else {
ret+=getSystemName(song.system[i]); ret+=getSystemName(song.system[i]);
} }
}
return ret; return ret;
} }
const char* DivEngine::getSystemName(DivSystem sys) { const char* DivEngine::getSystemName(DivSystem sys) {
if (sysDefs[sys]==NULL) return "Unknown"; 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; return sysDefs[sys]->name;
} }

View file

@ -1099,6 +1099,7 @@ class FurnaceGUI {
String audioDevice; String audioDevice;
String midiInDevice; String midiInDevice;
String midiOutDevice; String midiOutDevice;
String c163Name;
std::vector<int> initialSys; std::vector<int> initialSys;
Settings(): Settings():
@ -1201,7 +1202,8 @@ class FurnaceGUI {
patFontPath(""), patFontPath(""),
audioDevice(""), audioDevice(""),
midiInDevice(""), midiInDevice(""),
midiOutDevice("") {} midiOutDevice(""),
c163Name("") {}
} settings; } settings;
char finalLayoutPath[4096]; char finalLayoutPath[4096];

View file

@ -3063,7 +3063,7 @@ void FurnaceGUI::drawInsEdit() {
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::EndTabItem(); 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 (ImGui::InputInt("Waveform##WAVE",&ins->n163.wave,1,10)) { PARAMETER
if (ins->n163.wave<0) ins->n163.wave=0; if (ins->n163.wave<0) ins->n163.wave=0;
if (ins->n163.wave>=e->song.waveLen) ins->n163.wave=e->song.waveLen-1; if (ins->n163.wave>=e->song.waveLen) ins->n163.wave=e->song.waveLen-1;

View file

@ -1156,6 +1156,12 @@ void FurnaceGUI::drawSettings() {
ImGui::Separator(); ImGui::Separator();
ImGui::Text("N163/C163 chip name");
ImGui::SameLine();
ImGui::InputTextWithHint("##C163Name","Namco C163",&settings.c163Name);
ImGui::Separator();
bool insEditColorizeB=settings.insEditColorize; bool insEditColorizeB=settings.insEditColorize;
if (ImGui::Checkbox("Colorize instrument editor using instrument type",&insEditColorizeB)) { if (ImGui::Checkbox("Colorize instrument editor using instrument type",&insEditColorizeB)) {
settings.insEditColorize=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_OPL,"FM (OPL)");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_FDS,"FDS"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_FDS,"FDS");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_VBOY,"Virtual Boy"); 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_SCC,"Konami SCC");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPZ,"FM (OPZ)"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_OPZ,"FM (OPZ)");
UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEY,"POKEY"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEY,"POKEY");
@ -1972,6 +1982,8 @@ void FurnaceGUI::syncSettings() {
settings.audioDevice=e->getConfString("audioDevice",""); settings.audioDevice=e->getConfString("audioDevice","");
settings.midiInDevice=e->getConfString("midiInDevice",""); settings.midiInDevice=e->getConfString("midiInDevice","");
settings.midiOutDevice=e->getConfString("midiOutDevice",""); 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.audioQuality=e->getConfInt("audioQuality",0);
settings.audioBufSize=e->getConfInt("audioBufSize",1024); settings.audioBufSize=e->getConfInt("audioBufSize",1024);
settings.audioRate=e->getConfInt("audioRate",44100); settings.audioRate=e->getConfInt("audioRate",44100);
@ -2194,6 +2206,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("audioDevice",settings.audioDevice); e->setConf("audioDevice",settings.audioDevice);
e->setConf("midiInDevice",settings.midiInDevice); e->setConf("midiInDevice",settings.midiInDevice);
e->setConf("midiOutDevice",settings.midiOutDevice); e->setConf("midiOutDevice",settings.midiOutDevice);
e->setConf("c163Name",settings.c163Name);
e->setConf("audioQuality",settings.audioQuality); e->setConf("audioQuality",settings.audioQuality);
e->setConf("audioBufSize",settings.audioBufSize); e->setConf("audioBufSize",settings.audioBufSize);
e->setConf("audioRate",settings.audioRate); e->setConf("audioRate",settings.audioRate);