diff --git a/desmume/src/cli/main.cpp b/desmume/src/cli/main.cpp index e923831df..e9841eeb3 100644 --- a/desmume/src/cli/main.cpp +++ b/desmume/src/cli/main.cpp @@ -56,7 +56,7 @@ #include "GPU_osd.h" #include "desmume_config.h" #include "commandline.h" -#include "addons.h" +#include "slot2.h" #ifdef GDB_STUB #include "gdbstub.h" #endif @@ -539,28 +539,52 @@ int main(int argc, char ** argv) { fw_config.language = my_config.firmware_language; } - /* addons */ - my_config.process_addonCommands(); - addon_type = NDS_ADDON_NONE; - if (my_config.is_cflash_configured) - addon_type = NDS_ADDON_CFLASH; + my_config.process_addonCommands(); - if(my_config.gbaslot_rom != "") { - addon_type = NDS_ADDON_GBAGAME; - strncpy(GBAgameName, my_config.gbaslot_rom.c_str(), MAX_PATH); - } + int slot2_device_type = NDS_SLOT2_AUTO; - switch (addon_type) { - case NDS_ADDON_CFLASH: - case NDS_ADDON_RUMBLEPAK: - case NDS_ADDON_NONE: - case NDS_ADDON_GBAGAME: - break; - default: - addon_type = NDS_ADDON_NONE; - break; - } - addonsChangePak (addon_type); + if (my_config.is_cflash_configured) + slot2_device_type = NDS_SLOT2_CFLASH; + + if(my_config.gbaslot_rom != "") { + strncpy(GBAgameName, my_config.gbaslot_rom.c_str(), MAX_PATH); + // Check if the file exists and can be opened + FILE * test = fopen(GBAgameName, "rb"); + if (test) { + slot2_device_type = NDS_SLOT2_GBACART; + fclose(test); + } + } + + switch (slot2_device_type) + { + case NDS_SLOT2_NONE: + break; + case NDS_SLOT2_AUTO: + break; + case NDS_SLOT2_CFLASH: + break; + case NDS_SLOT2_RUMBLEPAK: + break; + case NDS_SLOT2_GBACART: + break; + case NDS_SLOT2_GUITARGRIP: + break; + case NDS_SLOT2_EXPMEMORY: + break; + case NDS_SLOT2_EASYPIANO: + break; + case NDS_SLOT2_PADDLE: + break; + case NDS_SLOT2_PASSME: + break; + default: + slot2_device_type = NDS_SLOT2_NONE; + break; + } + + slot2_Init(); + slot2_Change((NDS_SLOT2_TYPE)slot2_device_type); if ( !g_thread_supported()) { g_thread_init( NULL); diff --git a/desmume/src/gtk/main.cpp b/desmume/src/gtk/main.cpp index d82860c24..5767574b0 100644 --- a/desmume/src/gtk/main.cpp +++ b/desmume/src/gtk/main.cpp @@ -51,7 +51,7 @@ #include "commandline.h" -#include "addons.h" +#include "slot2.h" #include "filter/videofilter.h" @@ -2159,28 +2159,54 @@ common_gtk_main( class configured_features *my_config) fw_config.language = my_config->firmware_language; } + //------------------addons---------- my_config->process_addonCommands(); - addon_type = NDS_ADDON_NONE; + + int slot2_device_type = NDS_SLOT2_AUTO; + if (my_config->is_cflash_configured) - addon_type = NDS_ADDON_CFLASH; + slot2_device_type = NDS_SLOT2_CFLASH; if(my_config->gbaslot_rom != "") { - addon_type = NDS_ADDON_GBAGAME; strncpy(GBAgameName, my_config->gbaslot_rom.c_str(), MAX_PATH); + // Check if the file exists and can be opened + FILE * test = fopen(GBAgameName, "rb"); + if (test) { + slot2_device_type = NDS_SLOT2_GBACART; + fclose(test); + } } - switch (addon_type) { - case NDS_ADDON_CFLASH: - case NDS_ADDON_RUMBLEPAK: - case NDS_ADDON_NONE: - case NDS_ADDON_GBAGAME: - break; - default: - addon_type = NDS_ADDON_NONE; - break; - } - addonsChangePak (addon_type); + switch (slot2_device_type) + { + case NDS_SLOT2_NONE: + break; + case NDS_SLOT2_AUTO: + break; + case NDS_SLOT2_CFLASH: + break; + case NDS_SLOT2_RUMBLEPAK: + break; + case NDS_SLOT2_GBACART: + break; + case NDS_SLOT2_GUITARGRIP: + break; + case NDS_SLOT2_EXPMEMORY: + break; + case NDS_SLOT2_EASYPIANO: + break; + case NDS_SLOT2_PADDLE: + break; + case NDS_SLOT2_PASSME: + break; + default: + slot2_device_type = NDS_SLOT2_NONE; + break; + } + + slot2_Init(); + slot2_Change((NDS_SLOT2_TYPE)slot2_device_type); #ifdef GDB_STUB if ( my_config->arm9_gdb_port != 0) { diff --git a/desmume/src/slot2.cpp b/desmume/src/slot2.cpp index 45c423bfd..7f4206c5c 100644 --- a/desmume/src/slot2.cpp +++ b/desmume/src/slot2.cpp @@ -15,9 +15,9 @@ along with the this software. If not, see . */ #include "slot2.h" -#include "../types.h" -#include "../mem.h" -#include "../MMU.h" +#include "types.h" +#include "mem.h" +#include "MMU.h" //this is the currently-configured cflash mode ADDON_CFLASH_MODE CFlash_Mode = ADDON_CFLASH_MODE_RomPath;