mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-07 22:30:46 +01:00
preliminary new GUI implementation
This commit is contained in:
parent
f76332df49
commit
3307989c04
@ -2,8 +2,8 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
|
||||||
* michniewski August 2008
|
* michniewski August 2008
|
||||||
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* button_mapping.c
|
* button_mapping.c
|
||||||
*
|
*
|
||||||
@ -27,6 +27,50 @@
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
CtrlrMap ctrlr_def[4] = {
|
CtrlrMap ctrlr_def[4] = {
|
||||||
|
// Gamecube controller btn def
|
||||||
|
{
|
||||||
|
CTRLR_GCPAD,
|
||||||
|
13,
|
||||||
|
{
|
||||||
|
{PAD_BUTTON_DOWN, "DOWN"},
|
||||||
|
{PAD_BUTTON_UP, "UP"},
|
||||||
|
{PAD_BUTTON_LEFT, "LEFT"},
|
||||||
|
{PAD_BUTTON_RIGHT, "RIGHT"},
|
||||||
|
{PAD_BUTTON_A, "A"},
|
||||||
|
{PAD_BUTTON_B, "B"},
|
||||||
|
{PAD_BUTTON_X, "X"},
|
||||||
|
{PAD_BUTTON_Y, "Y"},
|
||||||
|
{PAD_BUTTON_MENU, "START"},
|
||||||
|
{PAD_BUTTON_START, "START"},
|
||||||
|
{PAD_TRIGGER_L, "L"},
|
||||||
|
{PAD_TRIGGER_R, "R"},
|
||||||
|
{PAD_TRIGGER_Z, "Z"},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Wiimote btn def
|
||||||
|
{
|
||||||
|
CTRLR_WIIMOTE,
|
||||||
|
11,
|
||||||
|
{
|
||||||
|
{WPAD_BUTTON_DOWN, "DOWN"},
|
||||||
|
{WPAD_BUTTON_UP, "UP"},
|
||||||
|
{WPAD_BUTTON_LEFT, "LEFT"},
|
||||||
|
{WPAD_BUTTON_RIGHT, "RIGHT"},
|
||||||
|
{WPAD_BUTTON_A, "A"},
|
||||||
|
{WPAD_BUTTON_B, "B"},
|
||||||
|
{WPAD_BUTTON_1, "1"},
|
||||||
|
{WPAD_BUTTON_2, "2"},
|
||||||
|
{WPAD_BUTTON_PLUS, "PLUS"},
|
||||||
|
{WPAD_BUTTON_MINUS, "MINUS"},
|
||||||
|
{WPAD_BUTTON_HOME, "HOME"},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""},
|
||||||
|
{0, ""}
|
||||||
|
}
|
||||||
|
},
|
||||||
// Nunchuk btn def
|
// Nunchuk btn def
|
||||||
{
|
{
|
||||||
CTRLR_NUNCHUK,
|
CTRLR_NUNCHUK,
|
||||||
@ -70,50 +114,5 @@ CtrlrMap ctrlr_def[4] = {
|
|||||||
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
||||||
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
|
{WPAD_CLASSIC_BUTTON_ZR, "ZR"}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
// Gamecube controller btn def
|
|
||||||
{
|
|
||||||
CTRLR_GCPAD,
|
|
||||||
13,
|
|
||||||
{
|
|
||||||
{PAD_BUTTON_DOWN, "DOWN"},
|
|
||||||
{PAD_BUTTON_UP, "UP"},
|
|
||||||
{PAD_BUTTON_LEFT, "LEFT"},
|
|
||||||
{PAD_BUTTON_RIGHT, "RIGHT"},
|
|
||||||
{PAD_BUTTON_A, "A"},
|
|
||||||
{PAD_BUTTON_B, "B"},
|
|
||||||
{PAD_BUTTON_X, "X"},
|
|
||||||
{PAD_BUTTON_Y, "Y"},
|
|
||||||
{PAD_BUTTON_MENU, "START"},
|
|
||||||
{PAD_BUTTON_START, "START"},
|
|
||||||
{PAD_TRIGGER_L, "L TRIG"},
|
|
||||||
{PAD_TRIGGER_R, "R TRIG"},
|
|
||||||
{PAD_TRIGGER_Z, "Z"},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Wiimote btn def
|
|
||||||
{
|
|
||||||
CTRLR_WIIMOTE,
|
|
||||||
11,
|
|
||||||
{
|
|
||||||
{WPAD_BUTTON_DOWN, "DOWN"},
|
|
||||||
{WPAD_BUTTON_UP, "UP"},
|
|
||||||
{WPAD_BUTTON_LEFT, "LEFT"},
|
|
||||||
{WPAD_BUTTON_RIGHT, "RIGHT"},
|
|
||||||
{WPAD_BUTTON_A, "A"},
|
|
||||||
{WPAD_BUTTON_B, "B"},
|
|
||||||
{WPAD_BUTTON_1, "1"},
|
|
||||||
{WPAD_BUTTON_2, "2"},
|
|
||||||
{WPAD_BUTTON_PLUS, "PLUS"},
|
|
||||||
{WPAD_BUTTON_MINUS, "MINUS"},
|
|
||||||
{WPAD_BUTTON_HOME, "HOME"},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""},
|
|
||||||
{0, ""}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
|
||||||
* michniewski August 2008
|
* michniewski August 2008
|
||||||
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* button_mapping.h
|
* button_mapping.h
|
||||||
*
|
*
|
||||||
@ -15,13 +15,15 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
CTRLR_NONE = -1,
|
CTRLR_NONE = -1,
|
||||||
CTRLR_NUNCHUK,
|
|
||||||
CTRLR_CLASSIC,
|
|
||||||
CTRLR_GCPAD,
|
CTRLR_GCPAD,
|
||||||
CTRLR_WIIMOTE,
|
CTRLR_WIIMOTE,
|
||||||
CTRLR_SNES = 7 // give some other value for the snes padmap
|
CTRLR_NUNCHUK,
|
||||||
|
CTRLR_CLASSIC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char ctrlrName[4][20] =
|
||||||
|
{ "GameCube Controller", "Wiimote", "Nunchuk + Wiimote", "Classic Controller" };
|
||||||
|
|
||||||
typedef struct _btn_map {
|
typedef struct _btn_map {
|
||||||
u32 btn; // button 'id'
|
u32 btn; // button 'id'
|
||||||
char* name; // button name
|
char* name; // button name
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
extern void ResetNES(void);
|
||||||
|
extern void PowerNES(void);
|
||||||
|
}
|
||||||
|
|
||||||
/* Message logging(non-netplay messages, usually) for all. */
|
/* Message logging(non-netplay messages, usually) for all. */
|
||||||
extern int NoWaiting;
|
extern int NoWaiting;
|
||||||
extern FCEUGI *GI;
|
extern FCEUGI *GI;
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* softdev July 2006
|
||||||
|
* svpe & crunchy2 June 2007
|
||||||
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* dvd.c
|
* dvd.cpp
|
||||||
*
|
*
|
||||||
* DVD loading routines
|
* DVD loading routines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -22,9 +24,11 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "menudraw.h"
|
|
||||||
#include "gcunzip.h"
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
|
#include "menu.h"
|
||||||
|
#include "gcunzip.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
|
#include "fileop.h"
|
||||||
|
|
||||||
#define MAXDVDFILES 2000
|
#define MAXDVDFILES 2000
|
||||||
|
|
||||||
@ -141,7 +145,6 @@ static int dvd_buffered_read(void *dst, u32 len, u64 offset)
|
|||||||
* This function relies on dvddir (file offset) being prepopulated!
|
* This function relies on dvddir (file offset) being prepopulated!
|
||||||
* returns: 1 - ok ; 0 - error
|
* returns: 1 - ok ; 0 - error
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
||||||
{
|
{
|
||||||
u64 offset = dvddir + fileoffset;
|
u64 offset = dvddir + fileoffset;
|
||||||
@ -318,35 +321,40 @@ getpvd ()
|
|||||||
*
|
*
|
||||||
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
bool MountDVD(bool silent)
|
bool MountDVD(bool silent)
|
||||||
{
|
{
|
||||||
if (!getpvd())
|
bool res = false;
|
||||||
|
|
||||||
|
if (getpvd())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ShowAction("Loading DVD...");
|
ShowAction("Loading DVD...");
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
DVD_Mount(); // mount the DVD unit again
|
DVD_Mount(); // mount the DVD unit again
|
||||||
#elif HW_RVL
|
#else
|
||||||
u32 val;
|
u32 val;
|
||||||
DI_GetCoverRegister(&val);
|
DI_GetCoverRegister(&val);
|
||||||
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("No disc inserted!");
|
ErrorPrompt("No disc inserted!");
|
||||||
|
CancelAction();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
DI_Mount();
|
DI_Mount();
|
||||||
while(DI_GetStatus() & DVD_INIT);
|
while(DI_GetStatus() & DVD_INIT) usleep(20000);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!getpvd())
|
if (getpvd())
|
||||||
{
|
res = true;
|
||||||
if(!silent)
|
else if(!silent)
|
||||||
WaitPrompt ("Invalid DVD.");
|
ErrorPrompt("Invalid DVD.");
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true;
|
CancelAction();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -355,7 +363,6 @@ bool MountDVD(bool silent)
|
|||||||
* Support function to return the next file entry, if any
|
* Support function to return the next file entry, if any
|
||||||
* Declared static to avoid accidental external entry.
|
* Declared static to avoid accidental external entry.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getentry (int entrycount, unsigned char dvdbuffer[])
|
getentry (int entrycount, unsigned char dvdbuffer[])
|
||||||
{
|
{
|
||||||
@ -445,7 +452,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -455,8 +462,16 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
|
|
||||||
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
||||||
StripExt(tmpname, fname); // hide file extension
|
|
||||||
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
if(strcmp(fname,"..") == 0)
|
||||||
|
{
|
||||||
|
sprintf(browserList[entrycount].displayname, "Up One Level");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StripExt(tmpname, fname); // hide file extension
|
||||||
|
strncpy (browserList[entrycount].displayname, tmpname, MAXDISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
|
memcpy (&offset32, &dvdbuffer[diroffset + EXTENT], 4);
|
||||||
|
|
||||||
@ -483,7 +498,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
|||||||
* It relies on dvddir and dvddirlength being pre-populated by a call to
|
* It relies on dvddir and dvddirlength being pre-populated by a call to
|
||||||
* getpvd, a previous parse or a menu selection.
|
* getpvd, a previous parse or a menu selection.
|
||||||
*
|
*
|
||||||
* The return value is number of files collected, or 0 on failure.
|
* The return value is number of files collected, or -1 on failure.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
int
|
int
|
||||||
ParseDVDdirectory ()
|
ParseDVDdirectory ()
|
||||||
@ -506,7 +521,7 @@ ParseDVDdirectory ()
|
|||||||
while (len < pdlength)
|
while (len < pdlength)
|
||||||
{
|
{
|
||||||
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
diroffset = 0;
|
diroffset = 0;
|
||||||
|
|
||||||
@ -523,6 +538,7 @@ ParseDVDdirectory ()
|
|||||||
// Sort the file list
|
// Sort the file list
|
||||||
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
browser.numEntries = filecount;
|
||||||
return filecount;
|
return filecount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,7 +546,6 @@ ParseDVDdirectory ()
|
|||||||
* SetDVDdirectory
|
* SetDVDdirectory
|
||||||
* Set the current DVD file offset
|
* Set the current DVD file offset
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void SetDVDdirectory(u64 dir, int length)
|
void SetDVDdirectory(u64 dir, int length)
|
||||||
{
|
{
|
||||||
dvddir = dir;
|
dvddir = dir;
|
||||||
@ -579,12 +594,18 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
|||||||
|
|
||||||
if(dirindex >= 0)
|
if(dirindex >= 0)
|
||||||
{
|
{
|
||||||
dvddir = browserList[dirindex].offset;
|
|
||||||
dvddirlength = browserList[dirindex].length;
|
|
||||||
browser.selIndex = dirindex;
|
browser.selIndex = dirindex;
|
||||||
|
|
||||||
if(browserList[dirindex].isdir) // only parse directories
|
if(browserList[dirindex].isdir) // only parse directories
|
||||||
browser.numEntries = ParseDVDdirectory();
|
{
|
||||||
|
UpdateDirName(METHOD_DVD);
|
||||||
|
ParseDVDdirectory();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dvddir = browserList[dirindex].offset;
|
||||||
|
dvddirlength = browserList[dirindex].length;
|
||||||
|
}
|
||||||
|
|
||||||
if(lastdir)
|
if(lastdir)
|
||||||
return true;
|
return true;
|
||||||
@ -597,8 +618,8 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
|||||||
bool SwitchDVDFolder(char origdir[])
|
bool SwitchDVDFolder(char origdir[])
|
||||||
{
|
{
|
||||||
// make a copy of origdir so we don't mess with original
|
// make a copy of origdir so we don't mess with original
|
||||||
char dir[200];
|
char dir[1024];
|
||||||
strcpy(dir, origdir);
|
strncpy(dir, origdir, 1024);
|
||||||
|
|
||||||
char * dirptr = dir;
|
char * dirptr = dir;
|
||||||
|
|
||||||
@ -612,6 +633,7 @@ bool SwitchDVDFolder(char origdir[])
|
|||||||
// start searching at root of DVD
|
// start searching at root of DVD
|
||||||
dvddir = dvdrootdir;
|
dvddir = dvdrootdir;
|
||||||
dvddirlength = dvdrootlength;
|
dvddirlength = dvdrootlength;
|
||||||
|
browser.dir[0] = 0;
|
||||||
ParseDVDdirectory();
|
ParseDVDdirectory();
|
||||||
|
|
||||||
return SwitchDVDFolderR(dirptr, 0);
|
return SwitchDVDFolderR(dirptr, 0);
|
||||||
@ -622,10 +644,10 @@ bool SwitchDVDFolder(char origdir[])
|
|||||||
* This function will load a file from DVD
|
* This function will load a file from DVD
|
||||||
* It assumes dvddir and dvddirlength are prepopulated
|
* It assumes dvddir and dvddirlength are prepopulated
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadDVDFileOffset (unsigned char *buffer, int length)
|
LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||||
{
|
{
|
||||||
|
int result = 0;
|
||||||
int offset;
|
int offset;
|
||||||
int blocks;
|
int blocks;
|
||||||
int i;
|
int i;
|
||||||
@ -643,17 +665,19 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
{
|
{
|
||||||
ret = dvd_read (buffer, length, discoffset);
|
ret = dvd_read (buffer, length, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
|
else
|
||||||
|
result = length;
|
||||||
}
|
}
|
||||||
else // load whole file
|
else // load whole file
|
||||||
{
|
{
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
|
|
||||||
if (IsZipFile (readbuffer))
|
if (IsZipFile (readbuffer))
|
||||||
{
|
{
|
||||||
return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -661,7 +685,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
{
|
{
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
memcpy (buffer + offset, readbuffer, 2048);
|
memcpy (buffer + offset, readbuffer, 2048);
|
||||||
offset += 2048;
|
offset += 2048;
|
||||||
discoffset += 2048;
|
discoffset += 2048;
|
||||||
@ -674,12 +698,15 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
i = dvddirlength % 2048;
|
i = dvddirlength % 2048;
|
||||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||||
if(ret <= 0) // read failure
|
if(ret <= 0) // read failure
|
||||||
return 0;
|
goto done;
|
||||||
memcpy (buffer + offset, readbuffer, i);
|
memcpy (buffer + offset, readbuffer, i);
|
||||||
}
|
}
|
||||||
|
result = dvddirlength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dvddirlength;
|
done:
|
||||||
|
CancelAction();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -688,20 +715,30 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
|||||||
* It will attempt to find the offset of the file, and if successful it
|
* It will attempt to find the offset of the file, and if successful it
|
||||||
* will populate dvddir and dvddirlength, and load the file
|
* will populate dvddir and dvddirlength, and load the file
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent)
|
LoadDVDFile(char * buffer, char *filepath, int datasize, bool silent)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
// retain original browser information
|
||||||
|
char origDir[MAXPATHLEN];
|
||||||
|
memset(origDir, 0, MAXPATHLEN);
|
||||||
|
strncpy(origDir, browser.dir, MAXPATHLEN);
|
||||||
|
int origSelIndex = browser.selIndex;
|
||||||
|
int origPageIndex = browser.selIndex;
|
||||||
|
|
||||||
if(SwitchDVDFolder(filepath))
|
if(SwitchDVDFolder(filepath))
|
||||||
{
|
ret = LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||||
return LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
else if(!silent)
|
||||||
}
|
ErrorPrompt("Error loading file!");
|
||||||
else
|
|
||||||
{
|
// restore browser information
|
||||||
if(!silent)
|
memset(browser.dir, 0, MAXPATHLEN);
|
||||||
WaitPrompt("Error loading file!");
|
strncpy(browser.dir, origDir, MAXPATHLEN);
|
||||||
return 0;
|
browser.selIndex = origSelIndex;
|
||||||
}
|
browser.pageIndex = origPageIndex;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -768,8 +805,8 @@ int dvd_driveid()
|
|||||||
dvd[6] = 0x20;
|
dvd[6] = 0x20;
|
||||||
dvd[7] = 3;
|
dvd[7] = 3;
|
||||||
|
|
||||||
while( dvd[7] & 1 )
|
while( dvd[7] & 1 );
|
||||||
;
|
|
||||||
DCFlushRange((void *)0x80000000, 32);
|
DCFlushRange((void *)0x80000000, 32);
|
||||||
|
|
||||||
return (int)inquiry[2];
|
return (int)inquiry[2];
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* softdev July 2006
|
||||||
|
* svpe & crunchy2 June 2007
|
||||||
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* dvd.h
|
* dvd.h
|
||||||
*
|
*
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceuconfig.c
|
* fceuconfig.cpp
|
||||||
*
|
*
|
||||||
* Configuration parameters
|
* Configuration parameters
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -20,6 +20,31 @@
|
|||||||
|
|
||||||
struct SGCSettings GCSettings;
|
struct SGCSettings GCSettings;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* FixInvalidSettings
|
||||||
|
*
|
||||||
|
* Attempts to correct at least some invalid settings - the ones that
|
||||||
|
* might cause crashes
|
||||||
|
***************************************************************************/
|
||||||
|
void FixInvalidSettings()
|
||||||
|
{
|
||||||
|
if(!(GCSettings.ZoomLevel > 0.5 && GCSettings.ZoomLevel < 1.5))
|
||||||
|
GCSettings.ZoomLevel = 1.0;
|
||||||
|
if(!(GCSettings.xshift > -50 && GCSettings.xshift < 50))
|
||||||
|
GCSettings.xshift = 0;
|
||||||
|
if(!(GCSettings.yshift > -50 && GCSettings.yshift < 50))
|
||||||
|
GCSettings.yshift = 0;
|
||||||
|
if(!(GCSettings.MusicVolume >= 0 && GCSettings.MusicVolume <= 100))
|
||||||
|
GCSettings.MusicVolume = 40;
|
||||||
|
if(!(GCSettings.SFXVolume >= 0 && GCSettings.SFXVolume <= 100))
|
||||||
|
GCSettings.SFXVolume = 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* DefaultSettings
|
||||||
|
*
|
||||||
|
* Sets all the defaults!
|
||||||
|
***************************************************************************/
|
||||||
void
|
void
|
||||||
DefaultSettings ()
|
DefaultSettings ()
|
||||||
{
|
{
|
||||||
@ -27,18 +52,21 @@ DefaultSettings ()
|
|||||||
|
|
||||||
GCSettings.currpal = 0;
|
GCSettings.currpal = 0;
|
||||||
GCSettings.timing = 0; // 0 - NTSC, 1 - PAL
|
GCSettings.timing = 0; // 0 - NTSC, 1 - PAL
|
||||||
GCSettings.FourScore = 0;
|
GCSettings.Controller = CTRL_PAD2; // NES pad, Four Score, Zapper
|
||||||
GCSettings.zapper = 0;
|
|
||||||
GCSettings.crosshair = 1;
|
GCSettings.crosshair = 1;
|
||||||
|
|
||||||
GCSettings.Zoom = 0; // zooming default off
|
|
||||||
GCSettings.ZoomLevel = 1.0; // zoom amount
|
GCSettings.ZoomLevel = 1.0; // zoom amount
|
||||||
GCSettings.render = 2; // Unfiltered
|
GCSettings.render = 2; // Unfiltered
|
||||||
GCSettings.widescreen = 0; // no aspect ratio correction
|
GCSettings.widescreen = 0; // no aspect ratio correction
|
||||||
GCSettings.hideoverscan = 2; // hide both horizontal and vertical
|
GCSettings.hideoverscan = 2; // hide both horizontal and vertical
|
||||||
|
|
||||||
GCSettings.xshift = 0; // video shift
|
GCSettings.xshift = 0; // horizontal video shift
|
||||||
GCSettings.yshift = 0;
|
GCSettings.yshift = 0; // vertical video shift
|
||||||
|
|
||||||
|
GCSettings.WiimoteOrientation = 0;
|
||||||
|
GCSettings.ExitAction = 0;
|
||||||
|
GCSettings.MusicVolume = 40;
|
||||||
|
GCSettings.SFXVolume = 40;
|
||||||
|
|
||||||
GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
GCSettings.LoadMethod = METHOD_AUTO; // Auto, SD, DVD, USB, Network (SMB)
|
||||||
GCSettings.SaveMethod = METHOD_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
GCSettings.SaveMethod = METHOD_AUTO; // Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, Network (SMB)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceuconfig.h
|
* fceuconfig.h
|
||||||
*
|
*
|
||||||
@ -10,9 +10,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _FCEUCONFIG_H_
|
#ifndef _FCEUCONFIG_H_
|
||||||
|
|
||||||
#define _FCEUCONFIG_H_
|
#define _FCEUCONFIG_H_
|
||||||
|
|
||||||
void DefaultSettings ();
|
void FixInvalidSettings();
|
||||||
|
void DefaultSettings();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceugx.c
|
* fceugx.cpp
|
||||||
*
|
*
|
||||||
* This file controls overall program flow. Most things start and end here!
|
* This file controls overall program flow. Most things start and end here!
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -25,14 +25,16 @@
|
|||||||
#include "fceustate.h"
|
#include "fceustate.h"
|
||||||
#include "fceuram.h"
|
#include "fceuram.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "menudraw.h"
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "gcaudio.h"
|
#include "gcaudio.h"
|
||||||
#include "gcvideo.h"
|
#include "gcvideo.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
|
#include "filelist.h"
|
||||||
|
#include "gui/gui.h"
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -40,6 +42,8 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "FreeTypeGX.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
extern int cleanSFMDATA();
|
extern int cleanSFMDATA();
|
||||||
@ -53,21 +57,26 @@ unsigned char * nesrom = NULL;
|
|||||||
int ConfigRequested = 0;
|
int ConfigRequested = 0;
|
||||||
int ShutdownRequested = 0;
|
int ShutdownRequested = 0;
|
||||||
int ResetRequested = 0;
|
int ResetRequested = 0;
|
||||||
|
int ExitRequested = 0;
|
||||||
char appPath[1024];
|
char appPath[1024];
|
||||||
|
FreeTypeGX *fontSystem;
|
||||||
uint8 *xbsave=NULL;
|
uint8 *xbsave=NULL;
|
||||||
int frameskip = 0;
|
int frameskip = 0;
|
||||||
|
|
||||||
extern bool romLoaded;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Shutdown / Reboot / Exit
|
* Shutdown / Reboot / Exit
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static void ExitCleanup()
|
static void ExitCleanup()
|
||||||
{
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
ShutoffRumble();
|
||||||
|
#endif
|
||||||
|
ShutdownAudio();
|
||||||
|
StopGX();
|
||||||
|
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
UnmountAllFAT();
|
UnmountAllFAT();
|
||||||
CloseShare();
|
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
DI_Close();
|
DI_Close();
|
||||||
@ -80,27 +89,32 @@ static void ExitCleanup()
|
|||||||
void (*PSOReload) () = (void (*)()) 0x80001800;
|
void (*PSOReload) () = (void (*)()) 0x80001800;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Reboot()
|
void ExitApp()
|
||||||
{
|
{
|
||||||
ExitCleanup();
|
ExitCleanup();
|
||||||
#ifdef HW_RVL
|
|
||||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
|
||||||
#else
|
|
||||||
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
|
||||||
*SOFTRESET_ADR = 0x00000000;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void ExitToLoader()
|
if(GCSettings.ExitAction == 0) // Exit to Loader
|
||||||
{
|
{
|
||||||
ExitCleanup();
|
#ifdef HW_RVL
|
||||||
// Exit to Loader
|
exit(0);
|
||||||
#ifdef HW_RVL
|
#else
|
||||||
exit(0);
|
if (psoid[0] == PSOSDLOADID)
|
||||||
#else // gamecube
|
PSOReload ();
|
||||||
if (psoid[0] == PSOSDLOADID)
|
#endif
|
||||||
PSOReload ();
|
}
|
||||||
#endif
|
else if(GCSettings.ExitAction == 1) // Exit to Menu
|
||||||
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||||
|
#else
|
||||||
|
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
||||||
|
*SOFTRESET_ADR = 0x00000000;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else // Shutdown Wii
|
||||||
|
{
|
||||||
|
SYS_ResetSystem(SYS_POWEROFF, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
@ -182,7 +196,6 @@ int main(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
DI_Close();
|
|
||||||
DI_Init(); // first
|
DI_Init(); // first
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -194,13 +207,13 @@ int main(int argc, char *argv[])
|
|||||||
WPAD_Init();
|
WPAD_Init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
InitGCVideo ();
|
InitGCVideo (); // Initialise video
|
||||||
ResetVideo_Menu (); // change to menu video mode
|
ResetVideo_Menu (); // change to menu video mode
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
// read wiimote accelerometer and IR data
|
// read wiimote accelerometer and IR data
|
||||||
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
WPAD_SetDataFormat(WPAD_CHAN_ALL,WPAD_FMT_BTNS_ACC_IR);
|
||||||
WPAD_SetVRes(WPAD_CHAN_ALL,640,480);
|
WPAD_SetVRes(WPAD_CHAN_ALL, screenwidth, screenheight);
|
||||||
|
|
||||||
// Wii Power/Reset buttons
|
// Wii Power/Reset buttons
|
||||||
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
||||||
@ -208,71 +221,61 @@ int main(int argc, char *argv[])
|
|||||||
SYS_SetResetCallback(ResetCB);
|
SYS_SetResetCallback(ResetCB);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Initialise FreeType
|
|
||||||
if (FT_Init ())
|
|
||||||
{
|
|
||||||
printf ("Cannot initialise font subsystem!\n");
|
|
||||||
while (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
InitialiseAudio();
|
|
||||||
|
|
||||||
// Initialize libFAT for SD and USB
|
|
||||||
MountAllFAT();
|
|
||||||
|
|
||||||
// Initialize DVD subsystem (GameCube only)
|
// Initialize DVD subsystem (GameCube only)
|
||||||
#ifdef HW_DOL
|
#ifdef HW_DOL
|
||||||
DVD_Init ();
|
DVD_Init ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// allocate memory to store rom
|
|
||||||
nesrom = (unsigned char *)memalign(32,1024*1024*3); // 3 MB should be plenty
|
|
||||||
|
|
||||||
/*** Minimal Emulation Loop ***/
|
|
||||||
if ( !FCEUI_Initialize() )
|
|
||||||
{
|
|
||||||
WaitPrompt("Unable to initialize FCE Ultra\n");
|
|
||||||
ExitToLoader();
|
|
||||||
}
|
|
||||||
|
|
||||||
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
|
|
||||||
|
|
||||||
memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory
|
|
||||||
cleanSFMDATA(); // clear state data
|
|
||||||
|
|
||||||
// Set defaults
|
|
||||||
DefaultSettings();
|
|
||||||
|
|
||||||
// store path app was loaded from
|
// store path app was loaded from
|
||||||
sprintf(appPath, "fceugx");
|
sprintf(appPath, "fceugx");
|
||||||
if(argc > 0 && argv[0] != NULL)
|
if(argc > 0 && argv[0] != NULL)
|
||||||
CreateAppPath(argv[0]);
|
CreateAppPath(argv[0]);
|
||||||
|
|
||||||
int selectedMenu = -1;
|
MountAllFAT(); // Initialize libFAT for SD and USB
|
||||||
|
|
||||||
// Load preferences
|
// Audio
|
||||||
if(!LoadPrefs())
|
InitialiseAudio();
|
||||||
{
|
|
||||||
WaitPrompt("Preferences reset - check settings!");
|
// Initialize font system
|
||||||
selectedMenu = 1; // change to preferences menu
|
fontSystem = new FreeTypeGX();
|
||||||
}
|
fontSystem->loadFont(font_ttf, font_ttf_size, 0);
|
||||||
|
fontSystem->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE);
|
||||||
|
|
||||||
|
InitGUIThreads();
|
||||||
|
|
||||||
|
DefaultSettings(); // Set defaults
|
||||||
|
|
||||||
|
// allocate memory to store rom
|
||||||
|
nesrom = (unsigned char *)memalign(32,1024*1024*3); // 3 MB should be plenty
|
||||||
|
|
||||||
|
/*** Minimal Emulation Loop ***/
|
||||||
|
if (!FCEUI_Initialize())
|
||||||
|
ExitApp();
|
||||||
|
|
||||||
|
FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON
|
||||||
|
|
||||||
|
memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory
|
||||||
|
cleanSFMDATA(); // clear state data
|
||||||
|
|
||||||
FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.)
|
FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.)
|
||||||
FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio
|
FCEUI_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio
|
||||||
|
|
||||||
while (1) // main loop
|
while (1) // main loop
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
// go back to checking if devices were inserted/removed
|
||||||
if(ShutdownRequested)
|
|
||||||
ShutdownWii();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
|
||||||
// since we're entering the menu
|
// since we're entering the menu
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
|
|
||||||
MainMenu(selectedMenu);
|
ConfigRequested = 1;
|
||||||
selectedMenu = 2; // return to game menu from now on
|
SwitchAudioMode(1);
|
||||||
|
|
||||||
|
if(!romLoaded)
|
||||||
|
MainMenu(MENU_GAMESELECTION);
|
||||||
|
else
|
||||||
|
MainMenu(MENU_GAME);
|
||||||
|
|
||||||
|
ConfigRequested = 0;
|
||||||
|
SwitchAudioMode(0);
|
||||||
|
|
||||||
// stop checking if devices were removed/inserted
|
// stop checking if devices were removed/inserted
|
||||||
// since we're starting emulation again
|
// since we're starting emulation again
|
||||||
@ -308,32 +311,15 @@ int main(int argc, char *argv[])
|
|||||||
PowerNES(); // reset game
|
PowerNES(); // reset game
|
||||||
ResetRequested = 0;
|
ResetRequested = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ConfigRequested)
|
if(ConfigRequested)
|
||||||
{
|
{
|
||||||
|
TakeScreenshot();
|
||||||
ResetVideo_Menu();
|
ResetVideo_Menu();
|
||||||
if (GCSettings.AutoSave == 1)
|
|
||||||
{
|
|
||||||
SaveRAM(GCSettings.SaveMethod, SILENT);
|
|
||||||
}
|
|
||||||
else if (GCSettings.AutoSave == 2)
|
|
||||||
{
|
|
||||||
SaveState(GCSettings.SaveMethod, SILENT);
|
|
||||||
}
|
|
||||||
else if(GCSettings.AutoSave == 3)
|
|
||||||
{
|
|
||||||
SaveRAM(GCSettings.SaveMethod, SILENT);
|
|
||||||
SaveState(GCSettings.SaveMethod, SILENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// save zoom level
|
|
||||||
SavePrefs(SILENT);
|
|
||||||
|
|
||||||
ConfigRequested = 0;
|
ConfigRequested = 0;
|
||||||
break; // leave emulation loop
|
break; // leave emulation loop
|
||||||
}
|
}
|
||||||
}
|
} // emulation loop
|
||||||
}
|
} // main loop
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -40,6 +40,18 @@ enum {
|
|||||||
FILE_PREF
|
FILE_PREF
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
CTRL_PAD,
|
||||||
|
CTRL_ZAPPER,
|
||||||
|
CTRL_PAD2,
|
||||||
|
CTRL_PAD4,
|
||||||
|
CTRL_LENGTH
|
||||||
|
};
|
||||||
|
|
||||||
|
const char ctrlName[6][20] =
|
||||||
|
{ "NES Controller", "NES Zapper", "NES Controllers (2)", "NES Controllers (4)" };
|
||||||
|
|
||||||
struct SGCSettings{
|
struct SGCSettings{
|
||||||
int AutoLoad;
|
int AutoLoad;
|
||||||
int AutoSave;
|
int AutoSave;
|
||||||
@ -54,7 +66,6 @@ struct SGCSettings{
|
|||||||
char smbpwd[20];
|
char smbpwd[20];
|
||||||
char smbshare[20];
|
char smbshare[20];
|
||||||
|
|
||||||
int Zoom; // 0 - off, 1 - on
|
|
||||||
float ZoomLevel; // zoom amount
|
float ZoomLevel; // zoom amount
|
||||||
int VerifySaves;
|
int VerifySaves;
|
||||||
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
||||||
@ -62,21 +73,23 @@ struct SGCSettings{
|
|||||||
int hideoverscan;
|
int hideoverscan;
|
||||||
int currpal;
|
int currpal;
|
||||||
int timing;
|
int timing;
|
||||||
int FourScore;
|
int Controller;
|
||||||
int zapper;
|
|
||||||
int crosshair;
|
int crosshair;
|
||||||
int xshift; // video output shift
|
int xshift; // video output shift
|
||||||
int yshift;
|
int yshift;
|
||||||
|
int WiimoteOrientation;
|
||||||
|
int ExitAction;
|
||||||
|
int MusicVolume;
|
||||||
|
int SFXVolume;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ExitToLoader();
|
void ExitApp();
|
||||||
void Reboot();
|
|
||||||
void ShutdownWii();
|
void ShutdownWii();
|
||||||
extern struct SGCSettings GCSettings;
|
extern struct SGCSettings GCSettings;
|
||||||
extern int ConfigRequested;
|
extern int ConfigRequested;
|
||||||
extern int ShutdownRequested;
|
extern int ShutdownRequested;
|
||||||
|
extern int ExitRequested;
|
||||||
extern char appPath[];
|
extern char appPath[];
|
||||||
extern int frameskip;
|
extern int frameskip;
|
||||||
extern unsigned char * nesrom;
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceload.c
|
* fceload.c
|
||||||
*
|
*
|
||||||
@ -37,9 +37,9 @@ extern uint8 FDSBIOS[8192];
|
|||||||
#include "gcaudio.h"
|
#include "gcaudio.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
|
|
||||||
bool romLoaded = false;
|
bool romLoaded = false;
|
||||||
|
|
||||||
@ -76,88 +76,88 @@ static void MakeFCEUFile(char * membuffer, int length)
|
|||||||
|
|
||||||
int GCMemROM(int method, int size)
|
int GCMemROM(int method, int size)
|
||||||
{
|
{
|
||||||
ResetGameLoaded();
|
ResetGameLoaded();
|
||||||
|
|
||||||
/*** Allocate and clear GameInfo ***/
|
/*** Allocate and clear GameInfo ***/
|
||||||
|
|
||||||
FCEUGameInfo = (FCEUGI *)memalign(32,sizeof(FCEUGI));
|
FCEUGameInfo = (FCEUGI *) memalign(32, sizeof(FCEUGI));
|
||||||
memset(FCEUGameInfo, 0, sizeof(FCEUGI));
|
memset(FCEUGameInfo, 0, sizeof(FCEUGI));
|
||||||
|
|
||||||
/*** Set some default values ***/
|
/*** Set some default values ***/
|
||||||
FCEUGameInfo->soundchan = 1;
|
FCEUGameInfo->soundchan = 1;
|
||||||
FCEUGameInfo->soundrate = SAMPLERATE;
|
FCEUGameInfo->soundrate = SAMPLERATE;
|
||||||
FCEUGameInfo->name=0;
|
FCEUGameInfo->name = 0;
|
||||||
FCEUGameInfo->type=GIT_CART;
|
FCEUGameInfo->type = GIT_CART;
|
||||||
FCEUGameInfo->vidsys=GIV_USER;
|
FCEUGameInfo->vidsys = GIV_USER;
|
||||||
FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
|
FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = -1;
|
||||||
FCEUGameInfo->inputfc=-1;
|
FCEUGameInfo->inputfc = -1;
|
||||||
FCEUGameInfo->cspecial=0;
|
FCEUGameInfo->cspecial = 0;
|
||||||
|
|
||||||
/*** Set internal sound information ***/
|
/*** Set internal sound information ***/
|
||||||
FCEUI_Sound(SAMPLERATE);
|
FCEUI_Sound(SAMPLERATE);
|
||||||
FCEUI_SetSoundVolume(100); // 0-100
|
FCEUI_SetSoundVolume(100); // 0-100
|
||||||
FCEUI_SetLowPass(0);
|
FCEUI_SetLowPass(0);
|
||||||
|
|
||||||
InitialisePads();
|
InitialisePads();
|
||||||
|
|
||||||
MakeFCEUFile((char *)nesrom, size);
|
MakeFCEUFile((char *) nesrom, size);
|
||||||
|
|
||||||
nesGameType = 0;
|
nesGameType = 0;
|
||||||
|
|
||||||
if(iNESLoad(NULL, fceufp))
|
if (iNESLoad(NULL, fceufp))
|
||||||
nesGameType = 1;
|
nesGameType = 1;
|
||||||
else if(UNIFLoad(NULL,fceufp))
|
else if (UNIFLoad(NULL, fceufp))
|
||||||
nesGameType = 2;
|
nesGameType = 2;
|
||||||
else if(NSFLoad(fceufp))
|
else if (NSFLoad(fceufp))
|
||||||
nesGameType = 3;
|
nesGameType = 3;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// read FDS BIOS into FDSBIOS - should be 8192 bytes
|
// read FDS BIOS into FDSBIOS - should be 8192 bytes
|
||||||
if(FDSBIOS[1] == 0)
|
if (FDSBIOS[1] == 0)
|
||||||
{
|
{
|
||||||
int biosSize = 0;
|
int biosSize = 0;
|
||||||
char * tmpbuffer = (char *)memalign(32,64 * 1024);
|
char * tmpbuffer = (char *) memalign(32, 64 * 1024);
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
if(MakeFilePath(filepath, FILE_FDSBIOS, method))
|
if (MakeFilePath(filepath, FILE_FDSBIOS, method))
|
||||||
{
|
{
|
||||||
biosSize = LoadFile (tmpbuffer, filepath, 0, method, SILENT);
|
biosSize = LoadFile(tmpbuffer, filepath, 0, method, SILENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(biosSize == 8192)
|
if (biosSize == 8192)
|
||||||
{
|
{
|
||||||
memcpy(FDSBIOS, tmpbuffer, 8192);
|
memcpy(FDSBIOS, tmpbuffer, 8192);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(biosSize > 0)
|
if (biosSize > 0)
|
||||||
WaitPrompt("FDS BIOS file is invalid!");
|
ErrorPrompt("FDS BIOS file is invalid!");
|
||||||
|
|
||||||
return 0; // BIOS not loaded, do not load game
|
return 0; // BIOS not loaded, do not load game
|
||||||
}
|
}
|
||||||
free(tmpbuffer);
|
free(tmpbuffer);
|
||||||
}
|
}
|
||||||
// load game
|
// load game
|
||||||
if(FDSLoad(NULL,fceufp))
|
if (FDSLoad(NULL, fceufp))
|
||||||
nesGameType = 4;
|
nesGameType = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nesGameType > 0)
|
if (nesGameType > 0)
|
||||||
{
|
{
|
||||||
FCEU_ResetVidSys();
|
FCEU_ResetVidSys();
|
||||||
PowerNES();
|
PowerNES();
|
||||||
FCEU_ResetPalette();
|
FCEU_ResetPalette();
|
||||||
FCEU_ResetMessages(); // Save state, status messages, etc.
|
FCEU_ResetMessages(); // Save state, status messages, etc.
|
||||||
SetSoundVariables();
|
SetSoundVariables();
|
||||||
ResetAudio();
|
ResetAudio();
|
||||||
romLoaded = true;
|
romLoaded = true;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Invalid game file!");
|
ErrorPrompt("Invalid game file!");
|
||||||
romLoaded = false;
|
romLoaded = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceuload.h
|
* fceuload.h
|
||||||
*
|
*
|
||||||
@ -10,3 +10,4 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int GCMemROM(int method, int size);
|
int GCMemROM(int method, int size);
|
||||||
|
extern bool romLoaded;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceustate.c
|
* fceustate.cpp
|
||||||
*
|
*
|
||||||
* Memory Based Load/Save RAM Manager
|
* Memory Based Load/Save RAM Manager
|
||||||
*
|
*
|
||||||
@ -20,10 +20,9 @@
|
|||||||
#include <fat.h>
|
#include <fat.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "images/saveicon.h"
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
|
||||||
@ -42,34 +41,9 @@ extern CartInfo UNIFCart;
|
|||||||
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
||||||
{
|
{
|
||||||
u32 offset = 0;
|
u32 offset = 0;
|
||||||
char comment[2][32];
|
|
||||||
memset(comment, 0, 64);
|
|
||||||
|
|
||||||
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0])
|
if(LocalHWInfo->battery && LocalHWInfo->SaveGame[0])
|
||||||
{
|
{
|
||||||
// add save icon and comments for Memory Card saves
|
|
||||||
if(operation == 0 &&
|
|
||||||
(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB))
|
|
||||||
{
|
|
||||||
// Copy in save icon
|
|
||||||
memcpy(savebuffer, saveicon, sizeof(saveicon));
|
|
||||||
offset += sizeof(saveicon);
|
|
||||||
|
|
||||||
// And the comments
|
|
||||||
sprintf (comment[0], "%s RAM", APPNAME);
|
|
||||||
strncpy (comment[1],romFilename,31); // we only have 32 chars to work with!
|
|
||||||
comment[1][31] = 0;
|
|
||||||
memcpy(savebuffer+offset, comment, 64);
|
|
||||||
offset += 64;
|
|
||||||
}
|
|
||||||
// skip save icon and comments for Memory Card saves
|
|
||||||
else if(operation == 1 &&
|
|
||||||
(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB))
|
|
||||||
{
|
|
||||||
offset += sizeof(saveicon);
|
|
||||||
offset += 64; // sizeof prefscomment
|
|
||||||
}
|
|
||||||
|
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
for(x=0;x<4;x++)
|
for(x=0;x<4;x++)
|
||||||
@ -87,28 +61,25 @@ static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
|||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveRAM (int method, bool silent)
|
bool SaveRAM (char * filepath, int method, bool silent)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
char filepath[1024];
|
|
||||||
int datasize = 0;
|
int datasize = 0;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if(nesGameType == 4)
|
if(nesGameType == 4)
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt("Saving is not available for FDS games!");
|
InfoPrompt("RAM saving is not available for FDS games!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent);
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
if (!MakeFilePath(filepath, FILE_RAM, method))
|
if(method == METHOD_AUTO)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShowAction ("Saving...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
// save game save to savebuffer
|
// save game save to savebuffer
|
||||||
@ -119,45 +90,65 @@ bool SaveRAM (int method, bool silent)
|
|||||||
|
|
||||||
if (datasize)
|
if (datasize)
|
||||||
{
|
{
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
// Set the comments
|
||||||
|
char comments[2][32];
|
||||||
|
memset(comments, 0, 64);
|
||||||
|
sprintf (comments[0], "%s RAM", APPNAME);
|
||||||
|
snprintf (comments[1], 32, romFilename);
|
||||||
|
SetMCSaveComments(comments);
|
||||||
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, method, silent);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if ( !silent )
|
if (!silent)
|
||||||
WaitPrompt("Save successful");
|
InfoPrompt("Save successful");
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( !silent )
|
if (!silent)
|
||||||
WaitPrompt("No data to save!");
|
InfoPrompt("No data to save!");
|
||||||
}
|
}
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadRAM (int method, bool silent)
|
bool
|
||||||
|
SaveRAMAuto (int method, bool silent)
|
||||||
{
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_RAM, method, romFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SaveRAM(filepath, method, silent);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadRAM (char * filepath, int method, bool silent)
|
||||||
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
|
||||||
if(nesGameType == 4)
|
if(nesGameType == 4) // RAM saves don't exist for FDS games
|
||||||
{
|
|
||||||
if(!silent)
|
|
||||||
WaitPrompt("Saving is not available for FDS games!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||||
|
|
||||||
if (!MakeFilePath(filepath, FILE_RAM, method))
|
if(method == METHOD_AUTO)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShowAction ("Loading...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, silent);
|
offset = LoadFile(filepath, method, silent);
|
||||||
@ -176,8 +167,25 @@ bool LoadRAM (int method, bool silent)
|
|||||||
{
|
{
|
||||||
// if we reached here, nothing was done!
|
// if we reached here, nothing was done!
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt ("Save file not found");
|
InfoPrompt ("Save file not found");
|
||||||
}
|
}
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
LoadRAMAuto (int method, bool silent)
|
||||||
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_RAM, method, romFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return LoadRAM(filepath, method, silent);
|
||||||
|
}
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceuram.h
|
* fceuram.h
|
||||||
*
|
*
|
||||||
* Memory Based Load/Save RAM Manager
|
* Memory Based Load/Save RAM Manager
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveRAM (int method, bool silent);
|
bool SaveRAM (char * filepath, int method, bool silent);
|
||||||
bool LoadRAM (int method, bool silent);
|
bool SaveRAMAuto (int method, bool silent);
|
||||||
|
bool LoadRAM (char * filepath, int method, bool silent);
|
||||||
|
bool LoadRAMAuto (int method, bool silent);
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceustate.c
|
* fceustate.cpp
|
||||||
*
|
*
|
||||||
* Memory Based Load/Save State Manager
|
* Memory Based Load/Save State Manager
|
||||||
*
|
*
|
||||||
@ -21,10 +21,9 @@
|
|||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "x6502.h"
|
#include "x6502.h"
|
||||||
|
|
||||||
#include "images/saveicon.h"
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
|
|
||||||
@ -57,33 +56,33 @@ static int sboffset; // Used as a basic fileptr
|
|||||||
/*** Open a file ***/
|
/*** Open a file ***/
|
||||||
static void memopen()
|
static void memopen()
|
||||||
{
|
{
|
||||||
sboffset = 0;
|
sboffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Write to the file ***/
|
/*** Write to the file ***/
|
||||||
static void memfwrite(void *buffer, int len)
|
static void memfwrite(void *buffer, int len)
|
||||||
{
|
{
|
||||||
if ((sboffset + len) > SAVEBUFFERSIZE)
|
if ((sboffset + len) > SAVEBUFFERSIZE)
|
||||||
WaitPrompt("Buffer Exceeded");
|
ErrorPrompt("Buffer Exceeded");
|
||||||
|
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
memcpy(&savebuffer[sboffset], buffer, len);
|
memcpy(&savebuffer[sboffset], buffer, len);
|
||||||
sboffset += len;
|
sboffset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Read from a file ***/
|
/*** Read from a file ***/
|
||||||
static void memfread(void *buffer, int len)
|
static void memfread(void *buffer, int len)
|
||||||
{
|
{
|
||||||
if ( (sboffset + len) > SAVEBUFFERSIZE)
|
if ((sboffset + len) > SAVEBUFFERSIZE)
|
||||||
WaitPrompt("Buffer exceeded");
|
ErrorPrompt("Buffer exceeded");
|
||||||
|
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
{
|
{
|
||||||
memcpy(buffer, &savebuffer[sboffset], len);
|
memcpy(buffer, &savebuffer[sboffset], len);
|
||||||
sboffset += len;
|
sboffset += len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -124,14 +123,14 @@ static int GCReadChunk(int chunkid, SFORMAT *sf)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Bad chunk link");
|
ErrorPrompt("Bad chunk link");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(info, "No Sync %s %s", chunk, sf->desc);
|
sprintf(info, "No Sync %s %s", chunk, sf->desc);
|
||||||
WaitPrompt(info);
|
ErrorPrompt(info);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sf++;
|
sf++;
|
||||||
@ -155,13 +154,6 @@ static int GCFCEUSS_Load(int method)
|
|||||||
{
|
{
|
||||||
memopen(); // reset file pointer
|
memopen(); // reset file pointer
|
||||||
|
|
||||||
// skip save icon and comments for Memory Card saves
|
|
||||||
if (method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
sboffset += sizeof(saveicon);
|
|
||||||
sboffset += 64; // sizeof prefscomment
|
|
||||||
}
|
|
||||||
|
|
||||||
sboffset += 16; // skip FCEU header
|
sboffset += 16; // skip FCEU header
|
||||||
|
|
||||||
// Now read the chunks back
|
// Now read the chunks back
|
||||||
@ -201,47 +193,48 @@ static int GCFCEUSS_Load(int method)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static int GCSaveChunk(int chunkid, SFORMAT *sf)
|
static int GCSaveChunk(int chunkid, SFORMAT *sf)
|
||||||
{
|
{
|
||||||
int chnkstart;
|
int chnkstart;
|
||||||
int csize = 0;
|
int csize = 0;
|
||||||
int chsize = 0;
|
int chsize = 0;
|
||||||
char chunk[] = "CHNK";
|
char chunk[] = "CHNK";
|
||||||
|
|
||||||
/*** Add chunk marker ***/
|
/*** Add chunk marker ***/
|
||||||
memfwrite(&chunk, 4);
|
memfwrite(&chunk, 4);
|
||||||
memfwrite(&chunkid, 4);
|
memfwrite(&chunkid, 4);
|
||||||
chnkstart = sboffset; /*** Save ptr ***/
|
chnkstart = sboffset; /*** Save ptr ***/
|
||||||
sboffset += 4; /*** Space for length ***/
|
sboffset += 4; /*** Space for length ***/
|
||||||
csize += 12;
|
csize += 12;
|
||||||
|
|
||||||
/*** Now run through this structure ***/
|
/*** Now run through this structure ***/
|
||||||
while (sf->v) {
|
while (sf->v)
|
||||||
/*** Check that there is a decription ***/
|
{
|
||||||
if ( sf->desc == NULL)
|
/*** Check that there is a decription ***/
|
||||||
break;
|
if (sf->desc == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
/*** Write out the description ***/
|
/*** Write out the description ***/
|
||||||
memfwrite( sf->desc, 4);
|
memfwrite(sf->desc, 4);
|
||||||
|
|
||||||
/*** Write the length of this chunk ***/
|
/*** Write the length of this chunk ***/
|
||||||
chsize = ( sf->s & (~RLSB) );
|
chsize = (sf->s & (~RLSB));
|
||||||
memfwrite( &chsize, 4);
|
memfwrite(&chsize, 4);
|
||||||
|
|
||||||
if ( chsize > 0 )
|
if (chsize > 0)
|
||||||
{
|
{
|
||||||
/*** Write the actual data ***/
|
/*** Write the actual data ***/
|
||||||
memfwrite( sf->v, chsize );
|
memfwrite(sf->v, chsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
csize += 8;
|
csize += 8;
|
||||||
csize += chsize;
|
csize += chsize;
|
||||||
|
|
||||||
sf++;
|
sf++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Update CHNK length ***/
|
/*** Update CHNK length ***/
|
||||||
memcpy(&savebuffer[chnkstart], &csize, 4);
|
memcpy(&savebuffer[chnkstart], &csize, 4);
|
||||||
|
|
||||||
return csize;
|
return csize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -265,21 +258,6 @@ static int GCFCEUSS_Save(int method)
|
|||||||
|
|
||||||
memopen(); // Reset Memory File
|
memopen(); // Reset Memory File
|
||||||
|
|
||||||
// add save icon and comments for Memory Card saves
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
// Copy in save icon
|
|
||||||
memfwrite((void *)&saveicon, sizeof(saveicon));
|
|
||||||
totalsize += sizeof(saveicon);
|
|
||||||
|
|
||||||
// And the comments
|
|
||||||
sprintf (comment[0], "%s State", APPNAME);
|
|
||||||
strncpy (comment[1],romFilename,31); // we only have 32 chars to work with!
|
|
||||||
comment[1][31] = 0;
|
|
||||||
memfwrite(&comment[0], 64);
|
|
||||||
totalsize += 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add version ID
|
// Add version ID
|
||||||
int mcversion = 0x981211;
|
int mcversion = 0x981211;
|
||||||
memcpy(&header[8], &mcversion, 4);
|
memcpy(&header[8], &mcversion, 4);
|
||||||
@ -313,33 +291,40 @@ static int GCFCEUSS_Save(int method)
|
|||||||
return totalsize;
|
return totalsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SaveState (int method, bool silent)
|
bool SaveState (char * filepath, int method, bool silent)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
char filepath[1024];
|
|
||||||
int datasize;
|
int datasize;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent);
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
if (!MakeFilePath(filepath, FILE_STATE, method))
|
if(method == METHOD_AUTO)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShowAction ("Saving...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
datasize = GCFCEUSS_Save(method);
|
datasize = GCFCEUSS_Save(method);
|
||||||
|
|
||||||
if (datasize)
|
if (datasize)
|
||||||
{
|
{
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
// Set the comments
|
||||||
|
char comments[2][32];
|
||||||
|
memset(comments, 0, 64);
|
||||||
|
sprintf (comments[0], "%s State", APPNAME);
|
||||||
|
snprintf (comments[1], 32, romFilename);
|
||||||
|
SetMCSaveComments(comments);
|
||||||
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, method, silent);
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if ( !silent )
|
if ( !silent )
|
||||||
WaitPrompt("Save successful");
|
InfoPrompt("Save successful");
|
||||||
retval = true;
|
retval = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -347,20 +332,34 @@ bool SaveState (int method, bool silent)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LoadState (int method, bool silent)
|
bool
|
||||||
|
SaveStateAuto (int method, bool silent)
|
||||||
{
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
char filepath[1024];
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_STATE, method, romFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return SaveState(filepath, method, silent);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadState (char * filepath, int method, bool silent)
|
||||||
|
{
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
bool retval = false;
|
bool retval = false;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||||
|
|
||||||
if (!MakeFilePath(filepath, FILE_STATE, method))
|
if(method == METHOD_AUTO)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
ShowAction ("Loading...");
|
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
|
|
||||||
offset = LoadFile(filepath, method, silent);
|
offset = LoadFile(filepath, method, silent);
|
||||||
@ -374,8 +373,25 @@ bool LoadState (int method, bool silent)
|
|||||||
{
|
{
|
||||||
// if we reached here, nothing was done!
|
// if we reached here, nothing was done!
|
||||||
if(!silent)
|
if(!silent)
|
||||||
WaitPrompt ("State file not found");
|
ErrorPrompt ("State file not found");
|
||||||
}
|
}
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
LoadStateAuto (int method, bool silent)
|
||||||
|
{
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
char filepath[1024];
|
||||||
|
|
||||||
|
if(!MakeFilePath(filepath, FILE_STATE, method, romFilename, 0))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return LoadState(filepath, method, silent);
|
||||||
|
}
|
||||||
|
@ -2,12 +2,14 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fceustate.h
|
* fceustate.h
|
||||||
*
|
*
|
||||||
* Memory Based Load/Save State Manager
|
* Memory Based Load/Save State Manager
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool SaveState (int method, bool silent);
|
bool SaveState (char * filepath, int method, bool silent);
|
||||||
bool LoadState (int method, bool silent);
|
bool SaveStateAuto (int method, bool silent);
|
||||||
|
bool LoadState (char * filepath, int method, bool silent);
|
||||||
|
bool LoadStateAuto (int method, bool silent);
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* filesel.c
|
* filebrowser.cpp
|
||||||
*
|
*
|
||||||
* Generic file routines - reading, writing, browsing
|
* Generic file routines - reading, writing, browsing
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -22,14 +22,16 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "pad.h"
|
#include "pad.h"
|
||||||
#include "fceuload.h"
|
#include "fceuload.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
|
#include "fceuram.h"
|
||||||
|
#include "fceustate.h"
|
||||||
|
|
||||||
BROWSERINFO browser;
|
BROWSERINFO browser;
|
||||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||||
@ -50,7 +52,7 @@ int autoLoadMethod()
|
|||||||
{
|
{
|
||||||
ShowAction ("Attempting to determine load method...");
|
ShowAction ("Attempting to determine load method...");
|
||||||
|
|
||||||
int method = 0;
|
int method = METHOD_AUTO;
|
||||||
|
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
method = METHOD_SD;
|
method = METHOD_SD;
|
||||||
@ -61,10 +63,11 @@ int autoLoadMethod()
|
|||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
method = METHOD_SMB;
|
||||||
else
|
else
|
||||||
WaitPrompt("Unable to auto-determine load method!");
|
ErrorPrompt("Unable to auto-determine load method!");
|
||||||
|
|
||||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
if(GCSettings.LoadMethod == METHOD_AUTO)
|
||||||
GCSettings.LoadMethod = method; // save method found for later use
|
GCSettings.LoadMethod = method; // save method found for later use
|
||||||
|
CancelAction();
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,23 +81,25 @@ int autoSaveMethod(bool silent)
|
|||||||
if(!silent)
|
if(!silent)
|
||||||
ShowAction ("Attempting to determine save method...");
|
ShowAction ("Attempting to determine save method...");
|
||||||
|
|
||||||
int method = 0;
|
int method = METHOD_AUTO;
|
||||||
|
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
method = METHOD_SD;
|
method = METHOD_SD;
|
||||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||||
method = METHOD_USB;
|
method = METHOD_USB;
|
||||||
else if(TestCard(CARD_SLOTA, SILENT))
|
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
||||||
method = METHOD_MC_SLOTA;
|
method = METHOD_MC_SLOTA;
|
||||||
else if(TestCard(CARD_SLOTB, SILENT))
|
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
||||||
method = METHOD_MC_SLOTB;
|
method = METHOD_MC_SLOTB;
|
||||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||||
method = METHOD_SMB;
|
method = METHOD_SMB;
|
||||||
else if(!silent)
|
else if(!silent)
|
||||||
WaitPrompt("Unable to auto-determine save method!");
|
ErrorPrompt("Unable to auto-determine save method!");
|
||||||
|
|
||||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
if(GCSettings.SaveMethod == METHOD_AUTO)
|
||||||
GCSettings.SaveMethod = method; // save method found for later use
|
GCSettings.SaveMethod = method; // save method found for later use
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
return method;
|
return method;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,7 +109,9 @@ int autoSaveMethod(bool silent)
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void ResetBrowser()
|
void ResetBrowser()
|
||||||
{
|
{
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
browser.numEntries = 0;
|
||||||
|
browser.selIndex = 0;
|
||||||
|
browser.pageIndex = 0;
|
||||||
|
|
||||||
// Clear any existing values
|
// Clear any existing values
|
||||||
if(browserList != NULL)
|
if(browserList != NULL)
|
||||||
@ -166,16 +173,17 @@ int UpdateDirName(int method)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Directory name is too long!");
|
ErrorPrompt("Directory name is too long!");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MakeFilePath(char filepath[], int type, int method)
|
bool MakeFilePath(char filepath[], int type, int method, char * filename, int filenum)
|
||||||
{
|
{
|
||||||
char file[512];
|
char file[512];
|
||||||
char folder[1024];
|
char folder[1024];
|
||||||
|
char ext[4];
|
||||||
char temppath[MAXPATHLEN];
|
char temppath[MAXPATHLEN];
|
||||||
|
|
||||||
if(type == FILE_ROM)
|
if(type == FILE_ROM)
|
||||||
@ -183,7 +191,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
// Check path length
|
// Check path length
|
||||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
||||||
{
|
{
|
||||||
WaitPrompt("Maximum filepath length reached!");
|
ErrorPrompt("Maximum filepath length reached!");
|
||||||
filepath[0] = 0;
|
filepath[0] = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -197,13 +205,33 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case FILE_RAM:
|
case FILE_RAM:
|
||||||
sprintf(folder, GCSettings.SaveFolder);
|
|
||||||
sprintf(file, "%s.sav", romFilename);
|
|
||||||
break;
|
|
||||||
case FILE_STATE:
|
case FILE_STATE:
|
||||||
sprintf(folder, GCSettings.SaveFolder);
|
sprintf(folder, GCSettings.SaveFolder);
|
||||||
sprintf(file, "%s.fcs", romFilename);
|
|
||||||
|
if(type == FILE_RAM) sprintf(ext, "sav");
|
||||||
|
else sprintf(ext, "fcs");
|
||||||
|
|
||||||
|
if(filenum >= 0)
|
||||||
|
{
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
filename[26] = 0; // truncate filename
|
||||||
|
sprintf(file, "%s%i.%s", filename, filenum, ext);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(filenum == 0)
|
||||||
|
sprintf(file, "%s Auto.%s", filename, ext);
|
||||||
|
else
|
||||||
|
sprintf(file, "%s %i.%s", filename, filenum, ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf(file, "%s", filename);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FILE_FDSBIOS:
|
case FILE_FDSBIOS:
|
||||||
sprintf(folder, GCSettings.LoadFolder);
|
sprintf(folder, GCSettings.LoadFolder);
|
||||||
sprintf(file, "disksys.rom");
|
sprintf(file, "disksys.rom");
|
||||||
@ -225,7 +253,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy(filepath, temppath);
|
strncpy(filepath, temppath, MAXPATHLEN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +299,7 @@ bool IsValidROM(int method)
|
|||||||
if(browserList[browser.selIndex].length < (1024*8) ||
|
if(browserList[browser.selIndex].length < (1024*8) ||
|
||||||
browserList[browser.selIndex].length > (1024*1024*3))
|
browserList[browser.selIndex].length > (1024*1024*3))
|
||||||
{
|
{
|
||||||
WaitPrompt("Invalid file size!");
|
ErrorPrompt("Invalid file size!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -310,7 +338,7 @@ bool IsValidROM(int method)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WaitPrompt("Unknown file type!");
|
ErrorPrompt("Unknown file type!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +347,6 @@ bool IsValidROM(int method)
|
|||||||
*
|
*
|
||||||
* Checks if the specified file is a 7z
|
* Checks if the specified file is a 7z
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
bool IsSz()
|
bool IsSz()
|
||||||
{
|
{
|
||||||
if (strlen(browserList[browser.selIndex].filename) > 4)
|
if (strlen(browserList[browser.selIndex].filename) > 4)
|
||||||
@ -337,352 +364,178 @@ bool IsSz()
|
|||||||
* StripExt
|
* StripExt
|
||||||
*
|
*
|
||||||
* Strips an extension from a filename
|
* Strips an extension from a filename
|
||||||
****************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void StripExt(char* returnstring, char * inputstring)
|
void StripExt(char* returnstring, char * inputstring)
|
||||||
{
|
{
|
||||||
char* loc_dot;
|
char* loc_dot;
|
||||||
|
|
||||||
strcpy (returnstring, inputstring);
|
strncpy (returnstring, inputstring, 255);
|
||||||
|
|
||||||
|
if(inputstring == NULL || strlen(inputstring) < 4)
|
||||||
|
return;
|
||||||
|
|
||||||
loc_dot = strrchr(returnstring,'.');
|
loc_dot = strrchr(returnstring,'.');
|
||||||
if (loc_dot != NULL)
|
if (loc_dot != NULL)
|
||||||
*loc_dot = '\0'; // strip file extension
|
*loc_dot = 0; // strip file extension
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* FileSelector
|
* BrowserLoadSz
|
||||||
*
|
*
|
||||||
* Let user select a file from the listing
|
* Opens the selected 7z file, and parses a listing of the files within
|
||||||
****************************************************************************/
|
***************************************************************************/
|
||||||
int FileSelector (int method)
|
int BrowserLoadSz(int method)
|
||||||
{
|
{
|
||||||
u32 p = 0;
|
char filepath[MAXPATHLEN];
|
||||||
u32 wp = 0;
|
memset(filepath, 0, MAXPATHLEN);
|
||||||
u32 ph = 0;
|
|
||||||
u32 wh = 0;
|
|
||||||
signed char gc_ay = 0;
|
|
||||||
signed char gc_sx = 0;
|
|
||||||
signed char wm_ay = 0;
|
|
||||||
signed char wm_sx = 0;
|
|
||||||
|
|
||||||
int haverom = 0;
|
// we'll store the 7z filepath for extraction later
|
||||||
int redraw = 1;
|
if(!MakeFilePath(szpath, FILE_ROM, method))
|
||||||
int selectit = 0;
|
return 0;
|
||||||
|
|
||||||
int scroll_delay = 0;
|
// add device to filepath
|
||||||
bool move_selection = 0;
|
sprintf(filepath, "%s%s", rootdir, szpath);
|
||||||
#define SCROLL_INITIAL_DELAY 15
|
memcpy(szpath, filepath, MAXPATHLEN);
|
||||||
#define SCROLL_LOOP_DELAY 2
|
|
||||||
|
|
||||||
while (haverom == 0)
|
int szfiles = SzParse(szpath, method);
|
||||||
{
|
if(szfiles)
|
||||||
if (redraw)
|
{
|
||||||
ShowFiles (browserList, browser.numEntries, browser.pageIndex, browser.selIndex);
|
browser.numEntries = szfiles;
|
||||||
redraw = 0;
|
inSz = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ErrorPrompt("Error opening archive!");
|
||||||
|
|
||||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
return szfiles;
|
||||||
|
}
|
||||||
|
|
||||||
gc_ay = PAD_StickY (0);
|
/****************************************************************************
|
||||||
gc_sx = PAD_SubStickX (0);
|
* BrowserLoadFile
|
||||||
|
*
|
||||||
|
* Loads the selected ROM
|
||||||
|
***************************************************************************/
|
||||||
|
int BrowserLoadFile(int method)
|
||||||
|
{
|
||||||
|
char filepath[1024];
|
||||||
|
int filesize = 0;
|
||||||
|
romLoaded = false;
|
||||||
|
|
||||||
p = PAD_ButtonsDown (0);
|
// check that this is a valid ROM
|
||||||
ph = PAD_ButtonsHeld (0);
|
if(!IsValidROM(method))
|
||||||
#ifdef HW_RVL
|
goto done;
|
||||||
wm_ay = WPAD_StickY (0, 0);
|
|
||||||
wm_sx = WPAD_StickX (0, 1);
|
|
||||||
|
|
||||||
wp = WPAD_ButtonsDown (0);
|
// store the filename (w/o ext) - used for ram/state naming
|
||||||
wh = WPAD_ButtonsHeld (0);
|
StripExt(romFilename, browserList[browser.selIndex].filename);
|
||||||
#endif
|
|
||||||
|
|
||||||
/*** Check for exit combo ***/
|
if(!inSz)
|
||||||
if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) )
|
{
|
||||||
return 0;
|
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||||
|
goto done;
|
||||||
|
|
||||||
/*** Check buttons, perform actions ***/
|
filesize = LoadFile ((char *)nesrom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
||||||
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (method)
|
||||||
{
|
{
|
||||||
if ( selectit )
|
case METHOD_DVD:
|
||||||
selectit = 0;
|
filesize = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
||||||
|
break;
|
||||||
if (browserList[browser.selIndex].isdir) // This is directory
|
default:
|
||||||
{
|
filesize = LoadSzFile(szpath, nesrom);
|
||||||
/* update current directory and set new entry list if directory has changed */
|
break;
|
||||||
|
|
||||||
int status;
|
|
||||||
|
|
||||||
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
|
||||||
{
|
|
||||||
if(method == METHOD_DVD)
|
|
||||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
|
||||||
inSz = false;
|
|
||||||
status = 1;
|
|
||||||
SzClose();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = UpdateDirName(method);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == 1) // ok, open directory
|
|
||||||
{
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case METHOD_DVD:
|
|
||||||
browser.numEntries = ParseDVDdirectory();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
browser.numEntries = ParseDirectory();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!browser.numEntries)
|
|
||||||
{
|
|
||||||
WaitPrompt ("Error reading directory!");
|
|
||||||
haverom = 1; // quit menu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (status == -1) // directory name too long
|
|
||||||
{
|
|
||||||
return 0; // quit menu
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // this is a file
|
|
||||||
{
|
|
||||||
// 7z file - let's open it up to select a file inside
|
|
||||||
if(IsSz())
|
|
||||||
{
|
|
||||||
// we'll store the 7z filepath for extraction later
|
|
||||||
if(!MakeFilePath(szpath, FILE_ROM, method))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// add device to filepath
|
|
||||||
char fullpath[1024];
|
|
||||||
sprintf(fullpath, "%s%s", rootdir, szpath);
|
|
||||||
strcpy(szpath, fullpath);
|
|
||||||
|
|
||||||
int szfiles = SzParse(szpath, method);
|
|
||||||
if(szfiles)
|
|
||||||
{
|
|
||||||
browser.numEntries = szfiles;
|
|
||||||
inSz = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
WaitPrompt("Error opening archive!");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check that this is a valid ROM
|
|
||||||
if(!IsValidROM(method))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// store the filename (w/o ext) - used for state saving
|
|
||||||
StripExt(romFilename, browserList[browser.selIndex].filename);
|
|
||||||
|
|
||||||
ShowAction ("Loading...");
|
|
||||||
|
|
||||||
int size = 0;
|
|
||||||
|
|
||||||
if(!inSz)
|
|
||||||
{
|
|
||||||
char filepath[1024];
|
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
size = LoadFile((char *)nesrom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (method)
|
|
||||||
{
|
|
||||||
case METHOD_DVD:
|
|
||||||
size = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
size = LoadSzFile(szpath, nesrom);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inSz = false;
|
|
||||||
|
|
||||||
if (size > 0)
|
|
||||||
{
|
|
||||||
if(GCMemROM(method, size) > 0)
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WaitPrompt("Error loading ROM!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
redraw = 1;
|
|
||||||
} // End of A
|
|
||||||
if ((p & PAD_BUTTON_B)
|
|
||||||
|| (wp & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B)))
|
|
||||||
{
|
|
||||||
while ((PAD_ButtonsDown(0) & PAD_BUTTON_B)
|
|
||||||
#ifdef HW_RVL
|
|
||||||
|| (WPAD_ButtonsDown(0) & (WPAD_BUTTON_B | WPAD_CLASSIC_BUTTON_B))
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
if (strcmp(browserList[0].filename, "..") == 0)
|
|
||||||
{
|
|
||||||
browser.selIndex = 0;
|
|
||||||
selectit = 1;
|
|
||||||
}
|
|
||||||
else if (strcmp(browserList[1].filename, "..") == 0)
|
|
||||||
{
|
|
||||||
browser.selIndex = selectit = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
} // End of B
|
|
||||||
if (((p | ph) & PAD_BUTTON_DOWN) || ((wp | wh) & (WPAD_BUTTON_DOWN
|
|
||||||
| WPAD_CLASSIC_BUTTON_DOWN)) || (gc_ay < -PADCAL) || (wm_ay
|
|
||||||
< -PADCAL))
|
|
||||||
{
|
|
||||||
if ((p & PAD_BUTTON_DOWN) || (wp & (WPAD_BUTTON_DOWN
|
|
||||||
| WPAD_CLASSIC_BUTTON_DOWN)))
|
|
||||||
{ /*** Button just pressed ***/
|
|
||||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else if (scroll_delay == 0)
|
|
||||||
{ /*** Button is held ***/
|
|
||||||
scroll_delay = SCROLL_LOOP_DELAY;
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scroll_delay--; // wait
|
|
||||||
}
|
|
||||||
|
|
||||||
if (move_selection)
|
|
||||||
{
|
|
||||||
browser.selIndex++;
|
|
||||||
if (browser.selIndex == browser.numEntries)
|
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
|
||||||
if ((browser.selIndex - browser.pageIndex) >= PAGESIZE)
|
|
||||||
browser.pageIndex += PAGESIZE;
|
|
||||||
redraw = 1;
|
|
||||||
move_selection = 0;
|
|
||||||
}
|
|
||||||
} // End of down
|
|
||||||
if (((p | ph) & PAD_BUTTON_UP) || ((wp | wh) & (WPAD_BUTTON_UP
|
|
||||||
| WPAD_CLASSIC_BUTTON_UP)) || (gc_ay > PADCAL) || (wm_ay
|
|
||||||
> PADCAL))
|
|
||||||
{
|
|
||||||
if ((p & PAD_BUTTON_UP) || (wp & (WPAD_BUTTON_UP
|
|
||||||
| WPAD_CLASSIC_BUTTON_UP)))
|
|
||||||
{ /*** Button just pressed***/
|
|
||||||
scroll_delay = SCROLL_INITIAL_DELAY; // reset scroll delay.
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else if (scroll_delay == 0)
|
|
||||||
{ /*** Button is held ***/
|
|
||||||
scroll_delay = SCROLL_LOOP_DELAY;
|
|
||||||
move_selection = 1; //continue (move selection)
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
scroll_delay--; // wait
|
|
||||||
}
|
|
||||||
|
|
||||||
if (move_selection)
|
|
||||||
{
|
|
||||||
browser.selIndex--;
|
|
||||||
if (browser.selIndex < 0)
|
|
||||||
{
|
|
||||||
browser.selIndex = browser.numEntries - 1;
|
|
||||||
browser.pageIndex = browser.selIndex - PAGESIZE + 1;
|
|
||||||
}
|
|
||||||
if (browser.selIndex < browser.pageIndex)
|
|
||||||
browser.pageIndex -= PAGESIZE;
|
|
||||||
if (browser.pageIndex < 0)
|
|
||||||
browser.pageIndex = 0;
|
|
||||||
redraw = 1;
|
|
||||||
move_selection = 0;
|
|
||||||
}
|
|
||||||
} // End of Up
|
|
||||||
if ((p & PAD_BUTTON_LEFT) || (wp & (WPAD_BUTTON_LEFT
|
|
||||||
| WPAD_CLASSIC_BUTTON_LEFT)))
|
|
||||||
{
|
|
||||||
/*** Go back a page ***/
|
|
||||||
browser.selIndex -= PAGESIZE;
|
|
||||||
if (browser.selIndex < 0)
|
|
||||||
{
|
|
||||||
browser.selIndex = browser.numEntries - 1;
|
|
||||||
browser.pageIndex = browser.selIndex - PAGESIZE + 1;
|
|
||||||
}
|
|
||||||
if (browser.selIndex < browser.pageIndex)
|
|
||||||
browser.pageIndex -= PAGESIZE;
|
|
||||||
if (browser.pageIndex < 0)
|
|
||||||
browser.pageIndex = 0;
|
|
||||||
redraw = 1;
|
|
||||||
}
|
|
||||||
if ((p & PAD_BUTTON_RIGHT) || (wp & (WPAD_BUTTON_RIGHT
|
|
||||||
| WPAD_CLASSIC_BUTTON_RIGHT)))
|
|
||||||
{
|
|
||||||
/*** Go forward a page ***/
|
|
||||||
browser.selIndex += PAGESIZE;
|
|
||||||
if (browser.selIndex > browser.numEntries - 1)
|
|
||||||
browser.selIndex = browser.pageIndex = 0;
|
|
||||||
if ((browser.selIndex - browser.pageIndex) >= PAGESIZE)
|
|
||||||
browser.pageIndex += PAGESIZE;
|
|
||||||
redraw = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
inSz = false;
|
||||||
|
|
||||||
|
if (filesize <= 0)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error loading ROM!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(GCMemROM(method, filesize) > 0)
|
||||||
|
{
|
||||||
|
romLoaded = true;
|
||||||
|
|
||||||
|
// load RAM or state
|
||||||
|
if (GCSettings.AutoLoad == 1)
|
||||||
|
LoadRAMAuto(GCSettings.SaveMethod, SILENT);
|
||||||
|
else if (GCSettings.AutoLoad == 2)
|
||||||
|
LoadStateAuto(GCSettings.SaveMethod, SILENT);
|
||||||
|
|
||||||
|
ResetNES();
|
||||||
|
ResetBrowser();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
CancelAction();
|
||||||
|
return romLoaded;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* BrowserChangeFolder
|
||||||
|
*
|
||||||
|
* Update current directory and set new entry list if directory has changed
|
||||||
|
***************************************************************************/
|
||||||
|
int BrowserChangeFolder(int method)
|
||||||
|
{
|
||||||
|
if(inSz && browser.selIndex == 0) // inside a 7z, requesting to leave
|
||||||
|
{
|
||||||
|
if(method == METHOD_DVD)
|
||||||
|
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||||
|
|
||||||
|
inSz = false;
|
||||||
|
SzClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!UpdateDirName(method))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case METHOD_DVD:
|
||||||
|
ParseDVDdirectory();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ParseDirectory(method);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!browser.numEntries)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error reading directory!");
|
||||||
|
}
|
||||||
|
|
||||||
|
return browser.numEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* OpenROM
|
* OpenROM
|
||||||
* Opens device specified by method, displays a list of ROMS
|
* Displays a list of ROMS on load device
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
int
|
int
|
||||||
OpenROM (int method)
|
OpenGameList ()
|
||||||
{
|
{
|
||||||
|
int method = GCSettings.LoadMethod;
|
||||||
|
|
||||||
if(method == METHOD_AUTO)
|
if(method == METHOD_AUTO)
|
||||||
method = autoLoadMethod();
|
method = autoLoadMethod();
|
||||||
|
|
||||||
if(ChangeInterface(method, NOTSILENT))
|
// change current dir to roms directory
|
||||||
|
switch(method)
|
||||||
{
|
{
|
||||||
// change current dir to roms directory
|
case METHOD_DVD:
|
||||||
switch(method)
|
browser.dir[0] = 0;
|
||||||
{
|
if(MountDVD(NOTSILENT))
|
||||||
case METHOD_DVD:
|
if(ParseDVDdirectory()) // Parse root directory
|
||||||
browser.dir[0] = 0;
|
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||||
browser.numEntries = ParseDVDdirectory(); // Parse root directory
|
break;
|
||||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
default:
|
||||||
break;
|
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
||||||
default:
|
ParseDirectory(method); // Parse root directory
|
||||||
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
break;
|
||||||
browser.numEntries = ParseDirectory(); // Parse root directory
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (browser.numEntries > 0)
|
|
||||||
{
|
|
||||||
// Select an entry
|
|
||||||
return FileSelector (method);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no entries found
|
|
||||||
WaitPrompt ("No Files Found!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 0;
|
return browser.numEntries;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* filesel.h
|
* filebrowser.h
|
||||||
*
|
*
|
||||||
* Generic file routines - reading, writing, browsing
|
* Generic file routines - reading, writing, browsing
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _NGCFILESEL_
|
#ifndef _FILEBROWSER_H_
|
||||||
#define _NGCFILESEL_
|
#define _FILEBROWSER_H_
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@ -29,6 +29,7 @@ typedef struct
|
|||||||
{
|
{
|
||||||
u64 offset; // DVD offset
|
u64 offset; // DVD offset
|
||||||
unsigned int length; // file length
|
unsigned int length; // file length
|
||||||
|
time_t mtime; // file modified time
|
||||||
char isdir; // 0 - file, 1 - directory
|
char isdir; // 0 - file, 1 - directory
|
||||||
char filename[MAXJOLIET + 1]; // full filename
|
char filename[MAXJOLIET + 1]; // full filename
|
||||||
char displayname[MAXDISPLAY + 1]; // name for browser display
|
char displayname[MAXDISPLAY + 1]; // name for browser display
|
||||||
@ -41,12 +42,17 @@ extern char rootdir[10];
|
|||||||
extern char romFilename[];
|
extern char romFilename[];
|
||||||
extern int nesGameType;
|
extern int nesGameType;
|
||||||
|
|
||||||
bool MakeFilePath(char filepath[], int type, int method);
|
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1);
|
||||||
int OpenROM (int method);
|
int UpdateDirName(int method);
|
||||||
|
int OpenGameList();
|
||||||
int autoLoadMethod();
|
int autoLoadMethod();
|
||||||
int autoSaveMethod(bool silent);
|
int autoSaveMethod(bool silent);
|
||||||
int FileSortCallback(const void *f1, const void *f2);
|
int FileSortCallback(const void *f1, const void *f2);
|
||||||
void StripExt(char* returnstring, char * inputstring);
|
void StripExt(char* returnstring, char * inputstring);
|
||||||
|
bool IsSz();
|
||||||
void ResetBrowser();
|
void ResetBrowser();
|
||||||
|
int BrowserLoadSz(int method);
|
||||||
|
int BrowserChangeFolder(int method);
|
||||||
|
int BrowserLoadFile(int method);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric January 2009
|
* Tantric January 2009
|
||||||
*
|
*
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fileop.c
|
* fileop.cpp
|
||||||
*
|
*
|
||||||
* File operations
|
* File operations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -29,8 +29,8 @@
|
|||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "networkop.h"
|
#include "networkop.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
|
|
||||||
unsigned char * savebuffer = NULL;
|
unsigned char * savebuffer = NULL;
|
||||||
FILE * file; // file pointer - the only one we should ever use!
|
FILE * file; // file pointer - the only one we should ever use!
|
||||||
@ -48,7 +48,7 @@ bool isMounted[9] = { false, false, false, false, false, false, false, false, fa
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* deviceThreading
|
* deviceThreading
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
lwp_t devicethread;
|
lwp_t devicethread = LWP_THREAD_NULL;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* devicecallback
|
* devicecallback
|
||||||
@ -114,7 +114,7 @@ devicecallback (void *arg)
|
|||||||
void
|
void
|
||||||
InitDeviceThread()
|
InitDeviceThread()
|
||||||
{
|
{
|
||||||
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 80);
|
LWP_CreateThread (&devicethread, devicecallback, NULL, NULL, 0, 40);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -179,6 +179,7 @@ bool MountFAT(int method)
|
|||||||
unmountRequired[method] = false;
|
unmountRequired[method] = false;
|
||||||
fatUnmount(rootdir);
|
fatUnmount(rootdir);
|
||||||
disc->shutdown();
|
disc->shutdown();
|
||||||
|
isMounted[method] = false;
|
||||||
}
|
}
|
||||||
if(!isMounted[method])
|
if(!isMounted[method])
|
||||||
{
|
{
|
||||||
@ -225,7 +226,7 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
||||||
#endif
|
#endif
|
||||||
if(!mounted && !silent) // no SD device found
|
if(!mounted && !silent) // no SD device found
|
||||||
WaitPrompt ("SD card not found!");
|
ErrorPrompt("SD card not found!");
|
||||||
}
|
}
|
||||||
else if(method == METHOD_USB)
|
else if(method == METHOD_USB)
|
||||||
{
|
{
|
||||||
@ -233,19 +234,31 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
mounted = MountFAT(method);
|
mounted = MountFAT(method);
|
||||||
|
|
||||||
if(!mounted && !silent)
|
if(!mounted && !silent)
|
||||||
WaitPrompt ("USB drive not found!");
|
ErrorPrompt("USB drive not found!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if(method == METHOD_DVD)
|
else if(method == METHOD_DVD)
|
||||||
{
|
{
|
||||||
sprintf(rootdir, "/");
|
rootdir[0] = 0;
|
||||||
mounted = MountDVD(silent);
|
mounted = MountDVD(silent);
|
||||||
}
|
}
|
||||||
|
#ifdef HW_RVL
|
||||||
else if(method == METHOD_SMB)
|
else if(method == METHOD_SMB)
|
||||||
{
|
{
|
||||||
sprintf(rootdir, "smb:/");
|
sprintf(rootdir, "smb:/");
|
||||||
mounted = ConnectShare(silent);
|
mounted = ConnectShare(silent);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
else if(method == METHOD_MC_SLOTA)
|
||||||
|
{
|
||||||
|
rootdir[0] = 0;
|
||||||
|
mounted = TestMC(CARD_SLOTA, silent);
|
||||||
|
}
|
||||||
|
else if(method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
rootdir[0] = 0;
|
||||||
|
mounted = TestMC(CARD_SLOTB, silent);
|
||||||
|
}
|
||||||
|
|
||||||
return mounted;
|
return mounted;
|
||||||
}
|
}
|
||||||
@ -254,39 +267,49 @@ bool ChangeInterface(int method, bool silent)
|
|||||||
* Browse subdirectories
|
* Browse subdirectories
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
int
|
int
|
||||||
ParseDirectory()
|
ParseDirectory(int method)
|
||||||
{
|
{
|
||||||
DIR_ITER *dir;
|
DIR_ITER *dir = NULL;
|
||||||
char fulldir[MAXPATHLEN];
|
char fulldir[MAXPATHLEN];
|
||||||
char filename[MAXPATHLEN];
|
char filename[MAXPATHLEN];
|
||||||
char tmpname[MAXPATHLEN];
|
char tmpname[MAXPATHLEN];
|
||||||
struct stat filestat;
|
struct stat filestat;
|
||||||
char msg[128];
|
char msg[128];
|
||||||
|
int retry = 1;
|
||||||
|
bool mounted = false;
|
||||||
|
|
||||||
// reset browser
|
// reset browser
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
|
|
||||||
// add device to path
|
ShowAction("Loading...");
|
||||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
|
||||||
|
|
||||||
// open the directory
|
// open the directory
|
||||||
dir = diropen(fulldir);
|
while(dir == NULL && retry == 1)
|
||||||
|
{
|
||||||
|
mounted = ChangeInterface(method, NOTSILENT);
|
||||||
|
sprintf(fulldir, "%s%s", rootdir, browser.dir); // add device to path
|
||||||
|
if(mounted) dir = diropen(fulldir);
|
||||||
|
if(dir == NULL)
|
||||||
|
{
|
||||||
|
unmountRequired[method] = true;
|
||||||
|
sprintf(msg, "Error opening %s", fulldir);
|
||||||
|
retry = ErrorPromptRetry(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we can't open the dir, try opening the root dir
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
{
|
{
|
||||||
sprintf(msg, "Error opening %s", fulldir);
|
if(ChangeInterface(method, SILENT))
|
||||||
WaitPrompt(msg);
|
|
||||||
|
|
||||||
// if we can't open the dir, open root dir
|
|
||||||
sprintf(browser.dir,"/");
|
|
||||||
|
|
||||||
dir = diropen(rootdir);
|
|
||||||
|
|
||||||
if (dir == NULL)
|
|
||||||
{
|
{
|
||||||
sprintf(msg, "Error opening %s", rootdir);
|
sprintf(browser.dir,"/");
|
||||||
WaitPrompt(msg);
|
dir = diropen(rootdir);
|
||||||
return 0;
|
if (dir == NULL)
|
||||||
|
{
|
||||||
|
sprintf(msg, "Error opening %s", rootdir);
|
||||||
|
ErrorPrompt(msg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,8 +325,8 @@ ParseDirectory()
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
entryNum = 0;
|
entryNum = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -313,9 +336,19 @@ ParseDirectory()
|
|||||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
|
|
||||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||||
StripExt(tmpname, filename); // hide file extension
|
|
||||||
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
if(strcmp(filename,"..") == 0)
|
||||||
|
{
|
||||||
|
sprintf(browserList[entryNum].displayname, "Up One Level");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StripExt(tmpname, filename); // hide file extension
|
||||||
|
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||||
|
}
|
||||||
|
|
||||||
browserList[entryNum].length = filestat.st_size;
|
browserList[entryNum].length = filestat.st_size;
|
||||||
|
browserList[entryNum].mtime = filestat.st_mtime;
|
||||||
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||||
|
|
||||||
entryNum++;
|
entryNum++;
|
||||||
@ -328,6 +361,9 @@ ParseDirectory()
|
|||||||
// Sort the file list
|
// Sort the file list
|
||||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
browser.numEntries = entryNum;
|
||||||
return entryNum;
|
return entryNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -338,8 +374,8 @@ ParseDirectory()
|
|||||||
void
|
void
|
||||||
AllocSaveBuffer ()
|
AllocSaveBuffer ()
|
||||||
{
|
{
|
||||||
if (savebuffer != NULL)
|
while(savebuffer != NULL) // save buffer is in use
|
||||||
free(savebuffer);
|
usleep(50); // wait for it to be free
|
||||||
|
|
||||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||||
@ -380,7 +416,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Error opening file");
|
ErrorPrompt("Error opening file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
@ -398,9 +434,8 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
char zipbuffer[2048];
|
char zipbuffer[2048];
|
||||||
u32 size = 0;
|
u32 size = 0;
|
||||||
u32 readsize = 0;
|
u32 readsize = 0;
|
||||||
|
char fullpath[MAXPATHLEN];
|
||||||
if(!ChangeInterface(method, NOTSILENT))
|
int retry = 1;
|
||||||
return 0;
|
|
||||||
|
|
||||||
switch(method)
|
switch(method)
|
||||||
{
|
{
|
||||||
@ -419,69 +454,84 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
|||||||
// since we're loading a file
|
// since we're loading a file
|
||||||
LWP_SuspendThread (devicethread);
|
LWP_SuspendThread (devicethread);
|
||||||
|
|
||||||
// add device to filepath
|
// open the file
|
||||||
char fullpath[1024];
|
while(!size && retry == 1)
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
|
||||||
|
|
||||||
file = fopen (fullpath, "rb");
|
|
||||||
|
|
||||||
if (file > 0)
|
|
||||||
{
|
{
|
||||||
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
if(ChangeInterface(method, silent))
|
||||||
{
|
{
|
||||||
size = fread (rbuffer, 1, length, file);
|
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||||
}
|
file = fopen (fullpath, "rb");
|
||||||
else // load whole file
|
|
||||||
{
|
|
||||||
readsize = fread (zipbuffer, 1, 2048, file);
|
|
||||||
|
|
||||||
if(readsize > 0)
|
if(file > 0)
|
||||||
{
|
{
|
||||||
if (IsZipFile (zipbuffer))
|
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
||||||
{
|
{
|
||||||
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
size = fread (rbuffer, 1, length, file);
|
||||||
}
|
}
|
||||||
else
|
else // load whole file
|
||||||
{
|
{
|
||||||
struct stat fileinfo;
|
readsize = fread (zipbuffer, 1, 2048, file);
|
||||||
fstat(file->_file, &fileinfo);
|
|
||||||
size = fileinfo.st_size;
|
|
||||||
|
|
||||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
if(readsize > 0)
|
||||||
|
|
||||||
u32 offset = readsize;
|
|
||||||
while(offset < size)
|
|
||||||
{
|
{
|
||||||
ShowProgress ("Loading...", offset, size);
|
if (IsZipFile (zipbuffer))
|
||||||
readsize = fread (rbuffer + offset, 1, (1024*512), file); // read in 512K chunks
|
{
|
||||||
|
size = UnZipBuffer ((unsigned char *)rbuffer, method); // unzip
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct stat fileinfo;
|
||||||
|
fstat(file->_file, &fileinfo);
|
||||||
|
size = fileinfo.st_size;
|
||||||
|
|
||||||
if(readsize <= 0 || readsize > (1024*512))
|
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||||
break; // read failure
|
|
||||||
|
|
||||||
if(readsize > 0)
|
u32 offset = readsize;
|
||||||
offset += readsize;
|
u32 nextread = 0;
|
||||||
|
while(offset < size)
|
||||||
|
{
|
||||||
|
if(size - offset > 1024*512) nextread = 1024*512;
|
||||||
|
else nextread = size-offset;
|
||||||
|
ShowProgress ("Loading...", offset, size);
|
||||||
|
readsize = fread (rbuffer + offset, 1, nextread, file); // read in next chunk
|
||||||
|
|
||||||
|
if(readsize <= 0 || readsize > nextread)
|
||||||
|
break; // read failure
|
||||||
|
|
||||||
|
if(readsize > 0)
|
||||||
|
offset += readsize;
|
||||||
|
}
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
if(offset != size) // # bytes read doesn't match # expected
|
||||||
|
size = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(offset != size) // # bytes read doesn't match # expected
|
|
||||||
size = 0;
|
|
||||||
}
|
}
|
||||||
|
fclose (file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!size)
|
||||||
|
{
|
||||||
|
if(!silent)
|
||||||
|
{
|
||||||
|
unmountRequired[method] = true;
|
||||||
|
retry = ErrorPromptRetry("Error loading file!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retry = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose (file);
|
|
||||||
}
|
|
||||||
if(!size && !silent)
|
|
||||||
{
|
|
||||||
unmountRequired[method] = true;
|
|
||||||
WaitPrompt("Error loading file!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
|
CancelAction();
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 LoadFile(char filepath[], int method, bool silent)
|
u32 LoadFile(char * filepath, int method, bool silent)
|
||||||
{
|
{
|
||||||
return LoadFile((char *)savebuffer, filepath, 0, method, silent);
|
return LoadFile((char *)savebuffer, filepath, 0, method, silent);
|
||||||
}
|
}
|
||||||
@ -493,53 +543,59 @@ u32 LoadFile(char filepath[], int method, bool silent)
|
|||||||
u32
|
u32
|
||||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||||
{
|
{
|
||||||
|
char fullpath[MAXPATHLEN];
|
||||||
u32 written = 0;
|
u32 written = 0;
|
||||||
|
int retry = 1;
|
||||||
|
|
||||||
if(!ChangeInterface(method, NOTSILENT))
|
if(datasize == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch(method)
|
ShowAction("Saving...");
|
||||||
|
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
{
|
{
|
||||||
case METHOD_MC_SLOTA:
|
if(method == METHOD_MC_SLOTA)
|
||||||
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
return SaveMCFile (buffer, CARD_SLOTA, filepath, datasize, silent);
|
||||||
break;
|
else
|
||||||
case METHOD_MC_SLOTB:
|
|
||||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (datasize)
|
// stop checking if devices were removed/inserted
|
||||||
{
|
// since we're saving a file
|
||||||
// stop checking if devices were removed/inserted
|
LWP_SuspendThread (devicethread);
|
||||||
// since we're saving a file
|
|
||||||
LWP_SuspendThread (devicethread);
|
|
||||||
|
|
||||||
// add device to filepath
|
while(!written && retry == 1)
|
||||||
char fullpath[1024];
|
{
|
||||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
if(ChangeInterface(method, silent))
|
||||||
|
|
||||||
// open file for writing
|
|
||||||
file = fopen (fullpath, "wb");
|
|
||||||
|
|
||||||
if (file > 0)
|
|
||||||
{
|
{
|
||||||
written = fwrite (savebuffer, 1, datasize, file);
|
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||||
fclose (file);
|
file = fopen (fullpath, "wb");
|
||||||
}
|
|
||||||
|
|
||||||
if(!written && !silent)
|
if (file > 0)
|
||||||
|
{
|
||||||
|
written = fwrite (savebuffer, 1, datasize, file);
|
||||||
|
if(written < datasize) written = 0;
|
||||||
|
fclose (file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!written)
|
||||||
{
|
{
|
||||||
unmountRequired[method] = true;
|
unmountRequired[method] = true;
|
||||||
WaitPrompt ("Error saving file!");
|
if(!silent)
|
||||||
|
retry = ErrorPromptRetry("Error saving file!");
|
||||||
|
else
|
||||||
|
retry = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
LWP_ResumeThread (devicethread);
|
LWP_ResumeThread (devicethread);
|
||||||
}
|
|
||||||
|
CancelAction();
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 SaveFile(char filepath[], u32 datasize, int method, bool silent)
|
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent)
|
||||||
{
|
{
|
||||||
return SaveFile((char *)savebuffer, filepath, datasize, method, silent);
|
return SaveFile((char *)savebuffer, filepath, datasize, method, silent);
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* fatop.h
|
* fileop.h
|
||||||
*
|
*
|
||||||
* File operations
|
* File operations
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _FILEOP_H_
|
#ifndef _FILEOP_H_
|
||||||
#define _FILEOP_H_
|
#define _FILEOP_H_
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -24,14 +25,14 @@ void InitDeviceThread();
|
|||||||
void MountAllFAT();
|
void MountAllFAT();
|
||||||
void UnmountAllFAT();
|
void UnmountAllFAT();
|
||||||
bool ChangeInterface(int method, bool silent);
|
bool ChangeInterface(int method, bool silent);
|
||||||
int ParseDirectory();
|
int ParseDirectory(int method);
|
||||||
void AllocSaveBuffer();
|
void AllocSaveBuffer();
|
||||||
void FreeSaveBuffer();
|
void FreeSaveBuffer();
|
||||||
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
u32 LoadFile(char * rbuffer, char *filepath, u32 length, int method, bool silent);
|
||||||
u32 LoadFile(char filepath[], int method, bool silent);
|
u32 LoadFile(char * filepath, int method, bool silent);
|
||||||
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
u32 LoadSzFile(char * filepath, unsigned char * rbuffer);
|
||||||
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
u32 SaveFile(char * buffer, char *filepath, u32 datasize, int method, bool silent);
|
||||||
u32 SaveFile(char filepath[], u32 datasize, int method, bool silent);
|
u32 SaveFile(char * filepath, u32 datasize, int method, bool silent);
|
||||||
|
|
||||||
extern unsigned char * savebuffer;
|
extern unsigned char * savebuffer;
|
||||||
extern FILE * file;
|
extern FILE * file;
|
||||||
|
@ -2,16 +2,17 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
* eke-eke October 2008
|
* eke-eke October 2008
|
||||||
*
|
*
|
||||||
* gcaudio.c
|
* gcaudio.cpp
|
||||||
*
|
*
|
||||||
* Audio driver
|
* Audio driver
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <asndlib.h>
|
||||||
|
|
||||||
#define SAMPLERATE 48000
|
#define SAMPLERATE 48000
|
||||||
|
|
||||||
@ -83,8 +84,6 @@ static void AudioSwitchBuffers()
|
|||||||
void InitialiseAudio()
|
void InitialiseAudio()
|
||||||
{
|
{
|
||||||
AUDIO_Init(NULL); // Start audio subsystem
|
AUDIO_Init(NULL); // Start audio subsystem
|
||||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
|
||||||
AUDIO_RegisterDMACallback( AudioSwitchBuffers );
|
|
||||||
memset(soundbuffer, 0, 3840*2);
|
memset(soundbuffer, 0, 3840*2);
|
||||||
memset(mixbuffer, 0, 16000);
|
memset(mixbuffer, 0, 16000);
|
||||||
}
|
}
|
||||||
@ -112,6 +111,50 @@ void ResetAudio()
|
|||||||
mixhead = mixtail = 0;
|
mixhead = mixtail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* SwitchAudioMode
|
||||||
|
*
|
||||||
|
* Switches between menu sound and emulator sound
|
||||||
|
***************************************************************************/
|
||||||
|
void
|
||||||
|
SwitchAudioMode(int mode)
|
||||||
|
{
|
||||||
|
if(mode == 0) // emulator
|
||||||
|
{
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Pause(1);
|
||||||
|
ASND_End();
|
||||||
|
#endif
|
||||||
|
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||||
|
AUDIO_RegisterDMACallback(AudioSwitchBuffers);
|
||||||
|
}
|
||||||
|
else // menu
|
||||||
|
{
|
||||||
|
AUDIO_StopDMA();
|
||||||
|
AUDIO_RegisterDMACallback(NULL);
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Init();
|
||||||
|
ASND_Pause(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ShutdownAudio
|
||||||
|
*
|
||||||
|
* Shuts down audio subsystem. Useful to avoid unpleasant sounds if a
|
||||||
|
* crash occurs during shutdown.
|
||||||
|
***************************************************************************/
|
||||||
|
void ShutdownAudio()
|
||||||
|
{
|
||||||
|
#ifndef NO_SOUND
|
||||||
|
ASND_Pause(1);
|
||||||
|
ASND_End();
|
||||||
|
#endif
|
||||||
|
AUDIO_StopDMA();
|
||||||
|
AUDIO_RegisterDMACallback(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* PlaySound
|
* PlaySound
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
* eke-eke October 2008
|
* eke-eke October 2008
|
||||||
*
|
*
|
||||||
* gcaudio.h
|
* gcaudio.h
|
||||||
@ -14,3 +14,5 @@ void InitialiseAudio();
|
|||||||
void StopAudio();
|
void StopAudio();
|
||||||
void ResetAudio();
|
void ResetAudio();
|
||||||
void PlaySound( int *Buffer, int samples );
|
void PlaySound( int *Buffer, int samples );
|
||||||
|
void SwitchAudioMode(int mode);
|
||||||
|
void ShutdownAudio();
|
||||||
|
@ -23,8 +23,11 @@ extern "C" {
|
|||||||
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "dvd.h"
|
#include "dvd.h"
|
||||||
|
#include "networkop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "menudraw.h"
|
#include "filebrowser.h"
|
||||||
|
#include "gcvideo.h"
|
||||||
|
#include "menu.h"
|
||||||
#include "gcunzip.h"
|
#include "gcunzip.h"
|
||||||
|
|
||||||
#define ZIPCHUNK 2048
|
#define ZIPCHUNK 2048
|
||||||
@ -145,7 +148,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
res = inflateInit2 (&zs, -MAX_WBITS);
|
res = inflateInit2 (&zs, -MAX_WBITS);
|
||||||
|
|
||||||
if (res != Z_OK)
|
if (res != Z_OK)
|
||||||
return 0;
|
goto done;
|
||||||
|
|
||||||
/*** Set ZipChunk for first pass ***/
|
/*** Set ZipChunk for first pass ***/
|
||||||
zipoffset =
|
zipoffset =
|
||||||
@ -169,8 +172,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
|
|
||||||
if (res == Z_MEM_ERROR)
|
if (res == Z_MEM_ERROR)
|
||||||
{
|
{
|
||||||
inflateEnd (&zs);
|
goto done;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
have = ZIPCHUNK - zs.avail_out;
|
have = ZIPCHUNK - zs.avail_out;
|
||||||
@ -198,23 +200,20 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(sizeread <= 0)
|
if(sizeread <= 0)
|
||||||
break; // read failure
|
goto done; // read failure
|
||||||
|
|
||||||
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
||||||
}
|
}
|
||||||
while (res != Z_STREAM_END);
|
while (res != Z_STREAM_END);
|
||||||
|
|
||||||
|
done:
|
||||||
inflateEnd (&zs);
|
inflateEnd (&zs);
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
if (res == Z_STREAM_END)
|
if (res == Z_STREAM_END)
|
||||||
{
|
return pkzip.uncompressedSize;
|
||||||
if (pkzip.uncompressedSize == (u32) bufferoffset)
|
else
|
||||||
return bufferoffset;
|
return 0;
|
||||||
else
|
|
||||||
return pkzip.uncompressedSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -247,7 +246,7 @@ GetFirstZipFilename (int method)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WaitPrompt("Error - Invalid ZIP file!");
|
ErrorPrompt("Error - Invalid ZIP file!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +316,7 @@ Is7ZipFile (char *buffer)
|
|||||||
// display an error message
|
// display an error message
|
||||||
static void SzDisplayError(SZ_RESULT res)
|
static void SzDisplayError(SZ_RESULT res)
|
||||||
{
|
{
|
||||||
WaitPrompt(szerrormsg[(res - 1)]);
|
ErrorPrompt(szerrormsg[(res - 1)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function used by the 7zip SDK to read data from SD/USB/DVD/SMB
|
// function used by the 7zip SDK to read data from SD/USB/DVD/SMB
|
||||||
@ -472,7 +471,7 @@ int SzParse(char * filepath, int method)
|
|||||||
if(!newBrowserList) // failed to allocate required memory
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
{
|
{
|
||||||
ResetBrowser();
|
ResetBrowser();
|
||||||
WaitPrompt("Out of memory: too many files!");
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
nbfiles = 0;
|
nbfiles = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -553,6 +552,8 @@ int SzExtractFile(int i, unsigned char *buffer)
|
|||||||
// close 7Zip archive and free memory
|
// close 7Zip archive and free memory
|
||||||
SzClose();
|
SzClose();
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
// check for errors
|
// check for errors
|
||||||
if(SzRes != SZ_OK)
|
if(SzRes != SZ_OK)
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* gcvideo.c
|
* gcvideo.cpp
|
||||||
*
|
*
|
||||||
* Video rendering
|
* Video rendering
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -16,12 +16,13 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wiiuse/wpad.h>
|
#include <wiiuse/wpad.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
#include "gcvideo.h"
|
#include "gcvideo.h"
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "images/nesback.h"
|
#include "pad.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
extern void FCEU_ResetPalette(void);
|
extern void FCEU_ResetPalette(void);
|
||||||
@ -37,6 +38,7 @@ static GXRModeObj *vmode; // Graphics Mode Object
|
|||||||
unsigned int *xfb[2]; // Framebuffers
|
unsigned int *xfb[2]; // Framebuffers
|
||||||
int whichfb = 0; // Frame buffer toggle
|
int whichfb = 0; // Frame buffer toggle
|
||||||
int screenheight;
|
int screenheight;
|
||||||
|
int screenwidth;
|
||||||
bool progressive = FALSE;
|
bool progressive = FALSE;
|
||||||
|
|
||||||
/*** 3D GX ***/
|
/*** 3D GX ***/
|
||||||
@ -47,6 +49,7 @@ static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN(32);
|
|||||||
static u32 copynow = GX_FALSE;
|
static u32 copynow = GX_FALSE;
|
||||||
static GXTexObj texobj;
|
static GXTexObj texobj;
|
||||||
static Mtx view;
|
static Mtx view;
|
||||||
|
static Mtx GXmodelView2D;
|
||||||
|
|
||||||
/*** Texture memory ***/
|
/*** Texture memory ***/
|
||||||
static unsigned char texturemem[TEX_WIDTH * TEX_HEIGHT * 2] ATTRIBUTE_ALIGN (32);
|
static unsigned char texturemem[TEX_WIDTH * TEX_HEIGHT * 2] ATTRIBUTE_ALIGN (32);
|
||||||
@ -54,6 +57,9 @@ static unsigned char texturemem[TEX_WIDTH * TEX_HEIGHT * 2] ATTRIBUTE_ALIGN (32)
|
|||||||
static int updateScaling = 1;
|
static int updateScaling = 1;
|
||||||
static int vmode_60hz = 0;
|
static int vmode_60hz = 0;
|
||||||
|
|
||||||
|
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
|
||||||
|
u8 * gameScreenTex2 = NULL; // a GX texture screen capture of the game (copy)
|
||||||
|
|
||||||
#define HASPECT 256
|
#define HASPECT 256
|
||||||
#define VASPECT 240
|
#define VASPECT 240
|
||||||
|
|
||||||
@ -244,7 +250,6 @@ vbgetback (void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -272,7 +277,6 @@ InitVideoThread ()
|
|||||||
static void
|
static void
|
||||||
copy_to_xfb (u32 arg)
|
copy_to_xfb (u32 arg)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (copynow == GX_TRUE)
|
if (copynow == GX_TRUE)
|
||||||
{
|
{
|
||||||
GX_CopyDisp (xfb[whichfb], GX_TRUE);
|
GX_CopyDisp (xfb[whichfb], GX_TRUE);
|
||||||
@ -368,13 +372,11 @@ draw_square (Mtx v)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* StartGX
|
* StartGX
|
||||||
*
|
*
|
||||||
* This function initialises the GX.
|
* This function initialises GX and sets it up for use
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static void
|
static void
|
||||||
StartGX ()
|
StartGX ()
|
||||||
{
|
{
|
||||||
Mtx44 p;
|
|
||||||
|
|
||||||
GXColor background = { 0, 0, 0, 0xff };
|
GXColor background = { 0, 0, 0, 0xff };
|
||||||
|
|
||||||
/*** Clear out FIFO area ***/
|
/*** Clear out FIFO area ***/
|
||||||
@ -384,27 +386,22 @@ StartGX ()
|
|||||||
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||||
GX_SetCopyClear (background, 0x00ffffff);
|
GX_SetCopyClear (background, 0x00ffffff);
|
||||||
|
|
||||||
|
|
||||||
GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1);
|
|
||||||
GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight);
|
|
||||||
GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
GX_SetDispCopyDst (vmode->fbWidth, vmode->xfbHeight);
|
|
||||||
GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, GX_TRUE, vmode->vfilter);
|
|
||||||
|
|
||||||
GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
|
||||||
|
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
|
||||||
GX_SetCullMode (GX_CULL_NONE);
|
|
||||||
GX_SetDispCopyGamma (GX_GM_1_0);
|
GX_SetDispCopyGamma (GX_GM_1_0);
|
||||||
GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
|
GX_SetCullMode (GX_CULL_NONE);
|
||||||
GX_SetColorUpdate (GX_TRUE);
|
}
|
||||||
|
|
||||||
guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
|
/****************************************************************************
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
* StopGX
|
||||||
|
*
|
||||||
|
* Stops GX (when exiting)
|
||||||
|
***************************************************************************/
|
||||||
|
void StopGX()
|
||||||
|
{
|
||||||
|
GX_AbortFrame();
|
||||||
|
GX_Flush();
|
||||||
|
|
||||||
GX_CopyDisp (xfb[whichfb], GX_TRUE); // reset xfb
|
VIDEO_SetBlack(TRUE);
|
||||||
|
VIDEO_Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -457,10 +454,28 @@ UpdateScaling()
|
|||||||
static void
|
static void
|
||||||
UpdatePadsCB ()
|
UpdatePadsCB ()
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
WPAD_ScanPads();
|
WPAD_ScanPads();
|
||||||
#endif
|
#endif
|
||||||
PAD_ScanPads();
|
PAD_ScanPads();
|
||||||
|
|
||||||
|
for(int i=3; i >= 0; i--)
|
||||||
|
{
|
||||||
|
#ifdef HW_RVL
|
||||||
|
memcpy(&userInput[i].wpad, WPAD_Data(i), sizeof(WPADData));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
userInput[i].chan = i;
|
||||||
|
userInput[i].pad.btns_d = PAD_ButtonsDown(i);
|
||||||
|
userInput[i].pad.btns_u = PAD_ButtonsUp(i);
|
||||||
|
userInput[i].pad.btns_h = PAD_ButtonsHeld(i);
|
||||||
|
userInput[i].pad.stickX = PAD_StickX(i);
|
||||||
|
userInput[i].pad.stickY = PAD_StickY(i);
|
||||||
|
userInput[i].pad.substickX = PAD_SubStickX(i);
|
||||||
|
userInput[i].pad.substickY = PAD_SubStickY(i);
|
||||||
|
userInput[i].pad.triggerL = PAD_TriggerL(i);
|
||||||
|
userInput[i].pad.triggerR = PAD_TriggerR(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -523,8 +538,8 @@ InitGCVideo ()
|
|||||||
// configure VI
|
// configure VI
|
||||||
VIDEO_Configure (vmode);
|
VIDEO_Configure (vmode);
|
||||||
|
|
||||||
// always 480 lines
|
|
||||||
screenheight = vmode->xfbHeight;
|
screenheight = vmode->xfbHeight;
|
||||||
|
screenwidth = vmode->fbWidth;
|
||||||
|
|
||||||
// Allocate the video buffers
|
// Allocate the video buffers
|
||||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||||
@ -549,12 +564,10 @@ InitGCVideo ()
|
|||||||
VIDEO_WaitVSync ();
|
VIDEO_WaitVSync ();
|
||||||
|
|
||||||
copynow = GX_FALSE;
|
copynow = GX_FALSE;
|
||||||
|
|
||||||
StartGX ();
|
StartGX ();
|
||||||
|
|
||||||
draw_init ();
|
draw_init ();
|
||||||
|
|
||||||
InitVideoThread ();
|
InitVideoThread ();
|
||||||
|
|
||||||
// Finally, the video is up and ready for use :)
|
// Finally, the video is up and ready for use :)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,11 +638,17 @@ ResetVideo_Emu ()
|
|||||||
GX_SetViewport (0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1);
|
GX_SetViewport (0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1);
|
||||||
GX_SetDispCopyYScale ((f32) rmode->xfbHeight / (f32) rmode->efbHeight);
|
GX_SetDispCopyYScale ((f32) rmode->xfbHeight / (f32) rmode->efbHeight);
|
||||||
GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight);
|
GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
|
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||||
GX_SetDispCopyDst (rmode->fbWidth, rmode->xfbHeight);
|
GX_SetDispCopyDst (rmode->fbWidth, rmode->xfbHeight);
|
||||||
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // deflickering filter only for filtered mode
|
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // deflickering filter only for filtered mode
|
||||||
|
|
||||||
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||||
|
|
||||||
|
GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||||
|
GX_SetColorUpdate (GX_TRUE);
|
||||||
|
|
||||||
guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
|
guOrtho(p, rmode->efbHeight/2, -(rmode->efbHeight/2), -(rmode->fbWidth/2), rmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
||||||
|
|
||||||
@ -644,41 +663,6 @@ ResetVideo_Emu ()
|
|||||||
updateScaling = 5;
|
updateScaling = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* ResetVideo_Menu
|
|
||||||
*
|
|
||||||
* Reset the video/rendering mode for the menu
|
|
||||||
****************************************************************************/
|
|
||||||
void
|
|
||||||
ResetVideo_Menu ()
|
|
||||||
{
|
|
||||||
Mtx44 p;
|
|
||||||
|
|
||||||
VIDEO_Configure (vmode);
|
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], COLOR_BLACK);
|
|
||||||
VIDEO_Flush();
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
if (vmode->viTVMode & VI_NON_INTERLACE)
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
else
|
|
||||||
while (VIDEO_GetNextField())
|
|
||||||
VIDEO_WaitVSync();
|
|
||||||
|
|
||||||
GX_SetViewport (0, 0, vmode->fbWidth, vmode->efbHeight, 0, 1);
|
|
||||||
GX_SetDispCopyYScale ((f32) vmode->xfbHeight / (f32) vmode->efbHeight);
|
|
||||||
GX_SetScissor (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
GX_SetDispCopyDst (vmode->fbWidth, vmode->xfbHeight);
|
|
||||||
GX_SetCopyFilter (vmode->aa, vmode->sample_pattern, GX_TRUE, vmode->vfilter);
|
|
||||||
|
|
||||||
GX_SetFieldMode (vmode->field_rendering, ((vmode->viHeight == 2 * vmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
|
||||||
GX_SetPixelFmt (GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
|
||||||
|
|
||||||
guOrtho(p, vmode->efbHeight/2, -(vmode->efbHeight/2), -(vmode->fbWidth/2), vmode->fbWidth/2, 10, 1000); // matrix, t, b, l, r, n, f
|
|
||||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* RenderFrame
|
* RenderFrame
|
||||||
*
|
*
|
||||||
@ -798,22 +782,211 @@ zoom_reset ()
|
|||||||
updateScaling = 5; // update video
|
updateScaling = 5; // update video
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/****************************************************************************
|
||||||
clearscreen ()
|
* TakeScreenshot
|
||||||
|
*
|
||||||
|
* Copies the current screen into a GX texture
|
||||||
|
***************************************************************************/
|
||||||
|
void TakeScreenshot()
|
||||||
{
|
{
|
||||||
int colour = COLOR_BLACK;
|
int texSize = vmode->fbWidth * vmode->efbHeight * 4;
|
||||||
whichfb ^= 1;
|
|
||||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], colour);
|
if(gameScreenTex) free(gameScreenTex);
|
||||||
memcpy (xfb[whichfb], &bg, 1280 * 480);
|
gameScreenTex = (u8 *)memalign(32, texSize);
|
||||||
|
if(gameScreenTex == NULL) return;
|
||||||
|
GX_SetTexCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight);
|
||||||
|
GX_SetTexCopyDst(vmode->fbWidth, vmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
|
||||||
|
GX_CopyTex(gameScreenTex, GX_FALSE);
|
||||||
|
GX_PixModeSync();
|
||||||
|
DCFlushRange(gameScreenTex, texSize);
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
if(gameScreenTex2) free(gameScreenTex2);
|
||||||
|
gameScreenTex2 = (u8 *)memalign(32, texSize);
|
||||||
|
if(gameScreenTex2 == NULL) return;
|
||||||
|
GX_CopyTex(gameScreenTex2, GX_FALSE);
|
||||||
|
GX_PixModeSync();
|
||||||
|
DCFlushRange(gameScreenTex2, texSize);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* ResetVideo_Menu
|
||||||
|
*
|
||||||
|
* Reset the video/rendering mode for the menu
|
||||||
|
****************************************************************************/
|
||||||
void
|
void
|
||||||
showscreen ()
|
ResetVideo_Menu ()
|
||||||
{
|
{
|
||||||
copynow = GX_FALSE;
|
Mtx44 p;
|
||||||
VIDEO_SetNextFramebuffer (xfb[whichfb]);
|
f32 yscale;
|
||||||
VIDEO_Flush ();
|
u32 xfbHeight;
|
||||||
VIDEO_WaitVSync ();
|
|
||||||
|
VIDEO_Configure (vmode);
|
||||||
|
VIDEO_Flush();
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
if (vmode->viTVMode & VI_NON_INTERLACE)
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
else
|
||||||
|
while (VIDEO_GetNextField())
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
|
||||||
|
// clears the bg to color and clears the z buffer
|
||||||
|
GXColor background = {0, 0, 0, 255};
|
||||||
|
GX_SetCopyClear (background, 0x00ffffff);
|
||||||
|
|
||||||
|
yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight);
|
||||||
|
xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||||
|
GX_SetScissor(0,0,vmode->fbWidth,vmode->efbHeight);
|
||||||
|
GX_SetDispCopySrc(0,0,vmode->fbWidth,vmode->efbHeight);
|
||||||
|
GX_SetDispCopyDst(vmode->fbWidth,xfbHeight);
|
||||||
|
GX_SetCopyFilter(vmode->aa,vmode->sample_pattern,GX_TRUE,vmode->vfilter);
|
||||||
|
GX_SetFieldMode(vmode->field_rendering,((vmode->viHeight==2*vmode->xfbHeight)?GX_ENABLE:GX_DISABLE));
|
||||||
|
|
||||||
|
if (vmode->aa)
|
||||||
|
GX_SetPixelFmt(GX_PF_RGB565_Z16, GX_ZC_LINEAR);
|
||||||
|
else
|
||||||
|
GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR);
|
||||||
|
|
||||||
|
// setup the vertex descriptor
|
||||||
|
// tells the flipper to expect direct data
|
||||||
|
GX_ClearVtxDesc();
|
||||||
|
GX_InvVtxCache ();
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
GX_SetVtxDesc(GX_VA_TEX0, GX_NONE);
|
||||||
|
GX_SetVtxDesc(GX_VA_POS, GX_DIRECT);
|
||||||
|
GX_SetVtxDesc (GX_VA_CLR0, GX_DIRECT);
|
||||||
|
|
||||||
|
GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
|
||||||
|
GX_SetVtxAttrFmt (GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBA8, 0);
|
||||||
|
GX_SetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_TEX_ST, GX_F32, 0);
|
||||||
|
GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE);
|
||||||
|
|
||||||
|
GX_SetNumChans(1);
|
||||||
|
GX_SetNumTexGens(1);
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
|
GX_SetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0);
|
||||||
|
GX_SetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY);
|
||||||
|
|
||||||
|
guMtxIdentity(GXmodelView2D);
|
||||||
|
guMtxTransApply (GXmodelView2D, GXmodelView2D, 0.0F, 0.0F, -50.0F);
|
||||||
|
GX_LoadPosMtxImm(GXmodelView2D,GX_PNMTX0);
|
||||||
|
|
||||||
|
guOrtho(p,0,479,0,639,0,300);
|
||||||
|
GX_LoadProjectionMtx(p, GX_ORTHOGRAPHIC);
|
||||||
|
|
||||||
|
GX_SetViewport(0,0,vmode->fbWidth,vmode->efbHeight,0,1);
|
||||||
|
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||||
|
GX_SetAlphaUpdate(GX_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_Render
|
||||||
|
*
|
||||||
|
* Renders everything current sent to GX, and flushes video
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_Render()
|
||||||
|
{
|
||||||
|
GX_DrawDone ();
|
||||||
|
|
||||||
|
whichfb ^= 1; // flip framebuffer
|
||||||
|
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||||
|
GX_SetColorUpdate(GX_TRUE);
|
||||||
|
GX_CopyDisp(xfb[whichfb],GX_TRUE);
|
||||||
|
VIDEO_SetNextFramebuffer(xfb[whichfb]);
|
||||||
|
VIDEO_Flush();
|
||||||
|
VIDEO_WaitVSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_DrawImg
|
||||||
|
*
|
||||||
|
* Draws the specified image on screen using GX
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[],
|
||||||
|
f32 degrees, f32 scaleX, f32 scaleY, u8 alpha)
|
||||||
|
{
|
||||||
|
if(data == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GXTexObj texObj;
|
||||||
|
|
||||||
|
GX_InitTexObj(&texObj, data, width,height, GX_TF_RGBA8,GX_CLAMP, GX_CLAMP,GX_FALSE);
|
||||||
|
GX_LoadTexObj(&texObj, GX_TEXMAP0);
|
||||||
|
GX_InvalidateTexAll();
|
||||||
|
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_MODULATE);
|
||||||
|
GX_SetVtxDesc (GX_VA_TEX0, GX_DIRECT);
|
||||||
|
|
||||||
|
Mtx m,m1,m2, mv;
|
||||||
|
width *=.5;
|
||||||
|
height*=.5;
|
||||||
|
guMtxIdentity (m1);
|
||||||
|
guMtxScaleApply(m1,m1,scaleX,scaleY,1.0);
|
||||||
|
Vector axis = (Vector) {0 , 0, 1 };
|
||||||
|
guMtxRotAxisDeg (m2, &axis, degrees);
|
||||||
|
guMtxConcat(m2,m1,m);
|
||||||
|
|
||||||
|
guMtxTransApply(m,m, xpos+width,ypos+height,0);
|
||||||
|
guMtxConcat (GXmodelView2D, m, mv);
|
||||||
|
GX_LoadPosMtxImm (mv, GX_PNMTX0);
|
||||||
|
|
||||||
|
GX_Begin(GX_QUADS, GX_VTXFMT0,4);
|
||||||
|
GX_Position3f32(-width, -height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(0, 0);
|
||||||
|
|
||||||
|
GX_Position3f32(width, -height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(1, 0);
|
||||||
|
|
||||||
|
GX_Position3f32(width, height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(1, 1);
|
||||||
|
|
||||||
|
GX_Position3f32(-width, height, 0);
|
||||||
|
GX_Color4u8(0xFF,0xFF,0xFF,alpha);
|
||||||
|
GX_TexCoord2f32(0, 1);
|
||||||
|
GX_End();
|
||||||
|
GX_LoadPosMtxImm (GXmodelView2D, GX_PNMTX0);
|
||||||
|
|
||||||
|
GX_SetTevOp (GX_TEVSTAGE0, GX_PASSCLR);
|
||||||
|
GX_SetVtxDesc (GX_VA_TEX0, GX_NONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Menu_DrawRectangle
|
||||||
|
*
|
||||||
|
* Draws a rectangle at the specified coordinates using GX
|
||||||
|
***************************************************************************/
|
||||||
|
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled)
|
||||||
|
{
|
||||||
|
u8 fmt;
|
||||||
|
long n;
|
||||||
|
int i;
|
||||||
|
f32 x2 = x+width;
|
||||||
|
f32 y2 = y+height;
|
||||||
|
Vector v[] = {{x,y,0.0f}, {x2,y,0.0f}, {x2,y2,0.0f}, {x,y2,0.0f}, {x,y,0.0f}};
|
||||||
|
|
||||||
|
if(!filled)
|
||||||
|
{
|
||||||
|
fmt = GX_LINESTRIP;
|
||||||
|
n = 5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fmt = GX_TRIANGLEFAN;
|
||||||
|
n = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
GX_Begin(fmt, GX_VTXFMT0, n);
|
||||||
|
for(i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
GX_Position3f32(v[i].x, v[i].y, v[i].z);
|
||||||
|
GX_Color4u8(color.r, color.g, color.b, color.a);
|
||||||
|
}
|
||||||
|
GX_End();
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* gcvideo.h
|
* gcvideo.h
|
||||||
*
|
*
|
||||||
@ -12,17 +12,6 @@
|
|||||||
#ifndef _GCVIDEO_H_
|
#ifndef _GCVIDEO_H_
|
||||||
#define _GCVIDEO_H_
|
#define _GCVIDEO_H_
|
||||||
|
|
||||||
void clearscreen ();
|
|
||||||
void showscreen ();
|
|
||||||
void InitGCVideo ();
|
|
||||||
void ResetVideo_Emu ();
|
|
||||||
void ResetVideo_Menu ();
|
|
||||||
void RenderFrame(unsigned char *XBuf);
|
|
||||||
void setFrameTimer();
|
|
||||||
void zoom (float speed);
|
|
||||||
void zoom_reset ();
|
|
||||||
void SetPalette();
|
|
||||||
|
|
||||||
// color palettes
|
// color palettes
|
||||||
#define MAXPAL 12
|
#define MAXPAL 12
|
||||||
|
|
||||||
@ -31,6 +20,24 @@ struct st_palettes {
|
|||||||
unsigned int data[64];
|
unsigned int data[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void InitGCVideo ();
|
||||||
|
void StopGX();
|
||||||
|
void ResetVideo_Emu ();
|
||||||
|
void RenderFrame(unsigned char *XBuf);
|
||||||
|
void setFrameTimer();
|
||||||
|
void zoom (float speed);
|
||||||
|
void zoom_reset ();
|
||||||
|
void SetPalette();
|
||||||
|
void ResetVideo_Menu ();
|
||||||
|
void TakeScreenshot();
|
||||||
|
void Menu_Render ();
|
||||||
|
void Menu_DrawImg(f32 xpos, f32 ypos, u16 width, u16 height, u8 data[], f32 degrees, f32 scaleX, f32 scaleY, u8 alphaF );
|
||||||
|
void Menu_DrawRectangle(f32 x, f32 y, f32 width, f32 height, GXColor color, u8 filled);
|
||||||
|
|
||||||
|
extern int screenheight;
|
||||||
|
extern int screenwidth;
|
||||||
|
extern u8 * gameScreenTex;
|
||||||
|
extern u8 * gameScreenTex2;
|
||||||
extern struct st_palettes palettes[];
|
extern struct st_palettes palettes[];
|
||||||
extern int FDSSwitchRequested;
|
extern int FDSSwitchRequested;
|
||||||
extern bool progressive;
|
extern bool progressive;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
@ -19,14 +20,15 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <asndlib.h>
|
#include <asndlib.h>
|
||||||
#include "pngu/pngu.h"
|
#include "pngu/pngu.h"
|
||||||
#include "FreeTypeGX.h"
|
|
||||||
#include "snes9xGX.h"
|
#include "../FreeTypeGX.h"
|
||||||
#include "video.h"
|
#include "../fceugx.h"
|
||||||
#include "input.h"
|
#include "../gcvideo.h"
|
||||||
#include "filelist.h"
|
#include "../pad.h"
|
||||||
#include "fileop.h"
|
#include "../filelist.h"
|
||||||
#include "menu.h"
|
#include "../fileop.h"
|
||||||
#include "oggplayer.h"
|
#include "../menu.h"
|
||||||
|
#include "../oggplayer.h"
|
||||||
|
|
||||||
#define SCROLL_INITIAL_DELAY 20
|
#define SCROLL_INITIAL_DELAY 20
|
||||||
#define SCROLL_LOOP_DELAY 3
|
#define SCROLL_LOOP_DELAY 3
|
||||||
@ -78,6 +80,8 @@ enum
|
|||||||
#define EFFECT_SCALE 128
|
#define EFFECT_SCALE 128
|
||||||
#define EFFECT_COLOR_TRANSITION 256
|
#define EFFECT_COLOR_TRANSITION 256
|
||||||
|
|
||||||
|
extern FreeTypeGX *fontSystem;
|
||||||
|
|
||||||
class GuiSound
|
class GuiSound
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
@ -354,10 +355,10 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
|||||||
saveDate[i]->SetText(saves->date[listOffset+i]);
|
saveDate[i]->SetText(saves->date[listOffset+i]);
|
||||||
saveTime[i]->SetText(saves->time[listOffset+i]);
|
saveTime[i]->SetText(saves->time[listOffset+i]);
|
||||||
|
|
||||||
if(saves->type[listOffset+i] == FILE_SRAM)
|
if(saves->type[listOffset+i] == FILE_RAM)
|
||||||
sprintf(savetext, "SRAM");
|
sprintf(savetext, "RAM");
|
||||||
else
|
else
|
||||||
sprintf(savetext, "Snapshot");
|
sprintf(savetext, "State");
|
||||||
|
|
||||||
len = strlen(saves->filename[listOffset+i]);
|
len = strlen(saves->filename[listOffset+i]);
|
||||||
if(len > 10 &&
|
if(len > 10 &&
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
@ -9,8 +10,6 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "gui.h"
|
#include "gui.h"
|
||||||
#include "snes9xGX.h"
|
|
||||||
#include "filelist.h"
|
|
||||||
|
|
||||||
static int currentSize = 0;
|
static int currentSize = 0;
|
||||||
static int presetSize = 0;
|
static int presetSize = 0;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
* FCE Ultra 0.98.12
|
||||||
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric February 2009
|
* Tantric February 2009
|
||||||
*
|
*
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
static s32 tcp_socket(void)
|
static s32 tcp_socket(void)
|
||||||
|
@ -15,104 +15,136 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "menudraw.h"
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
|
#include "common.h"
|
||||||
|
#include "gcvideo.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "memcardop.h"
|
#include "preferences.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filesel.h"
|
#include "dvd.h"
|
||||||
|
#include "images/saveicon.h"
|
||||||
|
|
||||||
|
static u8 * SysArea = NULL;
|
||||||
|
static char savecomments[2][32];
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* CardFileExists
|
* MountMC
|
||||||
*
|
|
||||||
* Wrapper to search through the files on the card.
|
|
||||||
* Returns TRUE if found.
|
|
||||||
***************************************************************************/
|
|
||||||
static int
|
|
||||||
CardFileExists (char *filename, int slot)
|
|
||||||
{
|
|
||||||
card_dir CardDir;
|
|
||||||
int CardError;
|
|
||||||
|
|
||||||
CardError = CARD_FindFirst (slot, &CardDir, TRUE);
|
|
||||||
while (CardError != CARD_ERROR_NOFILE)
|
|
||||||
{
|
|
||||||
CardError = CARD_FindNext (&CardDir);
|
|
||||||
|
|
||||||
if (strcmp ((char *) CardDir.filename, filename) == 0)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* MountCard
|
|
||||||
*
|
*
|
||||||
* Mounts the memory card in the given slot.
|
* Mounts the memory card in the given slot.
|
||||||
* Returns the result of the last attempted CARD_Mount command.
|
* Returns the result of the last attempted CARD_Mount command.
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
static int MountCard(int cslot, bool silent, u8 * SysArea)
|
static int MountMC(int slot, bool silent)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int tries = 0;
|
int tries = 0;
|
||||||
|
|
||||||
|
// Initialize Card System
|
||||||
|
SysArea = (u8 *)memalign(32, CARD_WORKAREA);
|
||||||
|
memset (SysArea, 0, CARD_WORKAREA);
|
||||||
|
CARD_Init ("FCEU", "00");
|
||||||
|
|
||||||
// Mount the card
|
// Mount the card
|
||||||
while ( tries < 10 && ret != 0)
|
while(tries < 10 && ret != 0)
|
||||||
{
|
{
|
||||||
EXI_ProbeReset ();
|
EXI_ProbeReset();
|
||||||
ret = CARD_Mount (cslot, &SysArea, NULL);
|
ret = CARD_Mount (slot, SysArea, NULL);
|
||||||
VIDEO_WaitVSync ();
|
VIDEO_WaitVSync();
|
||||||
tries++;
|
tries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ret != 0 && !silent)
|
||||||
|
{
|
||||||
|
if (slot == CARD_SLOTA)
|
||||||
|
ErrorPrompt("Unable to mount Slot A Memory Card!");
|
||||||
|
else
|
||||||
|
ErrorPrompt("Unable to mount Slot B Memory Card!");
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* TestCard
|
* TestMC
|
||||||
*
|
*
|
||||||
* Checks to see if a card is in the card slot specified
|
* Checks to see if a card is in the card slot specified
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
bool TestCard(int slot, bool silent)
|
bool TestMC(int slot, bool silent)
|
||||||
{
|
{
|
||||||
// Memory Cards do not work in Wii mode - disable
|
// Memory Cards do not work in Wii mode - disable
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
bool ret = false;
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("FCEU", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Try to mount the card
|
||||||
if (MountCard(slot, silent, (u8 *)SysArea) == 0)
|
if (MountMC(slot, silent) == 0)
|
||||||
{
|
{
|
||||||
// Mount successful!
|
// Mount successful!
|
||||||
if(!silent)
|
|
||||||
{
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Mounted Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Mounted Slot B Memory Card!");
|
|
||||||
}
|
|
||||||
CARD_Unmount (slot);
|
CARD_Unmount (slot);
|
||||||
return true;
|
ret = true;
|
||||||
}
|
}
|
||||||
else
|
free(SysArea);
|
||||||
{
|
return ret;
|
||||||
if(!silent)
|
}
|
||||||
{
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
/****************************************************************************
|
||||||
|
* ParseMCDirectory
|
||||||
|
*
|
||||||
|
* Parses a list of all files on the specified memory card
|
||||||
|
***************************************************************************/
|
||||||
|
int
|
||||||
|
ParseMCDirectory (int slot)
|
||||||
|
{
|
||||||
|
card_dir CardDir;
|
||||||
|
int CardError;
|
||||||
|
int entryNum = 0;
|
||||||
|
char tmpname[MAXPATHLEN];
|
||||||
|
|
||||||
|
// Try to mount the card
|
||||||
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
|
|
||||||
|
if (CardError == 0)
|
||||||
|
{
|
||||||
|
CardError = CARD_FindFirst (slot, &CardDir, TRUE);
|
||||||
|
while (CardError != CARD_ERROR_NOFILE)
|
||||||
|
{
|
||||||
|
BROWSERENTRY * newBrowserList = (BROWSERENTRY *)realloc(browserList, (entryNum+1) * sizeof(BROWSERENTRY));
|
||||||
|
|
||||||
|
if(!newBrowserList) // failed to allocate required memory
|
||||||
|
{
|
||||||
|
ResetBrowser();
|
||||||
|
ErrorPrompt("Out of memory: too many files!");
|
||||||
|
entryNum = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
browserList = newBrowserList;
|
||||||
|
}
|
||||||
|
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||||
|
|
||||||
|
strncpy(browserList[entryNum].filename, (char *)CardDir.filename, MAXJOLIET);
|
||||||
|
StripExt(tmpname, (char *)CardDir.filename); // hide file extension
|
||||||
|
strncpy(browserList[entryNum].displayname, tmpname, MAXDISPLAY); // crop name for display
|
||||||
|
browserList[entryNum].length = CardDir.filelen;
|
||||||
|
|
||||||
|
entryNum++;
|
||||||
|
|
||||||
|
CardError = CARD_FindNext (&CardDir);
|
||||||
|
}
|
||||||
|
CARD_Unmount(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the file list
|
||||||
|
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
|
browser.numEntries = entryNum;
|
||||||
|
return entryNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -122,37 +154,27 @@ static int
|
|||||||
VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
||||||
{
|
{
|
||||||
card_file CardFile;
|
card_file CardFile;
|
||||||
unsigned char verifbuffer[65536] ATTRIBUTE_ALIGN (32);
|
unsigned char verifybuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||||
int CardError;
|
int CardError;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int SectorSize;
|
unsigned int SectorSize;
|
||||||
char msg[80];
|
int bytesleft = 0;
|
||||||
int bytesleft = 0;
|
int bytesread = 0;
|
||||||
int bytesread = 0;
|
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
memset (verifybuffer, 0, 65536);
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("FCEU", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Get Sector Size
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
if (CardError == 0)
|
memset (&CardFile, 0, sizeof (CardFile));
|
||||||
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Unable to open file!");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
/*** Get Sector Size ***/
|
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
|
||||||
|
|
||||||
if (!CardFileExists (filename, slot))
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to open file for verify!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (&CardFile, 0, sizeof (CardFile));
|
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
|
||||||
|
|
||||||
blocks = CardFile.len;
|
blocks = CardFile.len;
|
||||||
|
|
||||||
if (blocks < SectorSize)
|
if (blocks < SectorSize)
|
||||||
@ -161,41 +183,29 @@ VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
|||||||
if (blocks % SectorSize)
|
if (blocks % SectorSize)
|
||||||
blocks += SectorSize;
|
blocks += SectorSize;
|
||||||
|
|
||||||
if (blocks > (unsigned int)datasize)
|
if (blocks > (unsigned int)datasize)
|
||||||
blocks = datasize;
|
blocks = datasize;
|
||||||
|
|
||||||
memset (verifbuffer, 0, 65536);
|
|
||||||
bytesleft = blocks;
|
bytesleft = blocks;
|
||||||
bytesread = 0;
|
bytesread = 0;
|
||||||
while (bytesleft > 0)
|
while (bytesleft > 0)
|
||||||
{
|
{
|
||||||
CARD_Read (&CardFile, verifbuffer, SectorSize, bytesread);
|
CardError = CARD_Read (&CardFile, verifybuffer, SectorSize, bytesread);
|
||||||
if ( memcmp (buf + bytesread, verifbuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
if (CardError || memcmp (buf + bytesread, verifybuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||||
{
|
{
|
||||||
CARD_Close (&CardFile);
|
bytesread = 0;
|
||||||
CARD_Unmount (slot);
|
ErrorPrompt("File integrity could not be verified!");
|
||||||
WaitPrompt("File did not verify!");
|
break;
|
||||||
return 0;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bytesleft -= SectorSize;
|
bytesleft -= SectorSize;
|
||||||
bytesread += SectorSize;
|
bytesread += SectorSize;
|
||||||
|
ShowProgress ("Verifying...", bytesread, blocks);
|
||||||
sprintf (msg, "Verified %d of %d bytes", bytesread, blocks);
|
|
||||||
ShowProgress (msg, bytesread, blocks);
|
|
||||||
}
|
}
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
CARD_Unmount (slot);
|
CancelAction();
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
else
|
return bytesread;
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -209,59 +219,63 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
|||||||
int CardError;
|
int CardError;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int SectorSize;
|
unsigned int SectorSize;
|
||||||
int bytesleft = 0;
|
int bytesleft = 0;
|
||||||
int bytesread = 0;
|
int bytesread = 0;
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
// Try to mount the card
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
|
||||||
CARD_Init ("FCEU", "00");
|
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
|
||||||
|
|
||||||
if (CardError == 0)
|
if (CardError == 0)
|
||||||
{
|
{
|
||||||
/*** Get Sector Size ***/
|
// Get Sector Size
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
if (!CardFileExists (filename, slot))
|
|
||||||
{
|
|
||||||
if (!silent)
|
|
||||||
WaitPrompt("Unable to open file");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset (&CardFile, 0, sizeof (CardFile));
|
memset (&CardFile, 0, sizeof (CardFile));
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
|
|
||||||
blocks = CardFile.len;
|
if(CardError)
|
||||||
|
|
||||||
if (blocks < SectorSize)
|
|
||||||
blocks = SectorSize;
|
|
||||||
|
|
||||||
if (blocks % SectorSize)
|
|
||||||
blocks += SectorSize;
|
|
||||||
|
|
||||||
memset (buf, 0, 0x22000);
|
|
||||||
|
|
||||||
bytesleft = blocks;
|
|
||||||
bytesread = 0;
|
|
||||||
while (bytesleft > 0)
|
|
||||||
{
|
{
|
||||||
CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
if(!silent)
|
||||||
bytesleft -= SectorSize;
|
ErrorPrompt("Unable to open file!");
|
||||||
bytesread += SectorSize;
|
|
||||||
}
|
}
|
||||||
CARD_Close (&CardFile);
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
else
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
{
|
||||||
|
blocks = CardFile.len;
|
||||||
|
|
||||||
|
if (blocks < SectorSize)
|
||||||
|
blocks = SectorSize;
|
||||||
|
|
||||||
|
if (blocks % SectorSize)
|
||||||
|
blocks += SectorSize;
|
||||||
|
|
||||||
|
bytesleft = blocks;
|
||||||
|
bytesread = 0;
|
||||||
|
while (bytesleft > 0)
|
||||||
|
{
|
||||||
|
CardError = CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||||
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error loading file!");
|
||||||
|
bytesread = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytesleft -= SectorSize;
|
||||||
|
bytesread += SectorSize;
|
||||||
|
ShowProgress ("Loading...", bytesread, blocks);
|
||||||
|
}
|
||||||
|
CARD_Close (&CardFile);
|
||||||
|
CancelAction();
|
||||||
|
}
|
||||||
|
CARD_Unmount(slot);
|
||||||
|
}
|
||||||
|
|
||||||
|
// discard save icon and comments
|
||||||
|
memmove(buf, buf+sizeof(saveicon)+64, bytesread);
|
||||||
|
bytesread -= (sizeof(saveicon)+64);
|
||||||
|
|
||||||
|
free(SysArea);
|
||||||
return bytesread;
|
return bytesread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,99 +291,59 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
|||||||
int CardError;
|
int CardError;
|
||||||
unsigned int blocks;
|
unsigned int blocks;
|
||||||
unsigned int SectorSize;
|
unsigned int SectorSize;
|
||||||
char msg[80];
|
int byteswritten = 0;
|
||||||
|
int bytesleft = 0;
|
||||||
|
|
||||||
if(datasize <= 0)
|
if(datasize <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*** Initialize Card System ***/
|
// add save icon and comments
|
||||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
memmove(buf+sizeof(saveicon)+64, buf, datasize);
|
||||||
memset (SysArea, 0, CARD_WORKAREA);
|
memcpy(buf, saveicon, sizeof(saveicon));
|
||||||
CARD_Init ("FCEU", "00");
|
memcpy(buf+sizeof(saveicon), savecomments, 64);
|
||||||
|
datasize += (sizeof(saveicon)+64);
|
||||||
|
|
||||||
/*** Try to mount the card ***/
|
// Try to mount the card
|
||||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
CardError = MountMC(slot, NOTSILENT);
|
||||||
|
|
||||||
if (CardError == 0)
|
if (CardError == 0)
|
||||||
{
|
{
|
||||||
/*** Get Sector Size ***/
|
// Get Sector Size
|
||||||
CARD_GetSectorSize (slot, &SectorSize);
|
CARD_GetSectorSize (slot, &SectorSize);
|
||||||
|
|
||||||
/*** Calculate number of blocks required ***/
|
// Calculate number of blocks required
|
||||||
blocks = (datasize / SectorSize) * SectorSize;
|
blocks = (datasize / SectorSize) * SectorSize;
|
||||||
if (datasize % SectorSize)
|
if (datasize % SectorSize)
|
||||||
blocks += SectorSize;
|
blocks += SectorSize;
|
||||||
|
|
||||||
/*** Does this file exist ? ***/
|
// Delete existing file (if present)
|
||||||
if (CardFileExists (filename, slot))
|
memset(&CardStatus, 0, sizeof(card_stat));
|
||||||
|
CardError = CARD_Open (slot, filename, &CardFile);
|
||||||
|
|
||||||
|
if(CardError == 0)
|
||||||
{
|
{
|
||||||
/*** Try to open the file ***/
|
CARD_Close (&CardFile);
|
||||||
CardError = CARD_Open (slot, filename, &CardFile);
|
CardError = CARD_Delete(slot, filename);
|
||||||
if (CardError)
|
if (CardError)
|
||||||
{
|
{
|
||||||
CARD_Unmount (slot);
|
ErrorPrompt("Unable to delete existing file!");
|
||||||
WaitPrompt("Unable to open card file!");
|
goto done;
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
|
|
||||||
{
|
|
||||||
CARD_Close (&CardFile);
|
|
||||||
|
|
||||||
/*** Try to create temp file to check available space ***/
|
|
||||||
CardError = CARD_Create (slot, "TEMPFILESNES9XGX201", blocks, &CardFile);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Not enough space to update file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Delete the temporary file ***/
|
|
||||||
CARD_Close (&CardFile);
|
|
||||||
CardError = CARD_Delete(slot, "TEMPFILESNES9XGX201");
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to delete temporary file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Delete the existing shorter file ***/
|
|
||||||
CardError = CARD_Delete(slot, filename);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to delete existing file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Create new, longer file ***/
|
|
||||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
WaitPrompt("Unable to create updated card file!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else /*** no file existed, create new one ***/
|
|
||||||
{
|
|
||||||
/*** Create new file ***/
|
|
||||||
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
|
||||||
if (CardError)
|
|
||||||
{
|
|
||||||
CARD_Unmount (slot);
|
|
||||||
if ( CardError == CARD_ERROR_INSSPACE )
|
|
||||||
WaitPrompt("Not enough space to create file!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to create card file!");
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Now, have an open file handle, ready to send out the data ***/
|
// Create new file
|
||||||
|
memset(&CardStatus, 0, sizeof(card_stat));
|
||||||
|
CardError = CARD_Create (slot, filename, blocks, &CardFile);
|
||||||
|
if (CardError)
|
||||||
|
{
|
||||||
|
if (CardError == CARD_ERROR_INSSPACE)
|
||||||
|
ErrorPrompt("Insufficient space to create file!");
|
||||||
|
else
|
||||||
|
ErrorPrompt("Unable to create card file!");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now, have an open file handle, ready to send out the data
|
||||||
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
||||||
CardStatus.icon_addr = 0x0;
|
CardStatus.icon_addr = 0x0;
|
||||||
CardStatus.icon_fmt = 2;
|
CardStatus.icon_fmt = 2;
|
||||||
@ -377,40 +351,43 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
|||||||
CardStatus.comment_addr = 2048;
|
CardStatus.comment_addr = 2048;
|
||||||
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
||||||
|
|
||||||
int byteswritten = 0;
|
bytesleft = blocks;
|
||||||
int bytesleft = blocks;
|
|
||||||
while (bytesleft > 0)
|
while (bytesleft > 0)
|
||||||
{
|
{
|
||||||
CardError =
|
CardError =
|
||||||
CARD_Write (&CardFile, buf + byteswritten,
|
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
|
||||||
SectorSize, byteswritten);
|
|
||||||
|
if(CardError)
|
||||||
|
{
|
||||||
|
ErrorPrompt("Error writing file!");
|
||||||
|
byteswritten = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
bytesleft -= SectorSize;
|
bytesleft -= SectorSize;
|
||||||
byteswritten += SectorSize;
|
byteswritten += SectorSize;
|
||||||
|
|
||||||
sprintf (msg, "Wrote %d of %d bytes", byteswritten, blocks);
|
ShowProgress ("Saving...", byteswritten, blocks);
|
||||||
ShowProgress (msg, byteswritten, blocks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CARD_Close (&CardFile);
|
CARD_Close (&CardFile);
|
||||||
CARD_Unmount (slot);
|
CancelAction();
|
||||||
|
|
||||||
if ( GCSettings.VerifySaves )
|
if (byteswritten > 0 && GCSettings.VerifySaves)
|
||||||
{
|
{
|
||||||
/*** Verify the written file, but only up to the length we wrote
|
// Verify the written file
|
||||||
because the file could be longer due to past writes ***/
|
if (!VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||||
if ( VerifyMCFile (buf, slot, filename, byteswritten) )
|
byteswritten = 0;
|
||||||
return byteswritten;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else
|
done:
|
||||||
return byteswritten;
|
CARD_Unmount (slot);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (slot == CARD_SLOTA)
|
|
||||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
|
||||||
else
|
|
||||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
|
||||||
|
|
||||||
return 0;
|
free(SysArea);
|
||||||
|
return byteswritten;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetMCSaveComments(char comments[2][32])
|
||||||
|
{
|
||||||
|
memcpy(savecomments, comments, 64);
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,20 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* memcardop.h
|
* memcardop.h
|
||||||
*
|
*
|
||||||
* Memory Card routines
|
* Memory Card routines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _MEMCARDOP_H_
|
#ifndef _MEMCARDOP_
|
||||||
#define _MEMCARDOP_H_
|
#define _MEMCARDOP_
|
||||||
|
|
||||||
|
int ParseMCDirectory (int slot);
|
||||||
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
|
int LoadMCFile (char *buf, int slot, char *filename, bool silent);
|
||||||
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
|
int SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent);
|
||||||
bool TestCard(int slot, bool silent);
|
bool TestMC(int slot, bool silent);
|
||||||
|
void SetMCSaveComments(char comments[2][32]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
3800
source/ngc/menu.cpp
3800
source/ngc/menu.cpp
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* menu.h
|
* menu.h
|
||||||
*
|
*
|
||||||
@ -10,9 +10,36 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef _NGCMENU_
|
#ifndef _NGCMENU_
|
||||||
|
|
||||||
#define _NGCMENU_
|
#define _NGCMENU_
|
||||||
|
|
||||||
void MainMenu (int selectedMenu);
|
#include <ogcsys.h>
|
||||||
|
|
||||||
|
void InitGUIThreads();
|
||||||
|
void MainMenu (int menuitem);
|
||||||
|
void ErrorPrompt(const char * msg);
|
||||||
|
int ErrorPromptRetry(const char * msg);
|
||||||
|
void InfoPrompt(const char * msg);
|
||||||
|
void ShowAction (const char *msg);
|
||||||
|
void CancelAction();
|
||||||
|
void ShowProgress (const char *msg, int done, int total);
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MENU_EXIT = -1,
|
||||||
|
MENU_NONE,
|
||||||
|
MENU_SETTINGS,
|
||||||
|
MENU_SETTINGS_MAPPINGS,
|
||||||
|
MENU_SETTINGS_MAPPINGS_CTRL,
|
||||||
|
MENU_SETTINGS_MAPPINGS_MAP,
|
||||||
|
MENU_SETTINGS_VIDEO,
|
||||||
|
MENU_SETTINGS_FILE,
|
||||||
|
MENU_SETTINGS_MENU,
|
||||||
|
MENU_SETTINGS_NETWORK,
|
||||||
|
MENU_GAMESELECTION,
|
||||||
|
MENU_GAME,
|
||||||
|
MENU_GAME_SAVE,
|
||||||
|
MENU_GAME_LOAD,
|
||||||
|
MENU_GAME_CHEATS
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "miniunz.h"
|
#include "miniunz.h"
|
||||||
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "http.h"
|
#include "http.h"
|
||||||
|
|
||||||
@ -146,12 +146,12 @@ bool DownloadUpdate()
|
|||||||
if(unzipResult)
|
if(unzipResult)
|
||||||
{
|
{
|
||||||
result = true;
|
result = true;
|
||||||
WaitPrompt("Update successful!");
|
InfoPrompt("Update successful!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = false;
|
result = false;
|
||||||
WaitPrompt("Update failed!");
|
InfoPrompt("Update failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFound = false; // updating is finished (successful or not!)
|
updateFound = false; // updating is finished (successful or not!)
|
||||||
@ -193,7 +193,7 @@ void InitializeNetwork(bool silent)
|
|||||||
{
|
{
|
||||||
char msg[150];
|
char msg[150];
|
||||||
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||||
WaitPrompt(msg);
|
ErrorPrompt(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ void InitializeNetwork(bool silent)
|
|||||||
void CloseShare()
|
void CloseShare()
|
||||||
{
|
{
|
||||||
if(networkShareInit)
|
if(networkShareInit)
|
||||||
smbClose();
|
smbClose("smb");
|
||||||
networkShareInit = false;
|
networkShareInit = false;
|
||||||
networkInit = false; // trigger a network reinit
|
networkInit = false; // trigger a network reinit
|
||||||
}
|
}
|
||||||
@ -242,7 +242,7 @@ ConnectShare (bool silent)
|
|||||||
sprintf(msg, "Share IP is blank.");
|
sprintf(msg, "Share IP is blank.");
|
||||||
|
|
||||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||||
WaitPrompt(msg2);
|
ErrorPrompt(msg2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -268,7 +268,7 @@ ConnectShare (bool silent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!networkShareInit && !silent)
|
if(!networkShareInit && !silent)
|
||||||
WaitPrompt ("Failed to connect to network share.");
|
ErrorPrompt ("Failed to connect to network share.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return networkShareInit;
|
return networkShareInit;
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <wiiuse/wpad.h>
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
@ -18,7 +17,10 @@
|
|||||||
#include "gcaudio.h"
|
#include "gcaudio.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "gcvideo.h"
|
#include "gcvideo.h"
|
||||||
#include "filesel.h"
|
#include "filebrowser.h"
|
||||||
|
#include "button_mapping.h"
|
||||||
|
#include "gui/gui.h"
|
||||||
|
#include "fceuload.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "driver.h"
|
#include "driver.h"
|
||||||
@ -27,7 +29,12 @@ extern "C" {
|
|||||||
extern INPUTC *FCEU_InitZapper(int w);
|
extern INPUTC *FCEU_InitZapper(int w);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern bool romLoaded;
|
int rumbleRequest[4] = {0,0,0,0};
|
||||||
|
GuiTrigger userInput[4];
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
|
static int rumbleCount[4] = {0,0,0,0};
|
||||||
|
#endif
|
||||||
|
|
||||||
static uint32 JSReturn = 0;
|
static uint32 JSReturn = 0;
|
||||||
void *InputDPR;
|
void *InputDPR;
|
||||||
@ -35,11 +42,9 @@ void *InputDPR;
|
|||||||
static INPUTC *zapperdata[2];
|
static INPUTC *zapperdata[2];
|
||||||
static unsigned int myzappers[2][3];
|
static unsigned int myzappers[2][3];
|
||||||
|
|
||||||
unsigned int nespadmap[11]; // Original NES controller buttons
|
u32 nespadmap[11]; // Original NES controller buttons
|
||||||
unsigned int gcpadmap[11]; // Gamecube controller Padmap
|
u32 zapperpadmap[11]; // Original NES Zapper controller buttons
|
||||||
unsigned int wmpadmap[11]; // Wiimote Padmap
|
u32 btnmap[2][4][12]; // button mapping
|
||||||
unsigned int ccpadmap[11]; // Classic Controller Padmap
|
|
||||||
unsigned int ncpadmap[11]; // Nunchuk + wiimote Padmap
|
|
||||||
|
|
||||||
void ResetControls()
|
void ResetControls()
|
||||||
{
|
{
|
||||||
@ -62,101 +67,151 @@ void ResetControls()
|
|||||||
|
|
||||||
/*** Gamecube controller Padmap ***/
|
/*** Gamecube controller Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
gcpadmap[i++] = PAD_BUTTON_B;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_B;
|
||||||
gcpadmap[i++] = PAD_BUTTON_A;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_A;
|
||||||
gcpadmap[i++] = PAD_BUTTON_Y;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_Y;
|
||||||
gcpadmap[i++] = PAD_BUTTON_X;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_X;
|
||||||
gcpadmap[i++] = PAD_TRIGGER_Z;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_TRIGGER_Z;
|
||||||
gcpadmap[i++] = PAD_BUTTON_START;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_START;
|
||||||
gcpadmap[i++] = PAD_BUTTON_UP;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_UP;
|
||||||
gcpadmap[i++] = PAD_BUTTON_DOWN;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN;
|
||||||
gcpadmap[i++] = PAD_BUTTON_LEFT;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT;
|
||||||
gcpadmap[i++] = PAD_BUTTON_RIGHT;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT;
|
||||||
gcpadmap[i++] = PAD_TRIGGER_L;
|
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_TRIGGER_L;
|
||||||
|
|
||||||
/*** Wiimote Padmap ***/
|
/*** Wiimote Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_1;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_2;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2;
|
||||||
wmpadmap[i++] = 0;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = 0;
|
||||||
wmpadmap[i++] = 0;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = 0;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_MINUS;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_PLUS;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_RIGHT;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_LEFT;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_UP;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_DOWN;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN;
|
||||||
wmpadmap[i++] = WPAD_BUTTON_A;
|
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A;
|
||||||
|
|
||||||
/*** Classic Controller Padmap ***/
|
/*** Classic Controller Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_Y;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_B;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_X;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_X;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_A;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_A;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_UP;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||||
|
|
||||||
/*** Nunchuk + wiimote Padmap ***/
|
/*** Nunchuk + wiimote Padmap ***/
|
||||||
i=0;
|
i=0;
|
||||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_C;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_Z;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||||
ncpadmap[i++] = 0;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = 0;
|
||||||
ncpadmap[i++] = 0;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = 0;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_MINUS;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_PLUS;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_UP;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_DOWN;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_LEFT;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_RIGHT;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT;
|
||||||
ncpadmap[i++] = WPAD_BUTTON_A;
|
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_A;
|
||||||
|
|
||||||
|
/*** Zapper : GC controller button mapping ***/
|
||||||
|
i=0;
|
||||||
|
btnmap[CTRL_ZAPPER][CTRLR_GCPAD][i++] = PAD_BUTTON_A; // shoot
|
||||||
|
btnmap[CTRL_ZAPPER][CTRLR_GCPAD][i++] = PAD_BUTTON_B; // insert coin
|
||||||
|
|
||||||
|
/*** Zapper : wiimote button mapping ***/
|
||||||
|
i=0;
|
||||||
|
btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_B; // shoot
|
||||||
|
btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A; // insert coin
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* SetControllers
|
||||||
|
***************************************************************************/
|
||||||
|
void SetControllers()
|
||||||
|
{
|
||||||
|
if(!romLoaded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(GCSettings.Controller == CTRL_PAD4)
|
||||||
|
FCEUI_DisableFourScore(false);
|
||||||
|
else
|
||||||
|
FCEUI_DisableFourScore(true);
|
||||||
|
|
||||||
|
// set defaults
|
||||||
|
zapperdata[0]=NULL;
|
||||||
|
zapperdata[1]=NULL;
|
||||||
|
myzappers[0][0]=myzappers[1][0]=128;
|
||||||
|
myzappers[0][1]=myzappers[1][1]=120;
|
||||||
|
myzappers[0][2]=myzappers[1][2]=0;
|
||||||
|
|
||||||
|
// Default ports back to gamepad
|
||||||
|
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
||||||
|
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
||||||
|
|
||||||
|
if(GCSettings.Controller == CTRL_ZAPPER)
|
||||||
|
{
|
||||||
|
// enable Zapper
|
||||||
|
int z = 1;
|
||||||
|
zapperdata[z] = FCEU_InitZapper(z);
|
||||||
|
FCEUI_SetInput(z, SI_ZAPPER, myzappers[z], 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Initialise Pads
|
* Initialise Pads
|
||||||
****************************************************************************/
|
***************************************************************************/
|
||||||
void InitialisePads()
|
void InitialisePads()
|
||||||
{
|
{
|
||||||
InputDPR = &JSReturn;
|
InputDPR = &JSReturn;
|
||||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
||||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
||||||
|
SetControllers();
|
||||||
ToggleFourScore(GCSettings.FourScore, true);
|
|
||||||
ToggleZapper(GCSettings.zapper, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToggleFourScore(int set, bool loaded)
|
#ifdef HW_RVL
|
||||||
{
|
|
||||||
if(loaded)
|
|
||||||
FCEUI_DisableFourScore(set);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToggleZapper(int set, bool loaded)
|
/****************************************************************************
|
||||||
|
* ShutoffRumble
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
void ShutoffRumble()
|
||||||
{
|
{
|
||||||
if(loaded)
|
for(int i=0;i<4;i++)
|
||||||
{
|
{
|
||||||
// set defaults
|
WPAD_Rumble(i, 0);
|
||||||
zapperdata[0]=NULL;
|
rumbleCount[i] = 0;
|
||||||
zapperdata[1]=NULL;
|
}
|
||||||
myzappers[0][0]=myzappers[1][0]=128;
|
}
|
||||||
myzappers[0][1]=myzappers[1][1]=120;
|
|
||||||
myzappers[0][2]=myzappers[1][2]=0;
|
|
||||||
|
|
||||||
// Default ports back to gamepad
|
/****************************************************************************
|
||||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
* DoRumble
|
||||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
***************************************************************************/
|
||||||
|
|
||||||
if(set)
|
void DoRumble(int i)
|
||||||
{
|
{
|
||||||
// enable Zapper
|
if(rumbleRequest[i] && rumbleCount[i] < 3)
|
||||||
zapperdata[set-1] = FCEU_InitZapper(set-1);
|
{
|
||||||
FCEUI_SetInput(set-1, SI_ZAPPER, myzappers[set-1], 1);
|
WPAD_Rumble(i, 1); // rumble on
|
||||||
}
|
rumbleCount[i]++;
|
||||||
|
}
|
||||||
|
else if(rumbleRequest[i])
|
||||||
|
{
|
||||||
|
rumbleCount[i] = 12;
|
||||||
|
rumbleRequest[i] = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(rumbleCount[i])
|
||||||
|
rumbleCount[i]--;
|
||||||
|
WPAD_Rumble(i, 0); // rumble off
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +298,7 @@ s8 WPAD_StickY(u8 chan, u8 right)
|
|||||||
|
|
||||||
return (s8)(val * 128.0f);
|
return (s8)(val * 128.0f);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// hold zapper cursor positions
|
// hold zapper cursor positions
|
||||||
static int pos_x = 0;
|
static int pos_x = 0;
|
||||||
@ -413,16 +469,16 @@ static unsigned char DecodeJoy( unsigned short pad )
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < MAXJP; i++)
|
for (i = 0; i < MAXJP; i++)
|
||||||
{
|
{
|
||||||
if ( (jp & gcpadmap[i]) // gamecube controller
|
if ( (jp & btnmap[CTRL_PAD][CTRLR_GCPAD][i]) // gamecube controller
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|| ( (exp_type == WPAD_EXP_NONE) && (wp & wmpadmap[i]) ) // wiimote
|
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) ) // wiimote
|
||||||
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) ) // classic controller
|
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // classic controller
|
||||||
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) ) // nunchuk + wiimote
|
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// if zapper is on, ignore all buttons except START and SELECT
|
// if zapper is on, ignore all buttons except START and SELECT
|
||||||
if(!GCSettings.zapper || nespadmap[i] == JOY_START || nespadmap[i] == JOY_SELECT)
|
if(GCSettings.Controller != CTRL_ZAPPER || nespadmap[i] == JOY_START || nespadmap[i] == JOY_SELECT)
|
||||||
{
|
{
|
||||||
if(nespadmap[i] == RAPID_A)
|
if(nespadmap[i] == RAPID_A)
|
||||||
{
|
{
|
||||||
@ -471,18 +527,16 @@ static unsigned char DecodeJoy( unsigned short pad )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// zapper enabled
|
// zapper enabled
|
||||||
if(GCSettings.zapper)
|
if(GCSettings.Controller == CTRL_ZAPPER)
|
||||||
{
|
{
|
||||||
int z = GCSettings.zapper-1; // NES port # (0 or 1)
|
int z = 1; // NES port # (0 or 1)
|
||||||
|
|
||||||
myzappers[z][2] = 0; // reset trigger to not pressed
|
myzappers[z][2] = 0; // reset trigger to not pressed
|
||||||
|
|
||||||
// is trigger pressed?
|
// is trigger pressed?
|
||||||
if ( (jp & PAD_BUTTON_A) // gamecube controller
|
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|| (wp & WPAD_BUTTON_A) // wiimote
|
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote
|
||||||
|| (wp & WPAD_BUTTON_B)
|
|
||||||
|| (wp & WPAD_CLASSIC_BUTTON_A) // classic controller
|
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -491,9 +545,9 @@ static unsigned char DecodeJoy( unsigned short pad )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VS zapper games
|
// VS zapper games
|
||||||
if ( (jp & PAD_BUTTON_B) // gamecube controller
|
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
|| (wp & WPAD_BUTTON_1) // wiimote
|
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -519,13 +573,11 @@ void GetJoy()
|
|||||||
short i;
|
short i;
|
||||||
|
|
||||||
s8 gc_px = PAD_SubStickX (0);
|
s8 gc_px = PAD_SubStickX (0);
|
||||||
s8 gc_py = PAD_SubStickY (0);
|
|
||||||
u32 jp = PAD_ButtonsHeld (0); // gamecube controller button info
|
u32 jp = PAD_ButtonsHeld (0); // gamecube controller button info
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
s8 wm_sx = WPAD_StickX (0,1);
|
s8 wm_sx = WPAD_StickX (0,1);
|
||||||
s8 wm_sy = WPAD_StickY (0,1);
|
u32 wm_pb = WPAD_ButtonsDown (0); // wiimote / expansion button info
|
||||||
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Turbo mode
|
// Turbo mode
|
||||||
@ -544,17 +596,6 @@ void GetJoy()
|
|||||||
frameskip = 0;
|
frameskip = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for video zoom
|
|
||||||
if (GCSettings.Zoom)
|
|
||||||
{
|
|
||||||
if (gc_py < -36 || gc_py > 36)
|
|
||||||
zoom ((float) gc_py / -36);
|
|
||||||
#ifdef HW_RVL
|
|
||||||
if (wm_sy < -36 || wm_sy > 36)
|
|
||||||
zoom ((float) wm_sy / -36);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// request to go back to menu
|
// request to go back to menu
|
||||||
if ((gc_px < -70) ||
|
if ((gc_px < -70) ||
|
||||||
((jp & PAD_BUTTON_START) && (jp & PAD_BUTTON_A) &&
|
((jp & PAD_BUTTON_START) && (jp & PAD_BUTTON_A) &&
|
||||||
@ -565,7 +606,6 @@ void GetJoy()
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
StopAudio();
|
|
||||||
ConfigRequested = 1;
|
ConfigRequested = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#define _PAD_H_
|
#define _PAD_H_
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
|
#include <wiiuse/wpad.h>
|
||||||
|
|
||||||
#define PI 3.14159265f
|
#define PI 3.14159265f
|
||||||
#define PADCAL 50
|
#define PADCAL 50
|
||||||
@ -20,20 +21,58 @@
|
|||||||
#define RAPID_A 256
|
#define RAPID_A 256
|
||||||
#define RAPID_B 512
|
#define RAPID_B 512
|
||||||
|
|
||||||
extern unsigned int gcpadmap[];
|
enum
|
||||||
extern unsigned int wmpadmap[];
|
{
|
||||||
extern unsigned int ccpadmap[];
|
TRIGGER_SIMPLE,
|
||||||
extern unsigned int ncpadmap[];
|
TRIGGER_BUTTON_ONLY,
|
||||||
|
TRIGGER_BUTTON_ONLY_IN_FOCUS
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _paddata {
|
||||||
|
u16 btns_d;
|
||||||
|
u16 btns_u;
|
||||||
|
u16 btns_h;
|
||||||
|
s8 stickX;
|
||||||
|
s8 stickY;
|
||||||
|
s8 substickX;
|
||||||
|
s8 substickY;
|
||||||
|
u8 triggerL;
|
||||||
|
u8 triggerR;
|
||||||
|
} PADData;
|
||||||
|
|
||||||
|
class GuiTrigger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GuiTrigger();
|
||||||
|
~GuiTrigger();
|
||||||
|
void SetSimpleTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
void SetButtonOnlyTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
void SetButtonOnlyInFocusTrigger(s32 ch, u32 wiibtns, u16 gcbtns);
|
||||||
|
s8 WPAD_Stick(u8 right, int axis);
|
||||||
|
bool Left();
|
||||||
|
bool Right();
|
||||||
|
bool Up();
|
||||||
|
bool Down();
|
||||||
|
|
||||||
|
u8 type;
|
||||||
|
s32 chan;
|
||||||
|
WPADData wpad;
|
||||||
|
PADData pad;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern GuiTrigger userInput[4];
|
||||||
|
extern int rumbleRequest[4];
|
||||||
|
extern u32 btnmap[2][4][12];
|
||||||
|
|
||||||
void ResetControls();
|
void ResetControls();
|
||||||
|
void ShutoffRumble();
|
||||||
|
void DoRumble(int i);
|
||||||
s8 WPAD_StickX(u8 chan,u8 right);
|
s8 WPAD_StickX(u8 chan,u8 right);
|
||||||
s8 WPAD_StickY(u8 chan, u8 right);
|
s8 WPAD_StickY(u8 chan, u8 right);
|
||||||
void InitialisePads();
|
void InitialisePads();
|
||||||
void GetJoy();
|
void GetJoy();
|
||||||
void ToggleFourScore(int set, bool loaded);
|
void ToggleFourScore(int set);
|
||||||
void ToggleZapper(int set, bool loaded);
|
void ToggleZapper(int set);
|
||||||
void DrawCursor();
|
void DrawCursor();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
|||||||
* FCE Ultra 0.98.12
|
* FCE Ultra 0.98.12
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric September 2008
|
* Tantric 2008-2009
|
||||||
*
|
*
|
||||||
* preferences.c
|
* preferences.cpp
|
||||||
*
|
*
|
||||||
* Preferences save/load preferences utilities
|
* Preferences save/load preferences utilities
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -15,8 +15,10 @@
|
|||||||
#include <ogcsys.h>
|
#include <ogcsys.h>
|
||||||
#include <mxml.h>
|
#include <mxml.h>
|
||||||
|
|
||||||
#include "images/saveicon.h"
|
#include "fceuconfig.h"
|
||||||
#include "menudraw.h"
|
#include "button_mapping.h"
|
||||||
|
#include "filebrowser.h"
|
||||||
|
#include "menu.h"
|
||||||
#include "memcardop.h"
|
#include "memcardop.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
@ -108,25 +110,6 @@ static const char * XMLSaveCallback(mxml_node_t *node, int where)
|
|||||||
static int
|
static int
|
||||||
preparePrefsData (int method)
|
preparePrefsData (int method)
|
||||||
{
|
{
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// add save icon and comments for Memory Card saves
|
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
offset = sizeof (saveicon);
|
|
||||||
|
|
||||||
// Copy in save icon
|
|
||||||
memcpy (savebuffer, saveicon, offset);
|
|
||||||
|
|
||||||
// And the comments
|
|
||||||
char prefscomment[2][32];
|
|
||||||
memset(prefscomment, 0, 64);
|
|
||||||
sprintf (prefscomment[0], "%s Prefs", APPNAME);
|
|
||||||
sprintf (prefscomment[1], "Preferences");
|
|
||||||
memcpy (savebuffer + offset, prefscomment, 64);
|
|
||||||
offset += 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = mxmlNewXML("1.0");
|
xml = mxmlNewXML("1.0");
|
||||||
mxmlSetWrapMargin(0); // disable line wrapping
|
mxmlSetWrapMargin(0); // disable line wrapping
|
||||||
|
|
||||||
@ -152,11 +135,10 @@ preparePrefsData (int method)
|
|||||||
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
||||||
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
||||||
|
|
||||||
createXMLSection("Emulation", "Emulation Settings");
|
createXMLSection("Video", "Video Settings");
|
||||||
|
|
||||||
createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal));
|
createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal));
|
||||||
createXMLSetting("timing", "Timing", toStr(GCSettings.timing));
|
createXMLSetting("timing", "Timing", toStr(GCSettings.timing));
|
||||||
createXMLSetting("Zoom", "Zoom On/Off", toStr(GCSettings.Zoom));
|
|
||||||
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
||||||
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
||||||
createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen));
|
createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen));
|
||||||
@ -164,15 +146,24 @@ preparePrefsData (int method)
|
|||||||
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
||||||
createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));
|
createXMLSetting("yshift", "Vertical Video Shift", toStr(GCSettings.yshift));
|
||||||
|
|
||||||
|
createXMLSection("Menu", "Menu Settings");
|
||||||
|
|
||||||
|
createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
|
||||||
|
createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
|
||||||
|
createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
|
||||||
|
createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
|
||||||
|
|
||||||
createXMLSection("Controller", "Controller Settings");
|
createXMLSection("Controller", "Controller Settings");
|
||||||
|
|
||||||
createXMLSetting("FourScore", "Four Score", toStr(GCSettings.FourScore));
|
createXMLSetting("Controller", "Controller", toStr(GCSettings.Controller));
|
||||||
createXMLSetting("zapper", "Zapper", toStr(GCSettings.zapper));
|
|
||||||
createXMLSetting("crosshair", "Zapper Crosshair", toStr(GCSettings.crosshair));
|
createXMLSetting("crosshair", "Zapper Crosshair", toStr(GCSettings.crosshair));
|
||||||
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
|
|
||||||
createXMLController(wmpadmap, "wmpadmap", "Wiimote");
|
createXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad", "NES Pad - GameCube Controller");
|
||||||
createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
|
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "NES Pad - Wiimote");
|
||||||
createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
|
createXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic", "NES Pad - Classic Controller");
|
||||||
|
createXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk", "NES Pad - Nunchuk + Wiimote");
|
||||||
|
createXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad", "Zapper - GameCube Controller");
|
||||||
|
createXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote", "Zapper - Wiimote");
|
||||||
|
|
||||||
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
int datasize = mxmlSaveString(xml, (char *)savebuffer, SAVEBUFFERSIZE, XMLSaveCallback);
|
||||||
|
|
||||||
@ -216,7 +207,6 @@ static void loadXMLSetting(float * var, const char * name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void loadXMLController(unsigned int controller[], const char * name)
|
static void loadXMLController(unsigned int controller[], const char * name)
|
||||||
|
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
||||||
|
|
||||||
@ -241,16 +231,8 @@ static bool
|
|||||||
decodePrefsData (int method)
|
decodePrefsData (int method)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
// skip save icon and comments for Memory Card saves
|
xml = mxmlLoadString(NULL, (char *)savebuffer, MXML_TEXT_CALLBACK);
|
||||||
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
|
||||||
{
|
|
||||||
offset = sizeof (saveicon);
|
|
||||||
offset += 64; // sizeof prefscomment
|
|
||||||
}
|
|
||||||
|
|
||||||
xml = mxmlLoadString(NULL, (char *)savebuffer+offset, MXML_TEXT_CALLBACK);
|
|
||||||
|
|
||||||
if(xml)
|
if(xml)
|
||||||
{
|
{
|
||||||
@ -305,11 +287,10 @@ decodePrefsData (int method)
|
|||||||
loadXMLSetting(GCSettings.smbuser, "smbuser", sizeof(GCSettings.smbuser));
|
loadXMLSetting(GCSettings.smbuser, "smbuser", sizeof(GCSettings.smbuser));
|
||||||
loadXMLSetting(GCSettings.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
loadXMLSetting(GCSettings.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
||||||
|
|
||||||
// Emulation Settings
|
// Video Settings
|
||||||
|
|
||||||
loadXMLSetting(&GCSettings.currpal, "currpal");
|
loadXMLSetting(&GCSettings.currpal, "currpal");
|
||||||
loadXMLSetting(&GCSettings.timing, "timing");
|
loadXMLSetting(&GCSettings.timing, "timing");
|
||||||
loadXMLSetting(&GCSettings.Zoom, "Zoom");
|
|
||||||
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
||||||
loadXMLSetting(&GCSettings.render, "render");
|
loadXMLSetting(&GCSettings.render, "render");
|
||||||
loadXMLSetting(&GCSettings.widescreen, "widescreen");
|
loadXMLSetting(&GCSettings.widescreen, "widescreen");
|
||||||
@ -317,15 +298,23 @@ decodePrefsData (int method)
|
|||||||
loadXMLSetting(&GCSettings.xshift, "xshift");
|
loadXMLSetting(&GCSettings.xshift, "xshift");
|
||||||
loadXMLSetting(&GCSettings.yshift, "yshift");
|
loadXMLSetting(&GCSettings.yshift, "yshift");
|
||||||
|
|
||||||
|
// Menu Settings
|
||||||
|
|
||||||
|
loadXMLSetting(&GCSettings.WiimoteOrientation, "WiimoteOrientation");
|
||||||
|
loadXMLSetting(&GCSettings.ExitAction, "ExitAction");
|
||||||
|
loadXMLSetting(&GCSettings.MusicVolume, "MusicVolume");
|
||||||
|
loadXMLSetting(&GCSettings.SFXVolume, "SFXVolume");
|
||||||
|
|
||||||
// Controller Settings
|
// Controller Settings
|
||||||
loadXMLSetting(&GCSettings.FourScore, "FSDisable");
|
loadXMLSetting(&GCSettings.Controller, "Controller");
|
||||||
loadXMLSetting(&GCSettings.zapper, "zapper");
|
|
||||||
loadXMLSetting(&GCSettings.crosshair, "crosshair");
|
loadXMLSetting(&GCSettings.crosshair, "crosshair");
|
||||||
|
|
||||||
loadXMLController(gcpadmap, "gcpadmap");
|
loadXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad");
|
||||||
loadXMLController(wmpadmap, "wmpadmap");
|
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote");
|
||||||
loadXMLController(ccpadmap, "ccpadmap");
|
loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic");
|
||||||
loadXMLController(ncpadmap, "ncpadmap");
|
loadXMLController(btnmap[CTRL_PAD][CTRLR_NUNCHUK], "btnmap_pad_nunchuk");
|
||||||
|
loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_GCPAD], "btnmap_zapper_gcpad");
|
||||||
|
loadXMLController(btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE], "btnmap_zapper_wiimote");
|
||||||
}
|
}
|
||||||
mxmlDelete(xml);
|
mxmlDelete(xml);
|
||||||
}
|
}
|
||||||
@ -347,23 +336,40 @@ SavePrefs (bool silent)
|
|||||||
// is the method preferences will be loaded from by default
|
// is the method preferences will be loaded from by default
|
||||||
int method = autoSaveMethod(silent);
|
int method = autoSaveMethod(silent);
|
||||||
|
|
||||||
|
if(method == METHOD_AUTO)
|
||||||
|
return false;
|
||||||
|
|
||||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
ShowAction ("Saving preferences...");
|
ShowAction ("Saving preferences...");
|
||||||
|
|
||||||
|
FixInvalidSettings();
|
||||||
|
|
||||||
AllocSaveBuffer ();
|
AllocSaveBuffer ();
|
||||||
datasize = preparePrefsData (method);
|
datasize = preparePrefsData (method);
|
||||||
|
|
||||||
|
if(method == METHOD_MC_SLOTA || method == METHOD_MC_SLOTB)
|
||||||
|
{
|
||||||
|
// Set the comments
|
||||||
|
char prefscomment[2][32];
|
||||||
|
memset(prefscomment, 0, 64);
|
||||||
|
sprintf (prefscomment[0], "%s Prefs", APPNAME);
|
||||||
|
sprintf (prefscomment[1], "Preferences");
|
||||||
|
SetMCSaveComments(prefscomment);
|
||||||
|
}
|
||||||
|
|
||||||
offset = SaveFile(filepath, datasize, method, silent);
|
offset = SaveFile(filepath, datasize, method, silent);
|
||||||
|
|
||||||
FreeSaveBuffer ();
|
FreeSaveBuffer ();
|
||||||
|
|
||||||
|
CancelAction();
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
if (!silent)
|
if (!silent)
|
||||||
WaitPrompt ("Preferences saved");
|
InfoPrompt ("Preferences saved");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -398,20 +404,29 @@ LoadPrefsFromMethod (int method)
|
|||||||
* Load Preferences
|
* Load Preferences
|
||||||
* Checks sources consecutively until we find a preference file
|
* Checks sources consecutively until we find a preference file
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
static bool prefLoaded = false;
|
||||||
|
|
||||||
bool LoadPrefs()
|
bool LoadPrefs()
|
||||||
{
|
{
|
||||||
ShowAction ("Loading preferences...");
|
if(prefLoaded) // already attempted loading
|
||||||
|
return true;
|
||||||
|
|
||||||
bool prefFound = false;
|
bool prefFound = false;
|
||||||
if(ChangeInterface(METHOD_SD, SILENT))
|
if(ChangeInterface(METHOD_SD, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||||
if(!prefFound && TestCard(CARD_SLOTA, SILENT))
|
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
||||||
if(!prefFound && TestCard(CARD_SLOTB, SILENT))
|
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
||||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
||||||
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
||||||
|
|
||||||
|
prefLoaded = true; // attempted to load preferences
|
||||||
|
|
||||||
|
if(prefFound)
|
||||||
|
FixInvalidSettings();
|
||||||
|
|
||||||
return prefFound;
|
return prefFound;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <utime.h>
|
#include <utime.h>
|
||||||
|
|
||||||
#include "unzip.h"
|
#include "unzip.h"
|
||||||
#include "menudraw.h"
|
#include "menu.h"
|
||||||
|
|
||||||
#define CASESENSITIVITY (0)
|
#define CASESENSITIVITY (0)
|
||||||
#define WRITEBUFFERSIZE (1024*256)
|
#define WRITEBUFFERSIZE (1024*256)
|
||||||
|
Loading…
Reference in New Issue
Block a user