Merge branch 'master' of https://github.com/tildearrow/furnace into es5506_alt

# Conflicts:
#	src/gui/insEdit.cpp
#	src/gui/sampleEdit.cpp
This commit is contained in:
cam900 2022-04-26 12:54:11 +09:00
commit 97d2bddf1f
66 changed files with 1118 additions and 312 deletions

View file

@ -34,7 +34,7 @@ class DivPlatformAmiga: public DivDispatch {
int audSub;
signed char audDat;
int sample, wave;
unsigned char ins;
int ins;
int busClock;
int note;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave, setPos, useV, useP;

View file

@ -37,7 +37,7 @@ class DivPlatformArcade: public DivDispatch {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
int vol, outVol;

View file

@ -33,7 +33,8 @@ class DivPlatformAY8910: public DivDispatch {
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, note, pitch;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View file

@ -29,7 +29,8 @@ class DivPlatformAY8930: public DivDispatch {
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, note, pitch;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen, duty;
int ins;
unsigned char psgMode, autoEnvNum, autoEnvDen, duty;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View file

@ -28,8 +28,7 @@
class DivPlatformBubSysWSG: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
signed char waveROM[32] = {0}; // 4 bit PROM per channel on bubble system

View file

@ -131,7 +131,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (ins->c64.filterIsAbs) {
filtCut=MIN(2047,chan[i].std.vol.val);
} else {
filtCut-=((signed char)chan[i].std.vol.val-18)*7;
filtCut-=((signed char)chan[i].std.vol.val)*7;
if (filtCut>2047) filtCut=2047;
if (filtCut<0) filtCut=0;
}
@ -161,7 +161,7 @@ void DivPlatformC64::tick(bool sysTick) {
if (ins->c64.dutyIsAbs) {
chan[i].duty=chan[i].std.duty.val;
} else {
chan[i].duty-=((signed char)chan[i].std.duty.val-12)*4;
chan[i].duty-=((signed char)chan[i].std.duty.val)*4;
}
rWrite(i*7+2,chan[i].duty&0xff);
rWrite(i*7+3,chan[i].duty>>8);

View file

@ -26,8 +26,8 @@
class DivPlatformC64: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, testWhen, note;
unsigned char ins, sweep, wave, attack, decay, sustain, release;
int freq, baseFreq, pitch, prevFreq, testWhen, note, ins;
unsigned char sweep, wave, attack, decay, sustain, release;
short duty;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, filter;
bool resetMask, resetFilter, resetDuty, ring, sync;

View file

@ -443,7 +443,7 @@ void DivPlatformES5506::tick(bool sysTick) {
pageWrite(0x00|i,0x06,0); // Clear ECOUNT
pageWrite(0x20|i,0x03,chan[i].pcm.reversed?chan[i].pcm.end:chan[i].pcm.start); // Set ACCUM to start address
pageWrite(0x00|i,0x07,0xffff); // Set K1 and K2 to 0xffff
pageWrite(0x00|i,0x09,0xffff);
pageWrite(0x00|i,0x09,0xffff,~0,(chanMax+1)*4*2); // needs to 4 sample period delay
pageWrite(0x00|i,0x01,chan[i].freq);
pageWrite(0x20|i,0x01,(chan[i].pcm.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT)?chan[i].pcm.start:chan[i].pcm.loopStart);
pageWrite(0x20|i,0x02,(chan[i].pcm.loopMode==DIV_SAMPLE_LOOPMODE_ONESHOT)?chan[i].pcm.end:chan[i].pcm.loopEnd);
@ -451,7 +451,7 @@ void DivPlatformES5506::tick(bool sysTick) {
pageWrite(0x00|i,0x03,((unsigned char)chan[i].envelope.lVRamp)<<8);
pageWrite(0x00|i,0x05,((unsigned char)chan[i].envelope.rVRamp)<<8);
pageWrite(0x00|i,0x0a,(((unsigned char)chan[i].envelope.k1Ramp)<<8)|(chan[i].envelope.k1Slow?1:0));
pageWrite(0x00|i,0x08,(((unsigned char)chan[i].envelope.k2Ramp)<<8)|(chan[i].envelope.k2Slow?1:0),~0,(chanMax+1)*4*2); // needs to 4 sample period delay
pageWrite(0x00|i,0x08,(((unsigned char)chan[i].envelope.k2Ramp)<<8)|(chan[i].envelope.k2Slow?1:0));
// initialize filter
pageWriteMask(0x00|i,0x5f,0x00,(chan[i].pcm.bank<<14)|(chan[i].filter.mode<<8),0xc300);
if ((chan[i].std.ex2.mode==0) && (chan[i].std.ex2.had)) {

View file

@ -54,10 +54,7 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
loopEnd(0),
loopMode(DIV_SAMPLE_LOOPMODE_ONESHOT) {}
} pcm;
int freq, baseFreq, pitch;
int sample, wave;
unsigned char ins;
int note;
int freq, baseFreq, pitch, note, ins, sample, wave;
bool active, insChanged, freqChanged, volChanged, keyOn, keyOff, inPorta, useWave, isReverseLoop;
struct FilterChanged { // Filter changed flags
@ -103,9 +100,10 @@ class DivPlatformES5506: public DivDispatch, public es550x_intf {
freq(0),
baseFreq(0),
pitch(0),
sample(-1),
ins(-1),
note(0),
ins(-1),
sample(-1),
wave(-1),
active(false),
insChanged(true),
freqChanged(false),

View file

@ -26,8 +26,8 @@
class DivPlatformFDS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note, modFreq;
unsigned char ins, duty, sweep, modDepth, modPos;
int freq, baseFreq, pitch, prevFreq, note, modFreq, ins;
unsigned char duty, sweep, modDepth, modPos;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, modOn;
signed char vol, outVol, wave;
signed char modTable[32];

View file

@ -27,8 +27,8 @@
class DivPlatformGB: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta;
signed char vol, outVol, wave;
DivMacroInt std;

View file

@ -86,14 +86,22 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
static int os[2];
for (size_t h=start; h<start+len; h++) {
if (!dacReady) {
dacDelay+=32000;
if (dacDelay>=rate) {
dacDelay-=rate;
dacReady=true;
}
}
if (dacMode && dacSample!=-1) {
dacPeriod-=6;
if (dacPeriod<1) {
dacPeriod+=dacRate;
if (dacPeriod>=rate) {
DivSample* s=parent->getSample(dacSample);
if (s->samples>0) {
if (!isMuted[5]) {
if (writes.size()<16) {
if (dacReady && writes.size()<16) {
urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80);
dacReady=false;
}
}
dacPos++;
@ -107,7 +115,7 @@ void DivPlatformGenesis::acquire_nuked(short* bufL, short* bufR, size_t start, s
}
}
}
dacPeriod+=MAX(40,dacRate);
while (dacPeriod>=rate) dacPeriod-=rate;
} else {
dacSample=-1;
}
@ -156,14 +164,22 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
static int os[2];
for (size_t h=start; h<start+len; h++) {
if (!dacReady) {
dacDelay+=32000;
if (dacDelay>=rate) {
dacDelay-=rate;
dacReady=true;
}
}
if (dacMode && dacSample!=-1) {
dacPeriod-=24;
if (dacPeriod<1) {
dacPeriod+=dacRate;
if (dacPeriod>=rate) {
DivSample* s=parent->getSample(dacSample);
if (s->samples>0) {
if (!isMuted[5]) {
if (writes.size()<16) {
if (dacReady && writes.size()<16) {
urgentWrite(0x2a,(unsigned char)s->data8[dacPos]+0x80);
dacReady=false;
}
}
dacPos++;
@ -177,7 +193,7 @@ void DivPlatformGenesis::acquire_ymfm(short* bufL, short* bufR, size_t start, si
}
}
}
dacPeriod+=MAX(40,dacRate);
while (dacPeriod>=rate) dacPeriod-=rate;
} else {
dacSample=-1;
}
@ -247,15 +263,15 @@ void DivPlatformGenesis::tick(bool sysTick) {
if (chan[i].std.arp.had) {
if (!chan[i].inPorta) {
if (chan[i].std.arp.mode) {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].std.arp.val);
chan[i].baseFreq=NOTE_FNUM_BLOCK(chan[i].std.arp.val,11);
} else {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note+(signed char)chan[i].std.arp.val);
chan[i].baseFreq=NOTE_FNUM_BLOCK(chan[i].note+(signed char)chan[i].std.arp.val,11);
}
}
chan[i].freqChanged=true;
} else {
if (chan[i].std.arp.mode && chan[i].std.arp.finished) {
chan[i].baseFreq=NOTE_FREQUENCY(chan[i].note);
chan[i].baseFreq=NOTE_FNUM_BLOCK(chan[i].note,11);
chan[i].freqChanged=true;
}
}
@ -396,11 +412,20 @@ void DivPlatformGenesis::tick(bool sysTick) {
for (int i=0; i<6; i++) {
if (i==2 && extMode) continue;
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,octave(chan[i].baseFreq));
if (chan[i].freq>262143) chan[i].freq=262143;
int freqt=toFreq(chan[i].freq)+chan[i].std.pitch.val;
immWrite(chanOffs[i]+ADDR_FREQH,freqt>>8);
immWrite(chanOffs[i]+ADDR_FREQ,freqt&0xff);
int fNum=parent->calcFreq(chan[i].baseFreq&0x7ff,chan[i].pitch,false,4)+chan[i].std.pitch.val;
int block=(chan[i].baseFreq&0xf800)>>11;
if (fNum<0) fNum=0;
if (fNum>2047) {
while (block<7) {
fNum>>=1;
block++;
}
if (fNum>2047) fNum=2047;
}
chan[i].freq=(block<<11)|fNum;
if (chan[i].freq>0x3fff) chan[i].freq=0x3fff;
immWrite(chanOffs[i]+ADDR_FREQH,chan[i].freq>>8);
immWrite(chanOffs[i]+ADDR_FREQ,chan[i].freq&0xff);
if (chan[i].furnaceDac && dacMode) {
double off=1.0;
if (dacSample>=0 && dacSample<parent->song.sampleLen) {
@ -408,12 +433,13 @@ void DivPlatformGenesis::tick(bool sysTick) {
if (s->centerRate<1) {
off=1.0;
} else {
off=8363.0/(double)s->centerRate;
off=(double)s->centerRate/8363.0;
}
}
dacRate=(1280000*1.25*off)/MAX(1,chan[i].baseFreq);
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,false,4)+chan[i].std.pitch.val;
dacRate=chan[i].freq*off;
if (dacRate<1) dacRate=1;
if (dumpWrites) addWrite(0xffff0001,1280000/dacRate);
if (dumpWrites) addWrite(0xffff0001,dacRate);
}
chan[i].freqChanged=false;
}
@ -424,47 +450,6 @@ void DivPlatformGenesis::tick(bool sysTick) {
}
}
int DivPlatformGenesis::octave(int freq) {
if (freq>=82432) {
return 128;
} else if (freq>=41216) {
return 64;
} else if (freq>=20608) {
return 32;
} else if (freq>=10304) {
return 16;
} else if (freq>=5152) {
return 8;
} else if (freq>=2576) {
return 4;
} else if (freq>=1288) {
return 2;
} else {
return 1;
}
return 1;
}
int DivPlatformGenesis::toFreq(int freq) {
if (freq>=82432) {
return 0x3800|((freq>>7)&0x7ff);
} else if (freq>=41216) {
return 0x3000|((freq>>6)&0x7ff);
} else if (freq>=20608) {
return 0x2800|((freq>>5)&0x7ff);
} else if (freq>=10304) {
return 0x2000|((freq>>4)&0x7ff);
} else if (freq>=5152) {
return 0x1800|((freq>>3)&0x7ff);
} else if (freq>=2576) {
return 0x1000|((freq>>2)&0x7ff);
} else if (freq>=1288) {
return 0x800|((freq>>1)&0x7ff);
} else {
return freq&0x7ff;
}
}
void DivPlatformGenesis::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
for (int j=0; j<4; j++) {
@ -511,7 +496,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
dacPos=0;
dacPeriod=0;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].baseFreq=parent->calcBaseFreq(1,1,c.value,false);
chan[c.chan].freqChanged=true;
}
chan[c.chan].furnaceDac=true;
@ -530,7 +515,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
}
dacPos=0;
dacPeriod=0;
dacRate=1280000/MAX(1,parent->getSample(dacSample)->rate);
dacRate=MAX(1,parent->getSample(dacSample)->rate);
if (dumpWrites) addWrite(0xffff0001,parent->getSample(dacSample)->rate);
chan[c.chan].furnaceDac=false;
}
@ -578,7 +563,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
chan[c.chan].insChanged=false;
if (c.value!=DIV_NOTE_NULL) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
chan[c.chan].portaPause=false;
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
@ -658,31 +643,65 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
break;
}
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_FREQUENCY(c.value2);
if (c.chan==5 && chan[c.chan].furnaceDac) {
int destFreq=parent->calcBaseFreq(1,1,c.value2,false);
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
chan[c.chan].baseFreq+=c.value*16;
if (chan[c.chan].baseFreq>=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
} else {
chan[c.chan].baseFreq-=c.value*16;
if (chan[c.chan].baseFreq<=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
}
chan[c.chan].freqChanged=true;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
}
break;
}
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
int newFreq;
bool return2=false;
if (chan[c.chan].portaPause) {
chan[c.chan].baseFreq=chan[c.chan].portaPauseFreq;
}
if (destFreq>chan[c.chan].baseFreq) {
newFreq=chan[c.chan].baseFreq+c.value*octave(chan[c.chan].baseFreq);
newFreq=chan[c.chan].baseFreq+c.value;
if (newFreq>=destFreq) {
newFreq=destFreq;
return2=true;
}
} else {
newFreq=chan[c.chan].baseFreq-c.value*octave(chan[c.chan].baseFreq);
newFreq=chan[c.chan].baseFreq-c.value;
if (newFreq<=destFreq) {
newFreq=destFreq;
return2=true;
}
}
// check for octave boundary
// what the heck!
if (!chan[c.chan].portaPause) {
if (octave(chan[c.chan].baseFreq)!=octave(newFreq)) {
if ((newFreq&0x7ff)>1288 && (newFreq&0xf800)<0x3800) {
chan[c.chan].portaPauseFreq=(644)|((newFreq+0x800)&0xf800);
chan[c.chan].portaPause=true;
break;
}
if ((newFreq&0x7ff)<644 && (newFreq&0xf800)>0) {
chan[c.chan].portaPauseFreq=newFreq=(1287)|((newFreq-0x800)&0xf800);
chan[c.chan].portaPause=true;
break;
}
}
chan[c.chan].baseFreq=newFreq;
chan[c.chan].portaPause=false;
chan[c.chan].freqChanged=true;
chan[c.chan].baseFreq=newFreq;
if (return2) {
chan[c.chan].inPorta=false;
return 2;
@ -701,7 +720,11 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
}
break;
case DIV_CMD_LEGATO: {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
if (c.chan==5 && chan[c.chan].furnaceDac) {
chan[c.chan].baseFreq=parent->calcBaseFreq(1,1,c.value,false);
} else {
chan[c.chan].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
}
chan[c.chan].note=c.value;
chan[c.chan].freqChanged=true;
break;
@ -853,6 +876,8 @@ void DivPlatformGenesis::reset() {
dacPeriod=0;
dacPos=0;
dacRate=0;
dacDelay=0;
dacReady=true;
dacSample=-1;
sampleBank=0;
lfoValue=8;

View file

@ -36,8 +36,8 @@ class DivPlatformGenesis: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, portaPauseFreq, note;
int ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, hardReset;
int vol, outVol;
unsigned char pan;
@ -47,6 +47,7 @@ class DivPlatformGenesis: public DivDispatch {
freq(0),
baseFreq(0),
pitch(0),
portaPauseFreq(0),
note(0),
ins(-1),
active(false),
@ -84,6 +85,8 @@ class DivPlatformGenesis: public DivDispatch {
int dacRate;
unsigned int dacPos;
int dacSample;
int dacDelay;
bool dacReady;
unsigned char sampleBank;
unsigned char lfoValue;
@ -93,9 +96,6 @@ class DivPlatformGenesis: public DivDispatch {
short oldWrites[512];
short pendingWrites[512];
int octave(int freq);
int toFreq(int freq);
friend void putDispatchChan(void*,int,int);
void acquire_nuked(short* bufL, short* bufR, size_t start, size_t len);

View file

@ -72,7 +72,7 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
opChan[ch].insChanged=false;
if (c.value!=DIV_NOTE_NULL) {
opChan[ch].baseFreq=NOTE_FREQUENCY(c.value);
opChan[ch].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
opChan[ch].portaPause=false;
opChan[ch].freqChanged=true;
}
@ -127,31 +127,49 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
break;
}
case DIV_CMD_NOTE_PORTA: {
int destFreq=NOTE_FREQUENCY(c.value2);
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
int newFreq;
bool return2=false;
if (opChan[ch].portaPause) {
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
}
if (destFreq>opChan[ch].baseFreq) {
newFreq=opChan[ch].baseFreq+c.value*octave(opChan[ch].baseFreq);
newFreq=opChan[ch].baseFreq+c.value;
if (newFreq>=destFreq) {
newFreq=destFreq;
return2=true;
}
} else {
newFreq=opChan[ch].baseFreq-c.value*octave(opChan[ch].baseFreq);
newFreq=opChan[ch].baseFreq-c.value;
if (newFreq<=destFreq) {
newFreq=destFreq;
return2=true;
}
}
// what the heck!
if (!opChan[ch].portaPause) {
if (octave(opChan[ch].baseFreq)!=octave(newFreq)) {
opChan[ch].portaPause=true;
break;
if ((newFreq&0x7ff)>1288 && (newFreq&0xf800)<0x3800) {
if (parent->song.fbPortaPause) {
opChan[ch].portaPauseFreq=(644)|((newFreq+0x800)&0xf800);
opChan[ch].portaPause=true;
break;
} else {
newFreq=(newFreq>>1)|((newFreq+0x800)&0xf800);
}
}
if ((newFreq&0x7ff)<644 && (newFreq&0xf800)>0) {
if (parent->song.fbPortaPause) {
opChan[ch].portaPauseFreq=newFreq=(1287)|((newFreq-0x800)&0xf800);
opChan[ch].portaPause=true;
break;
} else {
newFreq=(newFreq<<1)|((newFreq-0x800)&0xf800);
}
}
}
opChan[ch].baseFreq=newFreq;
opChan[ch].portaPause=false;
opChan[ch].freqChanged=true;
opChan[ch].baseFreq=newFreq;
if (return2) return 2;
break;
}
@ -172,7 +190,7 @@ int DivPlatformGenesisExt::dispatch(DivCommand c) {
}
break;
case DIV_CMD_LEGATO: {
opChan[ch].baseFreq=NOTE_FREQUENCY(c.value);
opChan[ch].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
opChan[ch].freqChanged=true;
break;
}
@ -289,35 +307,20 @@ void DivPlatformGenesisExt::tick(bool sysTick) {
unsigned char writeMask=2;
if (extMode) for (int i=0; i<4; i++) {
if (opChan[i].freqChanged) {
opChan[i].freq=parent->calcFreq(opChan[i].baseFreq,opChan[i].pitch);
if (opChan[i].freq>262143) opChan[i].freq=262143;
if (opChan[i].freq>=82432) {
opChan[i].freqH=((opChan[i].freq>>15)&7)|0x38;
opChan[i].freqL=(opChan[i].freq>>7)&0xff;
} else if (opChan[i].freq>=41216) {
opChan[i].freqH=((opChan[i].freq>>14)&7)|0x30;
opChan[i].freqL=(opChan[i].freq>>6)&0xff;
} else if (opChan[i].freq>=20608) {
opChan[i].freqH=((opChan[i].freq>>13)&7)|0x28;
opChan[i].freqL=(opChan[i].freq>>5)&0xff;
} else if (opChan[i].freq>=10304) {
opChan[i].freqH=((opChan[i].freq>>12)&7)|0x20;
opChan[i].freqL=(opChan[i].freq>>4)&0xff;
} else if (opChan[i].freq>=5152) {
opChan[i].freqH=((opChan[i].freq>>11)&7)|0x18;
opChan[i].freqL=(opChan[i].freq>>3)&0xff;
} else if (opChan[i].freq>=2576) {
opChan[i].freqH=((opChan[i].freq>>10)&7)|0x10;
opChan[i].freqL=(opChan[i].freq>>2)&0xff;
} else if (opChan[i].freq>=1288) {
opChan[i].freqH=((opChan[i].freq>>9)&7)|0x08;
opChan[i].freqL=(opChan[i].freq>>1)&0xff;
} else {
opChan[i].freqH=(opChan[i].freq>>8)&7;
opChan[i].freqL=opChan[i].freq&0xff;
int fNum=parent->calcFreq(opChan[i].baseFreq&0x7ff,opChan[i].pitch,false,4)+opChan[i].std.pitch.val;
int block=(opChan[i].baseFreq&0xf800)>>11;
if (fNum<0) fNum=0;
if (fNum>2047) {
while (block<7) {
fNum>>=1;
block++;
}
if (fNum>2047) fNum=2047;
}
immWrite(opChanOffsH[i],opChan[i].freqH);
immWrite(opChanOffsL[i],opChan[i].freqL);
opChan[i].freq=(block<<11)|fNum;
if (opChan[i].freq>0x3fff) opChan[i].freq=0x3fff;
immWrite(opChanOffsH[i],opChan[i].freq>>8);
immWrite(opChanOffsL[i],opChan[i].freq&0xff);
}
writeMask|=opChan[i].active<<(4+i);
if (opChan[i].keyOn) {

View file

@ -25,13 +25,27 @@ class DivPlatformGenesisExt: public DivPlatformGenesis {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch;
unsigned char ins;
int freq, baseFreq, pitch, portaPauseFreq, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;
unsigned char pan;
OpChannel(): freqH(0), freqL(0), freq(0), baseFreq(0), pitch(0), ins(-1), active(false), insChanged(true), freqChanged(false), keyOn(false), keyOff(false), portaPause(false), vol(0), pan(3) {}
OpChannel():
freqH(0),
freqL(0),
freq(0),
baseFreq(0),
pitch(0),
portaPauseFreq(0),
ins(-1),
active(false),
insChanged(true),
freqChanged(false),
keyOn(false),
keyOff(false),
portaPause(false),
vol(0),
pan(3) {}
};
OpChannel opChan[4];
bool isOpMuted[4];

View file

@ -44,8 +44,8 @@ class DivPlatformLynx: public DivDispatch {
DivMacroInt std;
MikeyFreqDiv fd;
MikeyDuty duty;
int baseFreq, pitch, note, actualNote, lfsr;
unsigned char ins, pan;
int baseFreq, pitch, note, actualNote, lfsr, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
Channel():

View file

@ -25,8 +25,8 @@
class DivPlatformMMC5: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, prevFreq, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View file

@ -25,8 +25,8 @@
class DivPlatformNES: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, prevFreq, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, prevFreq, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View file

@ -548,6 +548,9 @@ int DivPlatformOPL::dispatch(DivCommand c) {
if (chan[c.chan].insChanged) {
int ops=(slots[3][c.chan]!=255 && chan[c.chan].state.ops==4 && oplType==3)?4:2;
chan[c.chan].fourOp=(ops==4);
if (chan[c.chan].fourOp) {
chan[c.chan+1].std.init(NULL);
}
update4OpMask=true;
for (int i=0; i<ops; i++) {
unsigned char slot=slots[i][c.chan];

View file

@ -30,8 +30,7 @@ class DivPlatformOPL: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta, fourOp;
int vol, outVol;
unsigned char pan;

View file

@ -33,8 +33,7 @@ class DivPlatformOPLL: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
int vol, outVol;
unsigned char pan;

View file

@ -31,8 +31,8 @@ class DivPlatformPCE: public DivDispatch {
int freq, baseFreq, pitch, note;
int dacPeriod, dacRate;
unsigned int dacPos;
int dacSample;
unsigned char ins, pan;
int dacSample, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, noise, pcm, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View file

@ -53,6 +53,7 @@ void DivPlatformPCSpeaker::acquire_unfilt(short* bufL, short* bufR, size_t start
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
while (pos<0) {
if (freq<1) {
pos=1;
@ -71,6 +72,7 @@ void DivPlatformPCSpeaker::acquire_cone(short* bufL, short* bufR, size_t start,
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
while (pos<0) {
if (freq<1) {
pos=1;
@ -95,6 +97,7 @@ void DivPlatformPCSpeaker::acquire_piezo(short* bufL, short* bufR, size_t start,
for (size_t i=start; i<start+len; i++) {
if (on) {
pos-=PCSPKR_DIVIDER;
if (pos>freq) pos=freq;
while (pos<0) {
if (freq<1) {
pos=1;

View file

@ -25,8 +25,8 @@
class DivPlatformPCSpeaker: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, duty, sweep;
int freq, baseFreq, pitch, note, ins;
unsigned char duty, sweep;
bool active, insChanged, freqChanged, sweepChanged, keyOn, keyOff, inPorta, furnaceDac;
signed char vol, outVol, wave;
DivMacroInt std;

View file

@ -25,8 +25,7 @@
class DivPlatformPET: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
unsigned char sreg;

View file

@ -30,8 +30,7 @@ class DivPlatformQSound: public DivDispatch {
int freq, baseFreq, pitch;
unsigned short audLen;
unsigned int audPos;
int sample, wave;
unsigned char ins;
int sample, wave, ins;
int note;
int panning;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, useWave;

View file

@ -35,8 +35,8 @@ class DivPlatformSAA1099: public DivDispatch {
protected:
struct Channel {
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View file

@ -29,8 +29,7 @@ class DivPlatformSegaPCM: public DivDispatch {
struct Channel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM;
int vol, outVol;

View file

@ -86,11 +86,13 @@ void DivPlatformSMS::tick(bool sysTick) {
}
if (i==3) {
if (chan[i].std.duty.had) {
snNoiseMode=chan[i].std.duty.val;
if (chan[i].std.duty.val<2) {
chan[3].freqChanged=false;
if (chan[i].std.duty.val!=snNoiseMode || parent->song.snDutyReset) {
snNoiseMode=chan[i].std.duty.val;
if (chan[i].std.duty.val<2) {
chan[3].freqChanged=false;
}
updateSNMode=true;
}
updateSNMode=true;
}
if (chan[i].std.phaseReset.had) {
if (chan[i].std.phaseReset.val==1) {

View file

@ -26,8 +26,7 @@
class DivPlatformSMS: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note, actualNote;
unsigned char ins;
int freq, baseFreq, pitch, note, actualNote, ins;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
signed char vol, outVol;
DivMacroInt std;

View file

@ -226,12 +226,14 @@ void DivPlatformSwan::tick(bool sysTick) {
}
}
if (chan[3].std.duty.had) {
noise=chan[3].std.duty.val;
if (noise>0) {
rWrite(0x0e,((noise-1)&0x07)|0x18);
sndCtrl|=0x80;
} else {
sndCtrl&=~0x80;
if (noise!=chan[3].std.duty.val) {
noise=chan[3].std.duty.val;
if (noise>0) {
rWrite(0x0e,((noise-1)&0x07)|0x18);
sndCtrl|=0x80;
} else {
sndCtrl&=~0x80;
}
}
}
rWrite(0x10,sndCtrl);

View file

@ -28,8 +28,8 @@
class DivPlatformSwan: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave;
DivMacroInt std;

View file

@ -27,8 +27,8 @@
class DivPlatformTIA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, shape;
int freq, baseFreq, pitch, note, ins;
unsigned char shape;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta;
int vol, outVol;

View file

@ -35,8 +35,7 @@ class DivPlatformTX81Z: public DivDispatch {
DivInstrumentFM state;
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins;
int freq, baseFreq, pitch, note, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, portaPause, furnacePCM, hardReset;
int vol, outVol;

View file

@ -29,8 +29,8 @@ struct VERA_PCM;
class DivPlatformVERA: public DivDispatch {
protected:
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, freqChanged, inPorta;
int vol, outVol;
unsigned accum;

View file

@ -27,8 +27,8 @@
class DivPlatformVIC20: public DivDispatch {
struct Channel {
int freq, baseFreq, pitch, note;
unsigned char ins, pan;
int freq, baseFreq, pitch, note, ins;
unsigned char pan;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta;
int vol, outVol, wave, waveWriteCycle;
DivMacroInt std;

View file

@ -31,8 +31,8 @@ class DivPlatformVRC6: public DivDispatch {
int freq, baseFreq, pitch, note;
int dacPeriod, dacRate, dacOut;
unsigned int dacPos;
int dacSample;
unsigned char ins, duty;
int dacSample, ins;
unsigned char duty;
bool active, insChanged, freqChanged, keyOn, keyOff, inPorta, pcm, furnaceDac;
signed char vol, outVol;
DivMacroInt std;

View file

@ -43,8 +43,8 @@ class DivPlatformYM2610: public DivDispatch {
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
int vol, outVol;

View file

@ -35,8 +35,8 @@ class DivPlatformYM2610B: public DivDispatch {
struct Channel {
DivInstrumentFM state;
unsigned char freqH, freqL;
int freq, baseFreq, pitch, note;
unsigned char ins, psgMode, autoEnvNum, autoEnvDen;
int freq, baseFreq, pitch, note, ins;
unsigned char psgMode, autoEnvNum, autoEnvDen;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, inPorta, furnacePCM, hardReset;
int vol, outVol;

View file

@ -25,8 +25,7 @@ class DivPlatformYM2610BExt: public DivPlatformYM2610B {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch;
unsigned char ins;
int freq, baseFreq, pitch, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;

View file

@ -25,8 +25,7 @@ class DivPlatformYM2610Ext: public DivPlatformYM2610 {
struct OpChannel {
DivMacroInt std;
unsigned char freqH, freqL;
int freq, baseFreq, pitch;
unsigned char ins;
int freq, baseFreq, pitch, ins;
signed char konCycles;
bool active, insChanged, freqChanged, keyOn, keyOff, portaPause;
int vol;