Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt
This commit is contained in:
commit
46865b3adb
29 changed files with 301 additions and 105 deletions
|
|
@ -586,7 +586,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
}
|
||||
if (c.chan>=5 && chan[c.chan].dacMode) {
|
||||
if (skipRegisterWrites) break;
|
||||
//if (skipRegisterWrites) break;
|
||||
if (ins->type==DIV_INS_AMIGA) { // Furnace mode
|
||||
if (c.value!=DIV_NOTE_NULL) chan[c.chan].dacSample=ins->amiga.getSample(c.value);
|
||||
if (chan[c.chan].dacSample<0 || chan[c.chan].dacSample>=parent->song.sampleLen) {
|
||||
|
|
@ -1125,6 +1125,8 @@ void DivPlatformGenesis::forceIns() {
|
|||
}
|
||||
}
|
||||
if (chan[5].dacMode) {
|
||||
chan[5].dacSample=-1;
|
||||
chan[6].dacSample=-1;
|
||||
rWrite(0x2b,0x80);
|
||||
}
|
||||
immWrite(0x22,lfoValue);
|
||||
|
|
|
|||
|
|
@ -677,6 +677,8 @@ void DivPlatformGenesisExt::forceIns() {
|
|||
}
|
||||
}
|
||||
if (chan[5].dacMode) {
|
||||
chan[5].dacSample=-1;
|
||||
chan[6].dacSample=-1;
|
||||
rWrite(0x2b,0x80);
|
||||
}
|
||||
immWrite(0x22,lfoValue);
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
|
|||
if (chan[i].std.pitch.had) {
|
||||
if (chan[i].std.pitch.mode) {
|
||||
chan[i].pitch2+=chan[i].std.pitch.val;
|
||||
CLAMP_VAR(chan[i].pitch2,-32768,32767);
|
||||
CLAMP_VAR(chan[i].pitch2,-1048575,1048575);
|
||||
} else {
|
||||
chan[i].pitch2=chan[i].std.pitch.val;
|
||||
}
|
||||
|
|
@ -244,6 +244,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
|
|||
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
|
||||
//DivInstrument* ins=parent->getIns(chan[i].ins,DIV_INS_PCE);
|
||||
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,2,chan[i].pitch2,chipClock,CHIP_FREQBASE);
|
||||
if (chan[i].freq<0) chan[i].freq=0;
|
||||
if (chan[i].freq>1048575) chan[i].freq=1048575;
|
||||
if (chan[i].keyOn) {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1509,7 +1509,7 @@ DivMacroInt* DivPlatformOPL::getChanMacroInt(int ch) {
|
|||
}
|
||||
|
||||
DivDispatchOscBuffer* DivPlatformOPL::getOscBuffer(int ch) {
|
||||
if (ch>=18) return NULL;
|
||||
if (ch>=totalChans) return NULL;
|
||||
if (oplType==3 && ch<12) {
|
||||
if (chan[ch&(~1)].fourOp) {
|
||||
if (ch&1) {
|
||||
|
|
|
|||
|
|
@ -707,11 +707,11 @@ const void* DivPlatformQSound::getSampleMem(int index) {
|
|||
}
|
||||
|
||||
size_t DivPlatformQSound::getSampleMemCapacity(int index) {
|
||||
return index == 0 ? 16777216 : index == 1 ? MAX(0,16777216 - sampleMemUsage) : 0;
|
||||
return index == 0 ? 16777216 : index == 1 ? (sampleMemUsage>=16777216?1:(16777216 - sampleMemUsage)) : 0;
|
||||
}
|
||||
|
||||
size_t DivPlatformQSound::getSampleMemUsage(int index) {
|
||||
return index == 0 ? sampleMemLen : index == 1 ? MAX(0,sampleMemLenBS - sampleMemUsage) : 0;
|
||||
return index == 0 ? sampleMemLen : index == 1 ? ((sampleMemUsage>=sampleMemLenBS)?0:(sampleMemLenBS - sampleMemUsage)) : 0;
|
||||
}
|
||||
|
||||
bool DivPlatformQSound::isSampleLoaded(int index, int sample) {
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
void SoundUnit::NextSample(short* l, short* r) {
|
||||
// run channels
|
||||
for (int i=0; i<8; i++) {
|
||||
if (chan[i].vol==0 && !chan[i].flags.swvol) {
|
||||
if (chan[i].vol==0 && !chan[i].flags1.swvol) {
|
||||
fns[i]=0;
|
||||
continue;
|
||||
}
|
||||
if (chan[i].flags.pcm) {
|
||||
if (chan[i].flags0.pcm) {
|
||||
ns[i]=pcm[chan[i].pcmpos];
|
||||
} else switch (chan[i].flags.shape) {
|
||||
} else switch (chan[i].flags0.shape) {
|
||||
case 0:
|
||||
ns[i]=(((cycle[i]>>15)&127)>chan[i].duty)*127;
|
||||
break;
|
||||
|
|
@ -47,11 +47,11 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
break;
|
||||
}
|
||||
|
||||
if (chan[i].flags.ring) {
|
||||
if (chan[i].flags0.ring) {
|
||||
ns[i]=(ns[i]*ns[(i+1)&7])>>7;
|
||||
}
|
||||
|
||||
if (chan[i].flags.pcm) {
|
||||
if (chan[i].flags0.pcm) {
|
||||
if (chan[i].freq>0x8000) {
|
||||
pcmdec[i]+=0x8000;
|
||||
} else {
|
||||
|
|
@ -62,18 +62,18 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
if (chan[i].pcmpos<chan[i].pcmbnd) {
|
||||
chan[i].pcmpos++;
|
||||
if (chan[i].pcmpos==chan[i].pcmbnd) {
|
||||
if (chan[i].flags.pcmloop) {
|
||||
if (chan[i].flags1.pcmloop) {
|
||||
chan[i].pcmpos=chan[i].pcmrst;
|
||||
}
|
||||
}
|
||||
chan[i].pcmpos&=(pcmSize-1);
|
||||
} else if (chan[i].flags.pcmloop) {
|
||||
} else if (chan[i].flags1.pcmloop) {
|
||||
chan[i].pcmpos=chan[i].pcmrst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ocycle[i]=cycle[i];
|
||||
if (chan[i].flags.shape==5) {
|
||||
if (chan[i].flags0.shape==5) {
|
||||
switch ((chan[i].duty>>4)&3) {
|
||||
case 0:
|
||||
cycle[i]+=chan[i].freq*1-(chan[i].freq>>3);
|
||||
|
|
@ -92,7 +92,7 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
cycle[i]+=chan[i].freq;
|
||||
}
|
||||
if ((cycle[i]&0xf80000)!=(ocycle[i]&0xf80000)) {
|
||||
if (chan[i].flags.shape==4) {
|
||||
if (chan[i].flags0.shape==4) {
|
||||
lfsr[i]=(lfsr[i]>>1|(((lfsr[i]) ^ (lfsr[i] >> 2) ^ (lfsr[i] >> 3) ^ (lfsr[i] >> 5) ) & 1)<<31);
|
||||
} else {
|
||||
switch ((chan[i].duty>>4)&3) {
|
||||
|
|
@ -114,7 +114,7 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].flags.restim) {
|
||||
if (chan[i].flags1.restim) {
|
||||
if (--rcycle[i]<=0) {
|
||||
cycle[i]=0;
|
||||
rcycle[i]=chan[i].restimer;
|
||||
|
|
@ -122,19 +122,18 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
fns[i]=ns[i]*chan[i].vol*(chan[i].flags.pcm?4:2);
|
||||
if (chan[i].flags.fmode!=0) {
|
||||
fns[i]=ns[i]*chan[i].vol*(chan[i].flags0.pcm?4:2);
|
||||
if (chan[i].flags0.fmode!=0) {
|
||||
int ff=chan[i].cutoff;
|
||||
nslow[i]=nslow[i]+(((ff)*nsband[i])>>16);
|
||||
nshigh[i]=fns[i]-nslow[i]-(((256-chan[i].reson)*nsband[i])>>8);
|
||||
nsband[i]=(((ff)*nshigh[i])>>16)+nsband[i];
|
||||
fns[i]=(((chan[i].flags.fmode&1)?(nslow[i]):(0))+((chan[i].flags.fmode&2)?(nshigh[i]):(0))+((chan[i].flags.fmode&4)?(nsband[i]):(0)));
|
||||
fns[i]=(((chan[i].flags0.fmode&1)?(nslow[i]):(0))+((chan[i].flags0.fmode&2)?(nshigh[i]):(0))+((chan[i].flags0.fmode&4)?(nsband[i]):(0)));
|
||||
}
|
||||
nsL[i]=(fns[i]*SCpantabL[(unsigned char)chan[i].pan])>>8;
|
||||
nsR[i]=(fns[i]*SCpantabR[(unsigned char)chan[i].pan])>>8;
|
||||
oldfreq[i]=chan[i].freq;
|
||||
oldflags[i]=chan[i].flags.flags;
|
||||
if (chan[i].flags.swvol) {
|
||||
if (chan[i].flags1.swvol) {
|
||||
if (--swvolt[i]<=0) {
|
||||
swvolt[i]=chan[i].swvol.speed;
|
||||
if (chan[i].swvol.dir) {
|
||||
|
|
@ -174,7 +173,7 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].flags.swfreq) {
|
||||
if (chan[i].flags1.swfreq) {
|
||||
if (--swfreqt[i]<=0) {
|
||||
swfreqt[i]=chan[i].swfreq.speed;
|
||||
if (chan[i].swfreq.dir) {
|
||||
|
|
@ -198,7 +197,7 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].flags.swcut) {
|
||||
if (chan[i].flags1.swcut) {
|
||||
if (--swcutt[i]<=0) {
|
||||
swcutt[i]=chan[i].swcut.speed;
|
||||
if (chan[i].swcut.dir) {
|
||||
|
|
@ -222,11 +221,11 @@ void SoundUnit::NextSample(short* l, short* r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (chan[i].flags.resosc) {
|
||||
if (chan[i].flags1.resosc) {
|
||||
cycle[i]=0;
|
||||
rcycle[i]=chan[i].restimer;
|
||||
ocycle[i]=0;
|
||||
chan[i].flags.resosc=0;
|
||||
chan[i].flags1.resosc=0;
|
||||
}
|
||||
if (muted[i]) {
|
||||
nsL[i]=0;
|
||||
|
|
@ -377,7 +376,6 @@ void SoundUnit::Reset() {
|
|||
swcutt[i]=1;
|
||||
lfsr[i]=0xaaaa;
|
||||
oldfreq[i]=0;
|
||||
oldflags[i]=0;
|
||||
pcmdec[i]=0;
|
||||
}
|
||||
dsCounterL=0;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ class SoundUnit {
|
|||
signed char ilFeedback0;
|
||||
signed char ilFeedback1;
|
||||
unsigned short oldfreq[8];
|
||||
unsigned short oldflags[8];
|
||||
unsigned int pcmSize;
|
||||
bool dsOut;
|
||||
short dsCounterL, dsCounterR;
|
||||
|
|
@ -44,12 +43,17 @@ class SoundUnit {
|
|||
signed char vol;
|
||||
signed char pan;
|
||||
union {
|
||||
unsigned short flags;
|
||||
unsigned char val;
|
||||
struct {
|
||||
unsigned char shape: 3;
|
||||
unsigned char pcm: 1;
|
||||
unsigned char ring: 1;
|
||||
unsigned char fmode: 3;
|
||||
};
|
||||
} flags0;
|
||||
union {
|
||||
unsigned char val;
|
||||
struct {
|
||||
unsigned char resosc: 1;
|
||||
unsigned char resfilt: 1;
|
||||
unsigned char pcmloop: 1;
|
||||
|
|
@ -59,7 +63,7 @@ class SoundUnit {
|
|||
unsigned char swcut: 1;
|
||||
unsigned char padding: 1;
|
||||
};
|
||||
} flags;
|
||||
} flags1;
|
||||
unsigned short cutoff;
|
||||
unsigned char duty;
|
||||
unsigned char reson;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#define rWrite(a,v) if (!skipRegisterWrites) {writes.emplace(a,v); if (dumpWrites) {addWrite(a,v);}}
|
||||
#define postWrite(a,v) postDACWrites.emplace(a,v);
|
||||
|
||||
#define CHIP_DIVIDER 32
|
||||
|
||||
|
|
@ -186,7 +187,7 @@ void DivPlatformSwan::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
dacRate=((double)chipClock/2)/MAX(1,off*chan[i].freq);
|
||||
if (dumpWrites) addWrite(0xffff0001,dacRate);
|
||||
if (dumpWrites) postWrite(0xffff0001,dacRate);
|
||||
}
|
||||
if (chan[i].freq>2048) chan[i].freq=2048;
|
||||
if (chan[i].freq<1) chan[i].freq=1;
|
||||
|
|
@ -217,6 +218,12 @@ void DivPlatformSwan::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
rWrite(0x10,sndCtrl);
|
||||
|
||||
while (!postDACWrites.empty()) {
|
||||
const DivRegWrite& w=postDACWrites.back();
|
||||
if (dumpWrites) addWrite(w.addr,w.val);
|
||||
postDACWrites.pop();
|
||||
}
|
||||
}
|
||||
|
||||
int DivPlatformSwan::dispatch(DivCommand c) {
|
||||
|
|
@ -237,11 +244,11 @@ int DivPlatformSwan::dispatch(DivCommand c) {
|
|||
if (c.value!=DIV_NOTE_NULL) dacSample=ins->amiga.getSample(c.value);
|
||||
if (dacSample<0 || dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
if (dumpWrites) postWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0000,dacSample);
|
||||
postWrite(0xffff0000,dacSample);
|
||||
}
|
||||
}
|
||||
if (c.value!=DIV_NOTE_NULL) {
|
||||
|
|
@ -260,14 +267,14 @@ int DivPlatformSwan::dispatch(DivCommand c) {
|
|||
dacSample=12*sampleBank+chan[1].note%12;
|
||||
if (dacSample>=parent->song.sampleLen) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
if (dumpWrites) postWrite(0xffff0002,0);
|
||||
break;
|
||||
} else {
|
||||
if (dumpWrites) addWrite(0xffff0000,dacSample);
|
||||
if (dumpWrites) postWrite(0xffff0000,dacSample);
|
||||
}
|
||||
dacRate=parent->getSample(dacSample)->rate;
|
||||
if (dumpWrites) {
|
||||
addWrite(0xffff0001,dacRate);
|
||||
postWrite(0xffff0001,dacRate);
|
||||
}
|
||||
chan[1].active=true;
|
||||
chan[1].keyOn=true;
|
||||
|
|
@ -298,7 +305,7 @@ int DivPlatformSwan::dispatch(DivCommand c) {
|
|||
case DIV_CMD_NOTE_OFF:
|
||||
if (c.chan==1&&pcm) {
|
||||
dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
if (dumpWrites) postWrite(0xffff0002,0);
|
||||
pcm=false;
|
||||
}
|
||||
chan[c.chan].active=false;
|
||||
|
|
@ -463,6 +470,7 @@ int DivPlatformSwan::getRegisterPoolSize() {
|
|||
|
||||
void DivPlatformSwan::reset() {
|
||||
while (!writes.empty()) writes.pop();
|
||||
while (!postDACWrites.empty()) postDACWrites.pop();
|
||||
memset(regPool,0,128);
|
||||
for (int i=0; i<4; i++) {
|
||||
chan[i]=Channel();
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ class DivPlatformSwan: public DivDispatch {
|
|||
QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {}
|
||||
};
|
||||
std::queue<QueuedWrite> writes;
|
||||
std::queue<DivRegWrite> postDACWrites;
|
||||
WSwan* ws;
|
||||
void updateWave(int ch);
|
||||
friend void putDispatchChip(void*,int);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue