2008-08-06 03:09:59 +02:00
|
|
|
/****************************************************************************
|
2008-08-07 05:25:02 +02:00
|
|
|
* Snes9x 1.50
|
2008-08-06 03:09:59 +02:00
|
|
|
*
|
|
|
|
* Nintendo Gamecube Filesel - borrowed from GPP
|
|
|
|
*
|
|
|
|
* softdev July 2006
|
|
|
|
* svpe June 2007
|
|
|
|
* crunchy2 May-July 2007
|
|
|
|
****************************************************************************/
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2008-08-06 03:39:43 +02:00
|
|
|
#include <wiiuse/wpad.h>
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-06 04:31:44 +02:00
|
|
|
#include <sys/dir.h>
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "snes9x.h"
|
|
|
|
#include "memmap.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "cpuexec.h"
|
|
|
|
#include "ppu.h"
|
|
|
|
#include "apu.h"
|
|
|
|
#include "display.h"
|
|
|
|
#include "gfx.h"
|
|
|
|
#include "soundux.h"
|
|
|
|
#include "spc700.h"
|
|
|
|
#include "spc7110.h"
|
|
|
|
#include "controls.h"
|
|
|
|
|
|
|
|
#include "snes9xGx.h"
|
|
|
|
#include "dvd.h"
|
2008-08-07 07:19:17 +02:00
|
|
|
#include "menudraw.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "video.h"
|
|
|
|
#include "aram.h"
|
2008-08-06 03:55:59 +02:00
|
|
|
#include "unzip.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "filesel.h"
|
|
|
|
#include "smbload.h"
|
2008-08-07 07:33:24 +02:00
|
|
|
#include "fileop.h"
|
2008-08-06 03:09:59 +02:00
|
|
|
#include "mcsave.h"
|
|
|
|
|
|
|
|
#define PAGESIZE 17
|
2008-08-06 03:39:43 +02:00
|
|
|
int maxfiles;
|
2008-08-06 03:09:59 +02:00
|
|
|
int havedir = 0;
|
|
|
|
int hasloaded = 0;
|
|
|
|
int LoadDVDFile (unsigned char *buffer);
|
2008-08-07 05:25:02 +02:00
|
|
|
int haveFATdir = 0;
|
2008-08-06 03:09:59 +02:00
|
|
|
extern unsigned long ARAM_ROMSIZE;
|
|
|
|
extern int screenheight;
|
2008-08-06 03:39:43 +02:00
|
|
|
|
|
|
|
extern FILEENTRIES filelist[MAXFILES];
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-08 09:57:01 +02:00
|
|
|
* autoLoadMethod()
|
|
|
|
* Auto-determines and sets the load method
|
|
|
|
* Returns method set
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
|
|
|
int autoLoadMethod()
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-08 09:57:01 +02:00
|
|
|
if(changeFATInterface(METHOD_SD))
|
|
|
|
return METHOD_SD;
|
|
|
|
else if(changeFATInterface(METHOD_USB))
|
|
|
|
return METHOD_USB;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WaitPrompt((char*) "Unable to auto-determine load method!");
|
|
|
|
return 0; // no method found
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-08 09:57:01 +02:00
|
|
|
* autoSaveMethod()
|
|
|
|
* Auto-determines and sets the save method
|
|
|
|
* Returns method set
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
|
|
|
int autoSaveMethod()
|
|
|
|
{
|
2008-08-08 09:57:01 +02:00
|
|
|
if(changeFATInterface(METHOD_SD))
|
|
|
|
return METHOD_SD;
|
|
|
|
else if(changeFATInterface(METHOD_USB))
|
|
|
|
return METHOD_USB;
|
2008-08-08 10:13:13 +02:00
|
|
|
else if(TestCard(CARD_SLOTA, SILENT))
|
2008-08-08 09:57:01 +02:00
|
|
|
return METHOD_MC_SLOTA;
|
2008-08-08 10:13:13 +02:00
|
|
|
else if(TestCard(CARD_SLOTB, SILENT))
|
2008-08-08 09:57:01 +02:00
|
|
|
return METHOD_MC_SLOTB;
|
|
|
|
else
|
2008-08-07 05:25:02 +02:00
|
|
|
{
|
2008-08-08 09:57:01 +02:00
|
|
|
WaitPrompt((char*) "Unable to auto-determine save method!");
|
|
|
|
return 0; // no method found
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* StripExt
|
|
|
|
*
|
|
|
|
* Strips an extension from a filename
|
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
void StripExt(char* returnstring, char * inputstring)
|
|
|
|
{
|
|
|
|
char* loc_dot;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
strcpy (returnstring, inputstring);
|
|
|
|
loc_dot = strrchr(returnstring,'.');
|
|
|
|
if (loc_dot != NULL)
|
|
|
|
*loc_dot = '\0'; // strip file extension
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Showfile screen
|
|
|
|
*
|
|
|
|
* Display the file selection to the user
|
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
static void
|
|
|
|
ShowFiles (int offset, int selection)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
char text[MAXPATHLEN];
|
|
|
|
int ypos;
|
|
|
|
int w;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
clearscreen ();
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
setfontsize (28);
|
|
|
|
DrawText (-1, 60, (char*)"Choose Game");
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
setfontsize(18);
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
if (screenheight == 480)
|
|
|
|
ypos += 24;
|
|
|
|
else
|
|
|
|
ypos += 10;
|
2008-08-06 03:09:59 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
j = 0;
|
|
|
|
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
|
|
|
|
{
|
|
|
|
if (filelist[i].flags) // if a dir
|
|
|
|
{
|
|
|
|
strcpy (text, "[");
|
|
|
|
strcat (text, filelist[i].displayname);
|
|
|
|
strcat (text, "]");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// hide file extension on listing (.7z, .fig, .smc)
|
|
|
|
StripExt(text, filelist[i].displayname);
|
|
|
|
}
|
|
|
|
if (j == (selection - offset))
|
|
|
|
{
|
|
|
|
/*** Highlighted text entry ***/
|
|
|
|
for ( w = 0; w < 20; w++ )
|
|
|
|
DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 );
|
|
|
|
|
|
|
|
setfontcolour (0x00, 0x00, 0xe0);
|
|
|
|
DrawText (50, (j * 20) + ypos, text);
|
|
|
|
setfontcolour (0x00, 0x00, 0x00);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/*** Normal entry ***/
|
|
|
|
DrawText (50, (j * 20) + ypos, text);
|
|
|
|
}
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
showscreen ();
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-06 03:09:59 +02:00
|
|
|
* SNESROMSOffset
|
|
|
|
*
|
|
|
|
* Function to check for and return offset to a directory called SNESROMS, if
|
|
|
|
* any
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
int SNESROMSOffset()
|
|
|
|
{
|
|
|
|
int i;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
for ( i = 0; i < maxfiles; i++ )
|
|
|
|
if (strcmp(filelist[i].filename, "SNESROMS") == 0)
|
|
|
|
return i;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-06 04:31:44 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-06 03:09:59 +02:00
|
|
|
* FileSelector
|
|
|
|
*
|
2008-08-07 05:25:02 +02:00
|
|
|
* Let user select a file from the listing
|
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
int offset = 0;
|
|
|
|
int selection = 0;
|
|
|
|
|
|
|
|
#define PADCAL 40
|
|
|
|
int
|
2008-08-07 05:25:02 +02:00
|
|
|
FileSelector (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-06 03:55:59 +02:00
|
|
|
u32 p, wp, ph, wh;
|
|
|
|
signed char a, c;
|
2008-08-06 03:09:59 +02:00
|
|
|
int haverom = 0;
|
|
|
|
int redraw = 1;
|
|
|
|
int selectit = 0;
|
2008-08-07 05:25:02 +02:00
|
|
|
float mag, mag2 = 0;
|
|
|
|
u16 ang, ang2 = 0;
|
2008-08-06 03:55:59 +02:00
|
|
|
int scroll_delay = 0;
|
|
|
|
bool move_selection = 0;
|
|
|
|
#define SCROLL_INITIAL_DELAY 15
|
2008-08-07 05:25:02 +02:00
|
|
|
#define SCROLL_LOOP_DELAY 2
|
|
|
|
|
|
|
|
while (haverom == 0)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
if (redraw)
|
|
|
|
ShowFiles (offset, selection);
|
|
|
|
redraw = 0;
|
2008-08-06 03:45:56 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
p = PAD_ButtonsDown (0);
|
2008-08-06 03:55:59 +02:00
|
|
|
ph = PAD_ButtonsHeld (0);
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-06 03:39:43 +02:00
|
|
|
wp = WPAD_ButtonsDown (0);
|
2008-08-06 03:55:59 +02:00
|
|
|
wh = WPAD_ButtonsHeld (0);
|
2008-08-06 04:31:44 +02:00
|
|
|
wpad_get_analogues(0, &mag, &ang, &mag2, &ang2); // get joystick info from wii expansions
|
2008-08-06 03:45:56 +02:00
|
|
|
#else
|
|
|
|
wp = 0;
|
2008-08-06 03:55:59 +02:00
|
|
|
wh = 0;
|
2008-08-06 03:45:56 +02:00
|
|
|
#endif
|
|
|
|
a = PAD_StickY (0);
|
2008-08-06 03:55:59 +02:00
|
|
|
c = PAD_SubStickX (0);
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
/*** Check for exit combo ***/
|
|
|
|
if ( (c < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) return 0;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
/*** Check buttons, perform actions ***/
|
2008-08-06 03:45:56 +02:00
|
|
|
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
if ( selectit )
|
|
|
|
selectit = 0;
|
|
|
|
if (filelist[selection].flags) /*** This is directory ***/
|
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
if (method == METHOD_SD || method == METHOD_USB)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
/* memorize last entries list, actual root directory and selection for next access */
|
|
|
|
haveFATdir = 1;
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
/* update current directory and set new entry list if directory has changed */
|
2008-08-07 05:25:02 +02:00
|
|
|
int status = updateFATdirname(method);
|
2008-08-06 03:39:43 +02:00
|
|
|
if (status == 1) // ok, open directory
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
maxfiles = parseFATdirectory(method);
|
2008-08-06 03:09:59 +02:00
|
|
|
if (!maxfiles)
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
WaitPrompt ((char*) "Error reading directory !");
|
2008-08-07 05:25:02 +02:00
|
|
|
haverom = 1; // quit FAT menu
|
|
|
|
haveFATdir = 0; // reset everything at next access
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-06 03:39:43 +02:00
|
|
|
else if (status == -1) // directory name too long
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
haverom = 1; // quit FAT menu
|
|
|
|
haveFATdir = 0; // reset everything at next access
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( (strcmp (filelist[selection].filename, "..") == 0)
|
|
|
|
&& ((unsigned int)rootdir == filelist[selection].offset) )
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
rootdir = filelist[selection].offset;
|
|
|
|
rootdirlength = filelist[selection].length;
|
|
|
|
offset = selection = 0;
|
|
|
|
maxfiles = parsedirectory ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-08-06 03:39:43 +02:00
|
|
|
else // this is a file
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
rootdir = filelist[selection].offset;
|
2008-08-06 03:09:59 +02:00
|
|
|
rootdirlength = filelist[selection].length;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
|
|
|
// store the filename (used for sram/freeze naming)
|
2008-08-07 05:25:02 +02:00
|
|
|
StripExt(Memory.ROMFilename, filelist[selection].filename); // store stripped filename in Memory.ROMFilename
|
|
|
|
|
|
|
|
switch (method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
case METHOD_SD:
|
|
|
|
case METHOD_USB:
|
|
|
|
/*** Load from FAT ***/
|
|
|
|
/* memorize last entries list, actual root directory and selection for next access */
|
|
|
|
haveFATdir = 1;
|
|
|
|
ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename,
|
|
|
|
filelist[selection].length);
|
|
|
|
break;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
case METHOD_DVD:
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Now load the DVD file to it's offset ***/
|
|
|
|
ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
|
|
|
|
break;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
case METHOD_SMB:
|
2008-08-06 03:09:59 +02:00
|
|
|
/*** Load from SMB ***/
|
2008-08-07 05:25:02 +02:00
|
|
|
ARAM_ROMSIZE =
|
|
|
|
LoadSMBFile (filelist[selection].filename,
|
2008-08-06 03:09:59 +02:00
|
|
|
filelist[selection].length);
|
|
|
|
break;
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if (ARAM_ROMSIZE > 0)
|
|
|
|
{
|
|
|
|
hasloaded = 1;
|
|
|
|
Memory.LoadROM ("BLANK.SMC");
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
Memory.LoadSRAM ("BLANK");
|
|
|
|
haverom = 1;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
WaitPrompt((char*) "Error loading ROM!");
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
redraw = 1;
|
2008-08-06 03:39:43 +02:00
|
|
|
} // End of A
|
2008-08-06 03:45:56 +02:00
|
|
|
if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
2008-08-06 03:45:56 +02:00
|
|
|
#ifdef HW_RVL
|
2008-08-07 05:25:02 +02:00
|
|
|
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
2008-08-06 03:45:56 +02:00
|
|
|
#endif
|
|
|
|
)
|
2008-08-06 03:09:59 +02:00
|
|
|
VIDEO_WaitVSync();
|
2008-08-06 03:39:43 +02:00
|
|
|
//if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0))
|
2008-08-07 05:25:02 +02:00
|
|
|
if ( strcmp(filelist[0].filename,"..") == 0 )
|
2008-08-06 03:39:43 +02:00
|
|
|
{
|
|
|
|
selection = 0;
|
|
|
|
selectit = 1;
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
else if ( strcmp(filelist[1].filename,"..") == 0 )
|
2008-08-06 03:39:43 +02:00
|
|
|
{
|
2008-08-06 03:09:59 +02:00
|
|
|
selection = selectit = 1;
|
2008-08-06 03:39:43 +02:00
|
|
|
} else {
|
2008-08-06 03:09:59 +02:00
|
|
|
return 0;
|
2008-08-06 03:39:43 +02:00
|
|
|
}
|
|
|
|
} // End of B
|
2008-08-06 03:55:59 +02:00
|
|
|
if ( ((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -PADCAL) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-06 03:55:59 +02:00
|
|
|
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
|
|
|
|
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
|
|
move_selection = 1; //continue (move selection)
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
2008-08-06 03:55:59 +02:00
|
|
|
else if (scroll_delay == 0) { /*** Button is held ***/
|
|
|
|
scroll_delay = SCROLL_LOOP_DELAY;
|
|
|
|
move_selection = 1; //continue (move selection)
|
|
|
|
} else {
|
|
|
|
scroll_delay--; // wait
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
if (move_selection)
|
|
|
|
{
|
|
|
|
selection++;
|
|
|
|
if (selection == maxfiles)
|
|
|
|
selection = offset = 0;
|
|
|
|
if ((selection - offset) >= PAGESIZE)
|
|
|
|
offset += PAGESIZE;
|
|
|
|
redraw = 1;
|
|
|
|
move_selection = 0;
|
|
|
|
}
|
2008-08-06 03:39:43 +02:00
|
|
|
} // End of down
|
2008-08-06 03:55:59 +02:00
|
|
|
if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > PADCAL) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
|
2008-08-07 05:25:02 +02:00
|
|
|
{
|
2008-08-06 03:55:59 +02:00
|
|
|
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
|
|
|
|
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
|
|
move_selection = 1; //continue (move selection)
|
2008-08-07 05:25:02 +02:00
|
|
|
}
|
2008-08-06 03:55:59 +02:00
|
|
|
else if (scroll_delay == 0) { /*** Button is held ***/
|
|
|
|
scroll_delay = SCROLL_LOOP_DELAY;
|
|
|
|
move_selection = 1; //continue (move selection)
|
|
|
|
} else {
|
|
|
|
scroll_delay--; // wait
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:55:59 +02:00
|
|
|
if (move_selection)
|
|
|
|
{
|
|
|
|
selection--;
|
|
|
|
if (selection < 0) {
|
|
|
|
selection = maxfiles - 1;
|
|
|
|
offset = selection - PAGESIZE + 1;
|
|
|
|
}
|
|
|
|
if (selection < offset)
|
|
|
|
offset -= PAGESIZE;
|
|
|
|
if (offset < 0)
|
|
|
|
offset = 0;
|
|
|
|
redraw = 1;
|
|
|
|
move_selection = 0;
|
|
|
|
}
|
2008-08-06 03:39:43 +02:00
|
|
|
} // End of Up
|
2008-08-06 03:45:56 +02:00
|
|
|
if ( (p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_LEFT)) )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
/*** Go back a page ***/
|
|
|
|
selection -= PAGESIZE;
|
|
|
|
if (selection < 0)
|
|
|
|
{
|
|
|
|
selection = maxfiles - 1;
|
|
|
|
offset = selection - PAGESIZE + 1;
|
|
|
|
}
|
|
|
|
if (selection < offset)
|
|
|
|
offset -= PAGESIZE;
|
|
|
|
if (offset < 0)
|
|
|
|
offset = 0;
|
|
|
|
redraw = 1;
|
|
|
|
}
|
2008-08-06 03:45:56 +02:00
|
|
|
if ( (p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT | WPAD_CLASSIC_BUTTON_RIGHT)) )
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
/*** Go forward a page ***/
|
|
|
|
selection += PAGESIZE;
|
|
|
|
if (selection > maxfiles - 1)
|
|
|
|
selection = offset = 0;
|
|
|
|
if ((selection - offset) >= PAGESIZE)
|
|
|
|
offset += PAGESIZE;
|
|
|
|
redraw = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-06 03:09:59 +02:00
|
|
|
* OpenDVD
|
|
|
|
*
|
|
|
|
* Function to load a DVD directory and display to user.
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
2008-08-07 05:25:02 +02:00
|
|
|
OpenDVD (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
int romsdiroffset = 0;
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if (!getpvd())
|
|
|
|
{
|
2008-08-06 03:39:43 +02:00
|
|
|
ShowAction((char*) "Mounting DVD ... Wait");
|
2008-08-06 03:09:59 +02:00
|
|
|
DVD_Mount(); /* mount the DVD unit again */
|
|
|
|
havedir = 0; /* this may be a new DVD: content need to be parsed again */
|
|
|
|
if (!getpvd())
|
|
|
|
return 0; /* no correct ISO9660 DVD */
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if (havedir == 0)
|
|
|
|
{
|
|
|
|
offset = selection = 0; /* reset file selector */
|
2008-08-07 05:25:02 +02:00
|
|
|
haveFATdir = 0; /* prevent conflicts with FAT file selector */
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
if ((maxfiles = parsedirectory ()))
|
|
|
|
{
|
|
|
|
if ( romsdiroffset = SNESROMSOffset() )
|
|
|
|
{
|
|
|
|
rootdir = filelist[romsdiroffset].offset;
|
|
|
|
rootdirlength = filelist[romsdiroffset].length;
|
|
|
|
offset = selection = 0;
|
|
|
|
maxfiles = parsedirectory ();
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
|
|
|
int ret = FileSelector (method);
|
2008-08-06 03:09:59 +02:00
|
|
|
havedir = 1;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
else
|
2008-08-07 05:25:02 +02:00
|
|
|
return FileSelector (method);
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-06 03:09:59 +02:00
|
|
|
* OpenSMB
|
|
|
|
*
|
|
|
|
* Function to load from an SMB share
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
2008-08-07 05:25:02 +02:00
|
|
|
OpenSMB (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
if ((maxfiles = parseSMBDirectory ()))
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
|
|
|
char txt[80];
|
|
|
|
sprintf(txt,"maxfiles = %d", maxfiles);
|
2008-08-06 04:31:44 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
return FileSelector (method);
|
2008-08-06 04:31:44 +02:00
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
return 0;
|
2008-08-06 04:31:44 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* OpenFAT
|
|
|
|
*
|
|
|
|
* Function to load from FAT
|
|
|
|
****************************************************************************/
|
|
|
|
int
|
|
|
|
OpenFAT (int method)
|
|
|
|
{
|
|
|
|
char msg[80];
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
//if (haveFATdir == 0)
|
|
|
|
//{
|
|
|
|
/* don't mess with DVD entries */
|
|
|
|
havedir = 0; // gamecube only
|
|
|
|
|
|
|
|
/* change current dir to snes roms directory */
|
2008-08-08 09:57:01 +02:00
|
|
|
changeFATInterface(GCSettings.LoadMethod);
|
|
|
|
sprintf ( currFATdir, "%s/%s", ROOTFATDIR, GCSettings.LoadFolder );
|
2008-08-07 05:25:02 +02:00
|
|
|
|
|
|
|
/* Parse initial root directory and get entries list */
|
|
|
|
if ((maxfiles = parseFATdirectory (method)))
|
2008-08-06 04:31:44 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
/* Select an entry */
|
|
|
|
return FileSelector (method);
|
2008-08-06 04:31:44 +02:00
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
else
|
2008-08-06 04:31:44 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
/* no entries found */
|
|
|
|
sprintf (msg, "No Files Found!");
|
|
|
|
WaitPrompt (msg);
|
2008-08-06 04:31:44 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-07 05:25:02 +02:00
|
|
|
//}
|
|
|
|
/* Retrieve previous entries list and made a new selection */
|
|
|
|
//else
|
|
|
|
// return FileSelector (method);
|
|
|
|
|
|
|
|
return 0;
|
2008-08-06 04:31:44 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* OpenROM
|
|
|
|
* Opens device specified by method, displays a list of ROMS
|
|
|
|
****************************************************************************/
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
2008-08-07 05:25:02 +02:00
|
|
|
OpenROM (int method)
|
2008-08-06 03:09:59 +02:00
|
|
|
{
|
2008-08-07 05:25:02 +02:00
|
|
|
int loadROM = 0;
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
if(method == METHOD_AUTO)
|
|
|
|
method = autoLoadMethod();
|
2008-08-06 04:31:44 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
switch (method)
|
|
|
|
{
|
|
|
|
case METHOD_SD:
|
|
|
|
case METHOD_USB:
|
|
|
|
loadROM = OpenFAT (method);
|
|
|
|
break;
|
|
|
|
case METHOD_DVD:
|
|
|
|
// Load from DVD
|
|
|
|
loadROM = OpenDVD (method);
|
|
|
|
break;
|
|
|
|
case METHOD_SMB:
|
|
|
|
// Load from Network (SMB)
|
|
|
|
loadROM = OpenSMB (method);
|
|
|
|
break;
|
|
|
|
}
|
2008-08-07 07:19:17 +02:00
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
return loadROM;
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
|
2008-08-07 05:25:02 +02:00
|
|
|
/****************************************************************************
|
2008-08-06 03:09:59 +02:00
|
|
|
* LoadDVDFile
|
|
|
|
* This function will load a file from DVD, in BIN, SMD or ZIP format.
|
2008-08-07 05:25:02 +02:00
|
|
|
* The values for offset and length are inherited from rootdir and
|
2008-08-06 03:09:59 +02:00
|
|
|
* rootdirlength.
|
|
|
|
*
|
|
|
|
* The buffer parameter should re-use the initial ROM buffer.
|
2008-08-07 05:25:02 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2008-08-06 03:09:59 +02:00
|
|
|
int
|
|
|
|
LoadDVDFile (unsigned char *buffer)
|
|
|
|
{
|
|
|
|
int offset;
|
|
|
|
int blocks;
|
|
|
|
int i;
|
|
|
|
u64 discoffset;
|
|
|
|
char readbuffer[2048];
|
|
|
|
|
|
|
|
/*** SDCard Addition ***/
|
|
|
|
if (rootdirlength == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/*** How many 2k blocks to read ***/
|
|
|
|
blocks = rootdirlength / 2048;
|
|
|
|
offset = 0;
|
|
|
|
discoffset = rootdir;
|
2008-08-06 03:39:43 +02:00
|
|
|
ShowAction ((char*) "Loading ... Wait");
|
2008-08-06 03:09:59 +02:00
|
|
|
dvd_read (readbuffer, 2048, discoffset);
|
|
|
|
|
|
|
|
if (!IsZipFile (readbuffer))
|
|
|
|
|
|
|
|
{
|
|
|
|
for (i = 0; i < blocks; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
dvd_read (readbuffer, 2048, discoffset);
|
|
|
|
memcpy (buffer + offset, readbuffer, 2048);
|
|
|
|
offset += 2048;
|
|
|
|
discoffset += 2048;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** And final cleanup ***/
|
|
|
|
if (rootdirlength % 2048)
|
|
|
|
|
|
|
|
{
|
|
|
|
i = rootdirlength % 2048;
|
|
|
|
dvd_read (readbuffer, 2048, discoffset);
|
|
|
|
memcpy (buffer + offset, readbuffer, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
2008-08-06 03:55:59 +02:00
|
|
|
return UnZipBuffer (buffer, discoffset, 1, NULL); // unzip from dvd
|
2008-08-06 03:09:59 +02:00
|
|
|
}
|
|
|
|
return rootdirlength;
|
|
|
|
}
|