diff --git a/source/gc/gc.c b/source/gc/gc.c index 243a4229..5f3a52cb 100644 --- a/source/gc/gc.c +++ b/source/gc/gc.c @@ -17,7 +17,7 @@ // DIOS-MIOS DML_CFG *DMLCfg = NULL; -void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, bool force) +void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting) { gprintf("Wiiflow DML: Launch game '%s' through memory (new method)\n", GamePath); @@ -28,10 +28,12 @@ void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPat DMLCfg->Magicbytes = 0xD1050CF6; DMLCfg->CfgVersion = 0x00000001; - if(force) - DMLCfg->VideoMode |= DML_VID_FORCE; - else + if(videoSetting == 0) + DMLCfg->VideoMode |= DML_VID_NONE; + else if(videoSetting == 1) DMLCfg->VideoMode |= DML_VID_DML_AUTO; + else + DMLCfg->VideoMode |= DML_VID_FORCE; DMLCfg->Config |= DML_CFG_ACTIVITY_LED; //Sorry but I like it lol, option will may follow DMLCfg->Config |= DML_CFG_PADHOOK; //Makes life easier, l+z+b+digital down... @@ -126,6 +128,20 @@ void DML_New_WriteOptions() // Devolution static gconfig *DEVO_CONFIG = (gconfig*)0x80000020; +bool DEVO_Installed(const char* path) +{ + bool devo = false; + char loader_path[256]; + snprintf(loader_path, sizeof(loader_path), "%s/loader.bin", path); + FILE *f = fopen(loader_path, "rb"); + if(f) + { + devo = true; + fclose(f); + } + return devo; +} + void DEVO_SetOptions(const char *path, const char *partition) { struct stat st; @@ -188,6 +204,26 @@ void DEVO_SetOptions(const char *path, const char *partition) DCFlushRange(lowmem, 64); } +u8 *loader_bin = NULL; +#define LAUNCH() ((void(*)(void))loader_bin)() + +void DEVO_Boot(const char* path) +{ + char loader_path[256]; + snprintf(loader_path, sizeof(loader_path), "%s/loader.bin", path); + FILE *f = fopen(loader_path, "rb"); + if(f) + { + fseek(f, 0, SEEK_END); + u32 size = ftell(f); + rewind(f); + loader_bin = (u8*)MEM2_alloc(size); + fread(loader_bin, 1, size, f); + puts((const char*)loader_bin + 4); + LAUNCH(); + } +} + // General #define SRAM_ENGLISH 0 @@ -201,7 +237,7 @@ syssram* __SYS_LockSram(); u32 __SYS_UnlockSram(u32 write); u32 __SYS_SyncSram(void); -void GC_SetVideoMode(u8 videomode, bool force) +void GC_SetVideoMode(u8 videomode, u8 videoSetting) { syssram *sram; sram = __SYS_LockSram(); @@ -227,32 +263,32 @@ void GC_SetVideoMode(u8 videomode, bool force) if(videomode == 1) { - if(DMLCfg != NULL && force) + if(DMLCfg != NULL && videoSetting == 2) DMLCfg->VideoMode |= DML_VID_FORCE_PAL50; rmode = &TVPal528IntDf; } else if(videomode == 2) { - if(DMLCfg != NULL && force) + if(DMLCfg != NULL && videoSetting == 2) DMLCfg->VideoMode |= DML_VID_FORCE_NTSC; rmode = &TVNtsc480IntDf; } else if(videomode == 3) { - if(DMLCfg != NULL && force) + if(DMLCfg != NULL && videoSetting == 2) DMLCfg->VideoMode |= DML_VID_FORCE_PAL60; rmode = &TVEurgb60Hz480IntDf; memflag = 5; } else if(videomode == 4 ||videomode == 6) { - if(DMLCfg != NULL && force) + if(DMLCfg != NULL && videoSetting == 2) DMLCfg->VideoMode |= DML_VID_FORCE_PROG; rmode = &TVNtsc480Prog; } else if(videomode == 5 || videomode == 7) { - if(DMLCfg != NULL && force) + if(DMLCfg != NULL && videoSetting == 2) DMLCfg->VideoMode |= DML_VID_FORCE_PROG; rmode = &TVNtsc480Prog; memflag = 5; diff --git a/source/gc/gc.h b/source/gc/gc.h index 814fad0f..dd520a31 100644 --- a/source/gc/gc.h +++ b/source/gc/gc.h @@ -46,7 +46,7 @@ enum dmlvideomode DML_VID_PROG_PATCH = (1<<4), }; -void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, bool force); +void DML_New_SetOptions(const char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode, u8 videoSetting); void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats); void DML_New_SetBootDiscOption(); void DML_New_WriteOptions(); @@ -63,11 +63,13 @@ typedef struct global_config u32 disc2_cluster; } gconfig; +bool DEVO_Installed(const char* path); void DEVO_SetOptions(const char* path, const char *partition); +void DEVO_Boot(const char* path); // General -void GC_SetVideoMode(u8 videomode, bool force); +void GC_SetVideoMode(u8 videomode, u8 videoSetting); void GC_SetLanguage(u8 lang); int GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir); diff --git a/source/main.cpp b/source/main.cpp index 60c2271b..fc3340c9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -63,8 +63,6 @@ int main(int argc, char **argv) else if (argv[i] != NULL && strcasestr(argv[i], "EMULATOR_MAGIC") != NULL) Emulator_boot = true; } - Close_Inputs(); - // Load Custom IOS gprintf("Loading cIOS: %d\n", mainIOS); bool iosOK = loadIOS(mainIOS, false); diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 3a859a32..1c357170 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -23,6 +23,7 @@ #include "cios.hpp" #include "loader/playlog.h" #include "gc/fileOps.h" +#include "gc/gc.h" #include "Gekko.h" #include "GameTDB.hpp" #include "BannerWindow.hpp" @@ -267,6 +268,7 @@ void CMenu::init(void) } else m_show_dml = MIOSisDML(); + m_new_dml = m_cfg.getBool("DML", "dml_r52+", true); m_DMLgameDir = sfmt("%%s:/%s", m_cfg.getString("DML", "dir_usb_games", "games").c_str()); @@ -367,6 +369,7 @@ void CMenu::init(void) m_theme.load(fmt("%s.ini", m_themeDataDir.c_str())); m_plugin.init(m_pluginsDir); + m_devo_installed = DEVO_Installed(m_dataDir.c_str()); u8 defaultMenuLanguage = 7; //English switch (CONF_GetLanguage()) { @@ -427,7 +430,7 @@ void CMenu::init(void) m_vid.wide(), pShadowColor, pShadowX, pShadowY, pShadowBlur, chan); WPAD_SetVRes(chan, m_vid.width() + m_cursor[chan].width(), m_vid.height() + m_cursor[chan].height()); } - + m_btnMgr.init(m_vid); m_music->Init(m_cfg, m_musicDir, sfmt("%s/music", m_themeDataDir.c_str())); diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index 76394de3..4999f0f8 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -177,6 +177,7 @@ private: u16 m_mainLblInit; u16 m_mainLblUser[6]; u8 m_show_dml; + bool m_devo_installed; bool m_new_dml; bool m_GameTDBLoaded; //Main Config menus diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index ddc04472..2a2a3874 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -532,7 +532,7 @@ void CMenu::_game(bool launch) { _hideGame(); dir_discHdr *hdr = m_cf.getHdr(); - if(currentPartition != SD && hdr->type == TYPE_GC_GAME && m_show_dml != 1) + if(currentPartition != SD && hdr->type == TYPE_GC_GAME && (m_show_dml != 1 || !m_devo_installed)) { bool foundOnSD = false; CList tmplist; @@ -788,20 +788,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) if(has_enabled_providers() && _initNetwork() == 0) add_game_to_card(id.c_str()); - bool devo = false; - u8 *loader_bin = NULL; - FILE *f = fopen(fmt("%s/loader.bin", m_dataDir.c_str()), "rb"); - if(f) - { - devo = true; - fseek(f, 0, SEEK_END); - u32 size = ftell(f); - rewind(f); - loader_bin = (u8*)MEM2_alloc(size); - fread(loader_bin, 1, size, f); - puts((const char*)loader_bin + 4); - fclose(f); - } + u8 videoSetting = min(m_cfg.getInt("DML", "video_setting", 1), 2); u8 GClanguage = min((u32)m_gcfg2.getInt(id, "gc_language", 0), ARRAY_SIZE(CMenu::_GClanguages) - 1u); GClanguage = (GClanguage == 0) ? min((u32)m_cfg.getInt("DML", "game_language", 0), ARRAY_SIZE(CMenu::_GlobalGClanguages) - 1u) : GClanguage-1; @@ -813,7 +800,9 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) else if((id[3] != 'P') && (DMLvideoMode == 0)) DMLvideoMode = 2; - if(DML) + if(m_devo_installed && strcasestr(path.c_str(), "boot.bin") == NULL) + DEVO_SetOptions(path.c_str(), DeviceName[currentPartition]); + else if(DML) { m_cfg.setString("DML", "current_item", id); @@ -839,13 +828,9 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) newPath.erase(newPath.end() - 12, newPath.end()); } else - { newPath = &path[path.find_first_of(":/")+1]; - if(devo) - DEVO_SetOptions(path.c_str(), DeviceName[currentPartition]); - } if(m_new_dml) - DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath, cheats, DML_debug, NMM, nodisc, DMLvideoMode, false); + DML_New_SetOptions(newPath.c_str(), CheatPath, NewCheatPath, cheats, DML_debug, NMM, nodisc, DMLvideoMode, videoSetting); else DML_Old_SetOptions((char*)path.c_str(), CheatPath, NewCheatPath, cheats); @@ -868,9 +853,9 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) USBStorage_Deinit(); SDHC_Init(); - GC_SetVideoMode(DMLvideoMode, false); + GC_SetVideoMode(DMLvideoMode, videoSetting); GC_SetLanguage(GClanguage); - if(!devo) + if(!m_devo_installed || strcasestr(path.c_str(), "boot.bin") != NULL) { DML_New_WriteOptions(); WII_Initialize(); @@ -878,10 +863,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) Sys_LoadMenu(); } else - { - #define LAUNCH() ((void(*)(void))loader_bin)() - LAUNCH(); - } + DEVO_Boot(m_dataDir.c_str()); } void CMenu::_launchHomebrew(const char *filepath, vector arguments) diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 35c96bb0..78e8a658 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -122,7 +122,7 @@ void CMenu::_showMain(void) m_btnMgr.show(m_mainBtnUsb); break; default: - if(m_show_dml) + if(m_show_dml || m_devo_installed) m_btnMgr.show(m_mainBtnDML); else if (show_channel) m_btnMgr.show(m_mainBtnChannel); @@ -326,7 +326,7 @@ int CMenu::main(void) u32 lastView = m_current_view; if(BTN_UP_PRESSED) m_current_view = COVERFLOW_USB; - else if(BTN_DOWN_PRESSED && m_show_dml) + else if(BTN_DOWN_PRESSED && (m_show_dml ||m_devo_installed)) m_current_view = COVERFLOW_DML; else if(BTN_LEFT_PRESSED && show_emu) m_current_view = COVERFLOW_EMU; @@ -360,7 +360,7 @@ int CMenu::main(void) else if(m_btnMgr.selected(m_mainBtnChannel) || m_btnMgr.selected(m_mainBtnUsb) || m_btnMgr.selected(m_mainBtnDML) || m_btnMgr.selected(m_mainBtnHomebrew) || m_btnMgr.selected(m_mainBtnEmu)) { if(m_current_view == COVERFLOW_USB) - m_current_view = m_show_dml ? COVERFLOW_DML : (show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_EMU : ((show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB))); + m_current_view = (m_show_dml || m_devo_installed) ? COVERFLOW_DML : (show_channel ? COVERFLOW_CHANNEL : (show_emu ? COVERFLOW_EMU : ((show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB))); else if(m_current_view == COVERFLOW_DML) m_current_view = show_channel ? COVERFLOW_CHANNEL : ((show_emu ? COVERFLOW_EMU : (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_USB)); else if(m_current_view == COVERFLOW_CHANNEL) @@ -782,7 +782,7 @@ int CMenu::main(void) m_btnMgr.show(m_mainBtnUsb); break; default: - if(m_show_dml) + if(m_show_dml || m_devo_installed) m_btnMgr.show(m_mainBtnDML); else if(show_channel) m_btnMgr.show(m_mainBtnChannel); diff --git a/source/menu/menu_startup.cpp b/source/menu/menu_startup.cpp index a9338b1f..d3d9f4cb 100644 --- a/source/menu/menu_startup.cpp +++ b/source/menu/menu_startup.cpp @@ -211,7 +211,7 @@ bool CMenu::_Source() } if(m_btnMgr.selected(m_sourceBtnDML)) { - if (!m_show_dml) _showSourceNotice(); + if (!m_show_dml && !m_devo_installed) _showSourceNotice(); else { m_current_view = COVERFLOW_DML; @@ -258,7 +258,7 @@ bool CMenu::_Source() } if (source == "dml") { - if (!m_show_dml) _showSourceNotice(); + if (!m_show_dml && !m_devo_installed) _showSourceNotice(); else { m_current_view = COVERFLOW_DML;