From cd156d17b7a17447c30f7c73ecfed13ab4af366e Mon Sep 17 00:00:00 2001 From: "overjoy.psm" Date: Fri, 13 Jul 2012 13:16:13 +0000 Subject: [PATCH] WIP commit: Added support for neek2o (rev 88 and up) --- source/loader/cios.cpp | 17 +++++++++- source/loader/cios.hpp | 3 +- source/loader/wdvd.c | 14 +++++++++ source/loader/wdvd.h | 1 + source/menu/menu_game.cpp | 60 ++++++++++++++++++++++++++---------- source/menu/menu_nandemu.cpp | 19 ++++++++---- wiiflow.pnproj | 2 +- wiiflow.pnps | 2 +- 8 files changed, 91 insertions(+), 27 deletions(-) diff --git a/source/loader/cios.cpp b/source/loader/cios.cpp index 0a790d00..70891fb4 100644 --- a/source/loader/cios.cpp +++ b/source/loader/cios.cpp @@ -36,11 +36,26 @@ #define ARRAY_SIZE(a) (sizeof a / sizeof a[0]) -static u32 allowedBases[] = { 37, 38, 53, 55, 56, 57, 58 }; +static u32 allowedBases[] = { 37, 38, 53, 55, 56, 57, 58 }; +static u32 boot2version = 0; + +bool cIOSInfo::neek2o(void) +{ + if(!boot2version) + ES_GetBoot2Version(&boot2version); + + return boot2version > 4 ? true : false; +} /* Check if the cIOS is a D2X. */ bool cIOSInfo::D2X(u8 ios, u8 *base) { + if(neek2o()) + { + *base = (u8)IOS_GetVersion(); + return true; + } + iosinfo_t *info = GetInfo(ios); if(!info) return false; diff --git a/source/loader/cios.hpp b/source/loader/cios.hpp index 795aa205..42ef9f06 100644 --- a/source/loader/cios.hpp +++ b/source/loader/cios.hpp @@ -16,8 +16,9 @@ typedef struct _iosinfo_t class cIOSInfo { public: + static bool neek2o(void); static bool D2X(u8 ios, u8 *base); - static iosinfo_t *GetInfo(u8 ios); + static iosinfo_t *GetInfo(u8 ios); }; #endif \ No newline at end of file diff --git a/source/loader/wdvd.c b/source/loader/wdvd.c index faec4eb4..3cecd317 100644 --- a/source/loader/wdvd.c +++ b/source/loader/wdvd.c @@ -393,3 +393,17 @@ s32 WDVD_SetStreaming(void) return (ret == 1) ? 0 : -ret; } + +s32 WDVD_NEEK_LoadDisc(u32 id, u32 magic) +{ + u32 *vec = (u32*)memalign(32, sizeof(u32) * 2); + vec[0] = id; + vec[1] = magic; + + s32 ret = IOS_Ioctl(di_fd, 0x25, vec, sizeof(u32) * 2, NULL, 0); + + gprintf("Load disc: (%08x)(%08x)(%d)(%d)\n", id, magic, ret, di_fd); + free(vec); + + return ret; +} diff --git a/source/loader/wdvd.h b/source/loader/wdvd.h index bcf8c3fd..16028882 100644 --- a/source/loader/wdvd.h +++ b/source/loader/wdvd.h @@ -27,6 +27,7 @@ s32 WDVD_Eject(void); s32 WDVD_Read_Disc_BCA(void *); s32 WDVD_SetFragList(int device, void *fraglist, int size); s32 WDVD_SetStreaming(void); +s32 WDVD_NEEK_LoadDisc(u32 id, u32 magic); #ifdef __cplusplus } diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 2ae1fd0e..2121aa6e 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -25,6 +25,7 @@ #include "loader/frag.h" #include "loader/fst.h" +#include "cios.hpp" #include "gui/WiiMovie.hpp" #include "gui/GameTDB.hpp" @@ -58,6 +59,7 @@ extern const u8 gc_ogg[]; extern const u32 gc_ogg_size; extern u32 sector_size; +extern u32 boot2version; extern int mainIOS; static u64 sm_title_id[8] ATTRIBUTE_ALIGN(32); @@ -897,6 +899,17 @@ void CMenu::_launchHomebrew(const char *filepath, vector arguments) int CMenu::_loadIOS(u8 gameIOS, int userIOS, string id) { gprintf("Game ID# %s requested IOS %d. User selected %d\n", id.c_str(), gameIOS, userIOS); + if(cIOSInfo::neek2o()) + { + if(!loadIOS(gameIOS, true)) + { + _reload_wifi_gecko(); + error(sfmt("errgame4", L"Couldn't load IOS %i", gameIOS)); + return LOAD_IOS_FAILED; + } + return LOAD_IOS_SUCCEEDED; + } + if(userIOS) { for(CIOSItr itr = _installed_cios.begin(); itr != _installed_cios.end(); itr++) @@ -982,7 +995,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) } } - forwarder = m_gcfg2.getBool(id, "custom", forwarder) || strncmp(id.c_str(), "WIMC", 4) == 0; + forwarder = m_gcfg2.getBool(id, "custom", forwarder) || strncmp(id.c_str(), "WIMC", 4) == 0 || cIOSInfo::neek2o(); bool vipatch = m_gcfg2.testOptBool(id, "vipatch", m_cfg.getBool("GENERAL", "vipatch", false)); bool cheat = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool("NAND", "cheat", false)); @@ -1031,7 +1044,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) m_cat.save(true); m_cfg.save(true); cleanup(); - + if(!forwarder) { if(!emu_disabled) @@ -1062,7 +1075,7 @@ void CMenu::_launchChannel(dir_discHdr *hdr) gprintf("Return to channel %s %s. Using new d2x way\n", rtrn, IOS_Ioctlv(ESHandle, 0xA1, 1, 0, vector) != -101 ? "Succeeded" : "Failed!" ); IOS_Close(ESHandle); } - if(!emu_disabled) + if(!emu_disabled && !cIOSInfo::neek2o()) { Nand::Instance()->Init(emuPath.c_str(), emuPartition, false); DeviceHandler::Instance()->UnMount(emuPartition); @@ -1108,22 +1121,34 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) Nand::Instance()->Disable_Emu(); + if(cIOSInfo::neek2o()) + { + int discID = id.c_str()[0] << 24 | id.c_str()[1] << 16 | id.c_str()[2] << 8 | id.c_str()[3]; + WDVD_NEEK_LoadDisc((discID&0xFFFFFFFF), 0x5D1C9EA3); + dvd = true; + sleep(1); + } + if(dvd) { u32 cover = 0; - Disc_SetUSB(NULL); - if (WDVD_GetCoverStatus(&cover) < 0) + + if(!cIOSInfo::neek2o()) { - error(_t("errgame7", L"WDVDGetCoverStatus Failed!")); - if (BTN_B_PRESSED) return; - } - if (!(cover & 0x2)) - { - error(_t("errgame8", L"Please insert a game disc.")); - do { - WDVD_GetCoverStatus(&cover); + Disc_SetUSB(NULL); + if (WDVD_GetCoverStatus(&cover) < 0) + { + error(_t("errgame7", L"WDVDGetCoverStatus Failed!")); if (BTN_B_PRESSED) return; - } while(!(cover & 0x2)); + } + if (!(cover & 0x2)) + { + error(_t("errgame8", L"Please insert a game disc.")); + do { + WDVD_GetCoverStatus(&cover); + if (BTN_B_PRESSED) return; + } while(!(cover & 0x2)); + } } /* Open Disc */ if (Disc_Open(true) < 0) @@ -1276,7 +1301,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) app_gameconfig_load((u8 *) &id, gameconfig.get(), gameconfigSize); ocarina_load_code(cheatFile.get(), cheatSize); u8 gameIOS = 0; - if(!dvd) + if(!dvd || cIOSInfo::neek2o()) gameIOS = GetRequestedGameIOS(hdr); m_gcfg1.save(true); @@ -1288,7 +1313,7 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) bool iosLoaded = false; - if(!dvd) + if(!dvd || cIOSInfo::neek2o()) { int result = _loadIOS(gameIOS, userIOS, id); if(result == LOAD_IOS_FAILED) @@ -1315,7 +1340,8 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) } } IOSReloadBlock(IOS_GetVersion(), true); - if(emulate_mode) + + if(emulate_mode && !cIOSInfo::neek2o()) { Nand::Instance()->Init(emuPath.c_str(), emuPartition, false); DeviceHandler::Instance()->UnMount(emuPartition); diff --git a/source/menu/menu_nandemu.cpp b/source/menu/menu_nandemu.cpp index c6a1b9b2..d005888f 100644 --- a/source/menu/menu_nandemu.cpp +++ b/source/menu/menu_nandemu.cpp @@ -199,15 +199,22 @@ void CMenu::_enableNandEmu(bool fromconfig) _cfNeedsUpdate(); bool disable = m_cfg.getBool("NAND", "disable", true) && m_current_view == COVERFLOW_CHANNEL && !m_tempView; - if(!disable) + if(!disable || cIOSInfo::neek2o()) { - Nand::Instance()->Disable_Emu(); bool isD2XnewerThanV6 = false; - iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS); - if (iosInfo->version > 6) + if(!cIOSInfo::neek2o()) + { + Nand::Instance()->Disable_Emu(); + iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS); + if (iosInfo->version > 6) + isD2XnewerThanV6 = true; + if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !m_tempView) + Nand::Instance()->Enable_Emu(); + } + else + { isD2XnewerThanV6 = true; - if(m_current_view == COVERFLOW_CHANNEL && !m_cfg.getBool("NAND", "disable", true) && !m_tempView) - Nand::Instance()->Enable_Emu(); + } u8 limiter = 0; s8 direction = m_btnMgr.selected(m_configBtnPartitionP) ? 1 : -1; if (!fromconfig) diff --git a/wiiflow.pnproj b/wiiflow.pnproj index 866c29bc..9ecf4cdb 100644 --- a/wiiflow.pnproj +++ b/wiiflow.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wiiflow.pnps b/wiiflow.pnps index 48e588b5..d751e99c 100644 --- a/wiiflow.pnps +++ b/wiiflow.pnps @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file