dev105 - prepare for Game Boy hardware sequences

issue #27
This commit is contained in:
tildearrow 2022-08-07 00:03:27 -05:00
parent 47ea8132b2
commit 9f8c96d45b
5 changed files with 66 additions and 5 deletions

View file

@ -32,6 +32,8 @@ these fields are 0 in format versions prior to 100 (0.6pre1).
the format versions are: the format versions are:
- 105: Furance dev105
- 104: Furnace dev104
- 103: Furnace dev103 - 103: Furnace dev103
- 102: Furnace 0.6pre1 (dev102) - 102: Furnace 0.6pre1 (dev102)
- 101: Furnace 0.6pre1 (dev101) - 101: Furnace 0.6pre1 (dev101)
@ -813,6 +815,37 @@ size | description
--- | **Sound Unit data** (>=104) --- | **Sound Unit data** (>=104)
1 | use sample 1 | use sample
1 | switch roles of phase reset timer and frequency 1 | switch roles of phase reset timer and frequency
--- | **Game Boy envelope sequence** (>=105)
1 | length
??? | hardware sequence data
| size is length*3:
| 1 byte: command
| - 0: set envelope
| - 1: set sweep
| - 2: wait
| - 3: wait for release
| - 4: loop
| - 5: loop until release
| 2 bytes: data
| - for set envelope:
| - 1 byte: parameter
| - bit 4-7: volume
| - bit 3: direction
| - bit 0-2: length
| - 1 byte: sound length
| - for set sweep:
| - 1 byte: parameter
| - bit 4-6: length
| - bit 3: direction
| - bit 0-2: shift
| - 1 byte: nothing
| - for wait:
| - 1 byte: length (in ticks)
| - 1 byte: nothing
| - for wait for release:
| - 2 bytes: nothing
| - for loop/loop until release:
| - 2 bytes: position
``` ```
# wavetable # wavetable

View file

@ -45,8 +45,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false; #define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev104" #define DIV_VERSION "dev105"
#define DIV_ENGINE_VERSION 104 #define DIV_ENGINE_VERSION 105
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01

View file

@ -532,6 +532,13 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(su.useSample); w->writeC(su.useSample);
w->writeC(su.switchRoles); w->writeC(su.switchRoles);
// GB hardware sequence
w->writeC(gb.hwSeqLen);
for (int i=0; gb.hwSeqLen; i++) {
w->writeC(gb.hwSeq[i].cmd);
w->writeS(gb.hwSeq[i].data);
}
blockEndSeek=w->tell(); blockEndSeek=w->tell();
w->seek(blockStartSeek,SEEK_SET); w->seek(blockStartSeek,SEEK_SET);
w->writeI(blockEndSeek-blockStartSeek-4); w->writeI(blockEndSeek-blockStartSeek-4);
@ -1085,6 +1092,15 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
su.switchRoles=reader.readC(); su.switchRoles=reader.readC();
} }
// GB hardware sequence
if (version>=105) {
gb.hwSeqLen=reader.readC();
for (int i=0; i<gb.hwSeqLen; i++) {
gb.hwSeq[i].cmd=reader.readC();
gb.hwSeq[i].data=reader.readS();
}
}
return DIV_DATA_SUCCESS; return DIV_DATA_SUCCESS;
} }

View file

@ -261,12 +261,19 @@ struct DivInstrumentSTD {
}; };
struct DivInstrumentGB { struct DivInstrumentGB {
unsigned char envVol, envDir, envLen, soundLen; unsigned char envVol, envDir, envLen, soundLen, hwSeqLen;
struct HWSeqCommand {
unsigned char cmd;
unsigned short data;
} hwSeq[256];
DivInstrumentGB(): DivInstrumentGB():
envVol(15), envVol(15),
envDir(0), envDir(0),
envLen(2), envLen(2),
soundLen(64) {} soundLen(64),
hwSeqLen(0) {
memset(hwSeq,0,256*sizeof(int));
}
}; };
struct DivInstrumentC64 { struct DivInstrumentC64 {

View file

@ -31,6 +31,7 @@ class DivPlatformGB: public DivDispatch {
unsigned char duty, sweep; unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta; bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave; signed char vol, outVol, wave;
unsigned char envVol, envDir, envLen, soundLen;
DivMacroInt std; DivMacroInt std;
void macroInit(DivInstrument* which) { void macroInit(DivInstrument* which) {
std.init(which); std.init(which);
@ -54,7 +55,11 @@ class DivPlatformGB: public DivDispatch {
inPorta(false), inPorta(false),
vol(15), vol(15),
outVol(15), outVol(15),
wave(-1) {} wave(-1),
envVol(0),
envDir(0),
envLen(0),
soundLen(0) {}
}; };
Channel chan[4]; Channel chan[4];
DivDispatchOscBuffer* oscBuf[4]; DivDispatchOscBuffer* oscBuf[4];