mirror of
https://github.com/wiidev/usbloadergx.git
synced 2024-11-22 03:09:15 +01:00
This commit is contained in:
parent
8e42f68cae
commit
6e3bc5607e
@ -27,7 +27,6 @@ int CheatMenu(const char * gameID) {
|
||||
bool exit = false;
|
||||
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);
|
||||
|
||||
char imgPath[100];
|
||||
@ -35,25 +34,24 @@ int CheatMenu(const char * gameID) {
|
||||
GuiImageData btnOutline(imgPath, button_dialogue_box_png);
|
||||
snprintf(imgPath, sizeof(imgPath), "%ssettings_background.png", CFG.theme_path);
|
||||
GuiImageData settingsbg(imgPath, settings_background_png);
|
||||
|
||||
GuiImage settingsbackground(&settingsbg);
|
||||
|
||||
GuiTrigger trigA;
|
||||
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
|
||||
GuiTrigger trigB;
|
||||
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});
|
||||
backBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
||||
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.SetTrigger(&trigB);
|
||||
|
||||
GuiText createBtnTxt(tr("Create") , 22, (GXColor) {THEME.prompttxt_r, THEME.prompttxt_g, THEME.prompttxt_b, 255});
|
||||
createBtnTxt.SetMaxWidth(btnOutline.GetWidth()-30);
|
||||
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);
|
||||
|
||||
char txtfilename[55];
|
||||
@ -63,8 +61,6 @@ int CheatMenu(const char * gameID) {
|
||||
int check = c.openTxtfile(txtfilename);
|
||||
|
||||
int download =0;
|
||||
//char tmp[10];
|
||||
|
||||
|
||||
switch (check) {
|
||||
case -1:
|
||||
@ -72,9 +68,7 @@ int CheatMenu(const char * gameID) {
|
||||
break;
|
||||
case 0:
|
||||
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)
|
||||
download = CodeDownload(gameID);
|
||||
break;
|
||||
@ -133,7 +127,6 @@ int CheatMenu(const char * gameID) {
|
||||
x++;
|
||||
}
|
||||
}
|
||||
|
||||
string chtpath = Settings.Cheatcodespath;
|
||||
string gctfname = chtpath + c.getGameID() + ".gct";
|
||||
c.createGCT(selectednrs,x,gctfname.c_str());
|
||||
@ -141,7 +134,6 @@ int CheatMenu(const char * gameID) {
|
||||
exit = true;
|
||||
break;
|
||||
} else WindowPrompt(tr("Error"),tr("Could not create GCT file"),tr("OK"));
|
||||
|
||||
}
|
||||
|
||||
if (backBtn.GetState() == STATE_CLICKED) {
|
||||
@ -154,7 +146,6 @@ int CheatMenu(const char * gameID) {
|
||||
mainWindow->SetState(STATE_DEFAULT);
|
||||
mainWindow->Remove(&w);
|
||||
ResumeGui();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,293 +1,218 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "gct.h"
|
||||
|
||||
#define OUTOFRANGE "Error:Range"
|
||||
|
||||
GCTCheats::GCTCheats(void) {
|
||||
iCntCheats = 0;
|
||||
}
|
||||
|
||||
GCTCheats::~GCTCheats(void) {
|
||||
}
|
||||
|
||||
int GCTCheats::getCnt() {
|
||||
return iCntCheats;
|
||||
}
|
||||
|
||||
string GCTCheats::getGameName(void) {
|
||||
return sGameTitle;
|
||||
}
|
||||
|
||||
string GCTCheats::getGameID(void) {
|
||||
return sGameID;
|
||||
}
|
||||
|
||||
string GCTCheats::getCheat(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheats[nr];
|
||||
} else {
|
||||
return OUTOFRANGE;//"Error: CheatNr out of range";
|
||||
}
|
||||
}
|
||||
|
||||
string GCTCheats::getCheatName(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheatName[nr];
|
||||
} else {
|
||||
return "Error: CheatNr out of range";
|
||||
}
|
||||
}
|
||||
|
||||
string GCTCheats::getCheatComment(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheatComment[nr];
|
||||
} else {
|
||||
return "Error: CheatNr out of range";
|
||||
}
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(int nr,const char * filename) {
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Reversed Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
string buf = getCheat(nr);
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int x = 0;
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
filestr.write(footer,sizeof(footer));
|
||||
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Reversed Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
string buf = chtbuffer;
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int x = 0;
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
|
||||
filestr.write(footer,sizeof(footer));
|
||||
|
||||
filestr.close();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
|
||||
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Reversed Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int c = 0;
|
||||
while (c != cnt) {
|
||||
int actnr = nr[c];
|
||||
string buf = getCheat(actnr);
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
int x = 0;
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
filestr.write(footer,sizeof(footer));
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::openTxtfile(const char * filename) {
|
||||
ifstream filestr;
|
||||
int i = 0;
|
||||
string str;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
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;
|
||||
bool isComment = false;
|
||||
|
||||
do {
|
||||
getline(filestr,str,'\n');
|
||||
//cheatdata.append(str);
|
||||
|
||||
if (str == "") {
|
||||
emptyline = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (str.size() <= 16 || str.size() > 17 ) {
|
||||
isComment = true;
|
||||
printf ("%i",str.size());
|
||||
}
|
||||
|
||||
if (!isComment) {
|
||||
cheatdata.append(str);
|
||||
size_t found=cheatdata.find(' ');
|
||||
cheatdata.replace(found,1,"");
|
||||
} else {
|
||||
sCheatComment[i] = str;
|
||||
}
|
||||
|
||||
if (filestr.eof()) break;
|
||||
} while (!emptyline);
|
||||
|
||||
sCheats[i] = cheatdata;
|
||||
i++;
|
||||
}
|
||||
iCntCheats = i;
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*int GCTCheats::openTxtfile(const char * filename)
|
||||
{
|
||||
ifstream filestr;
|
||||
int i = 0;
|
||||
string str;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
/*
|
||||
* gct.h
|
||||
* Class to handle Ocarina TXT Cheatfiles
|
||||
* nIxx
|
||||
*/
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include "gct.h"
|
||||
|
||||
#define ERRORRANGE "Error: CheatNr out of range"
|
||||
|
||||
GCTCheats::GCTCheats(void) {
|
||||
iCntCheats = 0;
|
||||
}
|
||||
|
||||
GCTCheats::~GCTCheats(void) {
|
||||
|
||||
string sGameID ="";
|
||||
string sGameTitle = "";
|
||||
/*string sCheatName[MAXCHEATS];
|
||||
string sCheats[MAXCHEATS];
|
||||
string sCheatComment[MAXCHEATS];*/
|
||||
}
|
||||
|
||||
int GCTCheats::getCnt() {
|
||||
return iCntCheats;
|
||||
}
|
||||
|
||||
string GCTCheats::getGameName(void) {
|
||||
return sGameTitle;
|
||||
}
|
||||
|
||||
string GCTCheats::getGameID(void) {
|
||||
return sGameID;
|
||||
}
|
||||
|
||||
string GCTCheats::getCheat(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheats[nr];
|
||||
} else {
|
||||
return ERRORRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
string GCTCheats::getCheatName(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheatName[nr];
|
||||
} else {
|
||||
return ERRORRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
string GCTCheats::getCheatComment(int nr) {
|
||||
if (nr <= (iCntCheats-1)) {
|
||||
return sCheatComment[nr];
|
||||
} else {
|
||||
return ERRORRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(int nr,const char * filename) {
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
string buf = getCheat(nr);
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int x = 0;
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
filestr.write(footer,sizeof(footer));
|
||||
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(const char * chtbuffer,const char * filename) {
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
string buf = chtbuffer;
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int x = 0;
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
|
||||
filestr.write(footer,sizeof(footer));
|
||||
|
||||
filestr.close();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::createGCT(int nr[],int cnt,const char * filename) {
|
||||
|
||||
ofstream filestr;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
//Header and Footer
|
||||
char header[] = { 0x00, 0xd0, 0xc0, 0xde, 0x00, 0xd0, 0xc0, 0xde};
|
||||
char footer[] = { 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
filestr.write(header,sizeof(header));
|
||||
|
||||
int c = 0;
|
||||
while (c != cnt) {
|
||||
int actnr = nr[c];
|
||||
string buf = getCheat(actnr);
|
||||
long int li;
|
||||
int len = buf.size();
|
||||
int x = 0;
|
||||
|
||||
while (x < len) {
|
||||
string temp = buf.substr(x,2);
|
||||
li = strtol(temp.c_str(),NULL,16);
|
||||
temp = li;
|
||||
filestr.write(temp.c_str(),1);
|
||||
x +=2;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
|
||||
filestr.write(footer,sizeof(footer));
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GCTCheats::openTxtfile(const char * filename) {
|
||||
ifstream filestr;
|
||||
int i = 0;
|
||||
string str;
|
||||
filestr.open(filename);
|
||||
|
||||
if (filestr.fail())
|
||||
return 0;
|
||||
|
||||
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;
|
||||
bool isComment = false;
|
||||
|
||||
do {
|
||||
getline(filestr,str,'\n');
|
||||
//cheatdata.append(str);
|
||||
|
||||
if (str == "") {
|
||||
emptyline = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (str.size() <= 16 || str.size() > 17 ) {
|
||||
isComment = true;
|
||||
printf ("%i",str.size());
|
||||
}
|
||||
|
||||
if (!isComment) {
|
||||
cheatdata.append(str);
|
||||
size_t found=cheatdata.find(' ');
|
||||
cheatdata.replace(found,1,"");
|
||||
} else {
|
||||
sCheatComment[i] = str;
|
||||
}
|
||||
|
||||
if (filestr.eof()) break;
|
||||
} while (!emptyline);
|
||||
|
||||
sCheats[i] = cheatdata;
|
||||
i++;
|
||||
}
|
||||
iCntCheats = i;
|
||||
filestr.close();
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,103 +1,71 @@
|
||||
/*
|
||||
* gct.h
|
||||
* 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
|
||||
#define _GCT_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#define MAXCHEATS 40
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct chtentrie {
|
||||
string sGameID;
|
||||
string sGameTitle;
|
||||
string sCheatName[MAXCHEATS];
|
||||
string sCheats[MAXCHEATS];
|
||||
string sCheatComment[MAXCHEATS];
|
||||
int iCntCheats;
|
||||
};
|
||||
|
||||
//!Handles Ocarina TXT Cheatfiles
|
||||
class GCTCheats {
|
||||
private:
|
||||
chtentrie ccc;
|
||||
string sGameID;
|
||||
string sGameTitle;
|
||||
string sCheatName[MAXCHEATS];
|
||||
string sCheats[MAXCHEATS];
|
||||
string sCheatComment[MAXCHEATS];
|
||||
int iCntCheats;
|
||||
|
||||
public:
|
||||
|
||||
struct chtentries {
|
||||
string sGameID;
|
||||
string sGameTitle;
|
||||
string sCheatName[MAXCHEATS];
|
||||
string sCheats[MAXCHEATS];
|
||||
int iCntCheats;
|
||||
};
|
||||
|
||||
//!Constructor
|
||||
GCTCheats(void);
|
||||
//!Destructor
|
||||
~GCTCheats(void);
|
||||
//!Open txt file with cheats
|
||||
//!\param filename name of TXT file
|
||||
//!\return error code
|
||||
int openTxtfile(const char * filename);
|
||||
//!Creates GCT file for one cheat
|
||||
//!\param nr selected Cheat Numbers
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(int nr,const char * filename);
|
||||
//!Creates GCT file from a buffer
|
||||
//!\param chtbuffer buffer that holds the cheat data
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(const char * chtbuffer,const char * filename);
|
||||
//!Creates GCT file
|
||||
//!\param nr[] array of selected Cheat Numbers
|
||||
//!\param cnt size of array
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(int nr[],int cnt,const char * filename);
|
||||
//!Gets Count cheats
|
||||
//!\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 */
|
||||
/*
|
||||
* gct.h
|
||||
* Class to handle Ocarina TXT Cheatfiles
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _GCT_H
|
||||
#define _GCT_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#define MAXCHEATS 40
|
||||
|
||||
using namespace std;
|
||||
|
||||
//!Handles Ocarina TXT Cheatfiles
|
||||
class GCTCheats {
|
||||
private:
|
||||
string sGameID;
|
||||
string sGameTitle;
|
||||
string sCheatName[MAXCHEATS];
|
||||
string sCheats[MAXCHEATS];
|
||||
string sCheatComment[MAXCHEATS];
|
||||
int iCntCheats;
|
||||
|
||||
public:
|
||||
//!Constructor
|
||||
GCTCheats(void);
|
||||
//!Destructor
|
||||
~GCTCheats(void);
|
||||
//!Open txt file with cheats
|
||||
//!\param filename name of TXT file
|
||||
//!\return error code
|
||||
int openTxtfile(const char * filename);
|
||||
//!Creates GCT file for one cheat
|
||||
//!\param nr selected Cheat Numbers
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(int nr,const char * filename);
|
||||
//!Creates GCT file from a buffer
|
||||
//!\param chtbuffer buffer that holds the cheat data
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(const char * chtbuffer,const char * filename);
|
||||
//!Creates GCT file
|
||||
//!\param nr[] array of selected Cheat Numbers
|
||||
//!\param cnt size of array
|
||||
//!\param filename name of GCT file
|
||||
//!\return error code
|
||||
int createGCT(int nr[],int cnt,const char * filename);
|
||||
//!Gets Count cheats
|
||||
//!\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);
|
||||
};
|
||||
|
||||
#endif /* _GCT_H */
|
||||
|
@ -1,144 +1,144 @@
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "dolloader.h"
|
||||
#include "elfloader.h"
|
||||
|
||||
void *innetbuffer = NULL;
|
||||
|
||||
int AllocHomebrewMemory(u32 filesize) {
|
||||
|
||||
innetbuffer = malloc(filesize);
|
||||
|
||||
if (!innetbuffer)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
void FreeHomebrewBuffer() {
|
||||
free(innetbuffer);
|
||||
innetbuffer = NULL;
|
||||
}
|
||||
|
||||
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
|
||||
|
||||
memcpy(((u8 *) innetbuffer)+read, temp, len);
|
||||
|
||||
}
|
||||
|
||||
int BootHomebrew(char * path) {
|
||||
void *buffer = NULL;
|
||||
u32 filesize = 0;
|
||||
entrypoint entry;
|
||||
u32 cpu_isr;
|
||||
|
||||
FILE * file = fopen(path, "rb");
|
||||
if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
|
||||
fseek (file, 0, SEEK_END);
|
||||
filesize = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
buffer = malloc(filesize);
|
||||
|
||||
if (fread (buffer, 1, filesize, file) != filesize) {
|
||||
fclose (file);
|
||||
free(buffer);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
fclose (file);
|
||||
|
||||
struct __argv args;
|
||||
bzero(&args, sizeof(args));
|
||||
args.argvMagic = ARGV_MAGIC;
|
||||
args.length = strlen(path) + 2;
|
||||
args.commandLine = (char*)malloc(args.length);
|
||||
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
strcpy(args.commandLine, path);
|
||||
args.commandLine[args.length - 1] = '\0';
|
||||
args.argc = 1;
|
||||
args.argv = &args.commandLine;
|
||||
args.endARGV = args.argv + 1;
|
||||
|
||||
int ret = valid_elf_image(buffer);
|
||||
if (ret == 1)
|
||||
entry = (entrypoint) load_elf_image(buffer);
|
||||
else
|
||||
entry = (entrypoint) load_dol(buffer, &args);
|
||||
|
||||
free(buffer);
|
||||
|
||||
if (!entry) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush(0);
|
||||
WPAD_Disconnect(0);
|
||||
WPAD_Shutdown();
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
entry();
|
||||
_CPU_ISR_Restore (cpu_isr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BootHomebrewFromMem() {
|
||||
entrypoint entry;
|
||||
u32 cpu_isr;
|
||||
|
||||
if (!innetbuffer) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
struct __argv args;
|
||||
|
||||
int ret = valid_elf_image(innetbuffer);
|
||||
if (ret == 1)
|
||||
entry = (entrypoint) load_elf_image(innetbuffer);
|
||||
else
|
||||
entry = (entrypoint) load_dol(innetbuffer, &args);
|
||||
|
||||
free(innetbuffer);
|
||||
|
||||
if (!entry) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush(0);
|
||||
WPAD_Disconnect(0);
|
||||
WPAD_Shutdown();
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
entry();
|
||||
_CPU_ISR_Restore (cpu_isr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include <gccore.h>
|
||||
#include <ogcsys.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ogc/machine/processor.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "dolloader.h"
|
||||
#include "elfloader.h"
|
||||
|
||||
void *innetbuffer = NULL;
|
||||
|
||||
int AllocHomebrewMemory(u32 filesize) {
|
||||
|
||||
innetbuffer = malloc(filesize);
|
||||
|
||||
if (!innetbuffer)
|
||||
return -1;
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
void FreeHomebrewBuffer() {
|
||||
free(innetbuffer);
|
||||
innetbuffer = NULL;
|
||||
}
|
||||
|
||||
void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
|
||||
|
||||
memcpy(((u8 *) innetbuffer)+read, temp, len);
|
||||
|
||||
}
|
||||
|
||||
int BootHomebrew(char * path) {
|
||||
void *buffer = NULL;
|
||||
u32 filesize = 0;
|
||||
entrypoint entry;
|
||||
u32 cpu_isr;
|
||||
|
||||
FILE * file = fopen(path, "rb");
|
||||
if (!file) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
|
||||
fseek (file, 0, SEEK_END);
|
||||
filesize = ftell(file);
|
||||
rewind(file);
|
||||
|
||||
buffer = malloc(filesize);
|
||||
|
||||
if (fread (buffer, 1, filesize, file) != filesize) {
|
||||
fclose (file);
|
||||
free(buffer);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
fclose (file);
|
||||
|
||||
struct __argv args;
|
||||
bzero(&args, sizeof(args));
|
||||
args.argvMagic = ARGV_MAGIC;
|
||||
args.length = strlen(path) + 2;
|
||||
args.commandLine = (char*)malloc(args.length);
|
||||
if (!args.commandLine) SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
strcpy(args.commandLine, path);
|
||||
args.commandLine[args.length - 1] = '\0';
|
||||
args.argc = 1;
|
||||
args.argv = &args.commandLine;
|
||||
args.endARGV = args.argv + 1;
|
||||
|
||||
int ret = valid_elf_image(buffer);
|
||||
if (ret == 1)
|
||||
entry = (entrypoint) load_elf_image(buffer);
|
||||
else
|
||||
entry = (entrypoint) load_dol(buffer, &args);
|
||||
|
||||
free(buffer);
|
||||
|
||||
if (!entry) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush(0);
|
||||
WPAD_Disconnect(0);
|
||||
WPAD_Shutdown();
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
entry();
|
||||
_CPU_ISR_Restore (cpu_isr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int BootHomebrewFromMem() {
|
||||
entrypoint entry;
|
||||
u32 cpu_isr;
|
||||
|
||||
if (!innetbuffer) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
struct __argv args;
|
||||
|
||||
int ret = valid_elf_image(innetbuffer);
|
||||
if (ret == 1)
|
||||
entry = (entrypoint) load_elf_image(innetbuffer);
|
||||
else
|
||||
entry = (entrypoint) load_dol(innetbuffer, &args);
|
||||
|
||||
free(innetbuffer);
|
||||
|
||||
if (!entry) {
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
|
||||
WPAD_Flush(0);
|
||||
WPAD_Disconnect(0);
|
||||
WPAD_Shutdown();
|
||||
|
||||
SYS_ResetSystem(SYS_SHUTDOWN, 0, 0);
|
||||
_CPU_ISR_Disable (cpu_isr);
|
||||
__exception_closeall();
|
||||
entry();
|
||||
_CPU_ISR_Restore (cpu_isr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -322,7 +322,6 @@ int MenuHomebrewBrowse() {
|
||||
|
||||
GuiWindow w(screenwidth, screenheight);
|
||||
|
||||
|
||||
/*** XML Variables ***/
|
||||
HomebrewXML XMLInfo[4];
|
||||
|
||||
|
@ -1,132 +1,132 @@
|
||||
/****************************************************************************
|
||||
* URL List Class
|
||||
* for USB Loader GX
|
||||
* by dimok
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "URL_List.h"
|
||||
|
||||
|
||||
URL_List::URL_List(const char * url) {
|
||||
Links = NULL;
|
||||
urlcount = 0;
|
||||
|
||||
if (!IsNetworkInit()) {
|
||||
urlcount = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
struct block file = downloadfile(url);
|
||||
|
||||
if (!file.data || !file.size) {
|
||||
urlcount = -2;
|
||||
return;
|
||||
}
|
||||
|
||||
u32 cnt = 0;
|
||||
char temp[1024];
|
||||
|
||||
Links = (Link_Info *) malloc(sizeof(Link_Info));
|
||||
if (!Links) {
|
||||
free(file.data);
|
||||
urlcount = -3;
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&Links[urlcount], 0, sizeof(Link_Info));
|
||||
|
||||
while (cnt < file.size) {
|
||||
|
||||
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') {
|
||||
|
||||
u32 cnt2 = 0;
|
||||
cnt++;
|
||||
while (file.data[cnt] != '"' && cnt2 < 1024) {
|
||||
temp[cnt2] = file.data[cnt];
|
||||
cnt2++;
|
||||
cnt++;
|
||||
}
|
||||
temp[cnt2] = '\0';
|
||||
|
||||
Links = (Link_Info *) realloc(Links, (urlcount+1)*sizeof(Link_Info));
|
||||
|
||||
if (!Links) {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
free(file.data);
|
||||
urlcount = -4;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&(Links[urlcount]), 0, sizeof(Link_Info));
|
||||
|
||||
Links[urlcount].URL = new char[cnt2+1];
|
||||
|
||||
if (!Links[urlcount].URL) {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
free(file.data);
|
||||
urlcount = -5;
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(Links[urlcount].URL, cnt2+1, "%s", temp);
|
||||
|
||||
if (strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0)
|
||||
Links[urlcount].direct = false;
|
||||
else
|
||||
Links[urlcount].direct = true;
|
||||
|
||||
urlcount++;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
||||
free(file.data);
|
||||
}
|
||||
|
||||
URL_List::~URL_List() {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
|
||||
if (Links != NULL) {
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char * URL_List::GetURL(int ind) {
|
||||
if (ind > urlcount || ind < 0 || !Links || urlcount <= 0)
|
||||
return NULL;
|
||||
else
|
||||
return Links[ind].URL;
|
||||
}
|
||||
|
||||
int URL_List::GetURLCount() {
|
||||
return urlcount;
|
||||
}
|
||||
|
||||
static int ListCompare(const void *a, const void *b) {
|
||||
Link_Info *ab = (Link_Info*) a;
|
||||
Link_Info *bb = (Link_Info*) b;
|
||||
|
||||
return stricmp((char *) ab->URL, (char *) bb->URL);
|
||||
}
|
||||
void URL_List::SortList() {
|
||||
qsort(Links, urlcount, sizeof(Link_Info), ListCompare);
|
||||
}
|
||||
/****************************************************************************
|
||||
* URL List Class
|
||||
* for USB Loader GX
|
||||
* by dimok
|
||||
***************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gctypes.h>
|
||||
|
||||
#include "URL_List.h"
|
||||
|
||||
|
||||
URL_List::URL_List(const char * url) {
|
||||
Links = NULL;
|
||||
urlcount = 0;
|
||||
|
||||
if (!IsNetworkInit()) {
|
||||
urlcount = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
struct block file = downloadfile(url);
|
||||
|
||||
if (!file.data || !file.size) {
|
||||
urlcount = -2;
|
||||
return;
|
||||
}
|
||||
|
||||
u32 cnt = 0;
|
||||
char temp[1024];
|
||||
|
||||
Links = (Link_Info *) malloc(sizeof(Link_Info));
|
||||
if (!Links) {
|
||||
free(file.data);
|
||||
urlcount = -3;
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&Links[urlcount], 0, sizeof(Link_Info));
|
||||
|
||||
while (cnt < file.size) {
|
||||
|
||||
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') {
|
||||
|
||||
u32 cnt2 = 0;
|
||||
cnt++;
|
||||
while (file.data[cnt] != '"' && cnt2 < 1024) {
|
||||
temp[cnt2] = file.data[cnt];
|
||||
cnt2++;
|
||||
cnt++;
|
||||
}
|
||||
temp[cnt2] = '\0';
|
||||
|
||||
Links = (Link_Info *) realloc(Links, (urlcount+1)*sizeof(Link_Info));
|
||||
|
||||
if (!Links) {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
free(file.data);
|
||||
urlcount = -4;
|
||||
break;
|
||||
}
|
||||
|
||||
memset(&(Links[urlcount]), 0, sizeof(Link_Info));
|
||||
|
||||
Links[urlcount].URL = new char[cnt2+1];
|
||||
|
||||
if (!Links[urlcount].URL) {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
free(file.data);
|
||||
urlcount = -5;
|
||||
break;
|
||||
}
|
||||
|
||||
snprintf(Links[urlcount].URL, cnt2+1, "%s", temp);
|
||||
|
||||
if (strncmp(Links[urlcount].URL, "http://", strlen("http://")) != 0)
|
||||
Links[urlcount].direct = false;
|
||||
else
|
||||
Links[urlcount].direct = true;
|
||||
|
||||
urlcount++;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
|
||||
free(file.data);
|
||||
}
|
||||
|
||||
URL_List::~URL_List() {
|
||||
for (int i = 0; i == urlcount; i++) {
|
||||
delete Links[i].URL;
|
||||
Links[i].URL = NULL;
|
||||
}
|
||||
|
||||
if (Links != NULL) {
|
||||
free(Links);
|
||||
Links = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char * URL_List::GetURL(int ind) {
|
||||
if (ind > urlcount || ind < 0 || !Links || urlcount <= 0)
|
||||
return NULL;
|
||||
else
|
||||
return Links[ind].URL;
|
||||
}
|
||||
|
||||
int URL_List::GetURLCount() {
|
||||
return urlcount;
|
||||
}
|
||||
|
||||
static int ListCompare(const void *a, const void *b) {
|
||||
Link_Info *ab = (Link_Info*) a;
|
||||
Link_Info *bb = (Link_Info*) b;
|
||||
|
||||
return stricmp((char *) ab->URL, (char *) bb->URL);
|
||||
}
|
||||
void URL_List::SortList() {
|
||||
qsort(Links, urlcount, sizeof(Link_Info), ListCompare);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,98 +1,98 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Nuke (wiinuke@gmail.com)
|
||||
*
|
||||
* this file is part of GeckoOS for USB Gecko
|
||||
* http://www.usbgecko.com
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <ogc/ipc.h>
|
||||
|
||||
#include "settings/cfg.h"
|
||||
#include "fst.h"
|
||||
#include "dvd_broadway.h"
|
||||
#include "wpad.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
extern struct SSettings Settings;
|
||||
|
||||
u32 do_sd_code(char *filename) {
|
||||
FILE *fp;
|
||||
u8 *filebuff;
|
||||
u32 filesize;
|
||||
u32 ret;
|
||||
char filepath[150];
|
||||
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename);
|
||||
filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E;
|
||||
filepath[strlen(Settings.Cheatcodespath)+7] = 0x67;
|
||||
filepath[strlen(Settings.Cheatcodespath)+8] = 0x63;
|
||||
filepath[strlen(Settings.Cheatcodespath)+9] = 0x74;
|
||||
filepath[strlen(Settings.Cheatcodespath)+10] = 0;
|
||||
|
||||
fp = fopen(filepath, "rb");
|
||||
if (!fp) {
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
filesize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
filebuff = (u8*) malloc (filesize);
|
||||
if (filebuff == 0) {
|
||||
fclose(fp);
|
||||
sleep(2);
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = fread(filebuff, 1, filesize, fp);
|
||||
if (ret != filesize) {
|
||||
free(filebuff);
|
||||
fclose(fp);
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy((void*)0x800027E8,filebuff,filesize);
|
||||
*(vu8*)0x80001807 = 0x01;
|
||||
|
||||
free(filebuff);
|
||||
fclose(fp);
|
||||
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (C) 2008 Nuke (wiinuke@gmail.com)
|
||||
*
|
||||
* this file is part of GeckoOS for USB Gecko
|
||||
* http://www.usbgecko.com
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gccore.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <ogc/ipc.h>
|
||||
|
||||
#include "settings/cfg.h"
|
||||
#include "fst.h"
|
||||
#include "dvd_broadway.h"
|
||||
#include "wpad.h"
|
||||
#include "fatmounter.h"
|
||||
|
||||
extern struct SSettings Settings;
|
||||
|
||||
u32 do_sd_code(char *filename) {
|
||||
FILE *fp;
|
||||
u8 *filebuff;
|
||||
u32 filesize;
|
||||
u32 ret;
|
||||
char filepath[150];
|
||||
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
sprintf(filepath, "%s%s", Settings.Cheatcodespath, filename);
|
||||
filepath[strlen(Settings.Cheatcodespath)+6] = 0x2E;
|
||||
filepath[strlen(Settings.Cheatcodespath)+7] = 0x67;
|
||||
filepath[strlen(Settings.Cheatcodespath)+8] = 0x63;
|
||||
filepath[strlen(Settings.Cheatcodespath)+9] = 0x74;
|
||||
filepath[strlen(Settings.Cheatcodespath)+10] = 0;
|
||||
|
||||
fp = fopen(filepath, "rb");
|
||||
if (!fp) {
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(fp, 0, SEEK_END);
|
||||
filesize = ftell(fp);
|
||||
fseek(fp, 0, SEEK_SET);
|
||||
|
||||
filebuff = (u8*) malloc (filesize);
|
||||
if (filebuff == 0) {
|
||||
fclose(fp);
|
||||
sleep(2);
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = fread(filebuff, 1, filesize, fp);
|
||||
if (ret != filesize) {
|
||||
free(filebuff);
|
||||
fclose(fp);
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy((void*)0x800027E8,filebuff,filesize);
|
||||
*(vu8*)0x80001807 = 0x01;
|
||||
|
||||
free(filebuff);
|
||||
fclose(fp);
|
||||
|
||||
USBDevice_deInit();
|
||||
SDCard_deInit();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,225 +1,224 @@
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <gccore.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "apploader.h"
|
||||
#include "wdvd.h"
|
||||
#include "fstfile.h"
|
||||
|
||||
/** Alternate dolloader made by WiiPower modified by dimok **/
|
||||
|
||||
bool Load_Dol(void **buffer, int* dollen, char * filepath) {
|
||||
int ret;
|
||||
FILE* file;
|
||||
void* dol_buffer;
|
||||
|
||||
char fullpath[200];
|
||||
char gameidbuffer6[7];
|
||||
memset(gameidbuffer6, 0, 7);
|
||||
memcpy(gameidbuffer6, (char*)0x80000000, 6);
|
||||
snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6);
|
||||
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
file = fopen(fullpath, "rb");
|
||||
|
||||
if (file == NULL) {
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
|
||||
int filesize;
|
||||
fseek(file, 0, SEEK_END);
|
||||
filesize = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
dol_buffer = malloc(filesize);
|
||||
if (dol_buffer == NULL) {
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
ret = fread( dol_buffer, 1, filesize, file);
|
||||
if (ret != filesize) {
|
||||
free(dol_buffer);
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
*buffer = dol_buffer;
|
||||
*dollen = filesize;
|
||||
return true;
|
||||
}
|
||||
|
||||
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 PatchData[16] = { 0x40, 0x82, 0x00, 0x04, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
|
||||
|
||||
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));
|
||||
return true;
|
||||
}
|
||||
Addr += 4;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef struct _dolheader {
|
||||
u32 text_pos[7];
|
||||
u32 data_pos[11];
|
||||
u32 text_start[7];
|
||||
u32 data_start[11];
|
||||
u32 text_size[7];
|
||||
u32 data_size[11];
|
||||
u32 bss_start;
|
||||
u32 bss_size;
|
||||
u32 entry_point;
|
||||
} dolheader;
|
||||
|
||||
static dolheader *dolfile;
|
||||
|
||||
|
||||
u32 load_dol_image(void *dolstart) {
|
||||
|
||||
u32 i;
|
||||
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *) dolstart;
|
||||
for (i = 0; i < 7; i++) {
|
||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
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]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
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]);
|
||||
}
|
||||
/*
|
||||
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
||||
*/
|
||||
return dolfile->entry_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int i;
|
||||
static int phase;
|
||||
|
||||
u32 load_dol_start(void *dolstart) {
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *)dolstart;
|
||||
return dolfile->entry_point;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset((void *)dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size);
|
||||
|
||||
phase = 0;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len) {
|
||||
if (phase == 0) {
|
||||
if (i == 7) {
|
||||
phase = 1;
|
||||
i = 0;
|
||||
} else {
|
||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) {
|
||||
*offset = 0;
|
||||
*pos = 0;
|
||||
*len = 0;
|
||||
} else {
|
||||
*offset = (void *)dolfile->text_start[i];
|
||||
*pos = dolfile->text_pos[i];
|
||||
*len = dolfile->text_size[i];
|
||||
}
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (phase == 1) {
|
||||
if (i == 11) {
|
||||
phase = 2;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) {
|
||||
*offset = 0;
|
||||
*pos = 0;
|
||||
*len = 0;
|
||||
} else {
|
||||
*offset = (void *)dolfile->data_start[i];
|
||||
*pos = dolfile->data_pos[i];
|
||||
*len = dolfile->data_size[i];
|
||||
}
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
|
||||
int ret;
|
||||
void *dol_header;
|
||||
u32 entrypoint;
|
||||
|
||||
dol_header = memalign(32, sizeof(dolheader));
|
||||
if (dol_header == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2));
|
||||
|
||||
entrypoint = load_dol_start(dol_header);
|
||||
|
||||
if (entrypoint == 0) {
|
||||
free(dol_header);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *offset;
|
||||
u32 pos;
|
||||
u32 len;
|
||||
|
||||
while (load_dol_image_modified(&offset, &pos, &len)) {
|
||||
if (len != 0) {
|
||||
ret = WDVD_Read(offset, len, (doloffset<<2) + pos);
|
||||
|
||||
DCFlushRange(offset, len);
|
||||
|
||||
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(offset, len);
|
||||
|
||||
Remove_001_Protection(offset, len);
|
||||
}
|
||||
}
|
||||
|
||||
free(dol_header);
|
||||
|
||||
return entrypoint;
|
||||
}
|
||||
#include <ogcsys.h>
|
||||
#include <stdio.h>
|
||||
#include <gccore.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "fatmounter.h"
|
||||
#include "apploader.h"
|
||||
#include "wdvd.h"
|
||||
#include "fstfile.h"
|
||||
|
||||
/** Alternate dolloader made by WiiPower modified by dimok **/
|
||||
bool Load_Dol(void **buffer, int* dollen, char * filepath) {
|
||||
int ret;
|
||||
FILE* file;
|
||||
void* dol_buffer;
|
||||
|
||||
char fullpath[200];
|
||||
char gameidbuffer6[7];
|
||||
memset(gameidbuffer6, 0, 7);
|
||||
memcpy(gameidbuffer6, (char*)0x80000000, 6);
|
||||
snprintf(fullpath, 200, "%s%s.dol", filepath, gameidbuffer6);
|
||||
|
||||
SDCard_Init();
|
||||
USBDevice_Init();
|
||||
|
||||
file = fopen(fullpath, "rb");
|
||||
|
||||
if (file == NULL) {
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
|
||||
int filesize;
|
||||
fseek(file, 0, SEEK_END);
|
||||
filesize = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
dol_buffer = malloc(filesize);
|
||||
if (dol_buffer == NULL) {
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
ret = fread( dol_buffer, 1, filesize, file);
|
||||
if (ret != filesize) {
|
||||
free(dol_buffer);
|
||||
fclose(file);
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
return false;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
SDCard_deInit();
|
||||
USBDevice_deInit();
|
||||
*buffer = dol_buffer;
|
||||
*dollen = filesize;
|
||||
return true;
|
||||
}
|
||||
|
||||
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 PatchData[16] = { 0x40, 0x82, 0x00, 0x04, 0x38, 0x60, 0x00, 0x01, 0x48, 0x00, 0x02, 0x44, 0x38, 0x61, 0x00, 0x18 };
|
||||
|
||||
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));
|
||||
return true;
|
||||
}
|
||||
Addr += 4;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef struct _dolheader {
|
||||
u32 text_pos[7];
|
||||
u32 data_pos[11];
|
||||
u32 text_start[7];
|
||||
u32 data_start[11];
|
||||
u32 text_size[7];
|
||||
u32 data_size[11];
|
||||
u32 bss_start;
|
||||
u32 bss_size;
|
||||
u32 entry_point;
|
||||
} dolheader;
|
||||
|
||||
static dolheader *dolfile;
|
||||
|
||||
|
||||
u32 load_dol_image(void *dolstart) {
|
||||
|
||||
u32 i;
|
||||
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *) dolstart;
|
||||
for (i = 0; i < 7; i++) {
|
||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
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]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 11; i++) {
|
||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) continue;
|
||||
VIDEO_WaitVSync();
|
||||
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]);
|
||||
}
|
||||
/*
|
||||
memset ((void *) dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *) dolfile->bss_start, dolfile->bss_size);
|
||||
*/
|
||||
return dolfile->entry_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int i;
|
||||
static int phase;
|
||||
|
||||
u32 load_dol_start(void *dolstart) {
|
||||
if (dolstart) {
|
||||
dolfile = (dolheader *)dolstart;
|
||||
return dolfile->entry_point;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset((void *)dolfile->bss_start, 0, dolfile->bss_size);
|
||||
DCFlushRange((void *)dolfile->bss_start, dolfile->bss_size);
|
||||
|
||||
phase = 0;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
bool load_dol_image_modified(void **offset, u32 *pos, u32 *len) {
|
||||
if (phase == 0) {
|
||||
if (i == 7) {
|
||||
phase = 1;
|
||||
i = 0;
|
||||
} else {
|
||||
if ((!dolfile->text_size[i]) || (dolfile->text_start[i] < 0x100)) {
|
||||
*offset = 0;
|
||||
*pos = 0;
|
||||
*len = 0;
|
||||
} else {
|
||||
*offset = (void *)dolfile->text_start[i];
|
||||
*pos = dolfile->text_pos[i];
|
||||
*len = dolfile->text_size[i];
|
||||
}
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (phase == 1) {
|
||||
if (i == 11) {
|
||||
phase = 2;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((!dolfile->data_size[i]) || (dolfile->data_start[i] < 0x100)) {
|
||||
*offset = 0;
|
||||
*pos = 0;
|
||||
*len = 0;
|
||||
} else {
|
||||
*offset = (void *)dolfile->data_start[i];
|
||||
*pos = dolfile->data_pos[i];
|
||||
*len = dolfile->data_size[i];
|
||||
}
|
||||
i++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 Load_Dol_from_disc(u32 doloffset, u8 videoSelected, u8 patchcountrystring, u8 vipatch) {
|
||||
int ret;
|
||||
void *dol_header;
|
||||
u32 entrypoint;
|
||||
|
||||
dol_header = memalign(32, sizeof(dolheader));
|
||||
if (dol_header == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = WDVD_Read(dol_header, sizeof(dolheader), (doloffset<<2));
|
||||
|
||||
entrypoint = load_dol_start(dol_header);
|
||||
|
||||
if (entrypoint == 0) {
|
||||
free(dol_header);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *offset;
|
||||
u32 pos;
|
||||
u32 len;
|
||||
|
||||
while (load_dol_image_modified(&offset, &pos, &len)) {
|
||||
if (len != 0) {
|
||||
ret = WDVD_Read(offset, len, (doloffset<<2) + pos);
|
||||
|
||||
DCFlushRange(offset, len);
|
||||
|
||||
gamepatches(offset, len, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(offset, len);
|
||||
|
||||
Remove_001_Protection(offset, len);
|
||||
}
|
||||
}
|
||||
|
||||
free(dol_header);
|
||||
|
||||
return entrypoint;
|
||||
}
|
||||
|
@ -1,28 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <ogcsys.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "patches/patchcode.h"
|
||||
#include <stdio.h>
|
||||
#include <ogcsys.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "patches/patchcode.h"
|
||||
#include "patches/kenobiwii.h" /*FISHEARS*/
|
||||
#include "apploader.h"
|
||||
#include "wdvd.h"
|
||||
#include "wpad.h"
|
||||
#include "disc.h"
|
||||
#include "alternatedol.h"
|
||||
#include "fstfile.h"
|
||||
#include "settings/cfg.h"
|
||||
|
||||
/*KENOBI! - FISHEARS*/
|
||||
extern const unsigned char kenobiwii[];
|
||||
extern const int kenobiwii_size;
|
||||
/*KENOBI! - FISHEARS*/
|
||||
|
||||
/* Apploader function pointers */
|
||||
typedef int (*app_main)(void **dst, int *size, int *offset);
|
||||
typedef void (*app_init)(void (*report)(const char *fmt, ...));
|
||||
typedef void *(*app_final)();
|
||||
typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)());
|
||||
|
||||
#include "apploader.h"
|
||||
#include "wdvd.h"
|
||||
#include "wpad.h"
|
||||
#include "disc.h"
|
||||
#include "alternatedol.h"
|
||||
#include "fstfile.h"
|
||||
#include "settings/cfg.h"
|
||||
|
||||
/*KENOBI! - FISHEARS*/
|
||||
extern const unsigned char kenobiwii[];
|
||||
extern const int kenobiwii_size;
|
||||
/*KENOBI! - FISHEARS*/
|
||||
|
||||
/* Apploader function pointers */
|
||||
typedef int (*app_main)(void **dst, int *size, int *offset);
|
||||
typedef void (*app_init)(void (*report)(const char *fmt, ...));
|
||||
typedef void *(*app_final)();
|
||||
typedef void (*app_entry)(void (**init)(void (*report)(const char *fmt, ...)), int (**main)(), void *(**final)());
|
||||
|
||||
/* Apploader pointers */
|
||||
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[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[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[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[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[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[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[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) {
|
||||
mode1->viTVMode = mode2->viTVMode;
|
||||
mode1->fbWidth = mode2->fbWidth;
|
||||
mode1->efbHeight = mode2->efbHeight;
|
||||
mode1->xfbHeight = mode2->xfbHeight;
|
||||
mode1->viXOrigin = mode2->viXOrigin;
|
||||
mode1->viYOrigin = mode2->viYOrigin;
|
||||
mode1->viWidth = mode2->viWidth;
|
||||
mode1->viHeight = mode2->viHeight;
|
||||
mode1->xfbMode = mode2->xfbMode;
|
||||
mode1->field_rendering = mode2->field_rendering;
|
||||
mode1->aa = mode2->aa;
|
||||
mode1->sample_pattern[0][0] = mode2->sample_pattern[0][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[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[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[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[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[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->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];
|
||||
}
|
||||
|
||||
GXRModeObj* vmodes[] = {
|
||||
&TVNtsc240Ds,
|
||||
&TVNtsc240DsAa,
|
||||
&TVNtsc240Int,
|
||||
&TVNtsc240IntAa,
|
||||
&TVNtsc480IntDf,
|
||||
&TVNtsc480IntAa,
|
||||
&TVNtsc480Prog,
|
||||
&TVMpal480IntDf,
|
||||
&TVPal264Ds,
|
||||
&TVPal264DsAa,
|
||||
&TVPal264Int,
|
||||
&TVPal264IntAa,
|
||||
&TVPal524IntAa,
|
||||
&TVPal528Int,
|
||||
&TVPal528IntDf,
|
||||
&TVPal574IntDfScale,
|
||||
&TVEurgb60Hz240Ds,
|
||||
&TVEurgb60Hz240DsAa,
|
||||
&TVEurgb60Hz240Int,
|
||||
&TVEurgb60Hz240IntAa,
|
||||
&TVEurgb60Hz480Int,
|
||||
&TVEurgb60Hz480IntDf,
|
||||
&TVEurgb60Hz480IntAa,
|
||||
&TVEurgb60Hz480Prog,
|
||||
&TVEurgb60Hz480ProgSoft,
|
||||
&TVEurgb60Hz480ProgAa
|
||||
};
|
||||
|
||||
GXRModeObj* PAL2NTSC[]={
|
||||
&TVMpal480IntDf, &TVNtsc480IntDf,
|
||||
&TVPal264Ds, &TVNtsc240Ds,
|
||||
&TVPal264DsAa, &TVNtsc240DsAa,
|
||||
&TVPal264Int, &TVNtsc240Int,
|
||||
&TVPal264IntAa, &TVNtsc240IntAa,
|
||||
&TVPal524IntAa, &TVNtsc480IntAa,
|
||||
&TVPal528Int, &TVNtsc480IntAa,
|
||||
&TVPal528IntDf, &TVNtsc480IntDf,
|
||||
&TVPal574IntDfScale, &TVNtsc480IntDf,
|
||||
&TVEurgb60Hz240Ds, &TVNtsc240Ds,
|
||||
&TVEurgb60Hz240DsAa, &TVNtsc240DsAa,
|
||||
&TVEurgb60Hz240Int, &TVNtsc240Int,
|
||||
&TVEurgb60Hz240IntAa, &TVNtsc240IntAa,
|
||||
&TVEurgb60Hz480Int, &TVNtsc480IntAa,
|
||||
&TVEurgb60Hz480IntDf, &TVNtsc480IntDf,
|
||||
&TVEurgb60Hz480IntAa, &TVNtsc480IntAa,
|
||||
&TVEurgb60Hz480Prog, &TVNtsc480Prog,
|
||||
&TVEurgb60Hz480ProgSoft,&TVNtsc480Prog,
|
||||
&TVEurgb60Hz480ProgAa, &TVNtsc480Prog,
|
||||
0,0
|
||||
};
|
||||
|
||||
GXRModeObj* NTSC2PAL[]={
|
||||
&TVNtsc240Ds, &TVPal264Ds,
|
||||
&TVNtsc240DsAa, &TVPal264DsAa,
|
||||
&TVNtsc240Int, &TVPal264Int,
|
||||
&TVNtsc240IntAa, &TVPal264IntAa,
|
||||
&TVNtsc480IntDf, &TVPal528IntDf,
|
||||
&TVNtsc480IntAa, &TVPal524IntAa,
|
||||
&TVNtsc480Prog, &TVPal528IntDf,
|
||||
0,0
|
||||
};
|
||||
|
||||
GXRModeObj* NTSC2PAL60[]={
|
||||
&TVNtsc240Ds, &TVEurgb60Hz240Ds,
|
||||
&TVNtsc240DsAa, &TVEurgb60Hz240DsAa,
|
||||
&TVNtsc240Int, &TVEurgb60Hz240Int,
|
||||
&TVNtsc240IntAa, &TVEurgb60Hz240IntAa,
|
||||
&TVNtsc480IntDf, &TVEurgb60Hz480IntDf,
|
||||
&TVNtsc480IntAa, &TVEurgb60Hz480IntAa,
|
||||
&TVNtsc480Prog, &TVEurgb60Hz480Prog,
|
||||
0,0
|
||||
};
|
||||
bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) {
|
||||
u8 *Addr = (u8 *)Address;
|
||||
bool found = 0;
|
||||
u32 i;
|
||||
|
||||
while (Size >= sizeof(GXRModeObj)) {
|
||||
|
||||
|
||||
|
||||
for (i = 0; Table[i]; i+=2) {
|
||||
|
||||
|
||||
if (compare_videomodes(Table[i], (GXRModeObj*)Addr))
|
||||
|
||||
{
|
||||
found = 1;
|
||||
patch_videomode((GXRModeObj*)Addr, Table[i+1]);
|
||||
Addr += (sizeof(GXRModeObj)-4);
|
||||
Size -= (sizeof(GXRModeObj)-4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Addr += 4;
|
||||
Size -= 4;
|
||||
}
|
||||
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Anti 002 fix for IOS 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;
|
||||
if (videoSelected == 5) // patch
|
||||
|
||||
{
|
||||
switch (CONF_GetVideo()) {
|
||||
case CONF_VIDEO_PAL:
|
||||
if (CONF_GetEuRGB60() > 0) {
|
||||
table = NTSC2PAL60;
|
||||
} else {
|
||||
table = NTSC2PAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONF_VIDEO_MPAL:
|
||||
|
||||
|
||||
|
||||
table = NTSC2PAL;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
table = PAL2NTSC;
|
||||
break;
|
||||
}
|
||||
Search_and_patch_Video_Modes(dst, len, table);
|
||||
}
|
||||
|
||||
/*GAME HOOK - FISHEARS*/
|
||||
dogamehooks(dst,len);
|
||||
|
||||
if (vipatch)
|
||||
vidolpatcher(dst,len);
|
||||
|
||||
|
||||
/*LANGUAGE PATCH - FISHEARS*/
|
||||
langpatcher(dst,len);
|
||||
|
||||
/*Thanks to WiiPower*/
|
||||
if (patchcountrystring == 1)
|
||||
PatchCountryStrings(dst, len);
|
||||
|
||||
//if(Settings.anti002fix == on)
|
||||
if (fix002 == 2)
|
||||
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) {
|
||||
app_entry appldr_entry;
|
||||
app_init appldr_init;
|
||||
app_main appldr_main;
|
||||
app_final appldr_final;
|
||||
|
||||
u32 appldr_len;
|
||||
s32 ret;
|
||||
|
||||
/* Read apploader header */
|
||||
ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Calculate apploader length */
|
||||
appldr_len = buffer[5] + buffer[6];
|
||||
|
||||
/* Read apploader code */
|
||||
ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Set apploader entry function */
|
||||
appldr_entry = (app_entry)buffer[4];
|
||||
|
||||
/* Call apploader entry */
|
||||
appldr_entry(&appldr_init, &appldr_main, &appldr_final);
|
||||
|
||||
/* Initialize apploader */
|
||||
appldr_init(__noprint);
|
||||
|
||||
if (error002fix!=0) {
|
||||
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/
|
||||
*(u32 *)0x80003140 = *(u32 *)0x80003188;
|
||||
}
|
||||
|
||||
if (cheat) {
|
||||
/*HOOKS STUFF - FISHEARS*/
|
||||
memset((void*)0x80001800,0,kenobiwii_size);
|
||||
memcpy((void*)0x80001800,kenobiwii,kenobiwii_size);
|
||||
DCFlushRange((void*)0x80001800,kenobiwii_size);
|
||||
hooktype = 1;
|
||||
memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD
|
||||
/*HOOKS STUFF - FISHEARS*/
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
void *dst = NULL;
|
||||
int len = 0, offset = 0;
|
||||
|
||||
/* Run apploader main function */
|
||||
ret = appldr_main(&dst, &len, &offset);
|
||||
if (!ret)
|
||||
break;
|
||||
|
||||
/* Read data from DVD */
|
||||
WDVD_Read(dst, len, (u64)(offset << 2));
|
||||
|
||||
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(dst, len);
|
||||
}
|
||||
|
||||
*entry = appldr_final();
|
||||
|
||||
/** Load alternate dol if set **/
|
||||
if (alternatedol == 1) {
|
||||
void *dolbuffer;
|
||||
int dollen;
|
||||
|
||||
bool dolloaded = Load_Dol(&dolbuffer, &dollen, Settings.dolpath);
|
||||
if (dolloaded) {
|
||||
Remove_001_Protection(dolbuffer, dollen);
|
||||
|
||||
DCFlushRange(dolbuffer, dollen);
|
||||
|
||||
gamepatches(dolbuffer, dollen, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(dolbuffer, dollen);
|
||||
|
||||
/* Set entry point from apploader */
|
||||
*entry = (entry_point) load_dol_image(dolbuffer);
|
||||
}
|
||||
} else if (alternatedol == 2) {
|
||||
|
||||
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
|
||||
|
||||
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
if (*entry == 0)
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
return 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[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[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[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[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[5] != mode2->vfilter[5] || mode1->vfilter[6] != mode2->vfilter[6] ) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void patch_videomode(GXRModeObj* mode1, GXRModeObj* mode2) {
|
||||
mode1->viTVMode = mode2->viTVMode;
|
||||
mode1->fbWidth = mode2->fbWidth;
|
||||
mode1->efbHeight = mode2->efbHeight;
|
||||
mode1->xfbHeight = mode2->xfbHeight;
|
||||
mode1->viXOrigin = mode2->viXOrigin;
|
||||
mode1->viYOrigin = mode2->viYOrigin;
|
||||
mode1->viWidth = mode2->viWidth;
|
||||
mode1->viHeight = mode2->viHeight;
|
||||
mode1->xfbMode = mode2->xfbMode;
|
||||
mode1->field_rendering = mode2->field_rendering;
|
||||
mode1->aa = mode2->aa;
|
||||
mode1->sample_pattern[0][0] = mode2->sample_pattern[0][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[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[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[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[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[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->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];
|
||||
}
|
||||
|
||||
GXRModeObj* vmodes[] = {
|
||||
&TVNtsc240Ds,
|
||||
&TVNtsc240DsAa,
|
||||
&TVNtsc240Int,
|
||||
&TVNtsc240IntAa,
|
||||
&TVNtsc480IntDf,
|
||||
&TVNtsc480IntAa,
|
||||
&TVNtsc480Prog,
|
||||
&TVMpal480IntDf,
|
||||
&TVPal264Ds,
|
||||
&TVPal264DsAa,
|
||||
&TVPal264Int,
|
||||
&TVPal264IntAa,
|
||||
&TVPal524IntAa,
|
||||
&TVPal528Int,
|
||||
&TVPal528IntDf,
|
||||
&TVPal574IntDfScale,
|
||||
&TVEurgb60Hz240Ds,
|
||||
&TVEurgb60Hz240DsAa,
|
||||
&TVEurgb60Hz240Int,
|
||||
&TVEurgb60Hz240IntAa,
|
||||
&TVEurgb60Hz480Int,
|
||||
&TVEurgb60Hz480IntDf,
|
||||
&TVEurgb60Hz480IntAa,
|
||||
&TVEurgb60Hz480Prog,
|
||||
&TVEurgb60Hz480ProgSoft,
|
||||
&TVEurgb60Hz480ProgAa
|
||||
};
|
||||
|
||||
GXRModeObj* PAL2NTSC[]={
|
||||
&TVMpal480IntDf, &TVNtsc480IntDf,
|
||||
&TVPal264Ds, &TVNtsc240Ds,
|
||||
&TVPal264DsAa, &TVNtsc240DsAa,
|
||||
&TVPal264Int, &TVNtsc240Int,
|
||||
&TVPal264IntAa, &TVNtsc240IntAa,
|
||||
&TVPal524IntAa, &TVNtsc480IntAa,
|
||||
&TVPal528Int, &TVNtsc480IntAa,
|
||||
&TVPal528IntDf, &TVNtsc480IntDf,
|
||||
&TVPal574IntDfScale, &TVNtsc480IntDf,
|
||||
&TVEurgb60Hz240Ds, &TVNtsc240Ds,
|
||||
&TVEurgb60Hz240DsAa, &TVNtsc240DsAa,
|
||||
&TVEurgb60Hz240Int, &TVNtsc240Int,
|
||||
&TVEurgb60Hz240IntAa, &TVNtsc240IntAa,
|
||||
&TVEurgb60Hz480Int, &TVNtsc480IntAa,
|
||||
&TVEurgb60Hz480IntDf, &TVNtsc480IntDf,
|
||||
&TVEurgb60Hz480IntAa, &TVNtsc480IntAa,
|
||||
&TVEurgb60Hz480Prog, &TVNtsc480Prog,
|
||||
&TVEurgb60Hz480ProgSoft,&TVNtsc480Prog,
|
||||
&TVEurgb60Hz480ProgAa, &TVNtsc480Prog,
|
||||
0,0
|
||||
};
|
||||
|
||||
GXRModeObj* NTSC2PAL[]={
|
||||
&TVNtsc240Ds, &TVPal264Ds,
|
||||
&TVNtsc240DsAa, &TVPal264DsAa,
|
||||
&TVNtsc240Int, &TVPal264Int,
|
||||
&TVNtsc240IntAa, &TVPal264IntAa,
|
||||
&TVNtsc480IntDf, &TVPal528IntDf,
|
||||
&TVNtsc480IntAa, &TVPal524IntAa,
|
||||
&TVNtsc480Prog, &TVPal528IntDf,
|
||||
0,0
|
||||
};
|
||||
|
||||
GXRModeObj* NTSC2PAL60[]={
|
||||
&TVNtsc240Ds, &TVEurgb60Hz240Ds,
|
||||
&TVNtsc240DsAa, &TVEurgb60Hz240DsAa,
|
||||
&TVNtsc240Int, &TVEurgb60Hz240Int,
|
||||
&TVNtsc240IntAa, &TVEurgb60Hz240IntAa,
|
||||
&TVNtsc480IntDf, &TVEurgb60Hz480IntDf,
|
||||
&TVNtsc480IntAa, &TVEurgb60Hz480IntAa,
|
||||
&TVNtsc480Prog, &TVEurgb60Hz480Prog,
|
||||
0,0
|
||||
};
|
||||
bool Search_and_patch_Video_Modes(void *Address, u32 Size, GXRModeObj* Table[]) {
|
||||
u8 *Addr = (u8 *)Address;
|
||||
bool found = 0;
|
||||
u32 i;
|
||||
|
||||
while (Size >= sizeof(GXRModeObj)) {
|
||||
|
||||
|
||||
|
||||
for (i = 0; Table[i]; i+=2) {
|
||||
|
||||
|
||||
if (compare_videomodes(Table[i], (GXRModeObj*)Addr))
|
||||
|
||||
{
|
||||
found = 1;
|
||||
patch_videomode((GXRModeObj*)Addr, Table[i+1]);
|
||||
Addr += (sizeof(GXRModeObj)-4);
|
||||
Size -= (sizeof(GXRModeObj)-4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Addr += 4;
|
||||
Size -= 4;
|
||||
}
|
||||
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
/** Anti 002 fix for IOS 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;
|
||||
if (videoSelected == 5) // patch
|
||||
|
||||
{
|
||||
switch (CONF_GetVideo()) {
|
||||
case CONF_VIDEO_PAL:
|
||||
if (CONF_GetEuRGB60() > 0) {
|
||||
table = NTSC2PAL60;
|
||||
} else {
|
||||
table = NTSC2PAL;
|
||||
}
|
||||
break;
|
||||
|
||||
case CONF_VIDEO_MPAL:
|
||||
|
||||
|
||||
|
||||
table = NTSC2PAL;
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
table = PAL2NTSC;
|
||||
break;
|
||||
}
|
||||
Search_and_patch_Video_Modes(dst, len, table);
|
||||
}
|
||||
|
||||
/*GAME HOOK - FISHEARS*/
|
||||
dogamehooks(dst,len);
|
||||
|
||||
if (vipatch)
|
||||
vidolpatcher(dst,len);
|
||||
|
||||
|
||||
/*LANGUAGE PATCH - FISHEARS*/
|
||||
langpatcher(dst,len);
|
||||
|
||||
/*Thanks to WiiPower*/
|
||||
if (patchcountrystring == 1)
|
||||
PatchCountryStrings(dst, len);
|
||||
|
||||
//if(Settings.anti002fix == on)
|
||||
if (fix002 == 2)
|
||||
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) {
|
||||
app_entry appldr_entry;
|
||||
app_init appldr_init;
|
||||
app_main appldr_main;
|
||||
app_final appldr_final;
|
||||
|
||||
u32 appldr_len;
|
||||
s32 ret;
|
||||
|
||||
/* Read apploader header */
|
||||
ret = WDVD_Read(buffer, 0x20, APPLDR_OFFSET);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Calculate apploader length */
|
||||
appldr_len = buffer[5] + buffer[6];
|
||||
|
||||
/* Read apploader code */
|
||||
ret = WDVD_Read(appldr, appldr_len, APPLDR_OFFSET + 0x20);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Set apploader entry function */
|
||||
appldr_entry = (app_entry)buffer[4];
|
||||
|
||||
/* Call apploader entry */
|
||||
appldr_entry(&appldr_init, &appldr_main, &appldr_final);
|
||||
|
||||
/* Initialize apploader */
|
||||
appldr_init(__noprint);
|
||||
|
||||
if (error002fix!=0) {
|
||||
/* ERROR 002 fix (thanks to WiiPower for sharing this)*/
|
||||
*(u32 *)0x80003140 = *(u32 *)0x80003188;
|
||||
}
|
||||
|
||||
if (cheat) {
|
||||
/*HOOKS STUFF - FISHEARS*/
|
||||
memset((void*)0x80001800,0,kenobiwii_size);
|
||||
memcpy((void*)0x80001800,kenobiwii,kenobiwii_size);
|
||||
DCFlushRange((void*)0x80001800,kenobiwii_size);
|
||||
hooktype = 1;
|
||||
memcpy((void*)0x80001800, (char*)0x80000000, 6); // For WiiRD
|
||||
/*HOOKS STUFF - FISHEARS*/
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
void *dst = NULL;
|
||||
int len = 0, offset = 0;
|
||||
|
||||
/* Run apploader main function */
|
||||
ret = appldr_main(&dst, &len, &offset);
|
||||
if (!ret)
|
||||
break;
|
||||
|
||||
/* Read data from DVD */
|
||||
WDVD_Read(dst, len, (u64)(offset << 2));
|
||||
|
||||
gamepatches(dst, len, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(dst, len);
|
||||
}
|
||||
|
||||
*entry = appldr_final();
|
||||
|
||||
/** Load alternate dol if set **/
|
||||
if (alternatedol == 1) {
|
||||
void *dolbuffer;
|
||||
int dollen;
|
||||
|
||||
bool dolloaded = Load_Dol(&dolbuffer, &dollen, Settings.dolpath);
|
||||
if (dolloaded) {
|
||||
Remove_001_Protection(dolbuffer, dollen);
|
||||
|
||||
DCFlushRange(dolbuffer, dollen);
|
||||
|
||||
gamepatches(dolbuffer, dollen, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
DCFlushRange(dolbuffer, dollen);
|
||||
|
||||
/* Set entry point from apploader */
|
||||
*entry = (entry_point) load_dol_image(dolbuffer);
|
||||
}
|
||||
} else if (alternatedol == 2) {
|
||||
|
||||
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;
|
||||
|
||||
*entry = (entry_point) Load_Dol_from_disc(fst[alternatedoloffset].fileoffset, videoSelected, patchcountrystring, vipatch);
|
||||
|
||||
if (*entry == 0)
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user