diff --git a/desmume/src/Makefile.am b/desmume/src/Makefile.am index 3d59a86eb..13d795704 100644 --- a/desmume/src/Makefile.am +++ b/desmume/src/Makefile.am @@ -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 \ diff --git a/desmume/src/addons/slot2_auto.cpp b/desmume/src/addons/slot2_auto.cpp new file mode 100644 index 000000000..7bfac1b3e --- /dev/null +++ b/desmume/src/addons/slot2_auto.cpp @@ -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 . +*/ + +#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(); } diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp index 280b476e4..60a5c84d2 100644 --- a/desmume/src/slot2.cpp +++ b/desmume/src/slot2.cpp @@ -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(); diff --git a/desmume/src/slot2.h b/desmume/src/slot2.h index 83bb5266f..1acc15e67 100644 --- a/desmume/src/slot2.h +++ b/desmume/src/slot2.h @@ -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 diff --git a/desmume/src/windows/DeSmuME_2005.vcproj b/desmume/src/windows/DeSmuME_2005.vcproj index 964fe0d25..3ec1fa177 100644 --- a/desmume/src/windows/DeSmuME_2005.vcproj +++ b/desmume/src/windows/DeSmuME_2005.vcproj @@ -2131,6 +2131,10 @@ RelativePath="..\addons\slot1comp_rom.h" > + + diff --git a/desmume/src/windows/DeSmuME_2008.vcproj b/desmume/src/windows/DeSmuME_2008.vcproj index e619b5f37..c3dfbfe76 100644 --- a/desmume/src/windows/DeSmuME_2008.vcproj +++ b/desmume/src/windows/DeSmuME_2008.vcproj @@ -1049,6 +1049,10 @@ RelativePath="..\addons\slot1comp_rom.h" > + + diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj b/desmume/src/windows/DeSmuME_2010.vcxproj index 2613d6197..f38de73dd 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj +++ b/desmume/src/windows/DeSmuME_2010.vcxproj @@ -375,6 +375,7 @@ + @@ -669,7 +670,6 @@ - @@ -870,9 +870,6 @@ - - - diff --git a/desmume/src/windows/DeSmuME_2010.vcxproj.filters b/desmume/src/windows/DeSmuME_2010.vcxproj.filters index 82599ac87..f4896037f 100644 --- a/desmume/src/windows/DeSmuME_2010.vcxproj.filters +++ b/desmume/src/windows/DeSmuME_2010.vcxproj.filters @@ -804,6 +804,9 @@ Core\addons + + Core\addons + @@ -920,9 +923,6 @@ Core - - Core - Core @@ -1115,10 +1115,6 @@ Windows\tools - - - - Core\utils @@ -1548,6 +1544,9 @@ Windows\tools + + Core + diff --git a/desmume/src/windows/DeSmuME_2012.vcxproj b/desmume/src/windows/DeSmuME_2012.vcxproj index 70584ab28..cde094148 100644 --- a/desmume/src/windows/DeSmuME_2012.vcxproj +++ b/desmume/src/windows/DeSmuME_2012.vcxproj @@ -386,6 +386,7 @@ + diff --git a/desmume/src/windows/DeSmuME_2012.vcxproj.filters b/desmume/src/windows/DeSmuME_2012.vcxproj.filters index bb1027f78..e4409e912 100644 --- a/desmume/src/windows/DeSmuME_2012.vcxproj.filters +++ b/desmume/src/windows/DeSmuME_2012.vcxproj.filters @@ -796,6 +796,9 @@ Core\addons + + Core\addons + diff --git a/desmume/src/windows/gbaslot_config.cpp b/desmume/src/windows/gbaslot_config.cpp index 6f2cc8481..325088eb1 100644 --- a/desmume/src/windows/gbaslot_config.cpp +++ b/desmume/src/windows/gbaslot_config.cpp @@ -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; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index b5cdb10fe..37dd9cb8c 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -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: