diff --git a/desmume/src/addons/slot1_none.cpp b/desmume/src/addons/slot1_none.cpp index 6b16f4728..69cf8bcaf 100644 --- a/desmume/src/addons/slot1_none.cpp +++ b/desmume/src/addons/slot1_none.cpp @@ -25,7 +25,7 @@ class Slot1_None : public ISlot1Interface public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("None","Slot1 no-card emulation"); + static Slot1InfoSimple info("None","Slot1 no-card emulation", 0xFF); return &info; } diff --git a/desmume/src/addons/slot1_r4.cpp b/desmume/src/addons/slot1_r4.cpp index 000335395..e63fd7f99 100644 --- a/desmume/src/addons/slot1_r4.cpp +++ b/desmume/src/addons/slot1_r4.cpp @@ -42,7 +42,7 @@ public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("R4","Slot1 R4 emulation"); + static Slot1InfoSimple info("R4", "Slot1 R4 emulation", 0x03); return &info; } diff --git a/desmume/src/addons/slot1_retail_auto.cpp b/desmume/src/addons/slot1_retail_auto.cpp index 7a150889e..434fe3c56 100644 --- a/desmume/src/addons/slot1_retail_auto.cpp +++ b/desmume/src/addons/slot1_retail_auto.cpp @@ -33,7 +33,7 @@ public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("Retail (Auto)","Slot1 Retail (auto-selection) card emulation"); + static Slot1InfoSimple info("Retail (Auto)","Slot1 Retail (auto-selection) card emulation", 0xFE); return &info; } diff --git a/desmume/src/addons/slot1_retail_mcrom.cpp b/desmume/src/addons/slot1_retail_mcrom.cpp index 7f6744d53..025bd2972 100644 --- a/desmume/src/addons/slot1_retail_mcrom.cpp +++ b/desmume/src/addons/slot1_retail_mcrom.cpp @@ -39,7 +39,7 @@ public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("Retail MC+ROM","Slot1 Retail MC+ROM (standard) card emulation"); + static Slot1InfoSimple info("Retail MC+ROM", "Slot1 Retail MC+ROM (standard) card emulation", 0x01); return &info; } diff --git a/desmume/src/addons/slot1_retail_mcrom_debug.cpp b/desmume/src/addons/slot1_retail_mcrom_debug.cpp index 742b3fadb..f556bff79 100644 --- a/desmume/src/addons/slot1_retail_mcrom_debug.cpp +++ b/desmume/src/addons/slot1_retail_mcrom_debug.cpp @@ -45,7 +45,7 @@ public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("Retail DEBUG","Slot1 Retail (standard) card emulation + FS Nitro DEBUG"); + static Slot1InfoSimple info("Retail DEBUG","Slot1 Retail (standard) card emulation + FS Nitro DEBUG", 0x04); return &info; } diff --git a/desmume/src/addons/slot1_retail_nand.cpp b/desmume/src/addons/slot1_retail_nand.cpp index ad7337ffd..1474376e9 100644 --- a/desmume/src/addons/slot1_retail_nand.cpp +++ b/desmume/src/addons/slot1_retail_nand.cpp @@ -50,7 +50,7 @@ private: public: virtual Slot1Info const* info() { - static Slot1InfoSimple info("Retail NAND","Slot1 retail NAND card emulation"); + static Slot1InfoSimple info("Retail NAND","Slot1 retail NAND card emulation", 0x02); return &info; } diff --git a/desmume/src/slot1.cpp b/desmume/src/slot1.cpp index 74bebc8b4..7708b6d32 100644 --- a/desmume/src/slot1.cpp +++ b/desmume/src/slot1.cpp @@ -164,6 +164,26 @@ bool slot1_Change(NDS_SLOT1_TYPE changeToType) return true; } +bool slot1_getTypeByID(u8 ID, NDS_SLOT1_TYPE &type) +{ + for (u8 i = 0; i < NDS_SLOT1_COUNT; i++) + { + if (slot1_List[i]->info()->id() == ID) + { + type = (NDS_SLOT1_TYPE)i; + return true; + } + } + return false; +} + +bool slot1_ChangeByID(u8 ID) +{ + NDS_SLOT1_TYPE type = NDS_SLOT1_RETAIL_AUTO; + slot1_getTypeByID(ID, type); + return slot1_Change(type); +} + NDS_SLOT1_TYPE slot1_GetCurrentType() { return slot1_device_type; diff --git a/desmume/src/slot1.h b/desmume/src/slot1.h index e9d46be56..bf57539f9 100644 --- a/desmume/src/slot1.h +++ b/desmume/src/slot1.h @@ -31,20 +31,24 @@ class Slot1Info public: virtual const char* name() const = 0; virtual const char* descr()const = 0; + virtual const u8 id() const = 0; }; class Slot1InfoSimple : public Slot1Info { public: - Slot1InfoSimple(const char* _name, const char* _descr) + Slot1InfoSimple(const char* _name, const char* _descr, const u8 _id) : mName(_name) , mDescr(_descr) + , mID(_id) { } virtual const char* name() const { return mName; } virtual const char* descr() const { return mDescr; } + virtual const u8 id() const { return mID; } private: const char* mName, *mDescr; + const u8 mID; }; class ISlot1Interface @@ -93,12 +97,12 @@ typedef ISlot1Interface* TISlot1InterfaceConstructor(); enum NDS_SLOT1_TYPE { - NDS_SLOT1_NONE, - NDS_SLOT1_RETAIL_AUTO, //autodetect which kind of retail card to use - NDS_SLOT1_R4, //R4 flash card - NDS_SLOT1_RETAIL_NAND, //Made in Ore/WarioWare D.I.Y. - NDS_SLOT1_RETAIL_MCROM, //a standard MC (eeprom, flash, fram) -bearing retail card. Also supports motion, for now, because that's the way we originally coded it - NDS_SLOT1_RETAIL_DEBUG, //for romhacking and fan-made translations + NDS_SLOT1_NONE, // 0xFF - None + NDS_SLOT1_RETAIL_AUTO, // 0xFE - autodetect which kind of retail card to use + NDS_SLOT1_R4, // 0x03 - R4 flash card + NDS_SLOT1_RETAIL_NAND, // 0x02 - Made in Ore/WarioWare D.I.Y. + NDS_SLOT1_RETAIL_MCROM, // 0x01 - a standard MC (eeprom, flash, fram) -bearing retail card. Also supports motion, for now, because that's the way we originally coded it + NDS_SLOT1_RETAIL_DEBUG, // 0x04 - for romhacking and fan-made translations NDS_SLOT1_COUNT //use to count addons - MUST BE LAST!!! }; @@ -115,9 +119,14 @@ void slot1_Loadstate(EMUFILE* is); //just disconnects and reconnects the device. ideally, the disconnection and connection would be called with sensible timing void slot1_Reset(); +bool slot1_getTypeByID(u8 ID, NDS_SLOT1_TYPE &type); + //change the current device bool slot1_Change(NDS_SLOT1_TYPE type); +//change the current device by ID +bool slot1_ChangeByID(u8 ID); + //check on the current device NDS_SLOT1_TYPE slot1_GetCurrentType(); diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp index 2dbef1ce6..45c423bfd 100644 --- a/desmume/src/slot2.cpp +++ b/desmume/src/slot2.cpp @@ -115,7 +115,7 @@ bool slot2_Change(NDS_SLOT2_TYPE changeToType) return true; } -bool getTypeByID(u8 ID, NDS_SLOT2_TYPE &type) +bool slot2_getTypeByID(u8 ID, NDS_SLOT2_TYPE &type) { for (u8 i = 0; i < NDS_SLOT2_COUNT; i++) { @@ -131,7 +131,7 @@ bool getTypeByID(u8 ID, NDS_SLOT2_TYPE &type) bool slot2_ChangeByID(u8 ID) { NDS_SLOT2_TYPE type = NDS_SLOT2_AUTO; - getTypeByID(ID, type); + slot2_getTypeByID(ID, type); return slot2_Change(type); } diff --git a/desmume/src/slot2.h b/desmume/src/slot2.h index 952f26f43..621dff064 100644 --- a/desmume/src/slot2.h +++ b/desmume/src/slot2.h @@ -111,7 +111,7 @@ void slot2_Reset(); //change the current device bool slot2_Change(NDS_SLOT2_TYPE type); -bool getTypeByID(u8 ID, NDS_SLOT2_TYPE &type); +bool slot2_getTypeByID(u8 ID, NDS_SLOT2_TYPE &type); //change the current device by ID bool slot2_ChangeByID(u8 ID); diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 31444de08..a2f02a958 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -3163,7 +3163,7 @@ int _main() int slot2_device_id = (NDS_SLOT2_TYPE)GetPrivateProfileInt("Slot2", "id", slot2_List[NDS_SLOT2_AUTO]->info()->id(), IniName); NDS_SLOT2_TYPE slot2_device_type = NDS_SLOT2_AUTO; - getTypeByID(slot2_device_id, slot2_device_type); + slot2_getTypeByID(slot2_device_id, slot2_device_type); win32_CFlash_cfgMode = GetPrivateProfileInt("Slot2.CFlash", "fileMode", ADDON_CFLASH_MODE_RomPath, IniName); win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", ""); @@ -3186,7 +3186,10 @@ int _main() } //override slot1 type with commandline, if present - int slot1_device_type = (NDS_SLOT1_TYPE)GetPrivateProfileInt("Slot1", "type", NDS_SLOT1_RETAIL_AUTO, IniName); + int slot1_device_id = (NDS_SLOT1_TYPE)GetPrivateProfileInt("Slot1", "id", slot1_List[NDS_SLOT1_RETAIL_AUTO]->info()->id(), IniName); + NDS_SLOT1_TYPE slot1_device_type = NDS_SLOT1_RETAIL_AUTO; + slot1_getTypeByID(slot1_device_id, slot1_device_type); + if(cmdline.slot1 != "") WritePrivateProfileInt("Slot1","type",slot1_device_type,IniName); else diff --git a/desmume/src/windows/slot1_config.cpp b/desmume/src/windows/slot1_config.cpp index 2aa793214..0cdb4f2e7 100644 --- a/desmume/src/windows/slot1_config.cpp +++ b/desmume/src/windows/slot1_config.cpp @@ -349,9 +349,9 @@ void slot1Dialog(HWND hwnd) default: return; } - WritePrivateProfileInt("Slot1","type",temp_type_slot1,IniName); - + slot1_Change((NDS_SLOT1_TYPE)temp_type_slot1); + WritePrivateProfileInt("Slot1", "id", slot1_List[temp_type_slot1]->info()->id(), IniName); return; }