Merge branch 'tildearrow:master' into master

This commit is contained in:
Eknous 2023-07-24 14:21:30 +04:00 committed by GitHub
commit 695afcfc88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 101 additions and 40 deletions

View file

@ -56,8 +56,8 @@
#define DIV_UNSTABLE
#define DIV_VERSION "dev164"
#define DIV_ENGINE_VERSION 164
#define DIV_VERSION "dev165"
#define DIV_ENGINE_VERSION 165
// for imports
#define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02

View file

@ -2941,6 +2941,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
}
}
// Namco 163 pitch compensation compat
if (ds.version<165) {
for (int i=0; i<ds.systemLen; i++) {
if (ds.system[i]==DIV_SYSTEM_N163) {
ds.systemFlags[i].set("lenCompensate",true);
}
}
}
if (active) quitDispatch();
BUSY_BEGIN_SOFT;
saveLock.lock();

View file

@ -56,10 +56,10 @@ void DivPlatformMSM5232::acquire(short** buf, size_t len) {
for (int i=0; i<8; i++) {
int o=(
((regPool[12+(i>>4)]&1)?((msm->vo16[i]*partVolume[3+(i&4)])>>8):0)+
((regPool[12+(i>>4)]&2)?((msm->vo8[i]*partVolume[2+(i&4)])>>8):0)+
((regPool[12+(i>>4)]&4)?((msm->vo4[i]*partVolume[1+(i&4)])>>8):0)+
((regPool[12+(i>>4)]&8)?((msm->vo2[i]*partVolume[i&4])>>8):0)
((regPool[12+(i>>2)]&1)?((msm->vo16[i]*partVolume[3+(i&4)])>>8):0)+
((regPool[12+(i>>2)]&2)?((msm->vo8[i]*partVolume[2+(i&4)])>>8):0)+
((regPool[12+(i>>2)]&4)?((msm->vo4[i]*partVolume[1+(i&4)])>>8):0)+
((regPool[12+(i>>2)]&8)?((msm->vo2[i]*partVolume[i&4])>>8):0)
)<<2;
oscBuf[i]->data[oscBuf[i]->needle++]=CLAMP(o,-32768,32767);
}

View file

@ -34,7 +34,7 @@
rWriteMask(0x78-(c<<3)+(a&7),v,m) \
}
#define CHIP_FREQBASE (15*32768)
#define CHIP_FREQBASE (15*524288)
const char* regCheatSheetN163[]={
"FreqL7", "40",
@ -256,7 +256,12 @@ void DivPlatformN163::tick(bool sysTick) {
if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) {
// TODO: what is this mess?
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);
chan[i].freq=(((chan[i].freq*chan[i].curWaveLen)*(chanMax+1))/16);
if (lenCompensate) {
chan[i].freq=(((chan[i].freq*chan[i].curWaveLen)*(chanMax+1))/256);
} else {
chan[i].freq*=(chanMax+1);
chan[i].freq>>=3;
}
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>0x3ffff) chan[i].freq=0x3ffff;
if (chan[i].keyOn) {
@ -359,13 +364,13 @@ int DivPlatformN163::dispatch(DivCommand c) {
int destFreq=NOTE_FREQUENCY(c.value2);
bool return2=false;
if (destFreq>chan[c.chan].baseFreq) {
chan[c.chan].baseFreq+=c.value;
chan[c.chan].baseFreq+=c.value*((parent->song.linearPitch==2)?1:16);
if (chan[c.chan].baseFreq>=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
}
} else {
chan[c.chan].baseFreq-=c.value;
chan[c.chan].baseFreq-=c.value*((parent->song.linearPitch==2)?1:16);
if (chan[c.chan].baseFreq<=destFreq) {
chan[c.chan].baseFreq=destFreq;
return2=true;
@ -570,6 +575,8 @@ void DivPlatformN163::setFlags(const DivConfig& flags) {
oscBuf[i]->rate=rate/(initChanMax+1);
}
lenCompensate=flags.getBool("lenCompensate",false);
// needed to make sure changing channel count won't trigger glitches
reset();
}

View file

@ -61,7 +61,7 @@ class DivPlatformN163: public DivDispatch {
unsigned char initChanMax;
unsigned char chanMax;
short loadWave, loadPos;
bool multiplex;
bool multiplex, lenCompensate;
n163_core n163;
unsigned char regPool[128];

View file

@ -230,13 +230,16 @@ void DivPlatformOPLL::tick(bool sysTick) {
if (i>=6 && properDrums) {
drumState&=~(0x10>>(i-6));
immWrite(0x0e,0x20|drumState);
logV("properDrums %d",i);
} else if (i>=6 && drums) {
drumState&=~(0x10>>(chan[i].note%12));
immWrite(0x0e,0x20|drumState);
logV("drums %d",i);
} else {
if (i<9) {
immWrite(0x20+i,(chan[i].freqH)|(chan[i].state.alg?0x20:0));
}
logV("normal %d",i);
}
//chan[i].keyOn=false;
chan[i].keyOff=false;
@ -253,7 +256,7 @@ void DivPlatformOPLL::tick(bool sysTick) {
for (int i=0; i<11; i++) {
if (chan[i].freqChanged) {
chan[i].freq=parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,false,octave(chan[i].baseFreq)*2,chan[i].pitch2,chipClock,CHIP_FREQBASE);
if (chan[i].fixedFreq>0) chan[i].freq=chan[i].fixedFreq;
if (chan[i].fixedFreq>0 && properDrums) chan[i].freq=chan[i].fixedFreq;
if (chan[i].freq<0) chan[i].freq=0;
if (chan[i].freq>65535) chan[i].freq=65535;
int freqt=toFreq(chan[i].freq);
@ -771,11 +774,17 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
if (c.value) {
properDrums=true;
immWrite(0x0e,0x20);
drumState=0;
} else {
properDrums=false;
immWrite(0x0e,0x00);
drumState=0;
}
chan[6].freqChanged=true;
chan[7].freqChanged=true;
chan[8].freqChanged=true;
chan[9].freqChanged=true;
chan[10].freqChanged=true;
break;
case DIV_CMD_MACRO_OFF:
chan[c.chan].std.mask(c.value,true);

View file

@ -962,6 +962,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
int clockSel=flags.getInt("clockSel",0);
int channels=flags.getInt("channels",0)+1;
bool multiplex=flags.getBool("multiplex",false);
bool lenCompensate=flags.getBool("lenCompensate",false);
ImGui::Text("Clock rate:");
if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) {
@ -985,12 +986,16 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
if (ImGui::Checkbox("Disable hissing",&multiplex)) {
altered=true;
}
if (ImGui::Checkbox("Scale frequency to wave length",&lenCompensate)) {
altered=true;
}
if (altered) {
e->lockSave([&]() {
flags.set("clockSel",clockSel);
flags.set("channels",channels-1);
flags.set("multiplex",multiplex);
flags.set("lenCompensate",lenCompensate);
});
}
break;