add four more macros

they eventually will be used
This commit is contained in:
tildearrow 2022-01-13 13:55:33 -05:00
parent 36e52ec564
commit 943f88b306
6 changed files with 208 additions and 16 deletions

View File

@ -12,7 +12,7 @@ size | description
-----|------------------------------------
16 | "-Furnace module-" format magic
2 | format version
| - should be 15 for Furnace 0.3
| - should be 17 for Furnace 0.4
2 | reserved
4 | song info pointer
8 | reserved
@ -157,18 +157,30 @@ size | description
4 | arp macro length
4 | duty macro length
4 | wave macro length
4 | pitch macro length (>=17)
4 | extra 1 macro length (>=17)
4 | extra 2 macro length (>=17)
4 | extra 3 macro length (>=17)
4 | volume macro loop
4 | arp macro loop
4 | duty macro loop
4 | wave macro loop
4 | pitch macro loop (>=17)
4 | extra 1 macro loop (>=17)
4 | extra 2 macro loop (>=17)
4 | extra 3 macro loop (>=17)
1 | arp macro mode
1 | volume macro height (>=15)
1 | duty macro height (>=15)
1 | wave macro height (>=15)
1 | volume macro height (>=15) or reserved
1 | duty macro height (>=15) or reserved
1 | wave macro height (>=15) or reserved
4?? | volume macro
4?? | arp macro
4?? | duty macro
4?? | wave macro
4?? | pitch macro (>=17)
4?? | extra 1 macro (>=17)
4?? | extra 2 macro (>=17)
4?? | extra 3 macro (>=17)
# wavetable

View File

@ -1209,10 +1209,22 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
ins->std.arpMacroLen=reader.readI();
ins->std.dutyMacroLen=reader.readI();
ins->std.waveMacroLen=reader.readI();
if (ds.version>=17) {
ins->std.pitchMacroLen=reader.readI();
ins->std.ex1MacroLen=reader.readI();
ins->std.ex2MacroLen=reader.readI();
ins->std.ex3MacroLen=reader.readI();
}
ins->std.volMacroLoop=reader.readI();
ins->std.arpMacroLoop=reader.readI();
ins->std.dutyMacroLoop=reader.readI();
ins->std.waveMacroLoop=reader.readI();
if (ds.version>=17) {
ins->std.pitchMacroLoop=reader.readI();
ins->std.ex1MacroLoop=reader.readI();
ins->std.ex2MacroLoop=reader.readI();
ins->std.ex3MacroLoop=reader.readI();
}
ins->std.arpMacroMode=reader.readC();
ins->std.volMacroHeight=reader.readC();
ins->std.dutyMacroHeight=reader.readC();
@ -1224,6 +1236,12 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
reader.read(ins->std.arpMacro,4*ins->std.arpMacroLen);
reader.read(ins->std.dutyMacro,4*ins->std.dutyMacroLen);
reader.read(ins->std.waveMacro,4*ins->std.waveMacroLen);
if (ds.version>=17) {
reader.read(ins->std.pitchMacro,4*ins->std.pitchMacroLen);
reader.read(ins->std.ex1Macro,4*ins->std.ex1MacroLen);
reader.read(ins->std.ex2Macro,4*ins->std.ex2MacroLen);
reader.read(ins->std.ex3Macro,4*ins->std.ex3MacroLen);
}
ds.ins.push_back(ins);
}
@ -1665,10 +1683,18 @@ SafeWriter* DivEngine::saveFur() {
w->writeI(ins->std.arpMacroLen);
w->writeI(ins->std.dutyMacroLen);
w->writeI(ins->std.waveMacroLen);
w->writeI(ins->std.pitchMacroLen);
w->writeI(ins->std.ex1MacroLen);
w->writeI(ins->std.ex2MacroLen);
w->writeI(ins->std.ex3MacroLen);
w->writeI(ins->std.volMacroLoop);
w->writeI(ins->std.arpMacroLoop);
w->writeI(ins->std.dutyMacroLoop);
w->writeI(ins->std.waveMacroLoop);
w->writeI(ins->std.pitchMacroLoop);
w->writeI(ins->std.ex1MacroLoop);
w->writeI(ins->std.ex2MacroLoop);
w->writeI(ins->std.ex3MacroLoop);
w->writeC(ins->std.arpMacroMode);
w->writeC(ins->std.volMacroHeight);
w->writeC(ins->std.dutyMacroHeight);
@ -1685,6 +1711,18 @@ SafeWriter* DivEngine::saveFur() {
for (int j=0; j<ins->std.waveMacroLen; j++) {
w->writeI(ins->std.waveMacro[j]);
}
for (int j=0; j<ins->std.pitchMacroLen; j++) {
w->writeI(ins->std.pitchMacro[j]);
}
for (int j=0; j<ins->std.ex1MacroLen; j++) {
w->writeI(ins->std.ex1Macro[j]);
}
for (int j=0; j<ins->std.ex2MacroLen; j++) {
w->writeI(ins->std.ex2Macro[j]);
}
for (int j=0; j<ins->std.ex3MacroLen; j++) {
w->writeI(ins->std.ex3Macro[j]);
}
}
/// WAVETABLE

View File

@ -9,8 +9,8 @@
#include <map>
#include <queue>
#define DIV_VERSION "0.3.1"
#define DIV_ENGINE_VERSION 16
#define DIV_VERSION "0.4pre1"
#define DIV_ENGINE_VERSION 17
enum DivStatusView {
DIV_STATUS_NOTHING=0,

View File

@ -7,7 +7,9 @@ enum DivInstrumentType {
DIV_INS_FM=1,
DIV_INS_GB=2,
DIV_INS_C64=3,
DIV_INS_AMIGA=4
DIV_INS_AMIGA=4,
DIV_INS_PCE=5,
DIV_INS_AY=6
};
struct DivInstrumentFM {
@ -84,10 +86,14 @@ struct DivInstrumentSTD {
int arpMacro[256];
int dutyMacro[256];
int waveMacro[256];
int pitchMacro[256];
int ex1Macro[256];
int ex2Macro[256];
int ex3Macro[256];
bool arpMacroMode;
unsigned char volMacroHeight, dutyMacroHeight, waveMacroHeight;
unsigned char volMacroLen, arpMacroLen, dutyMacroLen, waveMacroLen;
signed char volMacroLoop, arpMacroLoop, dutyMacroLoop, waveMacroLoop;
unsigned char volMacroLen, arpMacroLen, dutyMacroLen, waveMacroLen, pitchMacroLen, ex1MacroLen, ex2MacroLen, ex3MacroLen;
signed char volMacroLoop, arpMacroLoop, dutyMacroLoop, waveMacroLoop, pitchMacroLoop, ex1MacroLoop, ex2MacroLoop, ex3MacroLoop;
DivInstrumentSTD():
arpMacroMode(false),
volMacroHeight(15),
@ -97,14 +103,26 @@ struct DivInstrumentSTD {
arpMacroLen(0),
dutyMacroLen(0),
waveMacroLen(0),
pitchMacroLen(0),
ex1MacroLen(0),
ex2MacroLen(0),
ex3MacroLen(0),
volMacroLoop(-1),
arpMacroLoop(-1),
dutyMacroLoop(-1),
waveMacroLoop(-1) {
waveMacroLoop(-1),
pitchMacroLoop(-1),
ex1MacroLoop(-1),
ex2MacroLoop(-1),
ex3MacroLoop(-1) {
memset(volMacro,0,256*sizeof(int));
memset(arpMacro,0,256*sizeof(int));
memset(dutyMacro,0,256*sizeof(int));
memset(waveMacro,0,256*sizeof(int));
memset(pitchMacro,0,256*sizeof(int));
memset(ex1Macro,0,256*sizeof(int));
memset(ex2Macro,0,256*sizeof(int));
memset(ex3Macro,0,256*sizeof(int));
}
};

View File

@ -66,6 +66,70 @@ void DivMacroInt::next() {
}
}
}
if (finishedPitch) finishedPitch=false;
if (hadPitch!=hasPitch) {
finishedPitch=true;
}
hadPitch=hasPitch;
if (hasPitch) {
pitch=ins->std.pitchMacro[pitchPos++];
if (pitchPos>=ins->std.pitchMacroLen && ins->std.pitchMacroLoop<ins->std.pitchMacroLen) {
if (ins->std.pitchMacroLoop>=0) {
pitchPos=ins->std.pitchMacroLoop;
} else {
hasPitch=false;
}
}
}
if (finishedEx1) finishedEx1=false;
if (hadEx1!=hasEx1) {
finishedEx1=true;
}
hadEx1=hasEx1;
if (hasEx1) {
ex1=ins->std.ex1Macro[ex1Pos++];
if (ex1Pos>=ins->std.ex1MacroLen && ins->std.ex1MacroLoop<ins->std.ex1MacroLen) {
if (ins->std.ex1MacroLoop>=0) {
ex1Pos=ins->std.ex1MacroLoop;
} else {
hasEx1=false;
}
}
}
if (finishedEx2) finishedEx2=false;
if (hadEx2!=hasEx2) {
finishedEx2=true;
}
hadEx2=hasEx2;
if (hasEx2) {
ex2=ins->std.ex2Macro[ex2Pos++];
if (ex2Pos>=ins->std.ex2MacroLen && ins->std.ex2MacroLoop<ins->std.ex2MacroLen) {
if (ins->std.ex2MacroLoop>=0) {
ex2Pos=ins->std.ex2MacroLoop;
} else {
hasEx2=false;
}
}
}
if (finishedEx3) finishedEx3=false;
if (hadEx3!=hasEx3) {
finishedEx3=true;
}
hadEx3=hasEx3;
if (hasEx3) {
ex3=ins->std.ex3Macro[ex3Pos++];
if (ex3Pos>=ins->std.ex3MacroLen && ins->std.ex3MacroLoop<ins->std.ex3MacroLen) {
if (ins->std.ex3MacroLoop>=0) {
ex3Pos=ins->std.ex3MacroLoop;
} else {
hasEx3=false;
}
}
}
}
void DivMacroInt::init(DivInstrument* which) {
@ -74,18 +138,34 @@ void DivMacroInt::init(DivInstrument* which) {
arpPos=0;
dutyPos=0;
wavePos=0;
pitchPos=0;
ex1Pos=0;
ex2Pos=0;
ex3Pos=0;
hasVol=false;
hasArp=false;
hasDuty=false;
hasWave=false;
hasPitch=false;
hasEx1=false;
hasEx2=false;
hasEx3=false;
hadVol=false;
hadArp=false;
hadDuty=false;
hadWave=false;
hadPitch=false;
hadEx1=false;
hadEx2=false;
hadEx3=false;
willVol=false;
willArp=false;
willDuty=false;
willWave=false;
willPitch=false;
willEx1=false;
willEx2=false;
willEx3=false;
arpMode=false;
if (ins==NULL) return;
@ -110,6 +190,26 @@ void DivMacroInt::init(DivInstrument* which) {
hasWave=true;
willWave=true;
}
if (ins->std.pitchMacroLen>0) {
hadPitch=true;
hasPitch=true;
willPitch=true;
}
if (ins->std.ex1MacroLen>0) {
hadEx1=true;
hasEx1=true;
willEx1=true;
}
if (ins->std.ex2MacroLen>0) {
hadEx2=true;
hasEx2=true;
willEx2=true;
}
if (ins->std.ex3MacroLen>0) {
hadEx3=true;
hasEx3=true;
willEx3=true;
}
if (ins->std.arpMacroMode) {
arpMode=true;

View File

@ -5,15 +5,15 @@
class DivMacroInt {
DivInstrument* ins;
int volPos, arpPos, dutyPos, wavePos;
int volPos, arpPos, dutyPos, wavePos, pitchPos, ex1Pos, ex2Pos, ex3Pos;
public:
int vol;
int arp;
int duty, wave;
bool hasVol, hasArp, hasDuty, hasWave;
bool hadVol, hadArp, hadDuty, hadWave;
bool finishedVol, finishedArp, finishedDuty, finishedWave;
bool willVol, willArp, willDuty, willWave;
int duty, wave, pitch, ex1, ex2, ex3;
bool hasVol, hasArp, hasDuty, hasWave, hasPitch, hasEx1, hasEx2, hasEx3;
bool hadVol, hadArp, hadDuty, hadWave, hadPitch, hadEx1, hadEx2, hadEx3;
bool finishedVol, finishedArp, finishedDuty, finishedWave, finishedPitch, finishedEx1, finishedEx2, finishedEx3;
bool willVol, willArp, willDuty, willWave, willPitch, willEx1, willEx2, willEx3;
bool arpMode;
void next();
void init(DivInstrument* which);
@ -23,26 +23,50 @@ class DivMacroInt {
arpPos(0),
dutyPos(0),
wavePos(0),
pitchPos(0),
ex1Pos(0),
ex2Pos(0),
ex3Pos(0),
vol(0),
arp(0),
duty(0),
wave(0),
pitch(0),
ex1(0),
ex2(0),
ex3(0),
hasVol(false),
hasArp(false),
hasDuty(false),
hasWave(false),
hasPitch(false),
hasEx1(false),
hasEx2(false),
hasEx3(false),
hadVol(false),
hadArp(false),
hadDuty(false),
hadWave(false),
hadPitch(false),
hadEx1(false),
hadEx2(false),
hadEx3(false),
finishedVol(false),
finishedArp(false),
finishedDuty(false),
finishedWave(false),
finishedPitch(false),
finishedEx1(false),
finishedEx2(false),
finishedEx3(false),
willVol(false),
willArp(false),
willDuty(false),
willWave(false),
willPitch(false),
willEx1(false),
willEx2(false),
willEx3(false),
arpMode(false) {}
};