mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-16 01:35:07 +00:00
Mute on pan registers instead
This commit is contained in:
parent
43cfb09acf
commit
eb3a73c38b
2 changed files with 38 additions and 27 deletions
|
@ -93,19 +93,27 @@ void DivPlatformVERA::acquire(short* bufL, short* bufR, size_t start, size_t len
|
||||||
if (chan[16].accum>=128) {
|
if (chan[16].accum>=128) {
|
||||||
DivSample* s=parent->getSample(chan[16].pcm.sample);
|
DivSample* s=parent->getSample(chan[16].pcm.sample);
|
||||||
if (s->samples>0) {
|
if (s->samples>0) {
|
||||||
|
int tmp_l=0;
|
||||||
|
int tmp_r=0;
|
||||||
|
if (!isMuted[16]) {
|
||||||
// TODO stereo samples once DivSample has a support for it
|
// TODO stereo samples once DivSample has a support for it
|
||||||
switch (s->depth) {
|
switch (s->depth) {
|
||||||
case 8:
|
case 8:
|
||||||
chan[16].pcm.out_l=chan[16].pcm.pan&1?(s->data8[chan[16].pcm.pos]*256):0;
|
tmp_l=s->data8[chan[16].pcm.pos]*256;
|
||||||
chan[16].pcm.out_r=chan[16].pcm.pan&2?(s->data8[chan[16].pcm.pos]*256):0;
|
tmp_r=tmp_l;
|
||||||
regPool[64]|=0x20; // for register viewer purposes
|
regPool[64]|=0x20; // for register viewer purposes
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
chan[16].pcm.out_l=chan[16].pcm.pan&1?(s->data16[chan[16].pcm.pos]):0;
|
tmp_l=s->data16[chan[16].pcm.pos];
|
||||||
chan[16].pcm.out_r=chan[16].pcm.pan&2?(s->data16[chan[16].pcm.pos]):0;
|
tmp_r=tmp_l;
|
||||||
regPool[64]&=~0x20;
|
regPool[64]&=~0x20;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!(chan[16].pan&1)) tmp_l=0;
|
||||||
|
if (!(chan[16].pan&2)) tmp_r=0;
|
||||||
|
}
|
||||||
|
chan[16].pcm.out_l=tmp_l;
|
||||||
|
chan[16].pcm.out_r=tmp_r;
|
||||||
} else {
|
} else {
|
||||||
chan[16].pcm.sample=-1;
|
chan[16].pcm.sample=-1;
|
||||||
}
|
}
|
||||||
|
@ -136,9 +144,11 @@ void DivPlatformVERA::reset() {
|
||||||
memset(regPool,0,66);
|
memset(regPool,0,66);
|
||||||
for (int i=0; i<16; i++) {
|
for (int i=0; i<16; i++) {
|
||||||
chan[i].vol=63;
|
chan[i].vol=63;
|
||||||
rWriteHi(i,2,3); // default pan
|
chan[i].pan=3;
|
||||||
|
rWriteHi(i,2,isMuted[i]?0:3);
|
||||||
}
|
}
|
||||||
chan[16].vol=15;
|
chan[16].vol=15;
|
||||||
|
chan[16].pan=3;
|
||||||
noiseState=1;
|
noiseState=1;
|
||||||
noiseOut=0;
|
noiseOut=0;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +175,7 @@ void DivPlatformVERA::tick() {
|
||||||
chan[i].std.next();
|
chan[i].std.next();
|
||||||
if (chan[i].std.hadVol) {
|
if (chan[i].std.hadVol) {
|
||||||
chan[i].outVol=MAX(chan[i].vol+chan[i].std.vol-63,0);
|
chan[i].outVol=MAX(chan[i].vol+chan[i].std.vol-63,0);
|
||||||
rWriteLo(i,2,isMuted[i]?0:(chan[i].outVol&63));
|
rWriteLo(i,2,chan[i].outVol);
|
||||||
}
|
}
|
||||||
if (chan[i].std.hadArp) {
|
if (chan[i].std.hadArp) {
|
||||||
if (!chan[i].inPorta) {
|
if (!chan[i].inPorta) {
|
||||||
|
@ -200,7 +210,7 @@ void DivPlatformVERA::tick() {
|
||||||
chan[16].std.next();
|
chan[16].std.next();
|
||||||
if (chan[16].std.hadVol) {
|
if (chan[16].std.hadVol) {
|
||||||
chan[16].outVol=MAX(chan[16].vol+MIN(chan[16].std.vol/4,15)-15,0);
|
chan[16].outVol=MAX(chan[16].vol+MIN(chan[16].std.vol/4,15)-15,0);
|
||||||
rWriteFIFOVol(isMuted[16]?0:(chan[16].outVol&15));
|
rWriteFIFOVol(chan[16].outVol&15);
|
||||||
}
|
}
|
||||||
if (chan[16].std.hadArp) {
|
if (chan[16].std.hadArp) {
|
||||||
if (!chan[16].inPorta) {
|
if (!chan[16].inPorta) {
|
||||||
|
@ -229,16 +239,15 @@ int DivPlatformVERA::dispatch(DivCommand c) {
|
||||||
int tmp;
|
int tmp;
|
||||||
switch (c.cmd) {
|
switch (c.cmd) {
|
||||||
case DIV_CMD_NOTE_ON:
|
case DIV_CMD_NOTE_ON:
|
||||||
tmp = isMuted[c.chan]?0:chan[c.chan].vol;
|
|
||||||
if(c.chan<16) {
|
if(c.chan<16) {
|
||||||
rWriteLo(c.chan,2,tmp)
|
rWriteLo(c.chan,2,chan[c.chan].vol)
|
||||||
} else {
|
} else {
|
||||||
chan[c.chan].pcm.sample=parent->getIns(chan[16].ins)->amiga.initSample;
|
chan[c.chan].pcm.sample=parent->getIns(chan[16].ins)->amiga.initSample;
|
||||||
if (chan[c.chan].pcm.sample<0 || chan[c.chan].pcm.sample>=parent->song.sampleLen) {
|
if (chan[c.chan].pcm.sample<0 || chan[c.chan].pcm.sample>=parent->song.sampleLen) {
|
||||||
chan[c.chan].pcm.sample=-1;
|
chan[c.chan].pcm.sample=-1;
|
||||||
}
|
}
|
||||||
chan[16].pcm.pos=0;
|
chan[16].pcm.pos=0;
|
||||||
rWriteFIFOVol(tmp);
|
rWriteFIFOVol(chan[c.chan].vol);
|
||||||
}
|
}
|
||||||
if (c.value!=DIV_NOTE_NULL) {
|
if (c.value!=DIV_NOTE_NULL) {
|
||||||
chan[c.chan].baseFreq=calcNoteFreq(c.chan,c.value);
|
chan[c.chan].baseFreq=calcNoteFreq(c.chan,c.value);
|
||||||
|
@ -270,11 +279,11 @@ int DivPlatformVERA::dispatch(DivCommand c) {
|
||||||
if (c.chan<16) {
|
if (c.chan<16) {
|
||||||
tmp=c.value&0x3f;
|
tmp=c.value&0x3f;
|
||||||
chan[c.chan].vol=tmp;
|
chan[c.chan].vol=tmp;
|
||||||
rWriteLo(c.chan,2,(isMuted[c.chan]?0:tmp));
|
rWriteLo(c.chan,2,tmp);
|
||||||
} else {
|
} else {
|
||||||
tmp=c.value&0x0f;
|
tmp=c.value&0x0f;
|
||||||
chan[c.chan].vol=tmp;
|
chan[c.chan].vol=tmp;
|
||||||
rWriteFIFOVol(isMuted[c.chan]?0:tmp);
|
rWriteFIFOVol(tmp);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DIV_CMD_GET_VOLUME:
|
case DIV_CMD_GET_VOLUME:
|
||||||
|
@ -328,10 +337,9 @@ int DivPlatformVERA::dispatch(DivCommand c) {
|
||||||
tmp=0;
|
tmp=0;
|
||||||
tmp|=(c.value&0x10)?1:0;
|
tmp|=(c.value&0x10)?1:0;
|
||||||
tmp|=(c.value&0x01)?2:0;
|
tmp|=(c.value&0x01)?2:0;
|
||||||
|
chan[c.chan].pan=tmp&3;
|
||||||
if (c.chan<16) {
|
if (c.chan<16) {
|
||||||
rWriteHi(c.chan,2,tmp);
|
rWriteHi(c.chan,2,isMuted[c.chan]?0:chan[c.chan].pan);
|
||||||
} else {
|
|
||||||
chan[c.chan].pcm.pan = tmp&3;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -365,6 +373,9 @@ int DivPlatformVERA::getRegisterPoolSize() {
|
||||||
|
|
||||||
void DivPlatformVERA::muteChannel(int ch, bool mute) {
|
void DivPlatformVERA::muteChannel(int ch, bool mute) {
|
||||||
isMuted[ch]=mute;
|
isMuted[ch]=mute;
|
||||||
|
if (ch<16) {
|
||||||
|
rWriteHi(ch,2,mute?0:chan[ch].pan);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DivPlatformVERA::isStereo() {
|
bool DivPlatformVERA::isStereo() {
|
||||||
|
|
|
@ -27,7 +27,7 @@ class DivPlatformVERA: public DivDispatch {
|
||||||
protected:
|
protected:
|
||||||
struct Channel {
|
struct Channel {
|
||||||
int freq, baseFreq, pitch, note;
|
int freq, baseFreq, pitch, note;
|
||||||
unsigned char ins;
|
unsigned char ins, pan;
|
||||||
bool active, freqChanged, inPorta;
|
bool active, freqChanged, inPorta;
|
||||||
int vol, outVol;
|
int vol, outVol;
|
||||||
unsigned accum;
|
unsigned accum;
|
||||||
|
@ -39,10 +39,10 @@ class DivPlatformVERA: public DivDispatch {
|
||||||
int out_l, out_r;
|
int out_l, out_r;
|
||||||
unsigned pos;
|
unsigned pos;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
unsigned char freq, pan;
|
unsigned char freq;
|
||||||
PCMChannel(): sample(-1), out_l(0), out_r(0), pos(0), len(0), freq(0), pan(3) {}
|
PCMChannel(): sample(-1), out_l(0), out_r(0), pos(0), len(0), freq(0) {}
|
||||||
} pcm;
|
} pcm;
|
||||||
Channel(): freq(0), baseFreq(0), pitch(0), note(0), ins(-1), active(false), freqChanged(false), inPorta(false), vol(0), outVol(0), accum(0), noiseval(0) {}
|
Channel(): freq(0), baseFreq(0), pitch(0), note(0), ins(-1), pan(0), active(false), freqChanged(false), inPorta(false), vol(0), outVol(0), accum(0), noiseval(0) {}
|
||||||
};
|
};
|
||||||
Channel chan[17];
|
Channel chan[17];
|
||||||
bool isMuted[17];
|
bool isMuted[17];
|
||||||
|
|
Loading…
Reference in a new issue