diff --git a/src/engine/instrument.h b/src/engine/instrument.h index a63b2975..7a03e569 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -71,6 +71,7 @@ enum DivInstrumentType: unsigned short { DIV_INS_YMZ280B=41, DIV_INS_RF5C68=42, DIV_INS_MSM5232=43, + DIV_INS_T6W28=44, DIV_INS_MAX, DIV_INS_NULL }; diff --git a/src/engine/platform/t6w28.cpp b/src/engine/platform/t6w28.cpp index 9c0c374d..6ff4cc12 100644 --- a/src/engine/platform/t6w28.cpp +++ b/src/engine/platform/t6w28.cpp @@ -72,8 +72,10 @@ void DivPlatformT6W28::acquire(short* bufL, short* bufR, size_t start, size_t le } void DivPlatformT6W28::writeOutVol(int ch) { - rWrite(1,0x90|(ch<<5)|(isMuted[ch]?15:(15-(chan[ch].outVol&15)))); - rWrite(0,0x90|(ch<<5)|(isMuted[ch]?15:(15-(chan[ch].outVol&15)))); + int left=15-CLAMP(chan[ch].outVol+chan[ch].panL-15,0,15); + int right=15-CLAMP(chan[ch].outVol+chan[ch].panR-15,0,15); + rWrite(0,0x90|(ch<<5)|(isMuted[ch]?15:left)); + rWrite(1,0x90|(ch<<5)|(isMuted[ch]?15:right)); } void DivPlatformT6W28::tick(bool sysTick) { @@ -90,12 +92,10 @@ void DivPlatformT6W28::tick(bool sysTick) { chan[i].freqChanged=true; } if (chan[i].std.panL.had) { - chan[i].pan&=0x0f; - chan[i].pan|=(chan[i].std.panL.val&15)<<4; + chan[i].panL=chan[i].std.panL.val&15; } if (chan[i].std.panR.had) { - chan[i].pan&=0xf0; - chan[i].pan|=chan[i].std.panR.val&15; + chan[i].panR=chan[i].std.panR.val&15; } if (chan[i].std.vol.had || chan[i].std.panL.had || chan[i].std.panR.had) { writeOutVol(i); @@ -208,7 +208,9 @@ int DivPlatformT6W28::dispatch(DivCommand c) { chan[c.chan].noise=c.value; break; case DIV_CMD_PANNING: { - chan[c.chan].pan=(c.value&0xf0)|(c.value2>>4); + chan[c.chan].panL=c.value>>4; + chan[c.chan].panR=c.value2>>4; + writeOutVol(c.chan); break; } case DIV_CMD_LEGATO: diff --git a/src/engine/platform/t6w28.h b/src/engine/platform/t6w28.h index ab8a8175..bc445991 100644 --- a/src/engine/platform/t6w28.h +++ b/src/engine/platform/t6w28.h @@ -29,7 +29,7 @@ class DivPlatformT6W28: public DivDispatch { struct Channel { int freq, baseFreq, pitch, pitch2, note; int ins; - unsigned char pan; + unsigned char panL, panR; bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise; signed char vol, outVol; DivMacroInt std; @@ -44,7 +44,8 @@ class DivPlatformT6W28: public DivDispatch { pitch2(0), note(0), ins(-1), - pan(255), + panL(15), + panR(15), active(false), insChanged(true), freqChanged(false), diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 779f2ca9..a0415bf6 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1660,7 +1660,7 @@ void DivEngine::registerSystems() { {"Square 1", "Square 2", "Square 3", "Noise"}, {"S1", "S2", "S3", "NO"}, {DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_NOISE}, - {DIV_INS_STD, DIV_INS_STD, DIV_INS_STD, DIV_INS_STD}, + {DIV_INS_T6W28, DIV_INS_T6W28, DIV_INS_T6W28, DIV_INS_T6W28}, {}, { {0x20, {DIV_CMD_STD_NOISE_MODE, "20xy: Set noise mode (x: preset/variable; y: thin pulse/noise)"}} diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 9a1740be..f45028ff 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -382,6 +382,10 @@ void FurnaceGUI::drawInsList(bool asChild) { ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_MSM5232]); name=fmt::sprintf(ICON_FA_BAR_CHART "##_INS%d",i); break; + case DIV_INS_T6W28: + ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_T6W28]); + name=fmt::sprintf(ICON_FA_BAR_CHART "##_INS%d",i); + break; default: ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_UNKNOWN]); name=fmt::sprintf(ICON_FA_QUESTION "##_INS%d",i); diff --git a/src/gui/gui.h b/src/gui/gui.h index e95cffc2..136c385f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -171,6 +171,7 @@ enum FurnaceGUIColors { GUI_COLOR_INSTR_YMZ280B, GUI_COLOR_INSTR_RF5C68, GUI_COLOR_INSTR_MSM5232, + GUI_COLOR_INSTR_T6W28, GUI_COLOR_INSTR_UNKNOWN, GUI_COLOR_CHANNEL_BG, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index b7755d15..ce62e7d5 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -124,6 +124,7 @@ const char* insTypes[DIV_INS_MAX+1]={ "YMZ280B", "RF5C68", "MSM5232", + "T6W28", NULL }; @@ -801,6 +802,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_INSTR_YMZ280B,"",ImVec4(0.4f,0.5f,1.0f,1.0f)), D(GUI_COLOR_INSTR_RF5C68,"",ImVec4(1.0f,0.3f,0.3f,1.0f)), D(GUI_COLOR_INSTR_MSM5232,"",ImVec4(0.5f,0.9f,1.0f,1.0f)), + D(GUI_COLOR_INSTR_T6W28,"",ImVec4(1.0f,0.8f,0.1f,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 60403d6b..a22e9dbe 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -4762,7 +4762,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_C64 || ins->type==DIV_INS_SAA1099) { waveBitMode=true; } - if (ins->type==DIV_INS_STD || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_NES) waveMax=0; + if (ins->type==DIV_INS_STD || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_NES || ins->type==DIV_INS_T6W28) waveMax=0; if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_VIC || ins->type==DIV_INS_OPLL) waveMax=15; if (ins->type==DIV_INS_C64) waveMax=4; if (ins->type==DIV_INS_SAA1099) waveMax=2; @@ -4866,7 +4866,7 @@ void FurnaceGUI::drawInsEdit() { } if (ins->type==DIV_INS_X1_010 || ins->type==DIV_INS_PCE || ins->type==DIV_INS_MIKEY || ins->type==DIV_INS_SAA1099 || ins->type==DIV_INS_NAMCO || ins->type==DIV_INS_RF5C68 || - ins->type==DIV_INS_VBOY) { + ins->type==DIV_INS_VBOY || ins->type==DIV_INS_T6W28) { panMax=15; } if (ins->type==DIV_INS_SEGAPCM) { diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index f16f2588..e18c9a00 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1680,6 +1680,7 @@ void FurnaceGUI::drawSettings() { if (ImGui::TreeNode("Instrument Types")) { UI_COLOR_CONFIG(GUI_COLOR_INSTR_FM,"FM (OPN)"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_STD,"SN76489/Sega PSG"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_T6W28,"T6W28"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_GB,"Game Boy"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_C64,"C64"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_AMIGA,"Amiga/Generic Sample");