NES: here's your FamiTracker compatibility flag

This commit is contained in:
tildearrow 2025-06-21 21:39:29 -05:00
parent 1ee703a158
commit ec69c30ca0
4 changed files with 17 additions and 3 deletions

View file

@ -655,6 +655,7 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len, bool dnft, bool dnft_si
int map_ch = 0;
ds.system[systemID++] = DIV_SYSTEM_NES;
ds.systemFlags[0].set("resetSweep",true); // FamiTracker behavior
if (pal) {
ds.systemFlags[0].set("clockSel", 1); // PAL clock

View file

@ -352,9 +352,6 @@ void DivPlatformNES::tick(bool sysTick) {
}
if (chan[i].sweepChanged) {
chan[i].sweepChanged=false;
if (i==0) {
// rWrite(16+i*5,chan[i].sweep);
}
}
if (i<3) if (chan[i].std.phaseReset.had) {
if (chan[i].std.phaseReset.val==1) {
@ -637,6 +634,13 @@ int DivPlatformNES::dispatch(DivCommand c) {
} else if (!parent->song.brokenOutVol2) {
rWrite(0x4000+c.chan*4,(chan[c.chan].envMode<<4)|chan[c.chan].vol|((chan[c.chan].duty&3)<<6));
}
if (resetSweep && c.chan<2) {
if (chan[c.chan].sweep!=0x08 && !chan[c.chan].sweepChanged) {
chan[c.chan].sweep=0x08;
chan[c.chan].prevFreq=-1;
rWrite(0x4001+(c.chan*4),chan[c.chan].sweep);
}
}
break;
case DIV_CMD_NOTE_OFF:
if (c.chan==4) {
@ -724,6 +728,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
}
}
rWrite(0x4001+(c.chan*4),chan[c.chan].sweep);
chan[c.chan].sweepChanged=true;
break;
case DIV_CMD_NES_ENV_MODE:
chan[c.chan].envMode=c.value&3;
@ -989,6 +994,7 @@ void DivPlatformNES::setFlags(const DivConfig& flags) {
}
dpcmModeDefault=flags.getBool("dpcmMode",true);
resetSweep=flags.getBool("resetSweep",false);
}
void DivPlatformNES::notifyInsDeletion(void* ins) {

View file

@ -68,6 +68,7 @@ class DivPlatformNES: public DivDispatch {
signed char lastDPCMFreq;
bool dpcmMode;
bool dpcmModeDefault;
bool resetSweep;
bool dacAntiClickOn;
bool useNP;
bool goingToLoop;

View file

@ -611,6 +611,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
case DIV_SYSTEM_5E01: {
int clockSel=flags.getInt("clockSel",0);
bool dpcmMode=flags.getBool("dpcmMode",true);
bool resetSweep=flags.getBool("resetSweep",false);
ImGui::Text(_("Clock rate:"));
@ -642,10 +643,15 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
}
ImGui::Unindent();
if (ImGui::Checkbox(_("Reset sweep on new note"),&resetSweep)) {
altered=true;
}
if (altered) {
e->lockSave([&]() {
flags.set("clockSel",clockSel);
flags.set("dpcmMode",dpcmMode);
flags.set("resetSweep",resetSweep);
});
}
break;