From 075f758e4dd65d7886d8e5f363cd7a05dfd49231 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 27 Mar 2022 22:04:01 -0500 Subject: [PATCH] Namco 163 refinements --- papers/format.md | 9 +++++++++ src/engine/engine.h | 4 ++-- src/engine/instrument.cpp | 12 ++++++++++++ src/engine/instrument.h | 4 ++-- src/engine/platform/n163.cpp | 2 +- src/gui/insEdit.cpp | 11 ++++------- 6 files changed, 30 insertions(+), 12 deletions(-) diff --git a/papers/format.md b/papers/format.md index d61e94d43..dd4bcce2d 100644 --- a/papers/format.md +++ b/papers/format.md @@ -29,6 +29,7 @@ furthermore, an `or reserved` indicates this field is always present, but is res the format versions are: +- 73: Furnace dev73 - 72: Furnace dev72 - 71: Furnace dev71 - 70: Furnace dev70 @@ -515,6 +516,14 @@ size | description | - 480 bytes 2?? | note sample × 120 | - 240 bytes + --- | **Namco 163 data** (>=73) + 4 | initial waveform + 1 | wave position + 1 | wave length + 1 | wave mode: + | - bit 1: update on change + | - bit 0: load on playback + 1 | reserved ``` # wavetable diff --git a/src/engine/engine.h b/src/engine/engine.h index 24c3e1352..0751941ee 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -42,8 +42,8 @@ #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_END isBusy.unlock(); softLocked=false; -#define DIV_VERSION "dev72" -#define DIV_ENGINE_VERSION 72 +#define DIV_VERSION "dev73" +#define DIV_ENGINE_VERSION 73 // for imports #define DIV_VERSION_MOD 0xff01 diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 6556bfea9..f3cf9f591 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -387,6 +387,11 @@ void DivInstrument::putInsData(SafeWriter* w) { } // N163 + w->writeI(n163.wave); + w->writeC(n163.wavePos); + w->writeC(n163.waveLen); + w->writeC(n163.waveMode); + w->writeC(0); // reserved } DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) { @@ -743,6 +748,13 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) { } // N163 + if (version>=73) { + n163.wave=reader.readI(); + n163.wavePos=(unsigned char)reader.readC(); + n163.waveLen=(unsigned char)reader.readC(); + n163.waveMode=(unsigned char)reader.readC(); + reader.readC(); // reserved + } return DIV_DATA_SUCCESS; } diff --git a/src/engine/instrument.h b/src/engine/instrument.h index a69800a1f..9d51670c1 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -392,8 +392,8 @@ struct DivInstrumentN163 { DivInstrumentN163(): wave(-1), wavePos(0), - waveLen(0), - waveMode(0) {} + waveLen(32), + waveMode(3) {} }; struct DivInstrument { diff --git a/src/engine/platform/n163.cpp b/src/engine/platform/n163.cpp index 42b55e907..14c2d12db 100644 --- a/src/engine/platform/n163.cpp +++ b/src/engine/platform/n163.cpp @@ -34,7 +34,7 @@ rWriteMask(0x78-(c<<3)+(a&7),v,m) \ } -#define CHIP_FREQBASE (15*65536) +#define CHIP_FREQBASE (15*32768) const char* regCheatSheetN163[]={ "FreqL7", "40", diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index da5b0e519..4d707f81f 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -2043,19 +2043,16 @@ void FurnaceGUI::drawInsEdit() { } ImGui::EndTabItem(); } - if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("N163")) { - ImGui::Text("Initial waveform"); - if (ImGui::InputInt("##WAVE",&ins->n163.wave,1,10)) { PARAMETER + if (ins->type==DIV_INS_N163) if (ImGui::BeginTabItem("Namco 163")) { + 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; } - ImGui::Text("Initial waveform position in RAM"); - if (ImGui::InputInt("##WAVEPOS",&ins->n163.wavePos,1,16)) { PARAMETER + if (ImGui::InputInt("Offset##WAVEPOS",&ins->n163.wavePos,1,16)) { PARAMETER if (ins->n163.wavePos<0) ins->n163.wavePos=0; if (ins->n163.wavePos>255) ins->n163.wavePos=255; } - ImGui::Text("Initial waveform length in RAM"); - if (ImGui::InputInt("##WAVELEN",&ins->n163.waveLen,4,16)) { PARAMETER + if (ImGui::InputInt("Length##WAVELEN",&ins->n163.waveLen,4,16)) { PARAMETER if (ins->n163.waveLen<0) ins->n163.waveLen=0; if (ins->n163.waveLen>252) ins->n163.waveLen=252; ins->n163.waveLen&=0xfc;