-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:
dborth 2008-08-07 03:25:02 +00:00
parent 1478cee2a3
commit 17d6488545
23 changed files with 2096 additions and 2151 deletions

48
source/ngc/cheatmgr.cpp Normal file
View 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
View File

@ -0,0 +1,12 @@
/****************************************************************************
* Snes9x 1.51
*
* Nintendo Wii/Gamecube Port
* Tantric August 2008
*
* cheatmgr.h
*
* Cheat handling
****************************************************************************/
void SetupCheats();

View File

@ -15,7 +15,6 @@
#include <fat.h> #include <fat.h>
#include <sys/dir.h> #include <sys/dir.h>
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
#include "debug.h" #include "debug.h"
@ -44,95 +43,84 @@
int maxfiles; int maxfiles;
int havedir = 0; int havedir = 0;
int hasloaded = 0; int hasloaded = 0;
int loadtype = 0;
int LoadDVDFile (unsigned char *buffer); int LoadDVDFile (unsigned char *buffer);
bool haveSDdir = 0; int haveFATdir = 0;
bool haveUSBdir = 0;
extern unsigned long ARAM_ROMSIZE; extern unsigned long ARAM_ROMSIZE;
extern int screenheight; extern int screenheight;
extern FILEENTRIES filelist[MAXFILES]; 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 * Strips an extension from a filename
*/ ****************************************************************************/
static void
ShowFiles (int offset, int selection)
{
int i, j;
char text[MAXPATHLEN];
int ypos;
int w;
setfontsize(18); void StripExt(char* returnstring, char * inputstring)
clearscreen ();
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)
{ {
char* loc_dot; char* loc_dot;
@ -144,31 +132,108 @@ void strip_ext(char* inputstring, char* returnstring)
return; 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 * FileSelector
* *
* Let user select a file from the DVD listing * Let user select a file from the listing
*/ ****************************************************************************/
int offset = 0; int offset = 0;
int selection = 0; int selection = 0;
#define PADCAL 40 #define PADCAL 40
int int
FileSelector () FileSelector (int method)
{ {
u32 p, wp, ph, wh; u32 p, wp, ph, wh;
signed char a, c; signed char a, c;
int haverom = 0; int haverom = 0;
int redraw = 1; int redraw = 1;
int selectit = 0; int selectit = 0;
float mag = 0; float mag, mag2 = 0;
float mag2 = 0; u16 ang, ang2 = 0;
u16 ang = 0;
u16 ang2 = 0;
int scroll_delay = 0; int scroll_delay = 0;
bool move_selection = 0; bool move_selection = 0;
#define SCROLL_INITIAL_DELAY 15 #define SCROLL_INITIAL_DELAY 15
#define SCROLL_LOOP_DELAY 4 #define SCROLL_LOOP_DELAY 2
while (haverom == 0) while (haverom == 0)
{ {
@ -201,36 +266,27 @@ FileSelector ()
selectit = 0; selectit = 0;
if (filelist[selection].flags) /*** This is directory ***/ 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 */ /* memorize last entries list, actual root directory and selection for next access */
if (loadtype == LOAD_SDC) haveFATdir = 1;
haveSDdir = 1;
else
haveUSBdir = 1;
/* update current directory and set new entry list if directory has changed */ /* update current directory and set new entry list if directory has changed */
int status = updateFATdirname(); int status = updateFATdirname(method);
if (status == 1) // ok, open directory if (status == 1) // ok, open directory
{ {
maxfiles = parseFATdirectory(); maxfiles = parseFATdirectory(method);
if (!maxfiles) if (!maxfiles)
{ {
WaitPrompt ((char*) "Error reading directory !"); WaitPrompt ((char*) "Error reading directory !");
haverom = 1; // quit SD menu haverom = 1; // quit FAT menu
if (loadtype == LOAD_SDC) // reset everything at next access haveFATdir = 0; // reset everything at next access
haveSDdir = 0;
else
haveUSBdir = 0;
} }
} }
else if (status == -1) // directory name too long else if (status == -1) // directory name too long
{ {
haverom = 1; // quit SD menu haverom = 1; // quit FAT menu
if (loadtype == LOAD_SDC) // reset everything at next access haveFATdir = 0; // reset everything at next access
haveSDdir = 0;
else
haveUSBdir = 0;
} }
} }
else else
@ -252,28 +308,29 @@ FileSelector ()
rootdir = filelist[selection].offset; rootdir = filelist[selection].offset;
rootdirlength = filelist[selection].length; rootdirlength = filelist[selection].length;
/*** store the filename (used for sram/freeze naming) ***/ // store the filename (used for sram/freeze naming)
strip_ext(filelist[selection].filename, Memory.ROMFilename); // store stripped filename in Memory.ROMFilename StripExt(Memory.ROMFilename, filelist[selection].filename); // store stripped filename in Memory.ROMFilename
switch (loadtype) 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 ***/ /*** Now load the DVD file to it's offset ***/
ARAM_ROMSIZE = LoadDVDFile (Memory.ROM); ARAM_ROMSIZE = LoadDVDFile (Memory.ROM);
break; break;
case LOAD_SMB: case METHOD_SMB:
/*** Load from SMB ***/ /*** Load from SMB ***/
ARAM_ROMSIZE = LoadSMBFile (filelist[selection].filename, ARAM_ROMSIZE =
filelist[selection].length); LoadSMBFile (filelist[selection].filename,
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); filelist[selection].length);
break; break;
} }
@ -397,18 +454,16 @@ FileSelector ()
return 0; return 0;
} }
/** /****************************************************************************
* OpenDVD * OpenDVD
* *
* Function to load a DVD directory and display to user. * Function to load a DVD directory and display to user.
*/ ****************************************************************************/
int int
OpenDVD () OpenDVD (int method)
{ {
int romsdiroffset = 0; int romsdiroffset = 0;
loadtype = LOAD_DVD;
if (!getpvd()) if (!getpvd())
{ {
ShowAction((char*) "Mounting DVD ... Wait"); ShowAction((char*) "Mounting DVD ... Wait");
@ -421,8 +476,7 @@ OpenDVD ()
if (havedir == 0) if (havedir == 0)
{ {
offset = selection = 0; /* reset file selector */ offset = selection = 0; /* reset file selector */
haveSDdir = 0; /* prevent conflicts with SDCARD, USB file selector */ haveFATdir = 0; /* prevent conflicts with FAT file selector */
haveUSBdir = 0;
if ((maxfiles = parsedirectory ())) if ((maxfiles = parsedirectory ()))
{ {
@ -434,126 +488,62 @@ OpenDVD ()
maxfiles = parsedirectory (); maxfiles = parsedirectory ();
} }
int ret = FileSelector (); int ret = FileSelector (method);
havedir = 1; havedir = 1;
return ret; return ret;
} }
} }
else else
return FileSelector (); return FileSelector (method);
return 0; return 0;
} }
/** /****************************************************************************
* OpenSMB * OpenSMB
* *
* Function to load from an SMB share * Function to load from an SMB share
*/ ****************************************************************************/
int int
OpenSMB () OpenSMB (int method)
{ {
loadtype = LOAD_SMB;
if ((maxfiles = parseSMBDirectory ())) if ((maxfiles = parseSMBDirectory ()))
{ {
char txt[80]; char txt[80];
sprintf(txt,"maxfiles = %d", maxfiles); sprintf(txt,"maxfiles = %d", maxfiles);
return FileSelector (); return FileSelector (method);
} }
return 0; return 0;
} }
/****************************************************************************
// is_mounted * OpenFAT
//
// 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;
}
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))
{
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;
}
}
/**
* OpenSD
* *
* Function to load from an SD Card * Function to load from FAT
*/ ****************************************************************************/
int int
OpenSD () OpenFAT (int method)
{ {
char msg[80]; char msg[80];
char buf[50] = "";
loadtype = LOAD_SDC; //if (haveFATdir == 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 */ /* don't mess with DVD entries */
havedir = 0; havedir = 0; // gamecube only
haveUSBdir = 0;
/* change current dir to snes roms directory */ /* change current dir to snes roms directory */
sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR ); if(method == METHOD_SD)
sprintf ( currFATdir, "%s/%s", ROOTSDDIR, GCSettings.LoadFolder );
else
sprintf ( currFATdir, "%s/%s", ROOTUSBDIR, GCSettings.LoadFolder );
/* Parse initial root directory and get entries list */ /* Parse initial root directory and get entries list */
if ((maxfiles = parseFATdirectory ())) if ((maxfiles = parseFATdirectory (method)))
{ {
/* Select an entry */ /* Select an entry */
return FileSelector (); return FileSelector (method);
} }
else else
{ {
@ -562,81 +552,55 @@ OpenSD ()
WaitPrompt (msg); WaitPrompt (msg);
return 0; return 0;
} }
} //}
/* Retrieve previous entries list and made a new selection */ /* Retrieve previous entries list and made a new selection */
else //else
return FileSelector (); // return FileSelector (method);
return 0; return 0;
} }
/** /****************************************************************************
* OpenUSB * OpenROM
* * Opens device specified by method, displays a list of ROMS
* Function to load from a USB device (wii only) ****************************************************************************/
*/
int int
OpenUSB () OpenROM (int method)
{ {
char msg[80]; int loadROM = 0;
char buf[50] = "";
/* if(method == METHOD_AUTO)
//fatUnmount(PI_USBSTORAGE); method = autoLoadMethod();
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; switch (method)
if (haveUSBdir == 0)
{ {
/* don't mess with DVD, SDCARD entries */ case METHOD_SD:
havedir = 0; case METHOD_USB:
haveSDdir = 0; loadROM = OpenFAT (method);
break;
/* change current dir to snes roms directory */ case METHOD_DVD:
sprintf ( currSDdir, "%s/%s", ROOTSDDIR, SNESROMDIR ); // Load from DVD
loadROM = OpenDVD (method);
/* Parse initial root directory and get entries list */ break;
if ((maxfiles = parseFATdirectory ())) case METHOD_SMB:
{ // Load from Network (SMB)
/* Select an entry */ loadROM = OpenSMB (method);
return FileSelector (); break;
}
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;
} }
return loadROM;
}
/** /****************************************************************************
* LoadDVDFile * LoadDVDFile
*
* This function will load a file from DVD, in BIN, SMD or ZIP format. * 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. * rootdirlength.
* *
* The buffer parameter should re-use the initial ROM buffer. * The buffer parameter should re-use the initial ROM buffer.
*/ ****************************************************************************/
int int
LoadDVDFile (unsigned char *buffer) LoadDVDFile (unsigned char *buffer)
{ {

View File

@ -10,17 +10,8 @@
#ifndef _NGCFILESEL_ #ifndef _NGCFILESEL_
#define _NGCFILESEL_ #define _NGCFILESEL_
int OpenDVD (); int OpenROM (int method);
int OpenSMB (); int autoLoadMethod();
int OpenSD (); int autoSaveMethod();
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"
#endif #endif

View File

@ -31,6 +31,7 @@
#include "dkpro.h" #include "dkpro.h"
#include "snes9xGX.h" #include "snes9xGX.h"
#include "memmap.h"
#include "aram.h" #include "aram.h"
#include <zlib.h> #include <zlib.h>
@ -49,9 +50,9 @@ extern int screenheight;
extern unsigned int *xfb[2]; extern unsigned int *xfb[2];
extern int whichfb; extern int whichfb;
/** /****************************************************************************
* Unpack the devkit pro logo * Unpack the devkit pro logo
*/ ****************************************************************************/
static u32 *dkproraw; static u32 *dkproraw;
/*** Permanent backdrop ***/ /*** Permanent backdrop ***/
#ifdef HW_RVL #ifdef HW_RVL
@ -59,14 +60,13 @@ u32 *backdrop;
#else #else
static u32 *backdrop; static u32 *backdrop;
#endif #endif
static void unpackbackdrop ();
unsigned int getcolour (u8 r1, u8 g1, u8 b1); unsigned int getcolour (u8 r1, u8 g1, u8 b1);
void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b ); void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b );
u32 getrgb( u32 ycbr, u32 low ); u32 getrgb( u32 ycbr, u32 low );
/** /****************************************************************************
* Initialisation of libfreetype * Initialisation of libfreetype
*/ ****************************************************************************/
int int
FT_Init () FT_Init ()
{ {
@ -91,11 +91,11 @@ FT_Init ()
} }
/** /****************************************************************************
* setfontsize * setfontsize
* *
* Set the screen font size in pixels * Set the screen font size in pixels
*/ ****************************************************************************/
void void
setfontsize (int pixelsize) setfontsize (int pixelsize)
{ {
@ -107,6 +107,10 @@ setfontsize (int pixelsize)
printf ("Error setting pixel sizes!"); printf ("Error setting pixel sizes!");
} }
/****************************************************************************
* DrawCharacter
* Draws a single character on the screen
****************************************************************************/
static void static void
DrawCharacter (FT_Bitmap * bmp, FT_Int x, FT_Int y) 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 * DrawText
* *
* Place the font bitmap on the screen * Place the font bitmap on the screen
*/ ****************************************************************************/
void void
DrawText (int x, int y, char *text) DrawText (int x, int y, char *text)
{ {
@ -161,6 +165,8 @@ DrawText (int x, int y, char *text)
if (n == 0) if (n == 0)
return; return;
setfontcolour (0x00, 0x00, 0x00);
/*** x == -1, auto centre ***/ /*** x == -1, auto centre ***/
if (x == -1) if (x == -1)
{ {
@ -198,11 +204,11 @@ DrawText (int x, int y, char *text)
} }
} }
/** /****************************************************************************
* setfontcolour * setfontcolour
* *
* Uses RGB triple values. * Uses RGB triple values.
*/ ****************************************************************************/
void void
setfontcolour (u8 r, u8 g, u8 b) setfontcolour (u8 r, u8 g, u8 b)
{ {
@ -213,47 +219,11 @@ setfontcolour (u8 r, u8 g, u8 b)
fontlo = fontcolour & 0xffff; 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 * dkunpack
* *
* Support function to expand the DevkitPro logo * Support function to expand the DevkitPro logo
*/ ****************************************************************************/
int int
dkunpack () dkunpack ()
{ {
@ -271,11 +241,11 @@ dkunpack ()
return 0; return 0;
} }
/** /****************************************************************************
* showdklogo * showdklogo
* *
* Display the DevkitPro logo * Display the DevkitPro logo
*/ ****************************************************************************/
void void
showdklogo () showdklogo ()
{ {
@ -302,13 +272,69 @@ showdklogo ()
free (dkproraw); 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 * getcolour
* *
* Simply converts RGB to Y1CbY2Cr format * Simply converts RGB to Y1CbY2Cr format
* *
* I got this from a pastebin, so thanks to whoever originally wrote it! * I got this from a pastebin, so thanks to whoever originally wrote it!
*/ ****************************************************************************/
unsigned int unsigned int
getcolour (u8 r1, u8 g1, u8 b1) 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); return ((y1 << 24) | (cb << 16) | (y2 << 8) | cr);
} }
/** /****************************************************************************
* Unpackbackdrop * Unpackbackdrop
*/ ****************************************************************************/
void void
unpackbackdrop () unpackbackdrop ()
{ {
@ -371,22 +397,9 @@ unpackbackdrop ()
} }
/** /****************************************************************************
* Display legal copyright and licence
*/
void
legal ()
{
unpackbackdrop ();
clearscreen ();
licence ();
showdklogo ();
showscreen ();
}
/**
* Wait for user to press A * Wait for user to press A
*/ ****************************************************************************/
void void
WaitButtonA () WaitButtonA ()
{ {
@ -399,9 +412,9 @@ WaitButtonA ()
#endif #endif
} }
/** /****************************************************************************
* Wait for user to press A or B. Returns 0 = B; 1 = A * Wait for user to press A or B. Returns 0 = B; 1 = A
*/ ****************************************************************************/
int int
WaitButtonAB () WaitButtonAB ()
@ -438,9 +451,9 @@ WaitButtonAB ()
#endif #endif
} }
/** /****************************************************************************
* Show a prompt * Show a prompt
*/ ****************************************************************************/
void void
WaitPrompt (char *msg) WaitPrompt (char *msg)
{ {
@ -459,10 +472,10 @@ WaitPrompt (char *msg)
WaitButtonA (); WaitButtonA ();
} }
/** /****************************************************************************
* Show a prompt with choice of two options. Returns 1 if A button was pressed * Show a prompt with choice of two options. Returns 1 if A button was pressed
and 0 if B button was pressed. and 0 if B button was pressed.
*/ ****************************************************************************/
int int
WaitPromptChoice (char *msg, char *bmsg, char *amsg) WaitPromptChoice (char *msg, char *bmsg, char *amsg)
{ {
@ -483,9 +496,9 @@ WaitPromptChoice (char *msg, char *bmsg, char *amsg)
return WaitButtonAB (); return WaitButtonAB ();
} }
/** /****************************************************************************
* Show an action in progress * Show an action in progress
*/ ****************************************************************************/
void void
ShowAction (char *msg) ShowAction (char *msg)
{ {
@ -505,20 +518,13 @@ ShowAction (char *msg)
* Generic Menu Routines * Generic Menu Routines
****************************************************************************/ ****************************************************************************/
void 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 i, w = 0;
int ypos; int ypos = 0;
int n = 1;
#if 0 ypos = 65;
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 = (screenheight - (maxitems * 32)) >> 1; previous
ypos = (screenheight - (maxitems * (fontsize + 8))) >> 1;
if (screenheight == 480) if (screenheight == 480)
ypos += 52; ypos += 52;
@ -527,42 +533,68 @@ DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsiz
clearscreen (); clearscreen ();
//#if 0 setfontcolour (0, 0, 0);
// DrawPolygon (4, bounding, 0x00, 0x00, 0xc0);
// DrawPolygon (4, base, 0x00, 0x00, 0xc0);
setfontsize (30);
if (title != NULL) if (title != NULL)
{
setfontsize (28);
DrawText (-1, 60, title); DrawText (-1, 60, title);
}
setfontsize (12); setfontsize (12);
DrawText (510, screenheight - 20, "Snes9x GX 004"); DrawText (510, screenheight - 20, (char *)"Snes9x GX 005");
//#endif
// Draw menu items
setfontsize (fontsize); // set font size setfontsize (fontsize); // set font size
setfontcolour (0, 0, 0);
for (i = 0; i < maxitems; i++) for (i = 0; i < maxitems; i++)
{
if(strlen(items[i]) > 0)
{ {
if (i == selected) if (i == selected)
{ {
//for( w = 0; w < 32; w++ )
for( w = 0; w < (fontsize + 8); w++ ) for( w = 0; w < (fontsize + 8); w++ )
//DrawLineFast( 30, 610, (i << 5) + (ypos-26) + w, 0x80, 0x80, 0x80 ); previous DrawLineFast( 30, 610, n * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 );
DrawLineFast( 30, 610, i * (fontsize + 8) + (ypos-(fontsize + 2)) + w, 0x80, 0x80, 0x80 );
setfontcolour (0xff, 0xff, 0xff); setfontcolour (0xff, 0xff, 0xff);
//DrawText (-1, (i << 5) + ypos, items[i]); previous DrawText (x, n * (fontsize + 8) + ypos, items[i]);
DrawText (-1, i * (fontsize + 8) + ypos, items[i]);
setfontcolour (0x00, 0x00, 0x00); setfontcolour (0x00, 0x00, 0x00);
} }
else else
DrawText (-1, i * (fontsize + 8) + ypos, items[i]); {
//DrawText (-1, i * 32 + ypos, items[i]); previous DrawText (x, n * (fontsize + 8) + ypos, items[i]);
}
n++;
}
} }
showscreen (); 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);
}
/**************************************************************************** /****************************************************************************
* RunMenu * RunMenu
* *
@ -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. * It's here to keep all the font / interface stuff together.
****************************************************************************/ ****************************************************************************/
int menu = 0; int menu = 0;
int 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 redraw = 1;
int quit = 0; int quit = 0;
@ -583,7 +616,6 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
u16 ang = 0; u16 ang = 0;
u16 ang2 = 0; u16 ang2 = 0;
//while (!(PAD_ButtonsDown (0) & PAD_BUTTON_B) && (quit == 0))
while (quit == 0) while (quit == 0)
{ {
if (redraw) if (redraw)
@ -607,14 +639,14 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > 70) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) ) if ( (p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP | WPAD_CLASSIC_BUTTON_UP)) || (a > 70) || (mag>JOY_THRESHOLD && (ang>300 || ang<50)) )
{ {
redraw = 1; redraw = 1;
menu--; menu = FindMenuItem(&items[0], maxitems, menu, -1);
} }
/*** Look for down ***/ /*** 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)) ) if ( (p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_DOWN)) || (a < -70) || (mag>JOY_THRESHOLD && (ang>130 && ang<230)) )
{ {
redraw = 1; redraw = 1;
menu++; menu = FindMenuItem(&items[0], maxitems, menu, +1);
} }
if ((p & PAD_BUTTON_A) || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A))) if ((p & PAD_BUTTON_A) || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)))
@ -628,12 +660,6 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
quit = -1; quit = -1;
ret = -1; ret = -1;
} }
if (menu == maxitems)
menu = 0;
if (menu < 0)
menu = maxitems - 1;
} }
/*** Wait for B button to be released before proceeding ***/ /*** Wait for B button to be released before proceeding ***/
@ -651,6 +677,92 @@ RunMenu (char items[][20], int maxitems, char *title, int fontsize)
} }
/****************************************************************************
* 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 * DrawLine
* *
@ -845,10 +957,10 @@ void DrawLineFast( int startx, int endx, int y, u8 r, u8 g, u8 b )
} }
} }
/** /*****************************************************************************
* Ok, I'm useless with Y1CBY2CR colour. * Ok, I'm useless with Y1CBY2CR colour.
* So convert back to RGB so I can work with it -;) * So convert back to RGB so I can work with it -;)
*/ ****************************************************************************/
u32 getrgb( u32 ycbr, u32 low ) u32 getrgb( u32 ycbr, u32 low )
{ {
u8 r,g,b; u8 r,g,b;
@ -873,5 +985,3 @@ u32 getrgb( u32 ycbr, u32 low )
return (u32)( r << 16 | g << 8 | b ); return (u32)( r << 16 | g << 8 | b );
} }

View File

@ -22,13 +22,14 @@
int FT_Init (); int FT_Init ();
void setfontsize (int pixelsize); 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); void setfontcolour (u8 r, u8 g, u8 b);
int RunMenu (char items[][20], int maxitems, char *title, int fontsize = 24); void DrawText (int x, int y, char *text);
void DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsize = 24); 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); void WaitPrompt (char *msg);
int WaitPromptChoice (char *msg, char* bmsg, char* amsg); int WaitPromptChoice (char *msg, char* bmsg, char* amsg);
void ShowAction (char *msg); void ShowAction (char *msg);

View File

@ -46,8 +46,6 @@ card_dir CardDir;
card_file CardFile; card_file CardFile;
card_stat CardStatus; card_stat CardStatus;
extern void uselessinquiry();
/**************************************************************************** /****************************************************************************
* Clear the savebuffer * Clear the savebuffer
@ -89,12 +87,11 @@ CardFileExists (char *filename, int slot)
* workarounds implemented for when the mount fails. * workarounds implemented for when the mount fails.
* Returns the result of the last attempted CARD_Mount command. * Returns the result of the last attempted CARD_Mount command.
****************************************************************************/ ****************************************************************************/
int MountCard(int cslot) int MountCard(int cslot, bool8 silent)
{ {
int ret; int ret;
int tries; int tries;
EXI_ProbeReset(); EXI_ProbeReset();
// Mount the card // Mount the card
@ -118,6 +115,8 @@ int MountCard(int cslot)
while ( tries < 5 && ret == CARD_ERROR_NOCARD ) while ( tries < 5 && ret == CARD_ERROR_NOCARD )
{ {
EXI_ProbeReset (); EXI_ProbeReset ();
if(!silent)
ShowAction ((char*) "Mounting card..."); ShowAction ((char*) "Mounting card...");
CARD_Unmount (cslot); CARD_Unmount (cslot);
usleep(500000); // wait half second usleep(500000); // wait half second
@ -131,8 +130,11 @@ int MountCard(int cslot)
while ( tries < 5 && ret == CARD_ERROR_UNLOCKED ) while ( tries < 5 && ret == CARD_ERROR_UNLOCKED )
{ {
EXI_ProbeReset (); EXI_ProbeReset ();
if(!silent)
ShowAction ((char*) "Waiting for unlock..."); ShowAction ((char*) "Waiting for unlock...");
usleep(500000); // wait half second usleep(500000); // wait half second
if(!silent)
ShowAction ((char*) ""); ShowAction ((char*) "");
usleep(500000); // wait half second usleep(500000); // wait half second
ret = CARD_Probe(cslot); ret = CARD_Probe(cslot);
@ -161,7 +163,7 @@ VerifyMCFile (unsigned char *buf, int slot, char *filename, int datasize)
CARD_Init ("SNES", "00"); CARD_Init ("SNES", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot); CardError = MountCard(slot, NOTSILENT);
if (CardError == 0) if (CardError == 0)
{ {
@ -242,7 +244,7 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
CARD_Init ("SNES", "00"); CARD_Init ("SNES", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot); CardError = MountCard(slot, NOTSILENT);
if (CardError == 0) if (CardError == 0)
{ {
@ -251,7 +253,6 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
if (!CardFileExists (filename, slot)) if (!CardFileExists (filename, slot))
{ {
if ( !silent )
WaitPrompt((char*) "Unable to open file"); WaitPrompt((char*) "Unable to open file");
return 0; return 0;
} }
@ -277,9 +278,12 @@ LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent)
bytesleft -= SectorSize; bytesleft -= SectorSize;
bytesread += SectorSize; bytesread += SectorSize;
if ( !silent )
{
sprintf (msg, "Read %d of %d bytes", bytesread, blocks); sprintf (msg, "Read %d of %d bytes", bytesread, blocks);
ShowProgress (msg, bytesread, blocks); ShowProgress (msg, bytesread, blocks);
} }
}
CARD_Close (&CardFile); CARD_Close (&CardFile);
CARD_Unmount (slot); CARD_Unmount (slot);
} }
@ -309,7 +313,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
CARD_Init ("SNES", "00"); CARD_Init ("SNES", "00");
/*** Try to mount the card ***/ /*** Try to mount the card ***/
CardError = MountCard(slot); CardError = MountCard(slot, NOTSILENT);
if (CardError == 0) if (CardError == 0)
{ {
@ -409,7 +413,7 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
if (CardError) if (CardError)
{ {
CARD_Unmount (slot); CARD_Unmount (slot);
if ( CardError = CARD_ERROR_INSSPACE ) if ( CardError == CARD_ERROR_INSSPACE )
WaitPrompt((char*) "Not enough space to create file!"); WaitPrompt((char*) "Not enough space to create file!");
else else
WaitPrompt((char*) "Unable to create card file!"); WaitPrompt((char*) "Unable to create card file!");
@ -468,124 +472,4 @@ SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool
} }
/****************************************************************************
* 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);
}
}

View File

@ -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 LoadBufferFromMC (unsigned char *buf, int slot, char *filename, bool8 silent);
int SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool8 silent); int SaveBufferToMC (unsigned char *buf, int slot, char *filename, int datasize, bool8 silent);
int MountCard(int cslot, 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);
#endif #endif

View File

@ -30,6 +30,7 @@
#include "filesel.h" #include "filesel.h"
#include "ftfont.h" #include "ftfont.h"
#include "smbload.h" #include "smbload.h"
#include "sdload.h"
#include "mcsave.h" #include "mcsave.h"
extern "C" extern "C"
@ -131,8 +132,11 @@ NGCFreezeMemBuffer ()
* Do freeze game for Nintendo Gamecube * Do freeze game for Nintendo Gamecube
*/ */
int int
NGCFreezeGame (int where, bool8 silent) NGCFreezeGame (int method, bool8 silent)
{ {
if(method == METHOD_AUTO)
method = autoSaveMethod();
char filename[1024]; char filename[1024];
SMBFILE smbfile; SMBFILE smbfile;
FILE *handle; FILE *handle;
@ -141,27 +145,22 @@ NGCFreezeGame (int where, bool8 silent)
int offset = 0; int offset = 0;
char msg[100]; char msg[100];
if (where == 4) if (method == METHOD_SD) // SD
{ {
/*** Freeze to SMB ***/ sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
sprintf (filename, "/%s/%s.frz", SNESSAVEDIR, Memory.ROMFilename);
} }
else if (where == 2 || where == 3) if (method == METHOD_USB) // USB
{ {
/*** Freeze to SDCard in slot A or slot B ***/ sprintf (filename, "%s/%s/%s.frz", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
#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 else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC Slot A or B
{ {
/*** Freeze to MC in slot A or slot B ***/
sprintf (filename, "%s.snz", Memory.ROMFilename); sprintf (filename, "%s.snz", Memory.ROMFilename);
} }
else if (method == METHOD_SMB) // SMB
{
sprintf (filename, "/%s/%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
}
S9xSetSoundMute (TRUE); S9xSetSoundMute (TRUE);
S9xPrepareSoundForSnapshotSave (FALSE); S9xPrepareSoundForSnapshotSave (FALSE);
@ -171,7 +170,86 @@ NGCFreezeGame (int where, bool8 silent)
S9xPrepareSoundForSnapshotSave (TRUE); S9xPrepareSoundForSnapshotSave (TRUE);
S9xSetSoundMute (FALSE); S9xSetSoundMute (FALSE);
if (where == 4) /*** SMB ***/ if (method == METHOD_SD || method == METHOD_USB) // FAT devices
{
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
{
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.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;
int decompressedsize = (int)bufoffset;
memcpy (savebuffer + offset, &decompressedsize, 4);
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 (); ConnectSMB ();
@ -211,82 +289,10 @@ NGCFreezeGame (int where, bool8 silent)
else else
{ {
char msg[100]; char msg[100];
sprintf(msg, "Couldn't save to SMB:\\%s\\", SNESSAVEDIR); sprintf(msg, "Couldn't save to SMB:\\%s\\", GCSettings.SaveFolder);
WaitPrompt (msg); 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 ***/
{
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;
}
int zippedsize = (int)DestBuffSize;
memcpy (savebuffer + offset, &zippedsize, 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);
}
}
return 0; return 0;
} }
@ -331,7 +337,7 @@ NGCUnFreezeBlock (char *name, uint8 * block, int size)
* NGCUnfreezeGame * NGCUnfreezeGame
*/ */
int int
NGCUnfreezeGame (int from, bool8 silent) NGCUnfreezeGame (int method, bool8 silent)
{ {
char filename[1024]; char filename[1024];
SMBFILE smbfile; SMBFILE smbfile;
@ -342,63 +348,31 @@ NGCUnfreezeGame (int from, bool8 silent)
bufoffset = 0; bufoffset = 0;
if (from == 4) if(method == METHOD_AUTO)
{ method = autoLoadMethod();
/*** From SMB ***/
sprintf (filename, "\\%s\\%s.frz", SNESSAVEDIR, Memory.ROMFilename);
ConnectSMB ();
/*** Read the file into memory ***/ if (method == METHOD_SD || method == METHOD_USB) // SD & USB
smbfile =
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
if (smbfile)
{ {
ShowAction ((char*) "Loading freeze file..."); if(method == METHOD_SD)
while ((read = sprintf (filename, "%s/%s/%s.frz", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
SMB_Read ((char *) membuffer + offset, 1024, offset, else
smbfile)) > 0) sprintf (filename, "%s/%s/%s.frz", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
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;
}
}
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"); handle = fopen (filename, "rb");
if (handle > 0) if (handle > 0)
{ {
if ( !silent )
ShowAction ((char*) "Loading freeze file..."); ShowAction ((char*) "Loading freeze file...");
offset = 0; offset = 0;
/*** Usual chunks into memory ***/ /*** Usual chunks into memory ***/
while ((read = fread (membuffer + offset, 1, 2048, handle)) > while ((read = fread (membuffer + offset, 1, 2048, handle)) > 0)
0)
offset += read; offset += read;
fclose (handle); fclose (handle);
if ( !silent )
ShowAction ((char*) "Unpacking freeze file"); ShowAction ((char*) "Unpacking freeze file");
if (S9xUnfreezeGame ("AGAME") != SUCCESS) if (S9xUnfreezeGame ("AGAME") != SUCCESS)
@ -407,21 +381,31 @@ NGCUnfreezeGame (int from, bool8 silent)
return 0; return 0;
} }
} }
else if ( !silent ) else
{ {
WaitPrompt((char*) "No freeze file found"); WaitPrompt((char*) "No freeze file found");
return 0; return 0;
} }
return 1;
} }
else /*** From MC in slot A or slot B ***/
else if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB) // MC in slot A or slot B
{ {
if ( !silent )
ShowAction ((char*) "Loading freeze file..."); ShowAction ((char*) "Loading freeze file...");
sprintf (filename, "%s.snz", Memory.ROMFilename); sprintf (filename, "%s.snz", Memory.ROMFilename);
int ret = LoadBufferFromMC ( savebuffer, from, filename, silent ); int ret = 0;
if(method == METHOD_MC_SLOTA)
LoadBufferFromMC ( savebuffer, CARD_SLOTA, filename, silent );
else
LoadBufferFromMC ( savebuffer, CARD_SLOTB, filename, silent );
if ( ret ) if ( ret )
{ {
if ( !silent )
ShowAction ((char*) "Unpacking freeze file"); ShowAction ((char*) "Unpacking freeze file");
// skip the saveicon and comment // skip the saveicon and comment
@ -459,31 +443,58 @@ NGCUnfreezeGame (int from, bool8 silent)
return 0; return 0;
} }
} }
else if ( !silent ) else
{ {
sprintf(msg, "Couldn't load from MC slot %s", (from ? "B" : "A"));
WaitPrompt (msg);
return 0; return 0;
} }
}
return 1; return 1;
}
else if (method == METHOD_SMB) // Network (SMB)
{
sprintf (filename, "\\%s\\%s.frz", GCSettings.SaveFolder, Memory.ROMFilename);
ConnectSMB ();
/*** Read the file into memory ***/
smbfile =
SMB_Open (filename, SMB_OPEN_READING | SMB_DENY_NONE, SMB_OF_OPEN);
if (smbfile)
{
if ( !silent )
ShowAction ((char*) "Loading freeze file...");
while ((read =
SMB_Read ((char *) membuffer + offset, 1024, offset,
smbfile)) > 0)
offset += read;
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 0; // if we reached here, nothing was done!
} }
void quickLoadFreeze (bool8 silent) void quickLoadFreeze (bool8 silent)
{ {
if ( QUICK_SAVE_SLOT >= 0 ) NGCUnfreezeGame ( GCSettings.SaveMethod, silent );
NGCUnfreezeGame ( QUICK_SAVE_SLOT, silent );
} }
void quickSaveFreeze (bool8 silent) void quickSaveFreeze (bool8 silent)
{ {
if ( QUICK_SAVE_SLOT >= 0 ) NGCFreezeGame ( GCSettings.SaveMethod, silent );
NGCFreezeGame ( QUICK_SAVE_SLOT, silent );
} }

View File

@ -25,8 +25,8 @@ typedef struct
} }
MEMFILE; MEMFILE;
int NGCFreezeGame (int where, bool8 silent); int NGCFreezeGame (int method, bool8 silent);
int NGCUnfreezeGame (int from, bool8 silent); int NGCUnfreezeGame (int method, bool8 silent);
void quickLoadFreeze (bool8 silent); void quickLoadFreeze (bool8 silent);
void quickSaveFreeze (bool8 silent); void quickSaveFreeze (bool8 silent);

View File

@ -43,7 +43,13 @@
#include "button_mapping.h" #include "button_mapping.h"
#include "ftfont.h" #include "ftfont.h"
extern void DrawMenu (char items[][20], char *title, int maxitems, int selected, int fontsize); #include "cheats.h"
#include "cheatmgr.h"
extern void DrawMenu (char items[][50], char *title, int maxitems, int selected, int fontsize);
extern SCheatData Cheat;
#define PSOSDLOADID 0x7c6000a6 #define PSOSDLOADID 0x7c6000a6
extern int menu; extern int menu;
@ -51,6 +57,9 @@ extern unsigned long ARAM_ROMSIZE;
#define SOFTRESET_ADR ((volatile u32*)0xCC003024) #define SOFTRESET_ADR ((volatile u32*)0xCC003024)
/****************************************************************************
* Reboot
****************************************************************************/
void Reboot() { void Reboot() {
#ifdef HW_RVL #ifdef HW_RVL
@ -61,407 +70,331 @@ void Reboot() {
#endif #endif
} }
/****************************************************************************
* Freeze Manager
****************************************************************************/
int freezecountwii = 7;
char freezemenuwii[][20] = { "Freeze to SD", "Thaw from SD",
"Freeze to MC Slot A", "Thaw from MC Slot A",
"Freeze to MC Slot B", "Thaw from MC Slot B",
"Return to previous"
};
int freezecount = 9;
char freezemenu[][20] = { "Freeze to SD", "Thaw from SD",
"Freeze to MC Slot A", "Thaw from MC Slot A",
"Freeze to MC Slot B", "Thaw from MC Slot B",
"Freeze to SMB", "Thaw from SMB",
"Return to previous"
};
int
FreezeManager ()
{
int ret;
int loaded = 0;
int quit = 0;
int oldmenu = menu;
menu = 0;
while (quit == 0)
{
if ( isWii ) /* Wii menu */
{
ret = RunMenu (freezemenuwii, freezecountwii, (char*)"Freeze Manager");
if (ret >= freezecountwii-1)
ret = freezecount-1;
}
else /* Gamecube menu */
ret = RunMenu (freezemenu, freezecount, (char*)"Freeze Manager");
switch (ret)
{
case 0:/*** Freeze to SDCard ***/
NGCFreezeGame (2, NOTSILENT);
break;
case 1:/*** Thaw from SDCard***/
quit = loaded = NGCUnfreezeGame (2, NOTSILENT);
break;
case 2:/*** Freeze to MC in slot A ***/
NGCFreezeGame (0, NOTSILENT);
break;
case 3:/*** Thaw from MC in slot A ***/
quit = loaded = NGCUnfreezeGame (0, NOTSILENT);
break;
case 4:/*** Freeze to MC in slot B ***/
NGCFreezeGame (1, NOTSILENT);
break;
case 5:/*** Thaw from MC in slot B ***/
quit = loaded = NGCUnfreezeGame (1, NOTSILENT);
break;
case 6:/*** Freeze to SMB ***/
if ( !isWii )
NGCFreezeGame (4, NOTSILENT);
break;
case 7:/*** Thaw from SMB ***/
if ( !isWii )
quit = loaded = NGCUnfreezeGame (4, NOTSILENT);
break;
case -1: /*** Button B ***/
case 8:
quit = 1;
break;
}
}
menu = oldmenu;
return loaded;
}
/**************************************************************************** /****************************************************************************
* Load Manager * Load Manager
****************************************************************************/ ****************************************************************************/
int loadmancountwii = 3;
char loadmanwii[][20] = { "Load from SD",
"Load from USB", "Return to previous"
};
int loadmancount = 4;
char loadman[][20] = { "Load from SD",
"Load from DVD", "Load from SMB", "Return to previous"
};
int int
LoadManager () LoadManager ()
{ {
int ret; int loadROM = OpenROM(GCSettings.LoadMethod);
int quit = 0;
int oldmenu = menu;
int retval = 1;
menu = 0;
while (quit == 0)
{
#ifdef HW_RVL
/* Wii menu */
ret = RunMenu (loadmanwii, loadmancountwii, (char*)"Load Manager");
switch (ret)
{
case 0:
/*** Load from SD ***/
quit = OpenSD ();
break;
case 1:
/*** Load from USB ***/
quit = OpenUSB ();
break;
case -1: /*** Button B ***/
case 2:
retval = 0;
quit = 1;
break;
}
#else
/* Gamecube menu */
ret = RunMenu (loadman, loadmancount, (char*)"Load Manager");
switch (ret)
{
case 0:
/*** Load from SD ***/
quit = OpenSD ();
break;
case 1:
/*** Load from DVD ***/
quit = OpenDVD ();
break;
case 2:
/*** Load from SMB ***/ //(gamecube option)
quit = OpenSMB ();
break;
case -1: /*** Button B ***/
case 3:
retval = 0;
quit = 1;
break;
}
#endif
}
/*** /***
* check for autoloadsram / freeze * check for autoloadsram / freeze
***/ ***/
if ( retval == 1 ) // if ROM was loaded, load the SRAM & settings if ( loadROM == 1 ) // if ROM was loaded, load the SRAM & settings
{ {
if ( GCSettings.AutoLoad == 1 ) if ( GCSettings.AutoLoad == 1 )
{
quickLoadSRAM ( SILENT ); quickLoadSRAM ( SILENT );
S9xSoftReset(); // reset after loading sram
}
else if ( GCSettings.AutoLoad == 2 ) else if ( GCSettings.AutoLoad == 2 )
{
quickLoadFreeze ( SILENT ); quickLoadFreeze ( SILENT );
}
// setup cheats
SetupCheats();
} }
menu = oldmenu; return loadROM;
return retval;
} }
/**************************************************************************** /****************************************************************************
* Save Manager * Preferences Menu
****************************************************************************/ ****************************************************************************/
int savecountwii = 7; static int prefmenuCount = 15;
char savemenuwii[][20] = { "Save to SD", "Load from SD", static char prefmenu[][50] = {
"Save to MC SLOT A", "Load from MC SLOT A",
"Save to MC SLOT B", "Load from MC SLOT B",
"Return to previous"
};
int savecount = 9;
char savemenu[][20] = { "Save to SD", "Load from SD",
"Save to MC SLOT A", "Load from MC SLOT A",
"Save to MC SLOT B", "Load from MC SLOT B",
"Save to SMB", "Load from SMB",
"Return to previous"
};
void
SaveManager ()
{
int ret;
int quit = 0;
int oldmenu = menu;
menu = 0;
while (quit == 0) "Load Method",
{ "Load Folder",
if ( isWii ) /* Wii menu */ "Save Method",
{ "Save Folder",
ret = RunMenu (savemenuwii, savecountwii, (char*)"SRAM Manager");
if (ret >= savecountwii-1)
ret = savecount-1;
}
else /* Gamecube menu */
ret = RunMenu (savemenu, savecount, (char*)"SRAM Manager");
switch (ret) "Auto Load",
{ "Auto Save",
case 0: "Verify MC Saves",
/*** Save to SD***/
SaveSRAMToSD (NOTSILENT);
break;
case 1: "Reverse Stereo",
/*** Load from SD***/ "Interpolated Sound",
LoadSRAMFromSD (NOTSILENT); "Transparency",
break; "Display Frame Rate",
"C-Stick Zoom",
"Video Filtering",
case 2: "Save Preferences",
/*** Save to MC slot A ***/ "Back to Main Menu"
SaveSRAMToMC (CARD_SLOTA, NOTSILENT);
break;
case 3:
/*** Load from MC slot A ***/
LoadSRAMFromMC (CARD_SLOTA, NOTSILENT);
break;
case 4:
/*** Save to MC slot B ***/
SaveSRAMToMC (CARD_SLOTB, NOTSILENT);
break;
case 5:
/*** Load from MC slot B ***/
LoadSRAMFromMC (CARD_SLOTB, NOTSILENT);
break;
case 6:
/*** Save to SMB **/
SaveSRAMToSMB (NOTSILENT);
break;
case 7:
/*** Load from SMB ***/
LoadSRAMFromSMB (NOTSILENT);
break;
case -1: /*** Button B ***/
case 8:
/*** Return ***/
quit = 1;
break;
}
}
menu = oldmenu;
}
/****************************************************************************
* Emulator Options
****************************************************************************/
static int emuCount = 12;
static char emulatorOptions[][20] = { "Reverse Stereo OFF",
"Interp. Sound ON", "Transparency ON", "FPS Display OFF",
"MultiTap 5 OFF", "C-Stick Zoom OFF",
"Auto Load OFF", "Auto Save OFF", "Verify MC Saves OFF",
"Video Filtering OFF", "Superscope OFF",
"Save Prefs Now", "Return to previous"
}; };
void void
EmulatorOptions () PreferencesMenu ()
{ {
int ret = 0; int ret = 0;
int quit = 0; int quit = 0;
int oldmenu = menu; int oldmenu = menu;
menu = 0; menu = 0;
while (quit == 0) while (quit == 0)
{ {
sprintf (emulatorOptions[0], "Reverse Stereo %s", // some load/save methods are not implemented - here's where we skip them
Settings.ReverseStereo == true ? " ON" : "OFF");
sprintf (emulatorOptions[1], "Interp. Sound %s", #ifndef HW_RVL // GameCube mode
Settings.InterpolatedSound == true ? " ON" : "OFF"); if(GCSettings.LoadMethod == METHOD_USB)
GCSettings.LoadMethod++;
if(GCSettings.SaveMethod == METHOD_USB)
GCSettings.SaveMethod++;
#else // Wii mode
if(GCSettings.LoadMethod == METHOD_DVD)
GCSettings.LoadMethod++;
#endif
sprintf (emulatorOptions[2], "Transparency %s", if(GCSettings.SaveMethod == METHOD_DVD) // saving to DVD is impossible
Settings.Transparency == true ? " ON" : "OFF"); GCSettings.SaveMethod++;
sprintf (emulatorOptions[3], "FPS Display %s", if(GCSettings.SaveMethod == METHOD_SMB) // disable SMB - network saving needs some work
Settings.DisplayFrameRate == true ? " ON" : "OFF"); GCSettings.SaveMethod++;
sprintf (emulatorOptions[4], "MultiTap 5 %s", if(GCSettings.LoadMethod == METHOD_SMB) // disable SMB - network loading needs some work
Settings.MultiPlayer5Master == true ? " ON" : "OFF"); GCSettings.LoadMethod++;
sprintf (emulatorOptions[5], "C-Stick Zoom %s", // correct load/save methods out of bounds
GCSettings.NGCZoom == true ? " ON" : "OFF"); if(GCSettings.LoadMethod > 4)
GCSettings.LoadMethod = 0;
if(GCSettings.SaveMethod > 6)
GCSettings.SaveMethod = 0;
if (GCSettings.AutoLoad == 0) sprintf (emulatorOptions[6],"Auto Load OFF"); if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (prefmenu[0],"Load Method AUTO");
else if (GCSettings.AutoLoad == 1) sprintf (emulatorOptions[6],"Auto Load SRAM"); else if (GCSettings.LoadMethod == METHOD_SD) sprintf (prefmenu[0],"Load Method SD");
else if (GCSettings.AutoLoad == 2) sprintf (emulatorOptions[6],"Auto Load FREEZE"); else if (GCSettings.LoadMethod == METHOD_USB) sprintf (prefmenu[0],"Load Method USB");
else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (prefmenu[0],"Load Method DVD");
else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (prefmenu[0],"Load Method Network");
if (GCSettings.AutoSave == 0) sprintf (emulatorOptions[7],"Auto Save OFF"); sprintf (prefmenu[1], "Load Folder %s", GCSettings.LoadFolder);
else if (GCSettings.AutoSave == 1) sprintf (emulatorOptions[7],"Auto Save SRAM");
else if (GCSettings.AutoSave == 2) sprintf (emulatorOptions[7],"Auto Save FREEZE");
else if (GCSettings.AutoSave == 3) sprintf (emulatorOptions[7],"Auto Save BOTH");
sprintf (emulatorOptions[8], "Verify MC Saves %s", if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (prefmenu[2],"Save Method AUTO");
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (prefmenu[2],"Save Method SD");
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (prefmenu[2],"Save Method USB");
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (prefmenu[2],"Save Method Network");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (prefmenu[2],"Save Method MC Slot A");
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (prefmenu[2],"Save Method MC Slot B");
sprintf (prefmenu[3], "Save Folder %s", GCSettings.SaveFolder);
// disable changing load/save directories for now
prefmenu[1][0] = '\0';
prefmenu[3][0] = '\0';
if (GCSettings.AutoLoad == 0) sprintf (prefmenu[4],"Auto Load OFF");
else if (GCSettings.AutoLoad == 1) sprintf (prefmenu[4],"Auto Load SRAM");
else if (GCSettings.AutoLoad == 2) sprintf (prefmenu[4],"Auto Load FREEZE");
if (GCSettings.AutoSave == 0) sprintf (prefmenu[5],"Auto Save OFF");
else if (GCSettings.AutoSave == 1) sprintf (prefmenu[5],"Auto Save SRAM");
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save FREEZE");
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
sprintf (prefmenu[6], "Verify MC Saves %s",
GCSettings.VerifySaves == true ? " ON" : "OFF"); GCSettings.VerifySaves == true ? " ON" : "OFF");
sprintf (emulatorOptions[9], "Video Filtering %s", sprintf (prefmenu[7], "Reverse Stereo %s",
Settings.ReverseStereo == true ? " ON" : "OFF");
sprintf (prefmenu[8], "Interpolated Sound %s",
Settings.InterpolatedSound == true ? " ON" : "OFF");
sprintf (prefmenu[9], "Transparency %s",
Settings.Transparency == true ? " ON" : "OFF");
sprintf (prefmenu[10], "Display Frame Rate %s",
Settings.DisplayFrameRate == true ? " ON" : "OFF");
sprintf (prefmenu[11], "C-Stick Zoom %s",
GCSettings.NGCZoom == true ? " ON" : "OFF");
sprintf (prefmenu[12], "Video Filtering %s",
GCSettings.render == true ? " ON" : "OFF"); GCSettings.render == true ? " ON" : "OFF");
if (GCSettings.Superscope > 0) sprintf (emulatorOptions[10], "Superscope: Pad %d", GCSettings.Superscope); ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16);
else sprintf (emulatorOptions[10], "Superscope OFF");
ret = RunMenu (emulatorOptions, emuCount, (char*)"Emulator Options", 18);
switch (ret) switch (ret)
{ {
case 0: case 0:
Settings.ReverseStereo ^= 1; GCSettings.LoadMethod ++;
break; break;
case 1: case 1:
Settings.InterpolatedSound ^= 1;
break; break;
case 2: case 2:
Settings.Transparency ^= 1; GCSettings.SaveMethod ++;
break; break;
case 3: case 3:
Settings.DisplayFrameRate ^= 1;
break; break;
case 4: case 4:
Settings.MultiPlayer5Master ^= 1;
if (Settings.MultiPlayer5Master)
{
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
}
else
{
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
}
break;
case 5:
GCSettings.NGCZoom ^= 1;
break;
case 6:
GCSettings.AutoLoad ++; GCSettings.AutoLoad ++;
if (GCSettings.AutoLoad > 2) if (GCSettings.AutoLoad > 2)
GCSettings.AutoLoad = 0; GCSettings.AutoLoad = 0;
break; break;
case 7: case 5:
GCSettings.AutoSave ++; GCSettings.AutoSave ++;
if (GCSettings.AutoSave > 3) if (GCSettings.AutoSave > 3)
GCSettings.AutoSave = 0; GCSettings.AutoSave = 0;
break; break;
case 8: case 6:
GCSettings.VerifySaves ^= 1; GCSettings.VerifySaves ^= 1;
break; break;
case 7:
Settings.ReverseStereo ^= 1;
break;
case 8:
Settings.InterpolatedSound ^= 1;
break;
case 9: case 9:
GCSettings.render ^= 1; Settings.Transparency ^= 1;
break; break;
case 10: case 10:
GCSettings.Superscope ++; Settings.DisplayFrameRate ^= 1;
if (GCSettings.Superscope > 4)
GCSettings.Superscope = 0;
break; break;
case 11: case 11:
GCSettings.NGCZoom ^= 1;
break;
case 12:
GCSettings.render ^= 1;
break;
case 13:
quickSavePrefs(NOTSILENT); quickSavePrefs(NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/
case 12: case 14:
quit = 1; quit = 1;
break; break;
} }
} }
menu = oldmenu;
}
/****************************************************************************
* Cheat Menu
****************************************************************************/
static int cheatmenuCount = 0;
static char cheatmenu[MAX_CHEATS][50];
void CheatMenu()
{
int ret = -1;
int oldmenu = menu;
menu = 0;
if(Cheat.num_cheats > 0)
{
cheatmenuCount = Cheat.num_cheats + 1;
sprintf (cheatmenu[cheatmenuCount-1], "Back to Game Menu");
while(ret != cheatmenuCount-1)
{
if(ret >= 0)
{
if(Cheat.c[ret].enabled)
S9xDisableCheat(ret);
else
S9xEnableCheat(ret);
}
for(uint16 i=0; i < Cheat.num_cheats; i++)
sprintf (cheatmenu[i], "%s %s", Cheat.c[i].name, Cheat.c[i].enabled == true ? " ON" : "OFF");
ret = RunMenu (cheatmenu, cheatmenuCount, (char*)"Cheats", 16);
}
}
else
{
WaitPrompt((char*)"Cheat file not found!");
}
menu = oldmenu;
}
/****************************************************************************
* Game Options Menu
****************************************************************************/
static int gamemenuCount = 9;
static char gamemenu[][50] = {
"Return to Game",
"Reset Game",
"ROM Information",
"Cheats",
"Load SRAM", "Save SRAM",
"Load Freeze", "Save Freeze",
"Back to Main Menu"
};
int
GameMenu ()
{
int ret, retval = 0;
int quit = 0;
int oldmenu = menu;
menu = 0;
while (quit == 0)
{
ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Options");
switch (ret)
{
case 0: // Return to Game
quit = retval = 1;
break;
case 1: // Reset Game
S9xSoftReset ();
quit = retval = 1;
break;
case 2: // ROM Information
RomInfo();
WaitButtonA ();
break;
case 3: // load cheats
CheatMenu();
break;
case 4: // Load SRAM
LoadSRAM(GCSettings.SaveMethod, NOTSILENT);
break;
case 5: // Save SRAM
SaveSRAM(GCSettings.SaveMethod, NOTSILENT);
break;
case 6: // Load Freeze
quit = retval = NGCUnfreezeGame (GCSettings.SaveMethod, SILENT);
break;
case 7: // Save Freeze
NGCFreezeGame (GCSettings.SaveMethod, NOTSILENT);
break;
case -1: // Button B
case 8: // Return to previous menu
retval = 0;
quit = 1;
break;
}
}
menu = oldmenu; menu = oldmenu;
return retval;
} }
/**************************************************************************** /****************************************************************************
@ -474,7 +407,8 @@ EmulatorOptions ()
u32 u32
GetInput (u16 ctrlr_type) GetInput (u16 ctrlr_type)
{ {
u32 exp_type, pressed; //u32 exp_type;
u32 pressed;
pressed=0; pressed=0;
s8 gc_px = 0; s8 gc_px = 0;
@ -519,7 +453,7 @@ GetInput (u16 ctrlr_type)
} // end GetInput() } // end GetInput()
int cfg_text_count = 7; int cfg_text_count = 7;
char cfg_text[][20] = { char cfg_text[][50] = {
"Remapping ", "Remapping ",
"Press Any Button", "Press Any Button",
"on the", "on the",
@ -533,7 +467,7 @@ u32
GetButtonMap(u16 ctrlr_type, char* btn_name) GetButtonMap(u16 ctrlr_type, char* btn_name)
{ {
u32 pressed, previous; u32 pressed, previous;
char temp[20] = ""; char temp[50] = "";
int k; int k;
pressed = 0; previous = 1; pressed = 0; previous = 1;
@ -570,7 +504,7 @@ GetButtonMap(u16 ctrlr_type, char* btn_name)
} // end getButtonMap() } // end getButtonMap()
int cfg_btns_count = 13; int cfg_btns_count = 13;
char cfg_btns_menu[][20] = { char cfg_btns_menu[][50] = {
"A - ", "A - ",
"B - ", "B - ",
"X - ", "X - ",
@ -602,7 +536,7 @@ ConfigureButtons (u16 ctrlr_type)
u32 pressed; u32 pressed;
unsigned int* currentpadmap; unsigned int* currentpadmap;
char temp[20] = ""; char temp[50] = "";
int i, j, k; int i, j, k;
/*** Update Menu Title (based on controller we're configuring) ***/ /*** Update Menu Title (based on controller we're configuring) ***/
@ -649,7 +583,7 @@ ConfigureButtons (u16 ctrlr_type)
} }
ret = RunMenu (cfg_btns_menu, cfg_btns_count, menu_title, 18); ret = RunMenu (cfg_btns_menu, cfg_btns_count, menu_title, 16);
switch (ret) switch (ret)
{ {
@ -682,23 +616,19 @@ ConfigureButtons (u16 ctrlr_type)
break; break;
} }
} }
menu = oldmenu; menu = oldmenu;
} // end configurebuttons() } // end configurebuttons()
int cfg_ctrlr_count_wii = 6; int ctlrmenucount = 8;
char cfg_ctrlr_menu_wii[][20] = { "Nunchuk", char ctlrmenu[][50] = {
"MultiTap",
"SuperScope",
"Nunchuk",
"Classic Controller", "Classic Controller",
"Gamecube Pad", "Gamecube Pad",
"Wiimote", "Wiimote",
"Save Prefs Now", "Save Preferences",
"Return to previous" "Go Back"
};
int cfg_ctrlr_count_gc = 3;
char cfg_ctrlr_menu_gc[][20] = { "Gamecube Pad",
"Save Prefs Now",
"Return to previous"
}; };
void void
@ -709,68 +639,69 @@ ConfigureControllers ()
int oldmenu = menu; int oldmenu = menu;
menu = 0; menu = 0;
// disable unavailable controller options if in GC mode
#ifndef HW_RVL
ctlrmenu[1][0] = '\0';
ctlrmenu[2][0] = '\0';
ctlrmenu[4][0] = '\0';
#endif
while (quit == 0) while (quit == 0)
{ {
#ifdef HW_RVL sprintf (ctlrmenu[0], "MultiTap %s", Settings.MultiPlayer5Master == true ? " ON" : "OFF");
/*** Wii Controller Config Menu ***/
ret = RunMenu (cfg_ctrlr_menu_wii, cfg_ctrlr_count_wii, (char*)"Configure Controllers"); if (GCSettings.Superscope > 0)
sprintf (ctlrmenu[1], "Superscope: Pad %d", GCSettings.Superscope);
else
sprintf (ctlrmenu[1], "Superscope OFF");
/*** Controller Config Menu ***/
ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers");
switch (ret) switch (ret)
{ {
case 0: case 0:
Settings.MultiPlayer5Master = (Settings.MultiPlayer5Master == false ? true : false);
if (Settings.MultiPlayer5Master)
S9xSetController (1, CTL_MP5, 1, 2, 3, -1);
else
S9xSetController (1, CTL_JOYPAD, 1, 0, 0, 0);
break;
case 1:
GCSettings.Superscope ++;
if (GCSettings.Superscope > 4)
GCSettings.Superscope = 0;
case 2:
/*** Configure Nunchuk ***/ /*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_NUNCHUK); ConfigureButtons (CTRLR_NUNCHUK);
break; break;
case 1: case 3:
/*** Configure Classic ***/ /*** Configure Classic ***/
ConfigureButtons (CTRLR_CLASSIC); ConfigureButtons (CTRLR_CLASSIC);
break; break;
case 2: case 4:
/*** Configure GC Pad ***/ /*** Configure GC Pad ***/
ConfigureButtons (CTRLR_GCPAD); ConfigureButtons (CTRLR_GCPAD);
break; break;
case 3: case 5:
/*** Configure Wiimote ***/ /*** Configure Wiimote ***/
ConfigureButtons (CTRLR_WIIMOTE); ConfigureButtons (CTRLR_WIIMOTE);
break; break;
case 4: case 6:
/*** Save Preferences Now ***/ /*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT); quickSavePrefs(NOTSILENT);
break; break;
case -1: /*** Button B ***/ case -1: /*** Button B ***/
case 5: case 7:
/*** Return ***/ /*** Return ***/
quit = 1; quit = 1;
break; break;
} }
#else
/*** Gamecube Controller Config Menu ***/
ret = RunMenu (cfg_ctrlr_menu_gc, cfg_ctrlr_count_gc, (char*)"Configure Controllers");
switch (ret)
{
case 0:
/*** Configure Nunchuk ***/
ConfigureButtons (CTRLR_GCPAD);
break;
case 1:
/*** Save Preferences Now ***/
quickSavePrefs(NOTSILENT);
break;
case -1: /*** Button B ***/
case 2:
/*** Return ***/
quit = 1;
break;
}
#endif
} }
menu = oldmenu; menu = oldmenu;
@ -779,79 +710,76 @@ ConfigureControllers ()
/**************************************************************************** /****************************************************************************
* Main Menu * Main Menu
****************************************************************************/ ****************************************************************************/
int menucount = 10; int menucount = 7;
char menuitems[][20] = { "Choose Game", char menuitems[][50] = {
"SRAM Manager", "Freeze Manager", "Choose Game", "Controller Configuration", "Preferences",
"Config Controllers", "Emulator Options", "Game Menu",
"Reset Game", "Stop DVD Drive", "Exit to Loader", "Credits", "Reset System", "Exit"
"Reboot System", "Return to Game"
}; };
void void
mainmenu () mainmenu (int selectedMenu)
{ {
int quit = 0; int quit = 0;
int ret; int ret;
int *psoid = (int *) 0x80001800; int *psoid = (int *) 0x80001800;
void (*PSOReload) () = (void (*)()) 0x80001800; void (*PSOReload) () = (void (*)()) 0x80001800;
if ( isWii ) // disable game-specific menu items if a ROM isn't loaded
sprintf (menuitems[8],"Reset Wii"); if ( ARAM_ROMSIZE == 0 )
menuitems[3][0] = '\0';
else else
sprintf (menuitems[8],"Reset Gamecube"); sprintf (menuitems[3], "Game Menu");
VIDEO_WaitVSync (); VIDEO_WaitVSync ();
while (quit == 0) while (quit == 0)
{
if(selectedMenu >= 0)
{
ret = selectedMenu;
selectedMenu = -1; // default back to main menu
}
else
{ {
ret = RunMenu (menuitems, menucount, (char*)"Main Menu"); ret = RunMenu (menuitems, menucount, (char*)"Main Menu");
}
switch (ret) switch (ret)
{ {
case 0: case 0:
/*** Load ROM Menu ***/ // Load ROM Menu
quit = LoadManager (); quit = LoadManager ();
break; break;
case 1: case 1:
/*** SRAM Manager Menu ***/ // Configure Controllers
if ( ARAM_ROMSIZE > 0 )
SaveManager ();
else
WaitPrompt((char*) "No ROM is loaded!");
break;
case 2:
/*** Do Freeze / Thaw Menu ***/
if ( ARAM_ROMSIZE > 0 )
quit = FreezeManager ();
else
WaitPrompt((char*) "No ROM is loaded!");
break;
case 3:
/*** Configure Controllers ***/
ConfigureControllers (); ConfigureControllers ();
break; break;
case 2:
// Preferences
PreferencesMenu ();
break;
case 3:
// Game Options
quit = GameMenu ();
break;
case 4: case 4:
/*** Emulator Options ***/ // Credits
EmulatorOptions (); Credits ();
WaitButtonA ();
break; break;
case 5: case 5:
/*** Soft reset ***/ // Reset the Gamecube/Wii
S9xSoftReset (); Reboot();
quit = 1;
break; break;
case 6: case 6:
/*** Turn off DVD motor ***/ // Exit to Loader
dvd_motor_off();
break;
case 7:
/*** Exit to Loader ***/
#ifdef HW_RVL #ifdef HW_RVL
exit(0); exit(0);
#else // gamecube #else // gamecube
@ -860,17 +788,10 @@ mainmenu ()
#endif #endif
break; break;
case 8: case -1: // Button B
/*** Reset the Gamecube/Wii ***/ // Return to Game
Reboot();
break;
case -1: /*** Button B ***/
case 9:
/*** Return to Game ***/
quit = 1; quit = 1;
break; break;
} }
} }
@ -885,6 +806,7 @@ mainmenu ()
#endif #endif
ReInitGCVideo(); // update video after reading settings ReInitGCVideo(); // update video after reading settings
Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false); // update superscope settings Settings.SuperScopeMaster = (GCSettings.Superscope > 0 ? true : false); // update superscope settings
// update mouse/justifier info? // update mouse/justifier info?
SetControllers(); SetControllers();

View File

@ -10,6 +10,6 @@
#define _NGCMENU_ #define _NGCMENU_
void mainmenu (); void mainmenu (int selectedMenu);
#endif #endif

View File

@ -21,6 +21,7 @@
#include "mcsave.h" #include "mcsave.h"
#include "sdload.h" #include "sdload.h"
#include "smbload.h" #include "smbload.h"
#include "filesel.h"
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
extern int currconfig[4]; extern int currconfig[4];
@ -31,14 +32,15 @@ extern unsigned int wmpadmap[];
extern unsigned int ccpadmap[]; extern unsigned int ccpadmap[];
extern unsigned int ncpadmap[]; 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"} }; char prefscomment[2][32] = { {PREFSVERSTRING}, {"Preferences"} };
/**************************************************************************** /****************************************************************************
* Prepare Preferences Data * Prepare Preferences Data
* *
* This sets up the save buffer for saving to a memory card. * This sets up the save buffer for saving.
****************************************************************************/ ****************************************************************************/
int int
preparePrefsData () preparePrefsData ()
@ -83,7 +85,7 @@ preparePrefsData ()
/**************************************************************************** /****************************************************************************
* Decode Preferences Data * Decode Preferences Data
****************************************************************************/ ****************************************************************************/
void bool
decodePrefsData () decodePrefsData ()
{ {
int offset; int offset;
@ -109,45 +111,131 @@ decodePrefsData ()
memcpy (&ccpadmap, savebuffer + offset, size); memcpy (&ccpadmap, savebuffer + offset, size);
offset += size; offset += size;
memcpy (&ncpadmap, savebuffer + offset, size); memcpy (&ncpadmap, savebuffer + offset, size);
return true;
} }
else else
WaitPrompt((char*) "Preferences reset - check settings!"); return false;
} }
void quickLoadPrefs (bool8 silent)
{
switch ( QUICK_SAVE_SLOT )
{
case CARD_SLOTA:
case CARD_SLOTB:
LoadPrefsFromMC(QUICK_SAVE_SLOT, silent);
break;
case CARD_SLOTA+2: /****************************************************************************
case CARD_SLOTB+2: * Save Preferences
LoadPrefsFromSD(silent); ****************************************************************************/
break; bool
SavePrefs (int method, bool silent)
{
if(method == METHOD_AUTO)
method = autoSaveMethod();
case CARD_SLOTA+4: bool retval = false;
LoadPrefsFromSMB(silent); char filepath[1024];
break; int datasize;
int offset = 0;
datasize = preparePrefsData ();
if (!silent)
ShowAction ((char*) "Saving preferences...");
if(method == METHOD_SD || method == METHOD_USB)
{
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);
} }
void quickSavePrefs (bool8 silent) if (offset > 0)
{ {
switch ( QUICK_SAVE_SLOT ) retval = decodePrefsData ();
if ( !silent )
{ {
case CARD_SLOTA: sprintf (filepath, "Wrote %d bytes", offset);
case CARD_SLOTB: WaitPrompt (filepath);
SavePrefsToMC(QUICK_SAVE_SLOT, silent);
break;
case CARD_SLOTA+2:
case CARD_SLOTB+2:
SavePrefsToSD(silent);
break;
case CARD_SLOTA+4:
SavePrefsToSMB(silent);
break;
} }
} }
return retval;
}
/****************************************************************************
* Load Preferences
****************************************************************************/
bool
LoadPrefs (int method, bool silent)
{
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)
{
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);
}

View File

@ -9,10 +9,9 @@
* Preferences save/load preferences utilities * Preferences save/load preferences utilities
****************************************************************************/ ****************************************************************************/
#define PREFS_FILE_NAME "snes9xGx.prf"
int preparePrefsData (); int preparePrefsData ();
void decodePrefsData (); bool decodePrefsData ();
bool SavePrefs (int method, bool silent);
void quickLoadPrefs (bool8 silent); bool LoadPrefs (int method, bool silent);
void quickSavePrefs (bool8 silent); bool quickLoadPrefs (bool8 silent);
bool quickSavePrefs (bool8 silent);

View File

@ -162,16 +162,45 @@
void void
DefaultSettings () DefaultSettings ()
{ {
/************** 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 ***/ /*** Default ALL to false ***/
memset (&Settings, 0, sizeof (Settings)); memset (&Settings, 0, sizeof (Settings));
/*** General ***/ /*** General ***/
Settings.MouseMaster = false; Settings.MouseMaster = false;
Settings.SuperScopeMaster = false; Settings.SuperScopeMaster = false;
Settings.MultiPlayer5Master = false; Settings.MultiPlayer5Master = false;
Settings.JustifierMaster = true; Settings.JustifierMaster = true;
Settings.ShutdownMaster = false; Settings.ShutdownMaster = false;
Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier Settings.CyclesPercentage = 100; // snes9x 1.50 and earlier
Settings.ApplyCheats = true;
/* Eke-Eke: specific to snes9x 1.51 */ /* Eke-Eke: specific to snes9x 1.51 */
// Settings.BlockInvalidVRAMAccess = true; // Settings.BlockInvalidVRAMAccess = true;
@ -203,25 +232,6 @@ DefaultSettings ()
/*** SDD1 - Star Ocean Returns -;) ***/ /*** SDD1 - Star Ocean Returns -;) ***/
Settings.SDD1Pack = true; 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.ForceNTSC = 0;
Settings.ForcePAL = 0; Settings.ForcePAL = 0;
Settings.ForceHiROM = 0; Settings.ForceHiROM = 0;
@ -237,6 +247,5 @@ DefaultSettings ()
Settings.ForceSuperFX = 0; Settings.ForceSuperFX = 0;
Settings.ForceDSP1 = 0; Settings.ForceDSP1 = 0;
Settings.ForceNoDSP1 = 0; Settings.ForceNoDSP1 = 0;
} }

View File

@ -7,7 +7,7 @@
* *
* sdload.cpp * sdload.cpp
* *
* Load ROMS from SD Card * Load ROMS from FAT
****************************************************************************/ ****************************************************************************/
#include <gccore.h> #include <gccore.h>
#include <stdio.h> #include <stdio.h>
@ -22,20 +22,75 @@
#include "filesel.h" #include "filesel.h"
#include "sram.h" #include "sram.h"
#include "preferences.h" #include "preferences.h"
#include "snes9xGx.h"
#include <zlib.h> #include <zlib.h>
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
extern char output[16384]; extern char output[16384];
FILE * filehandle; FILE * filehandle;
char currSDdir[MAXPATHLEN]; char currFATdir[MAXPATHLEN];
extern int offset; extern int offset;
extern int selection; extern int selection;
extern int loadtype;
extern FILEENTRIES filelist[MAXFILES]; 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 * FileSortCallback
* *
@ -64,52 +119,59 @@ static int FileSortCallback(const void *f1, const void *f2)
} }
/*************************************************************************** /***************************************************************************
* Update FAT (sdcard, usb) curent directory name * Update FATCARD curent directory name
***************************************************************************/ ***************************************************************************/
int updateFATdirname() int updateFATdirname(int method)
{ {
int size=0; int size=0;
char *test; char *test;
char temp[1024]; char temp[1024];
/* current directory doesn't change */ /* current directory doesn't change */
if (strcmp(filelist[selection].filename,".") == 0) return 0; if (strcmp(filelist[selection].filename,".") == 0)
{
return 0;
}
/* go up to parent directory */ /* go up to parent directory */
else if (strcmp(filelist[selection].filename,"..") == 0) else if (strcmp(filelist[selection].filename,"..") == 0)
{ {
/* determine last subdirectory namelength */ /* determine last subdirectory namelength */
sprintf(temp,"%s",currSDdir); sprintf(temp,"%s",currFATdir);
test = strtok(temp,"/"); test = strtok(temp,"/");
while (test != NULL) { while (test != NULL)
{
size = strlen(test); size = strlen(test);
test = strtok(NULL,"/"); test = strtok(NULL,"/");
} }
/* remove last subdirectory name */ /* remove last subdirectory name */
size = strlen(currSDdir) - size - 1; size = strlen(currFATdir) - size - 1;
currSDdir[size] = 0; currFATdir[size] = 0;
/* handles root name */
if (strcmp(currSDdir, "/") == 0)
return 1; return 1;
} }
else /* Open a directory */ /* Open a directory */
else
{ {
/* test new directory namelength */ /* test new directory namelength */
if ((strlen(currSDdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
{ {
/* handles root name */ /* handles root name */
sprintf(temp, "/%s/..", SNESROMDIR); sprintf(temp, "/%s/..", GCSettings.LoadFolder);
if (strcmp(currSDdir, temp) == 0) if (strcmp(currFATdir, temp) == 0)
sprintf(currSDdir,"%s",ROOTSDDIR); {
if(method == METHOD_SD)
sprintf(currFATdir,"%s",ROOTSDDIR);
else
sprintf(currFATdir,"%s",ROOTUSBDIR);
}
/* update current directory name */ /* update current directory name */
sprintf(currSDdir, "%s/%s",currSDdir, filelist[selection].filename); sprintf(currFATdir, "%s/%s",currFATdir, filelist[selection].filename);
return 1; return 1;
} else { }
else
{
WaitPrompt((char*)"Dirname is too long !"); WaitPrompt((char*)"Dirname is too long !");
return -1; return -1;
} }
@ -117,11 +179,12 @@ int updateFATdirname()
} }
/*************************************************************************** /***************************************************************************
* Browse FAT (sdcard, usb) subdirectories * Browse FAT subdirectories
***************************************************************************/ ***************************************************************************/
int parseFATdirectory() { int parseFATdirectory(int method)
{
int nbfiles = 0; int nbfiles = 0;
DIR_ITER *sddir; DIR_ITER *fatdir;
char filename[MAXPATHLEN]; char filename[MAXPATHLEN];
struct stat filestat; struct stat filestat;
char msg[128]; char msg[128];
@ -130,26 +193,30 @@ int parseFATdirectory() {
selection = offset = 0; selection = offset = 0;
/* open the directory */ /* open the directory */
sddir = diropen(currSDdir); fatdir = diropen(currFATdir);
if (sddir == NULL) { if (fatdir == NULL)
/*** if we can't open the previous dir, open root dir ***/ {
if (loadtype == LOAD_USB) sprintf(msg, "Error opening %s", currFATdir);
sprintf(currSDdir,"fat4:/");
else // LOAD_SDC
//sprintf(currSDdir,"%s",ROOTSDDIR);
sprintf(currSDdir,"fat3:/");
sddir = diropen(currSDdir);
WaitPrompt(msg); 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); WaitPrompt(msg);
return 0; return 0;
} }
} }
/* Move to DVD structure - this is required for the file selector */ /* Move to DVD structure - this is required for the file selector */
while(dirnext(sddir,filename,&filestat) == 0) { while(dirnext(fatdir,filename,&filestat) == 0) {
if(strcmp(filename,".") != 0) { if(strcmp(filename,".") != 0) {
memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES)); memset(&filelist[nbfiles], 0, sizeof(FILEENTRIES));
strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN); strncpy(filelist[nbfiles].filename, filename, MAXPATHLEN);
@ -161,7 +228,7 @@ int parseFATdirectory() {
} }
/*** close directory ***/ /*** close directory ***/
dirclose(sddir); dirclose(fatdir);
/* Sort the file list */ /* Sort the file list */
qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback); qsort(filelist, nbfiles, sizeof(FILEENTRIES), FileSortCallback);
@ -170,12 +237,11 @@ int parseFATdirectory() {
} }
/**************************************************************************** /****************************************************************************
* LoadSDFile * LoadFATFile
****************************************************************************/ ****************************************************************************/
extern bool haveSDdir; extern int haveFATdir;
extern bool haveUSBdir;
int int
LoadSDFile (char *filename, int length) LoadFATFile (char *filename, int length)
{ {
char zipbuffer[2048]; char zipbuffer[2048];
char filepath[MAXPATHLEN]; char filepath[MAXPATHLEN];
@ -186,13 +252,12 @@ LoadSDFile (char *filename, int length)
rbuffer = (unsigned char *) Memory.ROM; rbuffer = (unsigned char *) Memory.ROM;
/* Check filename length */ /* Check filename length */
if ((strlen(currSDdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN) if ((strlen(currFATdir)+1+strlen(filelist[selection].filename)) < MAXPATHLEN)
sprintf(filepath, "%s/%s",currSDdir,filelist[selection].filename); sprintf(filepath, "%s/%s",currFATdir,filelist[selection].filename);
else else
{ {
WaitPrompt((char*) "Maximum Filename Length reached !"); WaitPrompt((char*) "Maximum Filename Length reached !");
haveSDdir = 0; // reset everything before next access haveFATdir = 0; // reset everything before next access
haveUSBdir = 0;
return -1; return -1;
} }
@ -204,7 +269,7 @@ LoadSDFile (char *filename, int length)
if (IsZipFile (zipbuffer)) if (IsZipFile (zipbuffer))
{ {
/*** Unzip the ROM ***/ /*** Unzip the ROM ***/
size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from SD size = UnZipBuffer (rbuffer, 0, 0, handle); // unzip from FAT
fclose (handle); fclose (handle);
return size; return size;
@ -236,13 +301,11 @@ LoadSDFile (char *filename, int length)
return 0; return 0;
} }
/**************************************************************************** /****************************************************************************
* Load savebuffer from SD card file * Load savebuffer from FAT file
****************************************************************************/ ****************************************************************************/
int int
LoadBufferFromSD (char *filepath, bool silent) LoadBufferFromFAT (char *filepath, bool silent)
{ {
FILE *handle; FILE *handle;
int offset = 0; int offset = 0;
@ -274,12 +337,11 @@ LoadBufferFromSD (char *filepath, bool silent)
return offset; return offset;
} }
/**************************************************************************** /****************************************************************************
* Write savebuffer to SD card file * Write savebuffer to FAT card file
****************************************************************************/ ****************************************************************************/
int int
SaveBufferToSD (char *filepath, int datasize, bool silent) SaveBufferToFAT (char *filepath, int datasize, bool silent)
{ {
FILE *handle; FILE *handle;
@ -301,145 +363,3 @@ SaveBufferToSD (char *filepath, int datasize, bool silent)
return datasize; 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);
}
}
}

View File

@ -21,15 +21,17 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
static int FileSortCallback(const void *f1, const void *f2); #define ROOTSDDIR "fat3:/"
int updateFATdirname(); #define ROOTUSBDIR "fat4:/"
int parseFATdirectory();
int LoadSDFile (char *filename, int length);
void SaveSRAMToSD (bool silent);
void LoadSRAMFromSD (bool silent);
void SavePrefsToSD (bool silent);
void LoadPrefsFromSD (bool silent);
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 #endif

View File

@ -101,7 +101,7 @@ parseSMBDirectory ()
ConnectSMB (); ConnectSMB ();
strcpy (searchpath, SNESROMDIR); strcpy (searchpath, GCSettings.LoadFolder);
strcat (searchpath, "\\*.*"); strcat (searchpath, "\\*.*");
if (SMB_FindFirst if (SMB_FindFirst
@ -152,7 +152,7 @@ LoadSMBFile (char *filename, int length)
z_stream zs; z_stream zs;
int res, outbytes; int res, outbytes;
strcpy (filepath, SNESROMDIR); strcpy (filepath, GCSettings.LoadFolder);
strcat (filepath, "\\"); strcat (filepath, "\\");
strcat (filepath, filename); strcat (filepath, filename);
rbuffer = (char *) Memory.ROM; rbuffer = (char *) Memory.ROM;
@ -332,6 +332,7 @@ SaveBufferToSMB (char *filepath, int datasize, bool8 silent)
****************************************************************************/ ****************************************************************************/
int int
LoadBufferFromSMB (char *filepath, bool8 silent) LoadBufferFromSMB (char *filepath, bool8 silent)
{ {
SMBFILE smbfile; SMBFILE smbfile;
int ret; int ret;
@ -369,116 +370,3 @@ LoadBufferFromSMB (char *filepath, bool8 silent)
return 0; 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);
}
}
}

View File

@ -11,15 +11,14 @@
****************************************************************************/ ****************************************************************************/
#ifndef _NGCSMB_ #ifndef _NGCSMB_
#define _NGCSMB_ #define _NGCSMB_
void ConnectSMB (); void ConnectSMB ();
int parseSMBDirectory (); int parseSMBDirectory ();
int LoadSMBFile (char *filename, int length); int LoadSMBFile (char *filename, int length);
void SaveSRAMToSMB (bool8 silent); int LoadBufferFromSMB (char *filepath, bool8 silent);
void LoadSRAMFromSMB (bool8 silent); int SaveBufferToSMB (char *filepath, int datasize, bool8 silent);
void SavePrefsToSMB (bool8 silent);
void LoadPrefsFromSMB (bool8 silent);
typedef struct typedef struct
{ {
@ -35,4 +34,5 @@ typedef struct
} }
SMBINFO; SMBINFO;
#endif #endif

View File

@ -159,11 +159,11 @@
#include <ogcsys.h> #include <ogcsys.h>
#include <unistd.h> #include <unistd.h>
#include <fat.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <sdcard/card_cmn.h> #include <sdcard/card_cmn.h>
#include <sdcard/wiisd_io.h> #include <sdcard/wiisd_io.h>
#include <sdcard/card_io.h> #include <sdcard/card_io.h>
#include <fat.h>
#include "snes9x.h" #include "snes9x.h"
#include "memmap.h" #include "memmap.h"
@ -190,6 +190,7 @@
#include "preferences.h" #include "preferences.h"
#include "gctime.h" #include "gctime.h"
#include "button_mapping.h" #include "button_mapping.h"
#include "sdload.h"
unsigned long ARAM_ROMSIZE = 0; unsigned long ARAM_ROMSIZE = 0;
int ConfigRequested = 0; int ConfigRequested = 0;
@ -523,7 +524,6 @@ NGCReportButtons ()
if ( GCSettings.AutoSave == 1 ) if ( GCSettings.AutoSave == 1 )
{ {
//if ( WaitPromptChoice ((char*)"Save SRAM?", (char*)"Don't Save", (char*)"Save") )
quickSaveSRAM ( SILENT ); quickSaveSRAM ( SILENT );
} }
else if ( GCSettings.AutoSave == 2 ) else if ( GCSettings.AutoSave == 2 )
@ -540,7 +540,7 @@ NGCReportButtons ()
} }
} }
mainmenu (); mainmenu (3); // go to game menu
FrameTimer = 0; FrameTimer = 0;
ConfigRequested = 0; ConfigRequested = 0;
@ -613,6 +613,7 @@ void SetControllers ()
} }
} }
/**************************************************************************** /****************************************************************************
* Set the default mapping for NGC * Set the default mapping for NGC
****************************************************************************/ ****************************************************************************/
@ -747,16 +748,16 @@ int
main () main ()
{ {
unsigned int save_flags; unsigned int save_flags;
int selectedMenu = -1;
/*** Initialise GC ***/ /*** Initialise GC ***/
InitGCVideo (); /*** Get the ball rolling ***/ InitGCVideo (); /*** Get the ball rolling ***/
/*** Initialize libFAT and SD cards ***/ /*** Initialize libFAT for SD and USB ***/
fatInitDefault(); fatInitDefault();
//fatInit(8192, false); //fatInit(8192, false);
//fat_enable_readahead_all(); //fat_enable_readahead_all();
/*** Initialize DVD subsystem ***/ /*** Initialize DVD subsystem ***/
DVD_Init (); DVD_Init ();
@ -784,7 +785,6 @@ main ()
printf ("Cannot initialise font subsystem!\n"); printf ("Cannot initialise font subsystem!\n");
while (1); while (1);
} }
setfontsize (16);/***sets the font size.***/
/*** Set defaults ***/ /*** Set defaults ***/
DefaultSettings (); DefaultSettings ();
@ -814,11 +814,14 @@ main ()
if (!S9xGraphicsInit ()) if (!S9xGraphicsInit ())
while (1); while (1);
legal (); unpackbackdrop ();
WaitButtonA ();
// Load preferences // 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 // Correct any relevant saved settings that are invalid
Settings.FrameTimeNTSC = 16667; Settings.FrameTimeNTSC = 16667;
@ -831,7 +834,7 @@ main ()
{ {
while (ARAM_ROMSIZE == 0) while (ARAM_ROMSIZE == 0)
{ {
mainmenu (); mainmenu (selectedMenu);
} }
} }
else else

View File

@ -166,9 +166,23 @@
#define NOTSILENT 0 #define NOTSILENT 0
#define SILENT 1 #define SILENT 1
enum {
METHOD_AUTO,
METHOD_SD,
METHOD_USB,
METHOD_DVD,
METHOD_SMB,
METHOD_MC_SLOTA,
METHOD_MC_SLOTB
};
struct SGCSettings{ struct SGCSettings{
uint8 AutoLoad; uint8 AutoLoad;
uint8 AutoSave; 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 gcip[16];
char gwip[16]; char gwip[16];
char mask[16]; char mask[16];
@ -181,7 +195,6 @@ struct SGCSettings{
bool8 NGCZoom; bool8 NGCZoom;
uint8 VerifySaves; uint8 VerifySaves;
u16 render; // 0 - original, 1 - no AA 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 Superscope;
u16 Mouse; u16 Mouse;
}; };
@ -197,21 +210,6 @@ END_EXTERN_C
#define JOY_THRESHOLD 0.70 // for wii (expansion) analogues #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 ***/ /*** default SMB settings ***/
#ifndef GC_IP #ifndef GC_IP
#define GC_IP "192.168.1.32" /*** IP to assign the GameCube ***/ #define GC_IP "192.168.1.32" /*** IP to assign the GameCube ***/
@ -240,3 +238,5 @@ END_EXTERN_C
#ifndef SMB_IP #ifndef SMB_IP
#define SMB_IP "192.168.1.100" /*** IP Address of share server ***/ #define SMB_IP "192.168.1.100" /*** IP Address of share server ***/
#endif #endif
#endif

View File

@ -21,14 +21,13 @@
#include "mcsave.h" #include "mcsave.h"
#include "sdload.h" #include "sdload.h"
#include "smbload.h" #include "smbload.h"
#include "filesel.h"
extern unsigned char savebuffer[]; extern unsigned char savebuffer[];
//extern int currconfig[4];
extern int padcal; extern int padcal;
extern unsigned short gcpadmap[]; 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 * Prepare Memory Card SRAM Save Data
@ -47,7 +46,7 @@ prepareMCsavedata ()
memcpy (savebuffer, saveicon, offset); memcpy (savebuffer, saveicon, offset);
/*** And the sramcomments ***/ /*** And the sramcomments ***/
sprintf (sramcomment[1], "%s", Memory.ROMName); sprintf (sramcomment[1], "%s", Memory.ROMFilename);
memcpy (savebuffer + offset, sramcomment, 64); memcpy (savebuffer + offset, sramcomment, 64);
offset += 64; offset += 64;
@ -91,7 +90,7 @@ prepareEXPORTsavedata ()
ClearSaveBuffer (); ClearSaveBuffer ();
/*** Copy in the sramcomments ***/ /*** Copy in the sramcomments ***/
sprintf (sramcomment[1], "%s", Memory.ROMName); sprintf (sramcomment[1], "%s", Memory.ROMFilename);
memcpy (savebuffer + offset, sramcomment, 64); memcpy (savebuffer + offset, sramcomment, 64);
offset += 64; offset += 64;
@ -233,39 +232,136 @@ decodesavedata (int readsize)
} }
} }
void quickLoadSRAM (bool8 silent) /****************************************************************************
* Load SRAM
****************************************************************************/
bool
LoadSRAM (int method, bool silent)
{ {
switch ( QUICK_SAVE_SLOT ) 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)
{ {
case CARD_SLOTA: if(method == METHOD_SD)
case CARD_SLOTB: sprintf (filepath, "%s/%s/%s.srm", ROOTSDDIR, GCSettings.SaveFolder, Memory.ROMFilename);
LoadSRAMFromMC(QUICK_SAVE_SLOT, silent); else
break; sprintf (filepath, "%s/%s/%s.srm", ROOTUSBDIR, GCSettings.SaveFolder, Memory.ROMFilename);
case CARD_SLOTA+2:
case CARD_SLOTB+2: offset = LoadBufferFromFAT (filepath, silent);
LoadSRAMFromSD(silent);
break;
case CARD_SLOTA+4:
LoadSRAMFromSMB(SILENT);
break;
} }
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);
} }
void quickSaveSRAM (bool8 silent) if (offset > 0)
{ {
switch ( QUICK_SAVE_SLOT ) decodesavedata (offset);
if ( !silent )
{ {
case CARD_SLOTA: sprintf (filepath, "Loaded %d bytes", offset);
case CARD_SLOTB: WaitPrompt(filepath);
SaveSRAMToMC(QUICK_SAVE_SLOT, silent);
break;
case CARD_SLOTA+2:
case CARD_SLOTB+2:
SaveSRAMToSD(silent);
break;
case CARD_SLOTA+4:
SaveSRAMToSMB(SILENT);
break;
} }
S9xSoftReset();
retval = true;
}
return retval;
} }
/****************************************************************************
* Save SRAM
****************************************************************************/
bool
SaveSRAM (int method, bool silent)
{
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);
}

View File

@ -13,5 +13,7 @@ int prepareMCsavedata ();
int prepareEXPORTsavedata (); int prepareEXPORTsavedata ();
void decodesavedata (int readsize); void decodesavedata (int readsize);
void quickLoadSRAM (bool8 silent); bool SaveSRAM (int method, bool silent);
void quickSaveSRAM (bool8 silent); bool LoadSRAM (int method, bool silent);
bool quickLoadSRAM (bool silent);
bool quickSaveSRAM (bool silent);