From c3c02ac862bf6e4e0c0df734c19a43af58cf6af7 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Tue, 17 Jul 2012 11:30:08 +0000 Subject: [PATCH] -shutdown IOS subsystems as we do in wii games and channels also if we boot homebrew and devolution -fixed stupid bug which may made a problem with devolution (thanks stfour for finding it) -dont init mload on waninkokos cIOS which is older than r18 --- source/gc/gc.c | 17 +++++++++++------ source/gc/gc.h | 2 +- source/homebrew/homebrew.cpp | 6 +++++- source/loader/alt_ios.cpp | 10 ++++++++-- source/menu/menu_game.cpp | 2 +- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/source/gc/gc.c b/source/gc/gc.c index 1916e5a1..95a99a9e 100644 --- a/source/gc/gc.c +++ b/source/gc/gc.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "gc.h" #include "gecko.h" #include "fileOps.h" @@ -127,6 +128,7 @@ void DML_New_WriteOptions() // Devolution u8 *loader_bin = NULL; +extern void __exception_closeall(); static gconfig *DEVO_CONFIG = (gconfig*)0x80000020; #define DEVO_Entry() ((void(*)(void))loader_bin)() @@ -144,7 +146,7 @@ bool DEVO_Installed(const char* path) return devo; } -void DEVO_SetOptions(const char *path, const char *partition, const char* loader, bool memcard_emu) +void DEVO_SetOptions(const char *path, const char *partition, const char* loader, const char *gameID, bool memcard_emu) { //Read in loader.bin char loader_path[256]; @@ -162,14 +164,10 @@ void DEVO_SetOptions(const char *path, const char *partition, const char* loader //start writing cfg to mem struct stat st; - char full_path[256]; int data_fd; - char gameID[7]; stat(path, &st); FILE *iso_file = fopen(path, "rb"); - fread(&gameID, 1, 6, iso_file); - fseek(f, 0, SEEK_SET); fread((u8*)0x80000000, 1, 32, iso_file); fclose(iso_file); @@ -181,6 +179,7 @@ void DEVO_SetOptions(const char *path, const char *partition, const char* loader DEVO_CONFIG->disc1_cluster = st.st_ino; // make sure these directories exist, they are required for Devolution to function correctly + char full_path[256]; snprintf(full_path, sizeof(full_path), "%s:/apps", partition); fsop_MakeFolder(full_path); snprintf(full_path, sizeof(full_path), "%s:/apps/gc_devo", partition); @@ -235,8 +234,14 @@ void DEVO_Boot() { // the Devolution blob has an ID string at offset 4 puts((const char*)loader_bin + 4); - gprintf("WiiFlow GC: Devolution initialized. Booting game...\n \n"); + gprintf("WiiFlow GC: Devolution initialized. Booting game...\n"); + + /* Shutdown IOS subsystems */ + u32 level = IRQ_Disable(); + __IOS_ShutdownSubsystems(); + __exception_closeall(); DEVO_Entry(); + IRQ_Restore(level); } diff --git a/source/gc/gc.h b/source/gc/gc.h index c1e20a41..8b16b9a5 100644 --- a/source/gc/gc.h +++ b/source/gc/gc.h @@ -64,7 +64,7 @@ typedef struct global_config } gconfig; bool DEVO_Installed(const char* path); -void DEVO_SetOptions(const char* path, const char *partition, const char *loader, bool memcard_emu); +void DEVO_SetOptions(const char* path, const char *partition, const char *loader, const char *gameID, bool memcard_emum); void DEVO_Boot(); diff --git a/source/homebrew/homebrew.cpp b/source/homebrew/homebrew.cpp index 86ddf945..82cbe91e 100644 --- a/source/homebrew/homebrew.cpp +++ b/source/homebrew/homebrew.cpp @@ -152,7 +152,11 @@ int BootHomebrew(u64 chan_title) memmove(ARGS_ADDR, &args, sizeof(args)); DCFlushRange(ARGS_ADDR, sizeof(args) + args.length); - SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); + /* Shutdown IOS subsystems */ + u32 level = IRQ_Disable(); + __IOS_ShutdownSubsystems(); + __exception_closeall(); entry(); + IRQ_Restore(level); return 0; } diff --git a/source/loader/alt_ios.cpp b/source/loader/alt_ios.cpp index d884ba9f..6345906a 100644 --- a/source/loader/alt_ios.cpp +++ b/source/loader/alt_ios.cpp @@ -93,11 +93,17 @@ bool loadIOS(int ios, bool launch_game) bool iosOK = IOS_ReloadIOS(ios) == 0; ISFS_Initialize(); - gprintf("%s, Current IOS: %i Base: %i\n", iosOK ? "OK" : "FAILED!", IOS_GetVersion(), get_ios_base()); + gprintf("%s, Current IOS: %i\n", iosOK ? "OK" : "FAILED!", IOS_GetVersion()); if(is_ios_type(IOS_TYPE_HERMES, IOS_GetVersion())) + { load_ehc_module_ex(); - else if(is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion())) + gprintf("Hermes cIOS Base IOS%i\n", get_ios_base()); + } + else if(is_ios_type(IOS_TYPE_WANIN, IOS_GetVersion()) && IOS_GetRevision() >= 18) + { load_dip_249(); + gprintf("Waninkoko cIOS Base IOS%i\n", get_ios_base()); + } if(launch_game) { diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index d9405a22..a8e64dbb 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -861,7 +861,7 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) { loader = 2; bool memcard_emu = m_gcfg2.getBool(id, "devo_memcard_emu", false); - DEVO_SetOptions(path.c_str(), DeviceName[currentPartition], m_dataDir.c_str(), memcard_emu); + DEVO_SetOptions(path.c_str(), DeviceName[currentPartition], m_dataDir.c_str(), id.c_str(), memcard_emu); } m_gcfg1.save(true);