Add device selector

- command line for both wii and gamecube
- support sdgecko in wii mode
- you can now insert/remove devices without reboot via device selector
This commit is contained in:
suloku 2021-11-03 10:00:28 +01:00
parent 6db7f5444a
commit 9a3c7ba11d
16 changed files with 818 additions and 192 deletions

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 844 KiB

After

Width:  |  Height:  |  Size: 844 KiB

View File

@ -17,6 +17,7 @@
#include "bitmap.h"
#include "freetype.h"
#include "gci.h"
#include "sdsupp.h"
#ifdef DARK_MODE
#include "bg_dark_bmp.h"
@ -25,8 +26,8 @@
#endif
#ifdef HW_DOL
extern u8 SD2SP2;
extern int have_sd;
extern u8 CUR_DEVICE;
extern bool have_sd;
#ifdef DARK_MODE
#include "bg_dark_gcload_bmp.h"
#include "bg_dark_sd2sp2_bmp.h"
@ -35,6 +36,7 @@ extern int have_sd;
#include "bg_sd2sp2_bmp.h"
#endif
#endif
extern u8 selector_flag;
extern card_direntry gci;
//*extern GXRModeObj *vmode; /*** Graphics Mode Object ***/
@ -118,7 +120,6 @@ u32 ShowBMP(u8 * bmpfile) {
u8 *bgr;
u32 fboffset;
u32 rows, cols;
static u8 firstcall = 1;
bitmap = (WINBITMAP *) bmpfile;
@ -165,9 +166,9 @@ u32 ShowBMP(u8 * bmpfile) {
/*** Move to NEXT framebuffer ***/
whichfb ^= 1;
//Move background in the "device selection" screen to center the left pane with the GC memory card logo
if (firstcall)
if (selector_flag)
{
DrawBoxFilled(0,0,vmode->fbWidth-1,vmode->xfbHeight-1, COL_BG2);
for (rows = 0; rows < height; rows++) {
@ -179,7 +180,7 @@ u32 ShowBMP(u8 * bmpfile) {
else
{
xfb[whichfb][fboffset-(320*20) + (66)+cols] =CvtRGB (bgr[2], bgr[1], bgr[0],
bgr[5], bgr[4], bgr[3]);
bgr[5], bgr[4], bgr[3]);
}
bgr += 6;
@ -202,10 +203,6 @@ u32 ShowBMP(u8 * bmpfile) {
} /*** Outer row loop ***/
}
if (firstcall)
{
firstcall = 0;
}
/*** Setup the video to display this picture ***/
/*VIDEO_SetNextFramebuffer (xfb[whichfb]);
@ -310,13 +307,13 @@ void ClearScreen() {
#ifdef HW_DOL
#ifdef DARK_MODE
if (SD2SP2 == 1 && have_sd) ShowBMP((u8*) bg_dark_sd2sp2_bmp);
else if (SD2SP2 == 2 && have_sd) ShowBMP((u8*) bg_dark_gcload_bmp);
if (CUR_DEVICE == DEV_GCSDC && have_sd) ShowBMP((u8*) bg_dark_sd2sp2_bmp);
else if (CUR_DEVICE == DEV_GCODE && have_sd) ShowBMP((u8*) bg_dark_gcload_bmp);
else
ShowBMP((u8*) bg_dark_bmp);
#else
if (SD2SP2 == 1 && have_sd) ShowBMP((u8*) bg_sd2sp2_bmp);
else if (SD2SP2 == 2 && have_sd) ShowBMP((u8*) bg_gcload_bmp);
if (CUR_DEVICE == DEV_GCSDC && have_sd) ShowBMP((u8*) bg_sd2sp2_bmp);
else if (CUR_DEVICE == DEV_GCODE && have_sd) ShowBMP((u8*) bg_gcload_bmp);
else
ShowBMP((u8*) bg_bmp);
#endif

View File

@ -43,10 +43,7 @@ extern int cancel;
extern int doall;
extern int mode;
extern s32 MEM_CARD;
#ifdef HW_DOL
extern u8 SD2SP2;
extern int have_sd;
#endif
extern u8 CUR_DEVICE;
extern u16 bannerdata[CARD_BANNER_W*CARD_BANNER_H] ATTRIBUTE_ALIGN (32);
extern u8 bannerdataCI[CARD_BANNER_W*CARD_BANNER_H] ATTRIBUTE_ALIGN (32);
@ -87,6 +84,7 @@ extern u8 CommentBuffer[64] ATTRIBUTE_ALIGN (32);
extern u8 currFolder[260];
extern int folderCount;
extern int displaypath;
extern char fatpath[4];
#define PAGESIZE 16
@ -353,7 +351,7 @@ int SelectMode ()
DrawText (-1, ypos + 60, "Press X for SD CARD RESTORE mode");
DrawText (-1, ypos + 80, "Press Z for SD/PSO Reload");
ShowScreen ();*/
ClearScreen ();
//ClearScreen ();
//setfontcolour(84,174,211);
//setfontcolour(28,28,28);
@ -361,11 +359,34 @@ int SelectMode ()
setfontsize(10);
setfontcolour(COL_FONT_STATUS);
DrawText(595,87,appversion);
#ifdef HW_DOL
if (SD2SP2 && have_sd) DrawText(595,97, "SD2SP2");
else if (!SD2SP2 && have_sd) DrawText(595,97, "SDGecko");
else DrawText(595,97, "!Device");
#endif
switch(CUR_DEVICE)
{
case DEV_ND:
DrawText(595,97, "!Device");
break;
case DEV_GCSDA:
DrawText(595,97, "GeckoA");
break;
case DEV_GCSDB:
DrawText(595,97, "GeckoB");
break;
case DEV_GCSDC:
DrawText(595,97, "SD2SP2");
break;
case DEV_GCODE:
DrawText(595,97, "GCLoader");
break;
case DEV_WIISD:
DrawText(595,97, "Wii SD");
break;
case DEV_WIIUSB:
DrawText(595,97, "Wii USB");
break;
default:
break;
}
setfontsize (FONT_SIZE);
writeStatusBar("Choose your mode","");
ShowScreen();
@ -374,7 +395,7 @@ int SelectMode ()
for (;;)
{
/*
if (PAD_ButtonsHeld (0) & PAD_BUTTON_A)
{
while ((PAD_ButtonsDown (0) & PAD_BUTTON_A))
@ -383,6 +404,7 @@ int SelectMode ()
}
return 100;
}
*/
if (PAD_ButtonsHeld (0) & PAD_TRIGGER_Z)//Delete mode
{
while ((PAD_ButtonsDown (0) & PAD_TRIGGER_Z))
@ -425,6 +447,14 @@ int SelectMode ()
return 600;
}
*/
if (PAD_ButtonsHeld (0) & PAD_TRIGGER_R)//Device select mode
{
while ((PAD_ButtonsDown (0) & PAD_TRIGGER_R))
{
VIDEO_WaitVSync ();
}
return 1000;
}
while (PAD_ButtonsHeld (0) & PAD_TRIGGER_L)
{
if (PAD_ButtonsHeld (0) & PAD_BUTTON_Y){//Raw backup mode
@ -452,6 +482,7 @@ int SelectMode ()
}
}
#ifdef HW_RVL
/*
if (WPAD_ButtonsHeld (0) & WPAD_BUTTON_A)
{
while ((WPAD_ButtonsDown (0) & WPAD_BUTTON_A))
@ -460,6 +491,7 @@ int SelectMode ()
}
return 100;
}
*/
if (WPAD_ButtonsHeld (0) & WPAD_BUTTON_2)
{
while ((WPAD_ButtonsDown (0) & WPAD_BUTTON_2))//Delete mode
@ -502,6 +534,14 @@ int SelectMode ()
return 600;
}
*/
if (WPAD_ButtonsHeld (0) & WPAD_BUTTON_1)//Device select mode
{
while ((WPAD_ButtonsDown (0) & WPAD_BUTTON_1))
{
VIDEO_WaitVSync ();
}
return 1000;
}
while (WPAD_ButtonsHeld (0) & WPAD_BUTTON_B)
{
if (WPAD_ButtonsHeld (0) & WPAD_BUTTON_MINUS){//Raw backup mode
@ -749,7 +789,7 @@ void showCardInfo(int sel){
//clear right pane, but just the card info
DrawBoxFilled(375, 165, 605, 390, COL_BG1);
//clear the right side just in case we went offscreen with previous comment
DrawVLine (606, 145, 390, COL_BG2);
DrawVLine (606, 145, 390, COL_BG1);
DrawVLine (608, 145, 390, COL_BG2);
DrawBoxFilled(610, 145, 640, 390, COL_BG2);
@ -760,7 +800,7 @@ void showCardInfo(int sel){
char temp[5];
char folder[1024];
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[sel]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[sel]);
if(isdir_sd(folder) == 1)
{
@ -853,14 +893,15 @@ void showSaveInfo(int sel)
int y = 165, x = 378, j;
char gamecode[5], company[3], txt[1024];
int isFolder = 0;
//clear right pane, but just the save info
DrawBoxFilled(375, 145, 605, 390, COL_BG1);
//clear the right side just in case we went offscreen with previous comment
DrawVLine (606, 145, 390, COL_BG2);
DrawVLine (606, 145, 390, COL_BG1);
DrawVLine (608, 145, 390, COL_BG2);
DrawBoxFilled(610, 145, 640, 390, COL_BG2);
// read file, display some more info
// TODO: only read the necessary header + comment, display banner and icon files
if (mode == RESTORE_MODE)
@ -868,7 +909,7 @@ void showSaveInfo(int sel)
//Dragonbane: Show basic info if folder
char folder[1024];
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[sel]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[sel]);
if(isdir_sd(folder) == 1)
{
@ -1090,7 +1131,7 @@ static void ShowFiles (int offset, int selection, int upordown, int saveinfo) {
DrawBoxFilled(30, 55, 30+330, 50+16, COL_BG2);
setfontsize (10);
setfontcolour(COL_FONT);
sprintf (folder, "fat:/%s/", currFolder);
sprintf (folder, "%s:/%s/",fatpath, currFolder);
DrawText(40, 66, folder);
}
setfontsize(14);
@ -1104,7 +1145,7 @@ static void ShowFiles (int offset, int selection, int upordown, int saveinfo) {
//changed this to limit characters shown in filename since display gets weird
//if we let the entire filename appear
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[i]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[i]);
if(isdir_sd(folder) == 1)
@ -1158,7 +1199,7 @@ static void ShowFiles (int offset, int selection, int upordown, int saveinfo) {
setfontcolour(COL_FONT);
//user just pressed up, down, left or right, upordown holds the correction needded
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[selection+upordown]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[selection+upordown]);
if(isdir_sd(folder) == 1)
{
@ -1183,7 +1224,7 @@ static void ShowFiles (int offset, int selection, int upordown, int saveinfo) {
setfontcolour(COL_FONT);
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[selection]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[selection]);
if(isdir_sd(folder) == 1)
{
@ -1377,7 +1418,7 @@ int ShowSelector (int saveinfo)
#endif
char folder[1024];
sprintf (folder, "fat:/%s/%s", currFolder, (char*)filelist[selection]);
sprintf (folder, "%s:/%s/%s",fatpath, currFolder, (char*)filelist[selection]);
if(isdir_sd(folder) == 0)
{

View File

@ -36,8 +36,8 @@ void initialise_power() ;
#define COL_BG2 getcolour(255,255,255)
#define COL_SELECTOR 84,174,211 //Should be the same as BG1
#define COL_FONT 28,28,28
#define COL_FONT_FOLDER 200,200,20
#define COL_FONT_HIGHLIGHT 255,255,255
#define COL_FONT_FOLDER 255,255,255
#define COL_FONT_HIGHLIGHT 28,28,28
#define COL_FONT_STATUS COL_FONT
#endif
@ -61,7 +61,7 @@ int ShowSelector (int saveinfo);
int SelectMode ();
void writeStatusBar(char *line1, char *line2);
void clearLeftPane();
void clearRightPane();
void clearRightPane();
/****************************************************************************
* Draw functions - lines, boxes
****************************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -55,6 +55,7 @@ Header cardheader;
extern u8 currFolder[260];
extern int folderCount;
extern char fatpath[4];
extern syssram* __SYS_LockSram();
extern syssramex* __SYS_LockSramEx();
@ -292,14 +293,14 @@ s8 BackupRawImage(s32 slot, s32 *bytes_writen )
char name[64];
int filenumber = 1;
sprintf (filename, "fat:/%s", MCSAVES);
sprintf (filename, "%s:/%s", fatpath, MCSAVES);
mkdir(filename, S_IREAD | S_IWRITE);
time2name(name);
sprintf (filename, "fat:/%s/%04db_%s.raw", MCSAVES, BlockCount-5, name);
sprintf (filename, "%s:/%s/%04db_%s.raw", fatpath, MCSAVES, BlockCount-5, name);
//not really needed because the filename has seconds in it and the same filename will "never" happen
while (file_exists(filename)){
sprintf (filename, "fat:/%s/%04db_%s_%02d.raw", MCSAVES, BlockCount-5, name, filenumber);
sprintf (filename, "%s:/%s/%04db_%s_%02d.raw", fatpath, MCSAVES, BlockCount-5, name, filenumber);
filenumber++;
}
dumpFd = fopen(filename,"wb");
@ -429,7 +430,7 @@ s8 RestoreRawImage( s32 slot, char *sdfilename, s32 *bytes_writen )
/*** Make fullpath filename ***/
sprintf (filename, "fat:/%s/%s", currFolder, sdfilename);
sprintf (filename, "%s:/%s/%s", fatpath, currFolder, sdfilename);
/*** Open the SD Card file ***/
dumpFd = fopen ( filename , "rb" );
@ -513,8 +514,10 @@ s8 RestoreRawImage( s32 slot, char *sdfilename, s32 *bytes_writen )
//fclose(dumpFd);
/*
//Test code to see if raw image is correctly read
char testfile[64];
sprintf(testfile, "%s:/fatread.bin", fatpath);
FILE *test = 0;
test = fopen ( "fat:/fatread.bin" , "wb" );
test = fopen ( testfile , "wb" );
fwrite (CardBuffer , 1 , SectorSize , test);
fclose (test);
//Testcode end
@ -570,8 +573,9 @@ s8 RestoreRawImage( s32 slot, char *sdfilename, s32 *bytes_writen )
else
{
//Uncomment to dump contents that where read
FILE* dump = fopen("fat:/sectcheck_dump.bin","wb");
char dumpfile[64];
sprintf(dumpfile, "%s:/setcheck_dump.bin", fatpath);
FILE* dump = fopen(dumpfile,"wb");
fwrite(CheckBuffer,1,write_len,dump);
fclose(dump);
@ -645,7 +649,9 @@ s8 RestoreRawImage( s32 slot, char *sdfilename, s32 *bytes_writen )
//printf("different data. writing to SD (0x%08X), error %d\n",*check,CardError);
//Uncomment to dump contents that where read
FILE* dump = fopen("fat:/check_dump.bin","wb");
char checkdump[64];
sprintf(checkdump, "%s:/check_dump.bin", fatpath);
FILE* dump = fopen(checkdump,"wb");
fwrite(CheckBuffer,1,write_len,dump);
fclose(dump);

View File

@ -47,6 +47,7 @@ extern int OFFSET;
extern u8 currFolder[260];
extern int folderCount;
extern char fatpath[4];
bool file_exists(const char * filename)
{
@ -83,17 +84,17 @@ int SDSaveMCImage ()
memcpy (gamecode, &thisgci.gamecode, 4);
memcpy (tfile, &thisgci.filename, CARD_FILENAMELEN);
sprintf (filename, "fat:/%s", MCSAVES);
sprintf (filename, "%s:/%s", fatpath, MCSAVES);
mkdir(filename, S_IREAD | S_IWRITE);
sprintf (filename, "fat:/%s/%s-%s-%s_%02d.gci", MCSAVES, company, gamecode, tfile, filenumber);
sprintf (filename, "%s:/%s/%s-%s-%s_%02d.gci", fatpath, MCSAVES, company, gamecode, tfile, filenumber);
//Lets try if there's already a savegame (if it exists its name is legal, so theoretically the illegal name check will pass
//Illegal savegame should report as nonexisting...
//We will number the files
while (file_exists(filename)){
sprintf (filename, "fat:/%s/%s-%s-%s_%02d.gci", MCSAVES, company, gamecode, tfile, filenumber);
sprintf (filename, "%s:/%s/%s-%s-%s_%02d.gci", fatpath, MCSAVES, company, gamecode, tfile, filenumber);
filenumber++;
}
@ -107,11 +108,11 @@ int SDSaveMCImage ()
if (handle <= 0)
{
// couldn't open file, probably either card full or filename illegal; let's assume illegal filename and retry
sprintf (filename, "fat:/%s/%s-%s-%s_%02d.gci", MCSAVES, company, gamecode, "illegal_name", filenumber);
sprintf (filename, "%s:/%s/%s-%s-%s_%02d.gci", fatpath, MCSAVES, company, gamecode, "illegal_name", filenumber);
//let's see again if there aren't any saves already...
filenumber = 1;
while (file_exists(filename)){
sprintf (filename, "fat:/%s/%s-%s-%s_%02d.gci", MCSAVES, company, gamecode, "illegal_name", filenumber);
sprintf (filename, "%s:/%s/%s-%s-%s_%02d.gci", fatpath, MCSAVES, company, gamecode, "illegal_name", filenumber);
filenumber++;
}
//filename[128] = 0;
@ -176,7 +177,7 @@ int SDLoadMCImage(char *sdfilename)
/*** Make fullpath filename ***/
//sprintf (filename, "dev0:\\%s\\%s", MCSAVES, sdfilename);
sprintf (filename, "fat:/%s/%s", currFolder, sdfilename);
sprintf (filename, "%s:/%s/%s", fatpath, currFolder, sdfilename);
//SDCARD_Init ();
@ -265,7 +266,7 @@ int SDLoadMCImageHeader(char *sdfilename)
memset (CommentBuffer, 0, 64);
/*** Make fullpath filename ***/
sprintf (filename, "fat:/%s/%s", currFolder, sdfilename);
sprintf (filename, "%s:/%s/%s", fatpath, currFolder, sdfilename);
/*** Open the SD Card file ***/
@ -511,7 +512,7 @@ int SDLoadCardImageHeader(char *sdfilename)
memset (&cardheader, 0, sizeof(Header));
/*** Make fullpath filename ***/
sprintf (filename, "fat:/%s/%s", currFolder, sdfilename);
sprintf (filename, "%s:/%s/%s", fatpath, currFolder, sdfilename);
/*** Open the SD Card file ***/
handle = fopen ( filename , "rb" );
@ -614,7 +615,7 @@ int SDGetFileList(int mode)
int dirCount = 0;
char filename[1024];
sprintf (filename, "fat:/%s/", currFolder);
sprintf (filename, "%s:/%s/", fatpath, currFolder);
//Add Folders

View File

@ -1,5 +1,19 @@
#define MCSAVES "MCBACKUP"
#define DEV_NUM 0
#define DEV_GCSDA 1
#define DEV_GCSDB 2
#define DEV_GCSDC 3
#define DEV_GCODE 4
#define DEV_WIISD 5
#define DEV_WIIUSB 6
#define DEV_TOTAL 6
#define DEV_ND 0
#define DEV_AVAIL 1
#define DEV_MOUNTED 2
int SDSaveMCImage();
int SDLoadMCImage(char *sdfilename);
int SDLoadMCImageHeader(char *sdfilename);