- add auto-detection device;
This commit is contained in:
mtabachenko 2013-11-11 00:01:22 +00:00
parent 2d93fc7901
commit 61124f6551
12 changed files with 114 additions and 18 deletions

View File

@ -88,7 +88,7 @@ libdesmume_a_SOURCES = \
utils/tinyxml/tinyxml.h \
utils/tinyxml/tinyxmlerror.cpp \
utils/tinyxml/tinyxmlparser.cpp \
addons/slot2_mpcf.cpp addons/slot2_paddle.cpp addons/slot2_gbagame.cpp addons/slot2_none.cpp addons/slot2_rumblepak.cpp addons/slot2_guitarGrip.cpp addons/slot2_expMemory.cpp addons/slot2_piano.cpp addons/slot2_passme.cpp addons/slot1_none.cpp addons/slot1_r4.cpp addons/slot1_retail_nand.cpp addons/slot1_retail_auto.cpp addons/slot1_retail_mcrom.cpp addons/slot1_retail_mcrom_debug.cpp addons/slot1comp_mc.cpp addons/slot1comp_mc.h addons/slot1comp_rom.h addons/slot1comp_rom.cpp addons/slot1comp_protocol.h addons/slot1comp_protocol.cpp \
addons/slot2_auto.cpp addons/slot2_mpcf.cpp addons/slot2_paddle.cpp addons/slot2_gbagame.cpp addons/slot2_none.cpp addons/slot2_rumblepak.cpp addons/slot2_guitarGrip.cpp addons/slot2_expMemory.cpp addons/slot2_piano.cpp addons/slot2_passme.cpp addons/slot1_none.cpp addons/slot1_r4.cpp addons/slot1_retail_nand.cpp addons/slot1_retail_auto.cpp addons/slot1_retail_mcrom.cpp addons/slot1_retail_mcrom_debug.cpp addons/slot1comp_mc.cpp addons/slot1comp_mc.h addons/slot1comp_rom.h addons/slot1comp_rom.cpp addons/slot1comp_protocol.h addons/slot1comp_protocol.cpp \
cheatSystem.cpp cheatSystem.h \
texcache.cpp texcache.h rasterize.cpp rasterize.h \
metaspu/metaspu.cpp metaspu/metaspu.h \

View File

@ -0,0 +1,80 @@
/*
Copyright (C) 2013 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the this software. If not, see <http://www.gnu.org/licenses/>.
*/
#include "../slot2.h"
#include "../registers.h"
#include "../MMU.h"
#include "../NDSSystem.h"
class Slot2_Auto : public ISlot2Interface
{
private:
ISlot2Interface *mSelectedImplementation;
public:
Slot2_Auto()
: mSelectedImplementation(NULL)
{
}
virtual Slot2Info const* info()
{
static Slot2InfoSimple info("Auto","Slot2 (auto-selection) device emulation");
return &info;
}
virtual void connect()
{
NDS_SLOT2_TYPE selection = NDS_SLOT2_NONE;
//check game ID in core emulator and select right implementation
if ((memcmp(gameInfo.header.gameCode, "UBR", 3) == 0) // Opera Browser
)
selection = NDS_SLOT2_EXPMEMORY;
mSelectedImplementation = slot2_List[selection];
mSelectedImplementation->connect();
printf("Slot2 auto-selected device type: %s\n", mSelectedImplementation->info()->name());
}
virtual void disconnect()
{
if(mSelectedImplementation) mSelectedImplementation->disconnect();
mSelectedImplementation = NULL;
}
virtual void writeByte(u8 PROCNUM, u32 addr, u8 val) { mSelectedImplementation->writeByte(PROCNUM, addr, val); }
virtual void writeWord(u8 PROCNUM, u32 addr, u16 val) { mSelectedImplementation->writeWord(PROCNUM, addr, val); }
virtual void writeLong(u8 PROCNUM, u32 addr, u32 val) { mSelectedImplementation->writeLong(PROCNUM, addr, val); }
virtual u8 readByte(u8 PROCNUM, u32 addr) { return mSelectedImplementation->readByte(PROCNUM, addr); }
virtual u16 readWord(u8 PROCNUM, u32 addr) { return mSelectedImplementation->readWord(PROCNUM, addr); }
virtual u32 readLong(u8 PROCNUM, u32 addr) { return mSelectedImplementation->readLong(PROCNUM, addr); }
virtual void savestate(EMUFILE* os)
{
mSelectedImplementation->savestate(os);
}
virtual void loadstate(EMUFILE* is)
{
mSelectedImplementation->loadstate(is);
}
};
ISlot2Interface* construct_Slot2_Auto() { return new Slot2_Auto(); }

View File

@ -44,7 +44,7 @@ void slot2_Init()
//construct all devices
extern TISlot2InterfaceConstructor construct_Slot2_None;
//extern TISlot2InterfaceConstructor construct_Slot2_Auto;
extern TISlot2InterfaceConstructor construct_Slot2_Auto;
extern TISlot2InterfaceConstructor construct_Slot2_CFlash;
extern TISlot2InterfaceConstructor construct_Slot2_RumblePak;
extern TISlot2InterfaceConstructor construct_Slot2_GbaCart;
@ -55,7 +55,7 @@ void slot2_Init()
extern TISlot2InterfaceConstructor construct_Slot2_PassME;
slot2_List[NDS_SLOT2_NONE] = construct_Slot2_None();
//slot2_List[NDS_SLOT2_AUTO] = construct_Slot2_Auto();
slot2_List[NDS_SLOT2_AUTO] = construct_Slot2_Auto();
slot2_List[NDS_SLOT2_CFLASH] = construct_Slot2_CFlash();
slot2_List[NDS_SLOT2_RUMBLEPAK] = construct_Slot2_RumblePak();
slot2_List[NDS_SLOT2_GBACART] = construct_Slot2_GbaCart();

View File

@ -79,7 +79,7 @@ typedef ISlot2Interface* TISlot2InterfaceConstructor();
enum NDS_SLOT2_TYPE
{
NDS_SLOT2_NONE,
//NDS_SLOT2_AUTO,
NDS_SLOT2_AUTO,
NDS_SLOT2_CFLASH, // compact flash
NDS_SLOT2_RUMBLEPAK, // rumble pack
NDS_SLOT2_GBACART, // GBA cartrindge in slot

View File

@ -2131,6 +2131,10 @@
RelativePath="..\addons\slot1comp_rom.h"
>
</File>
<File
RelativePath="..\addons\slot2_auto.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>

View File

@ -1049,6 +1049,10 @@
RelativePath="..\addons\slot1comp_rom.h"
>
</File>
<File
RelativePath="..\addons\slot2_auto.cpp"
>
</File>
<File
RelativePath="..\addons\slot2_expMemory.cpp"
>

View File

@ -375,6 +375,7 @@
<ClCompile Include="..\addons\slot1_retail_auto.cpp" />
<ClCompile Include="..\addons\slot1_retail_mcrom.cpp" />
<ClCompile Include="..\addons\slot1_retail_mcrom_debug.cpp" />
<ClCompile Include="..\addons\slot2_auto.cpp" />
<ClCompile Include="..\addons\slot2_passme.cpp" />
<ClCompile Include="..\addons\slot2_piano.cpp" />
<ClCompile Include="..\addons\slot1_none.cpp" />
@ -669,7 +670,6 @@
<ClInclude Include="..\debug.h" />
<ClInclude Include="..\Disassembler.h" />
<ClInclude Include="..\driver.h" />
<ClInclude Include="..\emufat_types.h" />
<ClInclude Include="..\emufile.h" />
<ClInclude Include="..\encrypt.h" />
<ClInclude Include="..\fat.h" />
@ -870,9 +870,6 @@
<ClInclude Include="File_Extractor\unrar\unicode.hpp" />
<ClInclude Include="File_Extractor\unrar\unpack.hpp" />
<ClInclude Include="File_Extractor\unrar\unrar.h" />
<ClInclude Include="filter\hq2x.h" />
<ClInclude Include="filter\interp.h" />
<ClInclude Include="filter\lq2x.h" />
<ClInclude Include="FirmConfig.h" />
<ClInclude Include="fsnitroView.h" />
<ClInclude Include="gbaslot_config.h" />

View File

@ -804,6 +804,9 @@
<ClCompile Include="..\addons\slot2_passme.cpp">
<Filter>Core\addons</Filter>
</ClCompile>
<ClCompile Include="..\addons\slot2_auto.cpp">
<Filter>Core\addons</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\armcpu.h">
@ -920,9 +923,6 @@
<ClInclude Include="..\slot1.h">
<Filter>Core</Filter>
</ClInclude>
<ClCompile Include="..\slot2.h">
<Filter>Core</Filter>
</ClCompile>
<ClInclude Include="..\SPU.h">
<Filter>Core</Filter>
</ClInclude>
@ -1115,10 +1115,6 @@
<ClInclude Include="tileView.h">
<Filter>Windows\tools</Filter>
</ClInclude>
<ClInclude Include="filter\hq2x.h" />
<ClInclude Include="filter\interp.h" />
<ClInclude Include="filter\lq2x.h" />
<ClInclude Include="..\emufat_types.h" />
<ClInclude Include="..\utils\datetime.h">
<Filter>Core\utils</Filter>
</ClInclude>
@ -1548,6 +1544,9 @@
<ClInclude Include="fsnitroView.h">
<Filter>Windows\tools</Filter>
</ClInclude>
<ClInclude Include="..\slot2.h">
<Filter>Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\instruction_tabdef.inc">

View File

@ -386,6 +386,7 @@
<ClCompile Include="..\addons\slot1_retail_auto.cpp" />
<ClCompile Include="..\addons\slot1_retail_mcrom.cpp" />
<ClCompile Include="..\addons\slot1_retail_mcrom_debug.cpp" />
<ClCompile Include="..\addons\slot2_auto.cpp" />
<ClCompile Include="..\addons\slot2_passme.cpp" />
<ClCompile Include="..\addons\slot2_piano.cpp" />
<ClCompile Include="..\addons\slot1_none.cpp" />

View File

@ -796,6 +796,9 @@
<ClCompile Include="..\addons\slot2_passme.cpp">
<Filter>Core\addons</Filter>
</ClCompile>
<ClCompile Include="..\addons\slot2_auto.cpp">
<Filter>Core\addons</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\arm_jit.h">

View File

@ -441,6 +441,7 @@ INT_PTR CALLBACK GbaSlotPiano(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam)
}
u32 GBAslot_IDDs[NDS_SLOT2_COUNT] = {
IDD_GBASLOT_NONE,
IDD_GBASLOT_NONE,
IDD_GBASLOT_CFLASH,
IDD_GBASLOT_RUMBLEPAK,
@ -453,6 +454,7 @@ u32 GBAslot_IDDs[NDS_SLOT2_COUNT] = {
};
DLGPROC GBAslot_Procs[NDS_SLOT2_COUNT] = {
GbaSlotNone,
GbaSlotNone,
GbaSlotCFlash,
GbaSlotRumblePak,
@ -563,7 +565,12 @@ void GBAslotDialog(HWND hwnd)
needReset = true;
else
needReset = false;
break;
break;
case NDS_SLOT2_AUTO:
needReset = false;
break;
case NDS_SLOT2_CFLASH:
//save current values for win32 configuration
win32_CFlash_cfgMode = tmp_CFlashMode;

View File

@ -3159,7 +3159,7 @@ int _main()
slot1_R4_path_type = cmdline._slot1_fat_dir_type;
int slot2_device_type = (NDS_SLOT2_TYPE)GetPrivateProfileInt("Slot2", "type", NDS_SLOT1_NONE, IniName);
win32_CFlash_cfgMode = GetPrivateProfileInt("Slot2.CFlash", "fileMode", 2, IniName);
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", "");
GetPrivateProfileString("Slot2.GBAgame", "filename", "", GBAgameName, MAX_PATH, IniName);
@ -3187,7 +3187,6 @@ int _main()
else
slot1_Change((NDS_SLOT1_TYPE)slot1_device_type);
//slot2_device_type = NDS_SLOT2_GBACART; // ====================================
slot2_Init();
if(cmdline.gbaslot_rom != "")
{
@ -3199,6 +3198,8 @@ int _main()
{
case NDS_SLOT2_NONE:
break;
case NDS_SLOT2_AUTO:
break;
case NDS_SLOT2_CFLASH:
break;
case NDS_SLOT2_RUMBLEPAK: