- add device ID code;
This commit is contained in:
mtabachenko 2013-11-11 10:04:10 +00:00
parent 94aac3fccd
commit 3cd1e909fc
12 changed files with 52 additions and 20 deletions

View File

@ -25,7 +25,7 @@ class Slot1_None : public ISlot1Interface
public: public:
virtual Slot1Info const* info() virtual Slot1Info const* info()
{ {
static Slot1InfoSimple info("None","Slot1 no-card emulation"); static Slot1InfoSimple info("None","Slot1 no-card emulation", 0xFF);
return &info; return &info;
} }

View File

@ -42,7 +42,7 @@ public:
virtual Slot1Info const* info() virtual Slot1Info const* info()
{ {
static Slot1InfoSimple info("R4","Slot1 R4 emulation"); static Slot1InfoSimple info("R4", "Slot1 R4 emulation", 0x03);
return &info; return &info;
} }

View File

@ -33,7 +33,7 @@ public:
virtual Slot1Info const* info() 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; return &info;
} }

View File

@ -39,7 +39,7 @@ public:
virtual Slot1Info const* info() 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; return &info;
} }

View File

@ -45,7 +45,7 @@ public:
virtual Slot1Info const* info() 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; return &info;
} }

View File

@ -50,7 +50,7 @@ private:
public: public:
virtual Slot1Info const* info() 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; return &info;
} }

View File

@ -164,6 +164,26 @@ bool slot1_Change(NDS_SLOT1_TYPE changeToType)
return true; 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() NDS_SLOT1_TYPE slot1_GetCurrentType()
{ {
return slot1_device_type; return slot1_device_type;

View File

@ -31,20 +31,24 @@ class Slot1Info
public: public:
virtual const char* name() const = 0; virtual const char* name() const = 0;
virtual const char* descr()const = 0; virtual const char* descr()const = 0;
virtual const u8 id() const = 0;
}; };
class Slot1InfoSimple : public Slot1Info class Slot1InfoSimple : public Slot1Info
{ {
public: public:
Slot1InfoSimple(const char* _name, const char* _descr) Slot1InfoSimple(const char* _name, const char* _descr, const u8 _id)
: mName(_name) : mName(_name)
, mDescr(_descr) , mDescr(_descr)
, mID(_id)
{ {
} }
virtual const char* name() const { return mName; } virtual const char* name() const { return mName; }
virtual const char* descr() const { return mDescr; } virtual const char* descr() const { return mDescr; }
virtual const u8 id() const { return mID; }
private: private:
const char* mName, *mDescr; const char* mName, *mDescr;
const u8 mID;
}; };
class ISlot1Interface class ISlot1Interface
@ -93,12 +97,12 @@ typedef ISlot1Interface* TISlot1InterfaceConstructor();
enum NDS_SLOT1_TYPE enum NDS_SLOT1_TYPE
{ {
NDS_SLOT1_NONE, NDS_SLOT1_NONE, // 0xFF - None
NDS_SLOT1_RETAIL_AUTO, //autodetect which kind of retail card to use NDS_SLOT1_RETAIL_AUTO, // 0xFE - autodetect which kind of retail card to use
NDS_SLOT1_R4, //R4 flash card NDS_SLOT1_R4, // 0x03 - R4 flash card
NDS_SLOT1_RETAIL_NAND, //Made in Ore/WarioWare D.I.Y. NDS_SLOT1_RETAIL_NAND, // 0x02 - 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_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, //for romhacking and fan-made translations NDS_SLOT1_RETAIL_DEBUG, // 0x04 - for romhacking and fan-made translations
NDS_SLOT1_COUNT //use to count addons - MUST BE LAST!!! 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 //just disconnects and reconnects the device. ideally, the disconnection and connection would be called with sensible timing
void slot1_Reset(); void slot1_Reset();
bool slot1_getTypeByID(u8 ID, NDS_SLOT1_TYPE &type);
//change the current device //change the current device
bool slot1_Change(NDS_SLOT1_TYPE type); bool slot1_Change(NDS_SLOT1_TYPE type);
//change the current device by ID
bool slot1_ChangeByID(u8 ID);
//check on the current device //check on the current device
NDS_SLOT1_TYPE slot1_GetCurrentType(); NDS_SLOT1_TYPE slot1_GetCurrentType();

View File

@ -115,7 +115,7 @@ bool slot2_Change(NDS_SLOT2_TYPE changeToType)
return true; 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++) 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) bool slot2_ChangeByID(u8 ID)
{ {
NDS_SLOT2_TYPE type = NDS_SLOT2_AUTO; NDS_SLOT2_TYPE type = NDS_SLOT2_AUTO;
getTypeByID(ID, type); slot2_getTypeByID(ID, type);
return slot2_Change(type); return slot2_Change(type);
} }

View File

@ -111,7 +111,7 @@ void slot2_Reset();
//change the current device //change the current device
bool slot2_Change(NDS_SLOT2_TYPE type); 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 //change the current device by ID
bool slot2_ChangeByID(u8 ID); bool slot2_ChangeByID(u8 ID);

View File

@ -3163,7 +3163,7 @@ int _main()
int slot2_device_id = (NDS_SLOT2_TYPE)GetPrivateProfileInt("Slot2", "id", slot2_List[NDS_SLOT2_AUTO]->info()->id(), IniName); 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; 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_cfgMode = GetPrivateProfileInt("Slot2.CFlash", "fileMode", ADDON_CFLASH_MODE_RomPath, IniName);
win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", ""); win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", "");
@ -3186,7 +3186,10 @@ int _main()
} }
//override slot1 type with commandline, if present //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 != "") if(cmdline.slot1 != "")
WritePrivateProfileInt("Slot1","type",slot1_device_type,IniName); WritePrivateProfileInt("Slot1","type",slot1_device_type,IniName);
else else

View File

@ -349,9 +349,9 @@ void slot1Dialog(HWND hwnd)
default: default:
return; return;
} }
WritePrivateProfileInt("Slot1","type",temp_type_slot1,IniName);
slot1_Change((NDS_SLOT1_TYPE)temp_type_slot1); slot1_Change((NDS_SLOT1_TYPE)temp_type_slot1);
WritePrivateProfileInt("Slot1", "id", slot1_List[temp_type_slot1]->info()->id(), IniName);
return; return;
} }