sprinkled gprintf() throughout the source some more.

added functions to mess with the "return to" stub.  everything should be working right, but if i messed up, it may cause you not to be able to exit the program (it could just keep restarting itself).  now when booting homebrew, they should exit back to this program if you have a channel installed as UNEO or ULNR.  priority is given to UNEO if both are present.
This commit is contained in:
giantpune 2009-10-20 23:00:19 +00:00
parent 6a378e3523
commit b753af6d4d
15 changed files with 318 additions and 69 deletions

View File

@ -105,6 +105,8 @@ export OUTPUT := $(CURDIR)/$(TARGET)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
# @echo debug...
# start geckoreader.exe
#---------------------------------------------------------------------------------
lang:
@ -181,6 +183,9 @@ language: $(wildcard $(PROJECTDIR)/Languages/*.lang)
%.dat.o : %.dat
@echo $(notdir $<)
$(bin2o)
%.bin.o : %.bin
@echo $(notdir $<)
$(bin2o)
export PATH := $(PROJECTDIR)/gettext-bin:$(PATH)

BIN
data/stub.bin Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="false"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="false"></e></ViewState></pd>
<pd><ViewState><e p="gui\source\mload" x="false"></e><e p="gui\source\settings" x="false"></e><e p="gui\source\images" x="false"></e><e p="gui\source\prompts" x="true"></e><e p="gui\source\banner" x="false"></e><e p="gui\source\cheats" x="false"></e><e p="gui\source\network" x="true"></e><e p="gui\source\unzip" x="false"></e><e p="gui\source\usbloader" x="true"></e><e p="gui\source\xml" x="false"></e><e p="gui\source\fonts" x="false"></e><e p="gui\source\ramdisc" x="false"></e><e p="gui\source\sounds" x="false"></e><e p="gui\source\wad" x="false"></e><e p="gui" x="true"></e><e p="gui\source\homebrewboot" x="false"></e><e p="gui\source\language" x="false"></e><e p="gui\source" x="true"></e><e p="gui\source\libwbfs" x="false"></e><e p="gui\source\libwiigui" x="true"></e><e p="gui\source\patches" x="false"></e></ViewState></pd>

View File

@ -106,7 +106,7 @@ static char * number(char * str, long num, int base, int size, int precision
return str;
}
int kvsprintf(char *buf, const char *fmt, va_list args)
int kvsprintf1(char *buf, const char *fmt, va_list args)
{
int len;
unsigned long num;
@ -298,9 +298,8 @@ void gprintf(const char *str, ...)
va_list args;
va_start(args, str);
len=kvsprintf(__outstr,str,args);
len=kvsprintf1(__outstr,str,args);
va_end(args);
write(2, __outstr, len);
usb_sendbuffer_safe(1,__outstr,len);
}

View File

@ -1,7 +1,20 @@
#ifndef _GECKO_H_
#define _GECKO_H_
#ifdef __cplusplus
extern "C" {
#endif
//giantpune's functions for USB gecko
//use this just like printf();
void gprintf(const char *str, ...);
bool InitGecko();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -6,6 +6,7 @@
#include <unistd.h>
#include <ogc/machine/processor.h>
#include <wiiuse/wpad.h>
#include "../lstub.h"
#include "fatmounter.h"
#include "dolloader.h"
@ -36,6 +37,9 @@ void CopyHomebrewMemory(u32 read, u8 *temp, u32 len) {
}
int BootHomebrew(char * path) {
loadStub();
if (Set_Stub_Split(0x00010001,"UNEO")<0)
Set_Stub_Split(0x00010001,"ULNR");
void *buffer = NULL;
u32 filesize = 0;
entrypoint entry;
@ -102,6 +106,9 @@ int BootHomebrew(char * path) {
}
int BootHomebrewFromMem() {
loadStub();
if (Set_Stub_Split(0x00010001,"UNEO")<0)
Set_Stub_Split(0x00010001,"ULNR");
entrypoint entry;
u32 cpu_isr;

122
source/lstub.c Normal file
View File

@ -0,0 +1,122 @@
//functions for manipulating the HBC stub by giantpune
#include <string.h>
#include <ogcsys.h>
#include <malloc.h>
#include <stdio.h>
#include "lstub.h"
#include "stub_bin.h"
#define TITLE_1(x) ((u8)((x) >> 8))
#define TITLE_2(x) ((u8)((x) >> 16))
#define TITLE_3(x) ((u8)((x) >> 24))
#define TITLE_4(x) ((u8)((x) >> 32))
#define TITLE_5(x) ((u8)((x) >> 40))
#define TITLE_6(x) ((u8)((x) >> 48))
#define TITLE_7(x) ((u8)((x) >> 56))
#define TITLE_ID(x,y) (((u64)(x) << 32) | (y))
s32 Set_Stub(u64 reqID)
{
u32 tmdsize;
u64 tid = 0;
u64 *list;
u32 titlecount;
s32 ret;
u32 i;
ret = ES_GetNumTitles(&titlecount);
if(ret < 0)
return WII_EINTERNAL;
list = memalign(32, titlecount * sizeof(u64) + 32);
ret = ES_GetTitles(list, titlecount);
if(ret < 0) {
free(list);
return WII_EINTERNAL;
}
for(i=0; i<titlecount; i++) {
if (list[i]==reqID)
{
tid = list[i];
break;
}
}
free(list);
if(!tid)
return -69;//id to stub is not installed
if(ES_GetStoredTMDSize(tid, &tmdsize) < 0)
return WII_EINSTALL;
char *stub = (char *)0x800024C6;
stub[0] = TITLE_7(reqID);
stub[1] = TITLE_6(reqID);
stub[8] = TITLE_5(reqID);
stub[9] = TITLE_4(reqID);
stub[4] = TITLE_3(reqID);
stub[5] = TITLE_2(reqID);
stub[12] = TITLE_1(reqID);
stub[13] = ((u8)(reqID));
return 1;
}
s32 Set_Stub_Split(u32 type, const char* reqID)
{
char tmp[4];
u32 lower;
sprintf(tmp,"%c%c%c%c",reqID[0],reqID[1],reqID[2],reqID[3]);
memcpy(&lower, tmp, 4);
u64 reqID64 = TITLE_ID(type, lower);
return Set_Stub(reqID64);
}
void loadStub()
{
char *stubLoc = (char *)0x80001800;
memcpy(stubLoc, stub_bin, stub_bin_size);
}
u64 getStubDest()
{
char * sig = (char *)0x80001804;
if (!(
sig[0] == 'S' &&
sig[1] == 'T' &&
sig[2] == 'U' &&
sig[3] == 'B' &&
sig[4] == 'H' &&
sig[5] == 'A' &&
sig[6] == 'X' &&
sig[7] == 'X'))
return 0;
char *stub = (char *)0x800024C6;
char ret[8];
u64 retu =0;
ret[0] = stub[0];
ret[1] = stub[1];
ret[2] = stub[8];
ret[3] = stub[9];
ret[4] = stub[4];
ret[5] = stub[5];
ret[6] = stub[12];
ret[7] = stub[13];
ret[8] = 0x00;
memcpy(&retu, ret, 8);
return retu;
}

37
source/lstub.h Normal file
View File

@ -0,0 +1,37 @@
//small group of functions to manipulate the HBC stub
//brought to you by giantpune
#ifndef _LSTUB_H_
#define _LSTUB_H_
#ifdef __cplusplus
extern "C" {
#endif
//to set the "return to" stub for a certain ID
//!reqID is the Requested ID to return to
//!returns WII_EINTERNAL if it cant get the list of installed titles with ES functions
//!retuns -69 if the ID is not installed
//!1 if successful
s32 Set_Stub(u64 reqID);
//!same as the above function, but expects a type and 4 char channel ID
s32 Set_Stub_Split(u32 type, const char* reqID);
//load the default HBC stub into memory. as long as nothing writes to the 0x80001800
// +0xDC7 memory block it will stay there. by default it has 0x00010001/JODI.
void loadStub();
//get whatever ID the stub is set to load
//!returns 0 if no stub is loaded into memory (must be the HBC stub at 0x800018000)
//!otherwise returns the ID set to return to
u64 getStubDest();
#ifdef __cplusplus
}
#endif
#endif

View File

@ -35,6 +35,7 @@
#include "wpad.h"
#include "fat.h"
#include "gecko.h"
#include "svnrev.h"
extern bool geckoinit;
@ -128,7 +129,11 @@ main(int argc, char *argv[]) {
setlocale(LC_ALL, "en.UTF-8");
geckoinit = InitGecko();
gprintf("\x1b[2J");
gprintf("------------------");
gprintf("\nUSB Loader GX rev%s",GetRev());
gprintf("\nmain(int argc, char *argv[])");
s32 ret;
bool startupproblem = false;
@ -141,7 +146,7 @@ main(int argc, char *argv[]) {
} else if (!strncasecmp(argv[0], "sd:/", 4))
bootDevice_found = true;
}
/** PAD_Init has to be before InitVideo don't move that **/
PAD_Init(); // initialize PAD/WPAD
@ -160,7 +165,7 @@ main(int argc, char *argv[]) {
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
}
ret = WBFS_Init(WBFS_DEVICE_USB);
if (ret < 0) {
@ -189,6 +194,7 @@ main(int argc, char *argv[]) {
SDCard_Init(); // mount SD for loading cfg's
USBDevice_Init(); // and mount USB:/
gprintf("\n\tSD and USB Init OK");
if (!bootDevice_found) {
//try USB
@ -201,6 +207,7 @@ main(int argc, char *argv[]) {
gettextCleanUp();
CFG_Load();
gprintf("\n\tbootDevice = %s",bootDevice);
/* Load Custom IOS */
if (Settings.cios == ios222 && IOS_GetVersion() != 222) {
@ -235,6 +242,7 @@ main(int argc, char *argv[]) {
sleep(5);
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
}
gprintf("\n\tcIOS = %u (Rev %u)",IOS_GetVersion(), IOS_GetRevision());
//! Init the rest of the System
Sys_Init();

View File

@ -398,15 +398,6 @@ int MenuDiscList() {
GuiImageData btnsdcard(imgPath, sdcard_png);
snprintf(imgPath, sizeof(imgPath), "%sbattery.png", CFG.theme_path);
GuiImageData battery(imgPath, battery_png);
snprintf(imgPath, sizeof(imgPath), "%sbattery_bar.png", CFG.theme_path);
GuiImageData batteryBar(imgPath, battery_bar_png);
snprintf(imgPath, sizeof(imgPath), "%sbattery_red.png", CFG.theme_path);
GuiImageData batteryRed(imgPath, battery_red_png);
snprintf(imgPath, sizeof(imgPath), "%sbattery_bar_red.png", CFG.theme_path);
GuiImageData batteryBarRed(imgPath, battery_bar_red_png);
snprintf(imgPath, sizeof(imgPath), "%sfavIcon.png", CFG.theme_path);
GuiImageData imgfavIcon(imgPath, favIcon_png);
snprintf(imgPath, sizeof(imgPath), "%sfavIcon_gray.png", CFG.theme_path);
@ -864,6 +855,7 @@ int MenuDiscList() {
while (menu == MENU_NONE) {
if (idiotFlag==1) {
gprintf("\n\tIdiot flag");
char idiotBuffer[200];
snprintf(idiotBuffer, sizeof(idiotBuffer), "%s (%s). %s",tr("You have attempted to load a bad image"),
idiotChar,tr("Most likely it has dimensions that are not evenly divisible by 4."));
@ -922,12 +914,14 @@ int MenuDiscList() {
if ((datagB<1)&&(Settings.cios==1)&&(Settings.video == ntsc)&&(Settings.hddinfo == hr12)&&(Settings.qboot==1)&&(Settings.wsprompt==0)&&(Settings.language==ger)&&(Settings.tooltips==0)){dataed=1;dataef=1;}if (dataef==1){if (cosa>7){cosa=1;}datag++;if (sina==3){wiiBtn.SetAlignment(ALIGN_LEFT,ALIGN_BOTTOM);wiiBtnImg.SetAngle(0);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),((datag*2)-130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==2){wiiBtn.SetAlignment(ALIGN_RIGHT,ALIGN_TOP);wiiBtnImg.SetAngle(270);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((-2*(datag)+130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((2*(datag)-120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==1){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(180);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((cosa)*70),(2*(datag)-120));}else if(62<=datag){wiiBtn.SetPosition(((cosa)*70),(-2*(datag)+130));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}if (sina==0){wiiBtn.SetAlignment(ALIGN_TOP,ALIGN_LEFT);wiiBtnImg.SetAngle(90);if(datag>163){datag=1;}else if (datag<62){wiiBtn.SetPosition(((2*(datag)-130)),((cosa)*50));}else if(62<=datag){wiiBtn.SetPosition((-2*(datag)+120),((cosa)*50));}if (datag>162){wiiBtn.SetPosition(700,700);w.Remove(&wiiBtn);datagB=2;cosa++;sina=lastrawtime%4;}w.Append(&wiiBtn);}}
// respond to button presses
if (shutdown == 1) {
gprintf("\n\tshutdown");
Sys_Shutdown();
}
if (reset == 1)
Sys_Reboot();
if (updateavailable == true) {
gprintf("\n\tUpdate Available");
HaltGui();
GuiWindow ww(640,480);
w.SetState(STATE_DISABLED);
@ -943,6 +937,7 @@ int MenuDiscList() {
if (poweroffBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tpoweroffBtn clicked");
choice = WindowPrompt(tr("How to Shutdown?"),0,tr("Full Shutdown"), tr("Shutdown to Idle"), tr("Cancel"));
if (choice == 2) {
Sys_ShutdownToIdel();
@ -960,7 +955,8 @@ int MenuDiscList() {
}
} else if (gamecntBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
gamecntBtn.ResetState();
gprintf("\n\tgameCntBtn clicked");
gamecntBtn.ResetState();
char linebuf[150];
snprintf(linebuf, sizeof(linebuf), "%s %sGameList ?",tr("Save Game List to"), Settings.update_path);
choice = WindowPrompt(0,linebuf,"TXT","CSV",tr("Back"));
@ -974,6 +970,7 @@ int MenuDiscList() {
break;
} else if (homeBtn.GetState() == STATE_CLICKED) {
gprintf("\n\thomeBtn clicked");
s32 thetimeofbg = bgMusic->GetPlayTime();
bgMusic->Stop();
choice = WindowExitPrompt(tr("Exit USB Loader GX?"),0, tr("Back to Loader"),tr("Wii Menu"),tr("Back"),0);
@ -1001,6 +998,8 @@ int MenuDiscList() {
}
} else if (wiiBtn.GetState() == STATE_CLICKED) {
gprintf("\n\twiiBtn clicked");
dataed++;
wiiBtn.ResetState();
if (Settings.gameDisplay==list) {
@ -1011,6 +1010,7 @@ int MenuDiscList() {
gameCarousel->SetFocus(1);
}
} else if (installBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tinstallBtn clicked");
choice = WindowPrompt(tr("Install a game"),0,tr("Yes"),tr("No"));
if (choice == 1) {
menu = MENU_INSTALL;
@ -1026,6 +1026,7 @@ int MenuDiscList() {
}
}
}else if ((covert & 0x2)&&(covert!=covertOld)) {
gprintf("\n\tNew Disc Detected");
choice = WindowPrompt(tr("New Disc Detected"),0,tr("Install"),tr("Mount DVD drive"),tr("Cancel"));
if (choice == 1) {
menu = MENU_INSTALL;
@ -1046,6 +1047,7 @@ int MenuDiscList() {
}
else if (sdcardBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tsdCardBtn Clicked");
SDCard_deInit();
SDCard_Init();
if (Settings.gameDisplay==list) {
@ -1069,6 +1071,7 @@ int MenuDiscList() {
}
else if (DownloadBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tDownloadBtn Clicked");
if (isInserted(bootDevice)) {
choice = WindowPrompt(tr("Cover Download"), 0, tr("Normal Covers"), tr("3D Covers"), tr("Disc Images"), tr("Back")); // ask for download choice
if (choice != 0) {
@ -1110,6 +1113,7 @@ int MenuDiscList() {
}//end download
else if (settingsBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tsettingsBtn Clicked");
if (Settings.gameDisplay==list) {
startat = gameBrowser->GetSelectedOption();
offset = gameBrowser->GetOffset();
@ -1126,6 +1130,7 @@ int MenuDiscList() {
}
else if (favoriteBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tfavoriteBtn Clicked");
Settings.fave=!Settings.fave;
if (isInserted(bootDevice)) {
cfg_save_global();
@ -1138,6 +1143,7 @@ int MenuDiscList() {
else if (searchBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
gprintf("\n\tsearchBtn Clicked");
show_searchwindow=!show_searchwindow;
HaltGui();
if(searchBar)
@ -1219,6 +1225,7 @@ int MenuDiscList() {
}
else if (abcBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tabcBtn clicked");
if (Settings.sort != all) {
Settings.sort=all;
if (isInserted(bootDevice)) {
@ -1233,6 +1240,7 @@ int MenuDiscList() {
}
else if (countBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tcountBtn Clicked");
if (Settings.sort != pcount) {
Settings.sort=pcount;
//if(isSdInserted()) {
@ -1249,6 +1257,7 @@ int MenuDiscList() {
}
else if (listBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tlistBtn Clicked");
if (Settings.gameDisplay!=list) {
Settings.gameDisplay=list;
menu = MENU_DISCLIST;
@ -1264,6 +1273,7 @@ int MenuDiscList() {
else if (gridBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tgridBtn Clicked");
if (Settings.gameDisplay!=grid) {
Settings.gameDisplay=grid;
@ -1279,6 +1289,7 @@ int MenuDiscList() {
}
else if (carouselBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tcarouselBtn Clicked");
if (Settings.gameDisplay!=carousel) {
Settings.gameDisplay=carousel;
menu = MENU_DISCLIST;
@ -1291,10 +1302,12 @@ int MenuDiscList() {
carouselBtn.ResetState();
}
} else if (homebrewBtn.GetState() == STATE_CLICKED) {
gprintf("\n\thomebrewBtn Clicked");
menu = MENU_HOMEBREWBROWSE;
break;
} else if (gameInfo.GetState() == STATE_CLICKED && mountMethod!=3) {
gameInfo.ResetState();
gprintf("\n\tgameinfo Clicked");
gameInfo.ResetState();
if(selectImg1>=0 && selectImg1<(s32)gameCnt) {
gameSelected = selectImg1;
rockout();
@ -1311,7 +1324,8 @@ int MenuDiscList() {
}
}
else if (dvdBtn.GetState() == STATE_CLICKED) {
mountMethodOLD = (mountMethod==3?mountMethod:0);
gprintf("\n\tdvdBtn Clicked");
mountMethodOLD = (mountMethod==3?mountMethod:0);
mountMethod=DiscMount(dvdheader);
dvdBtn.ResetState();
@ -1431,7 +1445,8 @@ int MenuDiscList() {
}
if (idBtn.GetState() == STATE_CLICKED && mountMethod!=3) {
struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()];
gprintf("\n\tidBtn Clicked");
struct discHdr * header = &gameList[gameBrowser->GetSelectedOption()];
//enter new game ID
char entered[10];
snprintf(entered, sizeof(entered), "%s", IDfull);
@ -1507,7 +1522,8 @@ int MenuDiscList() {
sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull);
exeFile = fopen (nipple ,"rb");
if (exeFile==NULL) {
sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats."));
gprintf("\n\ttried to load missing gct.");
sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats."));
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
} else {
fseek (exeFile, 0, SEEK_END);
@ -1515,7 +1531,8 @@ int MenuDiscList() {
rewind (exeFile);
fclose(exeFile);
if (size>2056) {
sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results."));
gprintf("\n\tgct is too big");
sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results."));
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
}
}
@ -1537,6 +1554,8 @@ int MenuDiscList() {
playcount += 1;
CFG_save_game_num(header->id);
gprintf("\n\tplaycount for %c%c%c%c%c%c raised to %i",header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5],playcount);
}
menu = MENU_EXIT;
break;
@ -1555,7 +1574,8 @@ int MenuDiscList() {
sprintf(nipple, "%s%s.dol",Settings.dolpath,IDfull);
exeFile = fopen (nipple ,"rb");
if (exeFile==NULL) {
sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot."));
gprintf("\n\tTried to load alt dol that isn't there");
sprintf(nipple, "%s %s",nipple,tr("does not exist! You Messed something up, Idiot."));
WindowPrompt(tr("Error"),nipple,tr("OK"));
menu = MENU_CHECK;
wiilight(0);
@ -1569,7 +1589,8 @@ int MenuDiscList() {
sprintf(nipple, "%s%s.gct",Settings.Cheatcodespath,IDfull);
exeFile = fopen (nipple ,"rb");
if (exeFile==NULL) {
sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats."));
gprintf("\n\ttried to load gct file that isn't there");
sprintf(nipple, "%s %s",nipple,tr("does not exist! Loading game without cheats."));
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
} else {
fseek (exeFile, 0, SEEK_END);
@ -1577,7 +1598,8 @@ int MenuDiscList() {
rewind (exeFile);
fclose(exeFile);
if (size>2056) {
sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results."));
gprintf("\n\tgct file is too big");
sprintf(nipple, "%s %s",nipple,tr("contains over 255 lines of code. It will produce unexpected results."));
WindowPrompt(tr("Error"),nipple,NULL,NULL,NULL,NULL,170);
}
}
@ -1722,6 +1744,8 @@ int MenuDiscList() {
***************************************************************************/
static int MenuInstall() {
gprintf("\nMenuInstall()");
int menu = MENU_NONE;
static struct discHdr headerdisc ATTRIBUTE_ALIGN(32);
@ -2036,6 +2060,7 @@ static int MenuFormat() {
* MenuCheck
***************************************************************************/
static int MenuCheck() {
gprintf("\nMenuCheck()");
int menu = MENU_NONE;
int i = 0;
int choice;
@ -2192,6 +2217,7 @@ int MainMenu(int menu) {
WindowPrompt(0,tmp,0,0,0,0,100);
}
*/
gprintf("\nExiting main GUI");
CloseXMLDatabase();
ExitGUIThreads();
bgMusic->Stop();
@ -2217,18 +2243,22 @@ int MainMenu(int menu) {
u32 tid;
sprintf(tmp,"%c%c%c%c",header->id[0],header->id[1],header->id[2],header->id[3]);
memcpy(&tid, tmp, 4);
gprintf("\nBooting title %016llx",TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid));
WII_Initialize();
WII_LaunchTitle(TITLE_ID((header->id[5]=='1'?0x00010001:0x00010002),tid));
}
if (mountMethod==2)
{
gprintf("\nLoading BC for GameCube");
WII_Initialize();
WII_LaunchTitle(0x0000000100000100ULL);
}
if (boothomebrew == 1) {
gprintf("\nBootHomebrew");
BootHomebrew(Settings.selected_homebrew);
} else if (boothomebrew == 2) {
gprintf("\nBootHomebrewFromMenu");
BootHomebrewFromMem();
} else {
@ -2299,12 +2329,16 @@ int MainMenu(int menu) {
{
ret = Disc_SetUSB(header->id);
if (ret < 0) Sys_BackToLoader();
gprintf("\n\tUSB set to game");
}
else gprintf("\n\tUSB not set, loading DVD");
ret = Disc_Open();
if (ret < 0) Sys_BackToLoader();
SDCard_deInit();
USBDevice_deInit();
gprintf("\n\tSD and USB DeInit");
if (gameList){
free(gameList);
@ -2441,7 +2475,7 @@ int MainMenu(int menu) {
vipatch = 0;
break;
}
gprintf("\n\tDisc_wiiBoot");
ret = Disc_WiiBoot(videoselected, cheat, vipatch, countrystrings, errorfixer002, alternatedol, alternatedoloffset);
if (ret < 0) {
Sys_LoadMenu();

View File

@ -18,10 +18,9 @@
#include "settings/cfg.h"
#include "memory.h"
#include "../wad/title.h"
#include "../gecko.h"
#include "../patches/dvd_broadway.h"
#define BC 0x0000000100000100ULL
/*** Extern functions ***/
extern void ResumeGui();
extern void HaltGui();
@ -36,6 +35,7 @@ extern u8 mountMethod;
*Disk Browser
*********************************************************************************/
int DiscBrowse(struct discHdr * header) {
gprintf("\nDiscBrowser() started");
bool exit = false;
int ret, choice;
u64 offset;
@ -134,7 +134,7 @@ int DiscBrowse(struct discHdr * header) {
dolfilecount++;
}
}
gprintf("\n%i alt dols found",dolfilecount);
if (dolfilecount <= 0) {
WindowPrompt(tr("ERROR"), tr("No DOL file found on disc."), tr("OK"));
free(fstbuffer);
@ -238,6 +238,7 @@ int DiscBrowse(struct discHdr * header) {
int autoSelectDol(const char *id, bool force) {
gprintf("\nautoSelectDol() started");
char id4[10];
sprintf(id4,"%c%c%c%c",id[0],id[1],id[2],id[3]);
@ -499,6 +500,7 @@ void __dvd_readidcb(s32 result)
}
u8 DiscMount(discHdr *header) {
gprintf("\nDiscMount() ");
int ret;
HaltGui();

View File

@ -35,6 +35,10 @@
#include "xml/xml.h"
#include "../wad/title.h"
#include "language/UpdateLanguage.h"
#include "gecko.h"
#include "../lstub.h"
/*** Variables that are also used extern ***/
@ -66,6 +70,7 @@ extern void HaltGui();
* into the specified variable.
***************************************************************************/
int OnScreenKeyboard(char * var, u32 maxlen, int min) {
int save = -1;
int keyset = 0;
if (Settings.keyset == us) keyset = 0;
@ -73,6 +78,8 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min) {
else if (Settings.keyset == euro) keyset = 2;
else if (Settings.keyset == azerty) keyset = 3;
else if (Settings.keyset == qwerty) keyset = 4;
gprintf("\nOnScreenKeyboard(%s, %i, %i) \n\tkeyset = %i",var,maxlen,min,keyset);
GuiKeyboard keyboard(var, maxlen, min, keyset);
@ -132,6 +139,7 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min) {
mainWindow->Remove(&keyboard);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
gprintf("\t%s",(save?"saved":"discarded"));
return save;
}
@ -140,6 +148,8 @@ int OnScreenKeyboard(char * var, u32 maxlen, int min) {
* Display credits
***************************************************************************/
void WindowCredits() {
gprintf("\nWindowCredits()");
int angle = 0;
GuiSound * creditsMusic = NULL;
@ -362,6 +372,7 @@ void WindowCredits() {
* Display screensaver
***************************************************************************/
int WindowScreensaver() {
gprintf("\nWindowScreenSaver()");
int i = 0;
bool exit = false;
//char imgPath[100];//uncomment for themable screensaver
@ -419,12 +430,13 @@ int WindowScreensaver() {
* If title/subtitle or one of the buttons is not needed give him a 0 on that
* place.
***************************************************************************/
int
WindowPrompt(const char *title, const char *msg, const char *btn1Label,
int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
const char *btn2Label, const char *btn3Label,
const char *btn4Label, int wait) {
int choice = -1;
int count = wait;
gprintf("\nWindowPrompt(%s, %s, %s, %s, %s, %s, %i)",title,msg,btn1Label,btn2Label, btn3Label,btn4Label,wait);
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
@ -654,6 +666,8 @@ WindowPrompt(const char *title, const char *msg, const char *btn1Label,
mainWindow->Remove(&promptWindow);
mainWindow->SetState(STATE_DEFAULT);
ResumeGui();
gprintf(" = %i",choice);
return choice;
}
@ -671,6 +685,8 @@ int
WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
const char *btn2Label, const char *btn3Label,
const char *btn4Label) {
gprintf("\nWindowExitPrompt()");
GuiSound * homein = NULL;
homein = new GuiSound(menuin_ogg, menuin_ogg_size, SOUND_OGG, Settings.sfxvolume);
homein->SetVolume(Settings.sfxvolume);
@ -684,8 +700,13 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
int choice = -1;
char imgPath[100];
u8 HBC=0;
GuiWindow promptWindow(640,480);
u64 oldstub = getStubDest();
loadStub();
if (oldstub != 0x00010001554c4e52ll && oldstub != 0x00010001554e454fll)
Set_Stub(oldstub);
GuiWindow promptWindow(640,480);
promptWindow.SetAlignment(ALIGN_LEFT, ALIGN_TOP);
promptWindow.SetPosition(0, 0);
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM, Settings.sfxvolume);
@ -750,20 +771,9 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
batteryBtn[3]->SetPosition(494, 150);
char * sig = (char *)0x80001804;
if (
sig[0] == 'S' &&
sig[1] == 'T' &&
sig[2] == 'U' &&
sig[3] == 'B' &&
sig[4] == 'H' &&
sig[5] == 'A' &&
sig[6] == 'X' &&
sig[7] == 'X')
HBC=1; // Exit to HBC
#endif
GuiTrigger trigA;
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);
@ -795,7 +805,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
GuiButton btn1(&btn1Img,&btn1OverImg, 0, 3, 0, 0, &trigA, &btnSoundOver, &btnClick,0);
btn1.SetEffect(EFFECT_SLIDE_TOP | EFFECT_SLIDE_IN, 50);
GuiText btn2Txt((HBC!=1?tr("Homebrew Channel"):btn1Label), 28, (GXColor) {0, 0, 0, 255});
GuiText btn2Txt(btn1Label, 28, (GXColor) {0, 0, 0, 255});
GuiImage btn2Img(&button);
if (Settings.wsprompt == yes) {
btn2Txt.SetWidescreen(CFG.widescreen);
@ -805,9 +815,8 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
btn2.SetLabel(&btn2Txt);
btn2.SetEffect(EFFECT_SLIDE_LEFT | EFFECT_SLIDE_IN, 50);
btn2.SetRumble(false);
if (HBC==1) {
btn2.SetPosition(-150, 0);
}
btn2.SetPosition(-150, 0);
GuiText btn3Txt(btn2Label, 28, (GXColor) {0, 0, 0, 255});
GuiImage btn3Img(&button);
@ -909,15 +918,7 @@ WindowExitPrompt(const char *title, const char *msg, const char *btn1Label,
} else if (btn2.GetState() == STATE_CLICKED) {
ret = WindowPrompt(tr("Are you sure?"), 0, tr("Yes"), tr("No"));
if (ret == 1) {
if (HBC!=1) {
CloseXMLDatabase();
ExitGUIThreads();
ShutdownAudio();
StopGX();
WII_Initialize();
WII_BootHBC();
}
choice = 2;
}
HaltGui();
@ -1016,6 +1017,7 @@ int GameWindowPrompt() {
char ID[5];
char IDFull[7];
gprintf("\nGameWindowPrompt()");
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
@ -1225,7 +1227,8 @@ int GameWindowPrompt() {
snprintf (ID,sizeof(ID),"%c%c%c", header->id[0], header->id[1], header->id[2]);
snprintf (IDFull,sizeof(IDFull),"%c%c%c%c%c%c", header->id[0], header->id[1], header->id[2],header->id[3], header->id[4], header->id[5]);
if (diskCover)
gprintf("\n\t%s",IDFull);
if (diskCover)
delete diskCover;
@ -1519,6 +1522,7 @@ int GameWindowPrompt() {
delete diskCover;
delete diskCover2;
gprintf("\n\treturn %i",choice);
return choice;
}
@ -1722,7 +1726,8 @@ FormatingPartition(const char *title, partitionEntry *entry) {
***************************************************************************/
bool SearchMissingImages(int choice2) {
GuiWindow promptWindow(472,320);
gprintf("\nSearchMissingImages(%i)",choice2);
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
@ -1819,7 +1824,8 @@ bool SearchMissingImages(int choice2) {
__Menu_GetEntries();
ResumeGui();
if (cntMissFiles > 0) { //&& !IsNetworkInit()) {
gprintf(" = %i",cntMissFiles);
if (cntMissFiles > 0) { //&& !IsNetworkInit()) {
NetworkInitPrompt();
}
@ -1834,7 +1840,8 @@ bool SearchMissingImages(int choice2) {
***************************************************************************/
bool NetworkInitPrompt() {
if (IsNetworkInit())
gprintf("\nNetworkinitPrompt()");
if (IsNetworkInit())
return true;
bool success = true;
@ -2418,6 +2425,7 @@ ProgressDownloadWindow(int choice2) {
int ProgressUpdateWindow() {
gprintf("\nProgressUpdateWindow(not full channel)");
int ret = 0, failed = 0, updatemode = -1;
GuiWindow promptWindow(472,320);
@ -2718,6 +2726,9 @@ int ProgressUpdateWindow() {
if (!failed && ret >= 0 && updatemode == 1) {
WindowPrompt(tr("Successfully Updated") , tr("Restarting..."), tr("OK"));
loadStub();
Set_Stub_Split(0x00010001,"UNEO");
Sys_BackToLoader();
} else if(updatemode > 0 && ret > 0) {
WindowPrompt(tr("Successfully Updated") , 0, tr("OK"));
@ -2743,6 +2754,7 @@ int ProgressUpdateWindow() {
int ProgressUpdateWindow() {
int ret = 0, failed = 0;
gprintf("\nProgressUpdateWindow(full channel)");
GuiWindow promptWindow(472,320);
promptWindow.SetAlignment(ALIGN_CENTRE, ALIGN_MIDDLE);
promptWindow.SetPosition(0, -10);
@ -3002,14 +3014,16 @@ int ProgressUpdateWindow() {
} else {
//sprintf(nipple, tr("The update wad has been saved as %s. Now let's try to install it."),dolpath);
//WindowPrompt(0,nipple, tr("OK"));
error = Wad_Install(wadFile);
gprintf("\n\tinstall wad");
error = Wad_Install(wadFile);
fclose(wadFile);
if (error==0) {
diarhea = remove(dolpath);
if (diarhea)
WindowPrompt(tr("Success"),tr("The wad file was installed. But It could not be deleted from the SD card."),tr("OK"));
} else {
sprintf(nipple, tr("The wad installation failed with error %ld"),error);
gprintf(" -> failed");
sprintf(nipple, tr("The wad installation failed with error %ld"),error);
WindowPrompt(tr("Error"),nipple,tr("OK"));
}
}
@ -3022,7 +3036,8 @@ int ProgressUpdateWindow() {
ExitGUIThreads();
ShutdownAudio();
StopGX();
WII_Initialize();
gprintf("\nRebooting");
WII_Initialize();
WII_LaunchTitle(TITLE_ID(0x00010001,0x554c4e52));
}

View File

@ -12,7 +12,7 @@
#include "alternatedol.h"
#include "fstfile.h"
#include "settings/cfg.h"
#include "../gecko.h"
#include "gecko.h"
/*KENOBI! - FISHEARS*/
extern const unsigned char kenobiwii[];
@ -313,6 +313,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
u32 appldr_len;
s32 ret;
gprintf("\nApploader_Run() started");
//u32 geckoattached = usb_isgeckoalive(EXI_CHANNEL_1);
//if (geckoattached)usb_flush(EXI_CHANNEL_1);
@ -345,6 +346,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
}
if (cheat || geckoinit) {
// gprintf("\n\tkenobiwii loaded");
/*HOOKS STUFF - FISHEARS*/
memset((void*)0x80001800,0,kenobiwii_size);
memcpy((void*)0x80001800,kenobiwii,kenobiwii_size);
@ -375,6 +377,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
/** Load alternate dol if set **/
if (alternatedol == 1) {
// gprintf("\n\talt dol from FAT");
void *dolbuffer;
int dollen;
@ -396,6 +399,7 @@ s32 Apploader_Run(entry_point *entry, u8 cheat, u8 videoSelected, u8 vipatch, u8
free(dolbuffer);
} else if (alternatedol == 2) {
// gprintf("\n\talt dol from WBFS");
FST_ENTRY *fst = (FST_ENTRY *)*(u32 *)0x80000038;

View File

@ -10,9 +10,10 @@
#include "disc.h"
#include "video.h"
#include "wdvd.h"
#include "alternatedol.h"
#include "alternatedol.h"
#include "memory.h"
#include "../gecko.h"
/* Constants */
#define PTABLE_OFFSET 0x40000
#define WII_MAGIC 0x5D1C9EA3
@ -149,6 +150,8 @@ void __Disc_SetVMode(u8 videoselected) {
if (vmode->viTVMode & VI_NON_INTERLACE)
VIDEO_WaitVSync();
}
gprintf("\nVideo mode - %s",((progressive)?"progressive":"interlaced"));
}
void __Disc_SetTime(void) {