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:
- 105: Furance dev105
- 104: Furnace dev104
- 103: Furnace dev103
- 102: Furnace 0.6pre1 (dev102)
- 101: Furnace 0.6pre1 (dev101)
@ -813,6 +815,37 @@ size | description
--- | **Sound Unit data** (>=104)
1 | use sample
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

View File

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

View File

@ -532,6 +532,13 @@ void DivInstrument::putInsData(SafeWriter* w) {
w->writeC(su.useSample);
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();
w->seek(blockStartSeek,SEEK_SET);
w->writeI(blockEndSeek-blockStartSeek-4);
@ -1085,6 +1092,15 @@ DivDataErrors DivInstrument::readInsData(SafeReader& reader, short version) {
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;
}

View File

@ -261,12 +261,19 @@ struct DivInstrumentSTD {
};
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():
envVol(15),
envDir(0),
envLen(2),
soundLen(64) {}
soundLen(64),
hwSeqLen(0) {
memset(hwSeq,0,256*sizeof(int));
}
};
struct DivInstrumentC64 {

View File

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