From c80332eff37ae592834b7b32de6163c63c9b497a Mon Sep 17 00:00:00 2001 From: dimok321 <15055714+dimok789@users.noreply.github.com> Date: Fri, 19 Jun 2009 20:20:03 +0000 Subject: [PATCH] *Added Anti 002 Fix to GlobalSettings which was made by WiiPower (Thanks) NOTE: This fix is for games like Ghostbusters which don't work under IOS249 Rev10. With this fix on, this games work on Rev10 and you don't need to switch the cIOS all the time to play those games. For this option it is necessary that you turn ERROR 002 FIX ON. --- source/language/language.c | 5 +++++ source/language/language.h | 1 + source/settings/Settings.cpp | 9 +++++++++ source/settings/cfg.c | 9 +++++++++ source/settings/cfg.h | 1 + source/usbloader/apploader.c | 22 ++++++++++++++++++++++ 6 files changed, 47 insertions(+) diff --git a/source/language/language.c b/source/language/language.c index 8a3efce7..f786ea33 100644 --- a/source/language/language.c +++ b/source/language/language.c @@ -35,6 +35,7 @@ void lang_default() snprintf(LANGUAGE.ok, sizeof(LANGUAGE.ok), "OK"); snprintf(LANGUAGE.addToFavorite, sizeof(LANGUAGE.addToFavorite), "Favorite"); snprintf(LANGUAGE.all, sizeof(LANGUAGE.all), "Alphabetical"); +snprintf(LANGUAGE.Anti002fix, sizeof(LANGUAGE.Anti002fix), "Anti 002 fix"); snprintf(LANGUAGE.AppLanguage, sizeof(LANGUAGE.AppLanguage), "App Language"); snprintf(LANGUAGE.Alternatedol, sizeof(LANGUAGE.Alternatedol), "Alternate DOL"); snprintf(LANGUAGE.t3Covers, sizeof(LANGUAGE.t3Covers), "3D Covers"); @@ -322,6 +323,10 @@ void language_set(char *name, char *val) strcopy(LANGUAGE.ok, val, sizeof(LANGUAGE.ok)); return; } + if (strcmp(name, "Anti002fix") == 0) { + strcopy(LANGUAGE.Anti002fix, val, sizeof(LANGUAGE.Anti002fix)); + return; + } if (strcmp(name, "AppLanguage") == 0) { strcopy(LANGUAGE.AppLanguage, val, sizeof(LANGUAGE.AppLanguage)); return; diff --git a/source/language/language.h b/source/language/language.h index fceec84c..00f7715d 100644 --- a/source/language/language.h +++ b/source/language/language.h @@ -32,6 +32,7 @@ struct LANGUAGE char t3Covers[50]; char addToFavorite[50]; char all[30]; + char Anti002fix[50]; char AppLanguage[50]; char available[20]; char Areyousure[50]; diff --git a/source/settings/Settings.cpp b/source/settings/Settings.cpp index 85c46839..d0328fa5 100644 --- a/source/settings/Settings.cpp +++ b/source/settings/Settings.cpp @@ -733,6 +733,7 @@ int MenuSettings() options2.SetName(5,"%s", LANGUAGE.BootStandard); options2.SetName(6, "%s",LANGUAGE.QuickBoot); options2.SetName(7, "%s",LANGUAGE.Error002fix); + options2.SetName(8, "%s",LANGUAGE.Anti002fix); for(int i = 0; i <= MAXOPTIONS; i++) options2.SetValue(i, NULL); w.Append(&optionBrowser2); optionBrowser2.SetClickable(true); @@ -761,6 +762,8 @@ int MenuSettings() Settings.language = 0; if(Settings.error002 >= settings_off_on_max) Settings.error002 = 0; + if(Settings.anti002fix >= settings_off_on_max) + Settings.anti002fix = 0; if (Settings.video == discdefault) options2.SetValue(0,"%s",LANGUAGE.DiscDefault); else if (Settings.video == systemdefault) options2.SetValue(0,"%s",LANGUAGE.SystemDefault); @@ -800,6 +803,9 @@ int MenuSettings() if (Settings.error002 == no) options2.SetValue(7,"%s",LANGUAGE.No); else if (Settings.error002 == yes) options2.SetValue(7,"%s",LANGUAGE.Yes); + if (Settings.anti002fix == no) options2.SetValue(8,"%s",LANGUAGE.No); + else if (Settings.anti002fix == yes) options2.SetValue(8,"%s",LANGUAGE.Yes); + if(backBtn.GetState() == STATE_CLICKED) { backBtn.ResetState(); @@ -866,6 +872,9 @@ int MenuSettings() case 7: Settings.error002++; break; + case 8: + Settings.anti002fix++; + break; } } optionBrowser2.SetEffect(EFFECT_FADE, -20); diff --git a/source/settings/cfg.c b/source/settings/cfg.c index 7cace030..b3581ffc 100644 --- a/source/settings/cfg.c +++ b/source/settings/cfg.c @@ -333,6 +333,7 @@ void Global_Default(void) Settings.titlesOverride = 0; Settings.screensaver = 3; Settings.error002 = 0; + Settings.anti002fix = 0; } @@ -969,6 +970,13 @@ void global_cfg_set(char *name, char *val) } return; } + else if (strcmp(name, "anti002fix") == 0) { + int i; + if (sscanf(val, "%d", &i) == 1) { + Settings.anti002fix = i; + } + return; + } else if (strcmp(name, "titlesOverride") == 0) { int i; if (sscanf(val, "%d", &i) == 1) { @@ -1227,6 +1235,7 @@ bool cfg_save_global()// save global settings fprintf(f, "patchcountrystrings = %d\n ", Settings.patchcountrystrings); fprintf(f, "screensaver = %d\n ", Settings.screensaver); fprintf(f, "error002 = %d\n ", Settings.error002); + fprintf(f, "anti002fix = %d\n ", Settings.anti002fix); fclose(f); return true; } diff --git a/source/settings/cfg.h b/source/settings/cfg.h index 0a412e8a..da1dd377 100644 --- a/source/settings/cfg.h +++ b/source/settings/cfg.h @@ -351,6 +351,7 @@ struct SSettings { char Cheatcodespath[100]; int titlesOverride; short error002; + short anti002fix; }; void CFG_LoadGlobal(void); diff --git a/source/usbloader/apploader.c b/source/usbloader/apploader.c index 38186358..df85b6e2 100644 --- a/source/usbloader/apploader.c +++ b/source/usbloader/apploader.c @@ -220,6 +220,25 @@ bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) return found; } +/** Anti 002 fix for cIOS 249 rev < 12 thanks to WiiPower **/ +void Anti_002_fix(void *Address, int Size) +{ + u8 SearchPattern[12] = { 0x2C, 0x00, 0x00, 0x00, 0x48, 0x00, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 }; + u8 PatchData[12] = { 0x2C, 0x00, 0x00, 0x00, 0x40, 0x82, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 }; + + void *Addr = Address; + void *Addr_end = Address+Size; + + while(Addr <= Addr_end-sizeof(SearchPattern)) + { + if(memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) + { + memcpy(Addr,PatchData,sizeof(PatchData)); + } + Addr += 4; + } +} + void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch) { GXRModeObj** table = NULL; @@ -268,6 +287,9 @@ void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u if(patchcountrystring == 1) PatchCountryStrings(dst, len); + if(Settings.anti002fix == on) + Anti_002_fix(dst, len); + } s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol)