Skip to content

Commit

Permalink
dev183 - prepare for better DPCM mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
tildearrow committed Oct 13, 2023
1 parent ddf0e3f commit 7ede07e
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 278 deletions.
4 changes: 2 additions & 2 deletions src/engine/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class DivWorkPool;

#define DIV_UNSTABLE

#define DIV_VERSION "dev182"
#define DIV_ENGINE_VERSION 182
#define DIV_VERSION "dev183"
#define DIV_ENGINE_VERSION 183
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02
Expand Down
39 changes: 39 additions & 0 deletions src/engine/instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,21 @@ void DivInstrument::writeFeatureX1(SafeWriter* w) {
FEATURE_END;
}

void DivInstrument::writeFeatureNE(SafeWriter* w) {
FEATURE_BEGIN("NE");

w->writeC(amiga.useNoteMap?1:0);

if (amiga.useNoteMap) {
for (int note=0; note<120; note++) {
w->writeC(amiga.noteMap[note].dpcmFreq);
w->writeC(amiga.noteMap[note].dpcmDelta);
}
}

FEATURE_END;
}

void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bool insName) {
size_t blockStartSeek=0;
size_t blockEndSeek=0;
Expand Down Expand Up @@ -761,6 +776,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
bool featureSU=false;
bool featureES=false;
bool featureX1=false;
bool featureNE=false;

bool checkForWL=false;

Expand Down Expand Up @@ -904,6 +920,8 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
featureFM=true;
break;
case DIV_INS_NES:
featureSM=true;
featureNE=true;
break;
case DIV_INS_MSM6258:
featureSM=true;
Expand Down Expand Up @@ -993,6 +1011,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
}
if (amiga!=defaultIns.amiga) {
featureSM=true;
featureNE=true;
}
if (snes!=defaultIns.snes) {
featureSN=true;
Expand Down Expand Up @@ -1157,6 +1176,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
if (featureX1) {
writeFeatureX1(w);
}
if (featureNE) {
writeFeatureNE(w);
}

if (fui && (featureSL || featureWL)) {
w->write("EN",2);
Expand Down Expand Up @@ -2541,6 +2563,21 @@ void DivInstrument::readFeatureX1(SafeReader& reader, short version) {
READ_FEAT_END;
}

void DivInstrument::readFeatureNE(SafeReader& reader, short version) {
READ_FEAT_BEGIN;

amiga.useNoteMap=reader.readC();

if (amiga.useNoteMap) {
for (int note=0; note<120; note++) {
amiga.noteMap[note].dpcmFreq=reader.readC();
amiga.noteMap[note].dpcmDelta=reader.readC();
}
}

READ_FEAT_END;
}

DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song) {
unsigned char featCode[2];

Expand Down Expand Up @@ -2606,6 +2643,8 @@ DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, b
readFeatureES(reader,version);
} else if (memcmp(featCode,"X1",2)==0) { // X1-010
readFeatureX1(reader,version);
} else if (memcmp(featCode,"NE",2)==0) { // NES (DPCM)
readFeatureNE(reader,version);
} else {
if (song==NULL && (memcmp(featCode,"SL",2)==0 || (memcmp(featCode,"WL",2)==0))) {
// nothing
Expand Down
10 changes: 8 additions & 2 deletions src/engine/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,13 @@ struct DivInstrumentAmiga {
struct SampleMap {
int freq;
short map;
SampleMap(int f=0, short m=-1):
signed char dpcmFreq;
signed char dpcmDelta;
SampleMap(int f=0, short m=-1, signed char df=15, signed char dd=-1):
freq(f),
map(m) {}
map(m),
dpcmFreq(df),
dpcmDelta(dd) {}
};
short initSample;
bool useNoteMap;
Expand Down Expand Up @@ -759,6 +763,7 @@ struct DivInstrument {
void writeFeatureSU(SafeWriter* w);
void writeFeatureES(SafeWriter* w);
void writeFeatureX1(SafeWriter* w);
void writeFeatureNE(SafeWriter* w);

void readFeatureNA(SafeReader& reader, short version);
void readFeatureFM(SafeReader& reader, short version);
Expand All @@ -778,6 +783,7 @@ struct DivInstrument {
void readFeatureSU(SafeReader& reader, short version);
void readFeatureES(SafeReader& reader, short version);
void readFeatureX1(SafeReader& reader, short version);
void readFeatureNE(SafeReader& reader, short version);

DivDataErrors readInsDataOld(SafeReader& reader, short version);
DivDataErrors readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song);
Expand Down
4 changes: 2 additions & 2 deletions src/engine/sysDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ void DivEngine::registerSystems() {
{"Pulse 1", "Pulse 2", "Triangle", "Noise", "DPCM"},
{"S1", "S2", "TR", "NO", "DMC"},
{DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_WAVE, DIV_CH_NOISE, DIV_CH_PCM},
{DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_AMIGA},
{},
{DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_NES},
{DIV_INS_NULL, DIV_INS_NULL, DIV_INS_NULL, DIV_INS_NULL, DIV_INS_AMIGA},
{
{0x11, {DIV_CMD_NES_DMC, "11xx: Write to delta modulation counter (0 to 7F)"}},
{0x12, {DIV_CMD_STD_NOISE_MODE, "12xx: Set duty cycle/noise mode (pulse: 0 to 3; noise: 0 or 1)"}},
Expand Down
2 changes: 2 additions & 0 deletions src/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2260,6 +2260,8 @@ class FurnaceGUI {
void drawMacros(std::vector<FurnaceGUIMacroDesc>& macros, FurnaceGUIMacroEditState& state);
void alterSampleMap(bool isNote, int val);

void insTabSample(DivInstrument* ins);

void drawOrderButtons();

void actualWaveList();
Expand Down
Loading

0 comments on commit 7ede07e

Please sign in to comment.