mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-01 00:15:14 +01:00
rewrite of smb code, partially working on Wii
misc bug fixes function cleanup
This commit is contained in:
parent
7cb0371b38
commit
6ff361a2cd
@ -13,6 +13,7 @@
|
||||
#include "memmap.h"
|
||||
#include "fileop.h"
|
||||
#include "cheats.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern SCheatData Cheat;
|
||||
|
||||
@ -30,9 +31,14 @@ SetupCheats()
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Port
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* softdev July 2006
|
||||
* crunchy2 May 2007
|
||||
* Tantric August 2008
|
||||
*
|
||||
* fileop.cpp
|
||||
*
|
||||
@ -13,9 +14,11 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ogcsys.h>
|
||||
#include <zlib.h>
|
||||
#include "memmap.h"
|
||||
|
||||
#include "fileop.h"
|
||||
#include "unzip.h"
|
||||
#include "memmap.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "dvd.h"
|
||||
@ -24,15 +27,13 @@
|
||||
#include "preferences.h"
|
||||
#include "snes9xGx.h"
|
||||
|
||||
#include <zlib.h>
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
FILE * filehandle;
|
||||
|
||||
char currFATdir[MAXPATHLEN];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
|
||||
extern char currentdir[MAXPATHLEN];
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
/****************************************************************************
|
||||
@ -56,7 +57,7 @@ bool fat_is_mounted(PARTITION_INTERFACE partition) {
|
||||
* Checks if the device (method) specified is available, and
|
||||
* sets libfat to use the device
|
||||
****************************************************************************/
|
||||
bool changeFATInterface(int method)
|
||||
bool changeFATInterface(int method, bool silent)
|
||||
{
|
||||
bool devFound = false;
|
||||
|
||||
@ -82,6 +83,11 @@ bool changeFATInterface(int method)
|
||||
devFound = true;
|
||||
fatSetDefaultInterface(PI_SDGECKO_B);
|
||||
}
|
||||
if(!devFound)
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt ((char *)"SD card not found!");
|
||||
}
|
||||
}
|
||||
else if(method == METHOD_USB)
|
||||
{
|
||||
@ -91,6 +97,11 @@ bool changeFATInterface(int method)
|
||||
devFound = true;
|
||||
fatSetDefaultInterface(PI_USBSTORAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt ((char *)"USB flash drive not found!");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -137,208 +148,123 @@ 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
|
||||
***************************************************************************/
|
||||
int parseFATdirectory(int method)
|
||||
int
|
||||
parseFATdirectory(int method)
|
||||
{
|
||||
int nbfiles = 0;
|
||||
DIR_ITER *fatdir;
|
||||
char filename[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
char msg[128];
|
||||
int nbfiles = 0;
|
||||
DIR_ITER *fatdir;
|
||||
char filename[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
char msg[128];
|
||||
|
||||
/* initialize selection */
|
||||
selection = offset = 0;
|
||||
// initialize selection
|
||||
selection = offset = 0;
|
||||
|
||||
/* open the directory */
|
||||
fatdir = diropen(currFATdir);
|
||||
if (fatdir == NULL)
|
||||
// open the directory
|
||||
fatdir = diropen(currentdir);
|
||||
if (fatdir == NULL)
|
||||
{
|
||||
sprintf(msg, "Couldn't find %s", currFATdir);
|
||||
WaitPrompt(msg);
|
||||
sprintf(msg, "Couldn't open %s", currentdir);
|
||||
WaitPrompt(msg);
|
||||
|
||||
// if we can't open the previous dir, open root dir
|
||||
sprintf(currFATdir,"%s",ROOTFATDIR);
|
||||
// if we can't open the dir, open root dir
|
||||
sprintf(currentdir,"%s",ROOTFATDIR);
|
||||
|
||||
fatdir = diropen(currFATdir);
|
||||
fatdir = diropen(currentdir);
|
||||
|
||||
if (fatdir == NULL)
|
||||
if (fatdir == NULL)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", currFATdir);
|
||||
WaitPrompt(msg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Move to DVD structure - this is required for the file selector */
|
||||
while(dirnext(fatdir,filename,&filestat) == 0) {
|
||||
if(strcmp(filename,".") != 0) {
|
||||
memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES));
|
||||
strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN);
|
||||
strncpy(filelist[nbfiles].displayname, filename, MAXDISPLAY+1); // crop name for display
|
||||
filelist[nbfiles].length = filestat.st_size;
|
||||
filelist[nbfiles].flags = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1;
|
||||
nbfiles++;
|
||||
}
|
||||
sprintf(msg, "Error opening %s", currentdir);
|
||||
WaitPrompt(msg);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*** close directory ***/
|
||||
dirclose(fatdir);
|
||||
// index files/folders
|
||||
while(dirnext(fatdir,filename,&filestat) == 0)
|
||||
{
|
||||
if(strcmp(filename,".") != 0)
|
||||
{
|
||||
memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES));
|
||||
strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN);
|
||||
strncpy(filelist[nbfiles].displayname, filename, MAXDISPLAY+1); // crop name for display
|
||||
filelist[nbfiles].length = filestat.st_size;
|
||||
filelist[nbfiles].flags = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
nbfiles++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort the file list */
|
||||
// close directory
|
||||
dirclose(fatdir);
|
||||
|
||||
// Sort the file list
|
||||
qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback);
|
||||
|
||||
return nbfiles;
|
||||
return nbfiles;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* LoadFATFile
|
||||
****************************************************************************/
|
||||
extern int haveFATdir;
|
||||
int
|
||||
LoadFATFile (char *filename, int length)
|
||||
{
|
||||
char zipbuffer[2048];
|
||||
char filepath[MAXPATHLEN];
|
||||
FILE *handle;
|
||||
unsigned char *rbuffer;
|
||||
u32 size;
|
||||
char zipbuffer[2048];
|
||||
char filepath[MAXPATHLEN];
|
||||
FILE *handle;
|
||||
unsigned char *rbuffer;
|
||||
u32 size;
|
||||
|
||||
rbuffer = (unsigned char *) Memory.ROM;
|
||||
rbuffer = (unsigned char *) Memory.ROM;
|
||||
|
||||
/* Check filename length */
|
||||
if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
sprintf(filepath, "%s/%s",currFATdir,filelist[selection].filename);
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Maximum Filename Length reached !");
|
||||
haveFATdir = 0; // reset everything before next access
|
||||
return -1;
|
||||
}
|
||||
/* Check filename length */
|
||||
if ((strlen(currentdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
sprintf(filepath, "%s/%s",currentdir,filelist[selection].filename);
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Maximum Filename Length reached !");
|
||||
return -1;
|
||||
}
|
||||
|
||||
handle = fopen (filepath, "rb");
|
||||
if (handle > 0)
|
||||
{
|
||||
fread (zipbuffer, 1, 2048, handle);
|
||||
handle = fopen (filepath, "rb");
|
||||
if (handle > 0)
|
||||
{
|
||||
fread (zipbuffer, 1, 2048, handle);
|
||||
|
||||
if (IsZipFile (zipbuffer))
|
||||
if (IsZipFile (zipbuffer))
|
||||
{
|
||||
/*** Unzip the ROM ***/
|
||||
size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from FAT
|
||||
|
||||
fclose (handle);
|
||||
return size;
|
||||
size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from FAT
|
||||
|
||||
fclose (handle);
|
||||
return size;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
/*** Just load the file up ***/
|
||||
/*** Just load the file up ***/
|
||||
|
||||
fseek(handle, 0, SEEK_END);
|
||||
length = ftell(handle); // get filesize
|
||||
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
|
||||
fseek(handle, 0, SEEK_END);
|
||||
length = ftell(handle); // get filesize
|
||||
fseek(handle, 2048, SEEK_SET); // seek back to point where we left off
|
||||
|
||||
sprintf (filepath, "Loading %d bytes", length);
|
||||
ShowAction (filepath);
|
||||
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
|
||||
fread (rbuffer + 2048, 1, length - 2048, handle);
|
||||
fclose (handle);
|
||||
ShowAction ((char *)"Loading...");
|
||||
memcpy (rbuffer, zipbuffer, 2048); // copy what we already read
|
||||
fread (rbuffer + 2048, 1, length - 2048, handle);
|
||||
fclose (handle);
|
||||
|
||||
return length;
|
||||
return length;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Error opening file");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Error opening file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -25,9 +25,7 @@
|
||||
|
||||
bool fat_remount(PARTITION_INTERFACE partition);
|
||||
bool fat_is_mounted(PARTITION_INTERFACE partition);
|
||||
bool changeFATInterface(int method);
|
||||
static int FileSortCallback(const void *f1, const void *f2);
|
||||
int updateFATdirname(int method);
|
||||
bool changeFATInterface(int method, bool silent);
|
||||
int parseFATdirectory(int method);
|
||||
int LoadFATFile (char *filename, int length);
|
||||
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
|
||||
|
@ -1,31 +1,25 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Filesel - borrowed from GPP
|
||||
*
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* softdev July 2006
|
||||
* svpe June 2007
|
||||
* crunchy2 May-July 2007
|
||||
* Tantric August 2008
|
||||
*
|
||||
* filesel.cpp
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
****************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include <sys/dir.h>
|
||||
|
||||
#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"
|
||||
@ -34,20 +28,21 @@
|
||||
#include "aram.h"
|
||||
#include "unzip.h"
|
||||
#include "filesel.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
#include "fileop.h"
|
||||
#include "mcsave.h"
|
||||
|
||||
#define PAGESIZE 17
|
||||
int offset;
|
||||
int selection;
|
||||
char currentdir[MAXPATHLEN];
|
||||
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 FILEENTRIES filelist[MAXFILES];
|
||||
#define PAGESIZE 17
|
||||
int LoadDVDFile (unsigned char *buffer);
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
int havedir = 0;
|
||||
int hasloaded = 0;
|
||||
|
||||
/****************************************************************************
|
||||
* autoLoadMethod()
|
||||
@ -56,10 +51,12 @@ extern FILEENTRIES filelist[MAXFILES];
|
||||
****************************************************************************/
|
||||
int autoLoadMethod()
|
||||
{
|
||||
if(changeFATInterface(METHOD_SD))
|
||||
if(changeFATInterface(METHOD_SD, SILENT))
|
||||
return METHOD_SD;
|
||||
else if(changeFATInterface(METHOD_USB))
|
||||
else if(changeFATInterface(METHOD_USB, SILENT))
|
||||
return METHOD_USB;
|
||||
//else if(ConnectShare ())
|
||||
// return METHOD_SMB;
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Unable to auto-determine load method!");
|
||||
@ -74,14 +71,16 @@ int autoLoadMethod()
|
||||
****************************************************************************/
|
||||
int autoSaveMethod()
|
||||
{
|
||||
if(changeFATInterface(METHOD_SD))
|
||||
if(changeFATInterface(METHOD_SD, SILENT))
|
||||
return METHOD_SD;
|
||||
else if(changeFATInterface(METHOD_USB))
|
||||
else if(changeFATInterface(METHOD_USB, SILENT))
|
||||
return METHOD_USB;
|
||||
else if(TestCard(CARD_SLOTA, SILENT))
|
||||
return METHOD_MC_SLOTA;
|
||||
else if(TestCard(CARD_SLOTB, SILENT))
|
||||
return METHOD_MC_SLOTB;
|
||||
//else if(ConnectShare ())
|
||||
// return METHOD_SMB;
|
||||
else
|
||||
{
|
||||
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
|
||||
*
|
||||
@ -191,8 +267,6 @@ int SNESROMSOffset()
|
||||
*
|
||||
* Let user select a file from the listing
|
||||
****************************************************************************/
|
||||
int offset = 0;
|
||||
int selection = 0;
|
||||
|
||||
#define PADCAL 40
|
||||
int
|
||||
@ -232,39 +306,39 @@ FileSelector (int method)
|
||||
c = PAD_SubStickX (0);
|
||||
|
||||
/*** 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 ***/
|
||||
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
|
||||
{
|
||||
if ( selectit )
|
||||
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 */
|
||||
int status = updateFATdirname(method);
|
||||
if (status == 1) // ok, open directory
|
||||
int status = UpdateDirName();
|
||||
if (status == 1) // ok, open directory
|
||||
{
|
||||
maxfiles = parseFATdirectory(method);
|
||||
if(method == METHOD_SMB)
|
||||
maxfiles = parseSMBdirectory();
|
||||
else
|
||||
maxfiles = parseFATdirectory(method);
|
||||
|
||||
if (!maxfiles)
|
||||
{
|
||||
WaitPrompt ((char*) "Error reading directory !");
|
||||
haverom = 1; // quit FAT menu
|
||||
haveFATdir = 0; // reset everything at next access
|
||||
haverom = 1; // quit menu
|
||||
}
|
||||
}
|
||||
else if (status == -1) // directory name too long
|
||||
{
|
||||
haverom = 1; // quit FAT menu
|
||||
haveFATdir = 0; // reset everything at next access
|
||||
haverom = 1; // quit menu
|
||||
}
|
||||
}
|
||||
else
|
||||
else if(method == METHOD_DVD)
|
||||
{
|
||||
if ( (strcmp (filelist[selection].filename, "..") == 0)
|
||||
&& ((unsigned int)rootdir == filelist[selection].offset) )
|
||||
@ -290,9 +364,7 @@ FileSelector (int method)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
/*** Load from FAT ***/
|
||||
/* memorize last entries list, actual root directory and selection for next access */
|
||||
haveFATdir = 1;
|
||||
// Load from FAT
|
||||
ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename,
|
||||
filelist[selection].length);
|
||||
break;
|
||||
@ -441,7 +513,7 @@ OpenDVD (int method)
|
||||
|
||||
if (!getpvd())
|
||||
{
|
||||
ShowAction((char*) "Mounting DVD ... Wait");
|
||||
ShowAction((char*) "Loading DVD...");
|
||||
DVD_Mount(); /* mount the DVD unit again */
|
||||
havedir = 0; /* this may be a new DVD: content need to be parsed again */
|
||||
if (!getpvd())
|
||||
@ -451,7 +523,6 @@ OpenDVD (int method)
|
||||
if (havedir == 0)
|
||||
{
|
||||
offset = selection = 0; /* reset file selector */
|
||||
haveFATdir = 0; /* prevent conflicts with FAT file selector */
|
||||
|
||||
if ((maxfiles = parsedirectory ()))
|
||||
{
|
||||
@ -483,14 +554,24 @@ OpenDVD (int method)
|
||||
int
|
||||
OpenSMB (int method)
|
||||
{
|
||||
if ((maxfiles = parseSMBDirectory ()))
|
||||
{
|
||||
char txt[80];
|
||||
sprintf(txt,"maxfiles = %d", maxfiles);
|
||||
// Connect to network share
|
||||
if(ConnectShare ())
|
||||
{
|
||||
// change current dir to root dir
|
||||
sprintf(currentdir, GCSettings.LoadFolder);
|
||||
|
||||
return FileSelector (method);
|
||||
}
|
||||
return 0;
|
||||
if (maxfiles = parseSMBdirectory ())
|
||||
{
|
||||
return FileSelector (method);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no entries found
|
||||
WaitPrompt ((char *)"No Files Found!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -501,35 +582,24 @@ OpenSMB (int method)
|
||||
int
|
||||
OpenFAT (int method)
|
||||
{
|
||||
char msg[80];
|
||||
|
||||
//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)))
|
||||
if(changeFATInterface(method, NOTSILENT))
|
||||
{
|
||||
/* Select an entry */
|
||||
return FileSelector (method);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* no entries found */
|
||||
sprintf (msg, "No Files Found!");
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
//}
|
||||
/* Retrieve previous entries list and made a new selection */
|
||||
//else
|
||||
// return FileSelector (method);
|
||||
// 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no entries found
|
||||
WaitPrompt ((char *)"No Files Found!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -591,7 +661,7 @@ LoadDVDFile (unsigned char *buffer)
|
||||
blocks = rootdirlength / 2048;
|
||||
offset = 0;
|
||||
discoffset = rootdir;
|
||||
ShowAction ((char*) "Loading ... Wait");
|
||||
ShowAction ((char*) "Loading...");
|
||||
dvd_read (readbuffer, 2048, discoffset);
|
||||
|
||||
if (!IsZipFile (readbuffer))
|
||||
|
@ -13,5 +13,6 @@
|
||||
int OpenROM (int method);
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod();
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
|
||||
#endif
|
||||
|
@ -19,25 +19,20 @@
|
||||
#include <fat.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "memfile.h"
|
||||
#include "snes9x.h"
|
||||
#include "memmap.h"
|
||||
#include "soundux.h"
|
||||
#include "snapshot.h"
|
||||
#include "srtc.h"
|
||||
|
||||
#include "memfile.h"
|
||||
#include "Snes9xGx.h"
|
||||
#include "filesel.h"
|
||||
#include "menudraw.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
#include "fileop.h"
|
||||
#include "mcsave.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "smb.h"
|
||||
}
|
||||
|
||||
#define MEMBUFFER (512 * 1024)
|
||||
|
||||
extern void S9xSRTCPreSaveState ();
|
||||
@ -138,16 +133,15 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
method = autoSaveMethod();
|
||||
|
||||
char filename[1024];
|
||||
SMBFILE smbfile;
|
||||
//SMBFILE smbfile;
|
||||
FILE *handle;
|
||||
int len = 0;
|
||||
int wrote = 0;
|
||||
int offset = 0;
|
||||
|
||||
char msg[100];
|
||||
|
||||
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);
|
||||
}
|
||||
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
|
||||
{
|
||||
changeFATInterface(GCSettings.SaveMethod);
|
||||
changeFATInterface(GCSettings.SaveMethod, NOTSILENT);
|
||||
sprintf(msg, "Couldn't save to %s/%s/", ROOTFATDIR, GCSettings.SaveFolder);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
@ -246,10 +240,8 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
}
|
||||
else if (method == METHOD_SMB) // SMB
|
||||
{
|
||||
ConnectSMB ();
|
||||
|
||||
smbfile = SMB_Open (filename, SMB_OPEN_WRITING | SMB_DENY_NONE,
|
||||
SMB_OF_CREATE | SMB_OF_TRUNCATE);
|
||||
/*
|
||||
smbfile = SMB_OpenFile (filename, SMB_OPEN_WRITING, SMB_OF_CREATE | SMB_OF_TRUNCATE);
|
||||
|
||||
if (smbfile)
|
||||
{
|
||||
@ -273,7 +265,7 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
len -= wrote;
|
||||
}
|
||||
|
||||
SMB_Close (smbfile);
|
||||
SMB_CloseFile (smbfile);
|
||||
|
||||
if ( !silent )
|
||||
{
|
||||
@ -287,6 +279,7 @@ NGCFreezeGame (int method, bool8 silent)
|
||||
sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
*/
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -335,7 +328,7 @@ int
|
||||
NGCUnfreezeGame (int method, bool8 silent)
|
||||
{
|
||||
char filename[1024];
|
||||
SMBFILE smbfile;
|
||||
//SMBFILE smbfile;
|
||||
FILE *handle;
|
||||
int read = 0;
|
||||
int offset = 0;
|
||||
@ -348,7 +341,7 @@ NGCUnfreezeGame (int method, bool8 silent)
|
||||
|
||||
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);
|
||||
|
||||
handle = fopen (filename, "rb");
|
||||
@ -373,13 +366,11 @@ NGCUnfreezeGame (int method, bool8 silent)
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
return 0;
|
||||
}
|
||||
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
|
||||
@ -436,27 +427,24 @@ NGCUnfreezeGame (int method, bool8 silent)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
WaitPrompt((char*) "Freeze file not found");
|
||||
return 0;
|
||||
}
|
||||
else if (method == METHOD_SMB) // Network (SMB)
|
||||
{
|
||||
sprintf (filename, "\\%s\\%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
ConnectSMB ();
|
||||
sprintf (filename, "%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
|
||||
/*** Read the file into memory ***/
|
||||
smbfile =
|
||||
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
||||
// Read the file into memory
|
||||
/*smbfile =
|
||||
SMB_OpenFile (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
||||
|
||||
if (smbfile)
|
||||
{
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
while ((read =
|
||||
SMB_Read ((char *) membuffer + offset, 1024, offset,
|
||||
SMB_ReadFile ((char *) membuffer + offset, 1024, offset,
|
||||
smbfile)) > 0)
|
||||
offset += read;
|
||||
|
||||
@ -472,22 +460,10 @@ NGCUnfreezeGame (int method, bool8 silent)
|
||||
}
|
||||
else if ( !silent )
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
WaitPrompt((char*) "Freeze file not found");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
return 1;*/
|
||||
}
|
||||
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 );
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
* There's just enough here to do SnapShots - you should add anything else you
|
||||
* need.
|
||||
****************************************************************************/
|
||||
#include "snes9x.h"
|
||||
|
||||
#ifndef _NGCMEMFILE_
|
||||
#define _NGCMEMFILE_
|
||||
@ -28,7 +27,4 @@ MEMFILE;
|
||||
int NGCFreezeGame (int method, bool8 silent);
|
||||
int NGCUnfreezeGame (int method, bool8 silent);
|
||||
|
||||
void quickLoadFreeze (bool8 silent);
|
||||
void quickSaveFreeze (bool8 silent);
|
||||
|
||||
#endif
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "snes9xGx.h"
|
||||
#include "memmap.h"
|
||||
#include "debug.h"
|
||||
#include "cpuexec.h"
|
||||
@ -25,12 +25,15 @@
|
||||
#include "spc700.h"
|
||||
#include "spc7110.h"
|
||||
#include "controls.h"
|
||||
#include "cheats.h"
|
||||
|
||||
#include "snes9xGx.h"
|
||||
#include "aram.h"
|
||||
#include "video.h"
|
||||
#include "mcsave.h"
|
||||
#include "filesel.h"
|
||||
#include "unzip.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
#include "mcsave.h"
|
||||
#include "fileop.h"
|
||||
#include "memfile.h"
|
||||
@ -38,10 +41,8 @@
|
||||
#include "s9xconfig.h"
|
||||
#include "sram.h"
|
||||
#include "preferences.h"
|
||||
|
||||
#include "button_mapping.h"
|
||||
#include "menudraw.h"
|
||||
#include "cheats.h"
|
||||
#include "cheatmgr.h"
|
||||
|
||||
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 ( GCSettings.AutoLoad == 1 )
|
||||
quickLoadSRAM ( SILENT );
|
||||
LoadSRAM(GCSettings.SaveMethod, SILENT);
|
||||
else if ( GCSettings.AutoLoad == 2 )
|
||||
quickLoadFreeze ( SILENT );
|
||||
NGCUnfreezeGame (GCSettings.SaveMethod, SILENT);
|
||||
|
||||
// setup cheats
|
||||
SetupCheats();
|
||||
@ -266,7 +267,7 @@ PreferencesMenu ()
|
||||
break;
|
||||
|
||||
case 13:
|
||||
quickSavePrefs(NOTSILENT);
|
||||
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
||||
break;
|
||||
|
||||
case -1: /*** Button B ***/
|
||||
@ -367,7 +368,7 @@ GameMenu ()
|
||||
break;
|
||||
|
||||
case 4: // Load SRAM
|
||||
LoadSRAM(GCSettings.SaveMethod, NOTSILENT);
|
||||
quit = retval = LoadSRAM(GCSettings.SaveMethod, SILENT);
|
||||
break;
|
||||
|
||||
case 5: // Save SRAM
|
||||
@ -707,7 +708,7 @@ ConfigureControllers ()
|
||||
|
||||
case 8:
|
||||
/*** Save Preferences Now ***/
|
||||
quickSavePrefs(NOTSILENT);
|
||||
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
||||
break;
|
||||
|
||||
case -1: /*** Button B ***/
|
||||
|
@ -366,35 +366,36 @@ getcolour (u8 r1, u8 g1, u8 b1)
|
||||
void
|
||||
unpackbackdrop ()
|
||||
{
|
||||
unsigned long res, inbytes, outbytes;
|
||||
unsigned int colour;
|
||||
int offset;
|
||||
int i;
|
||||
unsigned long res, inbytes, outbytes;
|
||||
unsigned int colour;
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
// backdrop = (unsigned int *) malloc (screenheight * 1280);
|
||||
backdrop = (u32 *) malloc (screenheight * 1280);
|
||||
colour = getcolour (0x00, 0x00, 0x00);
|
||||
// backdrop = (unsigned int *) malloc (screenheight * 1280);
|
||||
backdrop = (u32 *) malloc (screenheight * 1280);
|
||||
colour = getcolour (0x00, 0x00, 0x00);
|
||||
|
||||
/*** Fill with black for now ***/
|
||||
for (i = 0; i < (320 * screenheight); i++)
|
||||
backdrop[i] = colour;
|
||||
for (i = 0; i < (320 * screenheight); i++)
|
||||
backdrop[i] = colour;
|
||||
|
||||
/*** If it's PAL50, need to move down a few lines ***/
|
||||
offset = ((screenheight - 480) >> 1) * 320;
|
||||
inbytes = BG_COMPRESSED;
|
||||
outbytes = BG_RAW;
|
||||
/*** If it's PAL50, need to move down a few lines ***/
|
||||
offset = ((screenheight - 480) >> 1) * 320;
|
||||
inbytes = BG_COMPRESSED;
|
||||
outbytes = BG_RAW;
|
||||
|
||||
res =
|
||||
uncompress ((Bytef *) backdrop + offset, &outbytes, (Bytef *) bg,
|
||||
inbytes);
|
||||
res =
|
||||
uncompress ((Bytef *) backdrop + offset, &outbytes, (Bytef *) bg,
|
||||
inbytes);
|
||||
|
||||
#ifndef HW_RVL
|
||||
/*** Now store the backdrop in ARAM ***/
|
||||
ARAMPut ((char *) backdrop, (char *) AR_BACKDROP, 640 * screenheight * 2);
|
||||
free (backdrop);
|
||||
#endif
|
||||
#ifndef HW_RVL
|
||||
/*** Now store the backdrop in ARAM ***/
|
||||
ARAMPut ((char *) backdrop, (char *) AR_BACKDROP, 640 * screenheight * 2);
|
||||
free (backdrop);
|
||||
#endif
|
||||
// otherwise (on wii) backdrop is stored in memory
|
||||
|
||||
clearscreen ();
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -457,19 +458,19 @@ WaitButtonAB ()
|
||||
void
|
||||
WaitPrompt (char *msg)
|
||||
{
|
||||
int ypos = (screenheight - 64) >> 1;
|
||||
int ypos = (screenheight - 64) >> 1;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
ypos += 30;
|
||||
DrawText (-1, ypos, (char*)"Press A to continue");
|
||||
showscreen ();
|
||||
WaitButtonA ();
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
ypos += 30;
|
||||
DrawText (-1, ypos, (char*)"Press A to continue");
|
||||
showscreen ();
|
||||
WaitButtonA ();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -479,21 +480,21 @@ WaitPrompt (char *msg)
|
||||
int
|
||||
WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
||||
{
|
||||
int ypos = (screenheight - 64) >> 1;
|
||||
int ypos = (screenheight - 64) >> 1;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 37;
|
||||
else
|
||||
ypos += 17;
|
||||
if (screenheight == 480)
|
||||
ypos += 37;
|
||||
else
|
||||
ypos += 17;
|
||||
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
ypos += 60;
|
||||
char txt[80];
|
||||
sprintf (txt, "B = %s : A = %s", bmsg, amsg);
|
||||
DrawText (-1, ypos, txt);
|
||||
showscreen ();
|
||||
return WaitButtonAB ();
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
ypos += 60;
|
||||
char txt[80];
|
||||
sprintf (txt, "B = %s : A = %s", bmsg, amsg);
|
||||
DrawText (-1, ypos, txt);
|
||||
showscreen ();
|
||||
return WaitButtonAB ();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -502,16 +503,16 @@ WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
||||
void
|
||||
ShowAction (char *msg)
|
||||
{
|
||||
int ypos = (screenheight - 30) >> 1;
|
||||
int ypos = (screenheight - 30) >> 1;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
showscreen ();
|
||||
clearscreen ();
|
||||
DrawText (-1, ypos, msg);
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -548,7 +549,7 @@ DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsiz
|
||||
// Draw menu items
|
||||
|
||||
setfontsize (fontsize); // set font size
|
||||
|
||||
|
||||
line_height = (fontsize + 8);
|
||||
|
||||
for (i = 0; i < maxitems; i++)
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "menudraw.h"
|
||||
#include "mcsave.h"
|
||||
#include "fileop.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
@ -139,13 +139,13 @@ SavePrefs (int method, bool silent)
|
||||
|
||||
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);
|
||||
offset = SaveBufferToFAT (filepath, datasize, silent);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
@ -187,13 +187,13 @@ LoadPrefs (int method, bool silent)
|
||||
|
||||
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);
|
||||
offset = LoadBufferFromFAT (filepath, silent);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
@ -216,21 +216,3 @@ LoadPrefs (int method, bool silent)
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -9,9 +9,5 @@
|
||||
* Preferences save/load preferences utilities
|
||||
****************************************************************************/
|
||||
|
||||
int preparePrefsData ();
|
||||
bool decodePrefsData ();
|
||||
bool SavePrefs (int method, bool silent);
|
||||
bool LoadPrefs (int method, bool silent);
|
||||
bool quickLoadPrefs (bool8 silent);
|
||||
bool quickSavePrefs (bool8 silent);
|
||||
|
@ -157,7 +157,7 @@
|
||||
#include <gccore.h>
|
||||
#include "snes9x.h"
|
||||
#include "snes9xGX.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
|
||||
void
|
||||
DefaultSettings ()
|
||||
@ -170,6 +170,18 @@ DefaultSettings ()
|
||||
GCSettings.AutoLoad = 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.gwip, GW_IP, 15);
|
||||
strncpy (GCSettings.mask, MASK, 15);
|
||||
@ -193,8 +205,8 @@ DefaultSettings ()
|
||||
memset (&Settings, 0, sizeof (Settings));
|
||||
|
||||
/*** General ***/
|
||||
|
||||
|
||||
|
||||
|
||||
Settings.MouseMaster = false;
|
||||
Settings.SuperScopeMaster = false;
|
||||
Settings.MultiPlayer5Master = false;
|
||||
|
@ -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
393
source/ngc/smbop.cpp
Normal 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;
|
||||
}
|
@ -1,38 +1,26 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Port
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* softdev July 2006
|
||||
* crunchy2 May 2007
|
||||
* Tantric August 2008
|
||||
*
|
||||
* smbload.cpp
|
||||
* smbop.h
|
||||
*
|
||||
* Load ROMS from a Network share.
|
||||
* SMB support routines
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _NGCSMB_
|
||||
|
||||
#define _NGCSMB_
|
||||
|
||||
void ConnectSMB ();
|
||||
int parseSMBDirectory ();
|
||||
bool InitializeNetwork(bool silent);
|
||||
bool ConnectShare ();
|
||||
int updateSMBdirname();
|
||||
int parseSMBdirectory ();
|
||||
int LoadSMBFile (char *filename, int length);
|
||||
int LoadBufferFromSMB (char *filepath, 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
|
@ -180,6 +180,7 @@
|
||||
|
||||
#include "snes9xGX.h"
|
||||
#include "dvd.h"
|
||||
#include "smbop.h"
|
||||
#include "video.h"
|
||||
#include "menudraw.h"
|
||||
#include "s9xconfig.h"
|
||||
@ -574,19 +575,19 @@ NGCReportButtons ()
|
||||
|
||||
if ( GCSettings.AutoSave == 1 )
|
||||
{
|
||||
quickSaveSRAM ( SILENT );
|
||||
SaveSRAM(GCSettings.SaveMethod, SILENT );
|
||||
}
|
||||
else if ( GCSettings.AutoSave == 2 )
|
||||
{
|
||||
if ( WaitPromptChoice ((char*)"Save Freeze State?", (char*)"Don't Save", (char*)"Save") )
|
||||
quickSaveFreeze ( SILENT );
|
||||
NGCFreezeGame ( GCSettings.SaveMethod, SILENT );
|
||||
}
|
||||
else if ( GCSettings.AutoSave == 3 )
|
||||
{
|
||||
if ( WaitPromptChoice ((char*)"Save SRAM and Freeze State?", (char*)"Don't Save", (char*)"Save") )
|
||||
{
|
||||
quickSaveSRAM ( SILENT );
|
||||
quickSaveFreeze ( SILENT );
|
||||
SaveSRAM(GCSettings.SaveMethod, SILENT );
|
||||
NGCFreezeGame ( GCSettings.SaveMethod, SILENT );
|
||||
}
|
||||
}
|
||||
|
||||
@ -644,34 +645,38 @@ u32 wpad_get_analogues(int pad, float* mag1, u16* ang1, float* mag2, u16* ang2)
|
||||
|
||||
void SetControllers ()
|
||||
{
|
||||
if (Settings.MultiPlayer5Master == true)
|
||||
{
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
|
||||
}
|
||||
else if (Settings.SuperScopeMaster == true)
|
||||
{
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_SUPERSCOPE, 1, 0, 0, 0);
|
||||
if (Settings.MultiPlayer5Master == true)
|
||||
{
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
|
||||
}
|
||||
else if (Settings.SuperScopeMaster == true)
|
||||
{
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_SUPERSCOPE, 1, 0, 0, 0);
|
||||
}
|
||||
else if (Settings.MouseMaster == true)
|
||||
{
|
||||
S9xSetController (0, CTL_MOUSE, 0, 0, 0, 0);
|
||||
if (GCSettings.Mouse == 2)
|
||||
S9xSetController (1, CTL_MOUSE, 1, 0, 0, 0);
|
||||
else
|
||||
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
|
||||
}
|
||||
else if (Settings.JustifierMaster == true)
|
||||
{
|
||||
S9xSetController(0, CTL_JUSTIFIER, 0, 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
|
||||
{
|
||||
// Plugin 2 Joypads by default
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
|
||||
}
|
||||
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);
|
||||
if (GCSettings.Mouse == 2) S9xSetController (1, CTL_MOUSE, 1, 0, 0, 0);
|
||||
else S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
|
||||
}
|
||||
else if (Settings.JustifierMaster == true)
|
||||
{
|
||||
S9xSetController(0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController(1, CTL_JUSTIFIER, (GCSettings.Justifier == 2), 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*** Plugin 2 Joypads by default ***/
|
||||
S9xSetController (0, CTL_JOYPAD, 0, 0, 0, 0);
|
||||
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -830,36 +835,15 @@ main ()
|
||||
unsigned int save_flags;
|
||||
int selectedMenu = -1;
|
||||
|
||||
/*** Initialise GC ***/
|
||||
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
|
||||
#ifdef HW_RVL
|
||||
WPAD_Init();
|
||||
// read wiimote accelerometer and IR data
|
||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*** Initialise GC ***/
|
||||
InitGCVideo (); /*** Get the ball rolling ***/
|
||||
|
||||
/*** Initialise freetype ***/
|
||||
if (FT_Init ())
|
||||
@ -868,18 +852,20 @@ main ()
|
||||
while (1);
|
||||
}
|
||||
|
||||
unpackbackdrop ();
|
||||
|
||||
/*** Set defaults ***/
|
||||
DefaultSettings ();
|
||||
|
||||
S9xUnmapAllControls ();
|
||||
SetDefaultButtonMap ();
|
||||
|
||||
printf ("Initialise Memory\n");
|
||||
//printf ("Initialise Memory\n");
|
||||
/*** Allocate SNES Memory ***/
|
||||
if (!Memory.Init ())
|
||||
while (1);
|
||||
|
||||
printf ("Initialise APU\n");
|
||||
//printf ("Initialise APU\n");
|
||||
/*** Allocate APU ***/
|
||||
if (!S9xInitAPU ())
|
||||
while (1);
|
||||
@ -890,16 +876,32 @@ main ()
|
||||
/*** Initialise Snes Sound System ***/
|
||||
S9xInitSound (5, TRUE, 1024);
|
||||
|
||||
printf ("Initialise GFX\n");
|
||||
//printf ("Initialise GFX\n");
|
||||
/*** Initialise Graphics ***/
|
||||
setGFX ();
|
||||
if (!S9xGraphicsInit ())
|
||||
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
|
||||
if(!quickLoadPrefs(SILENT))
|
||||
if(!LoadPrefs(GCSettings.SaveMethod, SILENT))
|
||||
{
|
||||
WaitPrompt((char*) "Preferences reset - check settings!");
|
||||
selectedMenu = 2; // change to preferences menu
|
||||
@ -926,9 +928,6 @@ main ()
|
||||
if (!Memory.LoadROM ("VIRTUAL.ROM"))
|
||||
while (1);
|
||||
CPU.Flags = save_flags;
|
||||
|
||||
/*** Load SRAM ***/
|
||||
Memory.LoadSRAM ("DVD");
|
||||
}
|
||||
|
||||
/*** Emulate ***/
|
||||
@ -936,6 +935,5 @@ main ()
|
||||
|
||||
/*** NO! - We're never leaving here ! ***/
|
||||
while (1);
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -177,27 +177,27 @@ enum {
|
||||
};
|
||||
|
||||
struct SGCSettings{
|
||||
uint8 AutoLoad;
|
||||
uint8 AutoSave;
|
||||
uint8 LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB)
|
||||
char LoadFolder[200]; // Path to game files
|
||||
uint8 SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB
|
||||
char SaveFolder[200]; // Path to save files
|
||||
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];
|
||||
bool8 NGCZoom;
|
||||
uint8 VerifySaves;
|
||||
uint8 AutoLoad;
|
||||
uint8 AutoSave;
|
||||
uint8 LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB)
|
||||
char LoadFolder[200]; // Path to game files
|
||||
uint8 SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB
|
||||
char SaveFolder[200]; // Path to save files
|
||||
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];
|
||||
bool8 NGCZoom;
|
||||
uint8 VerifySaves;
|
||||
u16 render; // 0 - original, 1 - no AA
|
||||
u16 Superscope;
|
||||
u16 Mouse;
|
||||
u16 Justifier;
|
||||
u16 Superscope;
|
||||
u16 Mouse;
|
||||
u16 Justifier;
|
||||
};
|
||||
|
||||
START_EXTERN_C
|
||||
@ -211,33 +211,4 @@ END_EXTERN_C
|
||||
|
||||
#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
|
||||
|
@ -14,13 +14,14 @@
|
||||
#include <ogcsys.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "snes9xGx.h"
|
||||
#include "memmap.h"
|
||||
#include "srtc.h"
|
||||
|
||||
#include "snes9xGx.h"
|
||||
#include "menudraw.h"
|
||||
#include "mcsave.h"
|
||||
#include "fileop.h"
|
||||
#include "smbload.h"
|
||||
#include "smbop.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
@ -235,28 +236,24 @@ decodesavedata (int readsize)
|
||||
/****************************************************************************
|
||||
* Load SRAM
|
||||
****************************************************************************/
|
||||
bool
|
||||
int
|
||||
LoadSRAM (int method, bool silent)
|
||||
{
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
|
||||
if(!silent)
|
||||
ShowAction ((char*) "Loading SRAM...");
|
||||
|
||||
if(method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
changeFATInterface(method);
|
||||
changeFATInterface(method, NOTSILENT);
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
offset = LoadBufferFromFAT (filepath, silent);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
@ -273,15 +270,15 @@ LoadSRAM (int method, bool silent)
|
||||
if (offset > 0)
|
||||
{
|
||||
decodesavedata (offset);
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
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)
|
||||
{
|
||||
changeFATInterface(method);
|
||||
changeFATInterface(method, NOTSILENT);
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTFATDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
offset = SaveBufferToFAT (filepath, datasize, silent);
|
||||
}
|
||||
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);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
@ -342,21 +339,3 @@ SaveSRAM (int method, bool silent)
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -9,11 +9,5 @@
|
||||
* SRAM save/load/import/export handling
|
||||
****************************************************************************/
|
||||
|
||||
int prepareMCsavedata ();
|
||||
int prepareEXPORTsavedata ();
|
||||
void decodesavedata (int readsize);
|
||||
|
||||
bool SaveSRAM (int method, bool silent);
|
||||
bool LoadSRAM (int method, bool silent);
|
||||
bool quickLoadSRAM (bool silent);
|
||||
bool quickSaveSRAM (bool silent);
|
||||
int LoadSRAM (int method, bool silent);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Video
|
||||
*
|
||||
@ -107,7 +107,7 @@ static unsigned char vbstack[TSTACK];
|
||||
* vbgetback
|
||||
*
|
||||
* This callback enables the emulator to keep running while waiting for a
|
||||
* vertical blank.
|
||||
* vertical blank.
|
||||
*
|
||||
* Putting LWP to good use :)
|
||||
****************************************************************************/
|
||||
@ -162,7 +162,7 @@ copy_to_xfb (u32 arg)
|
||||
}
|
||||
|
||||
FrameTimer++;
|
||||
SMBTimer++;
|
||||
//SMBTimer++;
|
||||
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ void UpdatePadsCB()
|
||||
#endif
|
||||
PAD_ScanPads();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* InitGCVideo
|
||||
*
|
||||
@ -290,20 +290,20 @@ InitGCVideo ()
|
||||
* Before doing anything else under libogc,
|
||||
* Call VIDEO_Init
|
||||
*/
|
||||
|
||||
|
||||
int *romptr = (int *) 0x81000000;
|
||||
|
||||
|
||||
VIDEO_Init ();
|
||||
PAD_Init ();
|
||||
//DVD_Init ();
|
||||
|
||||
/*** Check to see if this is a GC or a Wii ***/
|
||||
|
||||
/*** Check to see if this is a GC or a Wii ***/
|
||||
// int driveid = dvd_driveid();
|
||||
// bool8 isWii = !((driveid == 4) || (driveid == 6) || (driveid == 8));
|
||||
|
||||
|
||||
AUDIO_Init (NULL);
|
||||
AR_Init (NULL, 0);
|
||||
|
||||
|
||||
/* Before going any further, let's copy any attached ROM image ** */
|
||||
if (memcmp ((char *) romptr, "SNESROM0", 8) == 0)
|
||||
{
|
||||
@ -311,12 +311,12 @@ InitGCVideo ()
|
||||
romptr = (int *) 0x81000020;
|
||||
ARAMPut ((char *) romptr, (char *) AR_SNESROM, ARAM_ROMSIZE);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Always use NTSC mode - this works on NTSC and PAL, GC and Wii
|
||||
vmode = &TVNtsc480IntDf;
|
||||
vmode = &TVNtsc480IntDf;
|
||||
*/
|
||||
|
||||
|
||||
vmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
switch(vmode->viTVMode)
|
||||
@ -336,29 +336,29 @@ InitGCVideo ()
|
||||
vmode_60hz = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
|
||||
screenheight = vmode->xfbHeight;
|
||||
|
||||
|
||||
/*
|
||||
* Allocate the video buffers
|
||||
*/
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
|
||||
|
||||
/*
|
||||
* A console is always useful while debugging.
|
||||
*/
|
||||
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
|
||||
|
||||
|
||||
/*
|
||||
* Clear framebuffers etc.
|
||||
*/
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[1], COLOR_BLACK);
|
||||
VIDEO_SetNextFramebuffer (xfb[0]);
|
||||
|
||||
|
||||
/*
|
||||
* Let libogc populate manage the PADs for us
|
||||
*/
|
||||
@ -370,14 +370,14 @@ InitGCVideo ()
|
||||
VIDEO_WaitVSync ();
|
||||
if (vmode->viTVMode & VI_NON_INTERLACE)
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
|
||||
copynow = GX_FALSE;
|
||||
StartGX ();
|
||||
|
||||
|
||||
#ifdef VIDEO_THREADING
|
||||
InitVideoThread ();
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Finally, the video is up and ready for use :)
|
||||
*/
|
||||
@ -406,7 +406,7 @@ void ReInitGCVideo()
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Drawing screen
|
||||
* Drawing screen
|
||||
****************************************************************************/
|
||||
void
|
||||
clearscreen (int colour)
|
||||
@ -444,7 +444,7 @@ setGFX ()
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* MakeTexture
|
||||
* MakeTexture
|
||||
*
|
||||
* Proper GNU Asm rendition of the above, converted by shagkur. - Thanks!
|
||||
****************************************************************************/
|
||||
@ -460,7 +460,7 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height)
|
||||
" subi %4,%4,4\n"
|
||||
"2: mtctr %6\n"
|
||||
" mr %0,%5\n"
|
||||
//
|
||||
//
|
||||
"1: lwz %1,0(%5)\n"
|
||||
" stwu %1,8(%4)\n"
|
||||
" lwz %2,4(%5)\n"
|
||||
@ -482,7 +482,7 @@ MakeTexture (const void *src, void *dst, s32 width, s32 height)
|
||||
" addi %5,%0,4096\n"
|
||||
" subic. %7,%7,1\n"
|
||||
" bne 2b"
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 0 1 2 3 4 5 6 7
|
||||
:"=&r" (tmp0), "=&r" (tmp1), "=&r" (tmp2),
|
||||
"=&r" (tmp3), "+r" (dst):"r" (src), "r" (width),
|
||||
"r" (height));
|
||||
|
Loading…
Reference in New Issue
Block a user