diff --git a/src/engine/platform/powernoise.cpp b/src/engine/platform/powernoise.cpp index 422ef73e5..c6aa92a29 100644 --- a/src/engine/platform/powernoise.cpp +++ b/src/engine/platform/powernoise.cpp @@ -23,19 +23,20 @@ #include "furIcons.h" #include -#define rWrite(a,v) if (!skipRegisterWrites) {regPool[a] = (v); pwrnoise_write(&pn, (unsigned char)(a), (unsigned char)(v)); if (dumpWrites) {addWrite(a,v);} } -#define cWrite(c,a,v) rWrite((c << 3) | ((a) + 1), (v)) -#define noiseCtl(enable, am, tapB) (((enable) ? 0x80 : 0x00) | ((am) ? 0x02 : 0x00) | ((tapB) ? 0x01 : 0x00)) -#define slopeCtl(enable, rst, a, b) (((enable) ? 0x80 : 0x00) | \ - (rst ? 0x40 : 0x00) | \ - (a.clip ? 0x20 : 0x00) | \ - (b.clip ? 0x10 : 0x00) | \ - (a.reset ? 0x08 : 0x00) | \ - (b.reset ? 0x04 : 0x00) | \ - (a.dir ? 0x02 : 0x00) | \ - (b.dir ? 0x01 : 0x00)) -#define volPan(v, p) (((v * (p >> 4) / 15) << 4) | ((v * (p & 0xf) / 15) & 0xf)) -#define mapAmp(a) ((((a) * 65535 / 63 - 32768) * (pn.flags & 0x7) / 7) >> 1) +#define rWrite(a,v) if (!skipRegisterWrites) {regPool[a]=(v); pwrnoise_write(&pn,(unsigned char)(a),(unsigned char)(v)); if (dumpWrites) {addWrite(a,v);}} +#define cWrite(c,a,v) rWrite((c<<3)|((a)+1),(v)) +#define noiseCtl(enable,am,tapB) (((enable)?0x80:0x00)|((am)?0x02:0x00)|((tapB)?0x01:0x00)) +#define slopeCtl(enable,rst,a,b) (((enable)?0x80:0x00)| \ + (rst?0x40:0x00)| \ + (a.clip?0x20:0x00)| \ + (b.clip?0x10:0x00)| \ + (a.reset?0x08:0x00)| \ + (b.reset?0x04:0x00)| \ + (a.dir?0x02:0x00)| \ + (b.dir?0x01:0x00)) +#define volPan(v,p) (((v*(p>>4)/15)<<4)|((v*(p&0xf)/15)&0xf)) +// TODO: optimize! +#define mapAmp(a) ((((a)*65535/63-32768)*(pn.flags&0x7)/7)>>1) #define CHIP_DIVIDER 128 const char* regCheatSheetPowerNoise[]={ @@ -285,20 +286,19 @@ int DivPlatformPowerNoise::dispatch(DivCommand c) { switch (c.cmd) { case DIV_CMD_NOTE_ON: { DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_POWERNOISE); - if (ins->type==DIV_INS_POWERNOISE) { - if (skipRegisterWrites) break; - if (c.value!=DIV_NOTE_NULL) { - chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); - chan[c.chan].freqChanged=true; - chan[c.chan].note=c.value; - } - chan[c.chan].active=true; - chan[c.chan].macroInit(ins); - if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) { - chan[c.chan].outVol=chan[c.chan].vol; - } - chan[c.chan].keyOn=true; + // ?????? + if (skipRegisterWrites) break; + if (c.value!=DIV_NOTE_NULL) { + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); + chan[c.chan].freqChanged=true; + chan[c.chan].note=c.value; } + chan[c.chan].active=true; + chan[c.chan].macroInit(ins); + if (!parent->song.brokenOutVol && !chan[c.chan].std.vol.will) { + chan[c.chan].outVol=chan[c.chan].vol; + } + chan[c.chan].keyOn=true; chan[c.chan].insChanged=false; break; } diff --git a/src/gui/gui.h b/src/gui/gui.h index fc0a495b4..132032bc9 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -292,6 +292,7 @@ enum FurnaceGUIColors { GUI_COLOR_INSTR_C219, GUI_COLOR_INSTR_ESFM, GUI_COLOR_INSTR_POWERNOISE, + GUI_COLOR_INSTR_POWERNOISE_SLOPE, GUI_COLOR_INSTR_UNKNOWN, GUI_COLOR_CHANNEL_BG, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 7991ac187..ff92b38f7 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -989,6 +989,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_INSTR_C219,"",ImVec4(1.0f,0.8f,0.0f,1.0f)), D(GUI_COLOR_INSTR_ESFM,"",ImVec4(0.1f,0.9f,1.0f,1.0f)), D(GUI_COLOR_INSTR_POWERNOISE,"",ImVec4(1.0f,1.0f,0.8f,1.0f)), + D(GUI_COLOR_INSTR_POWERNOISE_SLOPE,"",ImVec4(1.0f,0.6f,0.3f,1.0f)), D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)), D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)), diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 7f64ad565..5907b600c 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -6909,6 +6909,9 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_POWERNOISE) { dutyMax=0; } + if (ins->type==DIV_INS_POWERNOISE_SLOPE) { + dutyMax=0; + } const char* waveLabel="Waveform"; int waveMax=(ins->type==DIV_INS_VERA)?3:(MAX(1,e->song.waveLen-1)); @@ -6944,6 +6947,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_C140) waveMax=0; if (ins->type==DIV_INS_C219) waveMax=0; if (ins->type==DIV_INS_POWERNOISE) waveMax=0; + if (ins->type==DIV_INS_POWERNOISE_SLOPE) waveMax=0; if (ins->type==DIV_INS_SU || ins->type==DIV_INS_POKEY) waveMax=7; if (ins->type==DIV_INS_PET) { waveMax=8; @@ -7085,6 +7089,9 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_POWERNOISE) { panMax=15; } + if (ins->type==DIV_INS_POWERNOISE_SLOPE) { + panMax=15; + } if (volMax>0) { macroList.push_back(FurnaceGUIMacroDesc(volumeLabel,&ins->std.volMacro,volMin,volMax,160,uiColors[GUI_COLOR_MACRO_VOLUME])); @@ -7173,7 +7180,8 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_C219 || ins->type==DIV_INS_TED || ins->type==DIV_INS_ESFM || - ins->type==DIV_INS_POWERNOISE) { + ins->type==DIV_INS_POWERNOISE || + ins->type==DIV_INS_POWERNOISE_SLOPE) { macroList.push_back(FurnaceGUIMacroDesc("Phase Reset",&ins->std.phaseResetMacro,0,1,32,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); } if (ex1Max>0) { @@ -7268,13 +7276,16 @@ void FurnaceGUI::drawInsEdit() { } if (ins->type==DIV_INS_POWERNOISE) { macroList.push_back(FurnaceGUIMacroDesc("Control",&ins->std.ex1Macro,0,6,96,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,powernoiseControlBits)); - macroList.push_back(FurnaceGUIMacroDesc("Portion A Length",&ins->std.ex2Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("Portion B Length",&ins->std.ex3Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc("Tap A Location",&ins->std.ex4Macro,0,15,96,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc("Tap B Location",&ins->std.ex5Macro,0,15,96,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Load LFSR",&ins->std.ex8Macro,0,16,256,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); + } + if (ins->type==DIV_INS_POWERNOISE_SLOPE) { + macroList.push_back(FurnaceGUIMacroDesc("Control",&ins->std.ex1Macro,0,6,96,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true,powernoiseControlBits)); + macroList.push_back(FurnaceGUIMacroDesc("Portion A Length",&ins->std.ex2Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); + macroList.push_back(FurnaceGUIMacroDesc("Portion B Length",&ins->std.ex3Macro,0,255,128,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc("Portion A Offset",&ins->std.ex6Macro,0,15,96,uiColors[GUI_COLOR_MACRO_OTHER])); macroList.push_back(FurnaceGUIMacroDesc("Portion B Offset",&ins->std.ex7Macro,0,15,96,uiColors[GUI_COLOR_MACRO_OTHER])); - macroList.push_back(FurnaceGUIMacroDesc("Load LFSR",&ins->std.ex8Macro,0,16,256,uiColors[GUI_COLOR_MACRO_OTHER],false,NULL,NULL,true)); } drawMacros(macroList,macroEditStateMacros); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 2ec4a0fd2..049044cc4 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -3493,6 +3493,10 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_INSTR_PV1000,"PV-1000"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_K053260,"K053260"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_C140,"C140"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_C219,"C219"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_ESFM,"ESFM"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_POWERNOISE,"PowerNoise (noise)"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_POWERNOISE_SLOPE,"PowerNoise (slope)"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_UNKNOWN,"Other/Unknown"); ImGui::TreePop(); }