Skip to content

Commit

Permalink
Merge branch 'tildearrow:ymf278b' into ymf278b
Browse files Browse the repository at this point in the history
  • Loading branch information
YaIiya authored Jul 12, 2024
2 parents cf48a07 + 137f0fb commit 692237b
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 90 deletions.
Binary file added instruments/OPL/detuneexample.fui
Binary file not shown.
16 changes: 16 additions & 0 deletions src/engine/dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,22 @@ enum DivDispatchCmds {
DIV_CMD_BIFURCATOR_STATE_LOAD,
DIV_CMD_BIFURCATOR_PARAMETER,

DIV_CMD_OPL4_PCM_MIX_FM, // (value)
DIV_CMD_OPL4_PCM_MIX_PCM, // (value)
DIV_CMD_OPL4_PCM_LFO, // (value)
DIV_CMD_OPL4_PCM_VIB, // (value)
DIV_CMD_OPL4_PCM_AM, // (value)
DIV_CMD_OPL4_PCM_AR, // (value)
DIV_CMD_OPL4_PCM_D1R, // (value)
DIV_CMD_OPL4_PCM_DL, // (value)
DIV_CMD_OPL4_PCM_D2R, // (value)
DIV_CMD_OPL4_PCM_RC, // (value)
DIV_CMD_OPL4_PCM_RR, // (value)
DIV_CMD_OPL4_PCM_DAMP, // (value)
DIV_CMD_OPL4_PCM_PSEUDO_REVERB, // (value)
DIV_CMD_OPL4_PCM_LFO_RESET, // (value)
DIV_CMD_OPL4_PCM_LEVEL_DIRECT, // (value)

DIV_CMD_MAX
};

Expand Down
3 changes: 2 additions & 1 deletion src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,8 @@ void DivEngine::delUnusedSamples() {
i->type==DIV_INS_C219 ||
i->type==DIV_INS_NDS ||
i->type==DIV_INS_GBA_DMA ||
i->type==DIV_INS_GBA_MINMOD) {
i->type==DIV_INS_GBA_MINMOD ||
i->type==DIV_INS_OPL4PCM) {
if (i->amiga.initSample>=0 && i->amiga.initSample<song.sampleLen) {
isUsed[i->amiga.initSample]=true;
}
Expand Down
46 changes: 46 additions & 0 deletions src/engine/instrument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,15 @@ bool DivInstrumentMultiPCM::operator==(const DivInstrumentMultiPCM& other) {
);
}

bool DivInstrumentOPL4PCM::operator==(const DivInstrumentOPL4PCM& other) {
return (
_C(damp) &&
_C(pseudoReverb) &&
_C(lfoReset) &&
_C(levelDirect)
);
}

bool DivInstrumentWaveSynth::operator==(const DivInstrumentWaveSynth& other) {
return (
_C(wave1) &&
Expand Down Expand Up @@ -848,6 +857,17 @@ void DivInstrument::writeFeatureS2(SafeWriter* w) {
FEATURE_END;
}

void DivInstrument::writeFeatureO4(SafeWriter* w) {
FEATURE_BEGIN("O4");

w->writeC(opl4pcm.damp);
w->writeC(opl4pcm.pseudoReverb);
w->writeC(opl4pcm.lfoReset);
w->writeC(opl4pcm.levelDirect);

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 @@ -894,6 +914,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
bool featureEF=false;
bool featurePN=false;
bool featureS2=false;
bool featureO4=false;

bool checkForWL=false;

Expand Down Expand Up @@ -1137,6 +1158,12 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
feature64=true;
featureS2=true;
break;
case DIV_INS_OPL4PCM:
featureSM=true;
featureSL=true;
featureMP=true;
featureO4=true;
break;
case DIV_INS_MAX:
break;
case DIV_INS_NULL:
Expand Down Expand Up @@ -1193,6 +1220,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
if (sid2!=defaultIns.sid2) {
featureS2=true;
}
if (opl4pcm!=defaultIns.opl4pcm) {
featureO4=true;
}
}

// check ins name
Expand Down Expand Up @@ -1344,6 +1374,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
if (featureS2) {
writeFeatureS2(w);
}
if (featureO4) {
writeFeatureO4(w);
}

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

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

opl4pcm.damp=reader.readC();
opl4pcm.pseudoReverb=reader.readC();
opl4pcm.lfoReset=reader.readC();
opl4pcm.levelDirect=reader.readC();

READ_FEAT_END;
}

DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song) {
unsigned char featCode[2];
bool volIsCutoff=false;
Expand Down Expand Up @@ -2246,6 +2290,8 @@ DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, b
readFeaturePN(reader,version);
} else if (memcmp(featCode,"S2",2)==0) { // SID2
readFeatureS2(reader,version);
} else if (memcmp(featCode,"O4",2)==0) { // OPL4 PCM
readFeatureO4(reader,version);
} else {
if (song==NULL && (memcmp(featCode,"SL",2)==0 || (memcmp(featCode,"WL",2)==0))) {
// nothing
Expand Down
20 changes: 20 additions & 0 deletions src/engine/instrument.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum DivInstrumentType: unsigned short {
DIV_INS_GBA_MINMOD=61,
DIV_INS_BIFURCATOR=62,
DIV_INS_SID2=63, // coincidence!
DIV_INS_OPL4PCM=64,
DIV_INS_MAX,
DIV_INS_NULL
};
Expand Down Expand Up @@ -620,6 +621,22 @@ struct DivInstrumentMultiPCM {
}
};

struct DivInstrumentOPL4PCM {
bool damp, pseudoReverb, lfoReset, levelDirect;

bool operator==(const DivInstrumentOPL4PCM& other);
bool operator!=(const DivInstrumentOPL4PCM& other) {
return !(*this==other);
}

DivInstrumentOPL4PCM():
damp(false),
pseudoReverb(false),
lfoReset(false),
levelDirect(true) {
}
};

enum DivWaveSynthEffects {
DIV_WS_NONE=0,
// one waveform effects
Expand Down Expand Up @@ -879,6 +896,7 @@ struct DivInstrument {
DivInstrumentESFM esfm;
DivInstrumentPowerNoise powernoise;
DivInstrumentSID2 sid2;
DivInstrumentOPL4PCM opl4pcm;

/**
* these are internal functions.
Expand Down Expand Up @@ -906,6 +924,7 @@ struct DivInstrument {
void writeFeatureEF(SafeWriter* w);
void writeFeaturePN(SafeWriter* w);
void writeFeatureS2(SafeWriter* w);
void writeFeatureO4(SafeWriter* w);

void readFeatureNA(SafeReader& reader, short version);
void readFeatureFM(SafeReader& reader, short version);
Expand All @@ -929,6 +948,7 @@ struct DivInstrument {
void readFeatureEF(SafeReader& reader, short version);
void readFeaturePN(SafeReader& reader, short version);
void readFeatureS2(SafeReader& reader, short version);
void readFeatureO4(SafeReader& reader, short version);

DivDataErrors readInsDataOld(SafeReader& reader, short version);
DivDataErrors readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song);
Expand Down
Loading

0 comments on commit 692237b

Please sign in to comment.