From f3acae37f82c28059b74b64de289ea3fa9998811 Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Thu, 22 Aug 2013 14:24:29 +0000 Subject: [PATCH] -updated diosmios/quadforce detection, now hopefully complete -removed the dml_r52+ and dm_r2.1+ options from the wiiflow.ini --- source/gui/text.cpp | 19 ++-------- source/menu/menu.cpp | 77 ++++++++++++++++++++++++++++----------- source/menu/menu.hpp | 6 ++- source/menu/menu_game.cpp | 48 ++++++++---------------- source/menu/menu_wad.cpp | 8 ++++ 5 files changed, 87 insertions(+), 71 deletions(-) diff --git a/source/gui/text.cpp b/source/gui/text.cpp index 6ed04371..6e7c9cc0 100644 --- a/source/gui/text.cpp +++ b/source/gui/text.cpp @@ -1,6 +1,7 @@ #include #include "text.hpp" #include "memory/mem2.hpp" +#include "fileOps/fileOps.h" static char general_buffer[MAX_MSG_SIZE * 2]; string sfmt(const char *format, ...) @@ -194,24 +195,12 @@ bool SFont::fromFile(const char *filename, u32 size, u32 lspacing, u32 w, u32 id lineSpacing = min(max(6u, lspacing), 1000u); - FILE *file = fopen(filename, "rb"); - if (file == NULL) return false; - fseek(file, 0, SEEK_END); - u32 fileSize = ftell(file); - fseek(file, 0, SEEK_SET); - if (fileSize == 0) return false; - if(data != NULL) free(data); - data = (u8*)MEM2_alloc(fileSize); - if (!data) - { - fclose(file); + data = fsop_ReadFile(filename, &dataSize); + if(data == NULL) return false; - } - - fread(data, 1, fileSize, file); - dataSize = fileSize; + DCFlushRange(data, dataSize); font = new FreeTypeGX(); diff --git a/source/menu/menu.cpp b/source/menu/menu.cpp index 30ea3162..4a335512 100644 --- a/source/menu/menu.cpp +++ b/source/menu/menu.cpp @@ -142,6 +142,11 @@ CMenu::CMenu() m_thrdDone = false; m_thrdWritten = 0; m_thrdTotal = 0; + /* mios stuff */ + m_mios_ver = 0; + m_sd_dm = false; + m_new_dml = false; + m_new_dm_cfg = false; } void CMenu::init() @@ -275,10 +280,9 @@ void CMenu::init() gprintf("Force enabling DML view\n"); m_show_dml = true; } - else - m_show_dml = MIOSisDML(); - m_new_dml = m_cfg.getBool(GC_DOMAIN, "dml_r52+", true); - m_new_dm_cfg = m_cfg.getBool(GC_DOMAIN, "dm_r2.1+", true); + MIOSisDML(); + if(m_show_dml == false) + m_show_dml = (m_mios_ver > 0); m_DMLgameDir = fmt("%%s:/%s", m_cfg.getString(GC_DOMAIN, "dir_usb_games", "games").c_str()); /* Emu NAND */ m_cfg.getString(CHANNEL_DOMAIN, "path", ""); @@ -2530,8 +2534,18 @@ void CMenu::UpdateCache(u32 view) } } -int CMenu::MIOSisDML() +void CMenu::MIOSisDML() { + /* + 0=mios + 1=dm + 2=qf + */ + m_mios_ver = 0; + m_sd_dm = false; + m_new_dml = false; + m_new_dm_cfg = false; + u32 size = 0; char ISFS_Filename[ISFS_MAXPATH] ATTRIBUTE_ALIGN(32); strcpy(ISFS_Filename, "/title/00000001/00000101/content/0000000c.app"); @@ -2539,27 +2553,48 @@ int CMenu::MIOSisDML() if(appfile) { for(u32 i = 0; i < size; ++i) - { /* GCLoader check */ - if(*(vu32*)(appfile+i) == 0x47434C6F && *(vu32*)(appfile+i+4) == 0x61646572) + { + /* check for some odd looking elf signs */ + if(m_mios_ver == 0 && *(vu32*)(appfile+i) == 0x7F454C46 && *(vu32*)(appfile+i+4) != 0x01020161) { - for(u32 j = 0; j < size; ++j) - { /* Lite or Quad (QuadForce name string only exist in QuadForce SD) */ - if(*(vu32*)(appfile+j) == 0x4C697465 || *(vu32*)(appfile+j) == 0x51756164) - { - gprintf("DIOS-MIOS Lite/QuadForce SD is installed as MIOS\n"); - free(appfile); - return 2; - } - } - gprintf("DIOS-MIOS/QuadForce USB is installed as MIOS\n"); - free(appfile); - return 1; + m_mios_ver = 1; + m_new_dml = true; /* assume cfg dm */ } + /* seaching for an old debug print in boot.bin only dml revs */ + if(*(vu32*)(appfile+i) == 0x5573696E && *(vu32*)(appfile+i+4) == 0x6720656E) + { + m_mios_ver = 1; + m_new_dml = false; /* boot.bin dm */ + } + /* pic checks */ + if(*(vu32*)(appfile+i) == 0xF282F280 && *(vu32*)(appfile+i+4) == 0xF281F27F) /* pic at 0x35000 */ + { + m_mios_ver = 1; + m_new_dm_cfg = true; /* newer dm cfg */ + } + if(*(vu32*)(appfile+i) == 0x5A9B5A77 && *(vu32*)(appfile+i+4) == 0x5C9A5B78) /* pic at 0x35000 */ + { + m_mios_ver = 1; + m_new_dm_cfg = true; /* current dm cfg */ + } + if(*(vu32*)(appfile+i) == 0x68846791 && *(vu32*)(appfile+i+4) == 0x63836390) /* pic at 0x6b000 */ + { + m_mios_ver = 1; + m_new_dm_cfg = false; /* older dm cfg */ + } + if(*(vu32*)(appfile+i) == 0x1D981F78 && *(vu32*)(appfile+i+4) == 0x1E991E79) /* pic at 0x95000 */ + { + m_mios_ver = 2; + m_new_dm_cfg = true; /* qf */ + } + /* Lite or Quad string for SD versions */ + if(*(vu32*)(appfile+i) == 0x4C697465 || *(vu32*)(appfile+i) == 0x51756164) + m_sd_dm = true; } free(appfile); } - gprintf("DIOS-MIOS (Lite) not found\n"); - return 0; + gprintf("m_mios_ver = %u; m_sd_dm = %d; m_new_dml = %d; m_new_dm_cfg = %d\n", + m_mios_ver, m_sd_dm, m_new_dml, m_new_dm_cfg); } void CMenu::RemoveCover(const char *id) diff --git a/source/menu/menu.hpp b/source/menu/menu.hpp index b6f911d1..3ec124d1 100644 --- a/source/menu/menu.hpp +++ b/source/menu/menu.hpp @@ -191,7 +191,9 @@ private: s16 m_mainBtnInit2; s16 m_mainLblInit; s16 m_mainLblUser[6]; - u8 m_show_dml; + u8 m_mios_ver; + bool m_show_dml; + bool m_sd_dm; bool m_devo_installed; bool m_new_dml; bool m_new_dm_cfg; @@ -1068,7 +1070,7 @@ private: const char *_domainFromView(void); const char *_cfDomain(bool selected = false); void UpdateCache(u32 view = COVERFLOW_MAX); - int MIOSisDML(); + void MIOSisDML(); void RemoveCover(const char *id); SFont _font(CMenu::FontSet &fontSet, const char *domain, const char *key, u32 fontSize, u32 lineSpacing, u32 weight, u32 index, const char *genKey); TexData _texture(const char *domain, const char *key, TexData &def, bool freeDef = true); diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 83d055ad..82bf5ee7 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -868,53 +868,36 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) else m_cfg.setString(GC_DOMAIN, "current_item", id); - u8 m_current_mios = m_cfg.getInt(GC_DOMAIN, "current_auto_mios", 0); - u8 req_mios = 0; bool isqf = false; const char *mios_wad = NULL; - - if(loader == 2 || (loader == 0 && m_current_mios > 0))//auto or (DM and auto prev used) + + if(loader == 2) //auto selected { - for(int i = 0; i < QFIDN; i++) - if(strncmp(id, qfid[i], strlen(qfid[i])) == 0) - isqf = true; - - if(isqf) + loader = 0; /* force dm boot */ + for(u8 i = 0; i < QFIDN; i++) { - if(currentPartition == SD) - { - req_mios = 4; + if(strncmp(id, qfid[i], strlen(qfid[i])) == 0) + isqf = true; + } + if(isqf) + { + if(currentPartition == SD && (m_mios_ver != 2 || m_sd_dm == false)) mios_wad = fmt("%s/qfsd.wad", m_miosDir.c_str()); - } - else if(currentPartition != SD) - { - req_mios = 3; + else if(currentPartition != SD && (m_mios_ver != 2 || m_sd_dm == true)) mios_wad = fmt("%s/qfusb.wad", m_miosDir.c_str()); - } } else { - if(currentPartition == SD) - { - req_mios = 2; + if(currentPartition == SD && (m_mios_ver != 1 || m_sd_dm == false)) mios_wad = fmt("%s/dml.wad", m_miosDir.c_str()); - } - else if(currentPartition != SD) - { - req_mios = 1; + else if(currentPartition != SD && (m_mios_ver != 1 || m_sd_dm == true)) mios_wad = fmt("%s/dm.wad", m_miosDir.c_str()); - } } - if(m_current_mios != req_mios && fsop_FileExist(mios_wad)) - { - m_cfg.setInt(GC_DOMAIN, "current_auto_mios", req_mios); + if(mios_wad != NULL && fsop_FileExist(mios_wad)) _Wad(mios_wad, true);//install mios - } - loader = 0; } //copy DML game from USB to SD if needed for DML - m_show_dml = MIOSisDML(); - if(currentPartition != SD && m_show_dml == 2 && (strstr(hdr->path, ".iso") == NULL || !m_devo_installed || loader == 0)) + if(loader == 0 && currentPartition != SD && m_sd_dm == true && strcasestr(hdr->path, ".iso") == NULL) { bool foundOnSD = false; ListGenerator SD_List; @@ -958,7 +941,6 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool disc) bool DIOSMIOS = false; if(loader == 0 || strcasestr(path, "boot.bin") != NULL) { - DIOSMIOS = true; char CheatPath[256]; u8 NMM = min((u32)m_gcfg2.getInt(id, "dml_nmm", 0), ARRAY_SIZE(CMenu::_NMM) - 1u); diff --git a/source/menu/menu_wad.cpp b/source/menu/menu_wad.cpp index b688c2b4..ab614051 100644 --- a/source/menu/menu_wad.cpp +++ b/source/menu/menu_wad.cpp @@ -494,6 +494,14 @@ void CMenu::_Wad(const char *wad_path, bool autoInstall) m_btnMgr.hide(m_wbfsLblMessage); m_btnMgr.hide(m_wbfsLblDialog); m_btnMgr.hide(m_wbfsPBar); + + if(mios == true) + { + /* recheck after new mios install */ + MIOSisDML(); + if(m_show_dml == false) + m_show_dml = (m_mios_ver > 0); + } } void CMenu::_initWad()