From 74450fba18828a2ee87bc43cce1bb33e5da6fac4 Mon Sep 17 00:00:00 2001 From: "overjoy.psm" Date: Sat, 28 Jan 2012 08:40:19 +0000 Subject: [PATCH] * Added a simpel check to find out if installed MIOS is unpatched, cMIOS or DML and it should be able to recognize most of them. * DML Coverview is now disabled if the MIOS found isn't recognized as DML * DML game subfolder naming convention may now change to 'Game Name' for example. No need to keep this as GameID anymore * Current_item config option is now saved while launching DML GC games * Playcount & Lastplayed options are now saved for DML GC games --- source/list/list.cpp | 10 ++++- source/loader/utils.h | 3 ++ source/menu/menu.cpp | 43 +++++++++++++++++++ source/menu/menu.hpp | 3 +- source/menu/menu_game.cpp | 89 +++++++++++++++++++++++++++------------ source/menu/menu_main.cpp | 24 ++++++++--- 6 files changed, 138 insertions(+), 34 deletions(-) diff --git a/source/list/list.cpp b/source/list/list.cpp index aa04836a..d97d1b62 100644 --- a/source/list/list.cpp +++ b/source/list/list.cpp @@ -132,7 +132,7 @@ void CList::GetHeaders(safe_vector pathlist, safe_vector::GetHeaders(safe_vector pathlist, safe_vector::GetHeaders(safe_vector pathlist, safe_vector arguments); - void _launchGC(const char *id, bool DML); + void _launchGC(dir_discHdr *hdr, bool DML); void _setAA(int aa); void _loadCFCfg(SThemeData &theme); void _loadCFLayout(int version, bool forceAA = false, bool otherScrnFmt = false); @@ -726,6 +726,7 @@ private: void _cleanupDefaultFont(); const char *_domainFromView(void); void UpdateCache(u32 view = COVERFLOW_MAX); + bool MIOSisDML(); SFont _font(CMenu::FontSet &fontSet, const char *domain, const char *key, u32 fontSize, u32 lineSpacing, u32 weight, u32 index, const char *genKey); STexture _texture(TexSet &texSet, const char *domain, const char *key, STexture def); safe_vector _textures(TexSet &texSet, const char *domain, const char *key); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index e1a3dad3..42345007 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -30,6 +30,8 @@ #include "defines.h" #include "gc/gc.h" +//#define DML_THROUGH_MEM /*** Load game through mem.. Not compatible with regulair DML ***/ + using namespace std; extern const u8 btngamecfg_png[]; @@ -536,65 +538,100 @@ void CMenu::_launch(dir_discHdr *hdr) switch(m_current_view) { case COVERFLOW_HOMEBREW: - _launchHomebrew((char *)hdr->path, m_homebrewArgs); + _launchHomebrew( (char *)hdr->path, m_homebrewArgs ); break; case COVERFLOW_CHANNEL: - _launchChannel(hdr); + _launchChannel( hdr ); break; case COVERFLOW_DML: - _launchGC((const char*)hdr->hdr.id,true); + _launchGC( hdr, true ); break; case COVERFLOW_USB: default: - _launchGame(hdr, false); + _launchGame( hdr, false ); break; } } extern "C" {extern void USBStorage_Deinit(void);} -void CMenu::_launchGC(const char *id, bool DML) +void CMenu::_launchGC(dir_discHdr *hdr, bool DML) { Nand::Instance()->Disable_Emu(); - u8 DMLvideoMode = min((u32)m_gcfg2.getInt(id, "dml_video_mode", 0), ARRAY_SIZE(CMenu::_DMLvideoModes) - 1u); - if (!DML) - DMLvideoMode = 0; - else + u8 DMLvideoMode = 0; + +#ifdef DML_THROUGH_MEM /*** Need special DML for this ***/ + if( DML ) { - char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); - FILE *f; - sprintf(filepath, "%s:/games/boot.bin", DeviceName[SD]); - f = fopen(filepath, "wb"); - fwrite(id, 1, 6, f); - fclose(f); + gprintf( "Wiiflow DML:Launch game 'sd:/games/%s/game.iso' through memory\n", hdr->path ); + DMLvideoMode = min((u32)m_gcfg2.getInt((char *)hdr->hdr.id, "dml_video_mode", 0), ARRAY_SIZE(CMenu::_DMLvideoModes) - 1u); + *(vu32*)0x800A0000 = 0x4e444d4c; + memcpy( (void *)0x800A0004, hdr->path, strlen( hdr->path ) +1 ); + DCFlushRange( (void *)( 0x800A0000 ), 4 ); + ICInvalidateRange( (void *)( 0x800A0000 ), 4 ); + + m_cfg.setString( "DML", "current_item", (char *)hdr->hdr.id ); + m_gcfg1.setInt( "PLAYCOUNT", (char *)hdr->hdr.id, m_gcfg1.getInt( "PLAYCOUNT", (char *)hdr->hdr.id, 0 ) + 1 ); + m_gcfg1.setUInt( "LASTPLAYED", (char *)hdr->hdr.id, time(NULL) ); + m_gcfg1.save(true); + m_cfg.save(true); Close_Inputs(); USBStorage_Deinit(); cleanup(); // Tell DML to boot the game from sd card - *(u32 *)0x80001800 = 0xB002D105; + *(vu32*)0x80001800 = 0xB002D105; DCFlushRange((void *)(0x80001800), 4); - ICInvalidateRange((void *)(0x80001800), 4); + ICInvalidateRange((void *)(0x80001800), 4); } - - memcpy((char *)0x80000000, id, 6); +#else + if( DML ) + { + gprintf( "Wiiflow DML:Launch game 'sd:/games/%s/game.iso' through boot.bin\n", hdr->path ); + DMLvideoMode = min((u32)m_gcfg2.getInt((char *)hdr->hdr.id, "dml_video_mode", 0), ARRAY_SIZE(CMenu::_DMLvideoModes) - 1u); + char filepath[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); + FILE *f; + sprintf(filepath, "%s:/games/boot.bin", DeviceName[SD]); + f = fopen(filepath, "wb"); + fwrite(hdr->path, 1, strlen( hdr->path ) +1, f); + fclose(f); + + m_cfg.setString("DML", "current_item", (char *)hdr->hdr.id); + m_gcfg1.setInt("PLAYCOUNT", (char *)hdr->hdr.id, m_gcfg1.getInt("PLAYCOUNT", string((const char *) hdr->hdr.id), 0) + 1); + m_gcfg1.setUInt("LASTPLAYED", (char *)hdr->hdr.id, time(NULL)); + m_gcfg1.save(true); + m_cfg.save(true); + + Close_Inputs(); + USBStorage_Deinit(); + cleanup(); + + // Tell DML to boot the game from sd card + *(vu32*)0x80001800 = 0xB002D105; + DCFlushRange((void *)(0x80001800), 4); + ICInvalidateRange((void *)(0x80001800), 4); + + } +#endif + - VIDEO_SetBlack(TRUE); - if (((id[3] == 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 1)) + memcpy((char *)0x80000000, (char *)hdr->hdr.id, 6); + if((((char)hdr->hdr.id[3] == 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 1)) { set_video_mode(1); } - if (((id[3] != 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 2)) + if((((char)hdr->hdr.id[3] != 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 2)) { set_video_mode(0); } + VIDEO_SetBlack(TRUE); VIDEO_Flush(); VIDEO_WaitVSync(); - *(volatile unsigned int *)0xCC003024 |= 7; + *(vu32*)0xCC003024 |= 7; - if (WII_LaunchTitle(0x0000000100000100ULL)<0) + if(WII_LaunchTitle( 0x100000100LL ) < 0 ) Sys_LoadMenu(); } @@ -1060,9 +1097,9 @@ void CMenu::_launchGame(dir_discHdr *hdr, bool dvd) Close_Inputs(); USBStorage_Deinit(); - if (gc) + if(gc) { - _launchGC(id.c_str(),false); + _launchGC( hdr, false ); } else { diff --git a/source/menu/menu_main.cpp b/source/menu/menu_main.cpp index 1cbd4756..487f4f3f 100644 --- a/source/menu/menu_main.cpp +++ b/source/menu/menu_main.cpp @@ -73,6 +73,7 @@ void CMenu::_hideMain(bool instant) static bool show_homebrew = true; static bool parental_homebrew = false; +static bool show_dml = false; void CMenu::_showMain(void) { @@ -90,13 +91,18 @@ void CMenu::_showMain(void) switch(m_current_view) { case COVERFLOW_HOMEBREW: - m_btnMgr.show(m_mainBtnDML); + if( show_dml ) + m_btnMgr.show(m_mainBtnDML); + else + m_btnMgr.show(m_mainBtnUsb); break; case COVERFLOW_CHANNEL: if(show_homebrew) m_btnMgr.show(m_mainBtnHomebrew); - else + else if( show_dml ) m_btnMgr.show(m_mainBtnDML); + else + m_btnMgr.show(m_mainBtnUsb); break; case COVERFLOW_DML: m_btnMgr.show(m_mainBtnUsb); @@ -159,6 +165,7 @@ int CMenu::main(void) bool use_grab = m_cfg.getBool("GENERAL", "use_grab", false); show_homebrew = !m_cfg.getBool("HOMEBREW", "disable", false); parental_homebrew = m_cfg.getBool("HOMEBREW", "parental", false); + show_dml = MIOSisDML(); m_reload = false; static u32 disc_check = 0; @@ -472,9 +479,9 @@ int CMenu::main(void) if (m_current_view == COVERFLOW_USB) m_current_view = COVERFLOW_CHANNEL; else if (m_current_view == COVERFLOW_CHANNEL) - m_current_view = (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : COVERFLOW_DML; + m_current_view = (show_homebrew && (parental_homebrew || !m_locked)) ? COVERFLOW_HOMEBREW : ( show_dml ? COVERFLOW_DML : COVERFLOW_USB ); else if (m_current_view == COVERFLOW_HOMEBREW) - m_current_view = COVERFLOW_DML; + m_current_view = show_dml ? COVERFLOW_DML : COVERFLOW_USB; else if (m_current_view == COVERFLOW_DML) m_current_view = COVERFLOW_USB; @@ -597,13 +604,18 @@ int CMenu::main(void) switch(m_current_view) { case COVERFLOW_HOMEBREW: - m_btnMgr.show(m_mainBtnDML); + if( show_dml ) + m_btnMgr.show(m_mainBtnDML); + else + m_btnMgr.show(m_mainBtnUsb); break; case COVERFLOW_CHANNEL: if (show_homebrew && (parental_homebrew || !m_locked)) m_btnMgr.show(m_mainBtnHomebrew); - else + else if( show_dml ) m_btnMgr.show(m_mainBtnDML); + else + m_btnMgr.show(m_mainBtnUsb); break; case COVERFLOW_DML: m_btnMgr.show(m_mainBtnUsb);