Merge pull request #778 from tildearrow/defines
Add and reorganize constant define includes
This commit is contained in:
commit
cff02d3ef0
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* Furnace Tracker - multi-system chiptune tracker
|
||||||
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _DEFINES_H
|
||||||
|
#define _DEFINES_H
|
||||||
|
|
||||||
|
// global
|
||||||
|
#define DIV_MAX_CHIPS 32
|
||||||
|
#define DIV_MAX_CHANS 128
|
||||||
|
#define DIV_MAX_PATTERNS 256
|
||||||
|
|
||||||
|
// in-pattern
|
||||||
|
#define DIV_MAX_ROWS 256
|
||||||
|
#define DIV_MAX_COLS 32
|
||||||
|
#define DIV_MAX_EFFECTS 8
|
||||||
|
|
||||||
|
// sample related
|
||||||
|
#define DIV_MAX_SAMPLE_TYPE 4
|
||||||
|
|
||||||
|
#endif
|
|
@ -884,10 +884,10 @@ void DivEngine::runExportThread() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DIV_EXPORT_MODE_MANY_SYS: {
|
case DIV_EXPORT_MODE_MANY_SYS: {
|
||||||
SNDFILE* sf[32];
|
SNDFILE* sf[DIV_MAX_CHIPS];
|
||||||
SF_INFO si[32];
|
SF_INFO si[DIV_MAX_CHIPS];
|
||||||
String fname[32];
|
String fname[DIV_MAX_CHIPS];
|
||||||
SFWrapper sfWrap[32];
|
SFWrapper sfWrap[DIV_MAX_CHIPS];
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
sf[i]=NULL;
|
sf[i]=NULL;
|
||||||
si[i].samplerate=got.rate;
|
si[i].samplerate=got.rate;
|
||||||
|
@ -915,7 +915,7 @@ void DivEngine::runExportThread() {
|
||||||
float* outBuf[2];
|
float* outBuf[2];
|
||||||
outBuf[0]=new float[EXPORT_BUFSIZE];
|
outBuf[0]=new float[EXPORT_BUFSIZE];
|
||||||
outBuf[1]=new float[EXPORT_BUFSIZE];
|
outBuf[1]=new float[EXPORT_BUFSIZE];
|
||||||
short* sysBuf[32];
|
short* sysBuf[DIV_MAX_CHIPS];
|
||||||
for (int i=0; i<song.systemLen; i++) {
|
for (int i=0; i<song.systemLen; i++) {
|
||||||
sysBuf[i]=new short[EXPORT_BUFSIZE*2];
|
sysBuf[i]=new short[EXPORT_BUFSIZE*2];
|
||||||
}
|
}
|
||||||
|
@ -1399,7 +1399,7 @@ void DivEngine::initSongWithDesc(const char* description, bool inBase64) {
|
||||||
c.loadFromMemory(description);
|
c.loadFromMemory(description);
|
||||||
}
|
}
|
||||||
int index=0;
|
int index=0;
|
||||||
for (; index<32; index++) {
|
for (; index<DIV_MAX_CHIPS; index++) {
|
||||||
song.system[index]=systemFromFileFur(c.getInt(fmt::sprintf("id%d",index),0));
|
song.system[index]=systemFromFileFur(c.getInt(fmt::sprintf("id%d",index),0));
|
||||||
if (song.system[index]==DIV_SYSTEM_NULL) {
|
if (song.system[index]==DIV_SYSTEM_NULL) {
|
||||||
break;
|
break;
|
||||||
|
@ -1456,7 +1456,7 @@ void DivEngine::swapChannels(int src, int dest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||||
curOrders->ord[dest][i]^=curOrders->ord[src][i];
|
curOrders->ord[dest][i]^=curOrders->ord[src][i];
|
||||||
curOrders->ord[src][i]^=curOrders->ord[dest][i];
|
curOrders->ord[src][i]^=curOrders->ord[dest][i];
|
||||||
curOrders->ord[dest][i]^=curOrders->ord[src][i];
|
curOrders->ord[dest][i]^=curOrders->ord[src][i];
|
||||||
|
@ -1487,7 +1487,7 @@ void DivEngine::swapChannels(int src, int dest) {
|
||||||
|
|
||||||
void DivEngine::stompChannel(int ch) {
|
void DivEngine::stompChannel(int ch) {
|
||||||
logV("stomping channel %d",ch);
|
logV("stomping channel %d",ch);
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||||
curOrders->ord[ch][i]=0;
|
curOrders->ord[ch][i]=0;
|
||||||
}
|
}
|
||||||
curPat[ch].wipePatterns();
|
curPat[ch].wipePatterns();
|
||||||
|
@ -1649,8 +1649,8 @@ void DivEngine::changeSystem(int index, DivSystem which, bool preserveOrder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivEngine::addSystem(DivSystem which) {
|
bool DivEngine::addSystem(DivSystem which) {
|
||||||
if (song.systemLen>32) {
|
if (song.systemLen>DIV_MAX_CHIPS) {
|
||||||
lastError="max number of systems is 32";
|
lastError=fmt::sprintf("max number of systems is %d",DIV_MAX_CHIPS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (chans+getChannelCount(which)>DIV_MAX_CHANS) {
|
if (chans+getChannelCount(which)>DIV_MAX_CHANS) {
|
||||||
|
@ -1794,7 +1794,7 @@ bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) {
|
||||||
unsigned char prevChanCollapse[DIV_MAX_CHANS];
|
unsigned char prevChanCollapse[DIV_MAX_CHANS];
|
||||||
|
|
||||||
for (int j=0; j<tchans; j++) {
|
for (int j=0; j<tchans; j++) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
prevPat[j][k]=song.subsong[i]->pat[j].data[k];
|
prevPat[j][k]=song.subsong[i]->pat[j].data[k];
|
||||||
}
|
}
|
||||||
prevEffectCols[j]=song.subsong[i]->pat[j].effectCols;
|
prevEffectCols[j]=song.subsong[i]->pat[j].effectCols;
|
||||||
|
@ -1806,7 +1806,7 @@ bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j=0; j<tchans; j++) {
|
for (int j=0; j<tchans; j++) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
song.subsong[i]->orders.ord[j][k]=prevOrders.ord[swappedChannels[j]][k];
|
song.subsong[i]->orders.ord[j][k]=prevOrders.ord[swappedChannels[j]][k];
|
||||||
song.subsong[i]->pat[j].data[k]=prevPat[swappedChannels[j]][k];
|
song.subsong[i]->pat[j].data[k]=prevPat[swappedChannels[j]][k];
|
||||||
}
|
}
|
||||||
|
@ -2768,7 +2768,7 @@ void DivEngine::delInstrument(int index) {
|
||||||
song.insLen=song.ins.size();
|
song.insLen=song.ins.size();
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
for (size_t j=0; j<song.subsong.size(); j++) {
|
for (size_t j=0; j<song.subsong.size(); j++) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
if (song.subsong[j]->pat[i].data[k]==NULL) continue;
|
if (song.subsong[j]->pat[i].data[k]==NULL) continue;
|
||||||
for (int l=0; l<song.subsong[j]->patLen; l++) {
|
for (int l=0; l<song.subsong[j]->patLen; l++) {
|
||||||
if (song.subsong[j]->pat[i].data[k]->data[l][2]>index) {
|
if (song.subsong[j]->pat[i].data[k]->data[l][2]>index) {
|
||||||
|
@ -3468,7 +3468,7 @@ void DivEngine::delSample(int index) {
|
||||||
|
|
||||||
void DivEngine::addOrder(bool duplicate, bool where) {
|
void DivEngine::addOrder(bool duplicate, bool where) {
|
||||||
unsigned char order[DIV_MAX_CHANS];
|
unsigned char order[DIV_MAX_CHANS];
|
||||||
if (curSubSong->ordersLen>=0xff) return;
|
if (curSubSong->ordersLen>=(DIV_MAX_PATTERNS-1)) return;
|
||||||
memset(order,0,DIV_MAX_CHANS);
|
memset(order,0,DIV_MAX_CHANS);
|
||||||
BUSY_BEGIN_SOFT;
|
BUSY_BEGIN_SOFT;
|
||||||
if (duplicate) {
|
if (duplicate) {
|
||||||
|
@ -3476,14 +3476,14 @@ void DivEngine::addOrder(bool duplicate, bool where) {
|
||||||
order[i]=curOrders->ord[i][curOrder];
|
order[i]=curOrders->ord[i][curOrder];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool used[256];
|
bool used[DIV_MAX_PATTERNS];
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
memset(used,0,sizeof(bool)*256);
|
memset(used,0,sizeof(bool)*DIV_MAX_PATTERNS);
|
||||||
for (int j=0; j<curSubSong->ordersLen; j++) {
|
for (int j=0; j<curSubSong->ordersLen; j++) {
|
||||||
used[curOrders->ord[i][j]]=true;
|
used[curOrders->ord[i][j]]=true;
|
||||||
}
|
}
|
||||||
order[i]=0xff;
|
order[i]=(DIV_MAX_PATTERNS-1);
|
||||||
for (int j=0; j<256; j++) {
|
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||||
if (!used[j]) {
|
if (!used[j]) {
|
||||||
order[i]=j;
|
order[i]=j;
|
||||||
break;
|
break;
|
||||||
|
@ -3518,7 +3518,7 @@ void DivEngine::addOrder(bool duplicate, bool where) {
|
||||||
|
|
||||||
void DivEngine::deepCloneOrder(bool where) {
|
void DivEngine::deepCloneOrder(bool where) {
|
||||||
unsigned char order[DIV_MAX_CHANS];
|
unsigned char order[DIV_MAX_CHANS];
|
||||||
if (curSubSong->ordersLen>=0xff) return;
|
if (curSubSong->ordersLen>=(DIV_MAX_PATTERNS-1)) return;
|
||||||
warnings="";
|
warnings="";
|
||||||
BUSY_BEGIN_SOFT;
|
BUSY_BEGIN_SOFT;
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
|
@ -3526,14 +3526,14 @@ void DivEngine::deepCloneOrder(bool where) {
|
||||||
logD("channel %d",i);
|
logD("channel %d",i);
|
||||||
order[i]=curOrders->ord[i][curOrder];
|
order[i]=curOrders->ord[i][curOrder];
|
||||||
// find free slot
|
// find free slot
|
||||||
for (int j=0; j<256; j++) {
|
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||||
logD("finding free slot in %d...",j);
|
logD("finding free slot in %d...",j);
|
||||||
if (curPat[i].data[j]==NULL) {
|
if (curPat[i].data[j]==NULL) {
|
||||||
int origOrd=order[i];
|
int origOrd=order[i];
|
||||||
order[i]=j;
|
order[i]=j;
|
||||||
DivPattern* oldPat=curPat[i].getPattern(origOrd,false);
|
DivPattern* oldPat=curPat[i].getPattern(origOrd,false);
|
||||||
DivPattern* pat=curPat[i].getPattern(j,true);
|
DivPattern* pat=curPat[i].getPattern(j,true);
|
||||||
memcpy(pat->data,oldPat->data,256*32*sizeof(short));
|
memcpy(pat->data,oldPat->data,DIV_MAX_ROWS*DIV_MAX_COLS*sizeof(short));
|
||||||
logD("found at %d",j);
|
logD("found at %d",j);
|
||||||
didNotFind=false;
|
didNotFind=false;
|
||||||
break;
|
break;
|
||||||
|
@ -3629,7 +3629,7 @@ void DivEngine::moveOrderDown() {
|
||||||
void DivEngine::exchangeIns(int one, int two) {
|
void DivEngine::exchangeIns(int one, int two) {
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
for (size_t j=0; j<song.subsong.size(); j++) {
|
for (size_t j=0; j<song.subsong.size(); j++) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
if (song.subsong[j]->pat[i].data[k]==NULL) continue;
|
if (song.subsong[j]->pat[i].data[k]==NULL) continue;
|
||||||
for (int l=0; l<song.subsong[j]->patLen; l++) {
|
for (int l=0; l<song.subsong[j]->patLen; l++) {
|
||||||
if (song.subsong[j]->pat[i].data[k]->data[l][2]==one) {
|
if (song.subsong[j]->pat[i].data[k]->data[l][2]==one) {
|
||||||
|
|
|
@ -318,7 +318,7 @@ enum DivChanTypes {
|
||||||
extern const char* cmdName[];
|
extern const char* cmdName[];
|
||||||
|
|
||||||
class DivEngine {
|
class DivEngine {
|
||||||
DivDispatchContainer disCont[32];
|
DivDispatchContainer disCont[DIV_MAX_CHIPS];
|
||||||
TAAudio* output;
|
TAAudio* output;
|
||||||
TAAudioDesc want, got;
|
TAAudioDesc want, got;
|
||||||
String exportPath;
|
String exportPath;
|
||||||
|
|
|
@ -1581,7 +1581,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
unsigned int wavePtr[256];
|
unsigned int wavePtr[256];
|
||||||
unsigned int samplePtr[256];
|
unsigned int samplePtr[256];
|
||||||
unsigned int subSongPtr[256];
|
unsigned int subSongPtr[256];
|
||||||
unsigned int sysFlagsPtr[32];
|
unsigned int sysFlagsPtr[DIV_MAX_CHIPS];
|
||||||
std::vector<int> patPtr;
|
std::vector<int> patPtr;
|
||||||
int numberOfSubSongs=0;
|
int numberOfSubSongs=0;
|
||||||
char magic[5];
|
char magic[5];
|
||||||
|
@ -1760,7 +1760,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
delete[] file;
|
delete[] file;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (subSong->patLen>256) {
|
if (subSong->patLen>DIV_MAX_ROWS) {
|
||||||
logE("pattern length is too large!");
|
logE("pattern length is too large!");
|
||||||
lastError="pattern length is too large!";
|
lastError="pattern length is too large!";
|
||||||
delete[] file;
|
delete[] file;
|
||||||
|
@ -1772,7 +1772,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
delete[] file;
|
delete[] file;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (subSong->ordersLen>256) {
|
if (subSong->ordersLen>DIV_MAX_PATTERNS) {
|
||||||
logE("song is too long!");
|
logE("song is too long!");
|
||||||
lastError="song is too long!";
|
lastError="song is too long!";
|
||||||
delete[] file;
|
delete[] file;
|
||||||
|
@ -1804,7 +1804,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
logD("systems:");
|
logD("systems:");
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
unsigned char sysID=reader.readC();
|
unsigned char sysID=reader.readC();
|
||||||
ds.system[i]=systemFromFileFur(sysID);
|
ds.system[i]=systemFromFileFur(sysID);
|
||||||
logD("- %d: %.2x (%s)",i,sysID,getSystemName(ds.system[i]));
|
logD("- %d: %.2x (%s)",i,sysID,getSystemName(ds.system[i]));
|
||||||
|
@ -1826,7 +1826,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// system volume
|
// system volume
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
ds.systemVol[i]=reader.readC();
|
ds.systemVol[i]=reader.readC();
|
||||||
if (ds.version<59 && ds.system[i]==DIV_SYSTEM_NES) {
|
if (ds.version<59 && ds.system[i]==DIV_SYSTEM_NES) {
|
||||||
ds.systemVol[i]/=4;
|
ds.systemVol[i]/=4;
|
||||||
|
@ -1834,15 +1834,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// system panning
|
// system panning
|
||||||
for (int i=0; i<32; i++) ds.systemPan[i]=reader.readC();
|
for (int i=0; i<DIV_MAX_CHIPS; i++) ds.systemPan[i]=reader.readC();
|
||||||
|
|
||||||
// system props
|
// system props
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
sysFlagsPtr[i]=reader.readI();
|
sysFlagsPtr[i]=reader.readI();
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle compound systems
|
// handle compound systems
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
if (ds.system[i]==DIV_SYSTEM_GENESIS ||
|
if (ds.system[i]==DIV_SYSTEM_GENESIS ||
|
||||||
ds.system[i]==DIV_SYSTEM_GENESIS_EXT ||
|
ds.system[i]==DIV_SYSTEM_GENESIS_EXT ||
|
||||||
ds.system[i]==DIV_SYSTEM_ARCADE) {
|
ds.system[i]==DIV_SYSTEM_ARCADE) {
|
||||||
|
@ -1851,7 +1851,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
ds.systemVol[j]=ds.systemVol[j-1];
|
ds.systemVol[j]=ds.systemVol[j-1];
|
||||||
ds.systemPan[j]=ds.systemPan[j-1];
|
ds.systemPan[j]=ds.systemPan[j-1];
|
||||||
}
|
}
|
||||||
if (++ds.systemLen>32) ds.systemLen=32;
|
if (++ds.systemLen>DIV_MAX_CHIPS) ds.systemLen=DIV_MAX_CHIPS;
|
||||||
|
|
||||||
if (ds.system[i]==DIV_SYSTEM_GENESIS) {
|
if (ds.system[i]==DIV_SYSTEM_GENESIS) {
|
||||||
ds.system[i]=DIV_SYSTEM_YM2612;
|
ds.system[i]=DIV_SYSTEM_YM2612;
|
||||||
|
@ -2000,7 +2000,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
|
|
||||||
for (int i=0; i<tchans; i++) {
|
for (int i=0; i<tchans; i++) {
|
||||||
subSong->pat[i].effectCols=reader.readC();
|
subSong->pat[i].effectCols=reader.readC();
|
||||||
if (subSong->pat[i].effectCols<1 || subSong->pat[i].effectCols>8) {
|
if (subSong->pat[i].effectCols<1 || subSong->pat[i].effectCols>DIV_MAX_EFFECTS) {
|
||||||
logE("channel %d has zero or too many effect columns! (%d)",i,subSong->pat[i].effectCols);
|
logE("channel %d has zero or too many effect columns! (%d)",i,subSong->pat[i].effectCols);
|
||||||
lastError=fmt::sprintf("channel %d has too many effect columns! (%d)",i,subSong->pat[i].effectCols);
|
lastError=fmt::sprintf("channel %d has too many effect columns! (%d)",i,subSong->pat[i].effectCols);
|
||||||
delete[] file;
|
delete[] file;
|
||||||
|
@ -2198,7 +2198,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
// read system flags
|
// read system flags
|
||||||
if (ds.version>=119) {
|
if (ds.version>=119) {
|
||||||
logD("reading chip flags...");
|
logD("reading chip flags...");
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
if (sysFlagsPtr[i]==0) continue;
|
if (sysFlagsPtr[i]==0) continue;
|
||||||
|
|
||||||
if (!reader.seek(sysFlagsPtr[i],SEEK_SET)) {
|
if (!reader.seek(sysFlagsPtr[i],SEEK_SET)) {
|
||||||
|
@ -2416,7 +2416,7 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
|
||||||
delete[] file;
|
delete[] file;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (index<0 || index>255) {
|
if (index<0 || index>(DIV_MAX_PATTERNS-1)) {
|
||||||
logE("pattern index out of range!",i);
|
logE("pattern index out of range!",i);
|
||||||
lastError="pattern index out of range!";
|
lastError="pattern index out of range!";
|
||||||
ds.unload();
|
ds.unload();
|
||||||
|
@ -4175,14 +4175,14 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
|
|
||||||
// fail if values are out of range
|
// fail if values are out of range
|
||||||
/*
|
/*
|
||||||
if (subSong->ordersLen>256) {
|
if (subSong->ordersLen>DIV_MAX_PATTERNS) {
|
||||||
logE("maximum song length is 256!");
|
logE("maximum song length is %d!",DIV_MAX_PATTERNS);
|
||||||
lastError="maximum song length is 256";
|
lastError=fmt::sprintf("maximum song length is %d",DIV_MAX_PATTERNS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (subSong->patLen>256) {
|
if (subSong->patLen>DIV_MAX_ROWS) {
|
||||||
logE("maximum pattern length is 256!");
|
logE("maximum pattern length is %d!",DIV_MAX_ROWS);
|
||||||
lastError="maximum pattern length is 256";
|
lastError=fmt::sprintf("maximum pattern length is %d",DIV_MAX_ROWS);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
@ -4236,18 +4236,18 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
for (size_t j=0; j<song.subsong.size(); j++) {
|
for (size_t j=0; j<song.subsong.size(); j++) {
|
||||||
DivSubSong* subs=song.subsong[j];
|
DivSubSong* subs=song.subsong[j];
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
if (subs->pat[i].data[k]==NULL) continue;
|
if (subs->pat[i].data[k]==NULL) continue;
|
||||||
patsToWrite.push_back(PatToWrite(j,i,k));
|
patsToWrite.push_back(PatToWrite(j,i,k));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool alreadyAdded[256];
|
bool alreadyAdded[DIV_MAX_PATTERNS];
|
||||||
for (int i=0; i<chans; i++) {
|
for (int i=0; i<chans; i++) {
|
||||||
for (size_t j=0; j<song.subsong.size(); j++) {
|
for (size_t j=0; j<song.subsong.size(); j++) {
|
||||||
DivSubSong* subs=song.subsong[j];
|
DivSubSong* subs=song.subsong[j];
|
||||||
memset(alreadyAdded,0,256*sizeof(bool));
|
memset(alreadyAdded,0,DIV_MAX_PATTERNS*sizeof(bool));
|
||||||
for (int k=0; k<subs->ordersLen; k++) {
|
for (int k=0; k<subs->ordersLen; k++) {
|
||||||
if (alreadyAdded[subs->orders.ord[i][k]]) continue;
|
if (alreadyAdded[subs->orders.ord[i][k]]) continue;
|
||||||
patsToWrite.push_back(PatToWrite(j,i,subs->orders.ord[i][k]));
|
patsToWrite.push_back(PatToWrite(j,i,subs->orders.ord[i][k]));
|
||||||
|
@ -4276,7 +4276,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
w->writeS(song.sampleLen);
|
w->writeS(song.sampleLen);
|
||||||
w->writeI(patsToWrite.size());
|
w->writeI(patsToWrite.size());
|
||||||
|
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
if (i>=song.systemLen) {
|
if (i>=song.systemLen) {
|
||||||
w->writeC(0);
|
w->writeC(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4284,17 +4284,17 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
w->writeC(song.systemVol[i]);
|
w->writeC(song.systemVol[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
w->writeC(song.systemPan[i]);
|
w->writeC(song.systemPan[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// chip flags (we'll seek here later)
|
// chip flags (we'll seek here later)
|
||||||
sysFlagsPtrSeek=w->tell();
|
sysFlagsPtrSeek=w->tell();
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
w->writeI(0);
|
w->writeI(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,10 +21,10 @@
|
||||||
#define _ORDERS_H
|
#define _ORDERS_H
|
||||||
|
|
||||||
struct DivOrders {
|
struct DivOrders {
|
||||||
unsigned char ord[DIV_MAX_CHANS][256];
|
unsigned char ord[DIV_MAX_CHANS][DIV_MAX_PATTERNS];
|
||||||
|
|
||||||
DivOrders() {
|
DivOrders() {
|
||||||
memset(ord,0,DIV_MAX_CHANS*256);
|
memset(ord,0,DIV_MAX_CHANS*DIV_MAX_PATTERNS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
static DivPattern emptyPat;
|
static DivPattern emptyPat;
|
||||||
|
|
||||||
DivPattern::DivPattern() {
|
DivPattern::DivPattern() {
|
||||||
memset(data,-1,256*32*sizeof(short));
|
memset(data,-1,DIV_MAX_ROWS*DIV_MAX_COLS*sizeof(short));
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_ROWS; i++) {
|
||||||
data[i][0]=0;
|
data[i][0]=0;
|
||||||
data[i][1]=0;
|
data[i][1]=0;
|
||||||
}
|
}
|
||||||
|
@ -43,13 +43,13 @@ DivPattern* DivChannelData::getPattern(int index, bool create) {
|
||||||
|
|
||||||
std::vector<std::pair<int,int>> DivChannelData::optimize() {
|
std::vector<std::pair<int,int>> DivChannelData::optimize() {
|
||||||
std::vector<std::pair<int,int>> ret;
|
std::vector<std::pair<int,int>> ret;
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||||
if (data[i]!=NULL) {
|
if (data[i]!=NULL) {
|
||||||
// compare
|
// compare
|
||||||
for (int j=0; j<256; j++) {
|
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||||
if (j==i) continue;
|
if (j==i) continue;
|
||||||
if (data[j]==NULL) continue;
|
if (data[j]==NULL) continue;
|
||||||
if (memcmp(data[i]->data,data[j]->data,256*32*sizeof(short))==0) {
|
if (memcmp(data[i]->data,data[j]->data,DIV_MAX_ROWS*DIV_MAX_COLS*sizeof(short))==0) {
|
||||||
delete data[j];
|
delete data[j];
|
||||||
data[j]=NULL;
|
data[j]=NULL;
|
||||||
logV("%d == %d",i,j);
|
logV("%d == %d",i,j);
|
||||||
|
@ -63,15 +63,15 @@ std::vector<std::pair<int,int>> DivChannelData::optimize() {
|
||||||
|
|
||||||
std::vector<std::pair<int,int>> DivChannelData::rearrange() {
|
std::vector<std::pair<int,int>> DivChannelData::rearrange() {
|
||||||
std::vector<std::pair<int,int>> ret;
|
std::vector<std::pair<int,int>> ret;
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||||
if (data[i]==NULL) {
|
if (data[i]==NULL) {
|
||||||
for (int j=i; j<256; j++) {
|
for (int j=i; j<DIV_MAX_PATTERNS; j++) {
|
||||||
if (data[j]!=NULL) {
|
if (data[j]!=NULL) {
|
||||||
data[i]=data[j];
|
data[i]=data[j];
|
||||||
data[j]=NULL;
|
data[j]=NULL;
|
||||||
logV("%d -> %d",j,i);
|
logV("%d -> %d",j,i);
|
||||||
ret.push_back(std::pair<int,int>(j,i));
|
ret.push_back(std::pair<int,int>(j,i));
|
||||||
if (++i>=256) break;
|
if (++i>=DIV_MAX_PATTERNS) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ std::vector<std::pair<int,int>> DivChannelData::rearrange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivChannelData::wipePatterns() {
|
void DivChannelData::wipePatterns() {
|
||||||
for (int i=0; i<256; i++) {
|
for (int i=0; i<DIV_MAX_PATTERNS; i++) {
|
||||||
if (data[i]!=NULL) {
|
if (data[i]!=NULL) {
|
||||||
delete data[i];
|
delete data[i];
|
||||||
data[i]=NULL;
|
data[i]=NULL;
|
||||||
|
@ -95,5 +95,5 @@ void DivPattern::copyOn(DivPattern* dest) {
|
||||||
|
|
||||||
DivChannelData::DivChannelData():
|
DivChannelData::DivChannelData():
|
||||||
effectCols(1) {
|
effectCols(1) {
|
||||||
memset(data,0,256*sizeof(void*));
|
memset(data,0,DIV_MAX_PATTERNS*sizeof(void*));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
struct DivPattern {
|
struct DivPattern {
|
||||||
String name;
|
String name;
|
||||||
short data[256][32];
|
short data[DIV_MAX_ROWS][DIV_MAX_COLS];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* copy this pattern to another.
|
* copy this pattern to another.
|
||||||
|
@ -42,7 +42,7 @@ struct DivChannelData {
|
||||||
// 3: volume
|
// 3: volume
|
||||||
// 4-5+: effect/effect value
|
// 4-5+: effect/effect value
|
||||||
// do NOT access directly unless you know what you're doing!
|
// do NOT access directly unless you know what you're doing!
|
||||||
DivPattern* data[256];
|
DivPattern* data[DIV_MAX_PATTERNS];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a pattern from this channel, or the empty pattern if not initialized.
|
* get a pattern from this channel, or the empty pattern if not initialized.
|
||||||
|
|
|
@ -57,9 +57,9 @@ void DivSample::putSampleData(SafeWriter* w) {
|
||||||
w->writeI(loop?loopStart:-1);
|
w->writeI(loop?loopStart:-1);
|
||||||
w->writeI(loop?loopEnd:-1);
|
w->writeI(loop?loopEnd:-1);
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<DIV_MAX_SAMPLE_TYPE; i++) {
|
||||||
unsigned int out=0;
|
unsigned int out=0;
|
||||||
for (int j=0; j<32; j++) {
|
for (int j=0; j<DIV_MAX_CHIPS; j++) {
|
||||||
if (renderOn[i][j]) out|=1<<j;
|
if (renderOn[i][j]) out|=1<<j;
|
||||||
}
|
}
|
||||||
w->writeI(out);
|
w->writeI(out);
|
||||||
|
@ -137,9 +137,9 @@ DivDataErrors DivSample::readSampleData(SafeReader& reader, short version) {
|
||||||
loopEnd=reader.readI();
|
loopEnd=reader.readI();
|
||||||
loop=(loopStart>=0)&&(loopEnd>=0);
|
loop=(loopStart>=0)&&(loopEnd>=0);
|
||||||
|
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<DIV_MAX_SAMPLE_TYPE; i++) {
|
||||||
unsigned int outMask=(unsigned int)reader.readI();
|
unsigned int outMask=(unsigned int)reader.readI();
|
||||||
for (int j=0; j<32; j++) {
|
for (int j=0; j<DIV_MAX_CHIPS; j++) {
|
||||||
renderOn[i][j]=outMask&(1<<j);
|
renderOn[i][j]=outMask&(1<<j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define _SAMPLE_H
|
#define _SAMPLE_H
|
||||||
|
|
||||||
#include "../ta-utils.h"
|
#include "../ta-utils.h"
|
||||||
|
#include "defines.h"
|
||||||
#include "safeWriter.h"
|
#include "safeWriter.h"
|
||||||
#include "dataErrors.h"
|
#include "dataErrors.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
@ -115,7 +116,7 @@ struct DivSample {
|
||||||
// - 2: Pingpong loop
|
// - 2: Pingpong loop
|
||||||
DivSampleLoopMode loopMode;
|
DivSampleLoopMode loopMode;
|
||||||
|
|
||||||
bool renderOn[4][32];
|
bool renderOn[DIV_MAX_SAMPLE_TYPE][DIV_MAX_CHIPS];
|
||||||
|
|
||||||
// these are the new data structures.
|
// these are the new data structures.
|
||||||
signed char* data8; // 8
|
signed char* data8; // 8
|
||||||
|
@ -331,11 +332,10 @@ struct DivSample {
|
||||||
lengthBRR(0),
|
lengthBRR(0),
|
||||||
lengthVOX(0),
|
lengthVOX(0),
|
||||||
samples(0) {
|
samples(0) {
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
renderOn[0][i]=true;
|
for (int j=0; j<DIV_MAX_SAMPLE_TYPE; j++) {
|
||||||
renderOn[1][i]=true;
|
renderOn[j][i]=true;
|
||||||
renderOn[2][i]=true;
|
}
|
||||||
renderOn[3][i]=true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
~DivSample();
|
~DivSample();
|
||||||
|
|
|
@ -25,7 +25,7 @@ void DivSubSong::clearData() {
|
||||||
pat[i].wipePatterns();
|
pat[i].wipePatterns();
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(orders.ord,0,DIV_MAX_CHANS*256);
|
memset(orders.ord,0,DIV_MAX_CHANS*DIV_MAX_PATTERNS);
|
||||||
ordersLen=1;
|
ordersLen=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ void DivSubSong::optimizePatterns() {
|
||||||
logD("optimizing channel %d...",i);
|
logD("optimizing channel %d...",i);
|
||||||
std::vector<std::pair<int,int>> clearOuts=pat[i].optimize();
|
std::vector<std::pair<int,int>> clearOuts=pat[i].optimize();
|
||||||
for (auto& j: clearOuts) {
|
for (auto& j: clearOuts) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
if (orders.ord[i][k]==j.first) {
|
if (orders.ord[i][k]==j.first) {
|
||||||
orders.ord[i][k]=j.second;
|
orders.ord[i][k]=j.second;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ void DivSubSong::rearrangePatterns() {
|
||||||
logD("re-arranging channel %d...",i);
|
logD("re-arranging channel %d...",i);
|
||||||
std::vector<std::pair<int,int>> clearOuts=pat[i].rearrange();
|
std::vector<std::pair<int,int>> clearOuts=pat[i].rearrange();
|
||||||
for (auto& j: clearOuts) {
|
for (auto& j: clearOuts) {
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
if (orders.ord[i][k]==j.first) {
|
if (orders.ord[i][k]==j.first) {
|
||||||
orders.ord[i][k]=j.second;
|
orders.ord[i][k]=j.second;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#define DIV_MAX_CHANS 128
|
#include "defines.h"
|
||||||
|
|
||||||
#include "../ta-utils.h"
|
#include "../ta-utils.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "orders.h"
|
#include "orders.h"
|
||||||
|
@ -230,11 +229,11 @@ struct DivSong {
|
||||||
bool isDMF;
|
bool isDMF;
|
||||||
|
|
||||||
// system
|
// system
|
||||||
DivSystem system[32];
|
DivSystem system[DIV_MAX_CHIPS];
|
||||||
unsigned char systemLen;
|
unsigned char systemLen;
|
||||||
signed char systemVol[32];
|
signed char systemVol[DIV_MAX_CHIPS];
|
||||||
signed char systemPan[32];
|
signed char systemPan[DIV_MAX_CHIPS];
|
||||||
DivConfig systemFlags[32];
|
DivConfig systemFlags[DIV_MAX_CHIPS];
|
||||||
|
|
||||||
// song information
|
// song information
|
||||||
String name, author, systemName;
|
String name, author, systemName;
|
||||||
|
@ -428,7 +427,7 @@ struct DivSong {
|
||||||
snNoLowPeriods(false),
|
snNoLowPeriods(false),
|
||||||
disableSampleMacro(false),
|
disableSampleMacro(false),
|
||||||
autoSystem(true) {
|
autoSystem(true) {
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
system[i]=DIV_SYSTEM_NULL;
|
system[i]=DIV_SYSTEM_NULL;
|
||||||
systemVol[i]=64;
|
systemVol[i]=64;
|
||||||
systemPan[i]=0;
|
systemPan[i]=0;
|
||||||
|
|
|
@ -945,15 +945,15 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p
|
||||||
w->writeI(0); // will be written later
|
w->writeI(0); // will be written later
|
||||||
w->writeI(version);
|
w->writeI(version);
|
||||||
|
|
||||||
bool willExport[32];
|
bool willExport[DIV_MAX_CHIPS];
|
||||||
bool isSecond[32];
|
bool isSecond[DIV_MAX_CHIPS];
|
||||||
int streamIDs[32];
|
int streamIDs[DIV_MAX_CHIPS];
|
||||||
double loopTimer[DIV_MAX_CHANS];
|
double loopTimer[DIV_MAX_CHANS];
|
||||||
double loopFreq[DIV_MAX_CHANS];
|
double loopFreq[DIV_MAX_CHANS];
|
||||||
int loopSample[DIV_MAX_CHANS];
|
int loopSample[DIV_MAX_CHANS];
|
||||||
bool sampleDir[DIV_MAX_CHANS];
|
bool sampleDir[DIV_MAX_CHANS];
|
||||||
std::vector<unsigned int> chipVol;
|
std::vector<unsigned int> chipVol;
|
||||||
std::vector<DivDelayedWrite> delayedWrites[32];
|
std::vector<DivDelayedWrite> delayedWrites[DIV_MAX_CHIPS];
|
||||||
std::vector<std::pair<int,DivDelayedWrite>> sortedWrites;
|
std::vector<std::pair<int,DivDelayedWrite>> sortedWrites;
|
||||||
|
|
||||||
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
for (int i=0; i<DIV_MAX_CHANS; i++) {
|
||||||
|
|
|
@ -693,7 +693,7 @@ void FurnaceGUI::actualSampleList() {
|
||||||
DivDispatch* dispatch=e->getDispatch(j);
|
DivDispatch* dispatch=e->getDispatch(j);
|
||||||
if (dispatch==NULL) continue;
|
if (dispatch==NULL) continue;
|
||||||
|
|
||||||
for (int k=0; k<4; k++) {
|
for (int k=0; k<DIV_MAX_SAMPLE_TYPE; k++) {
|
||||||
if (dispatch->getSampleMemCapacity(k)==0) continue;
|
if (dispatch->getSampleMemCapacity(k)==0) continue;
|
||||||
if (!dispatch->isSampleLoaded(k,i) && sample->renderOn[k][j]) {
|
if (!dispatch->isSampleLoaded(k,i) && sample->renderOn[k][j]) {
|
||||||
memWarning=true;
|
memWarning=true;
|
||||||
|
|
|
@ -522,7 +522,7 @@ void FurnaceGUI::doAction(int what) {
|
||||||
case GUI_ACTION_PAT_INCREASE_COLUMNS:
|
case GUI_ACTION_PAT_INCREASE_COLUMNS:
|
||||||
if (cursor.xCoarse<0 || cursor.xCoarse>=e->getTotalChannelCount()) break;
|
if (cursor.xCoarse<0 || cursor.xCoarse>=e->getTotalChannelCount()) break;
|
||||||
e->curPat[cursor.xCoarse].effectCols++;
|
e->curPat[cursor.xCoarse].effectCols++;
|
||||||
if (e->curPat[cursor.xCoarse].effectCols>8) e->curPat[cursor.xCoarse].effectCols=8;
|
if (e->curPat[cursor.xCoarse].effectCols>DIV_MAX_EFFECTS) e->curPat[cursor.xCoarse].effectCols=DIV_MAX_EFFECTS;
|
||||||
break;
|
break;
|
||||||
case GUI_ACTION_PAT_DECREASE_COLUMNS:
|
case GUI_ACTION_PAT_DECREASE_COLUMNS:
|
||||||
if (cursor.xCoarse<0 || cursor.xCoarse>=e->getTotalChannelCount()) break;
|
if (cursor.xCoarse<0 || cursor.xCoarse>=e->getTotalChannelCount()) break;
|
||||||
|
|
|
@ -119,7 +119,7 @@ void FurnaceGUI::makeUndo(ActionType action) {
|
||||||
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
||||||
DivPattern* p=e->curPat[i].getPattern(e->curOrders->ord[i][curOrder],false);
|
DivPattern* p=e->curPat[i].getPattern(e->curOrders->ord[i][curOrder],false);
|
||||||
for (int j=0; j<e->curSubSong->patLen; j++) {
|
for (int j=0; j<e->curSubSong->patLen; j++) {
|
||||||
for (int k=0; k<32; k++) {
|
for (int k=0; k<DIV_MAX_COLS; k++) {
|
||||||
if (p->data[j][k]!=oldPat[i]->data[j][k]) {
|
if (p->data[j][k]!=oldPat[i]->data[j][k]) {
|
||||||
s.pat.push_back(UndoPatternData(subSong,i,e->curOrders->ord[i][curOrder],j,k,oldPat[i]->data[j][k],p->data[j][k]));
|
s.pat.push_back(UndoPatternData(subSong,i,e->curOrders->ord[i][curOrder],j,k,oldPat[i]->data[j][k],p->data[j][k]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,20 +220,20 @@ void FurnaceGUI::doReplace() {
|
||||||
UndoStep us;
|
UndoStep us;
|
||||||
us.type=GUI_UNDO_REPLACE;
|
us.type=GUI_UNDO_REPLACE;
|
||||||
|
|
||||||
short prevVal[32];
|
short prevVal[DIV_MAX_COLS];
|
||||||
memset(prevVal,0,32*sizeof(short));
|
memset(prevVal,0,DIV_MAX_COLS*sizeof(short));
|
||||||
|
|
||||||
for (FurnaceGUIQueryResult& i: curQueryResults) {
|
for (FurnaceGUIQueryResult& i: curQueryResults) {
|
||||||
int patIndex=e->song.subsong[i.subsong]->orders.ord[i.x][i.order];
|
int patIndex=e->song.subsong[i.subsong]->orders.ord[i.x][i.order];
|
||||||
DivPattern* p=e->song.subsong[i.subsong]->pat[i.x].getPattern(patIndex,true);
|
DivPattern* p=e->song.subsong[i.subsong]->pat[i.x].getPattern(patIndex,true);
|
||||||
if (touched[i.x]==NULL) {
|
if (touched[i.x]==NULL) {
|
||||||
touched[i.x]=new bool[256*256];
|
touched[i.x]=new bool[DIV_MAX_PATTERNS*DIV_MAX_ROWS];
|
||||||
memset(touched[i.x],0,256*256*sizeof(bool));
|
memset(touched[i.x],0,DIV_MAX_PATTERNS*DIV_MAX_ROWS*sizeof(bool));
|
||||||
}
|
}
|
||||||
if (touched[i.x][(patIndex<<8)|i.y]) continue;
|
if (touched[i.x][(patIndex<<8)|i.y]) continue;
|
||||||
touched[i.x][(patIndex<<8)|i.y]=true;
|
touched[i.x][(patIndex<<8)|i.y]=true;
|
||||||
|
|
||||||
memcpy(prevVal,p->data[i.y],32*sizeof(short));
|
memcpy(prevVal,p->data[i.y],DIV_MAX_COLS*sizeof(short));
|
||||||
|
|
||||||
if (queryReplaceNoteDo) {
|
if (queryReplaceNoteDo) {
|
||||||
switch (queryReplaceNoteMode) {
|
switch (queryReplaceNoteMode) {
|
||||||
|
@ -462,7 +462,7 @@ void FurnaceGUI::doReplace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue undo step
|
// issue undo step
|
||||||
for (int j=0; j<32; j++) {
|
for (int j=0; j<DIV_MAX_COLS; j++) {
|
||||||
if (p->data[i.y][j]!=prevVal[j]) {
|
if (p->data[i.y][j]!=prevVal[j]) {
|
||||||
us.pat.push_back(UndoPatternData(i.subsong,i.x,patIndex,i.y,j,prevVal[j],p->data[i.y][j]));
|
us.pat.push_back(UndoPatternData(i.subsong,i.x,patIndex,i.y,j,prevVal[j],p->data[i.y][j]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -4766,7 +4766,7 @@ bool FurnaceGUI::loop() {
|
||||||
if (ImGui::Button("Orders")) {
|
if (ImGui::Button("Orders")) {
|
||||||
stop();
|
stop();
|
||||||
e->lockEngine([this]() {
|
e->lockEngine([this]() {
|
||||||
memset(e->curOrders->ord,0,DIV_MAX_CHANS*256);
|
memset(e->curOrders->ord,0,DIV_MAX_CHANS*DIV_MAX_PATTERNS);
|
||||||
e->curSubSong->ordersLen=1;
|
e->curSubSong->ordersLen=1;
|
||||||
});
|
});
|
||||||
e->setOrder(0);
|
e->setOrder(0);
|
||||||
|
@ -4782,8 +4782,8 @@ bool FurnaceGUI::loop() {
|
||||||
e->lockEngine([this]() {
|
e->lockEngine([this]() {
|
||||||
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
||||||
DivPattern* pat=e->curPat[i].getPattern(e->curOrders->ord[i][curOrder],true);
|
DivPattern* pat=e->curPat[i].getPattern(e->curOrders->ord[i][curOrder],true);
|
||||||
memset(pat->data,-1,256*32*sizeof(short));
|
memset(pat->data,-1,DIV_MAX_ROWS*DIV_MAX_COLS*sizeof(short));
|
||||||
for (int j=0; j<256; j++) {
|
for (int j=0; j<DIV_MAX_ROWS; j++) {
|
||||||
pat->data[j][0]=0;
|
pat->data[j][0]=0;
|
||||||
pat->data[j][1]=0;
|
pat->data[j][1]=0;
|
||||||
}
|
}
|
||||||
|
@ -6032,7 +6032,7 @@ FurnaceGUI::FurnaceGUI():
|
||||||
valueKeys[SDLK_KP_8]=8;
|
valueKeys[SDLK_KP_8]=8;
|
||||||
valueKeys[SDLK_KP_9]=9;
|
valueKeys[SDLK_KP_9]=9;
|
||||||
|
|
||||||
memset(willExport,1,32*sizeof(bool));
|
memset(willExport,1,DIV_MAX_CHIPS*sizeof(bool));
|
||||||
|
|
||||||
peak[0]=0;
|
peak[0]=0;
|
||||||
peak[1]=0;
|
peak[1]=0;
|
||||||
|
|
|
@ -1089,7 +1089,7 @@ class FurnaceGUI {
|
||||||
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
|
bool displayNew, fullScreen, preserveChanPos, wantScrollList, noteInputPoly;
|
||||||
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex;
|
bool displayPendingIns, pendingInsSingle, displayPendingRawSample, snesFilterHex;
|
||||||
bool mobileEdit;
|
bool mobileEdit;
|
||||||
bool willExport[32];
|
bool willExport[DIV_MAX_CHIPS];
|
||||||
int vgmExportVersion;
|
int vgmExportVersion;
|
||||||
int drawHalt;
|
int drawHalt;
|
||||||
int zsmExportTickRate;
|
int zsmExportTickRate;
|
||||||
|
|
|
@ -177,10 +177,10 @@ void FurnaceGUI::drawOrders() {
|
||||||
e->lockSave([this,i,j]() {
|
e->lockSave([this,i,j]() {
|
||||||
if (changeAllOrders) {
|
if (changeAllOrders) {
|
||||||
for (int k=0; k<e->getTotalChannelCount(); k++) {
|
for (int k=0; k<e->getTotalChannelCount(); k++) {
|
||||||
if (e->curOrders->ord[k][i]<0xff) e->curOrders->ord[k][i]++;
|
if (e->curOrders->ord[k][i]<(unsigned char)(DIV_MAX_PATTERNS-1)) e->curOrders->ord[k][i]++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (e->curOrders->ord[j][i]<0xff) e->curOrders->ord[j][i]++;
|
if (e->curOrders->ord[j][i]<(unsigned char)(DIV_MAX_PATTERNS-1)) e->curOrders->ord[j][i]++;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
e->walkSong(loopOrder,loopRow,loopEnd);
|
e->walkSong(loopOrder,loopRow,loopEnd);
|
||||||
|
|
|
@ -30,8 +30,8 @@ void FurnaceGUI::drawPatManager() {
|
||||||
}
|
}
|
||||||
if (!patManagerOpen) return;
|
if (!patManagerOpen) return;
|
||||||
char id[1024];
|
char id[1024];
|
||||||
unsigned char isUsed[256];
|
unsigned char isUsed[DIV_MAX_PATTERNS];
|
||||||
bool isNull[256];
|
bool isNull[DIV_MAX_PATTERNS];
|
||||||
if (ImGui::Begin("Pattern Manager",&patManagerOpen,globalWinFlags)) {
|
if (ImGui::Begin("Pattern Manager",&patManagerOpen,globalWinFlags)) {
|
||||||
ImGui::Text("Global Tasks");
|
ImGui::Text("Global Tasks");
|
||||||
|
|
||||||
|
@ -52,19 +52,19 @@ void FurnaceGUI::drawPatManager() {
|
||||||
|
|
||||||
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
for (int i=0; i<e->getTotalChannelCount(); i++) {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
memset(isUsed,0,256);
|
memset(isUsed,0,DIV_MAX_PATTERNS);
|
||||||
memset(isNull,0,256*sizeof(bool));
|
memset(isNull,0,DIV_MAX_PATTERNS*sizeof(bool));
|
||||||
for (int j=0; j<e->curSubSong->ordersLen; j++) {
|
for (int j=0; j<e->curSubSong->ordersLen; j++) {
|
||||||
isUsed[e->curSubSong->orders.ord[i][j]]++;
|
isUsed[e->curSubSong->orders.ord[i][j]]++;
|
||||||
}
|
}
|
||||||
for (int j=0; j<256; j++) {
|
for (int j=0; j<DIV_MAX_PATTERNS; j++) {
|
||||||
isNull[j]=(e->curSubSong->pat[i].data[j]==NULL);
|
isNull[j]=(e->curSubSong->pat[i].data[j]==NULL);
|
||||||
}
|
}
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::Text("%s",e->getChannelShortName(i));
|
ImGui::Text("%s",e->getChannelShortName(i));
|
||||||
|
|
||||||
ImGui::PushID(1000+i);
|
ImGui::PushID(1000+i);
|
||||||
for (int k=0; k<256; k++) {
|
for (int k=0; k<DIV_MAX_PATTERNS; k++) {
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
snprintf(id,1023,"%.2X",k);
|
snprintf(id,1023,"%.2X",k);
|
||||||
|
|
|
@ -875,11 +875,11 @@ void FurnaceGUI::drawPattern() {
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::BeginDisabled(e->curPat[i].effectCols>=8);
|
ImGui::BeginDisabled(e->curPat[i].effectCols>=DIV_MAX_EFFECTS);
|
||||||
snprintf(chanID,2048,">##_RCH%d",i);
|
snprintf(chanID,2048,">##_RCH%d",i);
|
||||||
if (ImGui::SmallButton(chanID)) {
|
if (ImGui::SmallButton(chanID)) {
|
||||||
e->curPat[i].effectCols++;
|
e->curPat[i].effectCols++;
|
||||||
if (e->curPat[i].effectCols>8) e->curPat[i].effectCols=8;
|
if (e->curPat[i].effectCols>DIV_MAX_EFFECTS) e->curPat[i].effectCols=DIV_MAX_EFFECTS;
|
||||||
}
|
}
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,19 +134,19 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
bool isChipVisible[32];
|
bool isChipVisible[DIV_MAX_CHIPS];
|
||||||
bool isTypeVisible[4];
|
bool isTypeVisible[DIV_MAX_SAMPLE_TYPE];
|
||||||
bool isMemVisible[4][32];
|
bool isMemVisible[DIV_MAX_SAMPLE_TYPE][DIV_MAX_CHIPS];
|
||||||
bool isMemWarning[4][32];
|
bool isMemWarning[DIV_MAX_SAMPLE_TYPE][DIV_MAX_CHIPS];
|
||||||
memset(isChipVisible,0,32*sizeof(bool));
|
memset(isChipVisible,0,DIV_MAX_CHIPS*sizeof(bool));
|
||||||
memset(isTypeVisible,0,4*sizeof(bool));
|
memset(isTypeVisible,0,DIV_MAX_SAMPLE_TYPE*sizeof(bool));
|
||||||
memset(isMemVisible,0,32*4*sizeof(bool));
|
memset(isMemVisible,0,DIV_MAX_CHIPS*DIV_MAX_SAMPLE_TYPE*sizeof(bool));
|
||||||
memset(isMemWarning,0,32*4*sizeof(bool));
|
memset(isMemWarning,0,DIV_MAX_CHIPS*DIV_MAX_SAMPLE_TYPE*sizeof(bool));
|
||||||
for (int i=0; i<e->song.systemLen; i++) {
|
for (int i=0; i<e->song.systemLen; i++) {
|
||||||
DivDispatch* dispatch=e->getDispatch(i);
|
DivDispatch* dispatch=e->getDispatch(i);
|
||||||
if (dispatch==NULL) continue;
|
if (dispatch==NULL) continue;
|
||||||
|
|
||||||
for (int j=0; j<4; j++) {
|
for (int j=0; j<DIV_MAX_SAMPLE_TYPE; j++) {
|
||||||
if (dispatch->getSampleMemCapacity(j)==0) continue;
|
if (dispatch->getSampleMemCapacity(j)==0) continue;
|
||||||
isChipVisible[i]=true;
|
isChipVisible[i]=true;
|
||||||
isTypeVisible[j]=true;
|
isTypeVisible[j]=true;
|
||||||
|
@ -155,7 +155,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int selColumns=1;
|
int selColumns=1;
|
||||||
for (int i=0; i<32; i++) {
|
for (int i=0; i<DIV_MAX_CHIPS; i++) {
|
||||||
if (isChipVisible[i]) selColumns++;
|
if (isChipVisible[i]) selColumns++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ void FurnaceGUI::drawSampleEdit() {
|
||||||
ImGui::Text("%d",i+1);
|
ImGui::Text("%d",i+1);
|
||||||
}
|
}
|
||||||
char id[1024];
|
char id[1024];
|
||||||
for (int i=0; i<4; i++) {
|
for (int i=0; i<DIV_MAX_SAMPLE_TYPE; i++) {
|
||||||
if (!isTypeVisible[i]) continue;
|
if (!isTypeVisible[i]) continue;
|
||||||
|
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
|
@ -180,7 +180,7 @@ void FurnaceGUI::drawSongInfo(bool asChild) {
|
||||||
int patLen=e->curSubSong->patLen;
|
int patLen=e->curSubSong->patLen;
|
||||||
if (ImGui::InputInt("##PatLength",&patLen,1,3)) { MARK_MODIFIED
|
if (ImGui::InputInt("##PatLength",&patLen,1,3)) { MARK_MODIFIED
|
||||||
if (patLen<1) patLen=1;
|
if (patLen<1) patLen=1;
|
||||||
if (patLen>256) patLen=256;
|
if (patLen>DIV_MAX_PATTERNS) patLen=DIV_MAX_PATTERNS;
|
||||||
e->curSubSong->patLen=patLen;
|
e->curSubSong->patLen=patLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ void FurnaceGUI::drawSongInfo(bool asChild) {
|
||||||
int ordLen=e->curSubSong->ordersLen;
|
int ordLen=e->curSubSong->ordersLen;
|
||||||
if (ImGui::InputInt("##OrdLength",&ordLen,1,3)) { MARK_MODIFIED
|
if (ImGui::InputInt("##OrdLength",&ordLen,1,3)) { MARK_MODIFIED
|
||||||
if (ordLen<1) ordLen=1;
|
if (ordLen<1) ordLen=1;
|
||||||
if (ordLen>256) ordLen=256;
|
if (ordLen>DIV_MAX_PATTERNS) ordLen=DIV_MAX_PATTERNS;
|
||||||
e->curSubSong->ordersLen=ordLen;
|
e->curSubSong->ordersLen=ordLen;
|
||||||
if (curOrder>=ordLen) {
|
if (curOrder>=ordLen) {
|
||||||
setOrder(ordLen-1);
|
setOrder(ordLen-1);
|
||||||
|
|
|
@ -112,7 +112,7 @@ void FurnaceGUI::drawSysManager() {
|
||||||
ImGui::EndDisabled();
|
ImGui::EndDisabled();
|
||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
if (e->song.systemLen<32) {
|
if (e->song.systemLen<DIV_MAX_CHIPS) {
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
|
|
Loading…
Reference in New Issue