WIP: adding ESFM (ESS ES1488/ESS ES1868 etc.) system
This commit is contained in:
parent
256140bc32
commit
779afcb97a
24 changed files with 4705 additions and 167 deletions
|
|
@ -228,6 +228,28 @@ bool DivInstrumentSNES::operator==(const DivInstrumentSNES& other) {
|
|||
);
|
||||
}
|
||||
|
||||
bool DivInstrumentESFM::operator==(const DivInstrumentESFM& other) {
|
||||
return (
|
||||
_C(noise) &&
|
||||
_C(op[0]) &&
|
||||
_C(op[1]) &&
|
||||
_C(op[2]) &&
|
||||
_C(op[3])
|
||||
);
|
||||
}
|
||||
|
||||
bool DivInstrumentESFM::Operator::operator==(const DivInstrumentESFM::Operator& other) {
|
||||
return (
|
||||
_C(delay) &&
|
||||
_C(outLvl) &&
|
||||
_C(modIn) &&
|
||||
_C(left) &&
|
||||
_C(right) &&
|
||||
_C(ct) &&
|
||||
_C(dt)
|
||||
);
|
||||
}
|
||||
|
||||
#undef _C
|
||||
|
||||
#define FEATURE_BEGIN(x) \
|
||||
|
|
@ -734,6 +756,22 @@ void DivInstrument::writeFeatureNE(SafeWriter* w) {
|
|||
FEATURE_END;
|
||||
}
|
||||
|
||||
void DivInstrument::writeFeatureEF(SafeWriter* w) {
|
||||
FEATURE_BEGIN("EF");
|
||||
|
||||
w->writeC(esfm.noise&3);
|
||||
for (int i=0; i<4; i++) {
|
||||
DivInstrumentESFM::Operator& op=esfm.op[i];
|
||||
|
||||
w->writeC(((op.delay&7)<<5)|((op.outLvl&7)<<2)|((op.right&1)<<1)|(op.left&1));
|
||||
w->writeC(op.modIn&7);
|
||||
w->writeC(op.ct);
|
||||
w->writeC(op.dt);
|
||||
}
|
||||
|
||||
FEATURE_END;
|
||||
}
|
||||
|
||||
void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bool insName) {
|
||||
size_t blockStartSeek=0;
|
||||
size_t blockEndSeek=0;
|
||||
|
|
@ -777,6 +815,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
|
|||
bool featureES=false;
|
||||
bool featureX1=false;
|
||||
bool featureNE=false;
|
||||
bool featureEF=false;
|
||||
|
||||
bool checkForWL=false;
|
||||
|
||||
|
|
@ -990,7 +1029,10 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
|
|||
featureSM=true;
|
||||
featureSL=true;
|
||||
break;
|
||||
|
||||
case DIV_INS_ESFM:
|
||||
featureFM=true;
|
||||
featureEF=true;
|
||||
break;
|
||||
case DIV_INS_MAX:
|
||||
break;
|
||||
case DIV_INS_NULL:
|
||||
|
|
@ -1038,6 +1080,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
|
|||
if (x1_010!=defaultIns.x1_010) {
|
||||
featureX1=true;
|
||||
}
|
||||
if (esfm!=defaultIns.esfm) {
|
||||
featureEF=true;
|
||||
}
|
||||
}
|
||||
|
||||
// check ins name
|
||||
|
|
@ -1180,6 +1225,9 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song, bo
|
|||
if (featureNE) {
|
||||
writeFeatureNE(w);
|
||||
}
|
||||
if (featureEF) {
|
||||
writeFeatureEF(w);
|
||||
}
|
||||
|
||||
if (fui && (featureSL || featureWL)) {
|
||||
w->write("EN",2);
|
||||
|
|
@ -2579,6 +2627,31 @@ void DivInstrument::readFeatureNE(SafeReader& reader, short version) {
|
|||
READ_FEAT_END;
|
||||
}
|
||||
|
||||
void DivInstrument::readFeatureEF(SafeReader& reader, short version) {
|
||||
READ_FEAT_BEGIN;
|
||||
|
||||
unsigned char next=reader.readC();
|
||||
esfm.noise = next&3;
|
||||
|
||||
for (int i=0; i<4; i++) {
|
||||
DivInstrumentESFM::Operator& op=esfm.op[i];
|
||||
|
||||
next=reader.readC();
|
||||
op.delay=(next>>5)&7;
|
||||
op.outLvl=(next>>2)&7;
|
||||
op.right=(next>>1)&1;
|
||||
op.left=next&1;
|
||||
|
||||
next=reader.readC();
|
||||
op.modIn=next&7;
|
||||
|
||||
op.ct=reader.readC();
|
||||
op.dt=reader.readC();
|
||||
}
|
||||
|
||||
READ_FEAT_END;
|
||||
}
|
||||
|
||||
DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, bool fui, DivSong* song) {
|
||||
unsigned char featCode[2];
|
||||
|
||||
|
|
@ -2646,6 +2719,8 @@ DivDataErrors DivInstrument::readInsDataNew(SafeReader& reader, short version, b
|
|||
readFeatureX1(reader,version);
|
||||
} else if (memcmp(featCode,"NE",2)==0) { // NES (DPCM)
|
||||
readFeatureNE(reader,version);
|
||||
} else if (memcmp(featCode,"EF",2)==0) { // ESFM
|
||||
readFeatureEF(reader,version);
|
||||
} else {
|
||||
if (song==NULL && (memcmp(featCode,"SL",2)==0 || (memcmp(featCode,"WL",2)==0))) {
|
||||
// nothing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue