dev233 - breaking the limit, part 1

now up to 32768 wavetables and 32768 samples

this is the first part and does not implement the new sample limit correctly
I have to adapt every dispatch to the new limit... see you in the next part

the format version had to be bumped because the WL and SL .fui features were limited to 256 entries
there are new LW and LS blocks with more space
howwver there's a new issue... we can have a feature larger than 65536, which is a limit imposed by the feature header :<
this will be addressed though
This commit is contained in:
tildearrow 2025-07-26 18:48:23 -05:00
parent c96d2983cd
commit 98030de8c7
9 changed files with 276 additions and 77 deletions

View file

@ -692,9 +692,9 @@ void DivEngine::convertOldFlags(unsigned int oldFlags, DivConfig& newFlags, DivS
}
bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
unsigned int insPtr[256];
unsigned int wavePtr[256];
unsigned int samplePtr[256];
std::vector<unsigned int> insPtr;
std::vector<unsigned int> wavePtr;
std::vector<unsigned int> samplePtr;
unsigned int subSongPtr[256];
unsigned int sysFlagsPtr[DIV_MAX_CHIPS];
unsigned int assetDirPtr[3];
@ -934,13 +934,13 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
delete[] file;
return false;
}
if (ds.waveLen<0 || ds.waveLen>256) {
if (ds.waveLen<0 || ds.waveLen>32768) {
logE("invalid wavetable count!");
lastError="invalid wavetable count!";
delete[] file;
return false;
}
if (ds.sampleLen<0 || ds.sampleLen>256) {
if (ds.sampleLen<0 || ds.sampleLen>32768) {
logE("invalid sample count!");
lastError="invalid sample count!";
delete[] file;
@ -1142,14 +1142,17 @@ bool DivEngine::loadFur(unsigned char* file, size_t len, int variantID) {
}
// pointers
insPtr.reserve(ds.insLen);
for (int i=0; i<ds.insLen; i++) {
insPtr[i]=reader.readI();
insPtr.push_back(reader.readI());
}
wavePtr.reserve(ds.waveLen);
for (int i=0; i<ds.waveLen; i++) {
wavePtr[i]=reader.readI();
wavePtr.push_back(reader.readI());
}
samplePtr.reserve(ds.sampleLen);
for (int i=0; i<ds.sampleLen; i++) {
samplePtr[i]=reader.readI();
samplePtr.push_back(reader.readI());
}
patPtr.reserve(numberOfPats);
for (int i=0; i<numberOfPats; i++) patPtr.push_back(reader.readI());
@ -2201,15 +2204,15 @@ SafeWriter* DivEngine::saveFur(bool notPrimary, bool newPatternFormat) {
saveLock.unlock();
return NULL;
}
if (song.wave.size()>256) {
logE("maximum number of wavetables is 256!");
lastError="maximum number of wavetables is 256";
if (song.wave.size()>32768) {
logE("maximum number of wavetables is 32768!");
lastError="maximum number of wavetables is 32768";
saveLock.unlock();
return NULL;
}
if (song.sample.size()>256) {
logE("maximum number of samples is 256!");
lastError="maximum number of samples is 256";
if (song.sample.size()>32768) {
logE("maximum number of samples is 32768!");
lastError="maximum number of samples is 32768";
saveLock.unlock();
return NULL;
}