*fix possible buffer overflow in GCT code array

*fix the gamelist from starting with 1 game on the list
*added fucntion for making screenshots and put it in a few loops. 
triggers are GC(Z), CC(left-Z), nunchuk(Z).  no comfirmation is given
except over usb gecko.  but files are saved in <boot device>/config/
USBLoader_GX_screenshot<date><time>.png
*took out some annoying prompts from the bannersound functions because
they were really annoying
This commit is contained in:
giantpune 2009-12-20 04:26:30 +00:00
parent 7cdb020b04
commit cb628348d6
15 changed files with 154 additions and 41 deletions

View File

@ -2,8 +2,8 @@
<app version="1"> <app version="1">
<name> USB Loader GX</name> <name> USB Loader GX</name>
<coder>USB Loader GX Team</coder> <coder>USB Loader GX Team</coder>
<version>1.0 r870</version> <version>1.0 r871</version>
<release_date>200912192045</release_date> <release_date>200912192124</release_date>
<short_description>Loads games from USB-devices</short_description> <short_description>Loads games from USB-devices</short_description>
<long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times. <long_description>USB Loader GX is a libwiigui based USB iso loader with a wii-like GUI. You can install games to your HDDs and boot them with shorter loading times.
The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller. The interactive GUI is completely controllable with WiiMote, Classic Controller or GC Controller.

View File

@ -132,13 +132,13 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) discid); wbfs_disc_t *disc = WBFS_OpenDisc((u8 *) discid);
if(!disc) if(!disc)
{ {
WindowPrompt(tr("Can't find disc"), 0, tr("OK")); // WindowPrompt(tr("Can't find disc"), 0, tr("OK"));
return NULL; return NULL;
} }
wiidisc_t *wdisc = wd_open_disc((int (*)(void *, u32, u32, void *))wbfs_disc_read, disc); wiidisc_t *wdisc = wd_open_disc((int (*)(void *, u32, u32, void *))wbfs_disc_read, disc);
if(!wdisc) if(!wdisc)
{ {
WindowPrompt(tr("Could not open Disc"), 0, tr("OK")); //WindowPrompt(tr("Could not open Disc"), 0, tr("OK"));
return NULL; return NULL;
} }
u8 * opening_bnr = wd_extract_file(wdisc, ALL_PARTITIONS, (char *) "opening.bnr"); u8 * opening_bnr = wd_extract_file(wdisc, ALL_PARTITIONS, (char *) "opening.bnr");
@ -156,7 +156,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
const IMETHeader *imetHdr = (IMETHeader *)opening_bnr; const IMETHeader *imetHdr = (IMETHeader *)opening_bnr;
if ( imetHdr->fcc != 0x494D4554 /*"IMET"*/ ) if ( imetHdr->fcc != 0x494D4554 /*"IMET"*/ )
{ {
WindowPrompt(tr("IMET Header wrong."), 0, tr("OK")); // WindowPrompt(tr("IMET Header wrong."), 0, tr("OK"));
free(opening_bnr); free(opening_bnr);
return NULL; return NULL;
} }
@ -177,7 +177,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
const u8 *sound_bin = ((const u8 *)bnrArcHdr) + fst[i].fileOffset; const u8 *sound_bin = ((const u8 *)bnrArcHdr) + fst[i].fileOffset;
if ( ((IMD5Header *)sound_bin)->fcc != 0x494D4435 /*"IMD5"*/ ) if ( ((IMD5Header *)sound_bin)->fcc != 0x494D4435 /*"IMD5"*/ )
{ {
WindowPrompt(tr("IMD5 Header not right."), 0, tr("OK")); // WindowPrompt(tr("IMD5 Header not right."), 0, tr("OK"));
free(opening_bnr); free(opening_bnr);
return NULL; return NULL;
} }
@ -190,7 +190,7 @@ const u8 *LoadBannerSound(const u8 *discid, u32 *size)
u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize); u8 * uncompressed_data = uncompressLZ77(soundChunk, soundChunkSize, uncSize);
if (!uncompressed_data) if (!uncompressed_data)
{ {
WindowPrompt(tr("Can't decompress LZ77"), 0, tr("OK")); // WindowPrompt(tr("Can't decompress LZ77"), 0, tr("OK"));
free(opening_bnr); free(opening_bnr);
return NULL; return NULL;
} }

View File

@ -32,7 +32,7 @@ GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, co
pagesize = THEME.pagesize; pagesize = THEME.pagesize;
scrollbaron = (gameCnt > pagesize) ? 1 : 0; scrollbaron = (gameCnt > pagesize) ? 1 : 0;
selectable = true; selectable = true;
listOffset = (offset == 0) ? this->FindMenuItem(-1, 1) : offset; listOffset = MAX(0,MIN(offset,(gameCnt-pagesize)));
selectedItem = selected - offset; selectedItem = selected - offset;
focus = 1; // allow focus focus = 1; // allow focus
char imgPath[100]; char imgPath[100];

View File

@ -16,7 +16,6 @@
#include <unistd.h> #include <unistd.h>
#include <locale.h> #include <locale.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
//#include <debug.h> //#include <debug.h>
extern "C" { extern "C" {
extern void __exception_setreload(int t); extern void __exception_setreload(int t);
@ -185,7 +184,7 @@ main(int argc, char *argv[]) {
// DEBUG_Init(GDBSTUB_DEVICE_USB, 1); // DEBUG_Init(GDBSTUB_DEVICE_USB, 1);
//_break(); //_break();
// __exception_setreload(5);//auto reset code dump nobody gives us codedump info anyways. __exception_setreload(5);//auto reset code dump nobody gives us codedump info anyways.
gprintf("\n\n------------------"); gprintf("\n\n------------------");
gprintf("\nUSB Loader GX rev%s",GetRev()); gprintf("\nUSB Loader GX rev%s",GetRev());

View File

@ -291,6 +291,7 @@ int MainMenu(int menu) {
switch (currentMenu) { switch (currentMenu) {
case MENU_CHECK: case MENU_CHECK:
currentMenu = MenuCheck(); currentMenu = MenuCheck();
break; break;
case MENU_FORMAT: case MENU_FORMAT:

View File

@ -17,7 +17,7 @@
#include "libwiigui/gui_searchbar.h" #include "libwiigui/gui_searchbar.h"
#define MAX_CHARACTERS 38 #define MAX_CHARACTERS 38
extern u8 * gameScreenTex;
extern struct discHdr *dvdheader; extern struct discHdr *dvdheader;
extern u8 mountMethod; extern u8 mountMethod;
extern int load_from_fs; extern int load_from_fs;
@ -49,10 +49,11 @@ static u32 startat = 0;
int MenuDiscList() { int MenuDiscList() {
gprintf("\nMenuDiscList()"); gprintf("\nMenuDiscList()");
//TakeScreenshot("SD:/screenshot1.png");
__Menu_GetEntries(); __Menu_GetEntries();
int offset = MIN(startat,gameCnt-1); int offset = MIN(startat,gameCnt-1);
startat = offset; startat = offset;
gprintf("\n\tstartat:%d offset:%d",startat,offset); //gprintf("\n\tstartat:%d offset:%d",startat,offset);
int datag = 0; int datag = 0;
int datagB =0; int datagB =0;
int dataed = -1; int dataed = -1;
@ -182,11 +183,17 @@ int MenuDiscList() {
GuiTrigger trigA; GuiTrigger trigA;
trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A); trigA.SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
GuiTrigger trigHome; GuiTrigger trigHome;
trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, 0); trigHome.SetButtonOnlyTrigger(-1, WPAD_BUTTON_HOME | WPAD_CLASSIC_BUTTON_HOME, PAD_BUTTON_START);
GuiTrigger trig2; GuiTrigger trig2;
trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0); trig2.SetButtonOnlyTrigger(-1, WPAD_BUTTON_2 | WPAD_CLASSIC_BUTTON_X, 0);
GuiTrigger trig1; GuiTrigger trig1;
trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0); trig1.SetButtonOnlyTrigger(-1, WPAD_BUTTON_1 | WPAD_CLASSIC_BUTTON_Y, 0);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
char spaceinfo[30]; char spaceinfo[30];
if (load_from_fs != PART_FS_WBFS) { if (load_from_fs != PART_FS_WBFS) {
@ -576,6 +583,8 @@ int MenuDiscList() {
w.Append(&settingsBtn); w.Append(&settingsBtn);
w.Append(&DownloadBtn); w.Append(&DownloadBtn);
w.Append(&idBtn); w.Append(&idBtn);
w.Append(&screenShotBtn);
// Begin Toolbar // Begin Toolbar
w.Append(&favoriteBtn); w.Append(&favoriteBtn);
@ -690,6 +699,7 @@ 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);}} 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 // respond to button presses
if (shutdown == 1) { if (shutdown == 1) {
@ -748,6 +758,14 @@ int MenuDiscList() {
menu = MENU_DISCLIST; menu = MENU_DISCLIST;
break; break;
}
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}else if (homeBtn.GetState() == STATE_CLICKED) { }else if (homeBtn.GetState() == STATE_CLICKED) {
gprintf("\n\thomeBtn clicked"); gprintf("\n\thomeBtn clicked");
bgMusic->Pause(); bgMusic->Pause();
@ -1279,6 +1297,7 @@ int MenuDiscList() {
idBtn.ResetState(); idBtn.ResetState();
} }
startat=gameBrowser->GetOffset(), offset=startat;
} }
if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt)) if (((gameSelected >= 0) && (gameSelected < (s32)gameCnt))
@ -1540,8 +1559,8 @@ int MenuDiscList() {
/*if (menu == MENU_EXIT) { /*if (menu == MENU_EXIT) {
SDCard_deInit(); SDCard_deInit();
}*/ }*/
startat=selectImg1, offset=selectImg1;//save the variables in case we are refreshing the list //if (Settings.gameDisplay==list) {startat=gameBrowser->GetOffset(), offset=startat;}//save the variables in case we are refreshing the list
gprintf("\n\tstartat:%d offset:%d",startat,offset); //gprintf("\n\tstartat:%d offset:%d",startat,offset);
HaltGui(); HaltGui();
mainWindow->RemoveAll(); mainWindow->RemoveAll();
mainWindow->Append(bgImg); mainWindow->Append(bgImg);

View File

@ -75,7 +75,7 @@ gprintf("\ndo_sd_code(%s)",filename);
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
filesize = ftell(fp); filesize = ftell(fp);
if(filesize <= 16){ if(filesize <= 16 || filesize>MAX_GCT_SIZE){
fclose(fp); fclose(fp);
sleep(2); sleep(2);
USBDevice_deInit(); USBDevice_deInit();

View File

@ -696,9 +696,17 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
} }
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&titleTxt); promptWindow.Append(&titleTxt);
promptWindow.Append(&msgTxt); promptWindow.Append(&msgTxt);
promptWindow.Append(&screenShotBtn);
if (btn1Label) if (btn1Label)
promptWindow.Append(&btn1); promptWindow.Append(&btn1);
@ -738,6 +746,11 @@ int WindowPrompt(const char *title, const char *msg, const char *btn1Label,
choice = 3; choice = 3;
} else if (btn4.GetState() == STATE_CLICKED) { } else if (btn4.GetState() == STATE_CLICKED) {
choice = 0; choice = 0;
} else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
} }
if (count>0)count--; if (count>0)count--;
if (count==0) choice = 1; if (count==0) choice = 1;
@ -1125,6 +1138,12 @@ int GameWindowPrompt() {
trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0); trigPlus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_PLUS | WPAD_CLASSIC_BUTTON_PLUS, 0);
GuiTrigger trigMinus; GuiTrigger trigMinus;
trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0); trigMinus.SetButtonOnlyTrigger(-1, WPAD_BUTTON_MINUS | WPAD_CLASSIC_BUTTON_MINUS, 0);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
if (CFG.widescreen) if (CFG.widescreen)
snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path); snprintf(imgPath, sizeof(imgPath), "%swdialogue_box_startgame.png", CFG.theme_path);
@ -1255,6 +1274,7 @@ int GameWindowPrompt() {
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
promptWindow.Append(&nameBtn); promptWindow.Append(&nameBtn);
promptWindow.Append(&playcntTxt); promptWindow.Append(&playcntTxt);
promptWindow.Append(&screenShotBtn);
promptWindow.Append(&btn2); promptWindow.Append(&btn2);
if (!mountMethod)//stuff we don't show if it is a DVD mounted if (!mountMethod)//stuff we don't show if it is a DVD mounted
{ {
@ -1524,6 +1544,12 @@ int GameWindowPrompt() {
} }
btnFavorite5.ResetState(); btnFavorite5.ResetState();
} }
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
// this next part is long because nobody could agree on what the left/right buttons should do // this next part is long because nobody could agree on what the left/right buttons should do
else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//next game else if ((btnRight.GetState() == STATE_CLICKED) && (Settings.xflip == no)) {//next game
promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50); promptWindow.SetEffect(EFFECT_SLIDE_RIGHT | EFFECT_SLIDE_OUT, 50);
@ -3540,6 +3566,14 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM); btn2.SetAlignment(ALIGN_RIGHT, ALIGN_BOTTOM);
btn2.SetPosition(-40, 2); btn2.SetPosition(-40, 2);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
promptWindow.Append(&screenShotBtn);
promptWindow.Append(&dialogBoxImg); promptWindow.Append(&dialogBoxImg);
if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg); if (strcmp(long_description,""))promptWindow.Append(&whiteBoxImg);
if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg); if (strcmp(long_description,""))promptWindow.Append(&scrollbarImg);
@ -3576,7 +3610,14 @@ HBCWindowPrompt(const char *name, const char *coder, const char *version,
choice = 1; choice = 1;
} else if (btn2.GetState() == STATE_CLICKED) { } else if (btn2.GetState() == STATE_CLICKED) {
choice = 0; choice = 0;
} else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) { }
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
else if ((arrowUpBtn.GetState()==STATE_CLICKED||arrowUpBtn.GetState()==STATE_HELD) ) {
if (long_descriptionTxt.GetFirstLine()>1) if (long_descriptionTxt.GetFirstLine()>1)
long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1); long_descriptionTxt.SetFirstLine(long_descriptionTxt.GetFirstLine()-1);
usleep(60000); usleep(60000);

View File

@ -26,6 +26,7 @@
#include "../wad/title.h" #include "../wad/title.h"
#include "../usbloader/getentries.h" #include "../usbloader/getentries.h"
#include "../usbloader/utils.h" #include "../usbloader/utils.h"
#include "../gecko.h"
#define typei 0x00010001 #define typei 0x00010001
@ -294,8 +295,16 @@ int TitleBrowser(u32 type) {
wifiBtn.SetAlpha(80); wifiBtn.SetAlpha(80);
wifiBtn.SetTrigger(&trigA); wifiBtn.SetTrigger(&trigA);
GuiTrigger trigZ;
trigZ.SetButtonOnlyTrigger(-1, WPAD_NUNCHUK_BUTTON_Z | WPAD_CLASSIC_BUTTON_ZL, PAD_TRIGGER_Z);
GuiButton screenShotBtn(0,0);
screenShotBtn.SetPosition(0,0);
screenShotBtn.SetTrigger(&trigZ);
HaltGui(); HaltGui();
GuiWindow w(screenwidth, screenheight); GuiWindow w(screenwidth, screenheight);
w.Append(&screenShotBtn);
w.Append(&settingsbackgroundbtn); w.Append(&settingsbackgroundbtn);
w.Append(&titleTxt); w.Append(&titleTxt);
w.Append(&cancelBtn); w.Append(&cancelBtn);
@ -538,6 +547,12 @@ int TitleBrowser(u32 type) {
exit = true; exit = true;
ret = -10; ret = -10;
} }
else if (screenShotBtn.GetState() == STATE_CLICKED) {
gprintf("\n\tscreenShotBtn clicked");
screenShotBtn.ResetState();
ScreenShot();
gprintf("...It's easy, mmmmmmKay");
}
} }
CloseConnection(); CloseConnection();

View File

@ -263,3 +263,20 @@ s32 IOS_ReloadIOSsafe(int ios)
return r; return r;
} }
#include <time.h>
void ScreenShot()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
char buffer2 [80];
time ( &rawtime );
timeinfo = localtime ( &rawtime );
//USBLoader_GX_ScreenShot-Month_Day_Hour_Minute_Second_Year.png
strftime (buffer,80,"USBLoader_GX_ScreenShot-%b%d%H%M%S%y.png",timeinfo);
sprintf(buffer2, "%s/config/%s", bootDevice, buffer);
TakeScreenshot(buffer2);
}

View File

@ -15,6 +15,7 @@ int Sys_ChangeIos(int ios);
int Sys_IosReload(int IOS); int Sys_IosReload(int IOS);
bool Sys_IsHermes(); bool Sys_IsHermes();
s32 IOS_ReloadIOSsafe(int ios); s32 IOS_ReloadIOSsafe(int ios);
void ScreenShot();
void ShowMemInfo(); void ShowMemInfo();
extern s32 ios222rev; extern s32 ios222rev;

View File

@ -346,9 +346,9 @@ void gamepatches(void * dst, int len, u8 videoSelected, u8 patchcountrystring, u
NewSuperMarioBrosPatch(dst, len); NewSuperMarioBrosPatch(dst, len);
gprintf("\nLoading WIP Patch..."); //gprintf("\nLoading WIP Patch...");
u32 ret = do_wip_code((u8 *)0x80000000); u32 ret = do_wip_code((u8 *)0x80000000);
gprintf("done\n", ret); //gprintf("done\n", ret);
//if(Settings.anti002fix == on) //if(Settings.anti002fix == on)

View File

@ -15,6 +15,7 @@
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "input.h" #include "input.h"
#include "gecko.h"
#include "libwiigui/gui.h" #include "libwiigui/gui.h"
#include "settings/cfg.h" #include "settings/cfg.h"
@ -29,6 +30,9 @@ int screenheight;
int screenwidth; int screenwidth;
u32 frameCount = 0; u32 frameCount = 0;
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
/**************************************************************************** /****************************************************************************
* UpdatePadsCB * UpdatePadsCB
* *
@ -457,3 +461,18 @@ void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexO
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR); GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE); GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
} }
/****************************************************************************
* TakeScreenshot
*
* Copies the current screen into a file "path"
***************************************************************************/
s32 TakeScreenshot(const char *path)
{
gprintf("\nTakeScreenshot(%s)", path);
IMGCTX ctx = PNGU_SelectImageFromDevice (path);
s32 ret = PNGU_EncodeFromYCbYCr(ctx,vmode->fbWidth, vmode->efbHeight,xfb[whichfb],0);
PNGU_ReleaseImageContext (ctx);
gprintf(":%d", ret);
return 1;
}

View File

@ -20,6 +20,7 @@ void Menu_DrawImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, u8 data[]
void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexObj *texObj, void Menu_DrawTPLImg(f32 xpos, f32 ypos, f32 zpos, f32 width, f32 height, GXTexObj *texObj,
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4); f32 degrees, f32 scaleX, f32 scaleY, u8 alpha, int XX1, int YY1,int XX2, int YY2,int XX3, int YY3,int XX4, int YY4);
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled); void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
s32 TakeScreenshot(const char *path);
extern int screenheight; extern int screenheight;
extern int screenwidth; extern int screenwidth;