Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt
* 'master' of https://github.com/tildearrow/furnace: (26 commits) prepare for #38 NES: DPCM work! fix bug caused by new renderSamples approach NES: prepare for DPCM OPZ: more fixed frequency mode fixes OPZ: possibly fix fixed freq emulation OPZ: fix muting OPL: fix panning damn it per-channel oscilloscope, part 10 NES: NSFPlay per-channel osc NES: NSFPlay muting NES: now fix tri_mute NES: finally fix typo in playback engine NES: wire up NSFplay now fix it damn it now move these files add readme convertir de Shift-JIS a UTF-8 ... # Conflicts: # src/engine/engine.cpp # src/engine/engine.h # src/engine/platform/nes.cpp # src/engine/vgmOps.cpp # src/gui/stats.cpp
This commit is contained in:
commit
e136db6d7a
53 changed files with 3990 additions and 393 deletions
|
|
@ -507,148 +507,12 @@ void DivEngine::renderSamples() {
|
|||
song.sample[i]->render();
|
||||
}
|
||||
|
||||
// step 2: allocate ADPCM-A samples
|
||||
if (adpcmAMem==NULL) adpcmAMem=new unsigned char[16777216];
|
||||
|
||||
size_t memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
int paddedLen=(s->lengthA+255)&(~0xff);
|
||||
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
|
||||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
// step 2: render samples to dispatch
|
||||
for (int i=0; i<song.systemLen; i++) {
|
||||
if (disCont[i].dispatch!=NULL) {
|
||||
disCont[i].dispatch->renderSamples();
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of ADPCM-A memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=16777216) {
|
||||
memcpy(adpcmAMem+memPos,s->dataA,16777216-memPos);
|
||||
logW("out of ADPCM-A memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(adpcmAMem+memPos,s->dataA,paddedLen);
|
||||
}
|
||||
s->offA=memPos;
|
||||
memPos+=paddedLen;
|
||||
}
|
||||
adpcmAMemLen=memPos+256;
|
||||
|
||||
// step 2: allocate ADPCM-B samples
|
||||
if (adpcmBMem==NULL) adpcmBMem=new unsigned char[16777216];
|
||||
|
||||
memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
int paddedLen=(s->lengthB+255)&(~0xff);
|
||||
if ((memPos&0xf00000)!=((memPos+paddedLen)&0xf00000)) {
|
||||
memPos=(memPos+0xfffff)&0xf00000;
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of ADPCM-B memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=16777216) {
|
||||
memcpy(adpcmBMem+memPos,s->dataB,16777216-memPos);
|
||||
logW("out of ADPCM-B memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(adpcmBMem+memPos,s->dataB,paddedLen);
|
||||
}
|
||||
s->offB=memPos;
|
||||
memPos+=paddedLen;
|
||||
}
|
||||
adpcmBMemLen=memPos+256;
|
||||
|
||||
// step 4: allocate qsound pcm samples
|
||||
if (qsoundMem==NULL) qsoundMem=new unsigned char[16777216];
|
||||
memset(qsoundMem,0,16777216);
|
||||
|
||||
memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
int length=s->length8;
|
||||
if (length>65536-16) {
|
||||
length=65536-16;
|
||||
}
|
||||
if ((memPos&0xff0000)!=((memPos+length)&0xff0000)) {
|
||||
memPos=(memPos+0xffff)&0xff0000;
|
||||
}
|
||||
if (memPos>=16777216) {
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+length>=16777216) {
|
||||
for (unsigned int i=0; i<16777216-(memPos+length); i++) {
|
||||
qsoundMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
}
|
||||
logW("out of QSound PCM memory for sample %d!",i);
|
||||
} else {
|
||||
for (int i=0; i<length; i++) {
|
||||
qsoundMem[(memPos+i)^0x8000]=s->data8[i];
|
||||
}
|
||||
}
|
||||
s->offQSound=memPos^0x8000;
|
||||
memPos+=length+16;
|
||||
}
|
||||
qsoundMemLen=memPos+256;
|
||||
|
||||
// step 4: allocate x1-010 pcm samples
|
||||
if (x1_010Mem==NULL) x1_010Mem=new unsigned char[1048576];
|
||||
memset(x1_010Mem,0,1048576);
|
||||
|
||||
memPos=0;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
int paddedLen=(s->length8+4095)&(~0xfff);
|
||||
// fit sample bank size to 128KB for Seta 2 external bankswitching logic (not emulated yet!)
|
||||
if (paddedLen>131072) {
|
||||
paddedLen=131072;
|
||||
}
|
||||
if ((memPos&0xfe0000)!=((memPos+paddedLen)&0xfe0000)) {
|
||||
memPos=(memPos+0x1ffff)&0xfe0000;
|
||||
}
|
||||
if (memPos>=1048576) {
|
||||
logW("out of X1-010 memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+paddedLen>=1048576) {
|
||||
memcpy(x1_010Mem+memPos,s->data8,1048576-memPos);
|
||||
logW("out of X1-010 memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(x1_010Mem+memPos,s->data8,paddedLen);
|
||||
}
|
||||
s->offX1_010=memPos;
|
||||
memPos+=paddedLen;
|
||||
}
|
||||
x1_010MemLen=memPos+256;
|
||||
|
||||
// step 5: allocate ES5506 pcm samples (forces depth for all samples to 16 bit due to chip limitation, compressed sample just LSB disconnected)
|
||||
if (es5506Mem==NULL) es5506Mem=new signed short[16777216/sizeof(short)]; // 2Mword * 4 banks
|
||||
memset(es5506Mem,0,16777216);
|
||||
|
||||
memPos=128;
|
||||
for (int i=0; i<song.sampleLen; i++) {
|
||||
DivSample* s=song.sample[i];
|
||||
unsigned int length=s->length16;
|
||||
// fit sample size to single bank size
|
||||
if (length>(2097152-64)*sizeof(short)) {
|
||||
length=(2097152-64)*sizeof(short);
|
||||
}
|
||||
if ((memPos&0xc00000)!=((memPos+length+128)&0xc00000)) {
|
||||
memPos=((memPos+0x3fffff)&0xc00000)+128;
|
||||
}
|
||||
if (memPos>=(16777216-128)) {
|
||||
logW("out of ES5506 memory for sample %d!",i);
|
||||
break;
|
||||
}
|
||||
if (memPos+length>=(16777216-128)) {
|
||||
memcpy(es5506Mem+(memPos/sizeof(short)),s->data16,16777216-memPos-128);
|
||||
logW("out of ES5506 memory for sample %d!",i);
|
||||
} else {
|
||||
memcpy(es5506Mem+(memPos/sizeof(short)),s->data16,length);
|
||||
}
|
||||
s->offES5506=memPos;
|
||||
memPos+=length;
|
||||
}
|
||||
es5506MemLen=memPos+256;
|
||||
}
|
||||
|
||||
String DivEngine::encodeSysDesc(std::vector<int>& desc) {
|
||||
|
|
@ -756,11 +620,11 @@ void DivEngine::createNew(const int* description) {
|
|||
initSongWithDesc(description);
|
||||
}
|
||||
recalcChans();
|
||||
renderSamples();
|
||||
saveLock.unlock();
|
||||
BUSY_END;
|
||||
initDispatch();
|
||||
BUSY_BEGIN;
|
||||
renderSamples();
|
||||
reset();
|
||||
BUSY_END;
|
||||
}
|
||||
|
|
@ -998,6 +862,11 @@ DivSample* DivEngine::getSample(int index) {
|
|||
return song.sample[index];
|
||||
}
|
||||
|
||||
DivDispatch* DivEngine::getDispatch(int index) {
|
||||
if (index<0 || index>=song.systemLen) return NULL;
|
||||
return disCont[index].dispatch;
|
||||
}
|
||||
|
||||
void DivEngine::setLoops(int loops) {
|
||||
remainingLoops=loops;
|
||||
}
|
||||
|
|
@ -2511,6 +2380,7 @@ bool DivEngine::switchMaster() {
|
|||
} else {
|
||||
return false;
|
||||
}
|
||||
renderSamples();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -2808,9 +2678,9 @@ bool DivEngine::init() {
|
|||
|
||||
// set default system preset
|
||||
if (!hasLoadedSomething) {
|
||||
logI("setting");
|
||||
logD("setting default preset");
|
||||
std::vector<int> preset=decodeSysDesc(getConfString("initialSys",""));
|
||||
logI("preset size %ld",preset.size());
|
||||
logD("preset size %ld",preset.size());
|
||||
if (preset.size()>0 && (preset.size()&3)==0) {
|
||||
preset.push_back(0);
|
||||
initSongWithDesc(preset.data());
|
||||
|
|
@ -2856,6 +2726,7 @@ bool DivEngine::init() {
|
|||
oscBuf[1]=new float[32768];
|
||||
|
||||
initDispatch();
|
||||
renderSamples();
|
||||
reset();
|
||||
active=true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue