mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-28 12:51:52 +01:00
-only enabling nand emu if we really need it
-cleaned up and corrected dml launch code, cheats now should work fine in all cases in gamecube games
This commit is contained in:
parent
7b85928088
commit
f10550a11d
@ -96,6 +96,7 @@ s32 Nand::Nand_Unmount(NandDevice *Device)
|
||||
|
||||
s32 Nand::Nand_Enable(NandDevice *Device)
|
||||
{
|
||||
gprintf("Enabling NAND Emulator\n");
|
||||
s32 fd = IOS_Open("/dev/fs", 0);
|
||||
if (fd < 0) return fd;
|
||||
|
||||
@ -118,6 +119,7 @@ s32 Nand::Nand_Enable(NandDevice *Device)
|
||||
|
||||
s32 Nand::Nand_Disable(void)
|
||||
{
|
||||
gprintf("Disabling NAND Emulator\n");
|
||||
s32 fd = IOS_Open("/dev/fs", 0);
|
||||
if (fd < 0) return fd;
|
||||
|
||||
|
@ -2,10 +2,12 @@
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include "gc.h"
|
||||
#include "gecko.h"
|
||||
#include "fileOps.h"
|
||||
#include "utils.h"
|
||||
#include "memory/mem2.hpp"
|
||||
|
||||
#define SRAM_ENGLISH 0
|
||||
#define SRAM_GERMAN 1
|
||||
@ -18,7 +20,7 @@ syssram* __SYS_LockSram();
|
||||
u32 __SYS_UnlockSram(u32 write);
|
||||
u32 __SYS_SyncSram(void);
|
||||
|
||||
void set_video_mode(int i)
|
||||
void GC_SetVideoMode(int i)
|
||||
{
|
||||
syssram *sram;
|
||||
sram = __SYS_LockSram();
|
||||
@ -48,8 +50,8 @@ void set_video_mode(int i)
|
||||
|
||||
/* Set video mode to PAL or NTSC */
|
||||
*(vu32*)0x800000CC = i;
|
||||
DCFlushRange((void *)(0x800000CC), 1);
|
||||
ICInvalidateRange((void *)(0x800000CC), 1);
|
||||
DCFlushRange((void *)(0x800000CC), 4);
|
||||
ICInvalidateRange((void *)(0x800000CC), 4);
|
||||
|
||||
VIDEO_Configure(rmode);
|
||||
m_frameBuf = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
|
||||
@ -77,7 +79,7 @@ u8 get_wii_language()
|
||||
}
|
||||
}
|
||||
|
||||
void set_language(u8 lang)
|
||||
void GC_SetLanguage(u8 lang)
|
||||
{
|
||||
if (lang == 0)
|
||||
{
|
||||
@ -94,7 +96,7 @@ void set_language(u8 lang)
|
||||
while(!__SYS_SyncSram());
|
||||
}
|
||||
|
||||
bool DML_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir)
|
||||
bool GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir)
|
||||
{
|
||||
char folder[50];
|
||||
char source[300];
|
||||
@ -111,3 +113,62 @@ bool DML_GameIsInstalled(char *discid, const char* partition, const char* dmlgam
|
||||
gprintf("Not found on %s: %s\n", partition, source);
|
||||
return false;
|
||||
}
|
||||
|
||||
void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool debugger, bool NMM, bool NMM_debug)
|
||||
{
|
||||
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through memory (new method)\n", GamePath);
|
||||
|
||||
DML_CFG *DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||
snprintf(DMLCfg->GamePath, sizeof(DMLCfg->GamePath), "/games/%s/game.iso", GamePath);
|
||||
|
||||
DMLCfg->Magicbytes = 0xD1050CF6;
|
||||
DMLCfg->CfgVersion = 0x00000001;
|
||||
DMLCfg->VideoMode |= DML_VID_NONE;
|
||||
DMLCfg->Config |= DML_CFG_GAME_PATH;
|
||||
|
||||
if(CheatPath)
|
||||
{
|
||||
char *ptr;
|
||||
if(strstr(CheatPath, "sd:/") == NULL)
|
||||
{
|
||||
fsop_CopyFile(CheatPath, NewCheatPath, NULL, NULL);
|
||||
ptr = &NewCheatPath[3];
|
||||
}
|
||||
else
|
||||
ptr = &CheatPath[3];
|
||||
strncpy(DMLCfg->CheatPath, ptr, sizeof(DMLCfg->CheatPath));
|
||||
DMLCfg->Config |= DML_CFG_CHEATS;
|
||||
DMLCfg->Config |= DML_CFG_CHEAT_PATH;
|
||||
}
|
||||
if(debugger)
|
||||
DMLCfg->Config |= DML_CFG_DEBUGGER;
|
||||
if(NMM)
|
||||
{
|
||||
DMLCfg->Config |= DML_CFG_NMM;
|
||||
if(NMM_debug)
|
||||
DMLCfg->Config |= DML_CFG_NMM_DEBUG;
|
||||
}
|
||||
//Write options into memory
|
||||
memcpy((void *)0xC0001700, DMLCfg, sizeof(DML_CFG));
|
||||
MEM2_free(DMLCfg);
|
||||
}
|
||||
|
||||
void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath)
|
||||
{
|
||||
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through boot.bin (old method)\n", GamePath);
|
||||
FILE *f;
|
||||
f = fopen("sd:/games/boot.bin", "wb");
|
||||
fwrite(GamePath, 1, strlen(GamePath) + 1, f);
|
||||
fclose(f);
|
||||
|
||||
if(CheatPath && strstr(CheatPath, NewCheatPath) == NULL)
|
||||
fsop_CopyFile(CheatPath, NewCheatPath, NULL, NULL);
|
||||
|
||||
//Tell DML to boot the game from sd card
|
||||
*(vu32*)0x80001800 = 0xB002D105;
|
||||
DCFlushRange((void *)(0x80001800), 4);
|
||||
ICInvalidateRange((void *)(0x80001800), 4);
|
||||
|
||||
*(vu32*)0xCC003024 |= 7;
|
||||
}
|
||||
|
@ -41,9 +41,11 @@ enum dmlvideomode
|
||||
DML_VID_FORCE_PROG = (1<<3),
|
||||
};
|
||||
|
||||
void set_video_mode(int i);
|
||||
void set_language(u8 lang);
|
||||
bool DML_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir);
|
||||
void GC_SetVideoMode(int i);
|
||||
void GC_SetLanguage(u8 lang);
|
||||
bool GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir);
|
||||
void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool debugger, bool NMM, bool NMM_debug);
|
||||
void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath);
|
||||
#endif //GC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1816,6 +1816,7 @@ bool CMenu::_loadList(void)
|
||||
{
|
||||
m_cf.clear();
|
||||
m_gameList.clear();
|
||||
Nand::Instance()->Disable_Emu();
|
||||
|
||||
if(m_cfg.getBool(_domainFromView(), "update_cache")) m_gameList.Update(m_current_view);
|
||||
|
||||
|
@ -155,5 +155,6 @@ void CMenu::_textAbout(void)
|
||||
if(iosInfo != NULL)
|
||||
m_btnMgr.setText(m_aboutLblIOS, wfmt(_fmt("ios", L"IOS%i base %i v%i"), mainIOS, iosInfo->baseios, iosInfo->version), true);
|
||||
SAFE_FREE(iosInfo);
|
||||
Nand::Instance()->Enable_Emu();
|
||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
}
|
||||
|
@ -31,7 +31,8 @@ void CMenu::_enableNandEmu(bool fromconfig)
|
||||
iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS);
|
||||
if (iosInfo->version > 6)
|
||||
isD2XnewerThanV6 = true;
|
||||
Nand::Instance()->Enable_Emu();
|
||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
u8 limiter = 0;
|
||||
s8 direction = m_btnMgr.selected(m_configBtnPartitionP) ? 1 : -1;
|
||||
if (!fromconfig)
|
||||
|
@ -107,7 +107,8 @@ void CMenu::_showConfig4(void)
|
||||
}
|
||||
}
|
||||
|
||||
Nand::Instance()->Enable_Emu();
|
||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
|
||||
m_btnMgr.setText(m_config4LblReturnToVal, channelName);
|
||||
}
|
||||
|
@ -30,9 +30,6 @@
|
||||
#include "homebrew.h"
|
||||
#include "defines.h"
|
||||
#include "gc/gc.h"
|
||||
#include "gc/fileOps.h"
|
||||
|
||||
//#define DML_THROUGH_MEM /*** Load game through mem.. Not compatible with regulair DML ***/
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -449,17 +446,17 @@ void CMenu::_game(bool launch)
|
||||
{
|
||||
char gcfolder[300];
|
||||
sprintf(gcfolder, "%s [%s]", m_cf.getTitle().toUTF8().c_str(), (char *)hdr->hdr.id);
|
||||
if (DML_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD], DML_DIR))
|
||||
if (GC_GameIsInstalled((char *)hdr->hdr.id, DeviceName[SD], DML_DIR))
|
||||
{
|
||||
memset(hdr->path, 0, sizeof(hdr->path));
|
||||
snprintf(hdr->path, sizeof(hdr->path), "%s", (char*)hdr->hdr.id);
|
||||
}
|
||||
else if(DML_GameIsInstalled(gcfolder, DeviceName[SD], DML_DIR))
|
||||
else if(GC_GameIsInstalled(gcfolder, DeviceName[SD], DML_DIR))
|
||||
{
|
||||
memset(hdr->path, 0, sizeof(hdr->path));
|
||||
snprintf(hdr->path, sizeof(hdr->path), "%s", gcfolder);
|
||||
}
|
||||
else if(!DML_GameIsInstalled(hdr->path, DeviceName[SD], DML_DIR) && !_wbfsOp(CMenu::WO_COPY_GAME))
|
||||
else if(!GC_GameIsInstalled(hdr->path, DeviceName[SD], DML_DIR) && !_wbfsOp(CMenu::WO_COPY_GAME))
|
||||
break;
|
||||
currentPartition = SD;
|
||||
}
|
||||
@ -633,79 +630,31 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML)
|
||||
m_gameSound.Stop();
|
||||
CheckGameSoundThread();
|
||||
char* id = (char *)hdr->hdr.id;
|
||||
u8 DMLvideoMode = 0;
|
||||
u8 GClanguage = 0;
|
||||
const char *ptr = "";
|
||||
|
||||
if(has_enabled_providers() && _initNetwork() == 0)
|
||||
add_game_to_card(id);
|
||||
|
||||
u8 DMLvideoMode = 0;
|
||||
u8 GClanguage = 0;
|
||||
|
||||
if(DML)
|
||||
{
|
||||
char CheatPath[256];
|
||||
char NewCheatPath[255];
|
||||
bool NMM = m_gcfg2.testOptBool(id, "NMM", m_cfg.getBool("DML", "NMM", false));
|
||||
bool NMM_debug = m_gcfg2.testOptBool(id, "NMM_debug", m_cfg.getBool("DML", "NMM_debug", false));
|
||||
bool cheats = m_gcfg2.testOptBool(id, "cheat", m_cfg.getBool("DML", "cheat", false));
|
||||
bool DML_debug = m_gcfg2.getBool(id, "debugger", false);
|
||||
|
||||
if(cheats)
|
||||
{
|
||||
char old_cheat_path[256];
|
||||
snprintf(old_cheat_path, sizeof(old_cheat_path), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id));
|
||||
char new_cheat_path[256];
|
||||
snprintf(new_cheat_path, sizeof(new_cheat_path), "%s/%s/%s", fmt(DML_DIR, DeviceName[SD]), hdr->path, fmt("%s.gct", id));
|
||||
|
||||
if(strstr(old_cheat_path, "sd:/") != NULL && m_new_dml)
|
||||
{
|
||||
ptr = &old_cheat_path[3];
|
||||
}
|
||||
else
|
||||
{
|
||||
fsop_CopyFile(old_cheat_path, new_cheat_path, NULL, NULL);
|
||||
ptr = &new_cheat_path[3];
|
||||
}
|
||||
gprintf("Cheat File: %s\n", ptr);
|
||||
snprintf(CheatPath, sizeof(CheatPath), "%s/%s", m_cheatDir.c_str(), fmt("%s.gct", id));
|
||||
snprintf(NewCheatPath, sizeof(NewCheatPath), "%s/%s/%s", fmt(DML_DIR, "sd"), hdr->path, fmt("%s.gct", id));
|
||||
}
|
||||
|
||||
if(m_new_dml)
|
||||
{
|
||||
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through memory\n", hdr->path);
|
||||
|
||||
DML_CFG *DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG));
|
||||
memset(DMLCfg, 0, sizeof(DML_CFG));
|
||||
snprintf(DMLCfg->GamePath, sizeof(DMLCfg->GamePath), "/games/%s/game.iso", hdr->path);
|
||||
DMLCfg->Magicbytes = 0xD1050CF6;
|
||||
DMLCfg->CfgVersion = 0x00000001;
|
||||
DMLCfg->VideoMode |= DML_VID_NONE;
|
||||
DMLCfg->Config |= DML_CFG_GAME_PATH;
|
||||
|
||||
if(cheats)
|
||||
{
|
||||
DMLCfg->Config |= DML_CFG_CHEATS;
|
||||
DMLCfg->Config |= DML_CFG_CHEAT_PATH;
|
||||
|
||||
strncpy(DMLCfg->CheatPath, ptr, sizeof(DMLCfg->CheatPath));
|
||||
}
|
||||
|
||||
if(m_gcfg2.getBool(id, "debugger", false))
|
||||
DMLCfg->Config |= DML_CFG_DEBUGGER;
|
||||
if(NMM)
|
||||
{
|
||||
DMLCfg->Config |= DML_CFG_NMM;
|
||||
if(NMM_debug)
|
||||
DMLCfg->Config |= DML_CFG_NMM_DEBUG;
|
||||
}
|
||||
|
||||
memcpy((void *)0xC0001700, DMLCfg, sizeof(DML_CFG));
|
||||
MEM2_free(DMLCfg);
|
||||
}
|
||||
DML_New_SetOptions(hdr->path, CheatPath, NewCheatPath, DML_debug, NMM, NMM_debug);
|
||||
else
|
||||
{
|
||||
gprintf("Wiiflow DML: Launch game 'sd:/games/%s/game.iso' through boot.bin\n", hdr->path);
|
||||
FILE *f;
|
||||
f = fopen("sd:/games/boot.bin", "wb");
|
||||
fwrite(hdr->path, 1, strlen(hdr->path) + 1, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
DML_Old_SetOptions(hdr->path, CheatPath, NewCheatPath);
|
||||
DMLvideoMode = min((u32)m_gcfg2.getInt(id, "dml_video_mode", 0), ARRAY_SIZE(CMenu::_DMLvideoModes) - 1u);
|
||||
if(DMLvideoMode == 0)
|
||||
DMLvideoMode = min((u32)m_cfg.getInt("DML", "video_mode", 0), ARRAY_SIZE(CMenu::_GlobalDMLvideoModes) - 1u);
|
||||
@ -731,29 +680,18 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML)
|
||||
WDVD_Init();
|
||||
WDVD_StopMotor();
|
||||
WDVD_Close();
|
||||
|
||||
//Tell DML to boot the game from sd card
|
||||
*(vu32*)0x80001800 = 0xB002D105;
|
||||
DCFlushRange((void *)(0x80001800), 4);
|
||||
ICInvalidateRange((void *)(0x80001800), 4);
|
||||
}
|
||||
|
||||
memcpy((char *)0x80000000, id, 6);
|
||||
if(((id[3] == 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 1))
|
||||
{
|
||||
set_video_mode(1);
|
||||
}
|
||||
GC_SetVideoMode(1);
|
||||
if(((id[3] != 'P') && (DMLvideoMode == 0)) || (DMLvideoMode == 2))
|
||||
{
|
||||
set_video_mode(0);
|
||||
}
|
||||
set_language(GClanguage);
|
||||
GC_SetVideoMode(0);
|
||||
GC_SetLanguage(GClanguage);
|
||||
VIDEO_SetBlack(TRUE);
|
||||
VIDEO_Flush();
|
||||
VIDEO_WaitVSync();
|
||||
|
||||
*(vu32*)0xCC003024 |= 7;
|
||||
|
||||
if(WII_LaunchTitle(0x100000100LL) < 0 )
|
||||
Sys_LoadMenu();
|
||||
}
|
||||
|
@ -390,7 +390,8 @@ int CMenu::main(void)
|
||||
iosinfo_t * iosInfo = cIOSInfo::GetInfo(mainIOS);
|
||||
if (iosInfo->version > 6)
|
||||
isD2XnewerThanV6 = true;
|
||||
Nand::Instance()->Enable_Emu();
|
||||
if(m_current_view == COVERFLOW_CHANNEL && m_cfg.getInt("NAND", "emulation", 0) > 0)
|
||||
Nand::Instance()->Enable_Emu();
|
||||
u8 limiter = 0;
|
||||
currentPartition = loopNum(currentPartition + 1, (int)USB8);
|
||||
while(!DeviceHandler::Instance()->IsInserted(currentPartition) ||
|
||||
|
@ -352,7 +352,7 @@ bool CMenu::_wbfsOp(CMenu::WBFS_OP op)
|
||||
char dmlgamedir[50];
|
||||
snprintf(dmlgamedir, sizeof(dmlgamedir), "%s", (currentPartition != SD) ? m_DMLgameDir.c_str() : DML_DIR);
|
||||
snprintf(gcfolder, sizeof(gcfolder), "%s [%s]", gcheader.title, (char *)gcheader.id);
|
||||
if (_searchGamesByID((const char *) gcheader.id).size() != 0 || DML_GameIsInstalled((char *)gcheader.id, DeviceName[currentPartition], dmlgamedir) || DML_GameIsInstalled(gcfolder, DeviceName[currentPartition], dmlgamedir))
|
||||
if (_searchGamesByID((const char *) gcheader.id).size() != 0 || GC_GameIsInstalled((char *)gcheader.id, DeviceName[currentPartition], dmlgamedir) || GC_GameIsInstalled(gcfolder, DeviceName[currentPartition], dmlgamedir))
|
||||
{
|
||||
error(_t("wbfsoperr4", L"Game already installed"));
|
||||
out = true;
|
||||
|
Loading…
Reference in New Issue
Block a user