diff --git a/src/engine/fileOps.cpp b/src/engine/fileOps.cpp index 86c971947..619591209 100644 --- a/src/engine/fileOps.cpp +++ b/src/engine/fileOps.cpp @@ -530,7 +530,7 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { if (ds.system[0]==DIV_SYSTEM_GB) { wave->max=15; } - if (wave->len>33) { + if (wave->len>65) { logE("invalid wave length %d. are we doing something wrong?\n",wave->len); lastError="file is corrupt or unreadable at wavetables"; delete[] file; @@ -736,6 +736,11 @@ bool DivEngine::loadDMF(unsigned char* file, size_t len) { ds.system[0]=DIV_SYSTEM_NES; ds.system[1]=DIV_SYSTEM_VRC7; } + if (ds.system[0]==DIV_SYSTEM_NES_FDS) { + ds.systemLen=2; + ds.system[0]=DIV_SYSTEM_NES; + ds.system[1]=DIV_SYSTEM_FDS; + } if (active) quitDispatch(); BUSY_BEGIN_SOFT; @@ -2055,19 +2060,22 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) { bool isFlat=false; if (song.systemLen==2) { if (song.system[0]==DIV_SYSTEM_YM2612 && song.system[1]==DIV_SYSTEM_SMS) { - isFlat=true; + isFlat=true; } if (song.system[0]==DIV_SYSTEM_YM2612_EXT && song.system[1]==DIV_SYSTEM_SMS) { - isFlat=true; + isFlat=true; } if (song.system[0]==DIV_SYSTEM_YM2151 && song.system[1]==DIV_SYSTEM_SEGAPCM_COMPAT) { isFlat=true; } if (song.system[0]==DIV_SYSTEM_SMS && song.system[1]==DIV_SYSTEM_OPLL) { - isFlat=true; + isFlat=true; } if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_VRC7) { - isFlat=true; + isFlat=true; + } + if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_FDS) { + isFlat=true; } } // fail if more than one system @@ -2127,6 +2135,9 @@ SafeWriter* DivEngine::saveDMF(unsigned char version) { } else if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_VRC7) { w->writeC(systemToFileDMF(DIV_SYSTEM_NES_VRC7)); sys=DIV_SYSTEM_NES_VRC7; + } else if (song.system[0]==DIV_SYSTEM_NES && song.system[1]==DIV_SYSTEM_FDS) { + w->writeC(systemToFileDMF(DIV_SYSTEM_NES_FDS)); + sys=DIV_SYSTEM_NES_VRC7; } else { w->writeC(systemToFileDMF(song.system[0])); sys=song.system[0]; diff --git a/src/engine/song.h b/src/engine/song.h index 9142636e3..1b8c85c21 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -42,6 +42,7 @@ enum DivSystem { DIV_SYSTEM_PCE, DIV_SYSTEM_NES, DIV_SYSTEM_NES_VRC7, // ** COMPOUND SYSTEM - DO NOT USE! ** + DIV_SYSTEM_NES_FDS, // ** COMPOUND SYSTEM - DO NOT USE! ** DIV_SYSTEM_C64_6581, DIV_SYSTEM_C64_8580, DIV_SYSTEM_ARCADE, // ** COMPOUND SYSTEM - DO NOT USE! ** diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 2b935b1aa..b3f9e6ab5 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -174,11 +174,12 @@ unsigned char DivEngine::systemToFileFur(DivSystem val) { return 0x43; case DIV_SYSTEM_NES_VRC7: return 0x46; + case DIV_SYSTEM_NES_FDS: + return 0; // unsupported case DIV_SYSTEM_C64_6581: return 0x47; case DIV_SYSTEM_YM2610_EXT: return 0x49; - // Furnace-specific systems case DIV_SYSTEM_AY8910: return 0x80; case DIV_SYSTEM_AMIGA: @@ -280,6 +281,80 @@ unsigned char DivEngine::systemToFileFur(DivSystem val) { return 0; } +DivSystem DivEngine::systemFromFileDMF(unsigned char val) { + switch (val) { + case 0x01: + return DIV_SYSTEM_YMU759; + case 0x02: + return DIV_SYSTEM_GENESIS; + case 0x03: + return DIV_SYSTEM_SMS; + case 0x04: + return DIV_SYSTEM_GB; + case 0x05: + return DIV_SYSTEM_PCE; + case 0x06: + return DIV_SYSTEM_NES; + case 0x07: + return DIV_SYSTEM_C64_8580; + case 0x08: + return DIV_SYSTEM_ARCADE; + case 0x09: + return DIV_SYSTEM_YM2610; + case 0x42: + return DIV_SYSTEM_GENESIS_EXT; + case 0x43: + return DIV_SYSTEM_SMS_OPLL; + case 0x46: + return DIV_SYSTEM_NES_VRC7; + case 0x47: + return DIV_SYSTEM_C64_6581; + case 0x49: + return DIV_SYSTEM_YM2610_EXT; + case 0x86: + return DIV_SYSTEM_NES_FDS; + } + return DIV_SYSTEM_NULL; +} + +unsigned char DivEngine::systemToFileDMF(DivSystem val) { + switch (val) { + case DIV_SYSTEM_YMU759: + return 0x01; + case DIV_SYSTEM_GENESIS: + return 0x02; + case DIV_SYSTEM_SMS: + return 0x03; + case DIV_SYSTEM_GB: + return 0x04; + case DIV_SYSTEM_PCE: + return 0x05; + case DIV_SYSTEM_NES: + return 0x06; + case DIV_SYSTEM_C64_8580: + return 0x07; + case DIV_SYSTEM_ARCADE: + return 0x08; + case DIV_SYSTEM_YM2610: + return 0x09; + case DIV_SYSTEM_GENESIS_EXT: + return 0x42; + case DIV_SYSTEM_SMS_OPLL: + return 0x43; + case DIV_SYSTEM_NES_VRC7: + return 0x46; + case DIV_SYSTEM_NES_FDS: + return 0x86; + case DIV_SYSTEM_C64_6581: + return 0x47; + case DIV_SYSTEM_YM2610_EXT: + return 0x49; + default: + return 0; + } + return 0; +} + int DivEngine::getChannelCount(DivSystem sys) { switch (sys) { case DIV_SYSTEM_NULL: @@ -305,9 +380,10 @@ int DivEngine::getChannelCount(DivSystem sys) { return 13; case DIV_SYSTEM_NES_VRC7: return 11; + case DIV_SYSTEM_NES_FDS: + return 6; case DIV_SYSTEM_YM2610_EXT: return 16; - // Furnace-specific systems case DIV_SYSTEM_AY8910: case DIV_SYSTEM_AY8930: return 3; @@ -576,6 +652,8 @@ const char* DivEngine::getSystemName(DivSystem sys) { return "NES"; case DIV_SYSTEM_NES_VRC7: return "NES + Konami VRC7"; + case DIV_SYSTEM_NES_FDS: + return "Famicom Disk System"; case DIV_SYSTEM_C64_6581: return "Commodore 64 with 6581"; case DIV_SYSTEM_C64_8580: @@ -588,7 +666,6 @@ const char* DivEngine::getSystemName(DivSystem sys) { return "Neo Geo CD"; case DIV_SYSTEM_YM2610_EXT: return "Neo Geo CD Extended Channel 2"; - // Furnace-specific systems case DIV_SYSTEM_YM2610_FULL: return "Neo Geo"; case DIV_SYSTEM_YM2610_FULL_EXT: @@ -707,6 +784,8 @@ const char* DivEngine::getSystemChips(DivSystem sys) { return "Ricoh 2A03"; case DIV_SYSTEM_NES_VRC7: return "Ricoh 2A03 + Konami VRC7"; + case DIV_SYSTEM_NES_FDS: + return "Ricoh 2A03 + Famicom Disk System"; case DIV_SYSTEM_C64_6581: return "SID 6581"; case DIV_SYSTEM_C64_8580: @@ -719,7 +798,6 @@ const char* DivEngine::getSystemChips(DivSystem sys) { return "Yamaha YM2610 no ADPCM-B"; case DIV_SYSTEM_YM2610_EXT: return "Yamaha YM2610 no ADPCM-B (extended channel 2)"; - // Furnace-specific systems case DIV_SYSTEM_AY8910: return "AY-3-8910"; case DIV_SYSTEM_AMIGA: @@ -851,7 +929,6 @@ const char* DivEngine::getSystemNameJ(DivSystem sys) { return "業務用ネオジオ"; case DIV_SYSTEM_YM2610_FULL_EXT: return "業務用ネオジオ"; - // Furnace-specific systems case DIV_SYSTEM_AY8910: return ""; case DIV_SYSTEM_AMIGA: @@ -1093,6 +1170,7 @@ const char* DivEngine::getChannelName(int chan) { break; case DIV_SYSTEM_SMS_OPLL: // this is flattened to SMS + OPLL. case DIV_SYSTEM_NES_VRC7: // this is flattened to NES + VRC7. + case DIV_SYSTEM_NES_FDS: // this is flattened to NES + FDS. return "??"; break; case DIV_SYSTEM_GB: @@ -1239,6 +1317,7 @@ const char* DivEngine::getChannelShortName(int chan) { break; case DIV_SYSTEM_SMS_OPLL: // this is flattened to SMS + OPLL. case DIV_SYSTEM_NES_VRC7: // this is flattened to NES + VRC7. + case DIV_SYSTEM_NES_FDS: // this is flattened to NES + FDS. return "??"; break; case DIV_SYSTEM_GB: @@ -1381,6 +1460,7 @@ int DivEngine::getChannelType(int chan) { break; case DIV_SYSTEM_SMS_OPLL: // this is flattened to SMS + OPLL. case DIV_SYSTEM_NES_VRC7: // this is flattened to NES + VRC7. + case DIV_SYSTEM_NES_FDS: // this is flattened to NES + FDS. return 0; break; case DIV_SYSTEM_GB: @@ -1529,6 +1609,9 @@ DivInstrumentType DivEngine::getPreferInsType(int chan) { case DIV_SYSTEM_NES_VRC7: // this is flattened to NES + VRC7. return DIV_INS_OPLL; break; + case DIV_SYSTEM_NES_FDS: // this is flattened to NES + FDS. + return DIV_INS_STD; + break; case DIV_SYSTEM_GB: return chanPrefType[4][dispatchChanOfChan[chan]]; break;