dev154 - NES: DPCM mode is now default

This commit is contained in:
tildearrow 2023-05-05 00:17:59 -05:00
parent f42c689f97
commit bd53c57658
7 changed files with 42 additions and 8 deletions

View file

@ -53,8 +53,8 @@
#define EXTERN_BUSY_BEGIN_SOFT e->softLocked=true; e->isBusy.lock(); #define EXTERN_BUSY_BEGIN_SOFT e->softLocked=true; e->isBusy.lock();
#define EXTERN_BUSY_END e->isBusy.unlock(); e->softLocked=false; #define EXTERN_BUSY_END e->isBusy.unlock(); e->softLocked=false;
#define DIV_VERSION "dev153" #define DIV_VERSION "dev154"
#define DIV_ENGINE_VERSION 153 #define DIV_ENGINE_VERSION 154
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02 #define DIV_VERSION_FC 0xff02

View file

@ -1040,6 +1040,11 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) {
ds.systemFlags[0].set("noEasyNoise",true); ds.systemFlags[0].set("noEasyNoise",true);
} }
// NES PCM
if (ds.system[0]==DIV_SYSTEM_NES) {
ds.systemFlags[0].set("dpcmMode",false);
}
ds.systemName=getSongSystemLegacyName(ds,!getConfInt("noMultiSystem",0)); ds.systemName=getSongSystemLegacyName(ds,!getConfInt("noMultiSystem",0));
if (active) quitDispatch(); if (active) quitDispatch();
@ -2724,6 +2729,15 @@ bool DivEngine::loadFur(unsigned char* file, size_t len) {
} }
} }
// NES PCM compat
if (ds.version<154) {
for (int i=0; i<ds.systemLen; i++) {
if (ds.system[i]==DIV_SYSTEM_NES) {
ds.systemFlags[i].set("dpcmMode",false);
}
}
}
if (active) quitDispatch(); if (active) quitDispatch();
BUSY_BEGIN_SOFT; BUSY_BEGIN_SOFT;
saveLock.lock(); saveLock.lock();

View file

@ -401,7 +401,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
chan[c.chan].furnaceDac=false; chan[c.chan].furnaceDac=false;
if (dpcmMode && !skipRegisterWrites) { if (dpcmMode && !skipRegisterWrites) {
unsigned int dpcmAddr=sampleOffDPCM[dacSample]; unsigned int dpcmAddr=sampleOffDPCM[dacSample];
unsigned int dpcmLen=(parent->getSample(dacSample)->lengthDPCM+15)>>4; unsigned int dpcmLen=parent->getSample(dacSample)->lengthDPCM>>4;
if (dpcmLen>255) dpcmLen=255; if (dpcmLen>255) dpcmLen=255;
goingToLoop=parent->getSample(dacSample)->isLoopable(); goingToLoop=parent->getSample(dacSample)->isLoopable();
// write DPCM // write DPCM
@ -655,7 +655,7 @@ void DivPlatformNES::reset() {
dacSample=-1; dacSample=-1;
sampleBank=0; sampleBank=0;
dpcmBank=0; dpcmBank=0;
dpcmMode=false; dpcmMode=dpcmModeDefault;
goingToLoop=false; goingToLoop=false;
countMode=false; countMode=false;
@ -709,6 +709,8 @@ void DivPlatformNES::setFlags(const DivConfig& flags) {
for (int i=0; i<5; i++) { for (int i=0; i<5; i++) {
oscBuf[i]->rate=rate/32; oscBuf[i]->rate=rate/32;
} }
dpcmModeDefault=flags.getBool("dpcmMode",true);
} }
void DivPlatformNES::notifyInsDeletion(void* ins) { void DivPlatformNES::notifyInsDeletion(void* ins) {

View file

@ -53,6 +53,7 @@ class DivPlatformNES: public DivDispatch {
unsigned char writeOscBuf; unsigned char writeOscBuf;
unsigned char apuType; unsigned char apuType;
bool dpcmMode; bool dpcmMode;
bool dpcmModeDefault;
bool dacAntiClickOn; bool dacAntiClickOn;
bool useNP; bool useNP;
bool goingToLoop; bool goingToLoop;

View file

@ -485,9 +485,9 @@ bool DivSample::initInternal(DivSampleDepth d, int count) {
break; break;
case DIV_SAMPLE_DEPTH_1BIT_DPCM: // DPCM case DIV_SAMPLE_DEPTH_1BIT_DPCM: // DPCM
if (dataDPCM!=NULL) delete[] dataDPCM; if (dataDPCM!=NULL) delete[] dataDPCM;
lengthDPCM=(count+7)/8; lengthDPCM=1+((((count+7)/8)+15)&(~15));
dataDPCM=new unsigned char[lengthDPCM]; dataDPCM=new unsigned char[lengthDPCM];
memset(dataDPCM,0,lengthDPCM); memset(dataDPCM,0xaa,lengthDPCM);
break; break;
case DIV_SAMPLE_DEPTH_YMZ_ADPCM: // YMZ ADPCM case DIV_SAMPLE_DEPTH_YMZ_ADPCM: // YMZ ADPCM
if (dataZ!=NULL) delete[] dataZ; if (dataZ!=NULL) delete[] dataZ;
@ -1092,12 +1092,14 @@ void DivSample::render(unsigned int formatMask) {
if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_1BIT_DPCM)) { // DPCM if (NOT_IN_FORMAT(DIV_SAMPLE_DEPTH_1BIT_DPCM)) { // DPCM
if (!initInternal(DIV_SAMPLE_DEPTH_1BIT_DPCM,samples)) return; if (!initInternal(DIV_SAMPLE_DEPTH_1BIT_DPCM,samples)) return;
int accum=63; int accum=63;
int next=63;
for (unsigned int i=0; i<samples; i++) { for (unsigned int i=0; i<samples; i++) {
int next=((unsigned short)(data16[i]^0x8000))>>9; next=((unsigned short)(data16[i]^0x8000))>>9;
if (next>accum) { if (next>accum) {
dataDPCM[i>>3]|=1<<(i&7); dataDPCM[i>>3]|=1<<(i&7);
accum++; accum++;
} else { } else {
dataDPCM[i>>3]&=~(1<<(i&7));
accum--; accum--;
} }
if (accum<0) accum=0; if (accum<0) accum=0;

View file

@ -699,7 +699,7 @@ void DivEngine::registerSystems() {
sysDefs[DIV_SYSTEM_NES]=new DivSysDef( sysDefs[DIV_SYSTEM_NES]=new DivSysDef(
"NES (Ricoh 2A03)", NULL, 0x06, 0x06, 5, false, true, 0x161, false, (1U<<DIV_SAMPLE_DEPTH_1BIT_DPCM)|(1U<<DIV_SAMPLE_DEPTH_8BIT), "NES (Ricoh 2A03)", NULL, 0x06, 0x06, 5, false, true, 0x161, false, (1U<<DIV_SAMPLE_DEPTH_1BIT_DPCM)|(1U<<DIV_SAMPLE_DEPTH_8BIT),
"also known as Famicom in Japan, it's the most well-known game console of the '80's.", "also known as Famicom in Japan, it's the most well-known game console of the '80's.",
{"Pulse 1", "Pulse 2", "Triangle", "Noise", "PCM"}, {"Pulse 1", "Pulse 2", "Triangle", "Noise", "DPCM"},
{"S1", "S2", "TR", "NO", "PCM"}, {"S1", "S2", "TR", "NO", "PCM"},
{DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_WAVE, DIV_CH_NOISE, DIV_CH_PCM}, {DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_WAVE, DIV_CH_NOISE, DIV_CH_PCM},
{DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_AMIGA}, {DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_NES, DIV_INS_AMIGA},

View file

@ -456,6 +456,9 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
case DIV_SYSTEM_FDS: case DIV_SYSTEM_FDS:
case DIV_SYSTEM_MMC5: { case DIV_SYSTEM_MMC5: {
int clockSel=flags.getInt("clockSel",0); int clockSel=flags.getInt("clockSel",0);
bool dpcmMode=flags.getBool("dpcmMode",true);
ImGui::Text("Clock rate:");
if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) { if (ImGui::RadioButton("NTSC (1.79MHz)",clockSel==0)) {
clockSel=0; clockSel=0;
@ -470,9 +473,21 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
altered=true; altered=true;
} }
ImGui::Text("DPCM channel mode:");
if (ImGui::RadioButton("DPCM (muffled samples; low CPU usage)",dpcmMode)) {
dpcmMode=true;
altered=true;
}
if (ImGui::RadioButton("PCM (crisp samples; high CPU usage)",!dpcmMode)) {
dpcmMode=false;
altered=true;
}
if (altered) { if (altered) {
e->lockSave([&]() { e->lockSave([&]() {
flags.set("clockSel",clockSel); flags.set("clockSel",clockSel);
flags.set("dpcmMode",dpcmMode);
}); });
} }
break; break;