mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-22 20:45:11 +00:00
enl_track1.ftm now loads
This commit is contained in:
parent
cd8deb590c
commit
af389831aa
1 changed files with 102 additions and 79 deletions
|
@ -808,11 +808,13 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
ds.systemName = "NES";
|
||||
} else if (blockName == "HEADER") {
|
||||
CHECK_BLOCK_VERSION(4);
|
||||
unsigned char totalSongs = reader.readC();
|
||||
unsigned char totalSongs=0;
|
||||
if (blockVersion>=2) totalSongs=reader.readC();
|
||||
logV("%d songs:", totalSongs + 1);
|
||||
ds.subsong.reserve(totalSongs);
|
||||
for (int i = 0; i <= totalSongs; i++) {
|
||||
String subSongName = reader.readString();
|
||||
String subSongName;
|
||||
if (blockVersion>=3) subSongName=reader.readString();
|
||||
ds.subsong.push_back(new DivSubSong);
|
||||
ds.subsong[i]->name = subSongName;
|
||||
ds.subsong[i]->hilightA = hilightA;
|
||||
|
@ -1326,19 +1328,39 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
|
||||
} else if (blockName == "SEQUENCES") {
|
||||
CHECK_BLOCK_VERSION(6);
|
||||
// reader.seek(blockSize,SEEK_CUR);
|
||||
|
||||
if (blockVersion < 3) {
|
||||
if (blockVersion < 2) {
|
||||
lastError = "sequences block version is too old";
|
||||
delete[] file;
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int seq_count = reader.readI();
|
||||
|
||||
if (blockVersion == 2) {
|
||||
for (unsigned int i = 0; i < seq_count; i++) {
|
||||
unsigned int index = reader.readI();
|
||||
unsigned int type = reader.readI();
|
||||
unsigned char size = reader.readC();
|
||||
macros[index][type].len = size;
|
||||
|
||||
for (int j = 0; j < size; j++) {
|
||||
unsigned char seq = reader.readC();
|
||||
reader.readC(); // reserved?
|
||||
macros[index][type].val[j] = seq;
|
||||
}
|
||||
|
||||
for (int k = 0; k < (int)ds.ins.size(); k++) {
|
||||
DivInstrument* ins=ds.ins[k];
|
||||
if (sequenceIndex[k][type] == index && ins->type == DIV_INS_NES && hasSequence[k][type]) {
|
||||
copyMacro(ins, ¯os[index][type], type, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unsigned char* Indices = new unsigned char[128 * 5];
|
||||
unsigned char* Types = new unsigned char[128 * 5];
|
||||
|
||||
unsigned int seq_count = reader.readI();
|
||||
|
||||
for (unsigned int i = 0; i < seq_count; i++) {
|
||||
unsigned int index = reader.readI();
|
||||
Indices[i] = index;
|
||||
|
@ -1421,6 +1443,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
|
||||
delete[] Indices;
|
||||
delete[] Types;
|
||||
}
|
||||
} else if (blockName == "GROOVES") {
|
||||
CHECK_BLOCK_VERSION(6);
|
||||
// reader.seek(blockSize,SEEK_CUR);
|
||||
|
@ -1525,20 +1548,18 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
int patNum = reader.readI();
|
||||
int numRows = reader.readI();
|
||||
|
||||
/*
|
||||
logV("ch: %d",ch);
|
||||
logV("subs: %d. map_channels[ch]: %d",subs,map_channels[ch]);
|
||||
logV("patNum: %d",patNum);
|
||||
logV("rows: %d",numRows);
|
||||
*/
|
||||
|
||||
DivPattern* pat = ds.subsong[subs]->pat[map_channels[ch]].getPattern(patNum, true);
|
||||
for (int i = 0; i < numRows; i++) {
|
||||
unsigned int row = 0;
|
||||
if (blockVersion >= 2 && blockVersion < 6) { // row index
|
||||
row = reader.readI();
|
||||
} else {
|
||||
if (ds.version==0x200 || blockVersion >= 6) { // row index
|
||||
row = (unsigned char)reader.readC();
|
||||
} else {
|
||||
row = reader.readI();
|
||||
}
|
||||
|
||||
unsigned char nextNote = reader.readC();
|
||||
|
@ -1600,10 +1621,12 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
if (blockVersion >= 6)
|
||||
effectCols = 4;
|
||||
|
||||
if (ds.version == 0x020) {
|
||||
if (ds.version == 0x200) {
|
||||
effectCols = 1;
|
||||
}
|
||||
|
||||
logV("effectCols: %d",effectCols);
|
||||
|
||||
unsigned char nextEffectVal = 0;
|
||||
unsigned char nextEffect = 0;
|
||||
|
||||
|
@ -1793,7 +1816,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
|
|||
|
||||
memset(sample->dataDPCM, 0xAA, true_size);
|
||||
|
||||
reader.read(sample->dataDPCM, true_size);
|
||||
reader.read(sample->dataDPCM, sample_len);
|
||||
}
|
||||
|
||||
int last_non_empty_sample = 0xff;
|
||||
|
|
Loading…
Reference in a new issue