- add ID code to Slot2 devices;
This commit is contained in:
mtabachenko 2013-11-11 09:19:20 +00:00
parent 69f5f165e2
commit 94aac3fccd
14 changed files with 67 additions and 28 deletions

View File

@ -33,7 +33,7 @@ public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Auto","Slot2 (auto-selection) device emulation");
static Slot2InfoSimple info("Auto","Slot2 (auto-selection) device emulation", 0xFE);
return &info;
}
@ -43,6 +43,9 @@ public:
NDS_SLOT2_TYPE selection = NDS_SLOT2_NONE;
//check game ID in core emulator and select right implementation
if (gameInfo.romsize == 0)
{}
else
if ((memcmp(gameInfo.header.gameCode, "UBR", 3) == 0)) selection = NDS_SLOT2_EXPMEMORY; // Opera Browser
else
if ((memcmp(gameInfo.header.gameCode, "YGH", 3) == 0)) selection = NDS_SLOT2_GUITARGRIP; // Guitar Hero - On Tour

View File

@ -41,7 +41,7 @@ private:
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Memory Expansion Pak", "Official RAM expansion for Opera browser");
static Slot2InfoSimple info("Memory Expansion Pak", "Official RAM expansion for Opera browser", 0x05);
return &info;
}

View File

@ -303,7 +303,7 @@ private:
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("GBA cartridge", "GBA cartridge in slot");
static Slot2InfoSimple info("GBA cartridge", "GBA cartridge in slot", 0x03);
return &info;
}

View File

@ -26,7 +26,7 @@ private:
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Guitar Grip", "Guitar Grip for Guitar Hero games");
static Slot2InfoSimple info("Guitar Grip", "Guitar Grip for Guitar Hero games", 0x04);
return &info;
}

View File

@ -266,7 +266,7 @@ class Slot2_CFlash : public ISlot2Interface
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("MPCF Flash Card Device", "MPCF Flash Card Device");
static Slot2InfoSimple info("MPCF Flash Card Device", "MPCF Flash Card Device", 0x01);
return &info;
}

View File

@ -23,7 +23,7 @@ class Slot2_None : public ISlot2Interface
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("None", "Slot2 no-device emulation");
static Slot2InfoSimple info("None", "Slot2 no-device emulation", 0xFF);
return &info;
}
};

View File

@ -56,7 +56,7 @@ private:
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Paddle", "Paddle");
static Slot2InfoSimple info("Paddle", "Paddle", 0x07);
return &info;
}

View File

@ -24,7 +24,7 @@ class Slot2_PassME : public ISlot2Interface
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("PassME", "PassME in GBA slot");
static Slot2InfoSimple info("PassME", "PassME in GBA slot", 0x08);
return &info;
}

View File

@ -24,7 +24,7 @@ class Slot2_EasyPiano : public ISlot2Interface
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Piano", "Piano for EasyPiano");
static Slot2InfoSimple info("Piano", "Piano for EasyPiano", 0x06);
return &info;
}

View File

@ -28,7 +28,7 @@ private:
public:
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Rumble Pak", "NDS Rumble Pak (need joystick with Feedback)");
static Slot2InfoSimple info("Rumble Pak", "NDS Rumble Pak (need joystick with Feedback)", 0x02);
return &info;
}

View File

@ -115,6 +115,26 @@ bool slot2_Change(NDS_SLOT2_TYPE changeToType)
return true;
}
bool getTypeByID(u8 ID, NDS_SLOT2_TYPE &type)
{
for (u8 i = 0; i < NDS_SLOT2_COUNT; i++)
{
if (slot2_List[i]->info()->id() == ID)
{
type = (NDS_SLOT2_TYPE)i;
return true;
}
}
return false;
}
bool slot2_ChangeByID(u8 ID)
{
NDS_SLOT2_TYPE type = NDS_SLOT2_AUTO;
getTypeByID(ID, type);
return slot2_Change(type);
}
NDS_SLOT2_TYPE slot2_GetCurrentType()
{
return slot2_device_type;

View File

@ -27,20 +27,24 @@ class Slot2Info
public:
virtual const char* name() const = 0;
virtual const char* descr() const = 0;
virtual const u8 id() const = 0;
};
class Slot2InfoSimple : public Slot2Info
{
public:
Slot2InfoSimple(const char* _name, const char* _descr)
Slot2InfoSimple(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 ISlot2Interface
@ -78,16 +82,16 @@ typedef ISlot2Interface* TISlot2InterfaceConstructor();
enum NDS_SLOT2_TYPE
{
NDS_SLOT2_NONE,
NDS_SLOT2_AUTO,
NDS_SLOT2_CFLASH, // compact flash
NDS_SLOT2_RUMBLEPAK, // rumble pack
NDS_SLOT2_GBACART, // GBA cartrindge in slot
NDS_SLOT2_GUITARGRIP, // Guitar Grip
NDS_SLOT2_EXPMEMORY, // Memory Expansion
NDS_SLOT2_EASYPIANO, // Easy Piano
NDS_SLOT2_PADDLE,
NDS_SLOT2_PASSME, // PassME
NDS_SLOT2_NONE, // 0xFF
NDS_SLOT2_AUTO, // 0xFE - Auto-select
NDS_SLOT2_CFLASH, // 0x01 - Compact flash
NDS_SLOT2_RUMBLEPAK, // 0x02 - RumblePak
NDS_SLOT2_GBACART, // 0x03 - GBA cartrindge in slot
NDS_SLOT2_GUITARGRIP, // 0x04 - Guitar Grip
NDS_SLOT2_EXPMEMORY, // 0x05 - Memory Expansion Pak
NDS_SLOT2_EASYPIANO, // 0x06 - Easy Piano
NDS_SLOT2_PADDLE, // 0x07 - Arkanoids DS paddle
NDS_SLOT2_PASSME, // 0x08 - PassME/Homebrew
NDS_SLOT2_COUNT // use for counter addons - MUST TO BE LAST!!!
};
@ -107,6 +111,11 @@ void slot2_Reset();
//change the current device
bool slot2_Change(NDS_SLOT2_TYPE type);
bool getTypeByID(u8 ID, NDS_SLOT2_TYPE &type);
//change the current device by ID
bool slot2_ChangeByID(u8 ID);
//check on the current device
NDS_SLOT2_TYPE slot2_GetCurrentType();

View File

@ -641,11 +641,14 @@ void GBAslotDialog(HWND hwnd)
default:
return;
}
if (temp_type!=NDS_SLOT2_GUITARGRIP)
if (temp_type != NDS_SLOT2_GUITARGRIP)
Guitar.Enabled = false;
WritePrivateProfileInt("Slot2","type",temp_type,IniName);
if (temp_type != NDS_SLOT2_EASYPIANO)
Piano.Enabled = false;
slot2_Change((NDS_SLOT2_TYPE)temp_type);
WritePrivateProfileInt("Slot2", "id", slot2_List[(u8)slot2_GetCurrentType()]->info()->id(), IniName);
if (romloaded && needReset)
NDS_Reset();
return;

View File

@ -3158,7 +3158,13 @@ int _main()
cmdline._slot1_fat_dir_type = 0;
slot1_R4_path_type = cmdline._slot1_fat_dir_type;
int slot2_device_type = (NDS_SLOT2_TYPE)GetPrivateProfileInt("Slot2", "type", NDS_SLOT2_AUTO, IniName);
slot1_Init();
slot2_Init();
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);
win32_CFlash_cfgMode = GetPrivateProfileInt("Slot2.CFlash", "fileMode", ADDON_CFLASH_MODE_RomPath, IniName);
win32_CFlash_cfgDirectory = GetPrivateProfileStdString("Slot2.CFlash", "path", "");
win32_CFlash_cfgFileName = GetPrivateProfileStdString("Slot2.CFlash", "filename", "");
@ -3178,16 +3184,14 @@ int _main()
else
win32_CFlash_cfgFileName = CFlash_Path;
}
slot1_Init();
//override slot1 type with commandline, if present
int slot1_device_type = (NDS_SLOT1_TYPE)GetPrivateProfileInt("Slot1", "type", NDS_SLOT1_RETAIL_AUTO, IniName);
if(cmdline.slot1 != "")
WritePrivateProfileInt("Slot1","type",slot1_device_type,IniName);
else
slot1_Change((NDS_SLOT1_TYPE)slot1_device_type);
slot2_Init();
if(cmdline.gbaslot_rom != "")
{
slot2_device_type = NDS_SLOT2_GBACART;