PowerNoise: split ins type

This commit is contained in:
tildearrow 2024-01-24 04:35:36 -05:00
parent 8fb554af5f
commit efad61c7d0
5 changed files with 47 additions and 30 deletions

View file

@ -23,19 +23,20 @@
#include "furIcons.h"
#include <math.h>
#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;
}

View file

@ -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,

View file

@ -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)),

View file

@ -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);

View file

@ -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();
}