rewrite of smb code, partially working on Wii

misc bug fixes
function cleanup
This commit is contained in:
dborth 2008-08-10 03:14:39 +00:00
parent 7cb0371b38
commit 6ff361a2cd
20 changed files with 896 additions and 980 deletions

View File

@ -13,6 +13,7 @@
#include "memmap.h" #include "memmap.h"
#include "fileop.h" #include "fileop.h"
#include "cheats.h" #include "cheats.h"
#include "filesel.h"
extern SCheatData Cheat; extern SCheatData Cheat;
@ -30,9 +31,14 @@ SetupCheats()
char cheatFile[150] = { '\0' }; char cheatFile[150] = { '\0' };
if(GCSettings.SaveMethod == METHOD_SD || GCSettings.SaveMethod == METHOD_USB) int method = GCSettings.SaveMethod;
if(method == METHOD_AUTO)
method = autoSaveMethod();
if(method == METHOD_SD || method == METHOD_USB)
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(method, NOTSILENT);
sprintf (cheatFile, "%s/snes9x/cheats/%s.cht", ROOTFATDIR, Memory.ROMFilename); sprintf (cheatFile, "%s/snes9x/cheats/%s.cht", ROOTFATDIR, Memory.ROMFilename);
} }

View File

@ -1,9 +1,10 @@
/**************************************************************************** /****************************************************************************
* Snes9x 1.50 * Snes9x 1.50
* *
* Nintendo Gamecube Port * Nintendo Wii/Gamecube Port
* softdev July 2006 * softdev July 2006
* crunchy2 May 2007 * crunchy2 May 2007
* Tantric August 2008
* *
* fileop.cpp * fileop.cpp
* *
@ -13,9 +14,11 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ogcsys.h> #include <ogcsys.h>
#include <zlib.h>
#include "memmap.h"
#include "fileop.h" #include "fileop.h"
#include "unzip.h" #include "unzip.h"
#include "memmap.h"
#include "video.h" #include "video.h"
#include "menudraw.h" #include "menudraw.h"
#include "dvd.h" #include "dvd.h"
@ -24,15 +27,13 @@
#include "preferences.h" #include "preferences.h"
#include "snes9xGx.h" #include "snes9xGx.h"
#include <zlib.h>
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
extern char output[16384]; extern char output[16384];
FILE * filehandle; FILE * filehandle;
char currFATdir[MAXPATHLEN];
extern int offset; extern int offset;
extern int selection; extern int selection;
extern char currentdir[MAXPATHLEN];
extern FILEENTRIES filelist[MAXFILES]; extern FILEENTRIES filelist[MAXFILES];
/**************************************************************************** /****************************************************************************
@ -56,7 +57,7 @@ bool fat_is_mounted(PARTITION_INTERFACE partition) {
* Checks if the device (method) specified is available, and * Checks if the device (method) specified is available, and
* sets libfat to use the device * sets libfat to use the device
****************************************************************************/ ****************************************************************************/
bool changeFATInterface(int method) bool changeFATInterface(int method, bool silent)
{ {
bool devFound = false; bool devFound = false;
@ -82,6 +83,11 @@ bool changeFATInterface(int method)
devFound = true; devFound = true;
fatSetDefaultInterface(PI_SDGECKO_B); fatSetDefaultInterface(PI_SDGECKO_B);
} }
if(!devFound)
{
if(!silent)
WaitPrompt ((char *)"SD card not found!");
}
} }
else if(method == METHOD_USB) else if(method == METHOD_USB)
{ {
@ -91,6 +97,11 @@ bool changeFATInterface(int method)
devFound = true; devFound = true;
fatSetDefaultInterface(PI_USBSTORAGE); fatSetDefaultInterface(PI_USBSTORAGE);
} }
else
{
if(!silent)
WaitPrompt ((char *)"USB flash drive not found!");
}
#endif #endif
} }
@ -137,94 +148,11 @@ bool fat_remount(PARTITION_INTERFACE partition) {
} }
} }
/***************************************************************************
* FileSortCallback
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
static int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.')
{
if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; }
}
/* If one is a file and one is a directory the directory is first. */
if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1;
if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1;
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
}
/***************************************************************************
* Update FATCARD curent directory name
***************************************************************************/
int updateFATdirname(int method)
{
int size=0;
char *test;
char temp[1024];
/* current directory doesn't change */
if (strcmp(filelist[selection].filename,".") == 0)
{
return 0;
}
/* go up to parent directory */
else if (strcmp(filelist[selection].filename,"..") == 0)
{
/* determine last subdirectory namelength */
sprintf(temp,"%s",currFATdir);
test = strtok(temp,"/");
while (test != NULL)
{
size = strlen(test);
test = strtok(NULL,"/");
}
/* remove last subdirectory name */
size = strlen(currFATdir) - size - 1;
currFATdir[size] = 0;
return 1;
}
/* Open a directory */
else
{
/* test new directory namelength */
if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
{
/* handles root name */
sprintf(temp, "/%s/..", GCSettings.LoadFolder);
if (strcmp(currFATdir, temp) == 0)
{
sprintf(currFATdir,"%s",ROOTFATDIR);
}
/* update current directory name */
sprintf(currFATdir, "%s/%s",currFATdir, filelist[selection].filename);
return 1;
}
else
{
WaitPrompt((char*)"Dirname is too long !");
return -1;
}
}
}
/*************************************************************************** /***************************************************************************
* Browse FAT subdirectories * Browse FAT subdirectories
***************************************************************************/ ***************************************************************************/
int parseFATdirectory(int method) int
parseFATdirectory(int method)
{ {
int nbfiles = 0; int nbfiles = 0;
DIR_ITER *fatdir; DIR_ITER *fatdir;
@ -232,45 +160,47 @@ int parseFATdirectory(int method)
struct stat filestat; struct stat filestat;
char msg[128]; char msg[128];
/* initialize selection */ // initialize selection
selection = offset = 0; selection = offset = 0;
/* open the directory */ // open the directory
fatdir = diropen(currFATdir); fatdir = diropen(currentdir);
if (fatdir == NULL) if (fatdir == NULL)
{ {
sprintf(msg, "Couldn't find %s", currFATdir); sprintf(msg, "Couldn't open %s", currentdir);
WaitPrompt(msg); WaitPrompt(msg);
// if we can't open the previous dir, open root dir // if we can't open the dir, open root dir
sprintf(currFATdir,"%s",ROOTFATDIR); sprintf(currentdir,"%s",ROOTFATDIR);
fatdir = diropen(currFATdir); fatdir = diropen(currentdir);
if (fatdir == NULL) if (fatdir == NULL)
{ {
sprintf(msg, "Error opening %s", currFATdir); sprintf(msg, "Error opening %s", currentdir);
WaitPrompt(msg); WaitPrompt(msg);
return 0; return 0;
} }
} }
/* Move to DVD structure - this is required for the file selector */ // index files/folders
while(dirnext(fatdir,filename,&filestat) == 0) { while(dirnext(fatdir,filename,&filestat) == 0)
if(strcmp(filename,".") != 0) { {
if(strcmp(filename,".") != 0)
{
memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES)); memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES));
strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN); strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN);
strncpy(filelist[nbfiles].displayname, filename, MAXDISPLAY+1); // crop name for display strncpy(filelist[nbfiles].displayname, filename, MAXDISPLAY+1); // crop name for display
filelist[nbfiles].length = filestat.st_size; filelist[nbfiles].length = filestat.st_size;
filelist[nbfiles].flags = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; filelist[nbfiles].flags = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
nbfiles++; nbfiles++;
} }
} }
/*** close directory ***/ // close directory
dirclose(fatdir); dirclose(fatdir);
/* Sort the file list */ // Sort the file list
qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback);
return nbfiles; return nbfiles;
@ -279,7 +209,6 @@ int parseFATdirectory(int method)
/**************************************************************************** /****************************************************************************
* LoadFATFile * LoadFATFile
****************************************************************************/ ****************************************************************************/
extern int haveFATdir;
int int
LoadFATFile (char *filename, int length) LoadFATFile (char *filename, int length)
{ {
@ -292,12 +221,11 @@ LoadFATFile (char *filename, int length)
rbuffer = (unsigned char *) Memory.ROM; rbuffer = (unsigned char *) Memory.ROM;
/* Check filename length */ /* Check filename length */
if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
sprintf(filepath, "%s/%s",currFATdir,filelist[selection].filename); sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename);
else else
{ {
WaitPrompt((char*) "Maximum Filename Length reached !"); WaitPrompt((char*) "Maximum Filename Length reached !");
haveFATdir = 0; // reset everything before next access
return -1; return -1;
} }
@ -313,7 +241,6 @@ LoadFATFile (char *filename, int length)
fclose (handle); fclose (handle);
return size; return size;
} }
else else
{ {
@ -323,8 +250,7 @@ LoadFATFile (char *filename, int length)
length = ftell(handle); // get filesize length = ftell(handle); // get filesize
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
sprintf (filepath, "Loading %d bytes", length); ShowAction ((char *)"Loading...");
ShowAction (filepath);
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
fread (rbuffer + 2048, 1, length - 2048, handle); fread (rbuffer + 2048, 1, length - 2048, handle);
fclose (handle); fclose (handle);

View File

@ -25,9 +25,7 @@
bool fat_remount(PARTITION_INTERFACE partition); bool fat_remount(PARTITION_INTERFACE partition);
bool fat_is_mounted(PARTITION_INTERFACE partition); bool fat_is_mounted(PARTITION_INTERFACE partition);
bool changeFATInterface(int method); bool changeFATInterface(int method, bool silent);
static int FileSortCallback(const void *f1, const void *f2);
int updateFATdirname(int method);
int parseFATdirectory(int method); int parseFATdirectory(int method);
int LoadFATFile (char *filename, int length); int LoadFATFile (char *filename, int length);
int SaveBufferToFAT (char *filepath, int datasize, bool silent); int SaveBufferToFAT (char *filepath, int datasize, bool silent);

View File

@ -1,31 +1,25 @@
/**************************************************************************** /****************************************************************************
* Snes9x 1.50 * Snes9x 1.50
* *
* Nintendo Gamecube Filesel - borrowed from GPP * Nintendo Wii/Gamecube Port
*
* softdev July 2006 * softdev July 2006
* svpe June 2007 * svpe June 2007
* crunchy2 May-July 2007 * crunchy2 May-July 2007
* Tantric August 2008
*
* filesel.cpp
*
* Generic file routines - reading, writing, browsing
****************************************************************************/ ****************************************************************************/
#include <gccore.h> #include <gccore.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <sys/dir.h> #include <sys/dir.h>
#include "snes9x.h" #include "snes9x.h"
#include "memmap.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 "snes9xGx.h"
#include "dvd.h" #include "dvd.h"
@ -34,20 +28,21 @@
#include "aram.h" #include "aram.h"
#include "unzip.h" #include "unzip.h"
#include "filesel.h" #include "filesel.h"
#include "smbload.h" #include "smbop.h"
#include "fileop.h" #include "fileop.h"
#include "mcsave.h" #include "mcsave.h"
#define PAGESIZE 17 int offset;
int selection;
char currentdir[MAXPATHLEN];
int maxfiles; int maxfiles;
int havedir = 0;
int hasloaded = 0;
int LoadDVDFile (unsigned char *buffer);
int haveFATdir = 0;
extern unsigned long ARAM_ROMSIZE;
extern int screenheight; extern int screenheight;
extern FILEENTRIES filelist[MAXFILES]; #define PAGESIZE 17
int LoadDVDFile (unsigned char *buffer);
extern unsigned long ARAM_ROMSIZE;
int havedir = 0;
int hasloaded = 0;
/**************************************************************************** /****************************************************************************
* autoLoadMethod() * autoLoadMethod()
@ -56,10 +51,12 @@ extern FILEENTRIES filelist[MAXFILES];
****************************************************************************/ ****************************************************************************/
int autoLoadMethod() int autoLoadMethod()
{ {
if(changeFATInterface(METHOD_SD)) if(changeFATInterface(METHOD_SD, SILENT))
return METHOD_SD; return METHOD_SD;
else if(changeFATInterface(METHOD_USB)) else if(changeFATInterface(METHOD_USB, SILENT))
return METHOD_USB; return METHOD_USB;
//else if(ConnectShare ())
// return METHOD_SMB;
else else
{ {
WaitPrompt((char*) "Unable to auto-determine load method!"); WaitPrompt((char*) "Unable to auto-determine load method!");
@ -74,14 +71,16 @@ int autoLoadMethod()
****************************************************************************/ ****************************************************************************/
int autoSaveMethod() int autoSaveMethod()
{ {
if(changeFATInterface(METHOD_SD)) if(changeFATInterface(METHOD_SD, SILENT))
return METHOD_SD; return METHOD_SD;
else if(changeFATInterface(METHOD_USB)) else if(changeFATInterface(METHOD_USB, SILENT))
return METHOD_USB; return METHOD_USB;
else if(TestCard(CARD_SLOTA, SILENT)) else if(TestCard(CARD_SLOTA, SILENT))
return METHOD_MC_SLOTA; return METHOD_MC_SLOTA;
else if(TestCard(CARD_SLOTB, SILENT)) else if(TestCard(CARD_SLOTB, SILENT))
return METHOD_MC_SLOTB; return METHOD_MC_SLOTB;
//else if(ConnectShare ())
// return METHOD_SMB;
else else
{ {
WaitPrompt((char*) "Unable to auto-determine save method!"); WaitPrompt((char*) "Unable to auto-determine save method!");
@ -89,6 +88,83 @@ int autoSaveMethod()
} }
} }
/***************************************************************************
* Update curent directory name
***************************************************************************/
int UpdateDirName()
{
int size=0;
char *test;
char temp[1024];
/* current directory doesn't change */
if (strcmp(filelist[selection].filename,".") == 0)
{
return 0;
}
/* go up to parent directory */
else if (strcmp(filelist[selection].filename,"..") == 0)
{
/* determine last subdirectory namelength */
sprintf(temp,"%s",currentdir);
test = strtok(temp,"/");
while (test != NULL)
{
size = strlen(test);
test = strtok(NULL,"/");
}
/* remove last subdirectory name */
size = strlen(currentdir) - size - 1;
currentdir[size] = 0;
return 1;
}
/* Open a directory */
else
{
/* test new directory namelength */
if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
{
/* update current directory name */
sprintf(currentdir, "%s/%s",currentdir, filelist[selection].filename);
return 1;
}
else
{
WaitPrompt((char*)"Directory name is too long !");
return -1;
}
}
}
/***************************************************************************
* FileSortCallback
*
* Quick sort callback to sort file entries with the following order:
* .
* ..
* <dirs>
* <files>
***************************************************************************/
int FileSortCallback(const void *f1, const void *f2)
{
/* Special case for implicit directories */
if(((FILEENTRIES *)f1)->filename[0] == '.' || ((FILEENTRIES *)f2)->filename[0] == '.')
{
if(strcmp(((FILEENTRIES *)f1)->filename, ".") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, ".") == 0) { return 1; }
if(strcmp(((FILEENTRIES *)f1)->filename, "..") == 0) { return -1; }
if(strcmp(((FILEENTRIES *)f2)->filename, "..") == 0) { return 1; }
}
/* If one is a file and one is a directory the directory is first. */
if(((FILEENTRIES *)f1)->flags == 1 && ((FILEENTRIES *)f2)->flags == 0) return -1;
if(((FILEENTRIES *)f1)->flags == 0 && ((FILEENTRIES *)f2)->flags == 1) return 1;
return stricmp(((FILEENTRIES *)f1)->filename, ((FILEENTRIES *)f2)->filename);
}
/**************************************************************************** /****************************************************************************
* StripExt * StripExt
* *
@ -191,8 +267,6 @@ int SNESROMSOffset()
* *
* Let user select a file from the listing * Let user select a file from the listing
****************************************************************************/ ****************************************************************************/
int offset = 0;
int selection = 0;
#define PADCAL 40 #define PADCAL 40
int int
@ -232,39 +306,39 @@ FileSelector (int method)
c = PAD_SubStickX (0); c = PAD_SubStickX (0);
/*** Check for exit combo ***/ /*** Check for exit combo ***/
if ( (c < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) ) return 0; if ( (c < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) )
return 0;
/*** Check buttons, perform actions ***/ /*** Check buttons, perform actions ***/
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) ) if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
{ {
if ( selectit ) if ( selectit )
selectit = 0; selectit = 0;
if (filelist[selection].flags) /*** This is directory ***/ if (filelist[selection].flags) // This is directory
{ {
if (method == METHOD_SD || method == METHOD_USB) if (method == METHOD_SD || method == METHOD_USB || method == METHOD_SMB)
{ {
/* memorize last entries list, actual root directory and selection for next access */
haveFATdir = 1;
/* update current directory and set new entry list if directory has changed */ /* update current directory and set new entry list if directory has changed */
int status = updateFATdirname(method); int status = UpdateDirName();
if (status == 1) // ok, open directory if (status == 1) // ok, open directory
{ {
if(method == METHOD_SMB)
maxfiles = parseSMBdirectory();
else
maxfiles = parseFATdirectory(method); maxfiles = parseFATdirectory(method);
if (!maxfiles) if (!maxfiles)
{ {
WaitPrompt ((char*) "Error reading directory !"); WaitPrompt ((char*) "Error reading directory !");
haverom = 1; // quit FAT menu haverom = 1; // quit menu
haveFATdir = 0; // reset everything at next access
} }
} }
else if (status == -1) // directory name too long else if (status == -1) // directory name too long
{ {
haverom = 1; // quit FAT menu haverom = 1; // quit menu
haveFATdir = 0; // reset everything at next access
} }
} }
else else if(method == METHOD_DVD)
{ {
if ( (strcmp (filelist[selection].filename, "..") == 0) if ( (strcmp (filelist[selection].filename, "..") == 0)
&& ((unsigned int)rootdir == filelist[selection].offset) ) && ((unsigned int)rootdir == filelist[selection].offset) )
@ -290,9 +364,7 @@ FileSelector (int method)
{ {
case METHOD_SD: case METHOD_SD:
case METHOD_USB: case METHOD_USB:
/*** Load from FAT ***/ // Load from FAT
/* memorize last entries list, actual root directory and selection for next access */
haveFATdir = 1;
ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename, ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename,
filelist[selection].length); filelist[selection].length);
break; break;
@ -441,7 +513,7 @@ OpenDVD (int method)
if (!getpvd()) if (!getpvd())
{ {
ShowAction((char*) "Mounting DVD ... Wait"); ShowAction((char*) "Loading DVD...");
DVD_Mount(); /* mount the DVD unit again */ DVD_Mount(); /* mount the DVD unit again */
havedir = 0; /* this may be a new DVD: content need to be parsed again */ havedir = 0; /* this may be a new DVD: content need to be parsed again */
if (!getpvd()) if (!getpvd())
@ -451,7 +523,6 @@ OpenDVD (int method)
if (havedir == 0) if (havedir == 0)
{ {
offset = selection = 0; /* reset file selector */ offset = selection = 0; /* reset file selector */
haveFATdir = 0; /* prevent conflicts with FAT file selector */
if ((maxfiles = parsedirectory ())) if ((maxfiles = parsedirectory ()))
{ {
@ -483,13 +554,23 @@ OpenDVD (int method)
int int
OpenSMB (int method) OpenSMB (int method)
{ {
if ((maxfiles = parseSMBDirectory ())) // Connect to network share
if(ConnectShare ())
{ {
char txt[80]; // change current dir to root dir
sprintf(txt,"maxfiles = %d", maxfiles); sprintf(currentdir, GCSettings.LoadFolder);
if (maxfiles = parseSMBdirectory ())
{
return FileSelector (method); return FileSelector (method);
} }
else
{
// no entries found
WaitPrompt ((char *)"No Files Found!");
return 0;
}
}
return 0; return 0;
} }
@ -501,35 +582,24 @@ OpenSMB (int method)
int int
OpenFAT (int method) OpenFAT (int method)
{ {
char msg[80]; if(changeFATInterface(method, NOTSILENT))
//if (haveFATdir == 0)
//{
/* don't mess with DVD entries */
havedir = 0; // gamecube only
/* change current dir to snes roms directory */
changeFATInterface(GCSettings.LoadMethod);
sprintf ( currFATdir, "%s/%s", ROOTFATDIR, GCSettings.LoadFolder );
/* Parse initial root directory and get entries list */
if ((maxfiles = parseFATdirectory (method)))
{ {
/* Select an entry */ // change current dir to snes roms directory
sprintf ( currentdir, "%s/%s", ROOTFATDIR, GCSettings.LoadFolder );
// Parse initial root directory and get entries list
if (maxfiles = parseFATdirectory (method))
{
// Select an entry
return FileSelector (method); return FileSelector (method);
} }
else else
{ {
/* no entries found */ // no entries found
sprintf (msg, "No Files Found!"); WaitPrompt ((char *)"No Files Found!");
WaitPrompt (msg);
return 0; return 0;
} }
//} }
/* Retrieve previous entries list and made a new selection */
//else
// return FileSelector (method);
return 0; return 0;
} }
@ -591,7 +661,7 @@ LoadDVDFile (unsigned char *buffer)
blocks = rootdirlength / 2048; blocks = rootdirlength / 2048;
offset = 0; offset = 0;
discoffset = rootdir; discoffset = rootdir;
ShowAction ((char*) "Loading ... Wait"); ShowAction ((char*) "Loading...");
dvd_read (readbuffer, 2048, discoffset); dvd_read (readbuffer, 2048, discoffset);
if (!IsZipFile (readbuffer)) if (!IsZipFile (readbuffer))

View File

@ -13,5 +13,6 @@
int OpenROM (int method); int OpenROM (int method);
int autoLoadMethod(); int autoLoadMethod();
int autoSaveMethod(); int autoSaveMethod();
int FileSortCallback(const void *f1, const void *f2);
#endif #endif

View File

@ -19,25 +19,20 @@
#include <fat.h> #include <fat.h>
#include <zlib.h> #include <zlib.h>
#include "memfile.h"
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
#include "soundux.h" #include "soundux.h"
#include "snapshot.h" #include "snapshot.h"
#include "srtc.h" #include "srtc.h"
#include "memfile.h"
#include "Snes9xGx.h" #include "Snes9xGx.h"
#include "filesel.h" #include "filesel.h"
#include "menudraw.h" #include "menudraw.h"
#include "smbload.h" #include "smbop.h"
#include "fileop.h" #include "fileop.h"
#include "mcsave.h" #include "mcsave.h"
extern "C"
{
#include "smb.h"
}
#define MEMBUFFER (512 * 1024) #define MEMBUFFER (512 * 1024)
extern void S9xSRTCPreSaveState (); extern void S9xSRTCPreSaveState ();
@ -138,16 +133,15 @@ NGCFreezeGame (int method, bool8 silent)
method = autoSaveMethod(); method = autoSaveMethod();
char filename[1024]; char filename[1024];
SMBFILE smbfile; //SMBFILE smbfile;
FILE *handle; FILE *handle;
int len = 0; int len = 0;
int wrote = 0;
int offset = 0;
char msg[100]; char msg[100];
if (method == METHOD_SD || method == METHOD_USB) // SD if (method == METHOD_SD || method == METHOD_USB) // SD
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(method, NOTSILENT);
sprintf (filename, "%s/%s/%s.frz", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filename, "%s/%s/%s.frz", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
} }
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC Slot A or B else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC Slot A or B
@ -189,7 +183,7 @@ NGCFreezeGame (int method, bool8 silent)
} }
else else
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(GCSettings.SaveMethod, NOTSILENT);
sprintf(msg, "Couldn't save to %s/%s/", ROOTFATDIR, GCSettings.SaveFolder); sprintf(msg, "Couldn't save to %s/%s/", ROOTFATDIR, GCSettings.SaveFolder);
WaitPrompt (msg); WaitPrompt (msg);
} }
@ -246,10 +240,8 @@ NGCFreezeGame (int method, bool8 silent)
} }
else if (method == METHOD_SMB) // SMB else if (method == METHOD_SMB) // SMB
{ {
ConnectSMB (); /*
smbfile = SMB_OpenFile (filename, SMB_OPEN_WRITING, SMB_OF_CREATE | SMB_OF_TRUNCATE);
smbfile = SMB_Open (filename, SMB_OPEN_WRITING | SMB_DENY_NONE,
SMB_OF_CREATE | SMB_OF_TRUNCATE);
if (smbfile) if (smbfile)
{ {
@ -273,7 +265,7 @@ NGCFreezeGame (int method, bool8 silent)
len -= wrote; len -= wrote;
} }
SMB_Close (smbfile); SMB_CloseFile (smbfile);
if ( !silent ) if ( !silent )
{ {
@ -287,6 +279,7 @@ NGCFreezeGame (int method, bool8 silent)
sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder); sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder);
WaitPrompt (msg); WaitPrompt (msg);
} }
*/
} }
return 0; return 0;
} }
@ -335,7 +328,7 @@ int
NGCUnfreezeGame (int method, bool8 silent) NGCUnfreezeGame (int method, bool8 silent)
{ {
char filename[1024]; char filename[1024];
SMBFILE smbfile; //SMBFILE smbfile;
FILE *handle; FILE *handle;
int read = 0; int read = 0;
int offset = 0; int offset = 0;
@ -348,7 +341,7 @@ NGCUnfreezeGame (int method, bool8 silent)
if (method == METHOD_SD || method == METHOD_USB) // SD & USB if (method == METHOD_SD || method == METHOD_USB) // SD & USB
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(method, NOTSILENT);
sprintf (filename, "%s/%s/%s.frz", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filename, "%s/%s/%s.frz", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
handle = fopen (filename, "rb"); handle = fopen (filename, "rb");
@ -373,15 +366,13 @@ NGCUnfreezeGame (int method, bool8 silent)
WaitPrompt((char*) "Error thawing"); WaitPrompt((char*) "Error thawing");
return 0; return 0;
} }
}
else
{
WaitPrompt((char*) "No freeze file found");
return 0;
}
return 1; return 1;
} }
WaitPrompt((char*) "Freeze file not found");
return 0;
}
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC in slot A or slot B else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC in slot A or slot B
{ {
if ( !silent ) if ( !silent )
@ -436,27 +427,24 @@ NGCUnfreezeGame (int method, bool8 silent)
return 0; return 0;
} }
} }
else
{ WaitPrompt((char*) "Freeze file not found");
return 0; return 0;
} }
return 1;
}
else if (method == METHOD_SMB) // Network (SMB) else if (method == METHOD_SMB) // Network (SMB)
{ {
sprintf (filename, "\\%s\\%s.frz", GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filename, "%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
ConnectSMB ();
/*** Read the file into memory ***/ // Read the file into memory
smbfile = /*smbfile =
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN); SMB_OpenFile (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
if (smbfile) if (smbfile)
{ {
if ( !silent ) if ( !silent )
ShowAction ((char*) "Loading freeze file..."); ShowAction ((char*) "Loading freeze file...");
while ((read = while ((read =
SMB_Read ((char *) membuffer + offset, 1024, offset, SMB_ReadFile ((char *) membuffer + offset, 1024, offset,
smbfile)) > 0) smbfile)) > 0)
offset += read; offset += read;
@ -472,22 +460,10 @@ NGCUnfreezeGame (int method, bool8 silent)
} }
else if ( !silent ) else if ( !silent )
{ {
WaitPrompt((char*) "No freeze file found"); WaitPrompt((char*) "Freeze file not found");
return 0; return 0;
} }
return 1; return 1;*/
} }
return 0; // if we reached here, nothing was done! return 0; // if we reached here, nothing was done!
} }
void quickLoadFreeze (bool8 silent)
{
NGCUnfreezeGame ( GCSettings.SaveMethod, silent );
}
void quickSaveFreeze (bool8 silent)
{
NGCFreezeGame ( GCSettings.SaveMethod, silent );
}

View File

@ -9,7 +9,6 @@
* There's just enough here to do SnapShots - you should add anything else you * There's just enough here to do SnapShots - you should add anything else you
* need. * need.
****************************************************************************/ ****************************************************************************/
#include "snes9x.h"
#ifndef _NGCMEMFILE_ #ifndef _NGCMEMFILE_
#define _NGCMEMFILE_ #define _NGCMEMFILE_
@ -28,7 +27,4 @@ MEMFILE;
int NGCFreezeGame (int method, bool8 silent); int NGCFreezeGame (int method, bool8 silent);
int NGCUnfreezeGame (int method, bool8 silent); int NGCUnfreezeGame (int method, bool8 silent);
void quickLoadFreeze (bool8 silent);
void quickSaveFreeze (bool8 silent);
#endif #endif

View File

@ -12,8 +12,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include "snes9x.h" #include "snes9x.h"
#include "snes9xGx.h"
#include "memmap.h" #include "memmap.h"
#include "debug.h" #include "debug.h"
#include "cpuexec.h" #include "cpuexec.h"
@ -25,12 +25,15 @@
#include "spc700.h" #include "spc700.h"
#include "spc7110.h" #include "spc7110.h"
#include "controls.h" #include "controls.h"
#include "cheats.h"
#include "snes9xGx.h"
#include "aram.h" #include "aram.h"
#include "video.h" #include "video.h"
#include "mcsave.h" #include "mcsave.h"
#include "filesel.h" #include "filesel.h"
#include "unzip.h" #include "unzip.h"
#include "smbload.h" #include "smbop.h"
#include "mcsave.h" #include "mcsave.h"
#include "fileop.h" #include "fileop.h"
#include "memfile.h" #include "memfile.h"
@ -38,10 +41,8 @@
#include "s9xconfig.h" #include "s9xconfig.h"
#include "sram.h" #include "sram.h"
#include "preferences.h" #include "preferences.h"
#include "button_mapping.h" #include "button_mapping.h"
#include "menudraw.h" #include "menudraw.h"
#include "cheats.h"
#include "cheatmgr.h" #include "cheatmgr.h"
extern void DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize); extern void DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize);
@ -83,9 +84,9 @@ LoadManager ()
if ( loadROM == 1 ) // if ROM was loaded, load the SRAM & settings if ( loadROM == 1 ) // if ROM was loaded, load the SRAM & settings
{ {
if ( GCSettings.AutoLoad == 1 ) if ( GCSettings.AutoLoad == 1 )
quickLoadSRAM ( SILENT ); LoadSRAM(GCSettings.SaveMethod, SILENT);
else if ( GCSettings.AutoLoad == 2 ) else if ( GCSettings.AutoLoad == 2 )
quickLoadFreeze ( SILENT ); NGCUnfreezeGame (GCSettings.SaveMethod, SILENT);
// setup cheats // setup cheats
SetupCheats(); SetupCheats();
@ -266,7 +267,7 @@ PreferencesMenu ()
break; break;
case 13: case 13:
quickSavePrefs(NOTSILENT); SavePrefs(GCSettings.SaveMethod, NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/
@ -367,7 +368,7 @@ GameMenu ()
break; break;
case 4: // Load SRAM case 4: // Load SRAM
LoadSRAM(GCSettings.SaveMethod, NOTSILENT); quit = retval = LoadSRAM(GCSettings.SaveMethod, SILENT);
break; break;
case 5: // Save SRAM case 5: // Save SRAM
@ -707,7 +708,7 @@ ConfigureControllers ()
case 8: case 8:
/*** Save Preferences Now ***/ /*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT); SavePrefs(GCSettings.SaveMethod, NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/

View File

@ -371,7 +371,7 @@ unpackbackdrop ()
int offset; int offset;
int i; int i;
// backdrop = (unsigned int *) malloc (screenheight * 1280); // backdrop = (unsigned int *) malloc (screenheight * 1280);
backdrop = (u32 *) malloc (screenheight * 1280); backdrop = (u32 *) malloc (screenheight * 1280);
colour = getcolour (0x00, 0x00, 0x00); colour = getcolour (0x00, 0x00, 0x00);
@ -388,13 +388,14 @@ unpackbackdrop ()
uncompress ((Bytef *) backdrop + offset, &outbytes, (Bytef *) bg, uncompress ((Bytef *) backdrop + offset, &outbytes, (Bytef *) bg,
inbytes); inbytes);
#ifndef HW_RVL #ifndef HW_RVL
/*** Now store the backdrop in ARAM ***/ /*** Now store the backdrop in ARAM ***/
ARAMPut ((char *) backdrop, (char *) AR_BACKDROP, 640 * screenheight * 2); ARAMPut ((char *) backdrop, (char *) AR_BACKDROP, 640 * screenheight * 2);
free (backdrop); free (backdrop);
#endif #endif
// otherwise (on wii) backdrop is stored in memory // otherwise (on wii) backdrop is stored in memory
clearscreen ();
showscreen ();
} }
/**************************************************************************** /****************************************************************************

View File

@ -20,7 +20,7 @@
#include "menudraw.h" #include "menudraw.h"
#include "mcsave.h" #include "mcsave.h"
#include "fileop.h" #include "fileop.h"
#include "smbload.h" #include "smbop.h"
#include "filesel.h" #include "filesel.h"
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
@ -139,13 +139,13 @@ SavePrefs (int method, bool silent)
if(method == METHOD_SD || method == METHOD_USB) if(method == METHOD_SD || method == METHOD_USB)
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(GCSettings.SaveMethod, NOTSILENT);
sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
offset = SaveBufferToFAT (filepath, datasize, silent); offset = SaveBufferToFAT (filepath, datasize, silent);
} }
else if(method == METHOD_SMB) else if(method == METHOD_SMB)
{ {
sprintf (filepath, "%s\\%s", GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
offset = SaveBufferToSMB (filepath, datasize, silent); offset = SaveBufferToSMB (filepath, datasize, silent);
} }
else if(method == METHOD_MC_SLOTA) else if(method == METHOD_MC_SLOTA)
@ -187,13 +187,13 @@ LoadPrefs (int method, bool silent)
if(method == METHOD_SD || method == METHOD_USB) if(method == METHOD_SD || method == METHOD_USB)
{ {
changeFATInterface(GCSettings.SaveMethod); changeFATInterface(GCSettings.SaveMethod, NOTSILENT);
sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s/%s", ROOTFATDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
offset = LoadBufferFromFAT (filepath, silent); offset = LoadBufferFromFAT (filepath, silent);
} }
else if(method == METHOD_SMB) else if(method == METHOD_SMB)
{ {
sprintf (filepath, "%s\\%s", GCSettings.SaveFolder, PREFS_FILE_NAME); sprintf (filepath, "%s/%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
LoadBufferFromSMB (filepath, silent); LoadBufferFromSMB (filepath, silent);
} }
else if(method == METHOD_MC_SLOTA) else if(method == METHOD_MC_SLOTA)
@ -216,21 +216,3 @@ LoadPrefs (int method, bool silent)
} }
return retval; return retval;
} }
/****************************************************************************
* Quick Load Preferences
****************************************************************************/
bool quickLoadPrefs (bool8 silent)
{
return LoadPrefs(GCSettings.SaveMethod, silent);
}
/****************************************************************************
* Quick Save Preferences
****************************************************************************/
bool quickSavePrefs (bool8 silent)
{
return SavePrefs(GCSettings.SaveMethod, silent);
}

View File

@ -9,9 +9,5 @@
* Preferences save/load preferences utilities * Preferences save/load preferences utilities
****************************************************************************/ ****************************************************************************/
int preparePrefsData ();
bool decodePrefsData ();
bool SavePrefs (int method, bool silent); bool SavePrefs (int method, bool silent);
bool LoadPrefs (int method, bool silent); bool LoadPrefs (int method, bool silent);
bool quickLoadPrefs (bool8 silent);
bool quickSavePrefs (bool8 silent);

View File

@ -157,7 +157,7 @@
#include <gccore.h> #include <gccore.h>
#include "snes9x.h" #include "snes9x.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "smbload.h" #include "smbop.h"
void void
DefaultSettings () DefaultSettings ()
@ -170,6 +170,18 @@ DefaultSettings ()
GCSettings.AutoLoad = 1; GCSettings.AutoLoad = 1;
GCSettings.AutoSave = 1; GCSettings.AutoSave = 1;
// default SMB settings
#define GC_IP "192.168.0.32" // IP to assign the GameCube
#define GW_IP "192.168.0.150" // Your gateway IP
#define MASK "255.255.255.0" // Your subnet mask
#define SMB_USER "Wiiuser" // Your share user
#define SMB_PWD "password" // Your share user password
#define SMB_GCID "Wii" // Machine Name of GameCube
#define SMB_SVID "Server" // Machine Name of Server(Share)
#define SMB_SHARE "SNES" // Share name on server
#define SMB_IP "192.168.0.1" // IP Address of share server
strncpy (GCSettings.gcip, GC_IP, 15); strncpy (GCSettings.gcip, GC_IP, 15);
strncpy (GCSettings.gwip, GW_IP, 15); strncpy (GCSettings.gwip, GW_IP, 15);
strncpy (GCSettings.mask, MASK, 15); strncpy (GCSettings.mask, MASK, 15);

View File

@ -1,372 +0,0 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Gamecube Port
* softdev July 2006
* crunchy2 May 2007
*
* smbload.cpp
*
* Load ROMS from a Network share.
****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include <network.h>
extern "C"
{
#include "smb.h"
}
#include "unzip.h"
#include "memmap.h"
#include "video.h"
#include "menudraw.h"
#include "dvd.h"
#include "filesel.h"
#include "sram.h"
#include "preferences.h"
#include "smbload.h"
#include "Snes9xGx.h"
#include <zlib.h>
static int connected = 0;
static int netinited = 0;
char output[16384];
unsigned int SMBTimer = 0;
extern unsigned char savebuffer[];
#define ZIPCHUNK 16384
#define SMBTIMEOUT ( 3600 ) /*** Some implementations timeout in 10 minutes ***/
SMBINFO smbinfo =
{ GC_IP, GW_IP, MASK, SMB_IP,
SMB_USER, SMB_PWD, SMB_GCID, SMB_SVID, SMB_SHARE
};
extern FILEENTRIES filelist[MAXFILES];
/****************************************************************************
* Mount SMB Share
****************************************************************************/
void
ConnectSMB ()
{
int ret;
if (SMBTimer > SMBTIMEOUT)
{
connected = 0;
SMBTimer = 0;
}
if (connected == 0)
{
if (netinited == 0)
{
ShowAction ((char*) "Setting up network interface ...");
ret = if_config (smbinfo.gcip, smbinfo.gwip, smbinfo.mask, 0);
netinited = 1;
}
ShowAction ((char*) "Connecting to share ...");
SMB_Destroy ();
if (SMB_Init (smbinfo.smbuser, smbinfo.smbpwd,
smbinfo.smbgcid, smbinfo.smbsvid, smbinfo.smbshare,
smbinfo.smbip) != SMB_SUCCESS)
{
WaitPrompt((char*) "Failed to connect to SMB share");
connected = 0;
return;
}
}
connected = 1;
}
/****************************************************************************
* parseSMBDirectory
*
* Load the share directory and put in the filelist array
*****************************************************************************/
int
parseSMBDirectory ()
{
char searchpath[1024];
int filecount = 0;
SMBDIRENTRY smbdir;
ConnectSMB ();
strcpy (searchpath, GCSettings.LoadFolder);
strcat (searchpath, "\\*.*");
if (SMB_FindFirst
(searchpath, SMB_SRCH_READONLY | SMB_SRCH_SYSTEM | SMB_SRCH_HIDDEN,
&smbdir) != SMB_SUCCESS)
{
return 0;
}
do
{
memset (&filelist[filecount], 0, sizeof (FILEENTRIES));
filelist[filecount].length = smbdir.size_low;
smbdir.name[MAXJOLIET] = 0;
/*** Update display name ***/
memcpy (&filelist[filecount].displayname, smbdir.name, MAXDISPLAY);
filelist[filecount].displayname[MAXDISPLAY] = 0;
strcpy (filelist[filecount].filename, smbdir.name);
filecount++;
}
while (SMB_FindNext (&smbdir) == SMB_SUCCESS);
SMB_FindClose ();
return filecount;
}
/****************************************************************************
* Load SMB file
****************************************************************************/
int
LoadSMBFile (char *filename, int length)
{
char buffer[128];
int offset = 0;
int bytesread = 0;
int total = 0;
char filepath[1024];
SMBFILE smbfile;
char *rbuffer;
char zipbuffer[16384];
int pass = 0;
int zip = 0;
PKZIPHEADER pkzip;
z_stream zs;
int res, outbytes;
strcpy (filepath, GCSettings.LoadFolder);
strcat (filepath, "\\");
strcat (filepath, filename);
rbuffer = (char *) Memory.ROM;
outbytes = 0;
int have = 0;
ConnectSMB ();
if ( connected )
{
/*** Open the file for reading ***/
smbfile =
SMB_Open (filepath, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
if (smbfile)
{
while (total < length)
{
bytesread = SMB_Read (zipbuffer, 16384, offset, smbfile);
if (pass == 0)
{
/*** Is this a Zip file ? ***/
zip = IsZipFile (zipbuffer);
if (zip)
{
memcpy (&pkzip, zipbuffer, sizeof (PKZIPHEADER));
pkzip.uncompressedSize = FLIP32 (pkzip.uncompressedSize);
memset (&zs, 0, sizeof (zs));
zs.zalloc = Z_NULL;
zs.zfree = Z_NULL;
zs.opaque = Z_NULL;
zs.avail_in = 0;
zs.next_in = Z_NULL;
res = inflateInit2 (&zs, -MAX_WBITS);
if (res != Z_OK)
{
SMB_Close (smbfile);
return 0;
}
zs.avail_in =
16384 - (sizeof (PKZIPHEADER) +
FLIP16 (pkzip.filenameLength) +
FLIP16 (pkzip.extraDataLength));
zs.next_in =
(Bytef *) zipbuffer + (sizeof (PKZIPHEADER) +
FLIP16 (pkzip.filenameLength) +
FLIP16 (pkzip.extraDataLength));
}
}
if (zip)
{
if (pass)
{
zs.avail_in = bytesread;
zs.next_in = (Bytef *) zipbuffer;
}
do
{
zs.avail_out = ZIPCHUNK;
zs.next_out = (Bytef *) output;
res = inflate (&zs, Z_NO_FLUSH);
have = ZIPCHUNK - zs.avail_out;
if (have)
{
memcpy (rbuffer + outbytes, output, have);
outbytes += have;
}
}
while (zs.avail_out == 0);
}
else
memcpy (rbuffer + offset, zipbuffer, bytesread);
total += bytesread;
offset += bytesread;
if (!zip)
{
sprintf (buffer, "Read %d of %d bytes", total, length);
ShowProgress (buffer, total, length);
}
else
{
sprintf (buffer, "Unzipped %d of %d", outbytes,
pkzip.uncompressedSize);
ShowProgress (buffer, outbytes, pkzip.uncompressedSize);
}
//ShowAction (buffer);
pass++;
}
if (zip)
{
inflateEnd (&zs);
total = outbytes;
}
SMB_Close (smbfile);
return total;
}
else
{
WaitPrompt((char*) "SMB Reading Failed!");
//while (1);
return 0;
}
}
return 0;
}
/****************************************************************************
* Write savebuffer to SMB file
****************************************************************************/
int
SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
{
SMBFILE smbfile;
int dsize = datasize;
int wrote = 0;
int offset = 0;
ConnectSMB ();
if ( connected )
{
smbfile =
SMB_Open (filepath, SMB_OPEN_WRITING | SMB_DENY_NONE,
SMB_OF_CREATE | SMB_OF_TRUNCATE);
if (smbfile)
{
while (dsize > 0)
{
if (dsize > 1024)
wrote =
SMB_Write ((char *) savebuffer + offset, 1024, offset, smbfile);
else
wrote =
SMB_Write ((char *) savebuffer + offset, dsize, offset, smbfile);
offset += wrote;
dsize -= wrote;
}
SMB_Close (smbfile);
SMBTimer = 0;
return offset;
}
else
{
char msg[100];
sprintf(msg, "Couldn't save SMB:%s", filepath);
WaitPrompt (msg);
}
}
return 0;
}
/****************************************************************************
* Load savebuffer from SMB file
****************************************************************************/
int
LoadBufferFromSMB (char *filepath, bool8 silent)
{
SMBFILE smbfile;
int ret;
int offset = 0;
ConnectSMB ();
if ( connected )
{
smbfile =
SMB_Open (filepath, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
if (!smbfile)
{
if (!silent)
{
char msg[100];
sprintf(msg, "Couldn't open SMB:%s", filepath);
WaitPrompt (msg);
}
return 0;
}
memset (savebuffer, 0, 0x22000);
while ((ret =
SMB_Read ((char *) savebuffer + offset, 1024, offset,
smbfile)) > 0)
offset += ret;
SMB_Close (smbfile);
return offset;
}
return 0;
}

393
source/ngc/smbop.cpp Normal file
View File

@ -0,0 +1,393 @@
/****************************************************************************
* Snes9x 1.50
*
* Nintendo Wii/Gamecube Port
* softdev July 2006
* crunchy2 May 2007
* Tantric August 2008
*
* smbload.cpp
*
* SMB support routines
****************************************************************************/
#include <gccore.h>
#include <stdio.h>
#include <string.h>
#include <ogcsys.h>
#include <network.h>
#include <smb.h>
#include <zlib.h>
#include <errno.h>
#include "memmap.h"
#include "unzip.h"
#include "video.h"
#include "menudraw.h"
#include "dvd.h"
#include "filesel.h"
#include "smbop.h"
#include "Snes9xGx.h"
SMBCONN smbconn;
extern char currentdir[MAXPATHLEN];
char output[16384];
extern unsigned char savebuffer[];
#define ZIPCHUNK 16384
/****************************************************************************
* InitializeNetwork
* Initializes the Wii/GameCube network interface
****************************************************************************/
bool InitializeNetwork(bool silent)
{
ShowAction ((char*) "Initializing network...");
s32 result;
while ((result = net_init()) == -EAGAIN);
if (result >= 0)
{
char myIP[16];
if (if_config(myIP, NULL, NULL, true) < 0)
{
WaitPrompt((char*) "Error reading IP address.");
return false;
}
else
{
if(!silent)
{
char msg[100];
sprintf(msg, "Network initialized. IP address: %s", myIP);
WaitPrompt(msg);
}
return true;
}
}
WaitPrompt((char*) "Unable to initialize network.");
return false;
}
/****************************************************************************
* Mount SMB Share
****************************************************************************/
bool
ConnectShare ()
{
bool networkInit = false;
bool networkShareInit = false;
networkInit = InitializeNetwork(SILENT);
if(networkInit)
{
ShowAction ((char*) "Connecting to network share...");
if(SMB_Connect(&smbconn, GCSettings.smbuser, GCSettings.smbpwd,
GCSettings.smbgcid, GCSettings.smbsvid, GCSettings.smbshare, GCSettings.smbip) == SMB_SUCCESS)
networkShareInit = true;
if(!networkShareInit)
WaitPrompt ((char*) "Failed to connect to network share.");
}
return networkShareInit;
}
/****************************************************************************
* parseSMBDirectory
*
* Load the directory and put in the filelist array
*****************************************************************************/
int
parseSMBdirectory ()
{
int filecount = 0;
char searchpath[1024];
SMBDIRENTRY smbdir;
sprintf(searchpath, "%s/*", currentdir);
// fix path - replace all '/' with '\'
for(uint i=0; i < strlen(searchpath); i++)
if(searchpath[i] == '/')
searchpath[i] = '\\';
ShowAction((char*) "Loading...");
if (SMB_FindFirst
(searchpath, SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
{
char msg[200];
sprintf(msg, "Could not open %s", currentdir);
WaitPrompt (msg);
// if we can't open the dir, open root dir
currentdir[0] = '\0';
sprintf(searchpath,"*");
if (SMB_FindFirst
(searchpath, SMB_SRCH_READONLY | SMB_SRCH_DIRECTORY, &smbdir, smbconn) != SMB_SUCCESS)
return 0;
}
// index files/folders
do
{
if(strcmp(smbdir.name,".") != 0 &&
!(strcmp(currentdir,"/") == 0 && strcmp(smbdir.name,"..") == 0))
{
memset (&filelist[filecount], 0, sizeof (FILEENTRIES));
filelist[filecount].length = smbdir.size_low;
smbdir.name[MAXJOLIET] = 0;
if(smbdir.attributes == SMB_SRCH_DIRECTORY)
filelist[filecount].flags = 1; // flag this as a dir
else
filelist[filecount].flags = 0;
// Update display name
memcpy (&filelist[filecount].displayname, smbdir.name, MAXDISPLAY);
filelist[filecount].displayname[MAXDISPLAY] = 0;
strcpy (filelist[filecount].filename, smbdir.name);
filecount++;
}
} while (SMB_FindNext (&smbdir, smbconn) == SMB_SUCCESS);
// close directory
SMB_FindClose (smbconn);
// Sort the file list
qsort(filelist, filecount, sizeof(FILEENTRIES), FileSortCallback);
return filecount;
}
/****************************************************************************
* Load SMB file
****************************************************************************/
int
LoadSMBFile (char *filename, int length)
{
int offset = 0;
int bytesread = 0;
char filepath[1024];
SMBFILE smbfile;
unsigned char *rbuffer;
char zipbuffer[16384];
int pass = 0;
int zip = 0;
PKZIPHEADER pkzip;
z_stream zs;
int res, outbytes = 0;
rbuffer = (unsigned char *) Memory.ROM;
int have = 0;
if(strcmp(currentdir,"/") == 0)
sprintf(filepath, "/%s", filename);
else
sprintf(filepath, "%s/%s", currentdir, filename);
// fix path - replace all '/' with '\'
for(uint i=0; i < strlen(filepath); i++)
if(filepath[i] == '/')
filepath[i] = '\\';
ShowAction((char *)"Loading...");
// Open the file for reading
smbfile =
SMB_OpenFile (filepath, SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
if (smbfile)
{
while (offset < length)
{
// Don't read past end of file
if (offset + bytesread > length)
bytesread = length - offset;
else
bytesread = 16384;
SMB_ReadFile (zipbuffer, bytesread, offset, smbfile);
if (pass == 0)
{
// Is this a Zip file ?
zip = IsZipFile (zipbuffer);
if (zip)
{
memcpy (&pkzip, zipbuffer, sizeof (PKZIPHEADER));
pkzip.uncompressedSize = FLIP32 (pkzip.uncompressedSize);
memset (&zs, 0, sizeof (zs));
zs.zalloc = Z_NULL;
zs.zfree = Z_NULL;
zs.opaque = Z_NULL;
zs.avail_in = 0;
zs.next_in = Z_NULL;
res = inflateInit2 (&zs, -MAX_WBITS);
if (res != Z_OK)
{
SMB_CloseFile (smbfile);
return 0;
}
zs.avail_in =
16384 - (sizeof (PKZIPHEADER) +
FLIP16 (pkzip.filenameLength) +
FLIP16 (pkzip.extraDataLength));
zs.next_in =
(Bytef *) zipbuffer + (sizeof (PKZIPHEADER) +
FLIP16 (pkzip.filenameLength) +
FLIP16 (pkzip.extraDataLength));
}
}
if (zip)
{
if (pass)
{
zs.avail_in = bytesread;
zs.next_in = (Bytef *) zipbuffer;
}
do
{
zs.avail_out = ZIPCHUNK;
zs.next_out = (Bytef *) output;
res = inflate (&zs, Z_NO_FLUSH);
have = ZIPCHUNK - zs.avail_out;
if (have)
{
memcpy (rbuffer + outbytes, output, have);
outbytes += have;
}
} while (zs.avail_out == 0);
}
else
{
memcpy (rbuffer + offset, zipbuffer, bytesread);
}
offset += bytesread;
pass++;
}
if (zip)
{
inflateEnd (&zs);
offset = outbytes;
}
SMB_CloseFile (smbfile);
return offset;
}
else
{
WaitPrompt((char*) "SMB Reading Failed!");
return 0;
}
}
/****************************************************************************
* Write savebuffer to SMB file
****************************************************************************/
int
SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
{
SMBFILE smbfile;
int dsize = datasize;
int wrote = 0;
int offset = 0;
// fix path - replace all '/' with '\'
for(uint i=0; i < strlen(filepath); i++)
if(filepath[i] == '/')
filepath[i] = '\\';
smbfile =
SMB_OpenFile (filepath, SMB_OPEN_WRITING | SMB_DENY_NONE,
SMB_OF_CREATE | SMB_OF_TRUNCATE, smbconn);
if (smbfile)
{
while (dsize > 0)
{
if (dsize > 1024)
wrote =
SMB_WriteFile ((char *) savebuffer + offset, 1024, offset, smbfile);
else
wrote =
SMB_WriteFile ((char *) savebuffer + offset, dsize, offset, smbfile);
offset += wrote;
dsize -= wrote;
}
SMB_CloseFile (smbfile);
return offset;
}
else
{
char msg[100];
sprintf(msg, "Couldn't save SMB: %s", filepath);
WaitPrompt (msg);
}
return 0;
}
/****************************************************************************
* Load savebuffer from SMB file
****************************************************************************/
int
LoadBufferFromSMB (char *filepath, bool8 silent)
{
SMBFILE smbfile;
int ret;
int offset = 0;
// fix path - replace all '/' with '\'
for(uint i=0; i < strlen(filepath); i++)
if(filepath[i] == '/')
filepath[i] = '\\';
smbfile =
SMB_OpenFile (filepath, SMB_OPEN_READING, SMB_OF_OPEN, smbconn);
if (!smbfile)
{
if (!silent)
{
char msg[100];
sprintf(msg, "Couldn't open SMB: %s", filepath);
WaitPrompt (msg);
}
return 0;
}
memset (savebuffer, 0, 0x22000);
while ((ret =
SMB_ReadFile ((char *) savebuffer + offset, 1024, offset,
smbfile)) > 0)
offset += ret;
SMB_CloseFile (smbfile);
return offset;
}

View File

@ -1,38 +1,26 @@
/**************************************************************************** /****************************************************************************
* Snes9x 1.50 * Snes9x 1.50
* *
* Nintendo Gamecube Port * Nintendo Wii/Gamecube Port
* softdev July 2006 * softdev July 2006
* crunchy2 May 2007 * crunchy2 May 2007
* Tantric August 2008
* *
* smbload.cpp * smbop.h
* *
* Load ROMS from a Network share. * SMB support routines
****************************************************************************/ ****************************************************************************/
#ifndef _NGCSMB_ #ifndef _NGCSMB_
#define _NGCSMB_ #define _NGCSMB_
void ConnectSMB (); bool InitializeNetwork(bool silent);
int parseSMBDirectory (); bool ConnectShare ();
int updateSMBdirname();
int parseSMBdirectory ();
int LoadSMBFile (char *filename, int length); int LoadSMBFile (char *filename, int length);
int LoadBufferFromSMB (char *filepath, bool8 silent); int LoadBufferFromSMB (char *filepath, bool8 silent);
int SaveBufferToSMB (char *filepath, int datasize, bool8 silent); int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
typedef struct
{
char gcip[16];
char gwip[16];
char mask[16];
char smbip[16];
char smbuser[20];
char smbpwd[20];
char smbgcid[20];
char smbsvid[20];
char smbshare[20];
}
SMBINFO;
#endif #endif

View File

@ -180,6 +180,7 @@
#include "snes9xGX.h" #include "snes9xGX.h"
#include "dvd.h" #include "dvd.h"
#include "smbop.h"
#include "video.h" #include "video.h"
#include "menudraw.h" #include "menudraw.h"
#include "s9xconfig.h" #include "s9xconfig.h"
@ -574,19 +575,19 @@ NGCReportButtons ()
if ( GCSettings.AutoSave == 1 ) if ( GCSettings.AutoSave == 1 )
{ {
quickSaveSRAM ( SILENT ); SaveSRAM(GCSettings.SaveMethod, SILENT );
} }
else if ( GCSettings.AutoSave == 2 ) else if ( GCSettings.AutoSave == 2 )
{ {
if ( WaitPromptChoice ((char*)"Save Freeze State?", (char*)"Don't Save", (char*)"Save") ) if ( WaitPromptChoice ((char*)"Save Freeze State?", (char*)"Don't Save", (char*)"Save") )
quickSaveFreeze ( SILENT ); NGCFreezeGame ( GCSettings.SaveMethod, SILENT );
} }
else if ( GCSettings.AutoSave == 3 ) else if ( GCSettings.AutoSave == 3 )
{ {
if ( WaitPromptChoice ((char*)"Save SRAM and Freeze State?", (char*)"Don't Save", (char*)"Save") ) if ( WaitPromptChoice ((char*)"Save SRAM and Freeze State?", (char*)"Don't Save", (char*)"Save") )
{ {
quickSaveSRAM ( SILENT ); SaveSRAM(GCSettings.SaveMethod, SILENT );
quickSaveFreeze ( SILENT ); NGCFreezeGame ( GCSettings.SaveMethod, SILENT );
} }
} }
@ -656,19 +657,23 @@ void SetControllers ()
} }
else if (Settings.MouseMaster == true) else if (Settings.MouseMaster == true)
{ {
// some games (eg: Mario Paint) don't allow the mouse in port 2
S9xSetController (0, CTL_MOUSE, 0, 0, 0, 0); S9xSetController (0, CTL_MOUSE, 0, 0, 0, 0);
if (GCSettings.Mouse == 2) S9xSetController (1, CTL_MOUSE, 1, 0, 0, 0); if (GCSettings.Mouse == 2)
else S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); S9xSetController (1, CTL_MOUSE, 1, 0, 0, 0);
else
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
} }
else if (Settings.JustifierMaster == true) else if (Settings.JustifierMaster == true)
{ {
S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0); S9xSetController(0, CTL_JUSTIFIER, 0, 0, 0, 0);
S9xSetController(1, CTL_JUSTIFIER, (GCSettings.Justifier == 2), 0, 0, 0); if(GCSettings.Justifier == 2)
S9xSetController(1, CTL_JUSTIFIER, 1, 0, 0, 0);
else
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
} }
else else
{ {
/*** Plugin 2 Joypads by default ***/ // Plugin 2 Joypads by default
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0); S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0); S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
} }
@ -830,36 +835,15 @@ main ()
unsigned int save_flags; unsigned int save_flags;
int selectedMenu = -1; int selectedMenu = -1;
/*** Initialise GC ***/ #ifdef HW_RVL
InitGCVideo (); /*** Get the ball rolling ***/
/*** Initialize libFAT for SD and USB ***/
fatInitDefault();
//fatInit(8192, false);
#ifdef HW_RVL
//fat_enable_readahead_all();
#endif
/*** Initialize DVD subsystem ***/
DVD_Init ();
#ifdef FORCE_WII
isWii = TRUE;
#else
int drvid = dvd_driveid ();
if ( drvid == 4 || drvid == 6 || drvid == 8 )
isWii = FALSE;
else
isWii = TRUE;
#endif
#ifdef HW_RVL
WPAD_Init(); WPAD_Init();
// read wiimote accelerometer and IR data // read wiimote accelerometer and IR data
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR); WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
WPAD_SetVRes(WPAD_CHAN_ALL,640,480); WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
#endif #endif
/*** Initialise GC ***/
InitGCVideo (); /*** Get the ball rolling ***/
/*** Initialise freetype ***/ /*** Initialise freetype ***/
if (FT_Init ()) if (FT_Init ())
@ -868,18 +852,20 @@ main ()
while (1); while (1);
} }
unpackbackdrop ();
/*** Set defaults ***/ /*** Set defaults ***/
DefaultSettings (); DefaultSettings ();
S9xUnmapAllControls (); S9xUnmapAllControls ();
SetDefaultButtonMap (); SetDefaultButtonMap ();
printf ("Initialise Memory\n"); //printf ("Initialise Memory\n");
/*** Allocate SNES Memory ***/ /*** Allocate SNES Memory ***/
if (!Memory.Init ()) if (!Memory.Init ())
while (1); while (1);
printf ("Initialise APU\n"); //printf ("Initialise APU\n");
/*** Allocate APU ***/ /*** Allocate APU ***/
if (!S9xInitAPU ()) if (!S9xInitAPU ())
while (1); while (1);
@ -890,16 +876,32 @@ main ()
/*** Initialise Snes Sound System ***/ /*** Initialise Snes Sound System ***/
S9xInitSound (5, TRUE, 1024); S9xInitSound (5, TRUE, 1024);
printf ("Initialise GFX\n"); //printf ("Initialise GFX\n");
/*** Initialise Graphics ***/ /*** Initialise Graphics ***/
setGFX (); setGFX ();
if (!S9xGraphicsInit ()) if (!S9xGraphicsInit ())
while (1); while (1);
unpackbackdrop (); // Initialize libFAT for SD and USB
fatInitDefault();
//fatInit(8192, false);
//fat_enable_readahead_all();
// Initialize DVD subsystem
DVD_Init ();
#ifdef FORCE_WII
isWii = TRUE;
#else
int drvid = dvd_driveid ();
if ( drvid == 4 || drvid == 6 || drvid == 8 )
isWii = FALSE;
else
isWii = TRUE;
#endif
// Load preferences // Load preferences
if(!quickLoadPrefs(SILENT)) if(!LoadPrefs(GCSettings.SaveMethod, SILENT))
{ {
WaitPrompt((char*) "Preferences reset - check settings!"); WaitPrompt((char*) "Preferences reset - check settings!");
selectedMenu = 2; // change to preferences menu selectedMenu = 2; // change to preferences menu
@ -926,9 +928,6 @@ main ()
if (!Memory.LoadROM ("VIRTUAL.ROM")) if (!Memory.LoadROM ("VIRTUAL.ROM"))
while (1); while (1);
CPU.Flags = save_flags; CPU.Flags = save_flags;
/*** Load SRAM ***/
Memory.LoadSRAM ("DVD");
} }
/*** Emulate ***/ /*** Emulate ***/
@ -937,5 +936,4 @@ main ()
/*** NO! - We're never leaving here ! ***/ /*** NO! - We're never leaving here ! ***/
while (1); while (1);
return 0; return 0;
} }

View File

@ -211,33 +211,4 @@ END_EXTERN_C
#define JOY_THRESHOLD 0.70 // for wii (expansion) analogues #define JOY_THRESHOLD 0.70 // for wii (expansion) analogues
/*** default SMB settings ***/
#ifndef GC_IP
#define GC_IP "192.168.1.32" /*** IP to assign the GameCube ***/
#endif
#ifndef GW_IP
#define GW_IP "192.168.1.100" /*** Your gateway IP ***/
#endif
#ifndef MASK
#define MASK "255.255.255.0" /*** Your subnet mask ***/
#endif
#ifndef SMB_USER
#define SMB_USER "Guest" /*** Your share user ***/
#endif
#ifndef SMB_PWD
#define SMB_PWD "password" /*** Your share user password ***/
#endif
#ifndef SMB_GCID
#define SMB_GCID "gamecube" /*** Machine Name of GameCube ***/
#endif
#ifndef SMB_SVID
#define SMB_SVID "mypc" /*** Machine Name of Server(Share) ***/
#endif
#ifndef SMB_SHARE
#define SMB_SHARE "gcshare" /*** Share name on server ***/
#endif
#ifndef SMB_IP
#define SMB_IP "192.168.1.100" /*** IP Address of share server ***/
#endif
#endif #endif

View File

@ -14,13 +14,14 @@
#include <ogcsys.h> #include <ogcsys.h>
#include "snes9x.h" #include "snes9x.h"
#include "snes9xGx.h"
#include "memmap.h" #include "memmap.h"
#include "srtc.h" #include "srtc.h"
#include "snes9xGx.h"
#include "menudraw.h" #include "menudraw.h"
#include "mcsave.h" #include "mcsave.h"
#include "fileop.h" #include "fileop.h"
#include "smbload.h" #include "smbop.h"
#include "filesel.h" #include "filesel.h"
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
@ -235,28 +236,24 @@ decodesavedata (int readsize)
/**************************************************************************** /****************************************************************************
* Load SRAM * Load SRAM
****************************************************************************/ ****************************************************************************/
bool int
LoadSRAM (int method, bool silent) LoadSRAM (int method, bool silent)
{ {
if(method == METHOD_AUTO) if(method == METHOD_AUTO)
method = autoLoadMethod(); method = autoLoadMethod();
bool retval = false;
char filepath[1024]; char filepath[1024];
int offset = 0; int offset = 0;
if(!silent)
ShowAction ((char*) "Loading SRAM...");
if(method == METHOD_SD || method == METHOD_USB) if(method == METHOD_SD || method == METHOD_USB)
{ {
changeFATInterface(method); changeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
offset = LoadBufferFromFAT (filepath, silent); offset = LoadBufferFromFAT (filepath, silent);
} }
else if(method == METHOD_SMB) else if(method == METHOD_SMB)
{ {
sprintf (filepath, "%s\\%s.srm", GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filepath, "%s/%s.srm", GCSettings.SaveFolder, Memory.ROMFilename);
offset = LoadBufferFromSMB (filepath, silent); offset = LoadBufferFromSMB (filepath, silent);
} }
else if(method == METHOD_MC_SLOTA) else if(method == METHOD_MC_SLOTA)
@ -273,15 +270,15 @@ LoadSRAM (int method, bool silent)
if (offset > 0) if (offset > 0)
{ {
decodesavedata (offset); decodesavedata (offset);
if ( !silent )
{
sprintf (filepath, "Loaded %d bytes", offset);
WaitPrompt(filepath);
}
S9xSoftReset(); S9xSoftReset();
retval = true;
return 1;
} }
return retval;
if(!silent)
WaitPrompt ((char*) "SRAM file not found");
return 0;
} }
/**************************************************************************** /****************************************************************************
@ -310,13 +307,13 @@ SaveSRAM (int method, bool silent)
{ {
if(method == METHOD_SD || method == METHOD_USB) if(method == METHOD_SD || method == METHOD_USB)
{ {
changeFATInterface(method); changeFATInterface(method, NOTSILENT);
sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
offset = SaveBufferToFAT (filepath, datasize, silent); offset = SaveBufferToFAT (filepath, datasize, silent);
} }
else if(method == METHOD_SMB) else if(method == METHOD_SMB)
{ {
sprintf (filepath, "%s\\%s.srm", GCSettings.SaveFolder, Memory.ROMFilename); sprintf (filepath, "%s/%s.srm", GCSettings.SaveFolder, Memory.ROMFilename);
offset = SaveBufferToSMB (filepath, datasize, silent); offset = SaveBufferToSMB (filepath, datasize, silent);
} }
else if(method == METHOD_MC_SLOTA) else if(method == METHOD_MC_SLOTA)
@ -342,21 +339,3 @@ SaveSRAM (int method, bool silent)
} }
return retval; return retval;
} }
/****************************************************************************
* Quick Load SRAM
****************************************************************************/
bool quickLoadSRAM (bool silent)
{
return LoadSRAM(GCSettings.SaveMethod, silent);
}
/****************************************************************************
* Quick Save SRAM
****************************************************************************/
bool quickSaveSRAM (bool silent)
{
return SaveSRAM(GCSettings.SaveMethod, silent);
}

View File

@ -9,11 +9,5 @@
* SRAM save/load/import/export handling * SRAM save/load/import/export handling
****************************************************************************/ ****************************************************************************/
int prepareMCsavedata ();
int prepareEXPORTsavedata ();
void decodesavedata (int readsize);
bool SaveSRAM (int method, bool silent); bool SaveSRAM (int method, bool silent);
bool LoadSRAM (int method, bool silent); int LoadSRAM (int method, bool silent);
bool quickLoadSRAM (bool silent);
bool quickSaveSRAM (bool silent);

View File

@ -162,7 +162,7 @@ copy_to_xfb (u32 arg)
} }
FrameTimer++; FrameTimer++;
SMBTimer++; //SMBTimer++;
} }