mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 02:31:50 +01:00
-Save/Load preferences are now on Preferences menu
-Save/Load Method set to Auto - will automatically determine method (NOT YET IMPLEMENTED - defaults to SD for the moment) -All ROM, SRAM, Freeze, and preferences are saved/loaded according to these preferences -new cheats menu! Loads .CHT file from /cheats folder, must match file name of ROM -combined SRAM / Freeze Managers into new "Game Option" menu -SRAM / Freeze - game (re)loaded automatically after loading a SRAM or Freeze from Game Options -SRAM load/save defaults to ON -Game Options, Return to Game, Reload Game do not show up until a game has been loaded -added ROM Information page to Game Option menu -licence/credits moved to Credits page -menu code tweaks -USB support -added future support for Wii DVD / Network loading -MultiTap & SuperScope moved to controller configuration -combined/rewrote SRAM/preferences/freeze code - this is now much cleaner and less repetitve - a few steps closer to being workable -a lot of function parameters have been changed and standardized -if preferences can't be loaded at the start and/or are reset, preferences menu pops up -if Home button is pressed when a game is running, Game Menu pops up -a bunch of misc. bug fixes -probably some more things
This commit is contained in:
parent
1478cee2a3
commit
17d6488545
48
source/ngc/cheatmgr.cpp
Normal file
48
source/ngc/cheatmgr.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51
|
||||
*
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* Tantric August 2008
|
||||
*
|
||||
* cheatmgr.cpp
|
||||
*
|
||||
* Cheat handling
|
||||
****************************************************************************/
|
||||
|
||||
#include "snes9xGx.h"
|
||||
#include "memmap.h"
|
||||
#include "sdload.h"
|
||||
#include "cheats.h"
|
||||
|
||||
extern SCheatData Cheat;
|
||||
|
||||
/****************************************************************************
|
||||
* SetupCheats
|
||||
*
|
||||
* Erases any prexisting cheats, loads cheats from a cheat file
|
||||
* Called when a ROM is first loaded
|
||||
****************************************************************************/
|
||||
void
|
||||
SetupCheats()
|
||||
{
|
||||
S9xInitCheatData ();
|
||||
S9xDeleteCheats ();
|
||||
|
||||
char cheatFile[150] = { '\0' };
|
||||
|
||||
if(GCSettings.SaveMethod == METHOD_SD)
|
||||
sprintf (cheatFile, "%s/snes9x/cheats/%s.cht", ROOTSDDIR, Memory.ROMFilename);
|
||||
else if(GCSettings.SaveMethod == METHOD_USB)
|
||||
sprintf (cheatFile, "%s/snes9x/cheats/%s.cht", ROOTUSBDIR, Memory.ROMFilename);
|
||||
|
||||
// load cheat file if present
|
||||
if(strlen(cheatFile) > 0)
|
||||
{
|
||||
if(S9xLoadCheatFile (cheatFile))
|
||||
{
|
||||
// disable all cheats loaded from the file
|
||||
for (uint16 i = 0; i < Cheat.num_cheats; i++)
|
||||
S9xDisableCheat(i);
|
||||
}
|
||||
}
|
||||
}
|
12
source/ngc/cheatmgr.h
Normal file
12
source/ngc/cheatmgr.h
Normal file
@ -0,0 +1,12 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51
|
||||
*
|
||||
* Nintendo Wii/Gamecube Port
|
||||
* Tantric August 2008
|
||||
*
|
||||
* cheatmgr.h
|
||||
*
|
||||
* Cheat handling
|
||||
****************************************************************************/
|
||||
|
||||
void SetupCheats();
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Filesel - borrowed from GPP
|
||||
*
|
||||
@ -15,7 +15,6 @@
|
||||
|
||||
#include <fat.h>
|
||||
#include <sys/dir.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "memmap.h"
|
||||
#include "debug.h"
|
||||
@ -44,95 +43,84 @@
|
||||
int maxfiles;
|
||||
int havedir = 0;
|
||||
int hasloaded = 0;
|
||||
int loadtype = 0;
|
||||
int LoadDVDFile (unsigned char *buffer);
|
||||
bool haveSDdir = 0;
|
||||
bool haveUSBdir = 0;
|
||||
int haveFATdir = 0;
|
||||
extern unsigned long ARAM_ROMSIZE;
|
||||
extern int screenheight;
|
||||
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
/**
|
||||
* Showfile screen
|
||||
/****************************************************************************
|
||||
* Auto-determines the load method
|
||||
* THIS CODE STILL NEEDS WORK
|
||||
****************************************************************************/
|
||||
int autoLoadMethod()
|
||||
{
|
||||
return METHOD_SD;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Auto-determines the save method
|
||||
* THIS CODE STILL NEEDS WORK
|
||||
****************************************************************************/
|
||||
int autoSaveMethod()
|
||||
{
|
||||
return METHOD_SD;
|
||||
int method = -1;
|
||||
|
||||
while(method < 0)
|
||||
{
|
||||
WaitPrompt((char*) "Checking SD");
|
||||
|
||||
if(diropen(ROOTSDDIR))
|
||||
{
|
||||
WaitPrompt((char*) "Found SD!");
|
||||
method = METHOD_SD;
|
||||
break;
|
||||
}
|
||||
|
||||
WaitPrompt((char*) "Checking USB");
|
||||
|
||||
if(diropen(ROOTUSBDIR))
|
||||
{
|
||||
WaitPrompt((char*) "Found USB!");
|
||||
method = METHOD_USB;
|
||||
break;
|
||||
}
|
||||
|
||||
WaitPrompt((char*) "Checking Slot A");
|
||||
|
||||
// check Memory Card Slot A
|
||||
if(MountCard(CARD_SLOTA, SILENT) == 0)
|
||||
{
|
||||
WaitPrompt((char*) "Found Memory Card A!");
|
||||
method = METHOD_MC_SLOTA;
|
||||
break;
|
||||
}
|
||||
WaitPrompt((char*) "Checking Slot B");
|
||||
|
||||
// check Memory Card Slot B
|
||||
if(MountCard(CARD_SLOTB, SILENT) == 0)
|
||||
{
|
||||
WaitPrompt((char*) "Found Memory Card B!");
|
||||
method = METHOD_MC_SLOTB;
|
||||
break;
|
||||
}
|
||||
|
||||
// no method found
|
||||
WaitPrompt((char*) "Error: Could not determine save method.");
|
||||
method = 0;
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* StripExt
|
||||
*
|
||||
* Display the file selection to the user
|
||||
*/
|
||||
static void
|
||||
ShowFiles (int offset, int selection)
|
||||
{
|
||||
int i, j;
|
||||
char text[MAXPATHLEN];
|
||||
int ypos;
|
||||
int w;
|
||||
|
||||
setfontsize(18);
|
||||
clearscreen ();
|
||||
* Strips an extension from a filename
|
||||
****************************************************************************/
|
||||
|
||||
ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 24;
|
||||
else
|
||||
ypos += 10;
|
||||
|
||||
|
||||
j = 0;
|
||||
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
|
||||
|
||||
{
|
||||
if (filelist[i].flags) // if a dir
|
||||
|
||||
{
|
||||
strcpy (text, "[");
|
||||
strcat (text, filelist[i].displayname);
|
||||
strcat (text, "]");
|
||||
}
|
||||
|
||||
else
|
||||
strcpy (text, filelist[i].displayname);
|
||||
if (j == (selection - offset))
|
||||
|
||||
{
|
||||
|
||||
/*** Highlighted text entry ***/
|
||||
for ( w = 0; w < 20; w++ )
|
||||
DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 );
|
||||
|
||||
setfontcolour (0x00, 0x00, 0xe0);
|
||||
DrawText (-1, (j * 20) + ypos, text);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
{
|
||||
/*** Normal entry ***/
|
||||
DrawText (-1, (j * 20) + ypos, text);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
showscreen ();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* SNESROMSOffset
|
||||
*
|
||||
* Function to check for and return offset to a directory called SNESROMS, if
|
||||
* any
|
||||
*/
|
||||
int SNESROMSOffset()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < maxfiles; i++ )
|
||||
if (strcmp(filelist[i].filename, "SNESROMS") == 0)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void strip_ext(char* inputstring, char* returnstring)
|
||||
void StripExt(char* returnstring, char * inputstring)
|
||||
{
|
||||
char* loc_dot;
|
||||
|
||||
@ -144,40 +132,117 @@ void strip_ext(char* inputstring, char* returnstring)
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Showfile screen
|
||||
*
|
||||
* Display the file selection to the user
|
||||
****************************************************************************/
|
||||
|
||||
static void
|
||||
ShowFiles (int offset, int selection)
|
||||
{
|
||||
int i, j;
|
||||
char text[MAXPATHLEN];
|
||||
int ypos;
|
||||
int w;
|
||||
|
||||
clearscreen ();
|
||||
|
||||
setfontsize (28);
|
||||
DrawText (-1, 60, (char*)"Choose Game");
|
||||
|
||||
setfontsize(18);
|
||||
|
||||
ypos = (screenheight - ((PAGESIZE - 1) * 20)) >> 1;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 24;
|
||||
else
|
||||
ypos += 10;
|
||||
|
||||
j = 0;
|
||||
for (i = offset; i < (offset + PAGESIZE) && (i < maxfiles); i++)
|
||||
{
|
||||
if (filelist[i].flags) // if a dir
|
||||
{
|
||||
strcpy (text, "[");
|
||||
strcat (text, filelist[i].displayname);
|
||||
strcat (text, "]");
|
||||
}
|
||||
else
|
||||
{
|
||||
// hide file extension on listing (.7z, .fig, .smc)
|
||||
StripExt(text, filelist[i].displayname);
|
||||
}
|
||||
if (j == (selection - offset))
|
||||
{
|
||||
/*** Highlighted text entry ***/
|
||||
for ( w = 0; w < 20; w++ )
|
||||
DrawLineFast( 30, 610, ( j * 20 ) + (ypos-16) + w, 0x80, 0x80, 0x80 );
|
||||
|
||||
setfontcolour (0x00, 0x00, 0xe0);
|
||||
DrawText (50, (j * 20) + ypos, text);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*** Normal entry ***/
|
||||
DrawText (50, (j * 20) + ypos, text);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* SNESROMSOffset
|
||||
*
|
||||
* Function to check for and return offset to a directory called SNESROMS, if
|
||||
* any
|
||||
****************************************************************************/
|
||||
int SNESROMSOffset()
|
||||
{
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < maxfiles; i++ )
|
||||
if (strcmp(filelist[i].filename, "SNESROMS") == 0)
|
||||
return i;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* FileSelector
|
||||
*
|
||||
* Let user select a file from the DVD listing
|
||||
*/
|
||||
* Let user select a file from the listing
|
||||
****************************************************************************/
|
||||
int offset = 0;
|
||||
int selection = 0;
|
||||
|
||||
#define PADCAL 40
|
||||
int
|
||||
FileSelector ()
|
||||
FileSelector (int method)
|
||||
{
|
||||
u32 p, wp, ph, wh;
|
||||
signed char a, c;
|
||||
int haverom = 0;
|
||||
int redraw = 1;
|
||||
int selectit = 0;
|
||||
float mag = 0;
|
||||
float mag2 = 0;
|
||||
u16 ang = 0;
|
||||
u16 ang2 = 0;
|
||||
float mag, mag2 = 0;
|
||||
u16 ang, ang2 = 0;
|
||||
int scroll_delay = 0;
|
||||
bool move_selection = 0;
|
||||
#define SCROLL_INITIAL_DELAY 15
|
||||
#define SCROLL_LOOP_DELAY 4
|
||||
|
||||
while (haverom == 0)
|
||||
#define SCROLL_LOOP_DELAY 2
|
||||
|
||||
while (haverom == 0)
|
||||
{
|
||||
if (redraw)
|
||||
ShowFiles (offset, selection);
|
||||
redraw = 0;
|
||||
|
||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
||||
|
||||
|
||||
p = PAD_ButtonsDown (0);
|
||||
ph = PAD_ButtonsHeld (0);
|
||||
#ifdef HW_RVL
|
||||
@ -190,10 +255,10 @@ FileSelector ()
|
||||
#endif
|
||||
a = PAD_StickY (0);
|
||||
c = PAD_SubStickX (0);
|
||||
|
||||
|
||||
/*** Check for exit combo ***/
|
||||
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)) )
|
||||
{
|
||||
@ -201,36 +266,27 @@ FileSelector ()
|
||||
selectit = 0;
|
||||
if (filelist[selection].flags) /*** This is directory ***/
|
||||
{
|
||||
if (loadtype == LOAD_SDC || loadtype == LOAD_USB)
|
||||
if (method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
/* memorize last entries list, actual root directory and selection for next access */
|
||||
if (loadtype == LOAD_SDC)
|
||||
haveSDdir = 1;
|
||||
else
|
||||
haveUSBdir = 1;
|
||||
|
||||
/* 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();
|
||||
int status = updateFATdirname(method);
|
||||
if (status == 1) // ok, open directory
|
||||
{
|
||||
maxfiles = parseFATdirectory();
|
||||
maxfiles = parseFATdirectory(method);
|
||||
if (!maxfiles)
|
||||
{
|
||||
WaitPrompt ((char*) "Error reading directory !");
|
||||
haverom = 1; // quit SD menu
|
||||
if (loadtype == LOAD_SDC) // reset everything at next access
|
||||
haveSDdir = 0;
|
||||
else
|
||||
haveUSBdir = 0;
|
||||
haverom = 1; // quit FAT menu
|
||||
haveFATdir = 0; // reset everything at next access
|
||||
}
|
||||
}
|
||||
else if (status == -1) // directory name too long
|
||||
{
|
||||
haverom = 1; // quit SD menu
|
||||
if (loadtype == LOAD_SDC) // reset everything at next access
|
||||
haveSDdir = 0;
|
||||
else
|
||||
haveUSBdir = 0;
|
||||
haverom = 1; // quit FAT menu
|
||||
haveFATdir = 0; // reset everything at next access
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -249,43 +305,44 @@ FileSelector ()
|
||||
}
|
||||
else // this is a file
|
||||
{
|
||||
rootdir = filelist[selection].offset;
|
||||
rootdir = filelist[selection].offset;
|
||||
rootdirlength = filelist[selection].length;
|
||||
|
||||
/*** store the filename (used for sram/freeze naming) ***/
|
||||
strip_ext(filelist[selection].filename, Memory.ROMFilename); // store stripped filename in Memory.ROMFilename
|
||||
|
||||
switch (loadtype)
|
||||
// store the filename (used for sram/freeze naming)
|
||||
StripExt(Memory.ROMFilename, filelist[selection].filename); // store stripped filename in Memory.ROMFilename
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case LOAD_DVD:
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
/*** Load from FAT ***/
|
||||
/* memorize last entries list, actual root directory and selection for next access */
|
||||
haveFATdir = 1;
|
||||
ARAM_ROMSIZE = LoadFATFile (filelist[selection].filename,
|
||||
filelist[selection].length);
|
||||
break;
|
||||
|
||||
case METHOD_DVD:
|
||||
/*** Now load the DVD file to it's offset ***/
|
||||
ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
|
||||
break;
|
||||
|
||||
case LOAD_SMB:
|
||||
|
||||
case METHOD_SMB:
|
||||
/*** Load from SMB ***/
|
||||
ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename,
|
||||
ARAM_ROMSIZE =
|
||||
LoadSMBFile (filelist[selection].filename,
|
||||
filelist[selection].length);
|
||||
break;
|
||||
|
||||
case LOAD_USB:
|
||||
case LOAD_SDC:
|
||||
/*** Load from SD Card ***/
|
||||
/* memorize last entries list, actual root directory and selection for next access */
|
||||
haveSDdir = 1;
|
||||
ARAM_ROMSIZE = LoadSDFile (filelist[selection].filename,
|
||||
filelist[selection].length);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (ARAM_ROMSIZE > 0)
|
||||
{
|
||||
hasloaded = 1;
|
||||
Memory.LoadROM ("BLANK.SMC");
|
||||
|
||||
|
||||
Memory.LoadSRAM ("BLANK");
|
||||
haverom = 1;
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -297,19 +354,19 @@ FileSelector ()
|
||||
} // End of A
|
||||
if ( (p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)) )
|
||||
{
|
||||
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
||||
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
||||
#ifdef HW_RVL
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
||||
#endif
|
||||
)
|
||||
VIDEO_WaitVSync();
|
||||
//if ((strcmp(filelist[1].filename,"..") == 0) && (strlen (filelist[0].filename) != 0))
|
||||
if ( strcmp(filelist[0].filename,"..") == 0 )
|
||||
if ( strcmp(filelist[0].filename,"..") == 0 )
|
||||
{
|
||||
selection = 0;
|
||||
selectit = 1;
|
||||
}
|
||||
else if ( strcmp(filelist[1].filename,"..") == 0 )
|
||||
else if ( strcmp(filelist[1].filename,"..") == 0 )
|
||||
{
|
||||
selection = selectit = 1;
|
||||
} else {
|
||||
@ -321,14 +378,14 @@ FileSelector ()
|
||||
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) ) { /*** Button just pressed ***/
|
||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
move_selection = 1; //continue (move selection)
|
||||
}
|
||||
}
|
||||
else if (scroll_delay == 0) { /*** Button is held ***/
|
||||
scroll_delay = SCROLL_LOOP_DELAY;
|
||||
move_selection = 1; //continue (move selection)
|
||||
} else {
|
||||
scroll_delay--; // wait
|
||||
}
|
||||
|
||||
|
||||
if (move_selection)
|
||||
{
|
||||
selection++;
|
||||
@ -341,18 +398,18 @@ FileSelector ()
|
||||
}
|
||||
} // End of down
|
||||
if ( ((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > PADCAL) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
|
||||
{
|
||||
{
|
||||
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) ) { /*** Button just pressed***/
|
||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
||||
move_selection = 1; //continue (move selection)
|
||||
}
|
||||
}
|
||||
else if (scroll_delay == 0) { /*** Button is held ***/
|
||||
scroll_delay = SCROLL_LOOP_DELAY;
|
||||
move_selection = 1; //continue (move selection)
|
||||
} else {
|
||||
scroll_delay--; // wait
|
||||
}
|
||||
|
||||
|
||||
if (move_selection)
|
||||
{
|
||||
selection--;
|
||||
@ -397,18 +454,16 @@ FileSelector ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* OpenDVD
|
||||
*
|
||||
* Function to load a DVD directory and display to user.
|
||||
*/
|
||||
****************************************************************************/
|
||||
int
|
||||
OpenDVD ()
|
||||
OpenDVD (int method)
|
||||
{
|
||||
int romsdiroffset = 0;
|
||||
|
||||
loadtype = LOAD_DVD;
|
||||
|
||||
|
||||
if (!getpvd())
|
||||
{
|
||||
ShowAction((char*) "Mounting DVD ... Wait");
|
||||
@ -417,13 +472,12 @@ OpenDVD ()
|
||||
if (!getpvd())
|
||||
return 0; /* no correct ISO9660 DVD */
|
||||
}
|
||||
|
||||
|
||||
if (havedir == 0)
|
||||
{
|
||||
offset = selection = 0; /* reset file selector */
|
||||
haveSDdir = 0; /* prevent conflicts with SDCARD, USB file selector */
|
||||
haveUSBdir = 0;
|
||||
|
||||
haveFATdir = 0; /* prevent conflicts with FAT file selector */
|
||||
|
||||
if ((maxfiles = parsedirectory ()))
|
||||
{
|
||||
if ( romsdiroffset = SNESROMSOffset() )
|
||||
@ -433,210 +487,120 @@ OpenDVD ()
|
||||
offset = selection = 0;
|
||||
maxfiles = parsedirectory ();
|
||||
}
|
||||
|
||||
int ret = FileSelector ();
|
||||
|
||||
int ret = FileSelector (method);
|
||||
havedir = 1;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
return FileSelector ();
|
||||
|
||||
return FileSelector (method);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* OpenSMB
|
||||
*
|
||||
* Function to load from an SMB share
|
||||
*/
|
||||
****************************************************************************/
|
||||
int
|
||||
OpenSMB ()
|
||||
OpenSMB (int method)
|
||||
{
|
||||
loadtype = LOAD_SMB;
|
||||
|
||||
if ((maxfiles = parseSMBDirectory ()))
|
||||
if ((maxfiles = parseSMBDirectory ()))
|
||||
{
|
||||
char txt[80];
|
||||
sprintf(txt,"maxfiles = %d", maxfiles);
|
||||
|
||||
return FileSelector ();
|
||||
|
||||
return FileSelector (method);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* OpenFAT
|
||||
*
|
||||
* Function to load from FAT
|
||||
****************************************************************************/
|
||||
int
|
||||
OpenFAT (int method)
|
||||
{
|
||||
char msg[80];
|
||||
|
||||
//if (haveFATdir == 0)
|
||||
//{
|
||||
/* don't mess with DVD entries */
|
||||
havedir = 0; // gamecube only
|
||||
|
||||
// is_mounted
|
||||
//
|
||||
// to check whether FAT media are detected.
|
||||
bool fat_is_mounted(PARTITION_INTERFACE partition) {
|
||||
char prefix[] = "fatX:/";
|
||||
prefix[3] = partition + '0';
|
||||
DIR_ITER *dir = diropen(prefix);
|
||||
if (dir) {
|
||||
dirclose(dir);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/* change current dir to snes roms directory */
|
||||
if(method == METHOD_SD)
|
||||
sprintf ( currFATdir, "%s/%s", ROOTSDDIR, GCSettings.LoadFolder );
|
||||
else
|
||||
sprintf ( currFATdir, "%s/%s", ROOTUSBDIR, GCSettings.LoadFolder );
|
||||
|
||||
void fat_enable_readahead_all() {
|
||||
int i;
|
||||
for (i=1; i <= 4; ++i) {
|
||||
if (fat_is_mounted((PARTITION_INTERFACE)i)) fatEnableReadAhead((PARTITION_INTERFACE)i, 64, 128);
|
||||
}
|
||||
}
|
||||
|
||||
bool fat_remount(PARTITION_INTERFACE partition) {
|
||||
//ShowAction("remounting...");
|
||||
/* // removed to make usb work...
|
||||
if (fat_is_mounted(partition))
|
||||
/* Parse initial root directory and get entries list */
|
||||
if ((maxfiles = parseFATdirectory (method)))
|
||||
{
|
||||
fatUnmount(partition);
|
||||
/* Select an entry */
|
||||
return FileSelector (method);
|
||||
}
|
||||
*/
|
||||
|
||||
fatMountNormalInterface(partition, 8);
|
||||
fatSetDefaultInterface(partition);
|
||||
//fatEnableReadAhead(partition, 64, 128);
|
||||
|
||||
if (fat_is_mounted(partition))
|
||||
else
|
||||
{
|
||||
//ShowAction("remount successful.");
|
||||
sleep(1);
|
||||
return 1;
|
||||
} else {
|
||||
ShowAction("FAT mount failed.");
|
||||
sleep(1);
|
||||
/* 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);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenSD
|
||||
*
|
||||
* Function to load from an SD Card
|
||||
*/
|
||||
/****************************************************************************
|
||||
* OpenROM
|
||||
* Opens device specified by method, displays a list of ROMS
|
||||
****************************************************************************/
|
||||
|
||||
int
|
||||
OpenSD ()
|
||||
OpenROM (int method)
|
||||
{
|
||||
char msg[80];
|
||||
char buf[50] = "";
|
||||
|
||||
loadtype = LOAD_SDC;
|
||||
int loadROM = 0;
|
||||
|
||||
/*
|
||||
fatUnmount(PI_INTERNAL_SD);
|
||||
fatMountNormalInterface(PI_INTERNAL_SD,8);
|
||||
//fatEnableReadAhead(PI_INTERNAL_SD, 64, 128);
|
||||
fatSetDefaultInterface(PI_INTERNAL_SD);
|
||||
//chdir("fat0:/");
|
||||
*/
|
||||
#ifdef HW_RVL
|
||||
// only remount on wii
|
||||
if (!fat_remount (PI_INTERNAL_SD))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (haveSDdir == 0)
|
||||
{
|
||||
/* don't mess with DVD entries */
|
||||
havedir = 0;
|
||||
haveUSBdir = 0;
|
||||
|
||||
/* change current dir to snes roms directory */
|
||||
sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR );
|
||||
|
||||
|
||||
/* Parse initial root directory and get entries list */
|
||||
if ((maxfiles = parseFATdirectory ()))
|
||||
{
|
||||
/* Select an entry */
|
||||
return FileSelector ();
|
||||
}
|
||||
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 ();
|
||||
|
||||
return 0;
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_SD:
|
||||
case METHOD_USB:
|
||||
loadROM = OpenFAT (method);
|
||||
break;
|
||||
case METHOD_DVD:
|
||||
// Load from DVD
|
||||
loadROM = OpenDVD (method);
|
||||
break;
|
||||
case METHOD_SMB:
|
||||
// Load from Network (SMB)
|
||||
loadROM = OpenSMB (method);
|
||||
break;
|
||||
}
|
||||
|
||||
return loadROM;
|
||||
}
|
||||
|
||||
/**
|
||||
* OpenUSB
|
||||
*
|
||||
* Function to load from a USB device (wii only)
|
||||
*/
|
||||
int
|
||||
OpenUSB ()
|
||||
{
|
||||
char msg[80];
|
||||
char buf[50] = "";
|
||||
|
||||
/*
|
||||
//fatUnmount(PI_USBSTORAGE);
|
||||
fatUnmount(PI_INTERNAL_SD);
|
||||
//if(!fatMountNormalInterface(PI_USBSTORAGE,8))
|
||||
// return 0;
|
||||
//fatEnableReadAhead(PI_USBSTORAGE, 64, 128);
|
||||
fatSetDefaultInterface(PI_USBSTORAGE);
|
||||
*/
|
||||
#ifdef HW_RVL
|
||||
// make compiler happy
|
||||
if (!fat_remount (PI_USBSTORAGE))
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
loadtype = LOAD_USB;
|
||||
|
||||
if (haveUSBdir == 0)
|
||||
{
|
||||
/* don't mess with DVD, SDCARD entries */
|
||||
havedir = 0;
|
||||
haveSDdir = 0;
|
||||
|
||||
/* change current dir to snes roms directory */
|
||||
sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR );
|
||||
|
||||
/* Parse initial root directory and get entries list */
|
||||
if ((maxfiles = parseFATdirectory ()))
|
||||
{
|
||||
/* Select an entry */
|
||||
return FileSelector ();
|
||||
}
|
||||
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 ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* LoadDVDFile
|
||||
*
|
||||
* This function will load a file from DVD, in BIN, SMD or ZIP format.
|
||||
* The values for offset and length are inherited from rootdir and
|
||||
* The values for offset and length are inherited from rootdir and
|
||||
* rootdirlength.
|
||||
*
|
||||
* The buffer parameter should re-use the initial ROM buffer.
|
||||
*/
|
||||
****************************************************************************/
|
||||
|
||||
int
|
||||
LoadDVDFile (unsigned char *buffer)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Filesel - borrowed from GPP
|
||||
*
|
||||
@ -10,17 +10,8 @@
|
||||
#ifndef _NGCFILESEL_
|
||||
#define _NGCFILESEL_
|
||||
|
||||
int OpenDVD ();
|
||||
int OpenSMB ();
|
||||
int OpenSD ();
|
||||
int OpenUSB ();
|
||||
|
||||
#define LOAD_DVD 1
|
||||
#define LOAD_SMB 2
|
||||
#define LOAD_SDC 4
|
||||
#define LOAD_USB 8
|
||||
#define ROOTSDDIR "fat3:/"
|
||||
#define SNESROMDIR "snes9x/roms"
|
||||
#define SNESSAVEDIR "snes9x/saves"
|
||||
int OpenROM (int method);
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod();
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Screen Font Driver
|
||||
*
|
||||
@ -31,6 +31,7 @@
|
||||
#include "dkpro.h"
|
||||
#include "snes9xGX.h"
|
||||
|
||||
#include "memmap.h"
|
||||
#include "aram.h"
|
||||
#include <zlib.h>
|
||||
|
||||
@ -49,24 +50,23 @@ extern int screenheight;
|
||||
extern unsigned int *xfb[2];
|
||||
extern int whichfb;
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Unpack the devkit pro logo
|
||||
*/
|
||||
****************************************************************************/
|
||||
static u32 *dkproraw;
|
||||
/*** Permanent backdrop ***/
|
||||
#ifdef HW_RVL
|
||||
u32 *backdrop;
|
||||
#else
|
||||
static u32 *backdrop;
|
||||
static u32 *backdrop;
|
||||
#endif
|
||||
static void unpackbackdrop ();
|
||||
unsigned int getcolour (u8 r1, u8 g1, u8 b1);
|
||||
void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b );
|
||||
u32 getrgb( u32 ycbr, u32 low );
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Initialisation of libfreetype
|
||||
*/
|
||||
****************************************************************************/
|
||||
int
|
||||
FT_Init ()
|
||||
{
|
||||
@ -91,11 +91,11 @@ FT_Init ()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* setfontsize
|
||||
*
|
||||
* Set the screen font size in pixels
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
setfontsize (int pixelsize)
|
||||
{
|
||||
@ -107,6 +107,10 @@ setfontsize (int pixelsize)
|
||||
printf ("Error setting pixel sizes!");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* DrawCharacter
|
||||
* Draws a single character on the screen
|
||||
****************************************************************************/
|
||||
static void
|
||||
DrawCharacter (FT_Bitmap * bmp, FT_Int x, FT_Int y)
|
||||
{
|
||||
@ -144,11 +148,11 @@ DrawCharacter (FT_Bitmap * bmp, FT_Int x, FT_Int y)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* DrawText
|
||||
*
|
||||
* Place the font bitmap on the screen
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
DrawText (int x, int y, char *text)
|
||||
{
|
||||
@ -161,6 +165,8 @@ DrawText (int x, int y, char *text)
|
||||
if (n == 0)
|
||||
return;
|
||||
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
|
||||
/*** x == -1, auto centre ***/
|
||||
if (x == -1)
|
||||
{
|
||||
@ -198,11 +204,11 @@ DrawText (int x, int y, char *text)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* setfontcolour
|
||||
*
|
||||
* Uses RGB triple values.
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
setfontcolour (u8 r, u8 g, u8 b)
|
||||
{
|
||||
@ -213,47 +219,11 @@ setfontcolour (u8 r, u8 g, u8 b)
|
||||
fontlo = fontcolour & 0xffff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Licence Information
|
||||
*
|
||||
* THIS MUST NOT BE REMOVED IN ANY DERIVATIVE WORK.
|
||||
*/
|
||||
void
|
||||
licence ()
|
||||
{
|
||||
|
||||
int ypos = ((screenheight - (282 + dkpro_HEIGHT)) >> 1);
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 42;
|
||||
else
|
||||
ypos += 24;
|
||||
|
||||
setfontsize (16);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
|
||||
DrawText (-1, ypos += 40, (char*)"Snes9x - Copyright (c) Snes9x Team 1996 - 2006");
|
||||
|
||||
DrawText (-1, ypos += 40, (char*)"This is free software, and you are welcome to");
|
||||
DrawText (-1, ypos += 20, (char*)"redistribute it under the conditions of the");
|
||||
DrawText (-1, ypos += 20, (char*)"GNU GENERAL PUBLIC LICENSE Version 2");
|
||||
DrawText (-1, ypos +=
|
||||
20, (char*)"Additionally, the developers of this port disclaim");
|
||||
DrawText (-1, ypos +=
|
||||
20, (char*)"all copyright interests in the Nintendo GameCube");
|
||||
DrawText (-1, ypos +=
|
||||
20, (char*)"porting code. You are free to use it as you wish");
|
||||
|
||||
DrawText (-1, ypos += 40, (char*)"Developed with DevkitPPC and libOGC");
|
||||
DrawText (-1, ypos += 20, (char*)"http://www.devkitpro.org");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* dkunpack
|
||||
*
|
||||
* Support function to expand the DevkitPro logo
|
||||
*/
|
||||
****************************************************************************/
|
||||
int
|
||||
dkunpack ()
|
||||
{
|
||||
@ -271,11 +241,11 @@ dkunpack ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* showdklogo
|
||||
*
|
||||
* Display the DevkitPro logo
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
showdklogo ()
|
||||
{
|
||||
@ -302,13 +272,69 @@ showdklogo ()
|
||||
free (dkproraw);
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Display credits, legal copyright and licence
|
||||
*
|
||||
* THIS MUST NOT BE REMOVED IN ANY DERIVATIVE WORK.
|
||||
****************************************************************************/
|
||||
void
|
||||
Credits ()
|
||||
{
|
||||
clearscreen ();
|
||||
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
|
||||
setfontsize (28);
|
||||
DrawText (-1, 60, (char*)"Credits");
|
||||
|
||||
int ypos = 25;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
|
||||
setfontsize (18);
|
||||
DrawText (-1, ypos += 30, (char*)"Technical");
|
||||
|
||||
setfontsize (14);
|
||||
DrawText (-1, ypos += 22, (char*)"Snes9x v1.5.1 - Snes9x Team");
|
||||
DrawText (-1, ypos += 18, (char*)"GameCube Port 2.0 WIP6 and earlier - SoftDev");
|
||||
DrawText (-1, ypos += 18, (char*)"Additional improvements to 2.0 WIP6 - eke-eke");
|
||||
DrawText (-1, ypos += 18, (char*)"GameCube 2.0.1bx enhancements - crunchy2");
|
||||
DrawText (-1, ypos += 18, (char*)"v00x updates - michniewski & Tantric");
|
||||
DrawText (-1, ypos += 18, (char*)"GX - http://www.gc-linux.org");
|
||||
DrawText (-1, ypos += 18, (char*)"libogc - Shagkur & wintermute");
|
||||
|
||||
setfontsize (18);
|
||||
DrawText (-1, ypos += 30, (char*)"Testing");
|
||||
|
||||
setfontsize (14);
|
||||
DrawText (-1, ypos += 22, (char*)"crunchy2 / tehskeen users / others");
|
||||
|
||||
setfontsize (18);
|
||||
DrawText (-1, ypos += 30, (char*)"Documentation");
|
||||
|
||||
setfontsize (14);
|
||||
DrawText (-1, ypos += 22, (char*)"brakken, crunchy2, michniewski");
|
||||
|
||||
setfontsize (12);
|
||||
DrawText (-1, ypos += 50, (char*)"Snes9x - Copyright (c) Snes9x Team 1996 - 2006");
|
||||
DrawText (-1, ypos += 15, (char*)"This software is open source and may be copied, distributed, or modified");
|
||||
DrawText (-1, ypos += 15, (char*)"under the terms of the GNU General Public License (GPL) Version 2.");
|
||||
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* getcolour
|
||||
*
|
||||
* Simply converts RGB to Y1CbY2Cr format
|
||||
*
|
||||
* I got this from a pastebin, so thanks to whoever originally wrote it!
|
||||
*/
|
||||
****************************************************************************/
|
||||
|
||||
unsigned int
|
||||
getcolour (u8 r1, u8 g1, u8 b1)
|
||||
@ -334,9 +360,9 @@ getcolour (u8 r1, u8 g1, u8 b1)
|
||||
return ((y1 << 24) | (cb << 16) | (y2 << 8) | cr);
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Unpackbackdrop
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
unpackbackdrop ()
|
||||
{
|
||||
@ -371,22 +397,9 @@ unpackbackdrop ()
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display legal copyright and licence
|
||||
*/
|
||||
void
|
||||
legal ()
|
||||
{
|
||||
unpackbackdrop ();
|
||||
clearscreen ();
|
||||
licence ();
|
||||
showdklogo ();
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Wait for user to press A
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
WaitButtonA ()
|
||||
{
|
||||
@ -399,20 +412,20 @@ WaitButtonA ()
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Wait for user to press A or B. Returns 0 = B; 1 = A
|
||||
*/
|
||||
****************************************************************************/
|
||||
|
||||
int
|
||||
WaitButtonAB ()
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
u32 gc_btns, wm_btns;
|
||||
|
||||
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B))
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B))
|
||||
|
||||
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B))
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_A | WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_A | WPAD_CLASSIC_BUTTON_B))
|
||||
) VIDEO_WaitVSync();
|
||||
|
||||
|
||||
while ( TRUE )
|
||||
{
|
||||
gc_btns = PAD_ButtonsDown (0);
|
||||
@ -424,9 +437,9 @@ WaitButtonAB ()
|
||||
}
|
||||
#else
|
||||
u32 gc_btns;
|
||||
|
||||
|
||||
while ( (PAD_ButtonsDown (0) & (PAD_BUTTON_A | PAD_BUTTON_B)) ) VIDEO_WaitVSync();
|
||||
|
||||
|
||||
while ( TRUE )
|
||||
{
|
||||
gc_btns = PAD_ButtonsDown (0);
|
||||
@ -438,9 +451,9 @@ WaitButtonAB ()
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Show a prompt
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
WaitPrompt (char *msg)
|
||||
{
|
||||
@ -459,10 +472,10 @@ WaitPrompt (char *msg)
|
||||
WaitButtonA ();
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Show a prompt with choice of two options. Returns 1 if A button was pressed
|
||||
and 0 if B button was pressed.
|
||||
*/
|
||||
****************************************************************************/
|
||||
int
|
||||
WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
||||
{
|
||||
@ -483,9 +496,9 @@ WaitPromptChoice (char *msg, char *bmsg, char *amsg)
|
||||
return WaitButtonAB ();
|
||||
}
|
||||
|
||||
/**
|
||||
/****************************************************************************
|
||||
* Show an action in progress
|
||||
*/
|
||||
****************************************************************************/
|
||||
void
|
||||
ShowAction (char *msg)
|
||||
{
|
||||
@ -505,62 +518,81 @@ ShowAction (char *msg)
|
||||
* Generic Menu Routines
|
||||
****************************************************************************/
|
||||
void
|
||||
DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsize)
|
||||
DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize, int x)
|
||||
{
|
||||
int i, w;
|
||||
int ypos;
|
||||
int i, w = 0;
|
||||
int ypos = 0;
|
||||
int n = 1;
|
||||
|
||||
#if 0
|
||||
int bounding[] = { 80, 40, 600, 40, 560, 94, 40, 94 };
|
||||
int base[] = { 80, screenheight - 90, 600, screenheight - 90,
|
||||
560, screenheight - 40, 40, screenheight - 40
|
||||
};
|
||||
#endif
|
||||
ypos = 65;
|
||||
|
||||
//ypos = (screenheight - (maxitems * 32)) >> 1; previous
|
||||
ypos = (screenheight - (maxitems * (fontsize + 8))) >> 1;
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
clearscreen ();
|
||||
|
||||
clearscreen ();
|
||||
setfontcolour (0, 0, 0);
|
||||
|
||||
//#if 0
|
||||
// DrawPolygon (4, bounding, 0x00, 0x00, 0xc0);
|
||||
// DrawPolygon (4, base, 0x00, 0x00, 0xc0);
|
||||
setfontsize (30);
|
||||
if (title != NULL)
|
||||
DrawText (-1, 60, title);
|
||||
setfontsize (12);
|
||||
DrawText (510, screenheight - 20, "Snes9x GX 004");
|
||||
//#endif
|
||||
|
||||
setfontsize (fontsize); // set font size
|
||||
setfontcolour (0, 0, 0);
|
||||
|
||||
for (i = 0; i < maxitems; i++)
|
||||
{
|
||||
if (i == selected)
|
||||
if (title != NULL)
|
||||
{
|
||||
//for( w = 0; w < 32; w++ )
|
||||
for( w = 0; w < (fontsize + 8); w++ )
|
||||
//DrawLineFast( 30, 610, (i << 5) + (ypos-26) + w, 0x80, 0x80, 0x80 ); previous
|
||||
DrawLineFast( 30, 610, i * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 );
|
||||
|
||||
setfontcolour (0xff, 0xff, 0xff);
|
||||
//DrawText (-1, (i << 5) + ypos, items[i]); previous
|
||||
DrawText (-1, i * (fontsize + 8) + ypos, items[i]);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
setfontsize (28);
|
||||
DrawText (-1, 60, title);
|
||||
}
|
||||
else
|
||||
DrawText (-1, i * (fontsize + 8) + ypos, items[i]);
|
||||
//DrawText (-1, i * 32 + ypos, items[i]); previous
|
||||
}
|
||||
|
||||
showscreen ();
|
||||
setfontsize (12);
|
||||
DrawText (510, screenheight - 20, (char *)"Snes9x GX 005");
|
||||
|
||||
// Draw menu items
|
||||
|
||||
setfontsize (fontsize); // set font size
|
||||
|
||||
for (i = 0; i < maxitems; i++)
|
||||
{
|
||||
if(strlen(items[i]) > 0)
|
||||
{
|
||||
if (i == selected)
|
||||
{
|
||||
for( w = 0; w < (fontsize + 8); w++ )
|
||||
DrawLineFast( 30, 610, n * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 );
|
||||
|
||||
setfontcolour (0xff, 0xff, 0xff);
|
||||
DrawText (x, n * (fontsize + 8) + ypos, items[i]);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawText (x, n * (fontsize + 8) + ypos, items[i]);
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
showscreen ();
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* FindMenuItem
|
||||
*
|
||||
* Help function to find the next visible menu item on the list
|
||||
* Supports menu wrap-around
|
||||
****************************************************************************/
|
||||
|
||||
int FindMenuItem(char items[][50], int maxitems, int currentItem, int direction)
|
||||
{
|
||||
int nextItem = currentItem + direction;
|
||||
|
||||
if(nextItem < 0)
|
||||
nextItem = maxitems-1;
|
||||
else if(nextItem >= maxitems)
|
||||
nextItem = 0;
|
||||
|
||||
if(strlen(items[nextItem]) > 0)
|
||||
return nextItem;
|
||||
else
|
||||
return FindMenuItem(&items[0], maxitems, nextItem, direction);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -570,8 +602,9 @@ DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsiz
|
||||
* It's here to keep all the font / interface stuff together.
|
||||
****************************************************************************/
|
||||
int menu = 0;
|
||||
|
||||
int
|
||||
RunMenu (char items[][20], int maxitems, char *title, int fontsize)
|
||||
RunMenu (char items[][50], int maxitems, char *title, int fontsize, int x)
|
||||
{
|
||||
int redraw = 1;
|
||||
int quit = 0;
|
||||
@ -582,8 +615,7 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
|
||||
float mag2 = 0;
|
||||
u16 ang = 0;
|
||||
u16 ang2 = 0;
|
||||
|
||||
//while (!(PAD_ButtonsDown (0) & PAD_BUTTON_B) && (quit == 0))
|
||||
|
||||
while (quit == 0)
|
||||
{
|
||||
if (redraw)
|
||||
@ -591,7 +623,7 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
|
||||
DrawMenu (&items[0], title, maxitems, menu, fontsize);
|
||||
redraw = 0;
|
||||
}
|
||||
|
||||
|
||||
p = PAD_ButtonsDown (0);
|
||||
#ifdef HW_RVL
|
||||
wp = WPAD_ButtonsDown (0);
|
||||
@ -600,57 +632,137 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
|
||||
wp = 0;
|
||||
#endif
|
||||
a = PAD_StickY (0);
|
||||
|
||||
|
||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
||||
|
||||
/*** Look for up ***/
|
||||
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > 70) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
|
||||
{
|
||||
redraw = 1;
|
||||
menu--;
|
||||
menu = FindMenuItem(&items[0], maxitems, menu, -1);
|
||||
}
|
||||
|
||||
|
||||
/*** Look for down ***/
|
||||
if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -70) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
|
||||
{
|
||||
redraw = 1;
|
||||
menu++;
|
||||
menu = FindMenuItem(&items[0], maxitems, menu, +1);
|
||||
}
|
||||
|
||||
|
||||
if ((p & PAD_BUTTON_A) || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)))
|
||||
{
|
||||
quit = 1;
|
||||
ret = menu;
|
||||
}
|
||||
|
||||
|
||||
if ((p & PAD_BUTTON_B) || (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)))
|
||||
{
|
||||
quit = -1;
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
if (menu == maxitems)
|
||||
menu = 0;
|
||||
|
||||
if (menu < 0)
|
||||
menu = maxitems - 1;
|
||||
}
|
||||
|
||||
/*** Wait for B button to be released before proceeding ***/
|
||||
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
||||
while ( (PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
||||
#ifdef HW_RVL
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
||||
#endif
|
||||
)
|
||||
{
|
||||
ret = -1;
|
||||
VIDEO_WaitVSync();
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* ROM Information Screen
|
||||
****************************************************************************/
|
||||
|
||||
void RomInfo()
|
||||
{
|
||||
clearscreen ();
|
||||
|
||||
int ypos = 65;
|
||||
|
||||
if (screenheight == 480)
|
||||
ypos += 52;
|
||||
else
|
||||
ypos += 32;
|
||||
|
||||
setfontsize (28);
|
||||
DrawText (-1, 60, (char*)"Rom Information");
|
||||
|
||||
setfontsize (16);
|
||||
setfontcolour (0x00, 0x00, 0x00);
|
||||
|
||||
#define MENU_INFO_ROM "ROM"
|
||||
#define MENU_INFO_ROMID "ROMID"
|
||||
#define MENU_INFO_COMPANY "Company"
|
||||
#define MENU_INFO_SIZE "Size"
|
||||
#define MENU_INFO_SRAM "SRAM"
|
||||
#define MENU_INFO_TYPE "Type"
|
||||
#define MENU_INFO_CHECKSUM "Checksum"
|
||||
#define MENU_INFO_TVTYPE "TV Type"
|
||||
#define MENU_INFO_FRAMES "Frames"
|
||||
#define MENU_INFO_CRC32 "CRC32"
|
||||
|
||||
char fmtString[1024];
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_ROM);
|
||||
DrawText (300, ypos, Memory.ROMName);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_ROMID);
|
||||
DrawText (300, ypos, Memory.ROMId);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_COMPANY);
|
||||
DrawText (300, ypos, Memory.CompanyId);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_SIZE);
|
||||
sprintf(fmtString, "%d", Memory.ROMSize);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_SRAM);
|
||||
sprintf(fmtString, "%d", Memory.SRAMSize);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_TYPE);
|
||||
sprintf(fmtString, "%d", Memory.ROMType);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_CHECKSUM);
|
||||
sprintf(fmtString, "%04x / %04x", Memory.ROMChecksum, Memory.ROMComplementChecksum);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_TVTYPE);
|
||||
sprintf(fmtString, "%s", Settings.PAL ? "PAL" : "NTSC");
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_FRAMES);
|
||||
sprintf(fmtString, "%d", Memory.ROMFramesPerSecond);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
ypos += 20;
|
||||
DrawText (150, ypos, (char *)MENU_INFO_CRC32);
|
||||
sprintf(fmtString, "%08X", Memory.ROMCRC32);
|
||||
DrawText (300, ypos, fmtString);
|
||||
|
||||
showscreen ();
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* DrawLine
|
||||
*
|
||||
@ -811,27 +923,27 @@ void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b )
|
||||
u32 colour, clo, chi;
|
||||
u32 lo,hi;
|
||||
u8 *s, *d;
|
||||
|
||||
|
||||
//colour = getcolour(r, g, b);
|
||||
colour = ( r << 16 | g << 8 | b );
|
||||
d = (u8 *)&colour;
|
||||
d[1] = c_adjust(d[1], DSTWEIGHT);
|
||||
d[2] = c_adjust(d[2], DSTWEIGHT);
|
||||
d[3] = c_adjust(d[3], DSTWEIGHT);
|
||||
|
||||
|
||||
width = ( endx - startx ) >> 1;
|
||||
offset = ( y << 8 ) + ( y << 6 ) + ( startx >> 1 );
|
||||
|
||||
|
||||
for ( i = 0; i < width; i++ )
|
||||
{
|
||||
lo = getrgb(xfb[whichfb][offset], 0);
|
||||
hi = getrgb(xfb[whichfb][offset], 1);
|
||||
|
||||
|
||||
s = (u8 *)&hi;
|
||||
s[1] = ( ( c_adjust(s[1],SRCWEIGHT) ) + d[1] );
|
||||
s[2] = ( ( c_adjust(s[2],SRCWEIGHT) ) + d[2] );
|
||||
s[3] = ( ( c_adjust(s[3],SRCWEIGHT) ) + d[3] );
|
||||
|
||||
|
||||
s = (u8 *)&lo;
|
||||
s[1] = ( ( c_adjust(s[1],SRCWEIGHT) ) + d[1] );
|
||||
s[2] = ( ( c_adjust(s[2],SRCWEIGHT) ) + d[2] );
|
||||
@ -840,21 +952,21 @@ void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b )
|
||||
clo = getcolour( s[1], s[2], s[3] );
|
||||
s = (u8 *)&hi;
|
||||
chi = getcolour( s[1], s[2], s[3] );
|
||||
|
||||
|
||||
xfb[whichfb][offset++] = (chi & 0xffff0000 ) | ( clo & 0xffff) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*****************************************************************************
|
||||
* Ok, I'm useless with Y1CBY2CR colour.
|
||||
* So convert back to RGB so I can work with it -;)
|
||||
*/
|
||||
****************************************************************************/
|
||||
u32 getrgb( u32 ycbr, u32 low )
|
||||
{
|
||||
u8 r,g,b;
|
||||
u32 y;
|
||||
s8 cb,cr;
|
||||
|
||||
|
||||
if ( low )
|
||||
y = ( ycbr & 0xff00 ) >> 8;
|
||||
else
|
||||
@ -862,16 +974,14 @@ u32 getrgb( u32 ycbr, u32 low )
|
||||
|
||||
cr = ycbr & 0xff;
|
||||
cb = ( ycbr & 0xff0000 ) >> 16;
|
||||
|
||||
|
||||
cr -= 128;
|
||||
cb -= 128;
|
||||
|
||||
|
||||
r = (u8)((float)y + 1.371 * (float)cr);
|
||||
g = (u8)((float)y - 0.698 * (float)cr - 0.336 * (float)cb);
|
||||
b = (u8)((float)y + 1.732 * (float)cb);
|
||||
|
||||
return (u32)( r << 16 | g << 8 | b );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.50
|
||||
* Snes9x 1.50
|
||||
*
|
||||
* Nintendo Gamecube Screen Font Driver
|
||||
*
|
||||
@ -22,13 +22,14 @@
|
||||
|
||||
int FT_Init ();
|
||||
void setfontsize (int pixelsize);
|
||||
void DrawText (int x, int y, char *text);
|
||||
void legal ();
|
||||
void highlight (int on);
|
||||
void WaitButtonA ();
|
||||
void setfontcolour (u8 r, u8 g, u8 b);
|
||||
int RunMenu (char items[][20], int maxitems, char *title, int fontsize = 24);
|
||||
void DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsize = 24);
|
||||
void DrawText (int x, int y, char *text);
|
||||
void unpackbackdrop ();
|
||||
void Credits ();
|
||||
void RomInfo ();
|
||||
void WaitButtonA ();
|
||||
int RunMenu (char items[][50], int maxitems, char *title, int fontsize = 20, int x = -1);
|
||||
void DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize = 20, int x = -1);
|
||||
void WaitPrompt (char *msg);
|
||||
int WaitPromptChoice (char *msg, char* bmsg, char* amsg);
|
||||
void ShowAction (char *msg);
|
||||
|
@ -46,8 +46,6 @@ card_dir CardDir;
|
||||
card_file CardFile;
|
||||
card_stat CardStatus;
|
||||
|
||||
extern void uselessinquiry();
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Clear the savebuffer
|
||||
@ -89,15 +87,14 @@ CardFileExists (char *filename, int slot)
|
||||
* workarounds implemented for when the mount fails.
|
||||
* Returns the result of the last attempted CARD_Mount command.
|
||||
****************************************************************************/
|
||||
int MountCard(int cslot)
|
||||
{
|
||||
int MountCard(int cslot, bool8 silent)
|
||||
{
|
||||
int ret;
|
||||
int tries;
|
||||
|
||||
|
||||
|
||||
EXI_ProbeReset();
|
||||
|
||||
//Mount the card
|
||||
|
||||
// Mount the card
|
||||
ret = CARD_Mount (cslot, SysArea, NULL);
|
||||
|
||||
tries = 0;
|
||||
@ -108,17 +105,19 @@ int MountCard(int cslot)
|
||||
WaitPrompt((char*) "Replug card in slot A!");
|
||||
else
|
||||
WaitPrompt((char*) "Replug card in slot B!");
|
||||
|
||||
|
||||
ShowAction ((char*) "");
|
||||
ret = CARD_Mount (cslot, SysArea, NULL);
|
||||
tries++;
|
||||
}
|
||||
|
||||
|
||||
tries = 0;
|
||||
while ( tries < 5 && ret == CARD_ERROR_NOCARD )
|
||||
{
|
||||
EXI_ProbeReset ();
|
||||
ShowAction ((char*) "Mounting card...");
|
||||
|
||||
if(!silent)
|
||||
ShowAction ((char*) "Mounting card...");
|
||||
CARD_Unmount (cslot);
|
||||
usleep(500000); // wait half second
|
||||
ShowAction ((char*) "");
|
||||
@ -131,14 +130,17 @@ int MountCard(int cslot)
|
||||
while ( tries < 5 && ret == CARD_ERROR_UNLOCKED )
|
||||
{
|
||||
EXI_ProbeReset ();
|
||||
ShowAction ((char*) "Waiting for unlock...");
|
||||
|
||||
if(!silent)
|
||||
ShowAction ((char*) "Waiting for unlock...");
|
||||
usleep(500000); // wait half second
|
||||
ShowAction ((char*) "");
|
||||
if(!silent)
|
||||
ShowAction ((char*) "");
|
||||
usleep(500000); // wait half second
|
||||
ret = CARD_Probe(cslot);
|
||||
tries++;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -159,36 +161,36 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
|
||||
/*** Initialize Card System ***/
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("SNES", "00");
|
||||
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot);
|
||||
|
||||
CardError = MountCard(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
|
||||
if (!CardFileExists (filename, slot))
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt((char*) "Unable to open file for verify!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset (&CardFile, 0, sizeof (CardFile));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
|
||||
blocks = CardFile.len;
|
||||
|
||||
|
||||
if (blocks < SectorSize)
|
||||
blocks = SectorSize;
|
||||
|
||||
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
|
||||
if (blocks > (unsigned int)datasize)
|
||||
blocks = datasize;
|
||||
|
||||
|
||||
memset (verifbuffer, 0, VERIFBUFFERSIZE);
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
@ -202,16 +204,16 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
|
||||
WaitPrompt((char*) "File did not verify!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
|
||||
|
||||
sprintf (msg, "Verified %d of %d bytes", bytesread, blocks);
|
||||
ShowProgress (msg, bytesread, blocks);
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@ -219,7 +221,7 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
|
||||
WaitPrompt((char*) "Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt((char*) "Unable to Mount Slot B Memory Card!");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -240,35 +242,34 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
|
||||
/*** Initialize Card System ***/
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("SNES", "00");
|
||||
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot);
|
||||
|
||||
CardError = MountCard(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
|
||||
if (!CardFileExists (filename, slot))
|
||||
{
|
||||
if ( !silent )
|
||||
WaitPrompt((char*) "Unable to open file");
|
||||
WaitPrompt((char*) "Unable to open file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset (&CardFile, 0, sizeof (CardFile));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
|
||||
blocks = CardFile.len;
|
||||
|
||||
|
||||
if (blocks < SectorSize)
|
||||
blocks = SectorSize;
|
||||
|
||||
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
|
||||
memset (buf, 0, 0x22000);
|
||||
|
||||
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
@ -276,9 +277,12 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
|
||||
CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
|
||||
sprintf (msg, "Read %d of %d bytes", bytesread, blocks);
|
||||
ShowProgress (msg, bytesread, blocks);
|
||||
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (msg, "Read %d of %d bytes", bytesread, blocks);
|
||||
ShowProgress (msg, bytesread, blocks);
|
||||
}
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
@ -288,7 +292,7 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
|
||||
WaitPrompt((char*) "Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt((char*) "Unable to Mount Slot B Memory Card!");
|
||||
|
||||
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
@ -303,26 +307,26 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
char msg[80];
|
||||
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("SNES", "00");
|
||||
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot);
|
||||
|
||||
CardError = MountCard(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
{
|
||||
/*** Calculate number of blocks required ***/
|
||||
blocks = (datasize / SectorSize) * SectorSize;
|
||||
if (datasize % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
|
||||
/*** Does this file exist ? ***/
|
||||
if (CardFileExists (filename, slot))
|
||||
{
|
||||
@ -334,11 +338,11 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
WaitPrompt((char*) "Unable to open card file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// if ( (s32)blocks < CardFile.len ) /*** new data is shorter ***/
|
||||
// {
|
||||
// CARD_Close (&CardFile);
|
||||
//
|
||||
// CARD_Close (&CardFile);
|
||||
//
|
||||
// /*** Delete the existing longer file ***/
|
||||
// CardError = CARD_Delete(slot, filename);
|
||||
// if (CardError)
|
||||
@ -347,7 +351,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
// WaitPrompt((char*) "Unable to delete existing file!");
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*** Create new, shorter file ***/
|
||||
// CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||
// if (CardError)
|
||||
@ -356,14 +360,14 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
// WaitPrompt((char*) "Unable to create updated card file!");
|
||||
// return 0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// }
|
||||
// else
|
||||
|
||||
// else
|
||||
|
||||
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
|
||||
{
|
||||
CARD_Close (&CardFile);
|
||||
|
||||
|
||||
/*** Try to create temp file to check available space ***/
|
||||
CardError = CARD_Create (slot, "TEMPFILESNES9XGX201", blocks, &CardFile);
|
||||
if (CardError)
|
||||
@ -372,7 +376,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
WaitPrompt((char*) "Not enough space to update file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*** Delete the temporary file ***/
|
||||
CARD_Close (&CardFile);
|
||||
CardError = CARD_Delete(slot, "TEMPFILESNES9XGX201");
|
||||
@ -382,7 +386,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
WaitPrompt((char*) "Unable to delete temporary file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*** Delete the existing shorter file ***/
|
||||
CardError = CARD_Delete(slot, filename);
|
||||
if (CardError)
|
||||
@ -391,7 +395,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
WaitPrompt((char*) "Unable to delete existing file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*** Create new, longer file ***/
|
||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||
if (CardError)
|
||||
@ -409,14 +413,14 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
if (CardError)
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
if ( CardError = CARD_ERROR_INSSPACE )
|
||||
if ( CardError == CARD_ERROR_INSSPACE )
|
||||
WaitPrompt((char*) "Not enough space to create file!");
|
||||
else
|
||||
WaitPrompt((char*) "Unable to create card file!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** Now, have an open file handle, ready to send out the data ***/
|
||||
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
CardStatus.icon_addr = 0x0;
|
||||
@ -424,7 +428,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
CardStatus.icon_speed = 1;
|
||||
CardStatus.comment_addr = 2048;
|
||||
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
|
||||
|
||||
int byteswritten = 0;
|
||||
int bytesleft = blocks;
|
||||
while (bytesleft > 0)
|
||||
@ -434,14 +438,14 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
SectorSize, byteswritten);
|
||||
bytesleft -= SectorSize;
|
||||
byteswritten += SectorSize;
|
||||
|
||||
|
||||
sprintf (msg, "Wrote %d of %d bytes", byteswritten, blocks);
|
||||
ShowProgress (msg, byteswritten, blocks);
|
||||
}
|
||||
|
||||
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
|
||||
|
||||
if ( GCSettings.VerifySaves )
|
||||
{
|
||||
/*** Verify the written file, but only up to the length we wrote
|
||||
@ -463,129 +467,9 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
|
||||
WaitPrompt((char*) "Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt((char*) "Unable to Mount Slot B Memory Card!");
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Memory Card SRAM Load
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadSRAMFromMC (int slot, int silent)
|
||||
{
|
||||
char filename[MAXPATHLEN];
|
||||
int offset = 0;
|
||||
|
||||
ShowAction ((char*) "Loading SRAM from MC...");
|
||||
|
||||
// check for 'old' version of sram
|
||||
sprintf (filename, "%s.srm", Memory.ROMName); // Build old SRAM filename
|
||||
|
||||
offset = LoadBufferFromMC (savebuffer, slot, filename, silent); // load file
|
||||
|
||||
if (offset > 0) // old sram found
|
||||
{
|
||||
if (WaitPromptChoice ((char*)"Old SRAM found. Convert and delete?", (char*)"Cancel", (char*)"Do it"))
|
||||
{
|
||||
decodesavedata (offset);
|
||||
CARD_Delete (slot, filename); // delete old sram
|
||||
SaveSRAMToMC (slot, silent);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
/*** Build SRAM filename ***/
|
||||
sprintf (filename, "%s.srm", Memory.ROMFilename);
|
||||
|
||||
offset = LoadBufferFromMC (savebuffer, slot, filename, silent);
|
||||
|
||||
if ( offset > 0 )
|
||||
{
|
||||
decodesavedata (offset);
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filename, "Loaded %d bytes", offset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
S9xSoftReset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Memory Card SRAM Save
|
||||
****************************************************************************/
|
||||
void
|
||||
SaveSRAMToMC (int slot, int silent)
|
||||
{
|
||||
char filename[128];
|
||||
int datasize;
|
||||
int offset;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving SRAM to MC...");
|
||||
|
||||
/*** Build SRAM filename ***/
|
||||
sprintf (filename, "%s.srm", Memory.ROMFilename);
|
||||
|
||||
datasize = prepareMCsavedata ();
|
||||
offset = SaveBufferToMC (savebuffer, slot, filename, datasize, silent);
|
||||
|
||||
if ( (offset > 0) && (!silent))
|
||||
{
|
||||
sprintf (filename, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Memory Card Preferences Load
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadPrefsFromMC (int slot, int silent)
|
||||
{
|
||||
int offset;
|
||||
char msg[80];
|
||||
|
||||
ShowAction ((char*) "Loading Prefs from MC...");
|
||||
|
||||
offset = LoadBufferFromMC (savebuffer, slot, PREFS_FILE_NAME, silent);
|
||||
|
||||
if ( offset > 0 )
|
||||
{
|
||||
decodePrefsData ();
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (msg, "Loaded %d bytes", offset);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Memory Card Preferences Save
|
||||
****************************************************************************/
|
||||
void
|
||||
SavePrefsToMC (int slot, int silent)
|
||||
{
|
||||
int datasize;
|
||||
int offset;
|
||||
char msg[80];
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving Prefs to MC...");
|
||||
|
||||
datasize = preparePrefsData ();
|
||||
offset = SaveBufferToMC (savebuffer, slot, PREFS_FILE_NAME, datasize, silent);
|
||||
|
||||
if ( offset > 0 && !silent)
|
||||
{
|
||||
sprintf (msg, "Wrote %d bytes", offset);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,11 +21,6 @@ int VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize);
|
||||
|
||||
int LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent);
|
||||
int SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool8 silent);
|
||||
|
||||
void LoadSRAMFromMC (int slot, int silent);
|
||||
void SaveSRAMToMC (int slot, int silent);
|
||||
|
||||
void LoadPrefsFromMC (int slot, int silent);
|
||||
void SavePrefsToMC (int slot, int silent);
|
||||
int MountCard(int cslot, bool8 silent);
|
||||
|
||||
#endif
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "filesel.h"
|
||||
#include "ftfont.h"
|
||||
#include "smbload.h"
|
||||
#include "sdload.h"
|
||||
#include "mcsave.h"
|
||||
|
||||
extern "C"
|
||||
@ -98,12 +99,12 @@ NGCFreezeMemBuffer ()
|
||||
{
|
||||
int i;
|
||||
char buffer[1024];
|
||||
|
||||
|
||||
bufoffset = 0;
|
||||
|
||||
|
||||
S9xUpdateRTC ();
|
||||
S9xSRTCPreSaveState ();
|
||||
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
SoundData.channels[i].previous16[0] =
|
||||
@ -111,16 +112,16 @@ NGCFreezeMemBuffer ()
|
||||
SoundData.channels[i].previous16[1] =
|
||||
(int16) SoundData.channels[i].previous[1];
|
||||
}
|
||||
|
||||
|
||||
sprintf (buffer, "%s:%04d\n", SNAPSHOT_MAGIC, SNAPSHOT_VERSION);
|
||||
PutMem (buffer, strlen (buffer));
|
||||
sprintf (buffer, "NAM:%06d:%s%c", (int) strlen (Memory.ROMFilename) + 1,
|
||||
Memory.ROMFilename, 0);
|
||||
|
||||
|
||||
PutMem (buffer, strlen (buffer) + 1);
|
||||
|
||||
|
||||
NGCFreezeStruct ();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -131,162 +132,167 @@ NGCFreezeMemBuffer ()
|
||||
* Do freeze game for Nintendo Gamecube
|
||||
*/
|
||||
int
|
||||
NGCFreezeGame (int where, bool8 silent)
|
||||
NGCFreezeGame (int method, bool8 silent)
|
||||
{
|
||||
char filename[1024];
|
||||
SMBFILE smbfile;
|
||||
FILE *handle;
|
||||
int len = 0;
|
||||
int wrote = 0;
|
||||
int offset = 0;
|
||||
char msg[100];
|
||||
|
||||
if (where == 4)
|
||||
{
|
||||
/*** Freeze to SMB ***/
|
||||
sprintf (filename, "/%s/%s.frz", SNESSAVEDIR, Memory.ROMFilename);
|
||||
}
|
||||
else if (where == 2 || where == 3)
|
||||
{
|
||||
/*** Freeze to SDCard in slot A or slot B ***/
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename);
|
||||
#else
|
||||
/*** Until we have LFN on SD ... ***/
|
||||
sprintf (filename, "%s/%s/%08x.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
/*** Freeze to MC in slot A or slot B ***/
|
||||
sprintf (filename, "%s.snz", Memory.ROMFilename);
|
||||
}
|
||||
|
||||
S9xSetSoundMute (TRUE);
|
||||
S9xPrepareSoundForSnapshotSave (FALSE);
|
||||
|
||||
NGCFreezeMemBuffer ();
|
||||
|
||||
S9xPrepareSoundForSnapshotSave (TRUE);
|
||||
S9xSetSoundMute (FALSE);
|
||||
|
||||
if (where == 4) /*** SMB ***/
|
||||
{
|
||||
ConnectSMB ();
|
||||
|
||||
smbfile = SMB_Open (filename, SMB_OPEN_WRITING | SMB_DENY_NONE,
|
||||
SMB_OF_CREATE | SMB_OF_TRUNCATE);
|
||||
|
||||
if (smbfile)
|
||||
{
|
||||
char filename[1024];
|
||||
SMBFILE smbfile;
|
||||
FILE *handle;
|
||||
int len = 0;
|
||||
int wrote = 0;
|
||||
int offset = 0;
|
||||
char msg[100];
|
||||
|
||||
if (method == METHOD_SD) // SD
|
||||
{
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
}
|
||||
if (method == METHOD_USB) // USB
|
||||
{
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC Slot A or B
|
||||
{
|
||||
sprintf (filename, "%s.snz", Memory.ROMFilename);
|
||||
}
|
||||
else if (method == METHOD_SMB) // SMB
|
||||
{
|
||||
sprintf (filename, "/%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
}
|
||||
|
||||
S9xSetSoundMute (TRUE);
|
||||
S9xPrepareSoundForSnapshotSave (FALSE);
|
||||
|
||||
NGCFreezeMemBuffer ();
|
||||
|
||||
S9xPrepareSoundForSnapshotSave (TRUE);
|
||||
S9xSetSoundMute (FALSE);
|
||||
|
||||
if (method == METHOD_SD || method == METHOD_USB) // FAT devices
|
||||
{
|
||||
handle = fopen (filename, "wb");
|
||||
|
||||
if (handle > 0)
|
||||
{
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving freeze game...");
|
||||
|
||||
len = bufoffset;
|
||||
offset = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
if (len > 1024)
|
||||
wrote =
|
||||
SMB_Write ((char *) membuffer + offset, 1024, offset,
|
||||
smbfile);
|
||||
else
|
||||
wrote =
|
||||
SMB_Write ((char *) membuffer + offset, len, offset,
|
||||
smbfile);
|
||||
|
||||
offset += wrote;
|
||||
len -= wrote;
|
||||
}
|
||||
|
||||
SMB_Close (smbfile);
|
||||
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", bufoffset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char msg[100];
|
||||
sprintf(msg, "Couldn't save to SMB:\\%s\\", SNESSAVEDIR);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
else if (where == 2 || where == 3) /*** SDCard slot A or slot B ***/
|
||||
{
|
||||
handle = fopen (filename, "wb");
|
||||
|
||||
if (handle > 0)
|
||||
{
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving freeze game...");
|
||||
|
||||
len = fwrite (membuffer, 1, bufoffset, handle);
|
||||
fclose (handle);
|
||||
|
||||
if (len != bufoffset)
|
||||
WaitPrompt((char*) "Error writing freeze file");
|
||||
else if ( !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", bufoffset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(msg, "Couldn't save to %s/%s/", ROOTSDDIR, SNESSAVEDIR);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
else /*** MC in slot A or slot B ***/
|
||||
{
|
||||
len = fwrite (membuffer, 1, bufoffset, handle);
|
||||
fclose (handle);
|
||||
|
||||
if (len != bufoffset)
|
||||
WaitPrompt((char*) "Error writing freeze file");
|
||||
else if ( !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", bufoffset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(method == METHOD_SD)
|
||||
sprintf(msg, "Couldn't save to %s/%s/", ROOTSDDIR, GCSettings.SaveFolder);
|
||||
else
|
||||
sprintf(msg, "Couldn't save to %s/%s/", ROOTUSBDIR, GCSettings.SaveFolder);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTA) // MC Slot A or B
|
||||
{
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving freeze game...");
|
||||
|
||||
ClearSaveBuffer ();
|
||||
|
||||
/*** Copy in save icon ***/
|
||||
int offset = sizeof (saveicon);
|
||||
memcpy (savebuffer, saveicon, offset);
|
||||
|
||||
/*** And the freezecomment ***/
|
||||
sprintf (freezecomment[1], "%s", Memory.ROMName);
|
||||
memcpy (savebuffer + offset, freezecomment, 64);
|
||||
offset += 64;
|
||||
|
||||
/*** Zip and copy in the freeze ***/
|
||||
uLongf DestBuffSize = (uLongf) SAVEBUFFERSIZE;
|
||||
int err= compress2((Bytef*)(savebuffer+offset+8), (uLongf*)&DestBuffSize, (const Bytef*)membuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
||||
|
||||
if(err!=Z_OK)
|
||||
{
|
||||
sprintf (msg, "zip error %s ",zError(err));
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
ClearSaveBuffer ();
|
||||
|
||||
/*** Copy in save icon ***/
|
||||
int offset = sizeof (saveicon);
|
||||
memcpy (savebuffer, saveicon, offset);
|
||||
|
||||
/*** And the freezecomment ***/
|
||||
sprintf (freezecomment[1], "%s", Memory.ROMFilename);
|
||||
memcpy (savebuffer + offset, freezecomment, 64);
|
||||
offset += 64;
|
||||
|
||||
/*** Zip and copy in the freeze ***/
|
||||
uLongf DestBuffSize = (uLongf) SAVEBUFFERSIZE;
|
||||
int err= compress2((Bytef*)(savebuffer+offset+8), (uLongf*)&DestBuffSize, (const Bytef*)membuffer, (uLongf)bufoffset, Z_BEST_COMPRESSION);
|
||||
|
||||
if(err!=Z_OK)
|
||||
{
|
||||
sprintf (msg, "zip error %s ",zError(err));
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int zippedsize = (int)DestBuffSize;
|
||||
memcpy (savebuffer + offset, &zippedsize, 4);
|
||||
offset += 4;
|
||||
|
||||
offset += 4;
|
||||
|
||||
int decompressedsize = (int)bufoffset;
|
||||
memcpy (savebuffer + offset, &decompressedsize, 4);
|
||||
offset += 4;
|
||||
|
||||
offset += zippedsize;
|
||||
|
||||
int ret = SaveBufferToMC ( savebuffer, where, filename, offset, SILENT );
|
||||
if ( ret && !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", ret);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
|
||||
offset += 4;
|
||||
|
||||
offset += zippedsize;
|
||||
|
||||
int ret;
|
||||
|
||||
if(method == METHOD_MC_SLOTA)
|
||||
ret = SaveBufferToMC ( savebuffer, CARD_SLOTA, filename, offset, SILENT );
|
||||
else
|
||||
ret = SaveBufferToMC ( savebuffer, CARD_SLOTB, filename, offset, SILENT );
|
||||
|
||||
if ( ret && !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", ret);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
else if (method == METHOD_SMB) // SMB
|
||||
{
|
||||
ConnectSMB ();
|
||||
|
||||
smbfile = SMB_Open (filename, SMB_OPEN_WRITING | SMB_DENY_NONE,
|
||||
SMB_OF_CREATE | SMB_OF_TRUNCATE);
|
||||
|
||||
if (smbfile)
|
||||
{
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving freeze game...");
|
||||
|
||||
len = bufoffset;
|
||||
offset = 0;
|
||||
while (len > 0)
|
||||
{
|
||||
if (len > 1024)
|
||||
wrote =
|
||||
SMB_Write ((char *) membuffer + offset, 1024, offset,
|
||||
smbfile);
|
||||
else
|
||||
wrote =
|
||||
SMB_Write ((char *) membuffer + offset, len, offset,
|
||||
smbfile);
|
||||
|
||||
offset += wrote;
|
||||
len -= wrote;
|
||||
}
|
||||
|
||||
SMB_Close (smbfile);
|
||||
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filename, "Written %d bytes", bufoffset);
|
||||
WaitPrompt (filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char msg[100];
|
||||
sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder);
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -331,7 +337,7 @@ NGCUnFreezeBlock (char *name, uint8 * block, int size)
|
||||
* NGCUnfreezeGame
|
||||
*/
|
||||
int
|
||||
NGCUnfreezeGame (int from, bool8 silent)
|
||||
NGCUnfreezeGame (int method, bool8 silent)
|
||||
{
|
||||
char filename[1024];
|
||||
SMBFILE smbfile;
|
||||
@ -339,151 +345,156 @@ NGCUnfreezeGame (int from, bool8 silent)
|
||||
int read = 0;
|
||||
int offset = 0;
|
||||
char msg[80];
|
||||
|
||||
|
||||
bufoffset = 0;
|
||||
|
||||
if (from == 4)
|
||||
{
|
||||
/*** From SMB ***/
|
||||
sprintf (filename, "\\%s\\%s.frz", SNESSAVEDIR, Memory.ROMFilename);
|
||||
ConnectSMB ();
|
||||
|
||||
/*** Read the file into memory ***/
|
||||
smbfile =
|
||||
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
||||
|
||||
if (smbfile)
|
||||
{
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
while ((read =
|
||||
SMB_Read ((char *) membuffer + offset, 1024, offset,
|
||||
smbfile)) > 0)
|
||||
offset += read;
|
||||
|
||||
SMB_Close (smbfile);
|
||||
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( !silent )
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
if (method == METHOD_SD || method == METHOD_USB) // SD & USB
|
||||
{
|
||||
if(method == METHOD_SD)
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
else
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
|
||||
handle = fopen (filename, "rb");
|
||||
|
||||
if (handle > 0)
|
||||
{
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
|
||||
offset = 0;
|
||||
/*** Usual chunks into memory ***/
|
||||
while ((read = fread (membuffer + offset, 1, 2048, handle)) > 0)
|
||||
offset += read;
|
||||
|
||||
fclose (handle);
|
||||
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else if (from == 2 || from == 3) /*** From SD slot A or slot B ***/
|
||||
{
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename);
|
||||
#else
|
||||
/*** From SDCard ***/
|
||||
sprintf (filename, "%s/%s/%08x.frz", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32);
|
||||
#endif
|
||||
|
||||
handle = fopen (filename, "rb");
|
||||
|
||||
if (handle > 0)
|
||||
{
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
|
||||
offset = 0;
|
||||
/*** Usual chunks into memory ***/
|
||||
while ((read = fread (membuffer + offset, 1, 2048, handle)) >
|
||||
0)
|
||||
offset += read;
|
||||
|
||||
fclose (handle);
|
||||
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( !silent )
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC in slot A or slot B
|
||||
{
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
|
||||
sprintf (filename, "%s.snz", Memory.ROMFilename);
|
||||
|
||||
int ret = 0;
|
||||
|
||||
if(method == METHOD_MC_SLOTA)
|
||||
LoadBufferFromMC ( savebuffer, CARD_SLOTA, filename, silent );
|
||||
else
|
||||
LoadBufferFromMC ( savebuffer, CARD_SLOTB, filename, silent );
|
||||
|
||||
if ( ret )
|
||||
{
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
|
||||
// skip the saveicon and comment
|
||||
offset = (sizeof(saveicon) + 64);
|
||||
uLongf zipsize = 0;
|
||||
uLongf decompressedsize = 0;
|
||||
|
||||
memcpy (&zipsize, savebuffer+offset, 4);
|
||||
offset += 4;
|
||||
|
||||
memcpy (&decompressedsize, savebuffer+offset, 4);
|
||||
offset += 4;
|
||||
|
||||
memset(membuffer, 0, MEMBUFFER);
|
||||
|
||||
uLongf DestBuffSize = MEMBUFFER;
|
||||
int err= uncompress((Bytef*)membuffer, (uLongf*)&DestBuffSize, (const Bytef*)(savebuffer + offset), zipsize);
|
||||
|
||||
if ( err!=Z_OK )
|
||||
{
|
||||
sprintf (msg, "unzip error %s ",zError(err));
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( DestBuffSize != decompressedsize )
|
||||
{
|
||||
WaitPrompt((char*) "Unzipped size doesn't match expected size!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
else /*** From MC in slot A or slot B ***/
|
||||
else if (method == METHOD_SMB) // Network (SMB)
|
||||
{
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
|
||||
sprintf (filename, "%s.snz", Memory.ROMFilename);
|
||||
|
||||
int ret = LoadBufferFromMC ( savebuffer, from, filename, silent );
|
||||
if ( ret )
|
||||
{
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
|
||||
// skip the saveicon and comment
|
||||
offset = (sizeof(saveicon) + 64);
|
||||
uLongf zipsize = 0;
|
||||
uLongf decompressedsize = 0;
|
||||
|
||||
memcpy (&zipsize, savebuffer+offset, 4);
|
||||
offset += 4;
|
||||
|
||||
memcpy (&decompressedsize, savebuffer+offset, 4);
|
||||
offset += 4;
|
||||
|
||||
memset(membuffer, 0, MEMBUFFER);
|
||||
sprintf (filename, "\\%s\\%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
ConnectSMB ();
|
||||
|
||||
uLongf DestBuffSize = MEMBUFFER;
|
||||
int err= uncompress((Bytef*)membuffer, (uLongf*)&DestBuffSize, (const Bytef*)(savebuffer + offset), zipsize);
|
||||
|
||||
if ( err!=Z_OK )
|
||||
{
|
||||
sprintf (msg, "unzip error %s ",zError(err));
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
/*** Read the file into memory ***/
|
||||
smbfile =
|
||||
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
||||
|
||||
if ( DestBuffSize != decompressedsize )
|
||||
{
|
||||
WaitPrompt((char*) "Unzipped size doesn't match expected size!");
|
||||
return 0;
|
||||
}
|
||||
if (smbfile)
|
||||
{
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Loading freeze file...");
|
||||
while ((read =
|
||||
SMB_Read ((char *) membuffer + offset, 1024, offset,
|
||||
smbfile)) > 0)
|
||||
offset += read;
|
||||
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( !silent )
|
||||
{
|
||||
sprintf(msg, "Couldn't load from MC slot %s", (from ? "B" : "A"));
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
SMB_Close (smbfile);
|
||||
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Unpacking freeze file");
|
||||
if (S9xUnfreezeGame ("AGAME") != SUCCESS)
|
||||
{
|
||||
WaitPrompt((char*) "Error thawing");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( !silent )
|
||||
{
|
||||
WaitPrompt((char*) "No freeze file found");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
return 0; // if we reached here, nothing was done!
|
||||
}
|
||||
|
||||
|
||||
void quickLoadFreeze (bool8 silent)
|
||||
{
|
||||
if ( QUICK_SAVE_SLOT >= 0 )
|
||||
NGCUnfreezeGame ( QUICK_SAVE_SLOT, silent );
|
||||
NGCUnfreezeGame ( GCSettings.SaveMethod, silent );
|
||||
}
|
||||
|
||||
|
||||
void quickSaveFreeze (bool8 silent)
|
||||
{
|
||||
if ( QUICK_SAVE_SLOT >= 0 )
|
||||
NGCFreezeGame ( QUICK_SAVE_SLOT, silent );
|
||||
NGCFreezeGame ( GCSettings.SaveMethod, silent );
|
||||
}
|
||||
|
||||
|
||||
|
@ -25,8 +25,8 @@ typedef struct
|
||||
}
|
||||
MEMFILE;
|
||||
|
||||
int NGCFreezeGame (int where, bool8 silent);
|
||||
int NGCUnfreezeGame (int from, bool8 silent);
|
||||
int NGCFreezeGame (int method, bool8 silent);
|
||||
int NGCUnfreezeGame (int method, bool8 silent);
|
||||
|
||||
void quickLoadFreeze (bool8 silent);
|
||||
void quickSaveFreeze (bool8 silent);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,6 @@
|
||||
|
||||
#define _NGCMENU_
|
||||
|
||||
void mainmenu ();
|
||||
void mainmenu (int selectedMenu);
|
||||
|
||||
#endif
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "mcsave.h"
|
||||
#include "sdload.h"
|
||||
#include "smbload.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
extern int currconfig[4];
|
||||
@ -31,14 +32,15 @@ extern unsigned int wmpadmap[];
|
||||
extern unsigned int ccpadmap[];
|
||||
extern unsigned int ncpadmap[];
|
||||
|
||||
#define PREFSVERSTRING "Snes9x GX 004a Prefs"
|
||||
#define PREFS_FILE_NAME "snes9xGx.prf"
|
||||
#define PREFSVERSTRING "Snes9x GX 005 Prefs"
|
||||
|
||||
char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} };
|
||||
|
||||
/****************************************************************************
|
||||
* Prepare Preferences Data
|
||||
*
|
||||
* This sets up the save buffer for saving to a memory card.
|
||||
* This sets up the save buffer for saving.
|
||||
****************************************************************************/
|
||||
int
|
||||
preparePrefsData ()
|
||||
@ -64,7 +66,7 @@ preparePrefsData ()
|
||||
size = sizeof (GCSettings);
|
||||
memcpy (savebuffer + offset, &GCSettings, size);
|
||||
offset += size;
|
||||
|
||||
|
||||
/*** Save buttonmaps ***/
|
||||
size = sizeof (unsigned int) *12; // this size applies to all padmaps
|
||||
memcpy (savebuffer + offset, &gcpadmap, size);
|
||||
@ -75,7 +77,7 @@ preparePrefsData ()
|
||||
offset += size;
|
||||
memcpy (savebuffer + offset, &ncpadmap, size);
|
||||
offset += size;
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -83,71 +85,157 @@ preparePrefsData ()
|
||||
/****************************************************************************
|
||||
* Decode Preferences Data
|
||||
****************************************************************************/
|
||||
void
|
||||
bool
|
||||
decodePrefsData ()
|
||||
{
|
||||
int offset;
|
||||
char prefscomment[32];
|
||||
int size;
|
||||
|
||||
offset = sizeof (saveicon);
|
||||
memcpy (prefscomment, savebuffer + offset, 32);
|
||||
|
||||
int offset;
|
||||
char prefscomment[32];
|
||||
int size;
|
||||
|
||||
offset = sizeof (saveicon);
|
||||
memcpy (prefscomment, savebuffer + offset, 32);
|
||||
|
||||
if ( strcmp (prefscomment, PREFSVERSTRING) == 0 )
|
||||
{
|
||||
offset += 64;
|
||||
memcpy (&Settings, savebuffer + offset, sizeof (Settings));
|
||||
offset += sizeof (Settings);
|
||||
memcpy (&GCSettings, savebuffer + offset, sizeof (GCSettings));
|
||||
offset += sizeof (GCSettings);
|
||||
// load padmaps (order important)
|
||||
size = sizeof (unsigned int) *12;
|
||||
memcpy (&gcpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&wmpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&ccpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&ncpadmap, savebuffer + offset, size);
|
||||
offset += 64;
|
||||
memcpy (&Settings, savebuffer + offset, sizeof (Settings));
|
||||
offset += sizeof (Settings);
|
||||
memcpy (&GCSettings, savebuffer + offset, sizeof (GCSettings));
|
||||
offset += sizeof (GCSettings);
|
||||
// load padmaps (order important)
|
||||
size = sizeof (unsigned int) *12;
|
||||
memcpy (&gcpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&wmpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&ccpadmap, savebuffer + offset, size);
|
||||
offset += size;
|
||||
memcpy (&ncpadmap, savebuffer + offset, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
WaitPrompt((char*) "Preferences reset - check settings!");
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void quickLoadPrefs (bool8 silent)
|
||||
|
||||
/****************************************************************************
|
||||
* Save Preferences
|
||||
****************************************************************************/
|
||||
bool
|
||||
SavePrefs (int method, bool silent)
|
||||
{
|
||||
switch ( QUICK_SAVE_SLOT )
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
|
||||
datasize = preparePrefsData ();
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving preferences...");
|
||||
|
||||
if(method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
case CARD_SLOTA:
|
||||
case CARD_SLOTB:
|
||||
LoadPrefsFromMC(QUICK_SAVE_SLOT, silent);
|
||||
break;
|
||||
|
||||
case CARD_SLOTA+2:
|
||||
case CARD_SLOTB+2:
|
||||
LoadPrefsFromSD(silent);
|
||||
break;
|
||||
|
||||
case CARD_SLOTA+4:
|
||||
LoadPrefsFromSMB(silent);
|
||||
break;
|
||||
if(method == METHOD_SD)
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
else
|
||||
sprintf (filepath, "%s/%s/%s", ROOTUSBDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
offset = SaveBufferToFAT (filepath, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf (filepath, "%s\\%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
offset = SaveBufferToSMB (filepath, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
{
|
||||
offset = SaveBufferToMC (savebuffer, CARD_SLOTA, PREFS_FILE_NAME, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
{
|
||||
offset = SaveBufferToMC (savebuffer, CARD_SLOTB, PREFS_FILE_NAME, datasize, silent);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
retval = decodePrefsData ();
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filepath);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void quickSavePrefs (bool8 silent)
|
||||
/****************************************************************************
|
||||
* Load Preferences
|
||||
****************************************************************************/
|
||||
bool
|
||||
LoadPrefs (int method, bool silent)
|
||||
{
|
||||
switch ( QUICK_SAVE_SLOT )
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(); // we use 'Save' folder because preferences need R/W
|
||||
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
|
||||
if ( !silent )
|
||||
ShowAction ((char*) "Loading preferences...");
|
||||
|
||||
if(method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
case CARD_SLOTA:
|
||||
case CARD_SLOTB:
|
||||
SavePrefsToMC(QUICK_SAVE_SLOT, silent);
|
||||
break;
|
||||
case CARD_SLOTA+2:
|
||||
case CARD_SLOTB+2:
|
||||
SavePrefsToSD(silent);
|
||||
break;
|
||||
case CARD_SLOTA+4:
|
||||
SavePrefsToSMB(silent);
|
||||
break;
|
||||
if(method == METHOD_SD)
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
else
|
||||
sprintf (filepath, "%s/%s/%s", ROOTUSBDIR, GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
offset = LoadBufferFromFAT (filepath, silent);
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf (filepath, "%s\\%s", GCSettings.SaveFolder, PREFS_FILE_NAME);
|
||||
LoadBufferFromSMB (filepath, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
{
|
||||
offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, PREFS_FILE_NAME, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
{
|
||||
offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, PREFS_FILE_NAME, silent);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
retval = decodePrefsData ();
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
}
|
||||
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,10 +9,9 @@
|
||||
* Preferences save/load preferences utilities
|
||||
****************************************************************************/
|
||||
|
||||
#define PREFS_FILE_NAME "snes9xGx.prf"
|
||||
|
||||
int preparePrefsData ();
|
||||
void decodePrefsData ();
|
||||
|
||||
void quickLoadPrefs (bool8 silent);
|
||||
void quickSavePrefs (bool8 silent);
|
||||
bool decodePrefsData ();
|
||||
bool SavePrefs (int method, bool silent);
|
||||
bool LoadPrefs (int method, bool silent);
|
||||
bool quickLoadPrefs (bool8 silent);
|
||||
bool quickSavePrefs (bool8 silent);
|
||||
|
@ -133,8 +133,8 @@
|
||||
Snes9x homepage: http://www.snes9x.com
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@ -162,81 +162,90 @@
|
||||
void
|
||||
DefaultSettings ()
|
||||
{
|
||||
/*** Default ALL to false ***/
|
||||
memset (&Settings, 0, sizeof (Settings));
|
||||
/************** GameCube/Wii Settings *********************/
|
||||
GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
||||
sprintf (GCSettings.LoadFolder,"snes9x/roms"); // Path to game files
|
||||
GCSettings.SaveMethod = METHOD_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
||||
sprintf (GCSettings.SaveFolder,"snes9x/saves"); // Path to save files
|
||||
GCSettings.AutoLoad = 1;
|
||||
GCSettings.AutoSave = 1;
|
||||
|
||||
strncpy (GCSettings.gcip, GC_IP, 15);
|
||||
strncpy (GCSettings.gwip, GW_IP, 15);
|
||||
strncpy (GCSettings.mask, MASK, 15);
|
||||
strncpy (GCSettings.smbip, SMB_IP, 15);
|
||||
strncpy (GCSettings.smbuser, SMB_USER, 19);
|
||||
strncpy (GCSettings.smbpwd, SMB_PWD, 19);
|
||||
strncpy (GCSettings.smbgcid, SMB_GCID, 19);
|
||||
strncpy (GCSettings.smbsvid, SMB_SVID, 19);
|
||||
strncpy (GCSettings.smbshare, SMB_SHARE, 19);
|
||||
|
||||
GCSettings.NGCZoom = 0;
|
||||
GCSettings.VerifySaves = 0;
|
||||
GCSettings.render = 0;
|
||||
GCSettings.Superscope = 0;
|
||||
GCSettings.Mouse = 0;
|
||||
|
||||
/****************** SNES9x Settings ***********************/
|
||||
|
||||
/*** Default ALL to false ***/
|
||||
memset (&Settings, 0, sizeof (Settings));
|
||||
|
||||
/*** General ***/
|
||||
Settings.MouseMaster = false;
|
||||
Settings.SuperScopeMaster = false;
|
||||
Settings.MultiPlayer5Master = false;
|
||||
Settings.JustifierMaster = true;
|
||||
Settings.ShutdownMaster = false;
|
||||
Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier
|
||||
|
||||
/* Eke-Eke: specific to snes9x 1.51 */
|
||||
// Settings.BlockInvalidVRAMAccess = true;
|
||||
// Settings.HDMATimingHack = 100;
|
||||
|
||||
|
||||
Settings.MouseMaster = false;
|
||||
Settings.SuperScopeMaster = false;
|
||||
Settings.MultiPlayer5Master = false;
|
||||
Settings.JustifierMaster = true;
|
||||
Settings.ShutdownMaster = false;
|
||||
Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier
|
||||
Settings.ApplyCheats = true;
|
||||
|
||||
/* Eke-Eke: specific to snes9x 1.51 */
|
||||
// Settings.BlockInvalidVRAMAccess = true;
|
||||
// Settings.HDMATimingHack = 100;
|
||||
|
||||
/*** Sound defaults. On GC this is 32Khz/16bit/Stereo/InterpolatedSound ***/
|
||||
Settings.APUEnabled = true;
|
||||
Settings.NextAPUEnabled = true;
|
||||
Settings.SoundPlaybackRate = 32000;
|
||||
Settings.Stereo = true;
|
||||
Settings.SixteenBitSound = true;
|
||||
Settings.SoundEnvelopeHeightReading = true;
|
||||
Settings.DisableSampleCaching = true;
|
||||
Settings.InterpolatedSound = true;
|
||||
Settings.ReverseStereo = false;
|
||||
Settings.APUEnabled = true;
|
||||
Settings.NextAPUEnabled = true;
|
||||
Settings.SoundPlaybackRate = 32000;
|
||||
Settings.Stereo = true;
|
||||
Settings.SixteenBitSound = true;
|
||||
Settings.SoundEnvelopeHeightReading = true;
|
||||
Settings.DisableSampleCaching = true;
|
||||
Settings.InterpolatedSound = true;
|
||||
Settings.ReverseStereo = false;
|
||||
|
||||
/*** Graphics ***/
|
||||
Settings.Transparency = true;
|
||||
Settings.SupportHiRes = true;
|
||||
Settings.SkipFrames = 10;
|
||||
Settings.TurboSkipFrames = 19;
|
||||
Settings.DisplayFrameRate = false;
|
||||
// Settings.AutoDisplayMessages = 1; /*** eke-eke snes9x 1.51 ***/
|
||||
|
||||
/* Eke-Eke: frame timings in 50hz and 60hz cpu mode */
|
||||
Settings.FrameTimePAL = 20000;
|
||||
Settings.FrameTimeNTSC = 16667;
|
||||
Settings.Transparency = true;
|
||||
Settings.SupportHiRes = true;
|
||||
Settings.SkipFrames = 10;
|
||||
Settings.TurboSkipFrames = 19;
|
||||
Settings.DisplayFrameRate = false;
|
||||
// Settings.AutoDisplayMessages = 1; /*** eke-eke snes9x 1.51 ***/
|
||||
|
||||
/* Eke-Eke: frame timings in 50hz and 60hz cpu mode */
|
||||
Settings.FrameTimePAL = 20000;
|
||||
Settings.FrameTimeNTSC = 16667;
|
||||
|
||||
/*** SDD1 - Star Ocean Returns -;) ***/
|
||||
Settings.SDD1Pack = true;
|
||||
|
||||
GCSettings.AutoLoad = 1;
|
||||
GCSettings.AutoSave = 1;
|
||||
|
||||
strncpy (GCSettings.gcip, GC_IP, 15);
|
||||
strncpy (GCSettings.gwip, GW_IP, 15);
|
||||
strncpy (GCSettings.mask, MASK, 15);
|
||||
strncpy (GCSettings.smbip, SMB_IP, 15);
|
||||
strncpy (GCSettings.smbuser, SMB_USER, 19);
|
||||
strncpy (GCSettings.smbpwd, SMB_PWD, 19);
|
||||
strncpy (GCSettings.smbgcid, SMB_GCID, 19);
|
||||
strncpy (GCSettings.smbsvid, SMB_SVID, 19);
|
||||
strncpy (GCSettings.smbshare, SMB_SHARE, 19);
|
||||
|
||||
GCSettings.NGCZoom = 0;
|
||||
GCSettings.VerifySaves = 0;
|
||||
GCSettings.render = 0;
|
||||
GCSettings.Superscope = 0;
|
||||
GCSettings.Mouse = 0;
|
||||
|
||||
Settings.ForceNTSC = 0;
|
||||
Settings.ForcePAL = 0;
|
||||
Settings.ForceHiROM = 0;
|
||||
Settings.ForceLoROM = 0;
|
||||
Settings.ForceHeader = 0;
|
||||
Settings.ForceNoHeader = 0;
|
||||
Settings.ForceTransparency = 0;
|
||||
Settings.ForceInterleaved = 0;
|
||||
Settings.ForceInterleaved2 = 0;
|
||||
Settings.ForceInterleaveGD24 = 0;
|
||||
Settings.ForceNotInterleaved = 0;
|
||||
Settings.ForceNoSuperFX = 0;
|
||||
Settings.ForceSuperFX = 0;
|
||||
Settings.ForceDSP1 = 0;
|
||||
Settings.ForceNoDSP1 = 0;
|
||||
|
||||
Settings.SDD1Pack = true;
|
||||
|
||||
Settings.ForceNTSC = 0;
|
||||
Settings.ForcePAL = 0;
|
||||
Settings.ForceHiROM = 0;
|
||||
Settings.ForceLoROM = 0;
|
||||
Settings.ForceHeader = 0;
|
||||
Settings.ForceNoHeader = 0;
|
||||
Settings.ForceTransparency = 0;
|
||||
Settings.ForceInterleaved = 0;
|
||||
Settings.ForceInterleaved2 = 0;
|
||||
Settings.ForceInterleaveGD24 = 0;
|
||||
Settings.ForceNotInterleaved = 0;
|
||||
Settings.ForceNoSuperFX = 0;
|
||||
Settings.ForceSuperFX = 0;
|
||||
Settings.ForceDSP1 = 0;
|
||||
Settings.ForceNoDSP1 = 0;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
*
|
||||
* sdload.cpp
|
||||
*
|
||||
* Load ROMS from SD Card
|
||||
* Load ROMS from FAT
|
||||
****************************************************************************/
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
@ -22,20 +22,75 @@
|
||||
#include "filesel.h"
|
||||
#include "sram.h"
|
||||
#include "preferences.h"
|
||||
#include "snes9xGx.h"
|
||||
|
||||
#include <zlib.h>
|
||||
extern unsigned char savebuffer[];
|
||||
extern char output[16384];
|
||||
FILE * filehandle;
|
||||
|
||||
char currSDdir[MAXPATHLEN];
|
||||
char currFATdir[MAXPATHLEN];
|
||||
extern int offset;
|
||||
extern int selection;
|
||||
|
||||
extern int loadtype;
|
||||
|
||||
extern FILEENTRIES filelist[MAXFILES];
|
||||
|
||||
/****************************************************************************
|
||||
* fat_is_mounted
|
||||
* to check whether FAT media are detected.
|
||||
****************************************************************************/
|
||||
|
||||
bool fat_is_mounted(PARTITION_INTERFACE partition) {
|
||||
char prefix[] = "fatX:/";
|
||||
prefix[3] = partition + '0';
|
||||
DIR_ITER *dir = diropen(prefix);
|
||||
if (dir) {
|
||||
dirclose(dir);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* fat_enable_readahead_all
|
||||
****************************************************************************/
|
||||
|
||||
void fat_enable_readahead_all() {
|
||||
int i;
|
||||
for (i=1; i <= 4; ++i) {
|
||||
if (fat_is_mounted((PARTITION_INTERFACE)i)) fatEnableReadAhead((PARTITION_INTERFACE)i, 64, 128);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* fat_remount
|
||||
****************************************************************************/
|
||||
|
||||
bool fat_remount(PARTITION_INTERFACE partition) {
|
||||
//ShowAction("remounting...");
|
||||
/* // removed to make usb work...
|
||||
if (fat_is_mounted(partition))
|
||||
{
|
||||
fatUnmount(partition);
|
||||
}
|
||||
*/
|
||||
|
||||
fatMountNormalInterface(partition, 8);
|
||||
fatSetDefaultInterface(partition);
|
||||
//fatEnableReadAhead(partition, 64, 128);
|
||||
|
||||
if (fat_is_mounted(partition))
|
||||
{
|
||||
//ShowAction("remount successful.");
|
||||
sleep(1);
|
||||
return 1;
|
||||
} else {
|
||||
ShowAction("FAT mount failed.");
|
||||
sleep(1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* FileSortCallback
|
||||
*
|
||||
@ -44,7 +99,7 @@ extern FILEENTRIES filelist[MAXFILES];
|
||||
* ..
|
||||
* <dirs>
|
||||
* <files>
|
||||
***************************************************************************/
|
||||
***************************************************************************/
|
||||
static int FileSortCallback(const void *f1, const void *f2)
|
||||
{
|
||||
/* Special case for implicit directories */
|
||||
@ -55,101 +110,113 @@ static int FileSortCallback(const void *f1, const void *f2)
|
||||
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 FAT (sdcard, usb) curent directory name
|
||||
***************************************************************************/
|
||||
int updateFATdirname()
|
||||
* Update FATCARD curent directory name
|
||||
***************************************************************************/
|
||||
int updateFATdirname(int method)
|
||||
{
|
||||
int size=0;
|
||||
char *test;
|
||||
char temp[1024];
|
||||
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",currSDdir);
|
||||
test = strtok(temp,"/");
|
||||
while (test != NULL) {
|
||||
size = strlen(test);
|
||||
test = strtok(NULL,"/");
|
||||
}
|
||||
|
||||
/* remove last subdirectory name */
|
||||
size = strlen(currSDdir) - size - 1;
|
||||
currSDdir[size] = 0;
|
||||
/* 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,"/");
|
||||
}
|
||||
|
||||
/* handles root name */
|
||||
if (strcmp(currSDdir, "/") == 0)
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
else /* Open a directory */
|
||||
{
|
||||
/* test new directory namelength */
|
||||
if ((strlen(currSDdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
/* 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/..", SNESROMDIR);
|
||||
if (strcmp(currSDdir, temp) == 0)
|
||||
sprintf(currSDdir,"%s",ROOTSDDIR);
|
||||
|
||||
sprintf(temp, "/%s/..", GCSettings.LoadFolder);
|
||||
if (strcmp(currFATdir, temp) == 0)
|
||||
{
|
||||
if(method == METHOD_SD)
|
||||
sprintf(currFATdir,"%s",ROOTSDDIR);
|
||||
else
|
||||
sprintf(currFATdir,"%s",ROOTUSBDIR);
|
||||
}
|
||||
|
||||
/* update current directory name */
|
||||
sprintf(currSDdir, "%s/%s",currSDdir, filelist[selection].filename);
|
||||
sprintf(currFATdir, "%s/%s",currFATdir, filelist[selection].filename);
|
||||
return 1;
|
||||
} else {
|
||||
WaitPrompt((char*)"Dirname is too long !");
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*)"Dirname is too long !");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************
|
||||
* Browse FAT (sdcard, usb) subdirectories
|
||||
***************************************************************************/
|
||||
int parseFATdirectory() {
|
||||
* Browse FAT subdirectories
|
||||
***************************************************************************/
|
||||
int parseFATdirectory(int method)
|
||||
{
|
||||
int nbfiles = 0;
|
||||
DIR_ITER *sddir;
|
||||
DIR_ITER *fatdir;
|
||||
char filename[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
char msg[128];
|
||||
|
||||
|
||||
/* initialize selection */
|
||||
selection = offset = 0;
|
||||
|
||||
/* open the directory */
|
||||
sddir = diropen(currSDdir);
|
||||
if (sddir == NULL) {
|
||||
/*** if we can't open the previous dir, open root dir ***/
|
||||
if (loadtype == LOAD_USB)
|
||||
sprintf(currSDdir,"fat4:/");
|
||||
else // LOAD_SDC
|
||||
//sprintf(currSDdir,"%s",ROOTSDDIR);
|
||||
sprintf(currSDdir,"fat3:/");
|
||||
|
||||
sddir = diropen(currSDdir);
|
||||
/* open the directory */
|
||||
fatdir = diropen(currFATdir);
|
||||
if (fatdir == NULL)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", currFATdir);
|
||||
WaitPrompt(msg);
|
||||
if (sddir == NULL) {
|
||||
sprintf(msg, "Error opening %s", currSDdir);
|
||||
|
||||
// if we can't open the previous dir, open root dir
|
||||
if(method == METHOD_SD)
|
||||
sprintf(currFATdir,"%s",ROOTSDDIR);
|
||||
else
|
||||
sprintf(currFATdir,"%s",ROOTUSBDIR);
|
||||
|
||||
fatdir = diropen(currFATdir);
|
||||
|
||||
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(sddir,filename,&filestat) == 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);
|
||||
@ -159,23 +226,22 @@ int parseFATdirectory() {
|
||||
nbfiles++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*** close directory ***/
|
||||
dirclose(sddir);
|
||||
|
||||
dirclose(fatdir);
|
||||
|
||||
/* Sort the file list */
|
||||
qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback);
|
||||
|
||||
|
||||
return nbfiles;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* LoadSDFile
|
||||
* LoadFATFile
|
||||
****************************************************************************/
|
||||
extern bool haveSDdir;
|
||||
extern bool haveUSBdir;
|
||||
extern int haveFATdir;
|
||||
int
|
||||
LoadSDFile (char *filename, int length)
|
||||
LoadFATFile (char *filename, int length)
|
||||
{
|
||||
char zipbuffer[2048];
|
||||
char filepath[MAXPATHLEN];
|
||||
@ -186,16 +252,15 @@ LoadSDFile (char *filename, int length)
|
||||
rbuffer = (unsigned char *) Memory.ROM;
|
||||
|
||||
/* Check filename length */
|
||||
if ((strlen(currSDdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
sprintf(filepath, "%s/%s",currSDdir,filelist[selection].filename);
|
||||
if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
|
||||
sprintf(filepath, "%s/%s",currFATdir,filelist[selection].filename);
|
||||
else
|
||||
{
|
||||
WaitPrompt((char*) "Maximum Filename Length reached !");
|
||||
haveSDdir = 0; // reset everything before next access
|
||||
haveUSBdir = 0;
|
||||
WaitPrompt((char*) "Maximum Filename Length reached !");
|
||||
haveFATdir = 0; // reset everything before next access
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
handle = fopen (filepath, "rb");
|
||||
if (handle > 0)
|
||||
{
|
||||
@ -204,7 +269,7 @@ LoadSDFile (char *filename, int length)
|
||||
if (IsZipFile (zipbuffer))
|
||||
{
|
||||
/*** Unzip the ROM ***/
|
||||
size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from SD
|
||||
size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from FAT
|
||||
|
||||
fclose (handle);
|
||||
return size;
|
||||
@ -213,17 +278,17 @@ LoadSDFile (char *filename, int length)
|
||||
else
|
||||
{
|
||||
/*** 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
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
return length;
|
||||
}
|
||||
}
|
||||
@ -236,20 +301,18 @@ LoadSDFile (char *filename, int length)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Load savebuffer from SD card file
|
||||
* Load savebuffer from FAT file
|
||||
****************************************************************************/
|
||||
int
|
||||
LoadBufferFromSD (char *filepath, bool silent)
|
||||
LoadBufferFromFAT (char *filepath, bool silent)
|
||||
{
|
||||
FILE *handle;
|
||||
FILE *handle;
|
||||
int offset = 0;
|
||||
int read = 0;
|
||||
|
||||
|
||||
handle = fopen (filepath, "rb");
|
||||
|
||||
|
||||
if (handle <= 0)
|
||||
{
|
||||
if ( !silent )
|
||||
@ -260,33 +323,32 @@ LoadBufferFromSD (char *filepath, bool silent)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
memset (savebuffer, 0, 0x22000);
|
||||
|
||||
|
||||
/*** This is really nice, just load the file and decode it ***/
|
||||
while ((read = fread (savebuffer + offset, 1, 1024, handle)) > 0)
|
||||
{
|
||||
offset += read;
|
||||
}
|
||||
|
||||
|
||||
fclose (handle);
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Write savebuffer to SD card file
|
||||
* Write savebuffer to FAT card file
|
||||
****************************************************************************/
|
||||
int
|
||||
SaveBufferToSD (char *filepath, int datasize, bool silent)
|
||||
SaveBufferToFAT (char *filepath, int datasize, bool silent)
|
||||
{
|
||||
FILE *handle;
|
||||
|
||||
FILE *handle;
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
handle = fopen (filepath, "wb");
|
||||
|
||||
|
||||
if (handle <= 0)
|
||||
{
|
||||
char msg[100];
|
||||
@ -294,152 +356,10 @@ SaveBufferToSD (char *filepath, int datasize, bool silent)
|
||||
WaitPrompt (msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
fwrite (savebuffer, 1, datasize, handle);
|
||||
fclose (handle);
|
||||
}
|
||||
|
||||
|
||||
return datasize;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Save SRAM to SD Card
|
||||
****************************************************************************/
|
||||
void SaveSRAMToSD (bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving SRAM to SD...");
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename);
|
||||
#else
|
||||
sprintf (filepath, "%s/%s/%08x.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32);
|
||||
#endif
|
||||
|
||||
datasize = prepareEXPORTsavedata ();
|
||||
|
||||
if ( datasize )
|
||||
{
|
||||
offset = SaveBufferToSD (filepath, datasize, silent);
|
||||
|
||||
if ( (offset > 0) && (!silent) )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Load SRAM From SD Card
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadSRAMFromSD (bool silent)
|
||||
{
|
||||
char filepath[MAXPATHLEN];
|
||||
int offset = 0;
|
||||
|
||||
ShowAction ((char*) "Loading SRAM from SD...");
|
||||
|
||||
// check for 'old' version of sram
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMName); // Build old SRAM filename
|
||||
|
||||
offset = LoadBufferFromSD (filepath, silent); // load file
|
||||
|
||||
if (offset > 0) // old sram found
|
||||
{
|
||||
if (WaitPromptChoice ((char*)"Old SRAM found. Convert and delete?", (char*)"Cancel", (char*)"Do it"))
|
||||
{
|
||||
decodesavedata (offset);
|
||||
remove (filepath); // delete old sram
|
||||
SaveSRAMToSD (silent);
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMFilename);
|
||||
#else
|
||||
sprintf (filepath, "%s/%s/%08x.srm", ROOTSDDIR, SNESSAVEDIR, Memory.ROMCRC32);
|
||||
#endif
|
||||
|
||||
offset = LoadBufferFromSD (filepath, silent);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
decodesavedata (offset);
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
S9xSoftReset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Save Preferences to SD Card
|
||||
****************************************************************************/
|
||||
void
|
||||
SavePrefsToSD (bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving prefs to SD...");
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
#else
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
#endif
|
||||
|
||||
datasize = preparePrefsData ();
|
||||
offset = SaveBufferToSD (filepath, datasize, silent);
|
||||
|
||||
if ( (offset > 0) && (!silent) )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filepath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Load Preferences from SD Card
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadPrefsFromSD (bool silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int offset = 0;
|
||||
|
||||
ShowAction ((char*) "Loading prefs from SD...");
|
||||
|
||||
#ifdef SDUSE_LFN
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
#else
|
||||
sprintf (filepath, "%s/%s/%s", ROOTSDDIR, SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
#endif
|
||||
|
||||
offset = LoadBufferFromSD (filepath, silent);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
decodePrefsData ();
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,15 +21,17 @@
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int FileSortCallback(const void *f1, const void *f2);
|
||||
int updateFATdirname();
|
||||
int parseFATdirectory();
|
||||
int LoadSDFile (char *filename, int length);
|
||||
void SaveSRAMToSD (bool silent);
|
||||
void LoadSRAMFromSD (bool silent);
|
||||
void SavePrefsToSD (bool silent);
|
||||
void LoadPrefsFromSD (bool silent);
|
||||
#define ROOTSDDIR "fat3:/"
|
||||
#define ROOTUSBDIR "fat4:/"
|
||||
|
||||
extern char currSDdir[MAXPATHLEN];
|
||||
bool fat_remount(PARTITION_INTERFACE partition);
|
||||
static int FileSortCallback(const void *f1, const void *f2);
|
||||
int updateFATdirname(int method);
|
||||
int parseFATdirectory(int method);
|
||||
int LoadFATFile (char *filename, int length);
|
||||
int SaveBufferToFAT (char *filepath, int datasize, bool silent);
|
||||
int LoadBufferFromFAT (char *filepath, bool silent);
|
||||
|
||||
extern char currFATdir[MAXPATHLEN];
|
||||
|
||||
#endif
|
||||
|
@ -53,26 +53,26 @@ 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)
|
||||
@ -82,7 +82,7 @@ ConnectSMB ()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
connected = 1;
|
||||
|
||||
}
|
||||
@ -101,7 +101,7 @@ parseSMBDirectory ()
|
||||
|
||||
ConnectSMB ();
|
||||
|
||||
strcpy (searchpath, SNESROMDIR);
|
||||
strcpy (searchpath, GCSettings.LoadFolder);
|
||||
strcat (searchpath, "\\*.*");
|
||||
|
||||
if (SMB_FindFirst
|
||||
@ -152,7 +152,7 @@ LoadSMBFile (char *filename, int length)
|
||||
z_stream zs;
|
||||
int res, outbytes;
|
||||
|
||||
strcpy (filepath, SNESROMDIR);
|
||||
strcpy (filepath, GCSettings.LoadFolder);
|
||||
strcat (filepath, "\\");
|
||||
strcat (filepath, filename);
|
||||
rbuffer = (char *) Memory.ROM;
|
||||
@ -160,10 +160,10 @@ LoadSMBFile (char *filename, int length)
|
||||
int have = 0;
|
||||
|
||||
ConnectSMB ();
|
||||
|
||||
|
||||
if ( connected )
|
||||
{
|
||||
|
||||
|
||||
/*** Open the file for reading ***/
|
||||
smbfile =
|
||||
SMB_Open (filepath, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
|
||||
@ -172,7 +172,7 @@ LoadSMBFile (char *filename, int length)
|
||||
while (total < length)
|
||||
{
|
||||
bytesread = SMB_Read (zipbuffer, 16384, offset, smbfile);
|
||||
|
||||
|
||||
if (pass == 0)
|
||||
{
|
||||
/*** Is this a Zip file ? ***/
|
||||
@ -188,13 +188,13 @@ LoadSMBFile (char *filename, int length)
|
||||
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) +
|
||||
@ -205,7 +205,7 @@ LoadSMBFile (char *filename, int length)
|
||||
FLIP16 (pkzip.extraDataLength));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (zip)
|
||||
{
|
||||
if (pass)
|
||||
@ -213,16 +213,16 @@ LoadSMBFile (char *filename, int length)
|
||||
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);
|
||||
@ -233,10 +233,10 @@ LoadSMBFile (char *filename, int length)
|
||||
}
|
||||
else
|
||||
memcpy (rbuffer + offset, zipbuffer, bytesread);
|
||||
|
||||
|
||||
total += bytesread;
|
||||
offset += bytesread;
|
||||
|
||||
|
||||
if (!zip)
|
||||
{
|
||||
sprintf (buffer, "Read %d of %d bytes", total, length);
|
||||
@ -249,19 +249,19 @@ LoadSMBFile (char *filename, int length)
|
||||
ShowProgress (buffer, outbytes, pkzip.uncompressedSize);
|
||||
}
|
||||
//ShowAction (buffer);
|
||||
|
||||
|
||||
pass++;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (zip)
|
||||
{
|
||||
inflateEnd (&zs);
|
||||
total = outbytes;
|
||||
}
|
||||
|
||||
|
||||
SMB_Close (smbfile);
|
||||
|
||||
|
||||
return total;
|
||||
}
|
||||
else
|
||||
@ -271,7 +271,7 @@ LoadSMBFile (char *filename, int length)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -286,15 +286,15 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
||||
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)
|
||||
@ -305,14 +305,14 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
||||
else
|
||||
wrote =
|
||||
SMB_Write ((char *) savebuffer + offset, dsize, offset, smbfile);
|
||||
|
||||
|
||||
offset += wrote;
|
||||
dsize -= wrote;
|
||||
}
|
||||
|
||||
|
||||
SMB_Close (smbfile);
|
||||
SMBTimer = 0;
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
else
|
||||
@ -322,7 +322,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
||||
WaitPrompt (msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -332,18 +332,19 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
|
||||
****************************************************************************/
|
||||
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)
|
||||
@ -354,131 +355,18 @@ LoadBufferFromSMB (char *filepath, bool8 silent)
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Save SRAM to SMB
|
||||
****************************************************************************/
|
||||
void
|
||||
SaveSRAMToSMB (bool8 silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset;
|
||||
|
||||
sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMFilename);
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving SRAM to SMB...");
|
||||
|
||||
datasize = prepareEXPORTsavedata ();
|
||||
|
||||
if ( datasize )
|
||||
{
|
||||
offset = SaveBufferToSMB (filepath, datasize, silent);
|
||||
|
||||
if ( (offset > 0) && (!silent) )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Load SRAM from SMB
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadSRAMFromSMB (bool8 silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int offset;
|
||||
|
||||
sprintf (filepath, "%s\\%s.srm", SNESSAVEDIR, Memory.ROMFilename);
|
||||
ShowAction ((char*) "Loading SRAM from SMB...");
|
||||
|
||||
offset = LoadBufferFromSMB (filepath, silent);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
decodesavedata (offset);
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
S9xSoftReset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Save Preferences to SMB
|
||||
****************************************************************************/
|
||||
void
|
||||
SavePrefsToSMB (bool8 silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset;
|
||||
|
||||
sprintf (filepath, "%s\\%s", SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving preferences to SMB...");
|
||||
|
||||
datasize = preparePrefsData ();
|
||||
|
||||
if ( datasize )
|
||||
{
|
||||
offset = SaveBufferToSMB (filepath, datasize, silent);
|
||||
|
||||
if ( (offset > 0) && (!silent) )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt (filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Load Preferences from SMB
|
||||
****************************************************************************/
|
||||
void
|
||||
LoadPrefsFromSMB (bool8 silent)
|
||||
{
|
||||
char filepath[1024];
|
||||
int offset;
|
||||
|
||||
ShowAction ((char*) "Loading preferences from SMB...");
|
||||
|
||||
sprintf (filepath, "%s\\%s", SNESSAVEDIR, PREFS_FILE_NAME);
|
||||
|
||||
offset = LoadBufferFromSMB (filepath, silent);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
decodePrefsData ();
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,15 +11,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _NGCSMB_
|
||||
|
||||
#define _NGCSMB_
|
||||
|
||||
void ConnectSMB ();
|
||||
int parseSMBDirectory ();
|
||||
int LoadSMBFile (char *filename, int length);
|
||||
void SaveSRAMToSMB (bool8 silent);
|
||||
void LoadSRAMFromSMB (bool8 silent);
|
||||
void SavePrefsToSMB (bool8 silent);
|
||||
void LoadPrefsFromSMB (bool8 silent);
|
||||
int LoadBufferFromSMB (char *filepath, bool8 silent);
|
||||
int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -35,4 +34,5 @@ typedef struct
|
||||
}
|
||||
SMBINFO;
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -131,8 +131,8 @@
|
||||
Snes9x homepage: http://www.snes9x.com
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@ -159,11 +159,11 @@
|
||||
|
||||
#include <ogcsys.h>
|
||||
#include <unistd.h>
|
||||
#include <fat.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <sdcard/card_cmn.h>
|
||||
#include <sdcard/wiisd_io.h>
|
||||
#include <sdcard/card_io.h>
|
||||
#include <fat.h>
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "memmap.h"
|
||||
@ -190,6 +190,7 @@
|
||||
#include "preferences.h"
|
||||
#include "gctime.h"
|
||||
#include "button_mapping.h"
|
||||
#include "sdload.h"
|
||||
|
||||
unsigned long ARAM_ROMSIZE = 0;
|
||||
int ConfigRequested = 0;
|
||||
@ -523,8 +524,7 @@ NGCReportButtons ()
|
||||
|
||||
if ( GCSettings.AutoSave == 1 )
|
||||
{
|
||||
//if ( WaitPromptChoice ((char*)"Save SRAM?", (char*)"Don't Save", (char*)"Save") )
|
||||
quickSaveSRAM ( SILENT );
|
||||
quickSaveSRAM ( SILENT );
|
||||
}
|
||||
else if ( GCSettings.AutoSave == 2 )
|
||||
{
|
||||
@ -540,7 +540,7 @@ NGCReportButtons ()
|
||||
}
|
||||
}
|
||||
|
||||
mainmenu ();
|
||||
mainmenu (3); // go to game menu
|
||||
FrameTimer = 0;
|
||||
ConfigRequested = 0;
|
||||
|
||||
@ -613,6 +613,7 @@ void SetControllers ()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* Set the default mapping for NGC
|
||||
****************************************************************************/
|
||||
@ -692,7 +693,7 @@ SetDefaultButtonMap ()
|
||||
maxcode = 0x60;
|
||||
S9xMapPointer( maxcode++, S9xGetCommandT("Pointer Superscope"), false);
|
||||
// add mouses here
|
||||
|
||||
|
||||
SetControllers ();
|
||||
|
||||
}
|
||||
@ -701,7 +702,7 @@ SetDefaultButtonMap ()
|
||||
* Emulation loop
|
||||
*
|
||||
* The 'clock' timer is long gone.
|
||||
* System now only uses vbl as hardware clock, so force PAL50 if you need 50hz
|
||||
* System now only uses vbl as hardware clock, so force PAL50 if you need 50hz
|
||||
****************************************************************************/
|
||||
/* Eke-Eke: initialize frame Sync */
|
||||
extern void S9xInitSync();
|
||||
@ -714,7 +715,7 @@ emulate ()
|
||||
AudioStart ();
|
||||
S9xInitSync();
|
||||
|
||||
setFrameTimerMethod(); // also called in NGCReportButtons()
|
||||
setFrameTimerMethod(); // also called in NGCReportButtons()
|
||||
|
||||
while (1)
|
||||
{
|
||||
@ -747,19 +748,19 @@ int
|
||||
main ()
|
||||
{
|
||||
unsigned int save_flags;
|
||||
|
||||
int selectedMenu = -1;
|
||||
|
||||
/*** Initialise GC ***/
|
||||
InitGCVideo (); /*** Get the ball rolling ***/
|
||||
|
||||
/*** Initialize libFAT and SD cards ***/
|
||||
|
||||
/*** 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
|
||||
@ -777,61 +778,63 @@ main ()
|
||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*** Initialise freetype ***/
|
||||
if (FT_Init ())
|
||||
{
|
||||
printf ("Cannot initialise font subsystem!\n");
|
||||
while (1);
|
||||
}
|
||||
setfontsize (16);/***sets the font size.***/
|
||||
|
||||
|
||||
/*** Set defaults ***/
|
||||
DefaultSettings ();
|
||||
|
||||
|
||||
S9xUnmapAllControls ();
|
||||
SetDefaultButtonMap ();
|
||||
|
||||
|
||||
printf ("Initialise Memory\n");
|
||||
/*** Allocate SNES Memory ***/
|
||||
if (!Memory.Init ())
|
||||
while (1);
|
||||
|
||||
|
||||
printf ("Initialise APU\n");
|
||||
/*** Allocate APU ***/
|
||||
if (!S9xInitAPU ())
|
||||
while (1);
|
||||
|
||||
|
||||
/*** Set Pixel Renderer to match 565 ***/
|
||||
S9xSetRenderPixelFormat (RGB565);
|
||||
|
||||
|
||||
/*** Initialise Snes Sound System ***/
|
||||
S9xInitSound (5, TRUE, 1024);
|
||||
|
||||
|
||||
printf ("Initialise GFX\n");
|
||||
/*** Initialise Graphics ***/
|
||||
setGFX ();
|
||||
if (!S9xGraphicsInit ())
|
||||
while (1);
|
||||
|
||||
legal ();
|
||||
WaitButtonA ();
|
||||
|
||||
|
||||
unpackbackdrop ();
|
||||
|
||||
// Load preferences
|
||||
quickLoadPrefs(SILENT);
|
||||
|
||||
if(!quickLoadPrefs(SILENT))
|
||||
{
|
||||
WaitPrompt((char*) "Preferences reset - check settings!");
|
||||
selectedMenu = 2; // change to preferences menu
|
||||
}
|
||||
|
||||
// Correct any relevant saved settings that are invalid
|
||||
Settings.FrameTimeNTSC = 16667;
|
||||
Settings.FrameTimePAL = 20000;
|
||||
if ( Settings.TurboSkipFrames <= Settings.SkipFrames )
|
||||
Settings.TurboSkipFrames = 20;
|
||||
|
||||
|
||||
/*** No appended ROM, so get the user to load one ***/
|
||||
if (ARAM_ROMSIZE == 0)
|
||||
{
|
||||
while (ARAM_ROMSIZE == 0)
|
||||
{
|
||||
mainmenu ();
|
||||
mainmenu (selectedMenu);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -841,14 +844,14 @@ main ()
|
||||
if (!Memory.LoadROM ("VIRTUAL.ROM"))
|
||||
while (1);
|
||||
CPU.Flags = save_flags;
|
||||
|
||||
|
||||
/*** Load SRAM ***/
|
||||
Memory.LoadSRAM ("DVD");
|
||||
}
|
||||
|
||||
|
||||
/*** Emulate ***/
|
||||
emulate ();
|
||||
|
||||
|
||||
/*** NO! - We're never leaving here ! ***/
|
||||
while (1);
|
||||
return 0;
|
||||
|
@ -131,8 +131,8 @@
|
||||
Snes9x homepage: http://www.snes9x.com
|
||||
|
||||
Permission to use, copy, modify and/or distribute Snes9x in both binary
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
and source form, for non-commercial purposes, is hereby granted without
|
||||
fee, providing that this license information and copyright notice appear
|
||||
with all copies and any derived work.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@ -166,9 +166,23 @@
|
||||
#define NOTSILENT 0
|
||||
#define SILENT 1
|
||||
|
||||
enum {
|
||||
METHOD_AUTO,
|
||||
METHOD_SD,
|
||||
METHOD_USB,
|
||||
METHOD_DVD,
|
||||
METHOD_SMB,
|
||||
METHOD_MC_SLOTA,
|
||||
METHOD_MC_SLOTB
|
||||
};
|
||||
|
||||
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];
|
||||
@ -181,9 +195,8 @@ struct SGCSettings{
|
||||
bool8 NGCZoom;
|
||||
uint8 VerifySaves;
|
||||
u16 render; // 0 - original, 1 - no AA
|
||||
u32 QuickSaveSlot; // -1 Disabled - no prefs are loaded, 0 Memory card in slot A, 1 Memory card in slot B, 2 SD card in slot A, 3 SD card in slot B, 4 SMB share, 5 USB
|
||||
u16 Superscope;
|
||||
u16 Mouse;
|
||||
u16 Superscope;
|
||||
u16 Mouse;
|
||||
};
|
||||
|
||||
START_EXTERN_C
|
||||
@ -197,21 +210,6 @@ END_EXTERN_C
|
||||
|
||||
#define JOY_THRESHOLD 0.70 // for wii (expansion) analogues
|
||||
|
||||
#endif
|
||||
|
||||
/*** QUICK_SAVE_SLOT defines where preferences are loaded and saved, and also
|
||||
where SRAM and Freezes are auto loaded or saved if enabled:
|
||||
|
||||
-1 Disabled - no prefs are loaded
|
||||
0 Memory card in slot A
|
||||
1 Memory card in slot B
|
||||
2 SD card in slot A
|
||||
3 SD card in slot B
|
||||
4 SMB share ***/
|
||||
#ifndef QUICK_SAVE_SLOT
|
||||
#define QUICK_SAVE_SLOT 2 // save to SD
|
||||
#endif
|
||||
|
||||
/*** default SMB settings ***/
|
||||
#ifndef GC_IP
|
||||
#define GC_IP "192.168.1.32" /*** IP to assign the GameCube ***/
|
||||
@ -240,3 +238,5 @@ END_EXTERN_C
|
||||
#ifndef SMB_IP
|
||||
#define SMB_IP "192.168.1.100" /*** IP Address of share server ***/
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -21,14 +21,13 @@
|
||||
#include "mcsave.h"
|
||||
#include "sdload.h"
|
||||
#include "smbload.h"
|
||||
#include "filesel.h"
|
||||
|
||||
extern unsigned char savebuffer[];
|
||||
//extern int currconfig[4];
|
||||
extern int padcal;
|
||||
extern unsigned short gcpadmap[];
|
||||
//extern unsigned short padmap[4];
|
||||
|
||||
char sramcomment[2][32] = { {"Snes9x GX 004 SRAM"}, {"Savegame"} };
|
||||
char sramcomment[2][32] = { {"Snes9x GX 005 SRAM"}, {"Savegame"} };
|
||||
|
||||
/****************************************************************************
|
||||
* Prepare Memory Card SRAM Save Data
|
||||
@ -47,7 +46,7 @@ prepareMCsavedata ()
|
||||
memcpy (savebuffer, saveicon, offset);
|
||||
|
||||
/*** And the sramcomments ***/
|
||||
sprintf (sramcomment[1], "%s", Memory.ROMName);
|
||||
sprintf (sramcomment[1], "%s", Memory.ROMFilename);
|
||||
memcpy (savebuffer + offset, sramcomment, 64);
|
||||
offset += 64;
|
||||
|
||||
@ -59,7 +58,7 @@ prepareMCsavedata ()
|
||||
|
||||
memcpy (savebuffer + offset, &size, 4);
|
||||
offset += 4;
|
||||
|
||||
|
||||
/*** Copy SRAM ***/
|
||||
if (size != 0)
|
||||
{
|
||||
@ -72,7 +71,7 @@ prepareMCsavedata ()
|
||||
offset += 16;
|
||||
// memcpy (savebuffer + offset, &padcal, 4);
|
||||
offset += 4;
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
@ -91,7 +90,7 @@ prepareEXPORTsavedata ()
|
||||
ClearSaveBuffer ();
|
||||
|
||||
/*** Copy in the sramcomments ***/
|
||||
sprintf (sramcomment[1], "%s", Memory.ROMName);
|
||||
sprintf (sramcomment[1], "%s", Memory.ROMFilename);
|
||||
memcpy (savebuffer + offset, sramcomment, 64);
|
||||
offset += 64;
|
||||
|
||||
@ -105,19 +104,19 @@ prepareEXPORTsavedata ()
|
||||
{
|
||||
// make it a 512 byte header so it is compatible with other platforms
|
||||
offset = 512;
|
||||
|
||||
|
||||
/*** Copy in the SRAM ***/
|
||||
size = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0;
|
||||
|
||||
|
||||
if (size > 0x20000)
|
||||
size = 0x20000;
|
||||
|
||||
|
||||
if (size != 0)
|
||||
{
|
||||
memcpy (savebuffer + offset, Memory.SRAM, size);
|
||||
offset += size;
|
||||
}
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
else
|
||||
@ -136,32 +135,32 @@ decodesavedata (int readsize)
|
||||
int offset;
|
||||
int size;
|
||||
char sramcomment[32];
|
||||
|
||||
|
||||
// Check for exportable format sram - it has the sram comment at the start
|
||||
memcpy (sramcomment, savebuffer, 32);
|
||||
|
||||
if ( (strncmp (sramcomment, "Snes9x GX 2.0", 13) == 0) || (strncmp (sramcomment, "Snes9x GX 00", 12) == 0) ) // version 2.0.XX or 00x
|
||||
{
|
||||
offset = 64;
|
||||
|
||||
|
||||
// Get the control pad configuration
|
||||
// memcpy (&currconfig, savebuffer + offset, 16);
|
||||
offset += 16;
|
||||
// memcpy (&padcal, savebuffer + offset, 4);
|
||||
offset += 4;
|
||||
|
||||
|
||||
// for (size = 0; size < 4; size++)
|
||||
// gcpadmap[size] = padmap[currconfig[size]];
|
||||
|
||||
|
||||
// move to start of SRAM which is after the 512 byte header
|
||||
offset = 512;
|
||||
|
||||
// import the SRAM
|
||||
size = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0;
|
||||
|
||||
|
||||
if (size > 0x20000)
|
||||
size = 0x20000;
|
||||
|
||||
|
||||
memcpy (Memory.SRAM, savebuffer + offset, size);
|
||||
offset += size;
|
||||
}
|
||||
@ -170,7 +169,7 @@ decodesavedata (int readsize)
|
||||
// else, check for a v2.0 memory card format save
|
||||
offset = sizeof (saveicon);
|
||||
memcpy (sramcomment, savebuffer + offset, 32);
|
||||
|
||||
|
||||
if ( strncmp (sramcomment, "Snes9x GX 2.0", 13) == 0 )
|
||||
{
|
||||
//WaitPrompt((char*) "Memory Card format save");
|
||||
@ -179,18 +178,18 @@ decodesavedata (int readsize)
|
||||
offset += 4;
|
||||
memcpy (Memory.SRAM, savebuffer + offset, size);
|
||||
offset += size;
|
||||
|
||||
|
||||
// If it is an old 2.0 format save, skip over the Settings as we
|
||||
// don't save them in SRAM now
|
||||
if ( strcmp (sramcomment, "Snes9x GX 2.0") == 0 )
|
||||
offset += sizeof (Settings);
|
||||
|
||||
|
||||
// Get the control pad configuration
|
||||
// memcpy (&currconfig, savebuffer + offset, 16);
|
||||
offset += 16;
|
||||
// memcpy (&padcal, savebuffer + offset, 4);
|
||||
offset += 4;
|
||||
|
||||
|
||||
// for (size = 0; size < 4; size++)
|
||||
// gcpadmap[size] = padmap[currconfig[size]];
|
||||
}
|
||||
@ -198,20 +197,20 @@ decodesavedata (int readsize)
|
||||
{
|
||||
// it's an older SnesGx memory card format save
|
||||
size = Memory.SRAMSize ? ( 1 << (Memory.SRAMSize + 3)) * 128 : 0;
|
||||
|
||||
|
||||
// import the SRAM
|
||||
if ( size )
|
||||
memcpy(&Memory.SRAM[0], &savebuffer[sizeof(saveicon)+68], size);
|
||||
|
||||
|
||||
// Ignore the settings saved in the file
|
||||
|
||||
|
||||
// NOTE: need to add import of joypad config?? Nah.
|
||||
}
|
||||
else
|
||||
{
|
||||
// else, check for SRAM from other version/platform of snes9x
|
||||
size = Memory.SRAMSize ? (1 << (Memory.SRAMSize + 3)) * 128 : 0;
|
||||
|
||||
|
||||
if ( readsize == size || readsize == size + SRTC_SRAM_PAD)
|
||||
{
|
||||
//WaitPrompt("readsize=size or + SRTC_SRAM_PAD");
|
||||
@ -233,39 +232,136 @@ decodesavedata (int readsize)
|
||||
}
|
||||
}
|
||||
|
||||
void quickLoadSRAM (bool8 silent)
|
||||
/****************************************************************************
|
||||
* Load SRAM
|
||||
****************************************************************************/
|
||||
bool
|
||||
LoadSRAM (int method, bool silent)
|
||||
{
|
||||
switch ( QUICK_SAVE_SLOT )
|
||||
{
|
||||
case CARD_SLOTA:
|
||||
case CARD_SLOTB:
|
||||
LoadSRAMFromMC(QUICK_SAVE_SLOT, silent);
|
||||
break;
|
||||
case CARD_SLOTA+2:
|
||||
case CARD_SLOTB+2:
|
||||
LoadSRAMFromSD(silent);
|
||||
break;
|
||||
case CARD_SLOTA+4:
|
||||
LoadSRAMFromSMB(SILENT);
|
||||
break;
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(method == METHOD_SD)
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
else
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
|
||||
offset = LoadBufferFromFAT (filepath, silent);
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf (filepath, "%s\\%s.srm", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
offset = LoadBufferFromSMB (filepath, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
{
|
||||
sprintf (filepath, "%s.srm", Memory.ROMFilename);
|
||||
offset = LoadBufferFromMC (savebuffer, CARD_SLOTA, filepath, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
{
|
||||
sprintf (filepath, "%s.srm", Memory.ROMFilename);
|
||||
offset = LoadBufferFromMC (savebuffer, CARD_SLOTB, filepath, silent);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
decodesavedata (offset);
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Loaded %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
S9xSoftReset();
|
||||
retval = true;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void quickSaveSRAM (bool8 silent)
|
||||
/****************************************************************************
|
||||
* Save SRAM
|
||||
****************************************************************************/
|
||||
bool
|
||||
SaveSRAM (int method, bool silent)
|
||||
{
|
||||
switch ( QUICK_SAVE_SLOT )
|
||||
{
|
||||
case CARD_SLOTA:
|
||||
case CARD_SLOTB:
|
||||
SaveSRAMToMC(QUICK_SAVE_SLOT, silent);
|
||||
break;
|
||||
case CARD_SLOTA+2:
|
||||
case CARD_SLOTB+2:
|
||||
SaveSRAMToSD(silent);
|
||||
break;
|
||||
case CARD_SLOTA+4:
|
||||
SaveSRAMToSMB(SILENT);
|
||||
break;
|
||||
}
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod();
|
||||
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ((char*) "Saving SRAM...");
|
||||
|
||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||
datasize = prepareMCsavedata ();
|
||||
else
|
||||
datasize = prepareEXPORTsavedata ();
|
||||
|
||||
if ( datasize )
|
||||
{
|
||||
if(method == METHOD_SD || method == METHOD_USB)
|
||||
{
|
||||
if(method == METHOD_SD)
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
else
|
||||
sprintf (filepath, "%s/%s/%s.srm", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
offset = SaveBufferToFAT (filepath, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf (filepath, "%s\\%s.srm", GCSettings.SaveFolder, Memory.ROMFilename);
|
||||
offset = SaveBufferToSMB (filepath, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTA)
|
||||
{
|
||||
sprintf (filepath, "%s.srm", Memory.ROMFilename);
|
||||
offset = SaveBufferToMC (savebuffer, CARD_SLOTA, filepath, datasize, silent);
|
||||
}
|
||||
else if(method == METHOD_MC_SLOTB)
|
||||
{
|
||||
sprintf (filepath, "%s.srm", Memory.ROMFilename);
|
||||
offset = SaveBufferToMC (savebuffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
}
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if ( !silent )
|
||||
{
|
||||
sprintf (filepath, "Wrote %d bytes", offset);
|
||||
WaitPrompt(filepath);
|
||||
}
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
@ -13,5 +13,7 @@ int prepareMCsavedata ();
|
||||
int prepareEXPORTsavedata ();
|
||||
void decodesavedata (int readsize);
|
||||
|
||||
void quickLoadSRAM (bool8 silent);
|
||||
void quickSaveSRAM (bool8 silent);
|
||||
bool SaveSRAM (int method, bool silent);
|
||||
bool LoadSRAM (int method, bool silent);
|
||||
bool quickLoadSRAM (bool silent);
|
||||
bool quickSaveSRAM (bool silent);
|
||||
|
Loading…
Reference in New Issue
Block a user