From 5a817f0ce7310974cd4e0a3e19ee5e16fbd088af Mon Sep 17 00:00:00 2001 From: "fix94.1" Date: Tue, 8 May 2012 20:38:50 +0000 Subject: [PATCH] -writing DML options now safe into memory, no way that there an error can occur anymore --- source/gc/gc.c | 27 +++++++++++++++------------ source/gc/gc.h | 2 ++ source/menu/menu_game.cpp | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/source/gc/gc.c b/source/gc/gc.c index 88677473..a5bd92c4 100644 --- a/source/gc/gc.c +++ b/source/gc/gc.c @@ -19,6 +19,7 @@ syssram* __SYS_LockSram(); u32 __SYS_UnlockSram(u32 write); u32 __SYS_SyncSram(void); +DML_CFG *DMLCfg = NULL; void GC_SetVideoMode(u8 videomode) { @@ -149,12 +150,11 @@ void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, boo { 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)); + DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG)); memset(DMLCfg, 0, sizeof(DML_CFG)); DMLCfg->Magicbytes = 0xD1050CF6; DMLCfg->CfgVersion = 0x00000001; - //DMLCfg->VideoMode |= DML_VID_FORCE; DMLCfg->VideoMode |= DML_VID_NONE; DMLCfg->Config |= DML_CFG_ACTIVITY_LED; //Sorry but I like it lol, option will may follow @@ -196,14 +196,6 @@ void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, boo if(DMLvideoMode > 3) DMLCfg->VideoMode |= DML_VID_PROG_PATCH; - - //Write options into memory - memcpy((void *)0xC0001700, DMLCfg, sizeof(DML_CFG)); - - //DML v1.2+ - memcpy((void *)0xC1200000, DMLCfg, sizeof(DML_CFG)); - - MEM2_free(DMLCfg); } void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats) @@ -229,16 +221,27 @@ void DML_New_SetBootDiscOption() { gprintf("Booting GC game\n"); - DML_CFG *DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG)); + DMLCfg = (DML_CFG*)MEM2_alloc(sizeof(DML_CFG)); memset(DMLCfg, 0, sizeof(DML_CFG)); DMLCfg->Magicbytes = 0xD1050CF6; DMLCfg->CfgVersion = 0x00000001; DMLCfg->Config |= DML_CFG_BOOT_DISC; +} + +void DML_New_WriteOptions() +{ + if(DMLCfg == NULL) + return; + + //Write options into memory + memcpy((void *)0x80001700, DMLCfg, sizeof(DML_CFG)); + DCFlushRange((void *)(0x80001700), sizeof(DML_CFG)); //DML v1.2+ - memcpy((void *)0xC1200000, DMLCfg, sizeof(DML_CFG)); + memcpy((void *)0x81200000, DMLCfg, sizeof(DML_CFG)); + DCFlushRange((void *)(0x81200000), sizeof(DML_CFG)); MEM2_free(DMLCfg); } diff --git a/source/gc/gc.h b/source/gc/gc.h index 864266fc..a9b72a9e 100644 --- a/source/gc/gc.h +++ b/source/gc/gc.h @@ -48,9 +48,11 @@ enum dmlvideomode void GC_SetVideoMode(u8 videomode); void GC_SetLanguage(u8 lang); int GC_GameIsInstalled(char *discid, const char* partition, const char* dmlgamedir); + void DML_New_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats, bool debugger, u8 NMM, u8 nodisc, u8 DMLvideoMode); void DML_Old_SetOptions(char *GamePath, char *CheatPath, char *NewCheatPath, bool cheats); void DML_New_SetBootDiscOption(); +void DML_New_WriteOptions(); #endif //GC_H_ #ifdef __cplusplus diff --git a/source/menu/menu_game.cpp b/source/menu/menu_game.cpp index 9172c610..8a0d2c99 100644 --- a/source/menu/menu_game.cpp +++ b/source/menu/menu_game.cpp @@ -761,9 +761,9 @@ void CMenu::_launchGC(dir_discHdr *hdr, bool DML) USBStorage_Deinit(); SDHC_Init(); - memcpy((char *)0x80000000, id, 6); GC_SetVideoMode(DMLvideoMode); GC_SetLanguage(GClanguage); + DML_New_WriteOptions(); if(WII_LaunchTitle(0x100000100LL) < 0) Sys_LoadMenu();