From 9472bd3d59f5366e8f39df5f2017473db12e29d8 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Tue, 6 Mar 2012 21:04:23 +0000 Subject: [PATCH] -added possibility to use another folder for gamecube games on usb, its a new config entry in DML section, dir_usb_games, default is the "games" folder. If you want for example "ngc", change the value to "%s:/ngc". (issue 19) --- source/gc/gc.c | 7 +++---- source/gc/gc.h | 2 +- source/loader/gc_disc.cpp | 5 ++++- source/loader/gc_disc.hpp | 4 +++- source/menu/menu.cpp | 9 ++++++--- source/menu/menu.hpp | 3 ++- source/menu/menu_game.cpp | 8 ++++---- source/menu/menu_wbfs.cpp | 22 +++++++++++++++------- 8 files changed, 38 insertions(+), 22 deletions(-) diff --git a/source/gc/gc.c b/source/gc/gc.c index 7db455b4..791008b8 100644 --- a/source/gc/gc.c +++ b/source/gc/gc.c @@ -6,7 +6,6 @@ #include "gecko.h" #include "fileOps.h" #include "utils.h" -#include "defines.h" #define SRAM_ENGLISH 0 #define SRAM_GERMAN 1 @@ -95,11 +94,11 @@ void set_language(u8 lang) while(!__SYS_SyncSram()); } -bool DML_GameIsInstalled(char *discid, const char* partition) +bool DML_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir) { - char folder[12]; + char folder[50]; char source[300]; - snprintf(folder, sizeof(folder), DML_DIR, partition); + snprintf(folder, sizeof(folder), dmlgamedir, partition); snprintf(source, sizeof(source), "%s/%s/game.iso", folder, discid); FILE *f = fopen(source, "r"); diff --git a/source/gc/gc.h b/source/gc/gc.h index 1764344f..3109fe5f 100644 --- a/source/gc/gc.h +++ b/source/gc/gc.h @@ -7,7 +7,7 @@ extern "C" #define GC_H_ void set_video_mode(int i); void set_language(u8 lang); -bool DML_GameIsInstalled(char *discid, const char* partition); +bool DML_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir); #endif //GC_H_ #ifdef __cplusplus diff --git a/source/loader/gc_disc.cpp b/source/loader/gc_disc.cpp index c656b2a4..4baaafac 100644 --- a/source/loader/gc_disc.cpp +++ b/source/loader/gc_disc.cpp @@ -152,7 +152,10 @@ s32 GCDump::DumpGame(progress_callback_t spinner, message_callback_t message, vo s32 ret = Disc_ReadGCHeader(&gcheader); Asciify2(gcheader.title); - snprintf(folder, sizeof(folder), DML_DIR, gamepartition); + if(strncmp(gamepartition, "sd",2) != 0) + snprintf(folder, sizeof(folder), dmlgamedir, gamepartition); + else + snprintf(folder, sizeof(folder), DML_DIR, gamepartition); if(!fsop_DirExist(folder)) makedir(folder); snprintf(folder, sizeof(folder), "%s:/games/%s [%.06s]%s", gamepartition, gcheader.title, (char *)gcheader.id, j ? "2" : ""); diff --git a/source/loader/gc_disc.hpp b/source/loader/gc_disc.hpp index bd8cea39..f3019c5d 100644 --- a/source/loader/gc_disc.hpp +++ b/source/loader/gc_disc.hpp @@ -34,7 +34,7 @@ typedef void (*message_callback_t)(int message, int info, char *cinfo, void *use class GCDump { public: - void Init(bool skip, bool comp, bool wexf, bool align, u32 nretry, u32 rsize, const char* partition) + void Init(bool skip, bool comp, bool wexf, bool align, u32 nretry, u32 rsize, const char* partition, const char* m_DMLgameDir) { skiponerror = skip; compressed = comp; @@ -43,6 +43,7 @@ public: gc_nbrretry = nretry; gc_readsize = rsize; gamepartition = partition; + dmlgamedir = m_DMLgameDir; gc_skipped = 0; } s32 DumpGame(progress_callback_t spinner, message_callback_t message, void *spinner_data); @@ -53,6 +54,7 @@ private: bool compressed; bool writeexfiles; const char* gamepartition; + const char* dmlgamedir; u8 Disc; u8 Disc2; u32 gc_nbrretry; diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 363ef02c..c93ea052 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -249,6 +249,7 @@ void CMenu::init(void) } else m_show_dml = MIOSisDML(); + m_DMLgameDir = m_cfg.getString("DML", "dir_usb_games", DML_DIR); m_cfg.getString("NAND", "path", "").c_str(); m_cfg.getInt("NAND", "partition", 0); @@ -263,7 +264,7 @@ void CMenu::init(void) m_ver = sfmt("%s/versions", m_appDir.c_str()); m_app_update_zip = sfmt("%s/update.zip", m_appDir.c_str()); m_data_update_zip = sfmt("%s/update.zip", m_dataDir.c_str()); - // + m_cacheDir = m_cfg.getString("GENERAL", "dir_cache", sfmt("%s/cache", m_dataDir.c_str())); m_settingsDir = m_cfg.getString("GENERAL", "dir_settings", sfmt("%s/settings", m_dataDir.c_str())); m_languagesDir = m_cfg.getString("GENERAL", "dir_languages", sfmt("%s/languages", m_dataDir.c_str())); @@ -278,7 +279,6 @@ void CMenu::init(void) m_cheatDir = m_cfg.getString("GENERAL", "dir_cheat", sfmt("%s/gct", m_txtCheatDir.c_str())); m_wipDir = m_cfg.getString("GENERAL", "dir_wip", sfmt("%s/wip", m_txtCheatDir.c_str())); m_listCacheDir = m_cfg.getString("GENERAL", "dir_list_cache", sfmt("%s/lists", m_cacheDir.c_str())); - // DeviceHandler::SetWatchdog(m_cfg.getUInt("GENERAL", "watchdog_timeout", 10)); @@ -1882,7 +1882,10 @@ bool CMenu::_loadDmlList() gprintf("%s\n", DeviceName[currentPartition]); DeviceHandler::Instance()->Open_WBFS(currentPartition); - m_gameList.Load(sfmt(DML_DIR, DeviceName[currentPartition]), ".iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); + if(currentPartition != SD) + m_gameList.Load(sfmt(m_DMLgameDir.c_str(), DeviceName[currentPartition]), ".iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); + else + m_gameList.Load(sfmt(DML_DIR, DeviceName[currentPartition]), ".iso", m_cfg.getString("DML", "lastlanguage", "EN").c_str()); m_cfg.setString("DML", "lastlanguage", m_loc.getString(m_curLanguage, "gametdb_code", "EN")); m_cfg.save(); return m_gameList.size() > 0 ? true : false; diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index c50aa62b..0a229dd0 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -81,7 +81,7 @@ private: std::string m_curChanId; u8 m_numCFVersions; - // + std::string m_themeDataDir; std::string m_appDir; std::string m_dataDir; @@ -101,6 +101,7 @@ private: std::string m_settingsDir; std::string m_languagesDir; std::string m_listCacheDir; + std::string m_DMLgameDir; /* Updates */ const char* m_app_update_url; const char* m_data_update_url; diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 0c9a4061..71cbd281 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -446,19 +446,19 @@ void CMenu::_game(bool launch) dir_discHdr *hdr = m_cf.getHdr(); if(currentPartition != SD && m_current_view == COVERFLOW_DML) { - char gcfolder[MAX_FAT_PATH]; + char gcfolder[300]; sprintf(gcfolder, "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id); - if (DML_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD])) + if (DML_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD], DML_DIR)) { memset(hdr->path,0,sizeof(hdr->path)); sprintf(hdr->path,"%s",(char*)hdr->hdr.id); } - else if(DML_GameIsInstalled(gcfolder, DeviceName[SD])) + else if(DML_GameIsInstalled(gcfolder, DeviceName[SD], DML_DIR)) { memset(hdr->path,0,sizeof(hdr->path)); sprintf(hdr->path,"%s",gcfolder); } - else if(!DML_GameIsInstalled(hdr->path, DeviceName[SD]) && !_wbfsOp(CMenu::WO_COPY_GAME)) + else if(!DML_GameIsInstalled(hdr->path, DeviceName[SD], DML_DIR) && !_wbfsOp(CMenu::WO_COPY_GAME)) break; currentPartition = SD; } diff --git a/source/menu/menu_wbfs.cpp b/source/menu/menu_wbfs.cpp index dbd5b80d..6e46c4d0 100644 --- a/source/menu/menu_wbfs.cpp +++ b/source/menu/menu_wbfs.cpp @@ -151,7 +151,7 @@ int CMenu::_GCgameInstaller(void *obj) u32 nretry = m.m_cfg.getUInt("DML", "num_retries", 5); u32 rsize = 1048576; //1MB - m_gcdump.Init(skip, comp, wexf, alig, nretry, rsize,DeviceName[currentPartition]); + m_gcdump.Init(skip, comp, wexf, alig, nretry, rsize,DeviceName[currentPartition],m.m_DMLgameDir.c_str()); int ret; @@ -207,10 +207,10 @@ int CMenu::_GCgameInstaller(void *obj) int CMenu::_GCcopyGame(void *obj) { CMenu &m = *(CMenu *)obj; - char folder[12]; + char folder[50]; char source[300]; char target[300]; - snprintf(folder, sizeof(folder), DML_DIR, DeviceName[currentPartition]); + snprintf(folder, sizeof(folder), m.m_DMLgameDir.c_str(), DeviceName[currentPartition]); snprintf(source, sizeof(source), "%s/%s", folder, m.m_cf.getHdr()->path); memset(folder, 0, sizeof(folder)); snprintf(folder, sizeof(folder), DML_DIR, DeviceName[SD]); @@ -338,9 +338,14 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) { Disc_ReadGCHeader(&gcheader); - char gcfolder[MAX_FAT_PATH]; + char gcfolder[300]; + char dmlgamedir[50]; + if(currentPartition != SD) + sprintf(dmlgamedir,"%s",m_DMLgameDir.c_str()); + else + sprintf(dmlgamedir,"%s",DML_DIR); sprintf(gcfolder, "%s [%s]", gcheader.title, (char *)gcheader.id); - if (_searchGamesByID((const char *) gcheader.id).size() != 0 || DML_GameIsInstalled((char *)gcheader.id, DeviceName[currentPartition]) || DML_GameIsInstalled(gcfolder, DeviceName[currentPartition])) + if (_searchGamesByID((const char *) gcheader.id).size() != 0 || DML_GameIsInstalled((char *)gcheader.id, DeviceName[currentPartition], dmlgamedir) || DML_GameIsInstalled(gcfolder, DeviceName[currentPartition], dmlgamedir)) { error(_t("wbfsoperr4", L"Game already installed")); out = true; @@ -370,9 +375,12 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op) } else { - char folder[12]; + char folder[50]; char source[300]; - snprintf(folder, sizeof(folder), DML_DIR, DeviceName[currentPartition]); + if(currentPartition != SD) + snprintf(folder, sizeof(folder), m_DMLgameDir.c_str(), DeviceName[currentPartition]); + else + snprintf(folder, sizeof(folder), DML_DIR, DeviceName[currentPartition]); snprintf(source, sizeof(source), "%s/%s", folder, m_cf.getHdr()->path); fsop_deleteFolder(source); upd_dml = true;