This commit is contained in:
thedarkness1981 2009-07-31 12:45:14 +00:00
parent 8e42f68cae
commit 6e3bc5607e
10 changed files with 1825 additions and 1943 deletions

View File

@ -27,7 +27,6 @@ int CheatMenu(const char * gameID) {
bool exit = false; bool exit = false;
int ret = 1; int ret = 1;
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume); GuiSound btnClick(button_click2_pcm, button_click2_pcm_size, SOUND_PCM, Settings.sfxvolume);
char imgPath[100]; char imgPath[100];
@ -35,25 +34,24 @@ int CheatMenu(const char * gameID) {
GuiImageData btnOutline(imgPath, button_dialogue_box_png); GuiImageData btnOutline(imgPath, button_dialogue_box_png);
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
GuiImageData settingsbg(imgPath, settings_background_png); GuiImageData settingsbg(imgPath, settings_background_png);
GuiImage settingsbackground(&settingsbg);
GuiTrigger trigA; GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigB; GuiTrigger trigB;
trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B); trigB.SetButtonOnlyTrigger(-1, WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B, PAD_BUTTON_B);
GuiImage settingsbackground(&settingsbg);
GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); GuiText backBtnTxt(tr("Back") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage backBtnImg(&btnOutline); GuiImage backBtnImg(&btnOutline);
GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, &btnSoundOver, &btnClick,1); GuiButton backBtn(&backBtnImg,&backBtnImg, 2, 3, -140, 400, &trigA, NULL, &btnClick,1);
backBtn.SetLabel(&backBtnTxt); backBtn.SetLabel(&backBtnTxt);
backBtn.SetTrigger(&trigB); backBtn.SetTrigger(&trigB);
GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255}); GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30); createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
GuiImage createBtnImg(&btnOutline); GuiImage createBtnImg(&btnOutline);
GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, &btnSoundOver, &btnClick,1); GuiButton createBtn(&createBtnImg,&createBtnImg, 2, 3, 160, 400, &trigA, NULL, &btnClick,1);
createBtn.SetLabel(&createBtnTxt); createBtn.SetLabel(&createBtnTxt);
char txtfilename[55]; char txtfilename[55];
@ -63,8 +61,6 @@ int CheatMenu(const char * gameID) {
int check = c.openTxtfile(txtfilename); int check = c.openTxtfile(txtfilename);
int download =0; int download =0;
//char tmp[10];
switch (check) { switch (check) {
case -1: case -1:
@ -72,9 +68,7 @@ int CheatMenu(const char * gameID) {
break; break;
case 0: case 0:
download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now")); download = WindowPrompt(tr("Error"),tr("No Cheatfile found"),tr("OK"),tr("Download Now"));
//snprintf(tmp, sizeof(tmp), "%i",download);
//WindowPrompt(0,tmp,tr("OK"),tr("Download Now"));
if (download==0) if (download==0)
download = CodeDownload(gameID); download = CodeDownload(gameID);
break; break;
@ -133,7 +127,6 @@ int CheatMenu(const char * gameID) {
x++; x++;
} }
} }
string chtpath = Settings.Cheatcodespath; string chtpath = Settings.Cheatcodespath;
string gctfname = chtpath + c.getGameID() + ".gct"; string gctfname = chtpath + c.getGameID() + ".gct";
c.createGCT(selectednrs,x,gctfname.c_str()); c.createGCT(selectednrs,x,gctfname.c_str());
@ -141,7 +134,6 @@ int CheatMenu(const char * gameID) {
exit = true; exit = true;
break; break;
} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK")); } else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
} }
if (backBtn.GetState() == STATE_CLICKED) { if (backBtn.GetState() == STATE_CLICKED) {
@ -154,7 +146,6 @@ int CheatMenu(const char * gameID) {
mainWindow->SetState(STATE_DEFAULT); mainWindow->SetState(STATE_DEFAULT);
mainWindow->Remove(&w); mainWindow->Remove(&w);
ResumeGui(); ResumeGui();
break; break;
} }

View File

@ -1,293 +1,218 @@
#include <iostream> /*
#include <fstream> * gct.h
#include "gct.h" * Class to handle Ocarina TXT Cheatfiles
* nIxx
#define OUTOFRANGE "Error:Range" */
GCTCheats::GCTCheats(void) { #include <iostream>
iCntCheats = 0; #include <fstream>
} #include "gct.h"
GCTCheats::~GCTCheats(void) { #define ERRORRANGE "Error: CheatNr out of range"
}
GCTCheats::GCTCheats(void) {
int GCTCheats::getCnt() { iCntCheats = 0;
return iCntCheats; }
}
GCTCheats::~GCTCheats(void) {
string GCTCheats::getGameName(void) {
return sGameTitle; string sGameID ="";
} string sGameTitle = "";
/*string sCheatName[MAXCHEATS];
string GCTCheats::getGameID(void) { string sCheats[MAXCHEATS];
return sGameID; string sCheatComment[MAXCHEATS];*/
} }
string GCTCheats::getCheat(int nr) { int GCTCheats::getCnt() {
if (nr <= (iCntCheats-1)) { return iCntCheats;
return sCheats[nr]; }
} else {
return OUTOFRANGE;//"Error: CheatNr out of range"; string GCTCheats::getGameName(void) {
} return sGameTitle;
} }
string GCTCheats::getCheatName(int nr) { string GCTCheats::getGameID(void) {
if (nr <= (iCntCheats-1)) { return sGameID;
return sCheatName[nr]; }
} else {
return "Error: CheatNr out of range"; string GCTCheats::getCheat(int nr) {
} if (nr <= (iCntCheats-1)) {
} return sCheats[nr];
} else {
string GCTCheats::getCheatComment(int nr) { return ERRORRANGE;
if (nr <= (iCntCheats-1)) { }
return sCheatComment[nr]; }
} else {
return "Error: CheatNr out of range"; string GCTCheats::getCheatName(int nr) {
} if (nr <= (iCntCheats-1)) {
} return sCheatName[nr];
} else {
int GCTCheats::createGCT(int nr,const char * filename) { return ERRORRANGE;
ofstream filestr; }
filestr.open(filename); }
if (filestr.fail()) string GCTCheats::getCheatComment(int nr) {
return 0; if (nr <= (iCntCheats-1)) {
return sCheatComment[nr];
//Reversed Header and Footer } else {
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; return ERRORRANGE;
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; }
}
string buf = getCheat(nr);
filestr.write(header,sizeof(header)); int GCTCheats::createGCT(int nr,const char * filename) {
ofstream filestr;
int x = 0; filestr.open(filename);
long int li;
int len = buf.size(); if (filestr.fail())
return 0;
while (x < len) {
string temp = buf.substr(x,2); //Header and Footer
li = strtol(temp.c_str(),NULL,16); char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
temp = li; char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
filestr.write(temp.c_str(),1);
x +=2; string buf = getCheat(nr);
} filestr.write(header,sizeof(header));
filestr.write(footer,sizeof(footer));
int x = 0;
filestr.close(); long int li;
return 1; int len = buf.size();
}
while (x < len) {
int GCTCheats::createGCT(const char * chtbuffer,const char * filename) { string temp = buf.substr(x,2);
ofstream filestr; li = strtol(temp.c_str(),NULL,16);
filestr.open(filename); temp = li;
filestr.write(temp.c_str(),1);
if (filestr.fail()) x +=2;
return 0; }
filestr.write(footer,sizeof(footer));
//Reversed Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; filestr.close();
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; return 1;
}
string buf = chtbuffer;
filestr.write(header,sizeof(header)); int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
ofstream filestr;
int x = 0; filestr.open(filename);
long int li;
int len = buf.size(); if (filestr.fail())
return 0;
while (x < len) {
string temp = buf.substr(x,2); //Header and Footer
li = strtol(temp.c_str(),NULL,16); char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
temp = li; char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
filestr.write(temp.c_str(),1);
x +=2; string buf = chtbuffer;
} filestr.write(header,sizeof(header));
filestr.write(footer,sizeof(footer)); int x = 0;
long int li;
filestr.close(); int len = buf.size();
return 1; while (x < len) {
} string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
int GCTCheats::createGCT(int nr[],int cnt,const char * filename) { temp = li;
filestr.write(temp.c_str(),1);
ofstream filestr; x +=2;
filestr.open(filename); }
if (filestr.fail()) filestr.write(footer,sizeof(footer));
return 0;
filestr.close();
//Reversed Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde}; return 1;
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; }
filestr.write(header,sizeof(header)); int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
int c = 0; ofstream filestr;
while (c != cnt) { filestr.open(filename);
int actnr = nr[c];
string buf = getCheat(actnr); if (filestr.fail())
long int li; return 0;
int len = buf.size();
int x = 0; //Header and Footer
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
while (x < len) { char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16); filestr.write(header,sizeof(header));
temp = li;
filestr.write(temp.c_str(),1); int c = 0;
x +=2; while (c != cnt) {
} int actnr = nr[c];
c++; string buf = getCheat(actnr);
} long int li;
int len = buf.size();
filestr.write(footer,sizeof(footer)); int x = 0;
filestr.close();
return 1; while (x < len) {
} string temp = buf.substr(x,2);
li = strtol(temp.c_str(),NULL,16);
int GCTCheats::openTxtfile(const char * filename) { temp = li;
ifstream filestr; filestr.write(temp.c_str(),1);
int i = 0; x +=2;
string str; }
filestr.open(filename); c++;
}
if (filestr.fail())
return 0; filestr.write(footer,sizeof(footer));
filestr.close();
filestr.seekg(0,ios_base::end); return 1;
int size = filestr.tellg(); }
if (size <= 0) return -1;
filestr.seekg(0,ios_base::beg); int GCTCheats::openTxtfile(const char * filename) {
ifstream filestr;
getline(filestr,sGameID); int i = 0;
getline(filestr,sGameTitle); string str;
filestr.ignore(); filestr.open(filename);
while (!filestr.eof()) { if (filestr.fail())
getline(filestr,sCheatName[i]); return 0;
string cheatdata;
bool emptyline = false; filestr.seekg(0,ios_base::end);
bool isComment = false; int size = filestr.tellg();
if (size <= 0) return -1;
do { filestr.seekg(0,ios_base::beg);
getline(filestr,str,'\n');
//cheatdata.append(str); getline(filestr,sGameID);
getline(filestr,sGameTitle);
if (str == "") { filestr.ignore();
emptyline = true;
break; while (!filestr.eof()) {
} getline(filestr,sCheatName[i]);
string cheatdata;
if (str.size() <= 16 || str.size() > 17 ) { bool emptyline = false;
isComment = true; bool isComment = false;
printf ("%i",str.size());
} do {
getline(filestr,str,'\n');
if (!isComment) { //cheatdata.append(str);
cheatdata.append(str);
size_t found=cheatdata.find(' '); if (str == "") {
cheatdata.replace(found,1,""); emptyline = true;
} else { break;
sCheatComment[i] = str; }
}
if (str.size() <= 16 || str.size() > 17 ) {
if (filestr.eof()) break; isComment = true;
} while (!emptyline); printf ("%i",str.size());
}
sCheats[i] = cheatdata;
i++; if (!isComment) {
} cheatdata.append(str);
iCntCheats = i; size_t found=cheatdata.find(' ');
filestr.close(); cheatdata.replace(found,1,"");
return 1; } else {
} sCheatComment[i] = str;
}
/*int GCTCheats::openTxtfile(const char * filename) if (filestr.eof()) break;
{ } while (!emptyline);
ifstream filestr;
int i = 0; sCheats[i] = cheatdata;
string str; i++;
filestr.open(filename); }
iCntCheats = i;
if (filestr.fail()) filestr.close();
return 0; return 1;
}
filestr.seekg(0,ios_base::end);
int size = filestr.tellg();
if (size <= 0) return -1;
filestr.seekg(0,ios_base::beg);
getline(filestr,sGameID);
getline(filestr,sGameTitle);
filestr.ignore();
while(!filestr.eof())
{
getline(filestr,sCheatName[i]);
string cheatdata;
bool emptyline = false;
do
{
getline(filestr,str,'\n');
cheatdata.append(str);
if (str == "")
{
emptyline = true;
break;
}
size_t found=cheatdata.find(' ');
cheatdata.replace(found,1,"");
if (filestr.eof()) break;
} while(!emptyline);
sCheats[i] = cheatdata;
i++;
}
iCntCheats = i;
filestr.close();
return 1;
}*/
struct GCTCheats::chtentries GCTCheats::getCheatList(void) {
struct GCTCheats::chtentries cheatlist;
int i = 0;
cheatlist.sGameID = sGameID;
cheatlist.sGameTitle = sGameTitle;
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
}
return cheatlist;
}
struct GCTCheats::chtentries GCTCheats::getCheatList(const char * filename) {
openTxtfile(filename);
struct GCTCheats::chtentries cheatlist;
int i = 0;
cheatlist.sGameID = sGameID;
cheatlist.sGameTitle = sGameTitle;
cheatlist.iCntCheats = iCntCheats;
while (i < iCntCheats) {
cheatlist.sCheatName[i] = sCheatName[i];
cheatlist.sCheats[i] = sCheats[i];
i++;
}
return cheatlist;
}
int GCTCheats::download_txtcheat(int id) {
//ToDo
return 1;
}

View File

@ -1,103 +1,71 @@
/* /*
* gct.h * gct.h
* Class to handle Ocarina TXT Cheatfiles * Class to handle Ocarina TXT Cheatfiles
* WIP: Actually it´s needed to call fatInitDefault() or the file will not be found *
* and no Comments supported for now */
*/
#ifndef _GCT_H
#ifndef _GCT_H #define _GCT_H
#define _GCT_H
#include <sstream>
#include <sstream>
#define MAXCHEATS 40
#define MAXCHEATS 40
using namespace std;
using namespace std;
//!Handles Ocarina TXT Cheatfiles
struct chtentrie { class GCTCheats {
string sGameID; private:
string sGameTitle; string sGameID;
string sCheatName[MAXCHEATS]; string sGameTitle;
string sCheats[MAXCHEATS]; string sCheatName[MAXCHEATS];
string sCheatComment[MAXCHEATS]; string sCheats[MAXCHEATS];
int iCntCheats; string sCheatComment[MAXCHEATS];
}; int iCntCheats;
//!Handles Ocarina TXT Cheatfiles public:
class GCTCheats { //!Constructor
private: GCTCheats(void);
chtentrie ccc; //!Destructor
string sGameID; ~GCTCheats(void);
string sGameTitle; //!Open txt file with cheats
string sCheatName[MAXCHEATS]; //!\param filename name of TXT file
string sCheats[MAXCHEATS]; //!\return error code
string sCheatComment[MAXCHEATS]; int openTxtfile(const char * filename);
int iCntCheats; //!Creates GCT file for one cheat
//!\param nr selected Cheat Numbers
public: //!\param filename name of GCT file
//!\return error code
struct chtentries { int createGCT(int nr,const char * filename);
string sGameID; //!Creates GCT file from a buffer
string sGameTitle; //!\param chtbuffer buffer that holds the cheat data
string sCheatName[MAXCHEATS]; //!\param filename name of GCT file
string sCheats[MAXCHEATS]; //!\return error code
int iCntCheats; int createGCT(const char * chtbuffer,const char * filename);
}; //!Creates GCT file
//!\param nr[] array of selected Cheat Numbers
//!Constructor //!\param cnt size of array
GCTCheats(void); //!\param filename name of GCT file
//!Destructor //!\return error code
~GCTCheats(void); int createGCT(int nr[],int cnt,const char * filename);
//!Open txt file with cheats //!Gets Count cheats
//!\param filename name of TXT file //!\return Count cheats
//!\return error code int getCnt();
int openTxtfile(const char * filename); //!Gets Game Name
//!Creates GCT file for one cheat //!\return Game Name
//!\param nr selected Cheat Numbers string getGameName(void);
//!\param filename name of GCT file //!Gets GameID
//!\return error code //!\return GameID
int createGCT(int nr,const char * filename); string getGameID(void);
//!Creates GCT file from a buffer //!Gets cheat data
//!\param chtbuffer buffer that holds the cheat data //!\return cheat data
//!\param filename name of GCT file string getCheat(int nr);
//!\return error code //!Gets Cheat Name
int createGCT(const char * chtbuffer,const char * filename); //!\return Cheat Name
//!Creates GCT file string getCheatName(int nr);
//!\param nr[] array of selected Cheat Numbers //!Gets Cheat Comment
//!\param cnt size of array //!\return Cheat Comment
//!\param filename name of GCT file string getCheatComment(int nr);
//!\return error code };
int createGCT(int nr[],int cnt,const char * filename);
//!Gets Count cheats #endif /* _GCT_H */
//!\return Count cheats
int getCnt();
//!Gets Game Name
//!\return Game Name
string getGameName(void);
//!Gets GameID
//!\return GameID
string getGameID(void);
//!Gets cheat data
//!\return cheat data
string getCheat(int nr);
//!Gets Cheat Name
//!\return Cheat Name
string getCheatName(int nr);
//!Gets Cheat Comment
//!\return Cheat Comment
string getCheatComment(int nr);
//!Gets Cheat List
//!\return struct chtentrie
//struct chtentrie getCheatList2(void);
//!Gets Cheat List
//!\return struct chtentries
struct chtentries getCheatList(void);
//!Gets Cheat List from file
//!\param filename name of TXT file
//!\return struct chtentries
struct chtentries getCheatList(const char * filename);
int download_txtcheat(int id);
};
#endif /* _GCT_H */

View File

@ -1,144 +1,144 @@
#include <gccore.h> #include <gccore.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <ogc/machine/processor.h> #include <ogc/machine/processor.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "fatmounter.h" #include "fatmounter.h"
#include "dolloader.h" #include "dolloader.h"
#include "elfloader.h" #include "elfloader.h"
void *innetbuffer = NULL; void *innetbuffer = NULL;
int AllocHomebrewMemory(u32 filesize) { int AllocHomebrewMemory(u32 filesize) {
innetbuffer = malloc(filesize); innetbuffer = malloc(filesize);
if (!innetbuffer) if (!innetbuffer)
return -1; return -1;
return 1; return 1;
} }
void FreeHomebrewBuffer() { void FreeHomebrewBuffer() {
free(innetbuffer); free(innetbuffer);
innetbuffer = NULL; innetbuffer = NULL;
} }
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) { void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
memcpy(((u8 *) innetbuffer)+read, temp, len); memcpy(((u8 *) innetbuffer)+read, temp, len);
} }
int BootHomebrew(char * path) { int BootHomebrew(char * path) {
void *buffer = NULL; void *buffer = NULL;
u32 filesize = 0; u32 filesize = 0;
entrypoint entry; entrypoint entry;
u32 cpu_isr; u32 cpu_isr;
FILE * file = fopen(path, "rb"); FILE * file = fopen(path, "rb");
if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
fseek (file, 0, SEEK_END); fseek (file, 0, SEEK_END);
filesize = ftell(file); filesize = ftell(file);
rewind(file); rewind(file);
buffer = malloc(filesize); buffer = malloc(filesize);
if (fread (buffer, 1, filesize, file) != filesize) { if (fread (buffer, 1, filesize, file) != filesize) {
fclose (file); fclose (file);
free(buffer); free(buffer);
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
fclose (file); fclose (file);
struct __argv args; struct __argv args;
bzero(&args, sizeof(args)); bzero(&args, sizeof(args));
args.argvMagic = ARGV_MAGIC; args.argvMagic = ARGV_MAGIC;
args.length = strlen(path) + 2; args.length = strlen(path) + 2;
args.commandLine = (char*)malloc(args.length); args.commandLine = (char*)malloc(args.length);
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
strcpy(args.commandLine, path); strcpy(args.commandLine, path);
args.commandLine[args.length - 1] = '\0'; args.commandLine[args.length - 1] = '\0';
args.argc = 1; args.argc = 1;
args.argv = &args.commandLine; args.argv = &args.commandLine;
args.endARGV = args.argv + 1; args.endARGV = args.argv + 1;
int ret = valid_elf_image(buffer); int ret = valid_elf_image(buffer);
if (ret == 1) if (ret == 1)
entry = (entrypoint) load_elf_image(buffer); entry = (entrypoint) load_elf_image(buffer);
else else
entry = (entrypoint) load_dol(buffer, &args); entry = (entrypoint) load_dol(buffer, &args);
free(buffer); free(buffer);
if (!entry) { if (!entry) {
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
WPAD_Flush(0); WPAD_Flush(0);
WPAD_Disconnect(0); WPAD_Disconnect(0);
WPAD_Shutdown(); WPAD_Shutdown();
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable (cpu_isr); _CPU_ISR_Disable (cpu_isr);
__exception_closeall(); __exception_closeall();
entry(); entry();
_CPU_ISR_Restore (cpu_isr); _CPU_ISR_Restore (cpu_isr);
return 0; return 0;
} }
int BootHomebrewFromMem() { int BootHomebrewFromMem() {
entrypoint entry; entrypoint entry;
u32 cpu_isr; u32 cpu_isr;
if (!innetbuffer) { if (!innetbuffer) {
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
struct __argv args; struct __argv args;
int ret = valid_elf_image(innetbuffer); int ret = valid_elf_image(innetbuffer);
if (ret == 1) if (ret == 1)
entry = (entrypoint) load_elf_image(innetbuffer); entry = (entrypoint) load_elf_image(innetbuffer);
else else
entry = (entrypoint) load_dol(innetbuffer, &args); entry = (entrypoint) load_dol(innetbuffer, &args);
free(innetbuffer); free(innetbuffer);
if (!entry) { if (!entry) {
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
SDCard_deInit(); SDCard_deInit();
USBDevice_deInit(); USBDevice_deInit();
WPAD_Flush(0); WPAD_Flush(0);
WPAD_Disconnect(0); WPAD_Disconnect(0);
WPAD_Shutdown(); WPAD_Shutdown();
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0); SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
_CPU_ISR_Disable (cpu_isr); _CPU_ISR_Disable (cpu_isr);
__exception_closeall(); __exception_closeall();
entry(); entry();
_CPU_ISR_Restore (cpu_isr); _CPU_ISR_Restore (cpu_isr);
return 0; return 0;
} }

View File

@ -322,7 +322,6 @@ int MenuHomebrewBrowse() {
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
/*** XML Variables ***/ /*** XML Variables ***/
HomebrewXML XMLInfo[4]; HomebrewXML XMLInfo[4];

View File

@ -1,132 +1,132 @@
/**************************************************************************** /****************************************************************************
* URL List Class * URL List Class
* for USB Loader GX * for USB Loader GX
* by dimok * by dimok
***************************************************************************/ ***************************************************************************/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <gctypes.h> #include <gctypes.h>
#include "URL_List.h" #include "URL_List.h"
URL_List::URL_List(const char * url) { URL_List::URL_List(const char * url) {
Links = NULL; Links = NULL;
urlcount = 0; urlcount = 0;
if (!IsNetworkInit()) { if (!IsNetworkInit()) {
urlcount = -1; urlcount = -1;
return; return;
} }
struct block file = downloadfile(url); struct block file = downloadfile(url);
if (!file.data || !file.size) { if (!file.data || !file.size) {
urlcount = -2; urlcount = -2;
return; return;
} }
u32 cnt = 0; u32 cnt = 0;
char temp[1024]; char temp[1024];
Links = (Link_Info *) malloc(sizeof(Link_Info)); Links = (Link_Info *) malloc(sizeof(Link_Info));
if (!Links) { if (!Links) {
free(file.data); free(file.data);
urlcount = -3; urlcount = -3;
return; return;
} }
memset(&Links[urlcount], 0, sizeof(Link_Info)); memset(&Links[urlcount], 0, sizeof(Link_Info));
while (cnt < file.size) { while (cnt < file.size) {
if (file.data[cnt] == '"' && file.data[cnt-1] == '=' && file.data[cnt-2] == 'f' if (file.data[cnt] == '"' && file.data[cnt-1] == '=' && file.data[cnt-2] == 'f'
&& file.data[cnt-3] == 'e' && file.data[cnt-4] == 'r' && file.data[cnt-5] == 'h') { && file.data[cnt-3] == 'e' && file.data[cnt-4] == 'r' && file.data[cnt-5] == 'h') {
u32 cnt2 = 0; u32 cnt2 = 0;
cnt++; cnt++;
while (file.data[cnt] != '"' && cnt2 < 1024) { while (file.data[cnt] != '"' && cnt2 < 1024) {
temp[cnt2] = file.data[cnt]; temp[cnt2] = file.data[cnt];
cnt2++; cnt2++;
cnt++; cnt++;
} }
temp[cnt2] = '\0'; temp[cnt2] = '\0';
Links = (Link_Info *) realloc(Links, (urlcount+1)*sizeof(Link_Info)); Links = (Link_Info *) realloc(Links, (urlcount+1)*sizeof(Link_Info));
if (!Links) { if (!Links) {
for (int i = 0; i == urlcount; i++) { for (int i = 0; i == urlcount; i++) {
delete Links[i].URL; delete Links[i].URL;
Links[i].URL = NULL; Links[i].URL = NULL;
} }
free(Links); free(Links);
Links = NULL; Links = NULL;
free(file.data); free(file.data);
urlcount = -4; urlcount = -4;
break; break;
} }
memset(&(Links[urlcount]), 0, sizeof(Link_Info)); memset(&(Links[urlcount]), 0, sizeof(Link_Info));
Links[urlcount].URL = new char[cnt2+1]; Links[urlcount].URL = new char[cnt2+1];
if (!Links[urlcount].URL) { if (!Links[urlcount].URL) {
for (int i = 0; i == urlcount; i++) { for (int i = 0; i == urlcount; i++) {
delete Links[i].URL; delete Links[i].URL;
Links[i].URL = NULL; Links[i].URL = NULL;
} }
free(Links); free(Links);
Links = NULL; Links = NULL;
free(file.data); free(file.data);
urlcount = -5; urlcount = -5;
break; break;
} }
snprintf(Links[urlcount].URL, cnt2+1, "%s", temp); snprintf(Links[urlcount].URL, cnt2+1, "%s", temp);
if (strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0) if (strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0)
Links[urlcount].direct = false; Links[urlcount].direct = false;
else else
Links[urlcount].direct = true; Links[urlcount].direct = true;
urlcount++; urlcount++;
} }
cnt++; cnt++;
} }
free(file.data); free(file.data);
} }
URL_List::~URL_List() { URL_List::~URL_List() {
for (int i = 0; i == urlcount; i++) { for (int i = 0; i == urlcount; i++) {
delete Links[i].URL; delete Links[i].URL;
Links[i].URL = NULL; Links[i].URL = NULL;
} }
if (Links != NULL) { if (Links != NULL) {
free(Links); free(Links);
Links = NULL; Links = NULL;
} }
} }
char * URL_List::GetURL(int ind) { char * URL_List::GetURL(int ind) {
if (ind > urlcount || ind < 0 || !Links || urlcount <= 0) if (ind > urlcount || ind < 0 || !Links || urlcount <= 0)
return NULL; return NULL;
else else
return Links[ind].URL; return Links[ind].URL;
} }
int URL_List::GetURLCount() { int URL_List::GetURLCount() {
return urlcount; return urlcount;
} }
static int ListCompare(const void *a, const void *b) { static int ListCompare(const void *a, const void *b) {
Link_Info *ab = (Link_Info*) a; Link_Info *ab = (Link_Info*) a;
Link_Info *bb = (Link_Info*) b; Link_Info *bb = (Link_Info*) b;
return stricmp((char *) ab->URL, (char *) bb->URL); return stricmp((char *) ab->URL, (char *) bb->URL);
} }
void URL_List::SortList() { void URL_List::SortList() {
qsort(Links, urlcount, sizeof(Link_Info), ListCompare); qsort(Links, urlcount, sizeof(Link_Info), ListCompare);
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,98 +1,98 @@
/* /*
* Copyright (C) 2008 Nuke (wiinuke@gmail.com) * Copyright (C) 2008 Nuke (wiinuke@gmail.com)
* *
* this file is part of GeckoOS for USB Gecko * this file is part of GeckoOS for USB Gecko
* http://www.usbgecko.com * http://www.usbgecko.com
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <gccore.h> #include <gccore.h>
#include <malloc.h> #include <malloc.h>
#include <sys/unistd.h> #include <sys/unistd.h>
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#include <ogc/ipc.h> #include <ogc/ipc.h>
#include "settings/cfg.h" #include "settings/cfg.h"
#include "fst.h" #include "fst.h"
#include "dvd_broadway.h" #include "dvd_broadway.h"
#include "wpad.h" #include "wpad.h"
#include "fatmounter.h" #include "fatmounter.h"
extern struct SSettings Settings; extern struct SSettings Settings;
u32 do_sd_code(char *filename) { u32 do_sd_code(char *filename) {
FILE *fp; FILE *fp;
u8 *filebuff; u8 *filebuff;
u32 filesize; u32 filesize;
u32 ret; u32 ret;
char filepath[150]; char filepath[150];
SDCard_Init(); SDCard_Init();
USBDevice_Init(); USBDevice_Init();
sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename); sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename);
filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E; filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E;
filepath[strlen(Settings.Cheatcodespath)+7] = 0x67; filepath[strlen(Settings.Cheatcodespath)+7] = 0x67;
filepath[strlen(Settings.Cheatcodespath)+8] = 0x63; filepath[strlen(Settings.Cheatcodespath)+8] = 0x63;
filepath[strlen(Settings.Cheatcodespath)+9] = 0x74; filepath[strlen(Settings.Cheatcodespath)+9] = 0x74;
filepath[strlen(Settings.Cheatcodespath)+10] = 0; filepath[strlen(Settings.Cheatcodespath)+10] = 0;
fp = fopen(filepath, "rb"); fp = fopen(filepath, "rb");
if (!fp) { if (!fp) {
USBDevice_deInit(); USBDevice_deInit();
SDCard_deInit(); SDCard_deInit();
return 0; return 0;
} }
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
filesize = ftell(fp); filesize = ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
filebuff = (u8*) malloc (filesize); filebuff = (u8*) malloc (filesize);
if (filebuff == 0) { if (filebuff == 0) {
fclose(fp); fclose(fp);
sleep(2); sleep(2);
USBDevice_deInit(); USBDevice_deInit();
SDCard_deInit(); SDCard_deInit();
return 0; return 0;
} }
ret = fread(filebuff, 1, filesize, fp); ret = fread(filebuff, 1, filesize, fp);
if (ret != filesize) { if (ret != filesize) {
free(filebuff); free(filebuff);
fclose(fp); fclose(fp);
USBDevice_deInit(); USBDevice_deInit();
SDCard_deInit(); SDCard_deInit();
return 0; return 0;
} }
memcpy((void*)0x800027E8,filebuff,filesize); memcpy((void*)0x800027E8,filebuff,filesize);
*(vu8*)0x80001807 = 0x01; *(vu8*)0x80001807 = 0x01;
free(filebuff); free(filebuff);
fclose(fp); fclose(fp);
USBDevice_deInit(); USBDevice_deInit();
SDCard_deInit(); SDCard_deInit();
return 1; return 1;
} }

View File

@ -1,225 +1,224 @@
#include <ogcsys.h> #include <ogcsys.h>
#include <stdio.h> #include <stdio.h>
#include <gccore.h> #include <gccore.h>
#include <string.h> #include <string.h>
#include <malloc.h> #include <malloc.h>
#include "fatmounter.h" #include "fatmounter.h"
#include "apploader.h" #include "apploader.h"
#include "wdvd.h" #include "wdvd.h"
#include "fstfile.h" #include "fstfile.h"
/** Alternate dolloader made by WiiPower modified by dimok **/ /** Alternate dolloader made by WiiPower modified by dimok **/
bool Load_Dol(void **buffer, int* dollen, char * filepath) {
bool Load_Dol(void **buffer, int* dollen, char * filepath) { int ret;
int ret; FILE* file;
FILE* file; void* dol_buffer;
void* dol_buffer;
char fullpath[200];
char fullpath[200]; char gameidbuffer6[7];
char gameidbuffer6[7]; memset(gameidbuffer6, 0, 7);
memset(gameidbuffer6, 0, 7); memcpy(gameidbuffer6, (char*)0x80000000, 6);
memcpy(gameidbuffer6, (char*)0x80000000, 6); snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6);
snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6);
SDCard_Init();
SDCard_Init(); USBDevice_Init();
USBDevice_Init();
file = fopen(fullpath, "rb");
file = fopen(fullpath, "rb");
if (file == NULL) {
if (file == NULL) { fclose(file);
fclose(file); SDCard_deInit();
SDCard_deInit(); USBDevice_deInit();
USBDevice_deInit(); return false;
return false; }
}
int filesize;
int filesize; fseek(file, 0, SEEK_END);
fseek(file, 0, SEEK_END); filesize = ftell(file);
filesize = ftell(file); fseek(file, 0, SEEK_SET);
fseek(file, 0, SEEK_SET);
dol_buffer = malloc(filesize);
dol_buffer = malloc(filesize); if (dol_buffer == NULL) {
if (dol_buffer == NULL) { fclose(file);
fclose(file); SDCard_deInit();
SDCard_deInit(); USBDevice_deInit();
USBDevice_deInit(); return false;
return false; }
} ret = fread( dol_buffer, 1, filesize, file);
ret = fread( dol_buffer, 1, filesize, file); if (ret != filesize) {
if (ret != filesize) { free(dol_buffer);
free(dol_buffer); fclose(file);
fclose(file); SDCard_deInit();
SDCard_deInit(); USBDevice_deInit();
USBDevice_deInit(); return false;
return false; }
} fclose(file);
fclose(file);
SDCard_deInit();
SDCard_deInit(); USBDevice_deInit();
USBDevice_deInit(); *buffer = dol_buffer;
*buffer = dol_buffer; *dollen = filesize;
*dollen = filesize; return true;
return true; }
}
bool Remove_001_Protection(void *Address, int Size) {
bool Remove_001_Protection(void *Address, int Size) { u8 SearchPattern[16] = { 0x40, 0x82, 0x00, 0x0C, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
u8 SearchPattern[16] = { 0x40, 0x82, 0x00, 0x0C, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 }; u8 PatchData[16] = { 0x40, 0x82, 0x00, 0x04, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
u8 PatchData[16] = { 0x40, 0x82, 0x00, 0x04, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
void *Addr = Address;
void *Addr = Address; void *Addr_end = Address+Size;
void *Addr_end = Address+Size;
while (Addr <= Addr_end-sizeof(SearchPattern)) {
while (Addr <= Addr_end-sizeof(SearchPattern)) { if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) {
if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) { memcpy(Addr,PatchData,sizeof(PatchData));
memcpy(Addr,PatchData,sizeof(PatchData)); return true;
return true; }
} Addr += 4;
Addr += 4; }
} return false;
return false; }
}
typedef struct _dolheader {
typedef struct _dolheader { u32 text_pos[7];
u32 text_pos[7]; u32 data_pos[11];
u32 data_pos[11]; u32 text_start[7];
u32 text_start[7]; u32 data_start[11];
u32 data_start[11]; u32 text_size[7];
u32 text_size[7]; u32 data_size[11];
u32 data_size[11]; u32 bss_start;
u32 bss_start; u32 bss_size;
u32 bss_size; u32 entry_point;
u32 entry_point; } dolheader;
} dolheader;
static dolheader *dolfile;
static dolheader *dolfile;
u32 load_dol_image(void *dolstart) {
u32 load_dol_image(void *dolstart) {
u32 i;
u32 i;
if (dolstart) {
if (dolstart) { dolfile = (dolheader *) dolstart;
dolfile = (dolheader *) dolstart; for (i = 0; i < 7; i++) {
for (i = 0; i < 7; i++) { if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue; VIDEO_WaitVSync();
VIDEO_WaitVSync(); ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]);
ICInvalidateRange ((void *) dolfile->text_start[i],dolfile->text_size[i]); memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]);
memmove ((void *) dolfile->text_start[i],dolstart+dolfile->text_pos[i],dolfile->text_size[i]); }
}
for (i = 0; i < 11; i++) {
for (i = 0; i < 11; i++) { if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue; VIDEO_WaitVSync();
VIDEO_WaitVSync(); memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]);
memmove ((void *) dolfile->data_start[i],dolstart+dolfile->data_pos[i],dolfile->data_size[i]); DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]);
DCFlushRangeNoSync ((void *) dolfile->data_start[i],dolfile->data_size[i]); }
} /*
/* memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size); DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size); */
*/ return dolfile->entry_point;
return dolfile->entry_point; }
} return 0;
return 0; }
}
static int i;
static int i; static int phase;
static int phase;
u32 load_dol_start(void *dolstart) {
u32 load_dol_start(void *dolstart) { if (dolstart) {
if (dolstart) { dolfile = (dolheader *)dolstart;
dolfile = (dolheader *)dolstart; return dolfile->entry_point;
return dolfile->entry_point; } else {
} else { return 0;
return 0; }
}
memset((void *)dolfile->bss_start, 0, dolfile->bss_size);
memset((void *)dolfile->bss_start, 0, dolfile->bss_size); DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size);
DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size);
phase = 0;
phase = 0; i = 0;
i = 0; }
}
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len) {
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len) { if (phase == 0) {
if (phase == 0) { if (i == 7) {
if (i == 7) { phase = 1;
phase = 1; i = 0;
i = 0; } else {
} else { if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) {
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) { *offset = 0;
*offset = 0; *pos = 0;
*pos = 0; *len = 0;
*len = 0; } else {
} else { *offset = (void *)dolfile->text_start[i];
*offset = (void *)dolfile->text_start[i]; *pos = dolfile->text_pos[i];
*pos = dolfile->text_pos[i]; *len = dolfile->text_size[i];
*len = dolfile->text_size[i]; }
} i++;
i++; return true;
return true; }
} }
}
if (phase == 1) {
if (phase == 1) { if (i == 11) {
if (i == 11) { phase = 2;
phase = 2; return false;
return false; }
}
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) {
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) { *offset = 0;
*offset = 0; *pos = 0;
*pos = 0; *len = 0;
*len = 0; } else {
} else { *offset = (void *)dolfile->data_start[i];
*offset = (void *)dolfile->data_start[i]; *pos = dolfile->data_pos[i];
*pos = dolfile->data_pos[i]; *len = dolfile->data_size[i];
*len = dolfile->data_size[i]; }
} i++;
i++; return true;
return true; }
} return false;
return false; }
}
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) { int ret;
int ret; void *dol_header;
void *dol_header; u32 entrypoint;
u32 entrypoint;
dol_header = memalign(32, sizeof(dolheader));
dol_header = memalign(32, sizeof(dolheader)); if (dol_header == NULL) {
if (dol_header == NULL) { return -1;
return -1; }
}
ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2));
ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2));
entrypoint = load_dol_start(dol_header);
entrypoint = load_dol_start(dol_header);
if (entrypoint == 0) {
if (entrypoint == 0) { free(dol_header);
free(dol_header); return -1;
return -1; }
}
void *offset;
void *offset; u32 pos;
u32 pos; u32 len;
u32 len;
while (load_dol_image_modified(&offset, &pos, &len)) {
while (load_dol_image_modified(&offset, &pos, &len)) { if (len != 0) {
if (len != 0) { ret = WDVD_Read(offset, len, (doloffset<<2) + pos);
ret = WDVD_Read(offset, len, (doloffset<<2) + pos);
DCFlushRange(offset, len);
DCFlushRange(offset, len);
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch);
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch);
DCFlushRange(offset, len);
DCFlushRange(offset, len);
Remove_001_Protection(offset, len);
Remove_001_Protection(offset, len); }
} }
}
free(dol_header);
free(dol_header);
return entrypoint;
return entrypoint; }
}

View File

@ -1,28 +1,28 @@
#include <stdio.h> #include <stdio.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <string.h> #include <string.h>
#include "patches/patchcode.h" #include "patches/patchcode.h"
#include "patches/kenobiwii.h" /*FISHEARS*/ #include "patches/kenobiwii.h" /*FISHEARS*/
#include "apploader.h" #include "apploader.h"
#include "wdvd.h" #include "wdvd.h"
#include "wpad.h" #include "wpad.h"
#include "disc.h" #include "disc.h"
#include "alternatedol.h" #include "alternatedol.h"
#include "fstfile.h" #include "fstfile.h"
#include "settings/cfg.h" #include "settings/cfg.h"
/*KENOBI! - FISHEARS*/ /*KENOBI! - FISHEARS*/
extern const unsigned char kenobiwii[]; extern const unsigned char kenobiwii[];
extern const int kenobiwii_size; extern const int kenobiwii_size;
/*KENOBI! - FISHEARS*/ /*KENOBI! - FISHEARS*/
/* Apploader function pointers */ /* Apploader function pointers */
typedef int (*app_main)(void **dst, int *size, int *offset); typedef int (*app_main)(void **dst, int *size, int *offset);
typedef void (*app_init)(void (*report)(const char *fmt, ...)); typedef void (*app_init)(void (*report)(const char *fmt, ...));
typedef void *(*app_final)(); typedef void *(*app_final)();
typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)()); typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)());
/* Apploader pointers */ /* Apploader pointers */
static u8 *appldr = (u8 *)0x81200000; static u8 *appldr = (u8 *)0x81200000;
@ -46,330 +46,330 @@ bool compare_videomodes(GXRModeObj* mode1, GXRModeObj* mode2) {
mode1->sample_pattern[1][0] != mode2->sample_pattern[1][0] || mode1->sample_pattern[2][0] != mode2->sample_pattern[2][0] || mode1->sample_pattern[1][0] != mode2->sample_pattern[1][0] || mode1->sample_pattern[2][0] != mode2->sample_pattern[2][0] ||
mode1->sample_pattern[3][0] != mode2->sample_pattern[3][0] || mode1->sample_pattern[4][0] != mode2->sample_pattern[4][0] || mode1->sample_pattern[3][0] != mode2->sample_pattern[3][0] || mode1->sample_pattern[4][0] != mode2->sample_pattern[4][0] ||
mode1->sample_pattern[5][0] != mode2->sample_pattern[5][0] || mode1->sample_pattern[6][0] != mode2->sample_pattern[6][0] || mode1->sample_pattern[5][0] != mode2->sample_pattern[5][0] || mode1->sample_pattern[6][0] != mode2->sample_pattern[6][0] ||
mode1->sample_pattern[7][0] != mode2->sample_pattern[7][0] || mode1->sample_pattern[8][0] != mode2->sample_pattern[8][0] || mode1->sample_pattern[7][0] != mode2->sample_pattern[7][0] || mode1->sample_pattern[8][0] != mode2->sample_pattern[8][0] ||
mode1->sample_pattern[9][0] != mode2->sample_pattern[9][0] || mode1->sample_pattern[10][0] != mode2->sample_pattern[10][0] || mode1->sample_pattern[9][0] != mode2->sample_pattern[9][0] || mode1->sample_pattern[10][0] != mode2->sample_pattern[10][0] ||
mode1->sample_pattern[11][0] != mode2->sample_pattern[11][0] || mode1->sample_pattern[0][1] != mode2->sample_pattern[0][1] || mode1->sample_pattern[11][0] != mode2->sample_pattern[11][0] || mode1->sample_pattern[0][1] != mode2->sample_pattern[0][1] ||
mode1->sample_pattern[1][1] != mode2->sample_pattern[1][1] || mode1->sample_pattern[2][1] != mode2->sample_pattern[2][1] || mode1->sample_pattern[1][1] != mode2->sample_pattern[1][1] || mode1->sample_pattern[2][1] != mode2->sample_pattern[2][1] ||
mode1->sample_pattern[3][1] != mode2->sample_pattern[3][1] || mode1->sample_pattern[4][1] != mode2->sample_pattern[4][1] || mode1->sample_pattern[3][1] != mode2->sample_pattern[3][1] || mode1->sample_pattern[4][1] != mode2->sample_pattern[4][1] ||
mode1->sample_pattern[5][1] != mode2->sample_pattern[5][1] || mode1->sample_pattern[6][1] != mode2->sample_pattern[6][1] || mode1->sample_pattern[5][1] != mode2->sample_pattern[5][1] || mode1->sample_pattern[6][1] != mode2->sample_pattern[6][1] ||
mode1->sample_pattern[7][1] != mode2->sample_pattern[7][1] || mode1->sample_pattern[8][1] != mode2->sample_pattern[8][1] || mode1->sample_pattern[7][1] != mode2->sample_pattern[7][1] || mode1->sample_pattern[8][1] != mode2->sample_pattern[8][1] ||
mode1->sample_pattern[9][1] != mode2->sample_pattern[9][1] || mode1->sample_pattern[10][1] != mode2->sample_pattern[10][1] || mode1->sample_pattern[9][1] != mode2->sample_pattern[9][1] || mode1->sample_pattern[10][1] != mode2->sample_pattern[10][1] ||
mode1->sample_pattern[11][1] != mode2->sample_pattern[11][1] || mode1->vfilter[0] != mode2->vfilter[0] || mode1->sample_pattern[11][1] != mode2->sample_pattern[11][1] || mode1->vfilter[0] != mode2->vfilter[0] ||
mode1->vfilter[1] != mode2->vfilter[1] || mode1->vfilter[2] != mode2->vfilter[2] || mode1->vfilter[3] != mode2->vfilter[3] || mode1->vfilter[4] != mode2->vfilter[4] || mode1->vfilter[1] != mode2->vfilter[1] || mode1->vfilter[2] != mode2->vfilter[2] || mode1->vfilter[3] != mode2->vfilter[3] || mode1->vfilter[4] != mode2->vfilter[4] ||
mode1->vfilter[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] ) { mode1->vfilter[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] ) {
return false; return false;
} else { } else {
return true; return true;
} }
} }
void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) { void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) {
mode1->viTVMode = mode2->viTVMode; mode1->viTVMode = mode2->viTVMode;
mode1->fbWidth = mode2->fbWidth; mode1->fbWidth = mode2->fbWidth;
mode1->efbHeight = mode2->efbHeight; mode1->efbHeight = mode2->efbHeight;
mode1->xfbHeight = mode2->xfbHeight; mode1->xfbHeight = mode2->xfbHeight;
mode1->viXOrigin = mode2->viXOrigin; mode1->viXOrigin = mode2->viXOrigin;
mode1->viYOrigin = mode2->viYOrigin; mode1->viYOrigin = mode2->viYOrigin;
mode1->viWidth = mode2->viWidth; mode1->viWidth = mode2->viWidth;
mode1->viHeight = mode2->viHeight; mode1->viHeight = mode2->viHeight;
mode1->xfbMode = mode2->xfbMode; mode1->xfbMode = mode2->xfbMode;
mode1->field_rendering = mode2->field_rendering; mode1->field_rendering = mode2->field_rendering;
mode1->aa = mode2->aa; mode1->aa = mode2->aa;
mode1->sample_pattern[0][0] = mode2->sample_pattern[0][0]; mode1->sample_pattern[0][0] = mode2->sample_pattern[0][0];
mode1->sample_pattern[1][0] = mode2->sample_pattern[1][0]; mode1->sample_pattern[1][0] = mode2->sample_pattern[1][0];
mode1->sample_pattern[2][0] = mode2->sample_pattern[2][0]; mode1->sample_pattern[2][0] = mode2->sample_pattern[2][0];
mode1->sample_pattern[3][0] = mode2->sample_pattern[3][0]; mode1->sample_pattern[3][0] = mode2->sample_pattern[3][0];
mode1->sample_pattern[4][0] = mode2->sample_pattern[4][0]; mode1->sample_pattern[4][0] = mode2->sample_pattern[4][0];
mode1->sample_pattern[5][0] = mode2->sample_pattern[5][0]; mode1->sample_pattern[5][0] = mode2->sample_pattern[5][0];
mode1->sample_pattern[6][0] = mode2->sample_pattern[6][0]; mode1->sample_pattern[6][0] = mode2->sample_pattern[6][0];
mode1->sample_pattern[7][0] = mode2->sample_pattern[7][0]; mode1->sample_pattern[7][0] = mode2->sample_pattern[7][0];
mode1->sample_pattern[8][0] = mode2->sample_pattern[8][0]; mode1->sample_pattern[8][0] = mode2->sample_pattern[8][0];
mode1->sample_pattern[9][0] = mode2->sample_pattern[9][0]; mode1->sample_pattern[9][0] = mode2->sample_pattern[9][0];
mode1->sample_pattern[10][0] = mode2->sample_pattern[10][0]; mode1->sample_pattern[10][0] = mode2->sample_pattern[10][0];
mode1->sample_pattern[11][0] = mode2->sample_pattern[11][0]; mode1->sample_pattern[11][0] = mode2->sample_pattern[11][0];
mode1->sample_pattern[0][1] = mode2->sample_pattern[0][1]; mode1->sample_pattern[0][1] = mode2->sample_pattern[0][1];
mode1->sample_pattern[1][1] = mode2->sample_pattern[1][1]; mode1->sample_pattern[1][1] = mode2->sample_pattern[1][1];
mode1->sample_pattern[2][1] = mode2->sample_pattern[2][1]; mode1->sample_pattern[2][1] = mode2->sample_pattern[2][1];
mode1->sample_pattern[3][1] = mode2->sample_pattern[3][1]; mode1->sample_pattern[3][1] = mode2->sample_pattern[3][1];
mode1->sample_pattern[4][1] = mode2->sample_pattern[4][1]; mode1->sample_pattern[4][1] = mode2->sample_pattern[4][1];
mode1->sample_pattern[5][1] = mode2->sample_pattern[5][1]; mode1->sample_pattern[5][1] = mode2->sample_pattern[5][1];
mode1->sample_pattern[6][1] = mode2->sample_pattern[6][1]; mode1->sample_pattern[6][1] = mode2->sample_pattern[6][1];
mode1->sample_pattern[7][1] = mode2->sample_pattern[7][1]; mode1->sample_pattern[7][1] = mode2->sample_pattern[7][1];
mode1->sample_pattern[8][1] = mode2->sample_pattern[8][1]; mode1->sample_pattern[8][1] = mode2->sample_pattern[8][1];
mode1->sample_pattern[9][1] = mode2->sample_pattern[9][1]; mode1->sample_pattern[9][1] = mode2->sample_pattern[9][1];
mode1->sample_pattern[10][1] = mode2->sample_pattern[10][1]; mode1->sample_pattern[10][1] = mode2->sample_pattern[10][1];
mode1->sample_pattern[11][1] = mode2->sample_pattern[11][1]; mode1->sample_pattern[11][1] = mode2->sample_pattern[11][1];
mode1->vfilter[0] = mode2->vfilter[0]; mode1->vfilter[0] = mode2->vfilter[0];
mode1->vfilter[1] = mode2->vfilter[1]; mode1->vfilter[1] = mode2->vfilter[1];
mode1->vfilter[2] = mode2->vfilter[2]; mode1->vfilter[2] = mode2->vfilter[2];
mode1->vfilter[3] = mode2->vfilter[3]; mode1->vfilter[3] = mode2->vfilter[3];
mode1->vfilter[4] = mode2->vfilter[4]; mode1->vfilter[4] = mode2->vfilter[4];
mode1->vfilter[5] = mode2->vfilter[5]; mode1->vfilter[5] = mode2->vfilter[5];
mode1->vfilter[6] = mode2->vfilter[6]; mode1->vfilter[6] = mode2->vfilter[6];
} }
GXRModeObj* vmodes[] = { GXRModeObj* vmodes[] = {
&TVNtsc240Ds, &TVNtsc240Ds,
&TVNtsc240DsAa, &TVNtsc240DsAa,
&TVNtsc240Int, &TVNtsc240Int,
&TVNtsc240IntAa, &TVNtsc240IntAa,
&TVNtsc480IntDf, &TVNtsc480IntDf,
&TVNtsc480IntAa, &TVNtsc480IntAa,
&TVNtsc480Prog, &TVNtsc480Prog,
&TVMpal480IntDf, &TVMpal480IntDf,
&TVPal264Ds, &TVPal264Ds,
&TVPal264DsAa, &TVPal264DsAa,
&TVPal264Int, &TVPal264Int,
&TVPal264IntAa, &TVPal264IntAa,
&TVPal524IntAa, &TVPal524IntAa,
&TVPal528Int, &TVPal528Int,
&TVPal528IntDf, &TVPal528IntDf,
&TVPal574IntDfScale, &TVPal574IntDfScale,
&TVEurgb60Hz240Ds, &TVEurgb60Hz240Ds,
&TVEurgb60Hz240DsAa, &TVEurgb60Hz240DsAa,
&TVEurgb60Hz240Int, &TVEurgb60Hz240Int,
&TVEurgb60Hz240IntAa, &TVEurgb60Hz240IntAa,
&TVEurgb60Hz480Int, &TVEurgb60Hz480Int,
&TVEurgb60Hz480IntDf, &TVEurgb60Hz480IntDf,
&TVEurgb60Hz480IntAa, &TVEurgb60Hz480IntAa,
&TVEurgb60Hz480Prog, &TVEurgb60Hz480Prog,
&TVEurgb60Hz480ProgSoft, &TVEurgb60Hz480ProgSoft,
&TVEurgb60Hz480ProgAa &TVEurgb60Hz480ProgAa
}; };
GXRModeObj* PAL2NTSC[]={ GXRModeObj* PAL2NTSC[]={
&TVMpal480IntDf, &TVNtsc480IntDf, &TVMpal480IntDf, &TVNtsc480IntDf,
&TVPal264Ds, &TVNtsc240Ds, &TVPal264Ds, &TVNtsc240Ds,
&TVPal264DsAa, &TVNtsc240DsAa, &TVPal264DsAa, &TVNtsc240DsAa,
&TVPal264Int, &TVNtsc240Int, &TVPal264Int, &TVNtsc240Int,
&TVPal264IntAa, &TVNtsc240IntAa, &TVPal264IntAa, &TVNtsc240IntAa,
&TVPal524IntAa, &TVNtsc480IntAa, &TVPal524IntAa, &TVNtsc480IntAa,
&TVPal528Int, &TVNtsc480IntAa, &TVPal528Int, &TVNtsc480IntAa,
&TVPal528IntDf, &TVNtsc480IntDf, &TVPal528IntDf, &TVNtsc480IntDf,
&TVPal574IntDfScale, &TVNtsc480IntDf, &TVPal574IntDfScale, &TVNtsc480IntDf,
&TVEurgb60Hz240Ds, &TVNtsc240Ds, &TVEurgb60Hz240Ds, &TVNtsc240Ds,
&TVEurgb60Hz240DsAa, &TVNtsc240DsAa, &TVEurgb60Hz240DsAa, &TVNtsc240DsAa,
&TVEurgb60Hz240Int, &TVNtsc240Int, &TVEurgb60Hz240Int, &TVNtsc240Int,
&TVEurgb60Hz240IntAa, &TVNtsc240IntAa, &TVEurgb60Hz240IntAa, &TVNtsc240IntAa,
&TVEurgb60Hz480Int, &TVNtsc480IntAa, &TVEurgb60Hz480Int, &TVNtsc480IntAa,
&TVEurgb60Hz480IntDf, &TVNtsc480IntDf, &TVEurgb60Hz480IntDf, &TVNtsc480IntDf,
&TVEurgb60Hz480IntAa, &TVNtsc480IntAa, &TVEurgb60Hz480IntAa, &TVNtsc480IntAa,
&TVEurgb60Hz480Prog, &TVNtsc480Prog, &TVEurgb60Hz480Prog, &TVNtsc480Prog,
&TVEurgb60Hz480ProgSoft,&TVNtsc480Prog, &TVEurgb60Hz480ProgSoft,&TVNtsc480Prog,
&TVEurgb60Hz480ProgAa, &TVNtsc480Prog, &TVEurgb60Hz480ProgAa, &TVNtsc480Prog,
0,0 0,0
}; };
GXRModeObj* NTSC2PAL[]={ GXRModeObj* NTSC2PAL[]={
&TVNtsc240Ds, &TVPal264Ds, &TVNtsc240Ds, &TVPal264Ds,
&TVNtsc240DsAa, &TVPal264DsAa, &TVNtsc240DsAa, &TVPal264DsAa,
&TVNtsc240Int, &TVPal264Int, &TVNtsc240Int, &TVPal264Int,
&TVNtsc240IntAa, &TVPal264IntAa, &TVNtsc240IntAa, &TVPal264IntAa,
&TVNtsc480IntDf, &TVPal528IntDf, &TVNtsc480IntDf, &TVPal528IntDf,
&TVNtsc480IntAa, &TVPal524IntAa, &TVNtsc480IntAa, &TVPal524IntAa,
&TVNtsc480Prog, &TVPal528IntDf, &TVNtsc480Prog, &TVPal528IntDf,
0,0 0,0
}; };
GXRModeObj* NTSC2PAL60[]={ GXRModeObj* NTSC2PAL60[]={
&TVNtsc240Ds, &TVEurgb60Hz240Ds, &TVNtsc240Ds, &TVEurgb60Hz240Ds,
&TVNtsc240DsAa, &TVEurgb60Hz240DsAa, &TVNtsc240DsAa, &TVEurgb60Hz240DsAa,
&TVNtsc240Int, &TVEurgb60Hz240Int, &TVNtsc240Int, &TVEurgb60Hz240Int,
&TVNtsc240IntAa, &TVEurgb60Hz240IntAa, &TVNtsc240IntAa, &TVEurgb60Hz240IntAa,
&TVNtsc480IntDf, &TVEurgb60Hz480IntDf, &TVNtsc480IntDf, &TVEurgb60Hz480IntDf,
&TVNtsc480IntAa, &TVEurgb60Hz480IntAa, &TVNtsc480IntAa, &TVEurgb60Hz480IntAa,
&TVNtsc480Prog, &TVEurgb60Hz480Prog, &TVNtsc480Prog, &TVEurgb60Hz480Prog,
0,0 0,0
}; };
bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) { bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) {
u8 *Addr = (u8 *)Address; u8 *Addr = (u8 *)Address;
bool found = 0; bool found = 0;
u32 i; u32 i;
while (Size >= sizeof(GXRModeObj)) { while (Size >= sizeof(GXRModeObj)) {
for (i = 0; Table[i]; i+=2) { for (i = 0; Table[i]; i+=2) {
if (compare_videomodes(Table[i], (GXRModeObj*)Addr)) if (compare_videomodes(Table[i], (GXRModeObj*)Addr))
{ {
found = 1; found = 1;
patch_videomode((GXRModeObj*)Addr, Table[i+1]); patch_videomode((GXRModeObj*)Addr, Table[i+1]);
Addr += (sizeof(GXRModeObj)-4); Addr += (sizeof(GXRModeObj)-4);
Size -= (sizeof(GXRModeObj)-4); Size -= (sizeof(GXRModeObj)-4);
break; break;
} }
} }
Addr += 4; Addr += 4;
Size -= 4; Size -= 4;
} }
return found; return found;
} }
/** Anti 002 fix for IOS 249 rev < 12 thanks to WiiPower **/ /** Anti 002 fix for IOS 249 rev < 12 thanks to WiiPower **/
void Anti_002_fix(void *Address, int Size) { void Anti_002_fix(void *Address, int Size) {
u8 SearchPattern[12] = { 0x2C, 0x00, 0x00, 0x00, 0x48, 0x00, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 }; 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 }; u8 PatchData[12] = { 0x2C, 0x00, 0x00, 0x00, 0x40, 0x82, 0x02, 0x14, 0x3C, 0x60, 0x80, 0x00 };
void *Addr = Address; void *Addr = Address;
void *Addr_end = Address+Size; void *Addr_end = Address+Size;
while (Addr <= Addr_end-sizeof(SearchPattern)) { while (Addr <= Addr_end-sizeof(SearchPattern)) {
if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) { if (memcmp(Addr, SearchPattern, sizeof(SearchPattern))==0) {
memcpy(Addr,PatchData,sizeof(PatchData)); memcpy(Addr,PatchData,sizeof(PatchData));
} }
Addr += 4; Addr += 4;
} }
} }
void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch) { void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
GXRModeObj** table = NULL; GXRModeObj** table = NULL;
if (videoSelected == 5) // patch if (videoSelected == 5) // patch
{ {
switch (CONF_GetVideo()) { switch (CONF_GetVideo()) {
case CONF_VIDEO_PAL: case CONF_VIDEO_PAL:
if (CONF_GetEuRGB60() > 0) { if (CONF_GetEuRGB60() > 0) {
table = NTSC2PAL60; table = NTSC2PAL60;
} else { } else {
table = NTSC2PAL; table = NTSC2PAL;
} }
break; break;
case CONF_VIDEO_MPAL: case CONF_VIDEO_MPAL:
table = NTSC2PAL; table = NTSC2PAL;
break; break;
default: default:
table = PAL2NTSC; table = PAL2NTSC;
break; break;
} }
Search_and_patch_Video_Modes(dst, len, table); Search_and_patch_Video_Modes(dst, len, table);
} }
/*GAME HOOK - FISHEARS*/ /*GAME HOOK - FISHEARS*/
dogamehooks(dst,len); dogamehooks(dst,len);
if (vipatch) if (vipatch)
vidolpatcher(dst,len); vidolpatcher(dst,len);
/*LANGUAGE PATCH - FISHEARS*/ /*LANGUAGE PATCH - FISHEARS*/
langpatcher(dst,len); langpatcher(dst,len);
/*Thanks to WiiPower*/ /*Thanks to WiiPower*/
if (patchcountrystring == 1) if (patchcountrystring == 1)
PatchCountryStrings(dst, len); PatchCountryStrings(dst, len);
//if(Settings.anti002fix == on) //if(Settings.anti002fix == on)
if (fix002 == 2) if (fix002 == 2)
Anti_002_fix(dst, len); Anti_002_fix(dst, len);
} }
s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) { s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8 patchcountrystring, u8 error002fix, u8 alternatedol, u32 alternatedoloffset) {
app_entry appldr_entry; app_entry appldr_entry;
app_init appldr_init; app_init appldr_init;
app_main appldr_main; app_main appldr_main;
app_final appldr_final; app_final appldr_final;
u32 appldr_len; u32 appldr_len;
s32 ret; s32 ret;
/* Read apploader header */ /* Read apploader header */
ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET); ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Calculate apploader length */ /* Calculate apploader length */
appldr_len = buffer[5] + buffer[6]; appldr_len = buffer[5] + buffer[6];
/* Read apploader code */ /* Read apploader code */
ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20); ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20);
if (ret < 0) if (ret < 0)
return ret; return ret;
/* Set apploader entry function */ /* Set apploader entry function */
appldr_entry = (app_entry)buffer[4]; appldr_entry = (app_entry)buffer[4];
/* Call apploader entry */ /* Call apploader entry */
appldr_entry(&appldr_init, &appldr_main, &appldr_final); appldr_entry(&appldr_init, &appldr_main, &appldr_final);
/* Initialize apploader */ /* Initialize apploader */
appldr_init(__noprint); appldr_init(__noprint);
if (error002fix!=0) { if (error002fix!=0) {
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/ /* ERROR 002 fix (thanks to WiiPower for sharing this)*/
*(u32 *)0x80003140 = *(u32 *)0x80003188; *(u32 *)0x80003140 = *(u32 *)0x80003188;
} }
if (cheat) { if (cheat) {
/*HOOKS STUFF - FISHEARS*/ /*HOOKS STUFF - FISHEARS*/
memset((void*)0x80001800,0,kenobiwii_size); memset((void*)0x80001800,0,kenobiwii_size);
memcpy((void*)0x80001800,kenobiwii,kenobiwii_size); memcpy((void*)0x80001800,kenobiwii,kenobiwii_size);
DCFlushRange((void*)0x80001800,kenobiwii_size); DCFlushRange((void*)0x80001800,kenobiwii_size);
hooktype = 1; hooktype = 1;
memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD
/*HOOKS STUFF - FISHEARS*/ /*HOOKS STUFF - FISHEARS*/
} }
for (;;) { for (;;) {
void *dst = NULL; void *dst = NULL;
int len = 0, offset = 0; int len = 0, offset = 0;
/* Run apploader main function */ /* Run apploader main function */
ret = appldr_main(&dst, &len, &offset); ret = appldr_main(&dst, &len, &offset);
if (!ret) if (!ret)
break; break;
/* Read data from DVD */ /* Read data from DVD */
WDVD_Read(dst, len, (u64)(offset << 2)); WDVD_Read(dst, len, (u64)(offset << 2));
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch); gamepatches(dst, len, videoSelected, patchcountrystring, vipatch);
DCFlushRange(dst, len); DCFlushRange(dst, len);
} }
*entry = appldr_final(); *entry = appldr_final();
/** Load alternate dol if set **/ /** Load alternate dol if set **/
if (alternatedol == 1) { if (alternatedol == 1) {
void *dolbuffer; void *dolbuffer;
int dollen; int dollen;
bool dolloaded = Load_Dol(&dolbuffer, &dollen, Settings.dolpath); bool dolloaded = Load_Dol(&dolbuffer, &dollen, Settings.dolpath);
if (dolloaded) { if (dolloaded) {
Remove_001_Protection(dolbuffer, dollen); Remove_001_Protection(dolbuffer, dollen);
DCFlushRange(dolbuffer, dollen); DCFlushRange(dolbuffer, dollen);
gamepatches(dolbuffer, dollen, videoSelected, patchcountrystring, vipatch); gamepatches(dolbuffer, dollen, videoSelected, patchcountrystring, vipatch);
DCFlushRange(dolbuffer, dollen); DCFlushRange(dolbuffer, dollen);
/* Set entry point from apploader */ /* Set entry point from apploader */
*entry = (entry_point) load_dol_image(dolbuffer); *entry = (entry_point) load_dol_image(dolbuffer);
} }
} else if (alternatedol == 2) { } else if (alternatedol == 2) {
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038; FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, patchcountrystring, vipatch); *entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, patchcountrystring, vipatch);
if (*entry == 0) if (*entry == 0)
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
} }
return 0; return 0;
} }