diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index f368788ac..ce7f2a2ab 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1122,7 +1122,7 @@ void DivEngine::initSongWithDesc(const int* description) { song.system[index]=(DivSystem)description[i]; song.systemVol[index]=description[i+1]; song.systemPan[index]=description[i+2]; - song.systemFlags[index]=description[i+3]; + song.systemFlagsOld[index]=description[i+3]; index++; chanCount+=getChannelCount(song.system[index]); if (chanCount>=DIV_MAX_CHANS) break; @@ -1345,7 +1345,7 @@ void DivEngine::changeSystem(int index, DivSystem which, bool preserveOrder) { } song.system[index]=which; - song.systemFlags[index]=0; + song.systemFlagsOld[index]=0; recalcChans(); saveLock.unlock(); BUSY_END; @@ -1371,7 +1371,7 @@ bool DivEngine::addSystem(DivSystem which) { song.system[song.systemLen]=which; song.systemVol[song.systemLen]=64; song.systemPan[song.systemLen]=0; - song.systemFlags[song.systemLen++]=0; + song.systemFlagsOld[song.systemLen++]=0; recalcChans(); saveLock.unlock(); BUSY_END; @@ -1415,7 +1415,7 @@ bool DivEngine::removeSystem(int index, bool preserveOrder) { song.system[i]=song.system[i+1]; song.systemVol[i]=song.systemVol[i+1]; song.systemPan[i]=song.systemPan[i+1]; - song.systemFlags[i]=song.systemFlags[i+1]; + song.systemFlagsOld[i]=song.systemFlagsOld[i+1]; } recalcChans(); saveLock.unlock(); @@ -1541,9 +1541,9 @@ bool DivEngine::swapSystem(int src, int dest, bool preserveOrder) { song.systemPan[dest]^=song.systemPan[src]; song.systemPan[src]^=song.systemPan[dest]; - song.systemFlags[src]^=song.systemFlags[dest]; - song.systemFlags[dest]^=song.systemFlags[src]; - song.systemFlags[src]^=song.systemFlags[dest]; + song.systemFlagsOld[src]^=song.systemFlagsOld[dest]; + song.systemFlagsOld[dest]^=song.systemFlagsOld[src]; + song.systemFlagsOld[src]^=song.systemFlagsOld[dest]; recalcChans(); saveLock.unlock(); @@ -3470,9 +3470,9 @@ void DivEngine::setOrder(unsigned char order) { void DivEngine::setSysFlags(int system, unsigned int flags, bool restart) { BUSY_BEGIN_SOFT; saveLock.lock(); - song.systemFlags[system]=flags; + song.systemFlagsOld[system]=flags; saveLock.unlock(); - disCont[system].dispatch->setFlags(song.systemFlags[system]); + disCont[system].dispatch->setFlags(song.systemFlagsOld[system]); disCont[system].setRates(got.rate); if (restart && isPlaying()) { playSub(false); @@ -3630,7 +3630,7 @@ void DivEngine::rescanAudioDevices() { void DivEngine::initDispatch() { BUSY_BEGIN; for (int i=0; i1 || bypassLimits)?2:0); // PAL + ds.systemFlagsOld[i]=1|(80<<8)|(bypassLimits?4:0)|((ds.systemLen>1 || bypassLimits)?2:0); // PAL } for(int i=0; ichanShow[i]=true; @@ -2579,7 +2579,7 @@ bool DivEngine::loadFC(unsigned char* file, size_t len) { ds.system[0]=DIV_SYSTEM_AMIGA; ds.systemVol[0]=64; ds.systemPan[0]=0; - ds.systemFlags[0]=1|(80<<8); // PAL + ds.systemFlagsOld[0]=1|(80<<8); // PAL ds.systemName="Amiga"; seqLen=reader.readI_BE(); @@ -3219,11 +3219,11 @@ bool DivEngine::loadFTM(unsigned char* file, size_t len) { } if (expansions&16) { ds.system[systemID]=DIV_SYSTEM_N163; - ds.systemFlags[systemID++]=n163Chans; + ds.systemFlagsOld[systemID++]=n163Chans; } if (expansions&32) { ds.system[systemID]=DIV_SYSTEM_AY8910; - ds.systemFlags[systemID++]=38; // Sunsoft 5B + ds.systemFlagsOld[systemID++]=38; // Sunsoft 5B } ds.systemLen=systemID; @@ -3734,7 +3734,7 @@ SafeWriter* DivEngine::saveFur(bool notPrimary) { } for (int i=0; i<32; i++) { - w->writeI(song.systemFlags[i]); + w->writeI(song.systemFlagsOld[i]); } // song name diff --git a/src/engine/song.h b/src/engine/song.h index b708ac0fb..975cc6e86 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -25,6 +25,7 @@ #define DIV_MAX_CHANS 128 #include "../ta-utils.h" +#include "config.h" #include "orders.h" #include "instrument.h" #include "pattern.h" @@ -232,202 +233,10 @@ struct DivSong { unsigned char systemLen; signed char systemVol[32]; signed char systemPan[32]; - // interpretation of these flags varies depending on system. - // - most systems: - // - bit 0: PAL - // - NES: - // - bit 0-1: system type - // - 0: NTSC - // - 1: PAL - // - 2: Dendy - // - SMS/SN76489: - // - bit 0-1, 8-15: clock rate - // - 0000: 3.58MHz (NTSC) - // - 0001: 3.55MHz (PAL) - // - 0002: 4MHz (Other) - // - 0003: 1.79MHz (half NTSC) - // - 0100: 3MHz - // - 0101: 2MHz - // - 0102: 447KHz (NTSC / 8) - // - bit 2-3, 6-7: chip type - // - 00: Sega VDP (16-bit noise) - // - 04: real SN76489 (15-bit noise) - // - 08: real SN76489 with Atari-like short noise buzz (15-bit noise) - // - 0c: Game Gear (16-bit noise, stereo) - // - 40: real SN76489A (17-bit noise) - // - 44: real SN76496 (17-bit noise) - // - 48: NCR 8496 (16-bit noise) - // - 4c: Tandy PSSJ-3 (16-bit noise) - // - 80: real SN94624 (15-bit noise) - // - 84: real SN76494 (17-bit noise) - // - bit 4: disable noise phase reset - // - YM2612/YM3438: - // - bit 0-30: clock rate - // - 0: Genesis NTSC (7.67MHz) - // - 1: Genesis PAL (7.61MHz) - // - 2: FM Towns (8MHz) - // - 3: AtGames Genesis (6.13MHz) - // - 4: Sega System 32 (8.06MHz) - // - bit 31: DAC distortion - // - 0: disable - // - 1: enable - // - YM2151: - // - bit 0-7: clock rate - // - 0: 3.58MHz (NTSC) - // - 1: 3.55MHz (PAL) - // - 2: 4MHz - // - YM2610(B): - // - bit 0-7: clock rate - // - 0: 8MHz (Neo Geo MVS) - // - 1: 8.06MHz (Neo Geo AES) - // - AY-3-8910/AY8930: - // - bit 0-3: clock rate - // - 0: 1.79MHz (MSX NTSC) - // - 1: 1.77MHz (ZX Spectrum, MSX PAL, etc.) - // - 2: 1.75MHz (ZX Spectrum) - // - 3: 2MHz (Atari ST) - // - 4: 1.5MHz (Vectrex) - // - 5: 1MHz (Amstrad CPC) - // - 6: 0.89MHz (Sunsoft 5B) - // - 7: 1.67MHz - // - 8: 0.83MHz (Sunsoft 5B on PAL) - // - 9: 1.10MHz (Gamate/VIC-20 PAL) - // - 10: 2.097152MHz (Game Boy) - // - 11: 3.58MHz (Darky) - // - 12: 3.6MHz (Darky) - // - 13: 1.25MHz - // - 14: 1.536MHz - // - bit 4-5: chip type (ignored on AY8930) - // - 0: AY-3-8910 or similar - // - 1: YM2149 - // - 2: Sunsoft 5B - // - 3: AY-3-8914 - // - bit 6: stereo (ignored on Sunsoft 5B) - // - 0: mono - // - 1: stereo ABC - // - bit 7: clock divider pin (YM2149, AY8930) - // - 0: high (disable divider) - // - 1: low (internally divided to half) - // - SAA1099: - // - bit 0-1: clock rate - // - 0: 8MHz (SAM Coupé) - // - 1: 7.15MHz (Game Blaster, NTSC) - // - 2: 7.09MHz (PAL) - // - Amiga: - // - bit 0: clock rate - // - 0: 7.15MHz (NTSC) - // - 1: 7.09MHz (PAL) - // - bit 1: model - // - 0: Amiga 500 - // - 1: Amiga 1200 - // - bit 8-14: stereo separation - // - 0 is 0% while 127 is 100% - // - PC Speaker: - // - bit 0-1: speaker type - // - 0: unfiltered - // - 1: cone - // - 2: piezo - // - 3: real (TODO) - // - QSound: - // - bit 12-20: echo feedback - // - Valid values are 0-255 - // - bit 0-11: echo delay length - // - Valid values are 0-2725 - // - 0 is max length, 2725 is min length - // - OPLL: - // - bit 0-3: clock rate - // - 0: NTSC (3.58MHz) - // - 1: PAL (3.55MHz) - // - 2: Other (4MHz) - // - 3: half NTSC (1.79MHz) - // - bit 4-7: patch set - // - 0: YM2413 - // - 1: YMF281 - // - 2: YM2423 - // - 3: VRC7 - // - 4: custom (TODO) - // - X1-010: - // - bit 0-3: clock rate - // - 0: 16MHz (Seta 1) - // - 1: 16.67MHz (Seta 2) - // - bit 4: stereo - // - 0: mono - // - 1: stereo - // - YM2203: - // - bit 0-4: clock rate - // - 0: 3.58MHz (NTSC) - // - 1: 3.55MHz (PAL) - // - 2: 4MHz - // - 3: 3MHz - // - 4: 3.9936MHz (PC-88, PC-98) - // - 5: 1.5MHz - // - bit 5-6: output rate - // - 0: FM: clock / 72, SSG: clock / 16 - // - 1: FM: clock / 36, SSG: clock / 8 - // - 2: FM: clock / 24, SSG: clock / 4 - // - YM2608: - // - bit 0-4: clock rate - // - 0: 8MHz - // - 1: 7.987MHz (PC-88, PC-98) - // - bit 5-6: output rate - // - 0: FM: clock / 144, SSG: clock / 32 - // - 1: FM: clock / 72, SSG: clock / 16 - // - 2: FM: clock / 48, SSG: clock / 8 - // - YM3526, YM3812, Y8950: - // - bit 0-7: clock rate - // - 0: 3.58MHz (NTSC) - // - 1: 3.55MHz (PAL) - // - 2: 4MHz - // - 3: 3MHz - // - 4: 3.9936MHz (PC-88, PC-98) - // - 5: 3.5MHz - // - YMF262: - // - bit 0-7: clock rate - // - 0: 14.32MHz (NTSC) - // - 1: 14.19MHz (PAL) - // - 2: 14MHz - // - 3: 16MHz - // - 4: 15MHz - // - YMF289B: (TODO) - // - bit 0-7: clock rate - // - 0: 33.8688MHz - // - 1: 28.64MHz (NTSC) - // - 2: 28.38MHz (PAL) - // - MSM6295: - // - bit 0-6: clock rate - // - 0: 1MHz - // - 1: 1.056MHz - // - 2: 4MHz - // - 3: 4.224MHz - // - 4: 3.58MHz (NTSC) - // - 5: 1.79MHz (Half NTSC) - // - 6: 1.023MHz - // - 7: 0.895MHz (Quarter NTSC) - // - 8: 2MHz - // - 9: 2.112MHz - // - 10: 0.875MHz - // - 11: 0.9375MHz - // - 12: 1.5MHz - // - 13: 3MHz - // - 14: 1.193MHz - // - bit 7: Output rate - // - 0: clock / 132 - // - 1: clock / 165 - // - SCC/+: - // - bit 0-6: clock rate - // - 0: 1.79MHz (MSX NTSC) - // - 1: 1.77MHz (PAL) - // - 2: 1.5MHz - // - 3: 2MHz - // - YMZ280B: - // - bit 0-7: clock rate - // - 0: 16.9344MHz - // - 1: 14.32MHz (NTSC) - // - 2: 14.19MHz (PAL) - // - 3: 16MHz - // - 4: 16.67MHz - // - 5: 14MHz - unsigned int systemFlags[32]; + // this one will be removed soon... + unsigned int systemFlagsOld[32]; + // ...and replaced with... this! + DivConfig systemFlags[32]; // song information String name, author, systemName; @@ -623,7 +432,7 @@ struct DivSong { system[i]=DIV_SYSTEM_NULL; systemVol[i]=64; systemPan[i]=0; - systemFlags[i]=0; + systemFlagsOld[i]=0; } subsong.push_back(new DivSubSong); system[0]=DIV_SYSTEM_YM2612; diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 9a10d26c0..27c347145 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -61,7 +61,7 @@ String DivEngine::getSongSystemLegacyName(DivSong& ds, bool isMultiSystemAccepta return "help! what's going on!"; case 1: if (ds.system[0]==DIV_SYSTEM_AY8910) { - switch (ds.systemFlags[0]&0x3f) { + switch (ds.systemFlagsOld[0]&0x3f) { case 0: // AY-3-8910, 1.79MHz case 1: // AY-3-8910, 1.77MHz case 2: // AY-3-8910, 1.75MHz @@ -88,35 +88,35 @@ String DivEngine::getSongSystemLegacyName(DivSong& ds, bool isMultiSystemAccepta return "Intellivision (PAL)"; default: - if ((ds.systemFlags[0]&0x30)==0x00) { + if ((ds.systemFlagsOld[0]&0x30)==0x00) { return "AY-3-8910"; - } else if ((ds.systemFlags[0]&0x30)==0x10) { + } else if ((ds.systemFlagsOld[0]&0x30)==0x10) { return "Yamaha YM2149"; - } else if ((ds.systemFlags[0]&0x30)==0x20) { + } else if ((ds.systemFlagsOld[0]&0x30)==0x20) { return "Overclocked Sunsoft 5B"; - } else if ((ds.systemFlags[0]&0x30)==0x30) { + } else if ((ds.systemFlagsOld[0]&0x30)==0x30) { return "Intellivision"; } } } else if (ds.system[0]==DIV_SYSTEM_SMS) { - switch (ds.systemFlags[0]&0x0f) { + switch (ds.systemFlagsOld[0]&0x0f) { case 0: case 1: return "Sega Master System"; case 6: return "BBC Micro"; } } else if (ds.system[0]==DIV_SYSTEM_YM2612) { - switch (ds.systemFlags[0]&3) { + switch (ds.systemFlagsOld[0]&3) { case 2: return "FM Towns"; } } else if (ds.system[0]==DIV_SYSTEM_YM2151) { - switch (ds.systemFlags[0]&3) { + switch (ds.systemFlagsOld[0]&3) { case 2: return "Sharp X68000"; } } else if (ds.system[0]==DIV_SYSTEM_SAA1099) { - switch (ds.systemFlags[0]&3) { + switch (ds.systemFlagsOld[0]&3) { case 0: return "SAM Coupé"; } diff --git a/src/engine/vgmOps.cpp b/src/engine/vgmOps.cpp index c0dc88955..dd5e1f37a 100644 --- a/src/engine/vgmOps.cpp +++ b/src/engine/vgmOps.cpp @@ -939,7 +939,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p if (!hasSN) { hasSN=disCont[i].dispatch->chipClock; willExport[i]=true; - switch ((song.systemFlags[i]>>2)&3) { + switch ((song.systemFlagsOld[i]>>2)&3) { case 1: // real SN snNoiseConfig=3; snNoiseSize=15; @@ -1054,7 +1054,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p ayConfig=0x03; hasClockDivider=true; } else { - switch ((song.systemFlags[i]>>4)&3) { + switch ((song.systemFlagsOld[i]>>4)&3) { default: case 0: // AY8910 ayConfig=0x00; @@ -1073,10 +1073,10 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p break; } } - if (hasClockDivider && ((song.systemFlags[i]>>7)&1)) { + if (hasClockDivider && ((song.systemFlagsOld[i]>>7)&1)) { ayFlags|=0x10; } - if (hasStereo && ((song.systemFlags[i]>>6)&1)) { + if (hasStereo && ((song.systemFlagsOld[i]>>6)&1)) { ayFlags|=0x80; } willExport[i]=true; @@ -1304,7 +1304,7 @@ SafeWriter* DivEngine::saveVGM(bool* sysToExport, bool loop, int version, bool p // chips even though the only difference is the output resolution // these system types are currently handled by reusing isSecond flag // also this system is not dual-able - if ((song.systemFlags[i]>>4)==1) { + if ((song.systemFlagsOld[i]>>4)==1) { if (!hasRFC1) { hasRFC1=disCont[i].dispatch->chipClock; isSecond[i]=true; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 4c7850adf..9ce08ab58 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -3438,7 +3438,7 @@ bool FurnaceGUI::loop() { if (ImGui::BeginMenu("configure chip...")) { for (int i=0; isong.systemLen; i++) { if (ImGui::TreeNode(fmt::sprintf("%d. %s##_SYSP%d",i+1,getSystemName(e->song.system[i]),i).c_str())) { - drawSysConf(i,e->song.system[i],e->song.systemFlags[i],true); + drawSysConf(i,e->song.system[i],e->song.systemFlagsOld[i],true); ImGui::TreePop(); } } diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index a8fbf48dc..de770768e 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -1904,7 +1904,7 @@ void FurnaceGUI::drawInsEdit() { if (e->song.system[i]==DIV_SYSTEM_VRC7) { isPresent[3]=true; } else if (e->song.system[i]==DIV_SYSTEM_OPLL || e->song.system[i]==DIV_SYSTEM_OPLL_DRUMS) { - isPresent[(e->song.systemFlags[i]>>4)&3]=true; + isPresent[(e->song.systemFlagsOld[i]>>4)&3]=true; } } if (!isPresent[0] && !isPresent[1] && !isPresent[2] && !isPresent[3]) { diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 805072f16..b55a064c5 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -273,7 +273,7 @@ void FurnaceGUI::drawSettings() { settings.initialSys.push_back(e->song.system[i]); settings.initialSys.push_back(e->song.systemVol[i]); settings.initialSys.push_back(e->song.systemPan[i]); - settings.initialSys.push_back(e->song.systemFlags[i]); + settings.initialSys.push_back(e->song.systemFlagsOld[i]); } settings.initialSysName=e->song.systemName; } diff --git a/src/gui/sysManager.cpp b/src/gui/sysManager.cpp index 386d26583..5d7a59c73 100644 --- a/src/gui/sysManager.cpp +++ b/src/gui/sysManager.cpp @@ -70,7 +70,7 @@ void FurnaceGUI::drawSysManager() { } ImGui::TableNextColumn(); if (ImGui::TreeNode(fmt::sprintf("%d. %s##_SYSM%d",i+1,getSystemName(e->song.system[i]),i).c_str())) { - drawSysConf(i,e->song.system[i],e->song.systemFlags[i],true); + drawSysConf(i,e->song.system[i],e->song.systemFlagsOld[i],true); ImGui::TreePop(); } ImGui::TableNextColumn();