Merge branch 'master' of github.com:tildearrow/furnace
This commit is contained in:
commit
019b036853
22 changed files with 403 additions and 573 deletions
|
|
@ -147,17 +147,19 @@ class DivPlatformOPN: public DivPlatformFMBase {
|
|||
double fmFreqBase;
|
||||
unsigned int fmDivBase;
|
||||
unsigned int ayDiv;
|
||||
unsigned char csmChan;
|
||||
bool extSys;
|
||||
|
||||
DivConfig ayFlags;
|
||||
|
||||
friend void putDispatchChip(void*,int);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false):
|
||||
DivPlatformOPN(double f=9440540.0, unsigned int d=72, unsigned int a=32, bool isExtSys=false, unsigned char cc=255):
|
||||
DivPlatformFMBase(),
|
||||
fmFreqBase(f),
|
||||
fmDivBase(d),
|
||||
ayDiv(a),
|
||||
csmChan(cc),
|
||||
extSys(isExtSys) {}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -554,7 +554,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
switch (c.cmd) {
|
||||
case DIV_CMD_NOTE_ON: {
|
||||
DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_FM);
|
||||
if (c.chan==7 && extMode && softPCM) { // CSM
|
||||
if (c.chan==csmChan && extMode && softPCM) { // CSM
|
||||
chan[c.chan].macroInit(ins);
|
||||
chan[c.chan].insChanged=false;
|
||||
|
||||
|
|
@ -686,7 +686,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_NOTE_OFF:
|
||||
if (c.chan>=5 && c.chan<7) {
|
||||
if (c.chan>=5 && c.chan<csmChan) {
|
||||
chan[c.chan].dacSample=-1;
|
||||
if (dumpWrites) addWrite(0xffff0002,0);
|
||||
if (parent->song.brokenDACMode) {
|
||||
|
|
@ -781,7 +781,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
if (c.chan==7) {
|
||||
if (c.chan==csmChan) {
|
||||
int destFreq=NOTE_PERIODIC(c.value2);
|
||||
bool return2=false;
|
||||
if (destFreq>chan[c.chan].baseFreq) {
|
||||
|
|
@ -850,7 +850,7 @@ int DivPlatformGenesis::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_LEGATO: {
|
||||
if (c.chan==7) {
|
||||
if (c.chan==csmChan) {
|
||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value);
|
||||
} else if (c.chan>=5 && chan[c.chan].furnaceDac && chan[c.chan].dacMode) {
|
||||
chan[c.chan].baseFreq=parent->calcBaseFreq(1,1,c.value,false);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
|
|||
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
|
||||
void quit();
|
||||
DivPlatformGenesis():
|
||||
DivPlatformOPN(9440540.0, 72, 32) {}
|
||||
DivPlatformOPN(9440540.0, 72, 32, false, 7) {}
|
||||
~DivPlatformGenesis();
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ void DivPlatformGenesisExt::tick(bool sysTick) {
|
|||
}
|
||||
}
|
||||
if (writeSomething) {
|
||||
if (chan[7].active) { // CSM
|
||||
if (chan[csmChan].active) { // CSM
|
||||
writeMask^=0xf0;
|
||||
}
|
||||
/*printf(
|
||||
|
|
@ -589,17 +589,17 @@ void DivPlatformGenesisExt::tick(bool sysTick) {
|
|||
}
|
||||
|
||||
if (extMode && softPCM) {
|
||||
if (chan[7].freqChanged) {
|
||||
chan[7].freq=parent->calcFreq(chan[7].baseFreq,chan[7].pitch,chan[7].fixedArp?chan[7].baseNoteOverride:chan[7].arpOff,chan[7].fixedArp,true,0,chan[7].pitch2,chipClock,CHIP_DIVIDER);
|
||||
if (chan[7].freq<1) chan[7].freq=1;
|
||||
if (chan[7].freq>1024) chan[7].freq=1024;
|
||||
int wf=0x400-chan[7].freq;
|
||||
if (chan[csmChan].freqChanged) {
|
||||
chan[csmChan].freq=parent->calcFreq(chan[csmChan].baseFreq,chan[csmChan].pitch,chan[csmChan].fixedArp?chan[csmChan].baseNoteOverride:chan[csmChan].arpOff,chan[csmChan].fixedArp,true,0,chan[csmChan].pitch2,chipClock,CHIP_DIVIDER);
|
||||
if (chan[csmChan].freq<1) chan[csmChan].freq=1;
|
||||
if (chan[csmChan].freq>1024) chan[csmChan].freq=1024;
|
||||
int wf=0x400-chan[csmChan].freq;
|
||||
immWrite(0x24,wf>>2);
|
||||
immWrite(0x25,wf&3);
|
||||
chan[7].freqChanged=false;
|
||||
chan[csmChan].freqChanged=false;
|
||||
}
|
||||
|
||||
if (chan[7].keyOff || chan[7].keyOn) {
|
||||
if (chan[csmChan].keyOff || chan[csmChan].keyOn) {
|
||||
writeNoteOn=true;
|
||||
for (int i=0; i<4; i++) {
|
||||
writeMask|=opChan[i].active<<(4+i);
|
||||
|
|
@ -608,7 +608,7 @@ void DivPlatformGenesisExt::tick(bool sysTick) {
|
|||
}
|
||||
|
||||
if (writeNoteOn) {
|
||||
if (chan[7].active) { // CSM
|
||||
if (chan[csmChan].active) { // CSM
|
||||
writeMask^=0xf0;
|
||||
}
|
||||
/*printf(
|
||||
|
|
@ -622,13 +622,13 @@ void DivPlatformGenesisExt::tick(bool sysTick) {
|
|||
}
|
||||
|
||||
if (extMode && softPCM) {
|
||||
if (chan[7].keyOn) {
|
||||
if (chan[csmChan].keyOn) {
|
||||
immWrite(0x27,0x81);
|
||||
chan[7].keyOn=false;
|
||||
chan[csmChan].keyOn=false;
|
||||
}
|
||||
if (chan[7].keyOff) {
|
||||
if (chan[csmChan].keyOff) {
|
||||
immWrite(0x27,0x40);
|
||||
chan[7].keyOff=false;
|
||||
chan[csmChan].keyOff=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,20 @@
|
|||
#define CHIP_DIVIDER 1
|
||||
|
||||
const char* regCheatSheetPokeMini[]={
|
||||
"Period", "0",
|
||||
"TMR3_SCALE", "1C",
|
||||
"TMR3_OSC", "1D",
|
||||
"TMR3_CTRL_L", "48",
|
||||
"TMR3_CTRL_H", "49",
|
||||
"TMR3_PRE_L", "4A",
|
||||
"TMR3_PRE_H", "4B",
|
||||
"TMR3_PVT_L", "4C",
|
||||
"TMR3_PVT_H", "4D",
|
||||
"TMR3_CNT_L", "4E",
|
||||
"TMR3_CNT_H", "4F",
|
||||
"IO_DIR", "60",
|
||||
"IO_DATA", "61",
|
||||
"AUD_CTRL", "70",
|
||||
"AUD_VOL", "71",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
@ -42,6 +55,37 @@ const char** DivPlatformPokeMini::getRegisterSheet() {
|
|||
return regCheatSheetPokeMini;
|
||||
}
|
||||
|
||||
void DivPlatformPokeMini::rWrite(unsigned char addr, unsigned char val) {
|
||||
if (addr<128) regPool[addr]=val;
|
||||
switch (addr) {
|
||||
case 0x1c:
|
||||
// ignore
|
||||
break;
|
||||
case 0x1d:
|
||||
// ignore
|
||||
break;
|
||||
case 0x48: case 0x49:
|
||||
on=val&4;
|
||||
if (val&2) pos=0;
|
||||
break;
|
||||
case 0x4a:
|
||||
preset=(preset&0xff00)|val;
|
||||
break;
|
||||
case 0x4b:
|
||||
preset=(preset&0xff)|(val<<8);
|
||||
break;
|
||||
case 0x4c:
|
||||
pivot=(pivot&0xff00)|val;
|
||||
break;
|
||||
case 0x4d:
|
||||
pivot=(pivot&0xff)|(val<<8);
|
||||
break;
|
||||
case 0x71:
|
||||
vol=val&3;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DivPlatformPokeMini::acquire(short* bufL, short* bufR, size_t start, size_t len) {
|
||||
int out=0;
|
||||
for (size_t i=start; i<start+len; i++) {
|
||||
|
|
@ -72,7 +116,7 @@ void DivPlatformPokeMini::tick(bool sysTick) {
|
|||
chan[i].std.next();
|
||||
if (chan[i].std.vol.had) {
|
||||
chan[i].outVol=VOL_SCALE_LINEAR(chan[i].vol,chan[i].std.vol.val,2);
|
||||
vol=(chan[i].outVol==2)?3:chan[i].outVol;
|
||||
rWrite(0x71,(chan[i].outVol==2)?3:chan[i].outVol);
|
||||
}
|
||||
if (NEW_ARP_STRAT) {
|
||||
chan[i].handleArp();
|
||||
|
|
@ -100,13 +144,16 @@ void DivPlatformPokeMini::tick(bool sysTick) {
|
|||
if (chan[i].freq<0) chan[i].freq=0;
|
||||
if (chan[i].freq>65535) chan[i].freq=65535;
|
||||
if (chan[i].keyOn) {
|
||||
on=true;
|
||||
rWrite(0x48,4);
|
||||
}
|
||||
if (chan[i].keyOff) {
|
||||
on=false;
|
||||
rWrite(0x48,0);
|
||||
}
|
||||
preset=chan[i].freq;
|
||||
pivot=(chan[i].duty*preset)>>8;
|
||||
rWrite(0x4a,chan[i].freq&0xff);
|
||||
rWrite(0x4b,chan[i].freq>>8);
|
||||
int pvt=(chan[i].duty*chan[i].freq)>>8;
|
||||
rWrite(0x4c,pvt&0xff);
|
||||
rWrite(0x4d,pvt>>8);
|
||||
if (chan[i].keyOn) chan[i].keyOn=false;
|
||||
if (chan[i].keyOff) chan[i].keyOff=false;
|
||||
chan[i].freqChanged=false;
|
||||
|
|
@ -122,7 +169,7 @@ int DivPlatformPokeMini::dispatch(DivCommand c) {
|
|||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
}
|
||||
vol=(chan[c.chan].outVol==2)?3:chan[c.chan].outVol;
|
||||
rWrite(0x71,(chan[c.chan].outVol==2)?3:chan[c.chan].outVol);
|
||||
chan[c.chan].active=true;
|
||||
chan[c.chan].keyOn=true;
|
||||
chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_POKEMINI));
|
||||
|
|
@ -151,7 +198,7 @@ int DivPlatformPokeMini::dispatch(DivCommand c) {
|
|||
chan[c.chan].outVol=c.value;
|
||||
}
|
||||
if (chan[c.chan].active) {
|
||||
on=chan[c.chan].vol;
|
||||
rWrite(0x71,(chan[c.chan].outVol==2)?3:chan[c.chan].outVol);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -186,14 +233,13 @@ int DivPlatformPokeMini::dispatch(DivCommand c) {
|
|||
break;
|
||||
}
|
||||
case DIV_CMD_LEGATO:
|
||||
if (c.chan==3) break;
|
||||
chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val):(0)));
|
||||
chan[c.chan].freqChanged=true;
|
||||
chan[c.chan].note=c.value;
|
||||
break;
|
||||
case DIV_CMD_PRE_PORTA:
|
||||
if (chan[c.chan].active && c.value2) {
|
||||
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_BEEPER));
|
||||
if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_POKEMINI));
|
||||
}
|
||||
if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note);
|
||||
chan[c.chan].inPorta=c.value;
|
||||
|
|
@ -239,18 +285,11 @@ DivDispatchOscBuffer* DivPlatformPokeMini::getOscBuffer(int ch) {
|
|||
}
|
||||
|
||||
unsigned char* DivPlatformPokeMini::getRegisterPool() {
|
||||
if (on) {
|
||||
regPool[0]=preset;
|
||||
regPool[1]=preset>>8;
|
||||
} else {
|
||||
regPool[0]=0;
|
||||
regPool[1]=0;
|
||||
}
|
||||
return regPool;
|
||||
}
|
||||
|
||||
int DivPlatformPokeMini::getRegisterPoolSize() {
|
||||
return 2;
|
||||
return 128;
|
||||
}
|
||||
|
||||
void DivPlatformPokeMini::reset() {
|
||||
|
|
@ -272,7 +311,7 @@ void DivPlatformPokeMini::reset() {
|
|||
pivot=0;
|
||||
elapsedMain=0;
|
||||
|
||||
memset(regPool,0,2);
|
||||
memset(regPool,0,128);
|
||||
}
|
||||
|
||||
bool DivPlatformPokeMini::keyOffAffectsArp(int ch) {
|
||||
|
|
@ -294,11 +333,11 @@ void DivPlatformPokeMini::notifyInsDeletion(void* ins) {
|
|||
}
|
||||
|
||||
void DivPlatformPokeMini::poke(unsigned int addr, unsigned short val) {
|
||||
// ???
|
||||
rWrite(addr,val);
|
||||
}
|
||||
|
||||
void DivPlatformPokeMini::poke(std::vector<DivRegWrite>& wlist) {
|
||||
// ???
|
||||
for (DivRegWrite& i: wlist) rWrite(i.addr,i.val);
|
||||
}
|
||||
|
||||
int DivPlatformPokeMini::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ class DivPlatformPokeMini: public DivDispatch {
|
|||
int pos;
|
||||
unsigned char timerScale, vol;
|
||||
unsigned short preset, pivot;
|
||||
unsigned char regPool[2];
|
||||
unsigned char regPool[128];
|
||||
unsigned short elapsedMain;
|
||||
|
||||
void rWrite(unsigned char addr, unsigned char val);
|
||||
|
||||
friend void putDispatchChip(void*,int);
|
||||
friend void putDispatchChan(void*,int,int);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,14 @@ void DivPlatformPOKEY::acquire(short* bufL, short* bufR, size_t start, size_t le
|
|||
}
|
||||
|
||||
mzpokeysnd_process_16(&pokey,&bufL[h],1);
|
||||
|
||||
if (++oscBufDelay>=14) {
|
||||
oscBufDelay=0;
|
||||
oscBuf[0]->data[oscBuf[0]->needle++]=pokey.outvol_0<<11;
|
||||
oscBuf[1]->data[oscBuf[1]->needle++]=pokey.outvol_1<<11;
|
||||
oscBuf[2]->data[oscBuf[2]->needle++]=pokey.outvol_2<<11;
|
||||
oscBuf[3]->data[oscBuf[3]->needle++]=pokey.outvol_3<<11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +417,7 @@ void DivPlatformPOKEY::setFlags(const DivConfig& flags) {
|
|||
CHECK_CUSTOM_CLOCK;
|
||||
rate=chipClock;
|
||||
for (int i=0; i<4; i++) {
|
||||
oscBuf[i]->rate=rate/16;
|
||||
oscBuf[i]->rate=rate/14;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -425,6 +433,7 @@ int DivPlatformPOKEY::init(DivEngine* p, int channels, int sugRate, const DivCon
|
|||
parent=p;
|
||||
dumpWrites=false;
|
||||
skipRegisterWrites=false;
|
||||
oscBufDelay=0;
|
||||
for (int i=0; i<4; i++) {
|
||||
isMuted[i]=false;
|
||||
oscBuf[i]=new DivDispatchOscBuffer;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class DivPlatformPOKEY: public DivDispatch {
|
|||
std::queue<QueuedWrite> writes;
|
||||
unsigned char audctl;
|
||||
bool audctlChanged;
|
||||
unsigned char oscBufDelay;
|
||||
PokeyState pokey;
|
||||
unsigned char regPool[16];
|
||||
friend void putDispatchChip(void*,int);
|
||||
|
|
|
|||
|
|
@ -1637,23 +1637,6 @@ void Update_pokey_sound_mz(PokeyState* ps, unsigned short addr, unsigned char va
|
|||
|
||||
#define MAX_SAMPLE 152
|
||||
|
||||
void mzpokeysnd_process_8(PokeyState* ps, void* sndbuffer, int sndn)
|
||||
{
|
||||
int i;
|
||||
int nsam = sndn;
|
||||
unsigned char *buffer = (unsigned char *) sndbuffer;
|
||||
|
||||
/* if there are two pokeys, then the signal is stereo
|
||||
we assume even sndn */
|
||||
while(nsam >= 1)
|
||||
{
|
||||
buffer[0] = (unsigned char)floor(generate_sample(ps)
|
||||
* (255.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 128 + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
buffer += 1;
|
||||
nsam -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void mzpokeysnd_process_16(PokeyState* ps, void* sndbuffer, int sndn)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -1665,7 +1648,7 @@ void mzpokeysnd_process_16(PokeyState* ps, void* sndbuffer, int sndn)
|
|||
while(nsam >= (int) 1)
|
||||
{
|
||||
buffer[0] = (short)floor(generate_sample(ps)
|
||||
* (65535.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95) + 0.5 + 0.5 * rand() / RAND_MAX - 0.25);
|
||||
* (65535.0 / 2 / MAX_SAMPLE / 4 * M_PI * 0.95));
|
||||
buffer += 1;
|
||||
nsam -= 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,7 +149,6 @@ typedef struct stPokeyState
|
|||
int outvol_3;
|
||||
} PokeyState;
|
||||
|
||||
void mzpokeysnd_process_8(PokeyState* ps, void* sndbuffer, int sndn);
|
||||
void mzpokeysnd_process_16(PokeyState* ps, void* sndbuffer, int sndn);
|
||||
void Update_pokey_sound_mz(PokeyState* ps, unsigned short addr, unsigned char val, unsigned char gain);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue