mirror of
https://github.com/dborth/fceugx.git
synced 2024-11-01 06:55:05 +01:00
preliminary new GUI implementation
This commit is contained in:
parent
f76332df49
commit
3307989c04
@ -2,8 +2,8 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* michniewski August 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* button_mapping.c
|
||||
*
|
||||
@ -27,6 +27,50 @@
|
||||
***/
|
||||
|
||||
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
|
||||
{
|
||||
CTRLR_NUNCHUK,
|
||||
@ -70,50 +114,5 @@ CtrlrMap ctrlr_def[4] = {
|
||||
{WPAD_CLASSIC_BUTTON_ZL, "ZL"},
|
||||
{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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* michniewski August 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* button_mapping.h
|
||||
*
|
||||
@ -15,13 +15,15 @@
|
||||
|
||||
enum {
|
||||
CTRLR_NONE = -1,
|
||||
CTRLR_NUNCHUK,
|
||||
CTRLR_CLASSIC,
|
||||
CTRLR_GCPAD,
|
||||
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 {
|
||||
u32 btn; // button 'id'
|
||||
char* name; // button name
|
||||
|
@ -11,6 +11,11 @@
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
extern "C" {
|
||||
extern void ResetNES(void);
|
||||
extern void PowerNES(void);
|
||||
}
|
||||
|
||||
/* Message logging(non-netplay messages, usually) for all. */
|
||||
extern int NoWaiting;
|
||||
extern FCEUGI *GI;
|
||||
|
@ -2,9 +2,11 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* softdev July 2006
|
||||
* svpe & crunchy2 June 2007
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* dvd.c
|
||||
* dvd.cpp
|
||||
*
|
||||
* DVD loading routines
|
||||
****************************************************************************/
|
||||
@ -22,9 +24,11 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "gcunzip.h"
|
||||
#include "fceugx.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
#include "filebrowser.h"
|
||||
#include "fileop.h"
|
||||
|
||||
#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!
|
||||
* returns: 1 - ok ; 0 - error
|
||||
***************************************************************************/
|
||||
|
||||
int dvd_safe_read(void *dst_v, u32 len, u64 fileoffset)
|
||||
{
|
||||
u64 offset = dvddir + fileoffset;
|
||||
@ -318,35 +321,40 @@ getpvd ()
|
||||
*
|
||||
* Tests if a ISO9660 DVD is inserted and available, and mounts it
|
||||
***************************************************************************/
|
||||
|
||||
bool MountDVD(bool silent)
|
||||
{
|
||||
if (!getpvd())
|
||||
bool res = false;
|
||||
|
||||
if (getpvd())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowAction("Loading DVD...");
|
||||
#ifdef HW_DOL
|
||||
DVD_Mount(); // mount the DVD unit again
|
||||
#elif HW_RVL
|
||||
#else
|
||||
u32 val;
|
||||
DI_GetCoverRegister(&val);
|
||||
if(val & 0x1) // True if no disc inside, use (val & 0x2) for true if disc inside.
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("No disc inserted!");
|
||||
ErrorPrompt("No disc inserted!");
|
||||
CancelAction();
|
||||
return false;
|
||||
}
|
||||
DI_Mount();
|
||||
while(DI_GetStatus() & DVD_INIT);
|
||||
while(DI_GetStatus() & DVD_INIT) usleep(20000);
|
||||
#endif
|
||||
|
||||
if (!getpvd())
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt ("Invalid DVD.");
|
||||
return false;
|
||||
if (getpvd())
|
||||
res = true;
|
||||
else if(!silent)
|
||||
ErrorPrompt("Invalid DVD.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
CancelAction();
|
||||
return res;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -355,7 +363,6 @@ bool MountDVD(bool silent)
|
||||
* Support function to return the next file entry, if any
|
||||
* Declared static to avoid accidental external entry.
|
||||
***************************************************************************/
|
||||
|
||||
static int
|
||||
getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
{
|
||||
@ -445,7 +452,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@ -455,8 +462,16 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
memset(&(browserList[entrycount]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy (browserList[entrycount].filename, fname, MAXJOLIET);
|
||||
|
||||
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);
|
||||
|
||||
@ -483,7 +498,7 @@ getentry (int entrycount, unsigned char dvdbuffer[])
|
||||
* It relies on dvddir and dvddirlength being pre-populated by a call to
|
||||
* 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
|
||||
ParseDVDdirectory ()
|
||||
@ -506,7 +521,7 @@ ParseDVDdirectory ()
|
||||
while (len < pdlength)
|
||||
{
|
||||
if (dvd_read (&dvdbuffer, 2048, pdoffset) == 0)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
diroffset = 0;
|
||||
|
||||
@ -523,6 +538,7 @@ ParseDVDdirectory ()
|
||||
// Sort the file list
|
||||
qsort(browserList, filecount, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
browser.numEntries = filecount;
|
||||
return filecount;
|
||||
}
|
||||
|
||||
@ -530,7 +546,6 @@ ParseDVDdirectory ()
|
||||
* SetDVDdirectory
|
||||
* Set the current DVD file offset
|
||||
***************************************************************************/
|
||||
|
||||
void SetDVDdirectory(u64 dir, int length)
|
||||
{
|
||||
dvddir = dir;
|
||||
@ -579,12 +594,18 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
|
||||
if(dirindex >= 0)
|
||||
{
|
||||
dvddir = browserList[dirindex].offset;
|
||||
dvddirlength = browserList[dirindex].length;
|
||||
browser.selIndex = dirindex;
|
||||
|
||||
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)
|
||||
return true;
|
||||
@ -597,8 +618,8 @@ static bool SwitchDVDFolderR(char * dir, int maxDepth)
|
||||
bool SwitchDVDFolder(char origdir[])
|
||||
{
|
||||
// make a copy of origdir so we don't mess with original
|
||||
char dir[200];
|
||||
strcpy(dir, origdir);
|
||||
char dir[1024];
|
||||
strncpy(dir, origdir, 1024);
|
||||
|
||||
char * dirptr = dir;
|
||||
|
||||
@ -612,6 +633,7 @@ bool SwitchDVDFolder(char origdir[])
|
||||
// start searching at root of DVD
|
||||
dvddir = dvdrootdir;
|
||||
dvddirlength = dvdrootlength;
|
||||
browser.dir[0] = 0;
|
||||
ParseDVDdirectory();
|
||||
|
||||
return SwitchDVDFolderR(dirptr, 0);
|
||||
@ -622,10 +644,10 @@ bool SwitchDVDFolder(char origdir[])
|
||||
* This function will load a file from DVD
|
||||
* It assumes dvddir and dvddirlength are prepopulated
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
int result = 0;
|
||||
int offset;
|
||||
int blocks;
|
||||
int i;
|
||||
@ -643,17 +665,19 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
ret = dvd_read (buffer, length, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
else
|
||||
result = length;
|
||||
}
|
||||
else // load whole file
|
||||
{
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
if (IsZipFile (readbuffer))
|
||||
{
|
||||
return UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||
result = UnZipBuffer (buffer, METHOD_DVD); // unzip from dvd
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -661,7 +685,7 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
{
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
memcpy (buffer + offset, readbuffer, 2048);
|
||||
offset += 2048;
|
||||
discoffset += 2048;
|
||||
@ -674,12 +698,15 @@ LoadDVDFileOffset (unsigned char *buffer, int length)
|
||||
i = dvddirlength % 2048;
|
||||
ret = dvd_read (readbuffer, 2048, discoffset);
|
||||
if(ret <= 0) // read failure
|
||||
return 0;
|
||||
goto done;
|
||||
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
|
||||
* will populate dvddir and dvddirlength, and load the file
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
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))
|
||||
{
|
||||
return LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("Error loading file!");
|
||||
return 0;
|
||||
}
|
||||
ret = LoadDVDFileOffset ((unsigned char *)buffer, datasize);
|
||||
else if(!silent)
|
||||
ErrorPrompt("Error loading file!");
|
||||
|
||||
// restore browser information
|
||||
memset(browser.dir, 0, MAXPATHLEN);
|
||||
strncpy(browser.dir, origDir, MAXPATHLEN);
|
||||
browser.selIndex = origSelIndex;
|
||||
browser.pageIndex = origPageIndex;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -768,8 +805,8 @@ int dvd_driveid()
|
||||
dvd[6] = 0x20;
|
||||
dvd[7] = 3;
|
||||
|
||||
while( dvd[7] & 1 )
|
||||
;
|
||||
while( dvd[7] & 1 );
|
||||
|
||||
DCFlushRange((void *)0x80000000, 32);
|
||||
|
||||
return (int)inquiry[2];
|
||||
|
@ -2,7 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* softdev July 2006
|
||||
* svpe & crunchy2 June 2007
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* dvd.h
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceuconfig.c
|
||||
* fceuconfig.cpp
|
||||
*
|
||||
* Configuration parameters
|
||||
****************************************************************************/
|
||||
@ -20,6 +20,31 @@
|
||||
|
||||
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
|
||||
DefaultSettings ()
|
||||
{
|
||||
@ -27,18 +52,21 @@ DefaultSettings ()
|
||||
|
||||
GCSettings.currpal = 0;
|
||||
GCSettings.timing = 0; // 0 - NTSC, 1 - PAL
|
||||
GCSettings.FourScore = 0;
|
||||
GCSettings.zapper = 0;
|
||||
GCSettings.Controller = CTRL_PAD2; // NES pad, Four Score, Zapper
|
||||
GCSettings.crosshair = 1;
|
||||
|
||||
GCSettings.Zoom = 0; // zooming default off
|
||||
GCSettings.ZoomLevel = 1.0; // zoom amount
|
||||
GCSettings.render = 2; // Unfiltered
|
||||
GCSettings.widescreen = 0; // no aspect ratio correction
|
||||
GCSettings.hideoverscan = 2; // hide both horizontal and vertical
|
||||
|
||||
GCSettings.xshift = 0; // video shift
|
||||
GCSettings.yshift = 0;
|
||||
GCSettings.xshift = 0; // horizontal video shift
|
||||
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.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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceuconfig.h
|
||||
*
|
||||
@ -10,9 +10,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FCEUCONFIG_H_
|
||||
|
||||
#define _FCEUCONFIG_H_
|
||||
|
||||
void DefaultSettings ();
|
||||
void FixInvalidSettings();
|
||||
void DefaultSettings();
|
||||
|
||||
#endif
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* 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!
|
||||
****************************************************************************/
|
||||
@ -25,14 +25,16 @@
|
||||
#include "fceustate.h"
|
||||
#include "fceuram.h"
|
||||
#include "common.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "preferences.h"
|
||||
#include "fileop.h"
|
||||
#include "filebrowser.h"
|
||||
#include "networkop.h"
|
||||
#include "gcaudio.h"
|
||||
#include "gcvideo.h"
|
||||
#include "pad.h"
|
||||
#include "filelist.h"
|
||||
#include "gui/gui.h"
|
||||
|
||||
#ifdef HW_RVL
|
||||
extern "C" {
|
||||
@ -40,6 +42,8 @@ extern "C" {
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "FreeTypeGX.h"
|
||||
|
||||
extern "C" {
|
||||
#include "types.h"
|
||||
extern int cleanSFMDATA();
|
||||
@ -53,21 +57,26 @@ unsigned char * nesrom = NULL;
|
||||
int ConfigRequested = 0;
|
||||
int ShutdownRequested = 0;
|
||||
int ResetRequested = 0;
|
||||
int ExitRequested = 0;
|
||||
char appPath[1024];
|
||||
FreeTypeGX *fontSystem;
|
||||
uint8 *xbsave=NULL;
|
||||
int frameskip = 0;
|
||||
|
||||
extern bool romLoaded;
|
||||
|
||||
/****************************************************************************
|
||||
* Shutdown / Reboot / Exit
|
||||
***************************************************************************/
|
||||
|
||||
static void ExitCleanup()
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
ShutoffRumble();
|
||||
#endif
|
||||
ShutdownAudio();
|
||||
StopGX();
|
||||
|
||||
LWP_SuspendThread (devicethread);
|
||||
UnmountAllFAT();
|
||||
CloseShare();
|
||||
|
||||
#ifdef HW_RVL
|
||||
DI_Close();
|
||||
@ -80,27 +89,32 @@ static void ExitCleanup()
|
||||
void (*PSOReload) () = (void (*)()) 0x80001800;
|
||||
#endif
|
||||
|
||||
void Reboot()
|
||||
void ExitApp()
|
||||
{
|
||||
ExitCleanup();
|
||||
#ifdef HW_RVL
|
||||
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
#else
|
||||
#define SOFTRESET_ADR ((volatile u32*)0xCC003024)
|
||||
*SOFTRESET_ADR = 0x00000000;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ExitToLoader()
|
||||
{
|
||||
ExitCleanup();
|
||||
// Exit to Loader
|
||||
if(GCSettings.ExitAction == 0) // Exit to Loader
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
exit(0);
|
||||
#else // gamecube
|
||||
#else
|
||||
if (psoid[0] == PSOSDLOADID)
|
||||
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
|
||||
@ -182,7 +196,6 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
#ifdef HW_RVL
|
||||
DI_Close();
|
||||
DI_Init(); // first
|
||||
#endif
|
||||
|
||||
@ -194,13 +207,13 @@ int main(int argc, char *argv[])
|
||||
WPAD_Init();
|
||||
#endif
|
||||
|
||||
InitGCVideo ();
|
||||
InitGCVideo (); // Initialise video
|
||||
ResetVideo_Menu (); // change to menu video mode
|
||||
|
||||
#ifdef HW_RVL
|
||||
// read wiimote accelerometer and IR data
|
||||
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
|
||||
WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB);
|
||||
@ -208,71 +221,61 @@ int main(int argc, char *argv[])
|
||||
SYS_SetResetCallback(ResetCB);
|
||||
#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)
|
||||
#ifdef HW_DOL
|
||||
DVD_Init ();
|
||||
#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
|
||||
sprintf(appPath, "fceugx");
|
||||
if(argc > 0 && argv[0] != NULL)
|
||||
CreateAppPath(argv[0]);
|
||||
|
||||
int selectedMenu = -1;
|
||||
MountAllFAT(); // Initialize libFAT for SD and USB
|
||||
|
||||
// Load preferences
|
||||
if(!LoadPrefs())
|
||||
{
|
||||
WaitPrompt("Preferences reset - check settings!");
|
||||
selectedMenu = 1; // change to preferences menu
|
||||
}
|
||||
// Audio
|
||||
InitialiseAudio();
|
||||
|
||||
// Initialize font system
|
||||
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_SetVidSystem(GCSettings.timing); // causes a small 'pop' in the audio
|
||||
|
||||
while (1) // main loop
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
if(ShutdownRequested)
|
||||
ShutdownWii();
|
||||
#endif
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
// since we're entering the menu
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
MainMenu(selectedMenu);
|
||||
selectedMenu = 2; // return to game menu from now on
|
||||
ConfigRequested = 1;
|
||||
SwitchAudioMode(1);
|
||||
|
||||
if(!romLoaded)
|
||||
MainMenu(MENU_GAMESELECTION);
|
||||
else
|
||||
MainMenu(MENU_GAME);
|
||||
|
||||
ConfigRequested = 0;
|
||||
SwitchAudioMode(0);
|
||||
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're starting emulation again
|
||||
@ -308,32 +311,15 @@ int main(int argc, char *argv[])
|
||||
PowerNES(); // reset game
|
||||
ResetRequested = 0;
|
||||
}
|
||||
|
||||
if(ConfigRequested)
|
||||
{
|
||||
TakeScreenshot();
|
||||
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;
|
||||
break; // leave emulation loop
|
||||
}
|
||||
}
|
||||
}
|
||||
} // emulation loop
|
||||
} // main loop
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -40,6 +40,18 @@ enum {
|
||||
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{
|
||||
int AutoLoad;
|
||||
int AutoSave;
|
||||
@ -54,7 +66,6 @@ struct SGCSettings{
|
||||
char smbpwd[20];
|
||||
char smbshare[20];
|
||||
|
||||
int Zoom; // 0 - off, 1 - on
|
||||
float ZoomLevel; // zoom amount
|
||||
int VerifySaves;
|
||||
int render; // 0 - original, 1 - filtered, 2 - unfiltered
|
||||
@ -62,21 +73,23 @@ struct SGCSettings{
|
||||
int hideoverscan;
|
||||
int currpal;
|
||||
int timing;
|
||||
int FourScore;
|
||||
int zapper;
|
||||
int Controller;
|
||||
int crosshair;
|
||||
int xshift; // video output shift
|
||||
int yshift;
|
||||
int WiimoteOrientation;
|
||||
int ExitAction;
|
||||
int MusicVolume;
|
||||
int SFXVolume;
|
||||
};
|
||||
|
||||
void ExitToLoader();
|
||||
void Reboot();
|
||||
void ExitApp();
|
||||
void ShutdownWii();
|
||||
extern struct SGCSettings GCSettings;
|
||||
extern int ConfigRequested;
|
||||
extern int ShutdownRequested;
|
||||
extern int ExitRequested;
|
||||
extern char appPath[];
|
||||
extern int frameskip;
|
||||
extern unsigned char * nesrom;
|
||||
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceload.c
|
||||
*
|
||||
@ -37,9 +37,9 @@ extern uint8 FDSBIOS[8192];
|
||||
#include "gcaudio.h"
|
||||
#include "common.h"
|
||||
#include "pad.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "fileop.h"
|
||||
#include "filesel.h"
|
||||
#include "filebrowser.h"
|
||||
|
||||
bool romLoaded = false;
|
||||
|
||||
@ -80,18 +80,18 @@ int GCMemROM(int method, int size)
|
||||
|
||||
/*** Allocate and clear GameInfo ***/
|
||||
|
||||
FCEUGameInfo = (FCEUGI *)memalign(32,sizeof(FCEUGI));
|
||||
FCEUGameInfo = (FCEUGI *) memalign(32, sizeof(FCEUGI));
|
||||
memset(FCEUGameInfo, 0, sizeof(FCEUGI));
|
||||
|
||||
/*** Set some default values ***/
|
||||
FCEUGameInfo->soundchan = 1;
|
||||
FCEUGameInfo->soundrate = SAMPLERATE;
|
||||
FCEUGameInfo->name=0;
|
||||
FCEUGameInfo->type=GIT_CART;
|
||||
FCEUGameInfo->vidsys=GIV_USER;
|
||||
FCEUGameInfo->input[0]=FCEUGameInfo->input[1]=-1;
|
||||
FCEUGameInfo->inputfc=-1;
|
||||
FCEUGameInfo->cspecial=0;
|
||||
FCEUGameInfo->name = 0;
|
||||
FCEUGameInfo->type = GIT_CART;
|
||||
FCEUGameInfo->vidsys = GIV_USER;
|
||||
FCEUGameInfo->input[0] = FCEUGameInfo->input[1] = -1;
|
||||
FCEUGameInfo->inputfc = -1;
|
||||
FCEUGameInfo->cspecial = 0;
|
||||
|
||||
/*** Set internal sound information ***/
|
||||
FCEUI_Sound(SAMPLERATE);
|
||||
@ -100,46 +100,46 @@ int GCMemROM(int method, int size)
|
||||
|
||||
InitialisePads();
|
||||
|
||||
MakeFCEUFile((char *)nesrom, size);
|
||||
MakeFCEUFile((char *) nesrom, size);
|
||||
|
||||
nesGameType = 0;
|
||||
|
||||
if(iNESLoad(NULL, fceufp))
|
||||
if (iNESLoad(NULL, fceufp))
|
||||
nesGameType = 1;
|
||||
else if(UNIFLoad(NULL,fceufp))
|
||||
else if (UNIFLoad(NULL, fceufp))
|
||||
nesGameType = 2;
|
||||
else if(NSFLoad(fceufp))
|
||||
else if (NSFLoad(fceufp))
|
||||
nesGameType = 3;
|
||||
else
|
||||
{
|
||||
// read FDS BIOS into FDSBIOS - should be 8192 bytes
|
||||
if(FDSBIOS[1] == 0)
|
||||
if (FDSBIOS[1] == 0)
|
||||
{
|
||||
int biosSize = 0;
|
||||
char * tmpbuffer = (char *)memalign(32,64 * 1024);
|
||||
char * tmpbuffer = (char *) memalign(32, 64 * 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(biosSize > 0)
|
||||
WaitPrompt("FDS BIOS file is invalid!");
|
||||
if (biosSize > 0)
|
||||
ErrorPrompt("FDS BIOS file is invalid!");
|
||||
|
||||
return 0; // BIOS not loaded, do not load game
|
||||
}
|
||||
free(tmpbuffer);
|
||||
}
|
||||
// load game
|
||||
if(FDSLoad(NULL,fceufp))
|
||||
if (FDSLoad(NULL, fceufp))
|
||||
nesGameType = 4;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ int GCMemROM(int method, int size)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Invalid game file!");
|
||||
ErrorPrompt("Invalid game file!");
|
||||
romLoaded = false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceuload.h
|
||||
*
|
||||
@ -10,3 +10,4 @@
|
||||
****************************************************************************/
|
||||
|
||||
int GCMemROM(int method, int size);
|
||||
extern bool romLoaded;
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceustate.c
|
||||
* fceustate.cpp
|
||||
*
|
||||
* Memory Based Load/Save RAM Manager
|
||||
*
|
||||
@ -20,10 +20,9 @@
|
||||
#include <fat.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "images/saveicon.h"
|
||||
#include "fceugx.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
#include "memcardop.h"
|
||||
#include "fileop.h"
|
||||
|
||||
@ -42,34 +41,9 @@ extern CartInfo UNIFCart;
|
||||
static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
||||
{
|
||||
u32 offset = 0;
|
||||
char comment[2][32];
|
||||
memset(comment, 0, 64);
|
||||
|
||||
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;
|
||||
|
||||
for(x=0;x<4;x++)
|
||||
@ -87,28 +61,25 @@ static u32 NGCFCEU_GameSave(CartInfo *LocalHWInfo, int operation, int method)
|
||||
return offset;
|
||||
}
|
||||
|
||||
bool SaveRAM (int method, bool silent)
|
||||
bool SaveRAM (char * filepath, int method, bool silent)
|
||||
{
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int datasize = 0;
|
||||
int offset = 0;
|
||||
|
||||
if(nesGameType == 4)
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("Saving is not available for FDS games!");
|
||||
InfoPrompt("RAM saving is not available for FDS games!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if (!MakeFilePath(filepath, FILE_RAM, method))
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
ShowAction ("Saving...");
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
// save game save to savebuffer
|
||||
@ -119,45 +90,65 @@ bool SaveRAM (int method, bool silent)
|
||||
|
||||
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);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if ( !silent )
|
||||
WaitPrompt("Save successful");
|
||||
if (!silent)
|
||||
InfoPrompt("Save successful");
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !silent )
|
||||
WaitPrompt("No data to save!");
|
||||
if (!silent)
|
||||
InfoPrompt("No data to save!");
|
||||
}
|
||||
FreeSaveBuffer ();
|
||||
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];
|
||||
|
||||
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;
|
||||
bool retval = false;
|
||||
|
||||
if(nesGameType == 4)
|
||||
{
|
||||
if(!silent)
|
||||
WaitPrompt("Saving is not available for FDS games!");
|
||||
if(nesGameType == 4) // RAM saves don't exist for FDS games
|
||||
return false;
|
||||
}
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||
|
||||
if (!MakeFilePath(filepath, FILE_RAM, method))
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
ShowAction ("Loading...");
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
offset = LoadFile(filepath, method, silent);
|
||||
@ -176,8 +167,25 @@ bool LoadRAM (int method, bool silent)
|
||||
{
|
||||
// if we reached here, nothing was done!
|
||||
if(!silent)
|
||||
WaitPrompt ("Save file not found");
|
||||
InfoPrompt ("Save file not found");
|
||||
}
|
||||
FreeSaveBuffer ();
|
||||
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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceuram.h
|
||||
*
|
||||
* Memory Based Load/Save RAM Manager
|
||||
****************************************************************************/
|
||||
|
||||
bool SaveRAM (int method, bool silent);
|
||||
bool LoadRAM (int method, bool silent);
|
||||
bool SaveRAM (char * filepath, 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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceustate.c
|
||||
* fceustate.cpp
|
||||
*
|
||||
* Memory Based Load/Save State Manager
|
||||
*
|
||||
@ -21,10 +21,9 @@
|
||||
#include "state.h"
|
||||
#include "x6502.h"
|
||||
|
||||
#include "images/saveicon.h"
|
||||
#include "fceugx.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
#include "memcardop.h"
|
||||
#include "fileop.h"
|
||||
|
||||
@ -64,7 +63,7 @@ static void memopen()
|
||||
static void memfwrite(void *buffer, int len)
|
||||
{
|
||||
if ((sboffset + len) > SAVEBUFFERSIZE)
|
||||
WaitPrompt("Buffer Exceeded");
|
||||
ErrorPrompt("Buffer Exceeded");
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
@ -76,8 +75,8 @@ static void memfwrite(void *buffer, int len)
|
||||
/*** Read from a file ***/
|
||||
static void memfread(void *buffer, int len)
|
||||
{
|
||||
if ( (sboffset + len) > SAVEBUFFERSIZE)
|
||||
WaitPrompt("Buffer exceeded");
|
||||
if ((sboffset + len) > SAVEBUFFERSIZE)
|
||||
ErrorPrompt("Buffer exceeded");
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
@ -124,14 +123,14 @@ static int GCReadChunk(int chunkid, SFORMAT *sf)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Bad chunk link");
|
||||
ErrorPrompt("Bad chunk link");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(info, "No Sync %s %s", chunk, sf->desc);
|
||||
WaitPrompt(info);
|
||||
ErrorPrompt(info);
|
||||
return 0;
|
||||
}
|
||||
sf++;
|
||||
@ -155,13 +154,6 @@ static int GCFCEUSS_Load(int method)
|
||||
{
|
||||
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
|
||||
|
||||
// Now read the chunks back
|
||||
@ -214,22 +206,23 @@ static int GCSaveChunk(int chunkid, SFORMAT *sf)
|
||||
csize += 12;
|
||||
|
||||
/*** Now run through this structure ***/
|
||||
while (sf->v) {
|
||||
while (sf->v)
|
||||
{
|
||||
/*** Check that there is a decription ***/
|
||||
if ( sf->desc == NULL)
|
||||
if (sf->desc == NULL)
|
||||
break;
|
||||
|
||||
/*** Write out the description ***/
|
||||
memfwrite( sf->desc, 4);
|
||||
memfwrite(sf->desc, 4);
|
||||
|
||||
/*** Write the length of this chunk ***/
|
||||
chsize = ( sf->s & (~RLSB) );
|
||||
memfwrite( &chsize, 4);
|
||||
chsize = (sf->s & (~RLSB));
|
||||
memfwrite(&chsize, 4);
|
||||
|
||||
if ( chsize > 0 )
|
||||
if (chsize > 0)
|
||||
{
|
||||
/*** Write the actual data ***/
|
||||
memfwrite( sf->v, chsize );
|
||||
memfwrite(sf->v, chsize);
|
||||
}
|
||||
|
||||
csize += 8;
|
||||
@ -265,21 +258,6 @@ static int GCFCEUSS_Save(int method)
|
||||
|
||||
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
|
||||
int mcversion = 0x981211;
|
||||
memcpy(&header[8], &mcversion, 4);
|
||||
@ -313,33 +291,40 @@ static int GCFCEUSS_Save(int method)
|
||||
return totalsize;
|
||||
}
|
||||
|
||||
bool SaveState (int method, bool silent)
|
||||
bool SaveState (char * filepath, int method, bool silent)
|
||||
{
|
||||
bool retval = false;
|
||||
char filepath[1024];
|
||||
int datasize;
|
||||
int offset = 0;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent);
|
||||
|
||||
if (!MakeFilePath(filepath, FILE_STATE, method))
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
ShowAction ("Saving...");
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
datasize = GCFCEUSS_Save(method);
|
||||
|
||||
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);
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if ( !silent )
|
||||
WaitPrompt("Save successful");
|
||||
InfoPrompt("Save successful");
|
||||
retval = true;
|
||||
}
|
||||
}
|
||||
@ -347,20 +332,34 @@ bool SaveState (int method, bool silent)
|
||||
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];
|
||||
|
||||
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;
|
||||
bool retval = false;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoSaveMethod(silent); // we use 'Save' because we need R/W
|
||||
|
||||
if (!MakeFilePath(filepath, FILE_STATE, method))
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
ShowAction ("Loading...");
|
||||
|
||||
AllocSaveBuffer ();
|
||||
|
||||
offset = LoadFile(filepath, method, silent);
|
||||
@ -374,8 +373,25 @@ bool LoadState (int method, bool silent)
|
||||
{
|
||||
// if we reached here, nothing was done!
|
||||
if(!silent)
|
||||
WaitPrompt ("State file not found");
|
||||
ErrorPrompt ("State file not found");
|
||||
}
|
||||
FreeSaveBuffer ();
|
||||
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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fceustate.h
|
||||
*
|
||||
* Memory Based Load/Save State Manager
|
||||
****************************************************************************/
|
||||
|
||||
bool SaveState (int method, bool silent);
|
||||
bool LoadState (int method, bool silent);
|
||||
bool SaveState (char * filepath, 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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* filesel.c
|
||||
* filebrowser.cpp
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
****************************************************************************/
|
||||
@ -22,14 +22,16 @@
|
||||
#include "common.h"
|
||||
#include "fceugx.h"
|
||||
#include "dvd.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
#include "networkop.h"
|
||||
#include "fileop.h"
|
||||
#include "memcardop.h"
|
||||
#include "pad.h"
|
||||
#include "fceuload.h"
|
||||
#include "gcunzip.h"
|
||||
#include "fceuram.h"
|
||||
#include "fceustate.h"
|
||||
|
||||
BROWSERINFO browser;
|
||||
BROWSERENTRY * browserList = NULL; // list of files/folders in browser
|
||||
@ -50,7 +52,7 @@ int autoLoadMethod()
|
||||
{
|
||||
ShowAction ("Attempting to determine load method...");
|
||||
|
||||
int method = 0;
|
||||
int method = METHOD_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
@ -61,10 +63,11 @@ int autoLoadMethod()
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
else
|
||||
WaitPrompt("Unable to auto-determine load method!");
|
||||
ErrorPrompt("Unable to auto-determine load method!");
|
||||
|
||||
if(GCSettings.LoadMethod == METHOD_AUTO)
|
||||
GCSettings.LoadMethod = method; // save method found for later use
|
||||
CancelAction();
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -78,23 +81,25 @@ int autoSaveMethod(bool silent)
|
||||
if(!silent)
|
||||
ShowAction ("Attempting to determine save method...");
|
||||
|
||||
int method = 0;
|
||||
int method = METHOD_AUTO;
|
||||
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
method = METHOD_SD;
|
||||
else if(ChangeInterface(METHOD_USB, SILENT))
|
||||
method = METHOD_USB;
|
||||
else if(TestCard(CARD_SLOTA, SILENT))
|
||||
else if(ChangeInterface(METHOD_MC_SLOTA, SILENT))
|
||||
method = METHOD_MC_SLOTA;
|
||||
else if(TestCard(CARD_SLOTB, SILENT))
|
||||
else if(ChangeInterface(METHOD_MC_SLOTB, SILENT))
|
||||
method = METHOD_MC_SLOTB;
|
||||
else if(ChangeInterface(METHOD_SMB, SILENT))
|
||||
method = METHOD_SMB;
|
||||
else if(!silent)
|
||||
WaitPrompt("Unable to auto-determine save method!");
|
||||
ErrorPrompt("Unable to auto-determine save method!");
|
||||
|
||||
if(GCSettings.SaveMethod == METHOD_AUTO)
|
||||
GCSettings.SaveMethod = method; // save method found for later use
|
||||
|
||||
CancelAction();
|
||||
return method;
|
||||
}
|
||||
|
||||
@ -104,7 +109,9 @@ int autoSaveMethod(bool silent)
|
||||
***************************************************************************/
|
||||
void ResetBrowser()
|
||||
{
|
||||
browser.selIndex = browser.pageIndex = 0;
|
||||
browser.numEntries = 0;
|
||||
browser.selIndex = 0;
|
||||
browser.pageIndex = 0;
|
||||
|
||||
// Clear any existing values
|
||||
if(browserList != NULL)
|
||||
@ -166,16 +173,17 @@ int UpdateDirName(int method)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Directory name is too long!");
|
||||
ErrorPrompt("Directory name is too long!");
|
||||
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 folder[1024];
|
||||
char ext[4];
|
||||
char temppath[MAXPATHLEN];
|
||||
|
||||
if(type == FILE_ROM)
|
||||
@ -183,7 +191,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
// Check path length
|
||||
if ((strlen(browser.dir)+1+strlen(browserList[browser.selIndex].filename)) >= MAXPATHLEN)
|
||||
{
|
||||
WaitPrompt("Maximum filepath length reached!");
|
||||
ErrorPrompt("Maximum filepath length reached!");
|
||||
filepath[0] = 0;
|
||||
return false;
|
||||
}
|
||||
@ -197,13 +205,33 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
switch(type)
|
||||
{
|
||||
case FILE_RAM:
|
||||
sprintf(folder, GCSettings.SaveFolder);
|
||||
sprintf(file, "%s.sav", romFilename);
|
||||
break;
|
||||
case FILE_STATE:
|
||||
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;
|
||||
|
||||
case FILE_FDSBIOS:
|
||||
sprintf(folder, GCSettings.LoadFolder);
|
||||
sprintf(file, "disksys.rom");
|
||||
@ -225,7 +253,7 @@ bool MakeFilePath(char filepath[], int type, int method)
|
||||
break;
|
||||
}
|
||||
}
|
||||
strcpy(filepath, temppath);
|
||||
strncpy(filepath, temppath, MAXPATHLEN);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -271,7 +299,7 @@ bool IsValidROM(int method)
|
||||
if(browserList[browser.selIndex].length < (1024*8) ||
|
||||
browserList[browser.selIndex].length > (1024*1024*3))
|
||||
{
|
||||
WaitPrompt("Invalid file size!");
|
||||
ErrorPrompt("Invalid file size!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -310,7 +338,7 @@ bool IsValidROM(int method)
|
||||
}
|
||||
}
|
||||
}
|
||||
WaitPrompt("Unknown file type!");
|
||||
ErrorPrompt("Unknown file type!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -319,7 +347,6 @@ bool IsValidROM(int method)
|
||||
*
|
||||
* Checks if the specified file is a 7z
|
||||
***************************************************************************/
|
||||
|
||||
bool IsSz()
|
||||
{
|
||||
if (strlen(browserList[browser.selIndex].filename) > 4)
|
||||
@ -337,130 +364,38 @@ bool IsSz()
|
||||
* StripExt
|
||||
*
|
||||
* Strips an extension from a filename
|
||||
****************************************************************************/
|
||||
|
||||
***************************************************************************/
|
||||
void StripExt(char* returnstring, char * inputstring)
|
||||
{
|
||||
char* loc_dot;
|
||||
|
||||
strcpy (returnstring, inputstring);
|
||||
strncpy (returnstring, inputstring, 255);
|
||||
|
||||
if(inputstring == NULL || strlen(inputstring) < 4)
|
||||
return;
|
||||
|
||||
loc_dot = strrchr(returnstring,'.');
|
||||
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
|
||||
****************************************************************************/
|
||||
int FileSelector (int method)
|
||||
* Opens the selected 7z file, and parses a listing of the files within
|
||||
***************************************************************************/
|
||||
int BrowserLoadSz(int method)
|
||||
{
|
||||
u32 p = 0;
|
||||
u32 wp = 0;
|
||||
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;
|
||||
char filepath[MAXPATHLEN];
|
||||
memset(filepath, 0, MAXPATHLEN);
|
||||
|
||||
int haverom = 0;
|
||||
int redraw = 1;
|
||||
int selectit = 0;
|
||||
|
||||
int scroll_delay = 0;
|
||||
bool move_selection = 0;
|
||||
#define SCROLL_INITIAL_DELAY 15
|
||||
#define SCROLL_LOOP_DELAY 2
|
||||
|
||||
while (haverom == 0)
|
||||
{
|
||||
if (redraw)
|
||||
ShowFiles (browserList, browser.numEntries, browser.pageIndex, browser.selIndex);
|
||||
redraw = 0;
|
||||
|
||||
VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
||||
|
||||
gc_ay = PAD_StickY (0);
|
||||
gc_sx = PAD_SubStickX (0);
|
||||
|
||||
p = PAD_ButtonsDown (0);
|
||||
ph = PAD_ButtonsHeld (0);
|
||||
#ifdef HW_RVL
|
||||
wm_ay = WPAD_StickY (0, 0);
|
||||
wm_sx = WPAD_StickX (0, 1);
|
||||
|
||||
wp = WPAD_ButtonsDown (0);
|
||||
wh = WPAD_ButtonsHeld (0);
|
||||
#endif
|
||||
|
||||
/*** Check for exit combo ***/
|
||||
if ( (gc_sx < -70) || (wm_sx < -70) || (wp & WPAD_BUTTON_HOME) || (wp & WPAD_CLASSIC_BUTTON_HOME) )
|
||||
return 0;
|
||||
|
||||
/*** Check buttons, perform actions ***/
|
||||
if ( (p & PAD_BUTTON_A) || selectit || (wp & (WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A)) )
|
||||
{
|
||||
if ( selectit )
|
||||
selectit = 0;
|
||||
|
||||
if (browserList[browser.selIndex].isdir) // This is directory
|
||||
{
|
||||
/* update current directory and set new entry list if directory has changed */
|
||||
|
||||
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);
|
||||
sprintf(filepath, "%s%s", rootdir, szpath);
|
||||
memcpy(szpath, filepath, MAXPATHLEN);
|
||||
|
||||
int szfiles = SzParse(szpath, method);
|
||||
if(szfiles)
|
||||
@ -469,220 +404,138 @@ int FileSelector (int method)
|
||||
inSz = true;
|
||||
}
|
||||
else
|
||||
WaitPrompt("Error opening archive!");
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorPrompt("Error opening archive!");
|
||||
|
||||
return szfiles;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* BrowserLoadFile
|
||||
*
|
||||
* Loads the selected ROM
|
||||
***************************************************************************/
|
||||
int BrowserLoadFile(int method)
|
||||
{
|
||||
char filepath[1024];
|
||||
int filesize = 0;
|
||||
romLoaded = false;
|
||||
|
||||
// check that this is a valid ROM
|
||||
if(!IsValidROM(method))
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
// store the filename (w/o ext) - used for state saving
|
||||
// store the filename (w/o ext) - used for ram/state naming
|
||||
StripExt(romFilename, browserList[browser.selIndex].filename);
|
||||
|
||||
ShowAction ("Loading...");
|
||||
|
||||
int size = 0;
|
||||
|
||||
if(!inSz)
|
||||
{
|
||||
char filepath[1024];
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_ROM, method))
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
size = LoadFile((char *)nesrom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
||||
filesize = LoadFile ((char *)nesrom, filepath, browserList[browser.selIndex].length, method, NOTSILENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
size = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
||||
filesize = SzExtractFile(browserList[browser.selIndex].offset, nesrom);
|
||||
break;
|
||||
default:
|
||||
size = LoadSzFile(szpath, nesrom);
|
||||
filesize = LoadSzFile(szpath, nesrom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inSz = false;
|
||||
|
||||
if (size > 0)
|
||||
if (filesize <= 0)
|
||||
{
|
||||
if(GCMemROM(method, size) > 0)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
ErrorPrompt("Error loading ROM!");
|
||||
}
|
||||
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)))
|
||||
if(GCMemROM(method, filesize) > 0)
|
||||
{
|
||||
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;
|
||||
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();
|
||||
}
|
||||
else if (strcmp(browserList[1].filename, "..") == 0)
|
||||
{
|
||||
browser.selIndex = selectit = 1;
|
||||
}
|
||||
else
|
||||
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
|
||||
{
|
||||
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(method == METHOD_DVD)
|
||||
SetDVDdirectory(browserList[0].offset, browserList[0].length);
|
||||
|
||||
inSz = false;
|
||||
SzClose();
|
||||
}
|
||||
|
||||
if (move_selection)
|
||||
if(!UpdateDirName(method))
|
||||
return -1;
|
||||
|
||||
switch (method)
|
||||
{
|
||||
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
|
||||
case METHOD_DVD:
|
||||
ParseDVDdirectory();
|
||||
break;
|
||||
|
||||
default:
|
||||
ParseDirectory(method);
|
||||
break;
|
||||
}
|
||||
|
||||
if (move_selection)
|
||||
if (!browser.numEntries)
|
||||
{
|
||||
browser.selIndex--;
|
||||
if (browser.selIndex < 0)
|
||||
{
|
||||
browser.selIndex = browser.numEntries - 1;
|
||||
browser.pageIndex = browser.selIndex - PAGESIZE + 1;
|
||||
ErrorPrompt("Error reading directory!");
|
||||
}
|
||||
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;
|
||||
|
||||
return browser.numEntries;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* OpenROM
|
||||
* Opens device specified by method, displays a list of ROMS
|
||||
* Displays a list of ROMS on load device
|
||||
***************************************************************************/
|
||||
|
||||
int
|
||||
OpenROM (int method)
|
||||
OpenGameList ()
|
||||
{
|
||||
int method = GCSettings.LoadMethod;
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
method = autoLoadMethod();
|
||||
|
||||
if(ChangeInterface(method, NOTSILENT))
|
||||
{
|
||||
// change current dir to roms directory
|
||||
switch(method)
|
||||
{
|
||||
case METHOD_DVD:
|
||||
browser.dir[0] = 0;
|
||||
browser.numEntries = ParseDVDdirectory(); // Parse root directory
|
||||
if(MountDVD(NOTSILENT))
|
||||
if(ParseDVDdirectory()) // Parse root directory
|
||||
SwitchDVDFolder(GCSettings.LoadFolder); // switch to ROM folder
|
||||
break;
|
||||
default:
|
||||
sprintf(browser.dir, "/%s", GCSettings.LoadFolder);
|
||||
browser.numEntries = ParseDirectory(); // Parse root directory
|
||||
ParseDirectory(method); // 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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* filesel.h
|
||||
* filebrowser.h
|
||||
*
|
||||
* Generic file routines - reading, writing, browsing
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _NGCFILESEL_
|
||||
#define _NGCFILESEL_
|
||||
#ifndef _FILEBROWSER_H_
|
||||
#define _FILEBROWSER_H_
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
@ -29,6 +29,7 @@ typedef struct
|
||||
{
|
||||
u64 offset; // DVD offset
|
||||
unsigned int length; // file length
|
||||
time_t mtime; // file modified time
|
||||
char isdir; // 0 - file, 1 - directory
|
||||
char filename[MAXJOLIET + 1]; // full filename
|
||||
char displayname[MAXDISPLAY + 1]; // name for browser display
|
||||
@ -41,12 +42,17 @@ extern char rootdir[10];
|
||||
extern char romFilename[];
|
||||
extern int nesGameType;
|
||||
|
||||
bool MakeFilePath(char filepath[], int type, int method);
|
||||
int OpenROM (int method);
|
||||
bool MakeFilePath(char filepath[], int type, int method, char * filename = NULL, int filenum = -1);
|
||||
int UpdateDirName(int method);
|
||||
int OpenGameList();
|
||||
int autoLoadMethod();
|
||||
int autoSaveMethod(bool silent);
|
||||
int FileSortCallback(const void *f1, const void *f2);
|
||||
void StripExt(char* returnstring, char * inputstring);
|
||||
bool IsSz();
|
||||
void ResetBrowser();
|
||||
int BrowserLoadSz(int method);
|
||||
int BrowserChangeFolder(int method);
|
||||
int BrowserLoadFile(int method);
|
||||
|
||||
#endif
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric January 2009
|
||||
*
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fileop.c
|
||||
* fileop.cpp
|
||||
*
|
||||
* File operations
|
||||
****************************************************************************/
|
||||
@ -29,8 +29,8 @@
|
||||
#include "memcardop.h"
|
||||
#include "networkop.h"
|
||||
#include "gcunzip.h"
|
||||
#include "menudraw.h"
|
||||
#include "filesel.h"
|
||||
#include "menu.h"
|
||||
#include "filebrowser.h"
|
||||
|
||||
unsigned char * savebuffer = NULL;
|
||||
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
|
||||
***************************************************************************/
|
||||
lwp_t devicethread;
|
||||
lwp_t devicethread = LWP_THREAD_NULL;
|
||||
|
||||
/****************************************************************************
|
||||
* devicecallback
|
||||
@ -114,7 +114,7 @@ devicecallback (void *arg)
|
||||
void
|
||||
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;
|
||||
fatUnmount(rootdir);
|
||||
disc->shutdown();
|
||||
isMounted[method] = false;
|
||||
}
|
||||
if(!isMounted[method])
|
||||
{
|
||||
@ -225,7 +226,7 @@ bool ChangeInterface(int method, bool silent)
|
||||
mounted = MountFAT(METHOD_SD_SLOTB); // try SD Gecko on slot B
|
||||
#endif
|
||||
if(!mounted && !silent) // no SD device found
|
||||
WaitPrompt ("SD card not found!");
|
||||
ErrorPrompt("SD card not found!");
|
||||
}
|
||||
else if(method == METHOD_USB)
|
||||
{
|
||||
@ -233,19 +234,31 @@ bool ChangeInterface(int method, bool silent)
|
||||
mounted = MountFAT(method);
|
||||
|
||||
if(!mounted && !silent)
|
||||
WaitPrompt ("USB drive not found!");
|
||||
ErrorPrompt("USB drive not found!");
|
||||
#endif
|
||||
}
|
||||
else if(method == METHOD_DVD)
|
||||
{
|
||||
sprintf(rootdir, "/");
|
||||
rootdir[0] = 0;
|
||||
mounted = MountDVD(silent);
|
||||
}
|
||||
#ifdef HW_RVL
|
||||
else if(method == METHOD_SMB)
|
||||
{
|
||||
sprintf(rootdir, "smb:/");
|
||||
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;
|
||||
}
|
||||
@ -254,39 +267,49 @@ bool ChangeInterface(int method, bool silent)
|
||||
* Browse subdirectories
|
||||
**************************************************************************/
|
||||
int
|
||||
ParseDirectory()
|
||||
ParseDirectory(int method)
|
||||
{
|
||||
DIR_ITER *dir;
|
||||
DIR_ITER *dir = NULL;
|
||||
char fulldir[MAXPATHLEN];
|
||||
char filename[MAXPATHLEN];
|
||||
char tmpname[MAXPATHLEN];
|
||||
struct stat filestat;
|
||||
char msg[128];
|
||||
int retry = 1;
|
||||
bool mounted = false;
|
||||
|
||||
// reset browser
|
||||
ResetBrowser();
|
||||
|
||||
// add device to path
|
||||
sprintf(fulldir, "%s%s", rootdir, browser.dir);
|
||||
ShowAction("Loading...");
|
||||
|
||||
// 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)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", fulldir);
|
||||
WaitPrompt(msg);
|
||||
|
||||
// if we can't open the dir, open root dir
|
||||
if(ChangeInterface(method, SILENT))
|
||||
{
|
||||
sprintf(browser.dir,"/");
|
||||
|
||||
dir = diropen(rootdir);
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
sprintf(msg, "Error opening %s", rootdir);
|
||||
WaitPrompt(msg);
|
||||
return 0;
|
||||
ErrorPrompt(msg);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -302,8 +325,8 @@ ParseDirectory()
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
entryNum = 0;
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
entryNum = -1;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -313,9 +336,19 @@ ParseDirectory()
|
||||
memset(&(browserList[entryNum]), 0, sizeof(BROWSERENTRY)); // clear the new entry
|
||||
|
||||
strncpy(browserList[entryNum].filename, filename, MAXJOLIET);
|
||||
|
||||
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].mtime = filestat.st_mtime;
|
||||
browserList[entryNum].isdir = (filestat.st_mode & _IFDIR) == 0 ? 0 : 1; // flag this as a dir
|
||||
|
||||
entryNum++;
|
||||
@ -328,6 +361,9 @@ ParseDirectory()
|
||||
// Sort the file list
|
||||
qsort(browserList, entryNum, sizeof(BROWSERENTRY), FileSortCallback);
|
||||
|
||||
CancelAction();
|
||||
|
||||
browser.numEntries = entryNum;
|
||||
return entryNum;
|
||||
}
|
||||
|
||||
@ -338,8 +374,8 @@ ParseDirectory()
|
||||
void
|
||||
AllocSaveBuffer ()
|
||||
{
|
||||
if (savebuffer != NULL)
|
||||
free(savebuffer);
|
||||
while(savebuffer != NULL) // save buffer is in use
|
||||
usleep(50); // wait for it to be free
|
||||
|
||||
savebuffer = (unsigned char *) memalign(32, SAVEBUFFERSIZE);
|
||||
memset (savebuffer, 0, SAVEBUFFERSIZE);
|
||||
@ -380,7 +416,7 @@ LoadSzFile(char * filepath, unsigned char * rbuffer)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Error opening file");
|
||||
ErrorPrompt("Error opening file");
|
||||
}
|
||||
|
||||
// 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];
|
||||
u32 size = 0;
|
||||
u32 readsize = 0;
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
return 0;
|
||||
char fullpath[MAXPATHLEN];
|
||||
int retry = 1;
|
||||
|
||||
switch(method)
|
||||
{
|
||||
@ -419,13 +454,15 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
// since we're loading a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
|
||||
// open the file
|
||||
while(!size && retry == 1)
|
||||
{
|
||||
if(ChangeInterface(method, silent))
|
||||
{
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "rb");
|
||||
|
||||
if (file > 0)
|
||||
if(file > 0)
|
||||
{
|
||||
if(length > 0 && length <= 2048) // do a partial read (eg: to check file header)
|
||||
{
|
||||
@ -450,17 +487,21 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
memcpy (rbuffer, zipbuffer, readsize); // copy what we already read
|
||||
|
||||
u32 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, (1024*512), file); // read in 512K chunks
|
||||
readsize = fread (rbuffer + offset, 1, nextread, file); // read in next chunk
|
||||
|
||||
if(readsize <= 0 || readsize > (1024*512))
|
||||
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;
|
||||
@ -469,19 +510,28 @@ LoadFile (char * rbuffer, char *filepath, u32 length, int method, bool silent)
|
||||
}
|
||||
fclose (file);
|
||||
}
|
||||
if(!size && !silent)
|
||||
}
|
||||
if(!size)
|
||||
{
|
||||
if(!silent)
|
||||
{
|
||||
unmountRequired[method] = true;
|
||||
WaitPrompt("Error loading file!");
|
||||
retry = ErrorPromptRetry("Error loading file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
retry = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// go back to checking if devices were inserted/removed
|
||||
LWP_ResumeThread (devicethread);
|
||||
|
||||
CancelAction();
|
||||
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);
|
||||
}
|
||||
@ -493,53 +543,59 @@ u32 LoadFile(char filepath[], int method, bool silent)
|
||||
u32
|
||||
SaveFile (char * buffer, char *filepath, u32 datasize, int method, bool silent)
|
||||
{
|
||||
char fullpath[MAXPATHLEN];
|
||||
u32 written = 0;
|
||||
int retry = 1;
|
||||
|
||||
if(!ChangeInterface(method, NOTSILENT))
|
||||
if(datasize == 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);
|
||||
break;
|
||||
case METHOD_MC_SLOTB:
|
||||
else
|
||||
return SaveMCFile (buffer, CARD_SLOTB, filepath, datasize, silent);
|
||||
break;
|
||||
}
|
||||
|
||||
if (datasize)
|
||||
{
|
||||
// stop checking if devices were removed/inserted
|
||||
// since we're saving a file
|
||||
LWP_SuspendThread (devicethread);
|
||||
|
||||
// add device to filepath
|
||||
char fullpath[1024];
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath);
|
||||
|
||||
// open file for writing
|
||||
while(!written && retry == 1)
|
||||
{
|
||||
if(ChangeInterface(method, silent))
|
||||
{
|
||||
sprintf(fullpath, "%s%s", rootdir, filepath); // add device to filepath
|
||||
file = fopen (fullpath, "wb");
|
||||
|
||||
if (file > 0)
|
||||
{
|
||||
written = fwrite (savebuffer, 1, datasize, file);
|
||||
if(written < datasize) written = 0;
|
||||
fclose (file);
|
||||
}
|
||||
|
||||
if(!written && !silent)
|
||||
}
|
||||
if(!written)
|
||||
{
|
||||
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
|
||||
LWP_ResumeThread (devicethread);
|
||||
}
|
||||
|
||||
CancelAction();
|
||||
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);
|
||||
}
|
||||
|
@ -2,15 +2,16 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* fatop.h
|
||||
* fileop.h
|
||||
*
|
||||
* File operations
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _FILEOP_H_
|
||||
#define _FILEOP_H_
|
||||
|
||||
#include <gccore.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -24,14 +25,14 @@ void InitDeviceThread();
|
||||
void MountAllFAT();
|
||||
void UnmountAllFAT();
|
||||
bool ChangeInterface(int method, bool silent);
|
||||
int ParseDirectory();
|
||||
int ParseDirectory(int method);
|
||||
void AllocSaveBuffer();
|
||||
void FreeSaveBuffer();
|
||||
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 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 FILE * file;
|
||||
|
@ -2,16 +2,17 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
* eke-eke October 2008
|
||||
*
|
||||
* gcaudio.c
|
||||
* gcaudio.cpp
|
||||
*
|
||||
* Audio driver
|
||||
****************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <string.h>
|
||||
#include <asndlib.h>
|
||||
|
||||
#define SAMPLERATE 48000
|
||||
|
||||
@ -83,8 +84,6 @@ static void AudioSwitchBuffers()
|
||||
void InitialiseAudio()
|
||||
{
|
||||
AUDIO_Init(NULL); // Start audio subsystem
|
||||
AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ);
|
||||
AUDIO_RegisterDMACallback( AudioSwitchBuffers );
|
||||
memset(soundbuffer, 0, 3840*2);
|
||||
memset(mixbuffer, 0, 16000);
|
||||
}
|
||||
@ -112,6 +111,50 @@ void ResetAudio()
|
||||
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
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
* eke-eke October 2008
|
||||
*
|
||||
* gcaudio.h
|
||||
@ -14,3 +14,5 @@ void InitialiseAudio();
|
||||
void StopAudio();
|
||||
void ResetAudio();
|
||||
void PlaySound( int *Buffer, int samples );
|
||||
void SwitchAudioMode(int mode);
|
||||
void ShutdownAudio();
|
||||
|
@ -23,8 +23,11 @@ extern "C" {
|
||||
|
||||
#include "fceugx.h"
|
||||
#include "dvd.h"
|
||||
#include "networkop.h"
|
||||
#include "fileop.h"
|
||||
#include "menudraw.h"
|
||||
#include "filebrowser.h"
|
||||
#include "gcvideo.h"
|
||||
#include "menu.h"
|
||||
#include "gcunzip.h"
|
||||
|
||||
#define ZIPCHUNK 2048
|
||||
@ -145,7 +148,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
res = inflateInit2 (&zs, -MAX_WBITS);
|
||||
|
||||
if (res != Z_OK)
|
||||
return 0;
|
||||
goto done;
|
||||
|
||||
/*** Set ZipChunk for first pass ***/
|
||||
zipoffset =
|
||||
@ -169,8 +172,7 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
|
||||
if (res == Z_MEM_ERROR)
|
||||
{
|
||||
inflateEnd (&zs);
|
||||
return 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
have = ZIPCHUNK - zs.avail_out;
|
||||
@ -198,22 +200,19 @@ UnZipBuffer (unsigned char *outbuffer, int method)
|
||||
break;
|
||||
}
|
||||
if(sizeread <= 0)
|
||||
break; // read failure
|
||||
goto done; // read failure
|
||||
|
||||
ShowProgress ("Loading...", bufferoffset, pkzip.uncompressedSize);
|
||||
}
|
||||
while (res != Z_STREAM_END);
|
||||
|
||||
done:
|
||||
inflateEnd (&zs);
|
||||
CancelAction();
|
||||
|
||||
if (res == Z_STREAM_END)
|
||||
{
|
||||
if (pkzip.uncompressedSize == (u32) bufferoffset)
|
||||
return bufferoffset;
|
||||
else
|
||||
return pkzip.uncompressedSize;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -247,7 +246,7 @@ GetFirstZipFilename (int method)
|
||||
}
|
||||
else
|
||||
{
|
||||
WaitPrompt("Error - Invalid ZIP file!");
|
||||
ErrorPrompt("Error - Invalid ZIP file!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,7 +316,7 @@ Is7ZipFile (char *buffer)
|
||||
// display an error message
|
||||
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
|
||||
@ -472,7 +471,7 @@ int SzParse(char * filepath, int method)
|
||||
if(!newBrowserList) // failed to allocate required memory
|
||||
{
|
||||
ResetBrowser();
|
||||
WaitPrompt("Out of memory: too many files!");
|
||||
ErrorPrompt("Out of memory: too many files!");
|
||||
nbfiles = 0;
|
||||
break;
|
||||
}
|
||||
@ -553,6 +552,8 @@ int SzExtractFile(int i, unsigned char *buffer)
|
||||
// close 7Zip archive and free memory
|
||||
SzClose();
|
||||
|
||||
CancelAction();
|
||||
|
||||
// check for errors
|
||||
if(SzRes != SZ_OK)
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* gcvideo.c
|
||||
* gcvideo.cpp
|
||||
*
|
||||
* Video rendering
|
||||
****************************************************************************/
|
||||
@ -16,12 +16,13 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "driver.h"
|
||||
#include "gcvideo.h"
|
||||
#include "fceugx.h"
|
||||
#include "menudraw.h"
|
||||
#include "images/nesback.h"
|
||||
#include "menu.h"
|
||||
#include "pad.h"
|
||||
|
||||
extern "C" {
|
||||
extern void FCEU_ResetPalette(void);
|
||||
@ -37,6 +38,7 @@ static GXRModeObj *vmode; // Graphics Mode Object
|
||||
unsigned int *xfb[2]; // Framebuffers
|
||||
int whichfb = 0; // Frame buffer toggle
|
||||
int screenheight;
|
||||
int screenwidth;
|
||||
bool progressive = FALSE;
|
||||
|
||||
/*** 3D GX ***/
|
||||
@ -47,6 +49,7 @@ static u8 gp_fifo[DEFAULT_FIFO_SIZE] ATTRIBUTE_ALIGN(32);
|
||||
static u32 copynow = GX_FALSE;
|
||||
static GXTexObj texobj;
|
||||
static Mtx view;
|
||||
static Mtx GXmodelView2D;
|
||||
|
||||
/*** Texture memory ***/
|
||||
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 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 VASPECT 240
|
||||
|
||||
@ -244,7 +250,6 @@ vbgetback (void *arg)
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -272,7 +277,6 @@ InitVideoThread ()
|
||||
static void
|
||||
copy_to_xfb (u32 arg)
|
||||
{
|
||||
|
||||
if (copynow == GX_TRUE)
|
||||
{
|
||||
GX_CopyDisp (xfb[whichfb], GX_TRUE);
|
||||
@ -368,13 +372,11 @@ draw_square (Mtx v)
|
||||
/****************************************************************************
|
||||
* StartGX
|
||||
*
|
||||
* This function initialises the GX.
|
||||
* This function initialises GX and sets it up for use
|
||||
***************************************************************************/
|
||||
static void
|
||||
StartGX ()
|
||||
{
|
||||
Mtx44 p;
|
||||
|
||||
GXColor background = { 0, 0, 0, 0xff };
|
||||
|
||||
/*** Clear out FIFO area ***/
|
||||
@ -384,27 +386,22 @@ StartGX ()
|
||||
GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE);
|
||||
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_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
|
||||
GX_SetColorUpdate (GX_TRUE);
|
||||
GX_SetCullMode (GX_CULL_NONE);
|
||||
}
|
||||
|
||||
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
|
||||
UpdatePadsCB ()
|
||||
{
|
||||
#ifdef HW_RVL
|
||||
#ifdef HW_RVL
|
||||
WPAD_ScanPads();
|
||||
#endif
|
||||
#endif
|
||||
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
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
// always 480 lines
|
||||
screenheight = vmode->xfbHeight;
|
||||
screenwidth = vmode->fbWidth;
|
||||
|
||||
// Allocate the video buffers
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
@ -549,12 +564,10 @@ InitGCVideo ()
|
||||
VIDEO_WaitVSync ();
|
||||
|
||||
copynow = GX_FALSE;
|
||||
|
||||
StartGX ();
|
||||
|
||||
draw_init ();
|
||||
|
||||
InitVideoThread ();
|
||||
|
||||
// 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_SetDispCopyYScale ((f32) rmode->xfbHeight / (f32) rmode->efbHeight);
|
||||
GX_SetScissor (0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
|
||||
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||
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_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
||||
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
|
||||
GX_LoadProjectionMtx (p, GX_ORTHOGRAPHIC);
|
||||
|
||||
@ -644,41 +663,6 @@ ResetVideo_Emu ()
|
||||
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
|
||||
*
|
||||
@ -798,22 +782,211 @@ zoom_reset ()
|
||||
updateScaling = 5; // update video
|
||||
}
|
||||
|
||||
void
|
||||
clearscreen ()
|
||||
/****************************************************************************
|
||||
* TakeScreenshot
|
||||
*
|
||||
* Copies the current screen into a GX texture
|
||||
***************************************************************************/
|
||||
void TakeScreenshot()
|
||||
{
|
||||
int colour = COLOR_BLACK;
|
||||
whichfb ^= 1;
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[whichfb], colour);
|
||||
memcpy (xfb[whichfb], &bg, 1280 * 480);
|
||||
int texSize = vmode->fbWidth * vmode->efbHeight * 4;
|
||||
|
||||
if(gameScreenTex) free(gameScreenTex);
|
||||
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
|
||||
showscreen ()
|
||||
ResetVideo_Menu ()
|
||||
{
|
||||
copynow = GX_FALSE;
|
||||
VIDEO_SetNextFramebuffer (xfb[whichfb]);
|
||||
VIDEO_Flush ();
|
||||
VIDEO_WaitVSync ();
|
||||
Mtx44 p;
|
||||
f32 yscale;
|
||||
u32 xfbHeight;
|
||||
|
||||
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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* gcvideo.h
|
||||
*
|
||||
@ -12,17 +12,6 @@
|
||||
#ifndef _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
|
||||
#define MAXPAL 12
|
||||
|
||||
@ -31,6 +20,24 @@ struct st_palettes {
|
||||
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 int FDSSwitchRequested;
|
||||
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
|
||||
*
|
||||
@ -19,14 +20,15 @@
|
||||
#include <math.h>
|
||||
#include <asndlib.h>
|
||||
#include "pngu/pngu.h"
|
||||
#include "FreeTypeGX.h"
|
||||
#include "snes9xGX.h"
|
||||
#include "video.h"
|
||||
#include "input.h"
|
||||
#include "filelist.h"
|
||||
#include "fileop.h"
|
||||
#include "menu.h"
|
||||
#include "oggplayer.h"
|
||||
|
||||
#include "../FreeTypeGX.h"
|
||||
#include "../fceugx.h"
|
||||
#include "../gcvideo.h"
|
||||
#include "../pad.h"
|
||||
#include "../filelist.h"
|
||||
#include "../fileop.h"
|
||||
#include "../menu.h"
|
||||
#include "../oggplayer.h"
|
||||
|
||||
#define SCROLL_INITIAL_DELAY 20
|
||||
#define SCROLL_LOOP_DELAY 3
|
||||
@ -78,6 +80,8 @@ enum
|
||||
#define EFFECT_SCALE 128
|
||||
#define EFFECT_COLOR_TRANSITION 256
|
||||
|
||||
extern FreeTypeGX *fontSystem;
|
||||
|
||||
class GuiSound
|
||||
{
|
||||
public:
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* 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
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* 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
|
||||
*
|
||||
@ -354,10 +355,10 @@ void GuiSaveBrowser::Update(GuiTrigger * t)
|
||||
saveDate[i]->SetText(saves->date[listOffset+i]);
|
||||
saveTime[i]->SetText(saves->time[listOffset+i]);
|
||||
|
||||
if(saves->type[listOffset+i] == FILE_SRAM)
|
||||
sprintf(savetext, "SRAM");
|
||||
if(saves->type[listOffset+i] == FILE_RAM)
|
||||
sprintf(savetext, "RAM");
|
||||
else
|
||||
sprintf(savetext, "Snapshot");
|
||||
sprintf(savetext, "State");
|
||||
|
||||
len = strlen(saves->filename[listOffset+i]);
|
||||
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
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric February 2009
|
||||
*
|
||||
@ -9,8 +10,6 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "gui.h"
|
||||
#include "snes9xGX.h"
|
||||
#include "filelist.h"
|
||||
|
||||
static int currentSize = 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
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
/****************************************************************************
|
||||
* Snes9x 1.51 Nintendo Wii/Gamecube Port
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric February 2009
|
||||
*
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <sys/errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "http.h"
|
||||
|
||||
static s32 tcp_socket(void)
|
||||
|
@ -15,104 +15,136 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "menudraw.h"
|
||||
#include "fceugx.h"
|
||||
#include "common.h"
|
||||
#include "gcvideo.h"
|
||||
#include "menu.h"
|
||||
#include "memcardop.h"
|
||||
#include "preferences.h"
|
||||
#include "filebrowser.h"
|
||||
#include "fileop.h"
|
||||
#include "filesel.h"
|
||||
#include "dvd.h"
|
||||
#include "images/saveicon.h"
|
||||
|
||||
static u8 * SysArea = NULL;
|
||||
static char savecomments[2][32];
|
||||
|
||||
/****************************************************************************
|
||||
* CardFileExists
|
||||
*
|
||||
* 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
|
||||
* MountMC
|
||||
*
|
||||
* Mounts the memory card in the given slot.
|
||||
* 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 tries = 0;
|
||||
|
||||
// Initialize Card System
|
||||
SysArea = (u8 *)memalign(32, CARD_WORKAREA);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("FCEU", "00");
|
||||
|
||||
// Mount the card
|
||||
while ( tries < 10 && ret != 0)
|
||||
while(tries < 10 && ret != 0)
|
||||
{
|
||||
EXI_ProbeReset ();
|
||||
ret = CARD_Mount (cslot, &SysArea, NULL);
|
||||
VIDEO_WaitVSync ();
|
||||
EXI_ProbeReset();
|
||||
ret = CARD_Mount (slot, SysArea, NULL);
|
||||
VIDEO_WaitVSync();
|
||||
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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* TestCard
|
||||
* TestMC
|
||||
*
|
||||
* 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
|
||||
#ifdef HW_RVL
|
||||
return false;
|
||||
#endif
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("FCEU", "00");
|
||||
bool ret = false;
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
if (MountCard(slot, silent, (u8 *)SysArea) == 0)
|
||||
// Try to mount the card
|
||||
if (MountMC(slot, silent) == 0)
|
||||
{
|
||||
// Mount successful!
|
||||
if(!silent)
|
||||
{
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Mounted Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Mounted Slot B Memory Card!");
|
||||
}
|
||||
CARD_Unmount (slot);
|
||||
return true;
|
||||
ret = true;
|
||||
}
|
||||
free(SysArea);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
{
|
||||
if(!silent)
|
||||
{
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
||||
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);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
// 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)
|
||||
{
|
||||
card_file CardFile;
|
||||
unsigned char verifbuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||
unsigned char verifybuffer[65536] ATTRIBUTE_ALIGN (32);
|
||||
int CardError;
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
char msg[80];
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("FCEU", "00");
|
||||
memset (verifybuffer, 0, 65536);
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
// 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);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
ErrorPrompt("Unable to open file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks = CardFile.len;
|
||||
|
||||
if (blocks < SectorSize)
|
||||
@ -164,38 +186,26 @@ VerifyMCFile (char *buf, int slot, char *filename, int datasize)
|
||||
if (blocks > (unsigned int)datasize)
|
||||
blocks = datasize;
|
||||
|
||||
memset (verifbuffer, 0, 65536);
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CARD_Read (&CardFile, verifbuffer, SectorSize, bytesread);
|
||||
if ( memcmp (buf + bytesread, verifbuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||
CardError = CARD_Read (&CardFile, verifybuffer, SectorSize, bytesread);
|
||||
if (CardError || memcmp (buf + bytesread, verifybuffer, (unsigned int)bytesleft < SectorSize ? bytesleft : SectorSize) )
|
||||
{
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("File did not verify!");
|
||||
return 0;
|
||||
bytesread = 0;
|
||||
ErrorPrompt("File integrity could not be verified!");
|
||||
break;
|
||||
}
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
bytesread += SectorSize;
|
||||
|
||||
sprintf (msg, "Verified %d of %d bytes", bytesread, blocks);
|
||||
ShowProgress (msg, bytesread, blocks);
|
||||
ShowProgress ("Verifying...", bytesread, blocks);
|
||||
}
|
||||
CARD_Close (&CardFile);
|
||||
CARD_Unmount (slot);
|
||||
|
||||
return 1;
|
||||
CancelAction();
|
||||
}
|
||||
else
|
||||
if (slot == CARD_SLOTA)
|
||||
WaitPrompt("Unable to Mount Slot A Memory Card!");
|
||||
else
|
||||
WaitPrompt("Unable to Mount Slot B Memory Card!");
|
||||
|
||||
return 0;
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -212,29 +222,24 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
||||
int bytesleft = 0;
|
||||
int bytesread = 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("FCEU", "00");
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
// Try to mount the card
|
||||
CardError = MountMC(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
// Get Sector Size
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
if (!CardFileExists (filename, slot))
|
||||
{
|
||||
if (!silent)
|
||||
WaitPrompt("Unable to open file");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset (&CardFile, 0, sizeof (CardFile));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
if(!silent)
|
||||
ErrorPrompt("Unable to open file!");
|
||||
}
|
||||
else
|
||||
{
|
||||
blocks = CardFile.len;
|
||||
|
||||
if (blocks < SectorSize)
|
||||
@ -243,25 +248,34 @@ LoadMCFile (char *buf, int slot, char *filename, bool silent)
|
||||
if (blocks % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
memset (buf, 0, 0x22000);
|
||||
|
||||
bytesleft = blocks;
|
||||
bytesread = 0;
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CARD_Read (&CardFile, buf + bytesread, SectorSize, bytesread);
|
||||
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);
|
||||
CARD_Unmount (slot);
|
||||
CancelAction();
|
||||
}
|
||||
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!");
|
||||
|
||||
// discard save icon and comments
|
||||
memmove(buf, buf+sizeof(saveicon)+64, bytesread);
|
||||
bytesread -= (sizeof(saveicon)+64);
|
||||
|
||||
free(SysArea);
|
||||
return bytesread;
|
||||
}
|
||||
|
||||
@ -277,99 +291,59 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
||||
int CardError;
|
||||
unsigned int blocks;
|
||||
unsigned int SectorSize;
|
||||
char msg[80];
|
||||
int byteswritten = 0;
|
||||
int bytesleft = 0;
|
||||
|
||||
if(datasize <= 0)
|
||||
return 0;
|
||||
|
||||
/*** Initialize Card System ***/
|
||||
u8 SysArea[CARD_WORKAREA] ATTRIBUTE_ALIGN (32);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
CARD_Init ("FCEU", "00");
|
||||
// add save icon and comments
|
||||
memmove(buf+sizeof(saveicon)+64, buf, datasize);
|
||||
memcpy(buf, saveicon, sizeof(saveicon));
|
||||
memcpy(buf+sizeof(saveicon), savecomments, 64);
|
||||
datasize += (sizeof(saveicon)+64);
|
||||
|
||||
/*** Try to mount the card ***/
|
||||
CardError = MountCard(slot, NOTSILENT, (u8 *)SysArea);
|
||||
// Try to mount the card
|
||||
CardError = MountMC(slot, NOTSILENT);
|
||||
|
||||
if (CardError == 0)
|
||||
{
|
||||
/*** Get Sector Size ***/
|
||||
// Get Sector Size
|
||||
CARD_GetSectorSize (slot, &SectorSize);
|
||||
|
||||
/*** Calculate number of blocks required ***/
|
||||
// Calculate number of blocks required
|
||||
blocks = (datasize / SectorSize) * SectorSize;
|
||||
if (datasize % SectorSize)
|
||||
blocks += SectorSize;
|
||||
|
||||
/*** Does this file exist ? ***/
|
||||
if (CardFileExists (filename, slot))
|
||||
{
|
||||
/*** Try to open the file ***/
|
||||
// Delete existing file (if present)
|
||||
memset(&CardStatus, 0, sizeof(card_stat));
|
||||
CardError = CARD_Open (slot, filename, &CardFile);
|
||||
if (CardError)
|
||||
{
|
||||
CARD_Unmount (slot);
|
||||
WaitPrompt("Unable to open card file!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (s32)blocks > CardFile.len ) /*** new data is longer ***/
|
||||
if(CardError == 0)
|
||||
{
|
||||
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;
|
||||
ErrorPrompt("Unable to delete existing file!");
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/*** Create new, longer file ***/
|
||||
// Create new file
|
||||
memset(&CardStatus, 0, sizeof(card_stat));
|
||||
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!");
|
||||
if (CardError == CARD_ERROR_INSSPACE)
|
||||
ErrorPrompt("Insufficient space to create file!");
|
||||
else
|
||||
WaitPrompt("Unable to create card file!");
|
||||
return 0;
|
||||
}
|
||||
ErrorPrompt("Unable to create card file!");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*** Now, have an open file handle, ready to send out the data ***/
|
||||
// Now, have an open file handle, ready to send out the data
|
||||
CARD_GetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
CardStatus.icon_addr = 0x0;
|
||||
CardStatus.icon_fmt = 2;
|
||||
@ -377,40 +351,43 @@ SaveMCFile (char *buf, int slot, char *filename, int datasize, bool silent)
|
||||
CardStatus.comment_addr = 2048;
|
||||
CARD_SetStatus (slot, CardFile.filenum, &CardStatus);
|
||||
|
||||
int byteswritten = 0;
|
||||
int bytesleft = blocks;
|
||||
bytesleft = blocks;
|
||||
|
||||
while (bytesleft > 0)
|
||||
{
|
||||
CardError =
|
||||
CARD_Write (&CardFile, buf + byteswritten,
|
||||
SectorSize, byteswritten);
|
||||
CARD_Write (&CardFile, buf + byteswritten, SectorSize, byteswritten);
|
||||
|
||||
if(CardError)
|
||||
{
|
||||
ErrorPrompt("Error writing file!");
|
||||
byteswritten = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
bytesleft -= SectorSize;
|
||||
byteswritten += SectorSize;
|
||||
|
||||
sprintf (msg, "Wrote %d of %d bytes", byteswritten, blocks);
|
||||
ShowProgress (msg, byteswritten, blocks);
|
||||
ShowProgress ("Saving...", byteswritten, blocks);
|
||||
}
|
||||
|
||||
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
|
||||
because the file could be longer due to past writes ***/
|
||||
if ( VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||
return byteswritten;
|
||||
else
|
||||
return 0;
|
||||
// Verify the written file
|
||||
if (!VerifyMCFile (buf, slot, filename, byteswritten) )
|
||||
byteswritten = 0;
|
||||
}
|
||||
else
|
||||
return byteswritten;
|
||||
done:
|
||||
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
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* memcardop.h
|
||||
*
|
||||
* Memory Card routines
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _MEMCARDOP_H_
|
||||
#define _MEMCARDOP_H_
|
||||
#ifndef _MEMCARDOP_
|
||||
#define _MEMCARDOP_
|
||||
|
||||
int ParseMCDirectory (int slot);
|
||||
int LoadMCFile (char *buf, int slot, char *filename, 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
|
||||
|
3774
source/ngc/menu.cpp
3774
source/ngc/menu.cpp
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* menu.h
|
||||
*
|
||||
@ -10,9 +10,36 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _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
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "miniunz.h"
|
||||
|
||||
#include "fceugx.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
#include "fileop.h"
|
||||
#include "http.h"
|
||||
|
||||
@ -146,12 +146,12 @@ bool DownloadUpdate()
|
||||
if(unzipResult)
|
||||
{
|
||||
result = true;
|
||||
WaitPrompt("Update successful!");
|
||||
InfoPrompt("Update successful!");
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
WaitPrompt("Update failed!");
|
||||
InfoPrompt("Update failed!");
|
||||
}
|
||||
|
||||
updateFound = false; // updating is finished (successful or not!)
|
||||
@ -193,7 +193,7 @@ void InitializeNetwork(bool silent)
|
||||
{
|
||||
char msg[150];
|
||||
sprintf(msg, "Unable to initialize network (Error #: %i)", initResult);
|
||||
WaitPrompt(msg);
|
||||
ErrorPrompt(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,7 +201,7 @@ void InitializeNetwork(bool silent)
|
||||
void CloseShare()
|
||||
{
|
||||
if(networkShareInit)
|
||||
smbClose();
|
||||
smbClose("smb");
|
||||
networkShareInit = false;
|
||||
networkInit = false; // trigger a network reinit
|
||||
}
|
||||
@ -242,7 +242,7 @@ ConnectShare (bool silent)
|
||||
sprintf(msg, "Share IP is blank.");
|
||||
|
||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||
WaitPrompt(msg2);
|
||||
ErrorPrompt(msg2);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -268,7 +268,7 @@ ConnectShare (bool silent)
|
||||
}
|
||||
|
||||
if(!networkShareInit && !silent)
|
||||
WaitPrompt ("Failed to connect to network share.");
|
||||
ErrorPrompt ("Failed to connect to network share.");
|
||||
}
|
||||
|
||||
return networkShareInit;
|
||||
|
@ -10,7 +10,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "fceugx.h"
|
||||
@ -18,7 +17,10 @@
|
||||
#include "gcaudio.h"
|
||||
#include "menu.h"
|
||||
#include "gcvideo.h"
|
||||
#include "filesel.h"
|
||||
#include "filebrowser.h"
|
||||
#include "button_mapping.h"
|
||||
#include "gui/gui.h"
|
||||
#include "fceuload.h"
|
||||
|
||||
extern "C" {
|
||||
#include "driver.h"
|
||||
@ -27,7 +29,12 @@ extern "C" {
|
||||
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;
|
||||
void *InputDPR;
|
||||
@ -35,11 +42,9 @@ void *InputDPR;
|
||||
static INPUTC *zapperdata[2];
|
||||
static unsigned int myzappers[2][3];
|
||||
|
||||
unsigned int nespadmap[11]; // Original NES controller buttons
|
||||
unsigned int gcpadmap[11]; // Gamecube controller Padmap
|
||||
unsigned int wmpadmap[11]; // Wiimote Padmap
|
||||
unsigned int ccpadmap[11]; // Classic Controller Padmap
|
||||
unsigned int ncpadmap[11]; // Nunchuk + wiimote Padmap
|
||||
u32 nespadmap[11]; // Original NES controller buttons
|
||||
u32 zapperpadmap[11]; // Original NES Zapper controller buttons
|
||||
u32 btnmap[2][4][12]; // button mapping
|
||||
|
||||
void ResetControls()
|
||||
{
|
||||
@ -62,84 +67,84 @@ void ResetControls()
|
||||
|
||||
/*** Gamecube controller Padmap ***/
|
||||
i=0;
|
||||
gcpadmap[i++] = PAD_BUTTON_B;
|
||||
gcpadmap[i++] = PAD_BUTTON_A;
|
||||
gcpadmap[i++] = PAD_BUTTON_Y;
|
||||
gcpadmap[i++] = PAD_BUTTON_X;
|
||||
gcpadmap[i++] = PAD_TRIGGER_Z;
|
||||
gcpadmap[i++] = PAD_BUTTON_START;
|
||||
gcpadmap[i++] = PAD_BUTTON_UP;
|
||||
gcpadmap[i++] = PAD_BUTTON_DOWN;
|
||||
gcpadmap[i++] = PAD_BUTTON_LEFT;
|
||||
gcpadmap[i++] = PAD_BUTTON_RIGHT;
|
||||
gcpadmap[i++] = PAD_TRIGGER_L;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_B;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_A;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_Y;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_X;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_TRIGGER_Z;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_START;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_UP;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_DOWN;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_LEFT;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_BUTTON_RIGHT;
|
||||
btnmap[CTRL_PAD][CTRLR_GCPAD][i++] = PAD_TRIGGER_L;
|
||||
|
||||
/*** Wiimote Padmap ***/
|
||||
i=0;
|
||||
wmpadmap[i++] = WPAD_BUTTON_1;
|
||||
wmpadmap[i++] = WPAD_BUTTON_2;
|
||||
wmpadmap[i++] = 0;
|
||||
wmpadmap[i++] = 0;
|
||||
wmpadmap[i++] = WPAD_BUTTON_MINUS;
|
||||
wmpadmap[i++] = WPAD_BUTTON_PLUS;
|
||||
wmpadmap[i++] = WPAD_BUTTON_RIGHT;
|
||||
wmpadmap[i++] = WPAD_BUTTON_LEFT;
|
||||
wmpadmap[i++] = WPAD_BUTTON_UP;
|
||||
wmpadmap[i++] = WPAD_BUTTON_DOWN;
|
||||
wmpadmap[i++] = WPAD_BUTTON_A;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_1;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_2;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = 0;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = 0;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_MINUS;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_PLUS;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_RIGHT;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_LEFT;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_UP;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_DOWN;
|
||||
btnmap[CTRL_PAD][CTRLR_WIIMOTE][i++] = WPAD_BUTTON_A;
|
||||
|
||||
/*** Classic Controller Padmap ***/
|
||||
i=0;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_B;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_X;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_A;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||
ccpadmap[i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_Y;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_B;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_X;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_A;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_MINUS;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_PLUS;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_UP;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_DOWN;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_LEFT;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_RIGHT;
|
||||
btnmap[CTRL_PAD][CTRLR_CLASSIC][i++] = WPAD_CLASSIC_BUTTON_FULL_L;
|
||||
|
||||
/*** Nunchuk + wiimote Padmap ***/
|
||||
i=0;
|
||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||
ncpadmap[i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||
ncpadmap[i++] = 0;
|
||||
ncpadmap[i++] = 0;
|
||||
ncpadmap[i++] = WPAD_BUTTON_MINUS;
|
||||
ncpadmap[i++] = WPAD_BUTTON_PLUS;
|
||||
ncpadmap[i++] = WPAD_BUTTON_UP;
|
||||
ncpadmap[i++] = WPAD_BUTTON_DOWN;
|
||||
ncpadmap[i++] = WPAD_BUTTON_LEFT;
|
||||
ncpadmap[i++] = WPAD_BUTTON_RIGHT;
|
||||
ncpadmap[i++] = WPAD_BUTTON_A;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_C;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_NUNCHUK_BUTTON_Z;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = 0;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = 0;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_MINUS;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_PLUS;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_UP;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_DOWN;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_LEFT;
|
||||
btnmap[CTRL_PAD][CTRLR_NUNCHUK][i++] = WPAD_BUTTON_RIGHT;
|
||||
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
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Initialise Pads
|
||||
****************************************************************************/
|
||||
void InitialisePads()
|
||||
* SetControllers
|
||||
***************************************************************************/
|
||||
void SetControllers()
|
||||
{
|
||||
InputDPR = &JSReturn;
|
||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
||||
if(!romLoaded)
|
||||
return;
|
||||
|
||||
ToggleFourScore(GCSettings.FourScore, true);
|
||||
ToggleZapper(GCSettings.zapper, true);
|
||||
}
|
||||
if(GCSettings.Controller == CTRL_PAD4)
|
||||
FCEUI_DisableFourScore(false);
|
||||
else
|
||||
FCEUI_DisableFourScore(true);
|
||||
|
||||
void ToggleFourScore(int set, bool loaded)
|
||||
{
|
||||
if(loaded)
|
||||
FCEUI_DisableFourScore(set);
|
||||
}
|
||||
|
||||
void ToggleZapper(int set, bool loaded)
|
||||
{
|
||||
if(loaded)
|
||||
{
|
||||
// set defaults
|
||||
zapperdata[0]=NULL;
|
||||
zapperdata[1]=NULL;
|
||||
@ -151,12 +156,62 @@ void ToggleZapper(int set, bool loaded)
|
||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
||||
|
||||
if(set)
|
||||
if(GCSettings.Controller == CTRL_ZAPPER)
|
||||
{
|
||||
// enable Zapper
|
||||
zapperdata[set-1] = FCEU_InitZapper(set-1);
|
||||
FCEUI_SetInput(set-1, SI_ZAPPER, myzappers[set-1], 1);
|
||||
int z = 1;
|
||||
zapperdata[z] = FCEU_InitZapper(z);
|
||||
FCEUI_SetInput(z, SI_ZAPPER, myzappers[z], 1);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Initialise Pads
|
||||
***************************************************************************/
|
||||
void InitialisePads()
|
||||
{
|
||||
InputDPR = &JSReturn;
|
||||
FCEUI_SetInput(0, SI_GAMEPAD, InputDPR, 0);
|
||||
FCEUI_SetInput(1, SI_GAMEPAD, InputDPR, 0);
|
||||
SetControllers();
|
||||
}
|
||||
|
||||
#ifdef HW_RVL
|
||||
|
||||
/****************************************************************************
|
||||
* ShutoffRumble
|
||||
***************************************************************************/
|
||||
|
||||
void ShutoffRumble()
|
||||
{
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
WPAD_Rumble(i, 0);
|
||||
rumbleCount[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* DoRumble
|
||||
***************************************************************************/
|
||||
|
||||
void DoRumble(int i)
|
||||
{
|
||||
if(rumbleRequest[i] && rumbleCount[i] < 3)
|
||||
{
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
// hold zapper cursor positions
|
||||
static int pos_x = 0;
|
||||
@ -413,16 +469,16 @@ static unsigned char DecodeJoy( unsigned short pad )
|
||||
int 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
|
||||
|| ( (exp_type == WPAD_EXP_NONE) && (wp & wmpadmap[i]) ) // wiimote
|
||||
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & ccpadmap[i]) ) // classic controller
|
||||
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & ncpadmap[i]) ) // nunchuk + wiimote
|
||||
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_PAD][CTRLR_WIIMOTE][i]) ) // wiimote
|
||||
|| ( (exp_type == WPAD_EXP_CLASSIC) && (wp & btnmap[CTRL_PAD][CTRLR_CLASSIC][i]) ) // classic controller
|
||||
|| ( (exp_type == WPAD_EXP_NUNCHUK) && (wp & btnmap[CTRL_PAD][CTRLR_NUNCHUK][i]) ) // nunchuk + wiimote
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
@ -471,18 +527,16 @@ static unsigned char DecodeJoy( unsigned short pad )
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
// is trigger pressed?
|
||||
if ( (jp & PAD_BUTTON_A) // gamecube controller
|
||||
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][0]) // gamecube controller
|
||||
#ifdef HW_RVL
|
||||
|| (wp & WPAD_BUTTON_A) // wiimote
|
||||
|| (wp & WPAD_BUTTON_B)
|
||||
|| (wp & WPAD_CLASSIC_BUTTON_A) // classic controller
|
||||
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][0]) ) // wiimote
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@ -491,9 +545,9 @@ static unsigned char DecodeJoy( unsigned short pad )
|
||||
}
|
||||
|
||||
// VS zapper games
|
||||
if ( (jp & PAD_BUTTON_B) // gamecube controller
|
||||
if ( (jp & btnmap[CTRL_ZAPPER][CTRLR_GCPAD][1]) // gamecube controller
|
||||
#ifdef HW_RVL
|
||||
|| (wp & WPAD_BUTTON_1) // wiimote
|
||||
|| ( (exp_type == WPAD_EXP_NONE) && (wp & btnmap[CTRL_ZAPPER][CTRLR_WIIMOTE][1]) ) // wiimote
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@ -519,13 +573,11 @@ void GetJoy()
|
||||
short i;
|
||||
|
||||
s8 gc_px = PAD_SubStickX (0);
|
||||
s8 gc_py = PAD_SubStickY (0);
|
||||
u32 jp = PAD_ButtonsHeld (0); // gamecube controller button info
|
||||
|
||||
#ifdef HW_RVL
|
||||
s8 wm_sx = WPAD_StickX (0,1);
|
||||
s8 wm_sy = WPAD_StickY (0,1);
|
||||
u32 wm_pb = WPAD_ButtonsHeld (0); // wiimote / expansion button info
|
||||
u32 wm_pb = WPAD_ButtonsDown (0); // wiimote / expansion button info
|
||||
#endif
|
||||
|
||||
// Turbo mode
|
||||
@ -544,17 +596,6 @@ void GetJoy()
|
||||
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
|
||||
if ((gc_px < -70) ||
|
||||
((jp & PAD_BUTTON_START) && (jp & PAD_BUTTON_A) &&
|
||||
@ -565,7 +606,6 @@ void GetJoy()
|
||||
#endif
|
||||
)
|
||||
{
|
||||
StopAudio();
|
||||
ConfigRequested = 1;
|
||||
}
|
||||
else
|
||||
|
@ -13,6 +13,7 @@
|
||||
#define _PAD_H_
|
||||
|
||||
#include <gccore.h>
|
||||
#include <wiiuse/wpad.h>
|
||||
|
||||
#define PI 3.14159265f
|
||||
#define PADCAL 50
|
||||
@ -20,20 +21,58 @@
|
||||
#define RAPID_A 256
|
||||
#define RAPID_B 512
|
||||
|
||||
extern unsigned int gcpadmap[];
|
||||
extern unsigned int wmpadmap[];
|
||||
extern unsigned int ccpadmap[];
|
||||
extern unsigned int ncpadmap[];
|
||||
enum
|
||||
{
|
||||
TRIGGER_SIMPLE,
|
||||
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 ShutoffRumble();
|
||||
void DoRumble(int i);
|
||||
s8 WPAD_StickX(u8 chan,u8 right);
|
||||
s8 WPAD_StickY(u8 chan, u8 right);
|
||||
void InitialisePads();
|
||||
void GetJoy();
|
||||
void ToggleFourScore(int set, bool loaded);
|
||||
void ToggleZapper(int set, bool loaded);
|
||||
void ToggleFourScore(int set);
|
||||
void ToggleZapper(int set);
|
||||
void DrawCursor();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
* FCE Ultra 0.98.12
|
||||
* Nintendo Wii/Gamecube Port
|
||||
*
|
||||
* Tantric September 2008
|
||||
* Tantric 2008-2009
|
||||
*
|
||||
* preferences.c
|
||||
* preferences.cpp
|
||||
*
|
||||
* Preferences save/load preferences utilities
|
||||
****************************************************************************/
|
||||
@ -15,8 +15,10 @@
|
||||
#include <ogcsys.h>
|
||||
#include <mxml.h>
|
||||
|
||||
#include "images/saveicon.h"
|
||||
#include "menudraw.h"
|
||||
#include "fceuconfig.h"
|
||||
#include "button_mapping.h"
|
||||
#include "filebrowser.h"
|
||||
#include "menu.h"
|
||||
#include "memcardop.h"
|
||||
#include "fileop.h"
|
||||
#include "fceugx.h"
|
||||
@ -108,25 +110,6 @@ static const char * XMLSaveCallback(mxml_node_t *node, int where)
|
||||
static int
|
||||
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");
|
||||
mxmlSetWrapMargin(0); // disable line wrapping
|
||||
|
||||
@ -152,11 +135,10 @@ preparePrefsData (int method)
|
||||
createXMLSetting("smbuser", "Share Username", GCSettings.smbuser);
|
||||
createXMLSetting("smbpwd", "Share Password", GCSettings.smbpwd);
|
||||
|
||||
createXMLSection("Emulation", "Emulation Settings");
|
||||
createXMLSection("Video", "Video Settings");
|
||||
|
||||
createXMLSetting("currpal", "Palette", toStr(GCSettings.currpal));
|
||||
createXMLSetting("timing", "Timing", toStr(GCSettings.timing));
|
||||
createXMLSetting("Zoom", "Zoom On/Off", toStr(GCSettings.Zoom));
|
||||
createXMLSetting("ZoomLevel", "Zoom Level", FtoStr(GCSettings.ZoomLevel));
|
||||
createXMLSetting("render", "Video Filtering", toStr(GCSettings.render));
|
||||
createXMLSetting("widescreen", "Aspect Ratio Correction", toStr(GCSettings.widescreen));
|
||||
@ -164,15 +146,24 @@ preparePrefsData (int method)
|
||||
createXMLSetting("xshift", "Horizontal Video Shift", toStr(GCSettings.xshift));
|
||||
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");
|
||||
|
||||
createXMLSetting("FourScore", "Four Score", toStr(GCSettings.FourScore));
|
||||
createXMLSetting("zapper", "Zapper", toStr(GCSettings.zapper));
|
||||
createXMLSetting("Controller", "Controller", toStr(GCSettings.Controller));
|
||||
createXMLSetting("crosshair", "Zapper Crosshair", toStr(GCSettings.crosshair));
|
||||
createXMLController(gcpadmap, "gcpadmap", "GameCube Pad");
|
||||
createXMLController(wmpadmap, "wmpadmap", "Wiimote");
|
||||
createXMLController(ccpadmap, "ccpadmap", "Classic Controller");
|
||||
createXMLController(ncpadmap, "ncpadmap", "Nunchuk");
|
||||
|
||||
createXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad", "NES Pad - GameCube Controller");
|
||||
createXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote", "NES Pad - Wiimote");
|
||||
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);
|
||||
|
||||
@ -216,7 +207,6 @@ static void loadXMLSetting(float * var, const char * name)
|
||||
}
|
||||
|
||||
static void loadXMLController(unsigned int controller[], const char * name)
|
||||
|
||||
{
|
||||
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
||||
|
||||
@ -241,16 +231,8 @@ static bool
|
||||
decodePrefsData (int method)
|
||||
{
|
||||
bool result = false;
|
||||
int offset = 0;
|
||||
|
||||
// skip save icon and comments for Memory Card saves
|
||||
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);
|
||||
xml = mxmlLoadString(NULL, (char *)savebuffer, MXML_TEXT_CALLBACK);
|
||||
|
||||
if(xml)
|
||||
{
|
||||
@ -305,11 +287,10 @@ decodePrefsData (int method)
|
||||
loadXMLSetting(GCSettings.smbuser, "smbuser", sizeof(GCSettings.smbuser));
|
||||
loadXMLSetting(GCSettings.smbpwd, "smbpwd", sizeof(GCSettings.smbpwd));
|
||||
|
||||
// Emulation Settings
|
||||
// Video Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.currpal, "currpal");
|
||||
loadXMLSetting(&GCSettings.timing, "timing");
|
||||
loadXMLSetting(&GCSettings.Zoom, "Zoom");
|
||||
loadXMLSetting(&GCSettings.ZoomLevel, "ZoomLevel");
|
||||
loadXMLSetting(&GCSettings.render, "render");
|
||||
loadXMLSetting(&GCSettings.widescreen, "widescreen");
|
||||
@ -317,15 +298,23 @@ decodePrefsData (int method)
|
||||
loadXMLSetting(&GCSettings.xshift, "xshift");
|
||||
loadXMLSetting(&GCSettings.yshift, "yshift");
|
||||
|
||||
// Menu Settings
|
||||
|
||||
loadXMLSetting(&GCSettings.WiimoteOrientation, "WiimoteOrientation");
|
||||
loadXMLSetting(&GCSettings.ExitAction, "ExitAction");
|
||||
loadXMLSetting(&GCSettings.MusicVolume, "MusicVolume");
|
||||
loadXMLSetting(&GCSettings.SFXVolume, "SFXVolume");
|
||||
|
||||
// Controller Settings
|
||||
loadXMLSetting(&GCSettings.FourScore, "FSDisable");
|
||||
loadXMLSetting(&GCSettings.zapper, "zapper");
|
||||
loadXMLSetting(&GCSettings.Controller, "Controller");
|
||||
loadXMLSetting(&GCSettings.crosshair, "crosshair");
|
||||
|
||||
loadXMLController(gcpadmap, "gcpadmap");
|
||||
loadXMLController(wmpadmap, "wmpadmap");
|
||||
loadXMLController(ccpadmap, "ccpadmap");
|
||||
loadXMLController(ncpadmap, "ncpadmap");
|
||||
loadXMLController(btnmap[CTRL_PAD][CTRLR_GCPAD], "btnmap_pad_gcpad");
|
||||
loadXMLController(btnmap[CTRL_PAD][CTRLR_WIIMOTE], "btnmap_pad_wiimote");
|
||||
loadXMLController(btnmap[CTRL_PAD][CTRLR_CLASSIC], "btnmap_pad_classic");
|
||||
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);
|
||||
}
|
||||
@ -347,23 +336,40 @@ SavePrefs (bool silent)
|
||||
// is the method preferences will be loaded from by default
|
||||
int method = autoSaveMethod(silent);
|
||||
|
||||
if(method == METHOD_AUTO)
|
||||
return false;
|
||||
|
||||
if(!MakeFilePath(filepath, FILE_PREF, method))
|
||||
return false;
|
||||
|
||||
if (!silent)
|
||||
ShowAction ("Saving preferences...");
|
||||
|
||||
FixInvalidSettings();
|
||||
|
||||
AllocSaveBuffer ();
|
||||
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);
|
||||
|
||||
FreeSaveBuffer ();
|
||||
|
||||
CancelAction();
|
||||
|
||||
if (offset > 0)
|
||||
{
|
||||
if (!silent)
|
||||
WaitPrompt ("Preferences saved");
|
||||
InfoPrompt ("Preferences saved");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -398,20 +404,29 @@ LoadPrefsFromMethod (int method)
|
||||
* Load Preferences
|
||||
* Checks sources consecutively until we find a preference file
|
||||
***************************************************************************/
|
||||
static bool prefLoaded = false;
|
||||
|
||||
bool LoadPrefs()
|
||||
{
|
||||
ShowAction ("Loading preferences...");
|
||||
if(prefLoaded) // already attempted loading
|
||||
return true;
|
||||
|
||||
bool prefFound = false;
|
||||
if(ChangeInterface(METHOD_SD, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SD);
|
||||
if(!prefFound && ChangeInterface(METHOD_USB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_USB);
|
||||
if(!prefFound && TestCard(CARD_SLOTA, SILENT))
|
||||
if(!prefFound && TestMC(CARD_SLOTA, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTA);
|
||||
if(!prefFound && TestCard(CARD_SLOTB, SILENT))
|
||||
if(!prefFound && TestMC(CARD_SLOTB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_MC_SLOTB);
|
||||
if(!prefFound && ChangeInterface(METHOD_SMB, SILENT))
|
||||
prefFound = LoadPrefsFromMethod(METHOD_SMB);
|
||||
|
||||
prefLoaded = true; // attempted to load preferences
|
||||
|
||||
if(prefFound)
|
||||
FixInvalidSettings();
|
||||
|
||||
return prefFound;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <utime.h>
|
||||
|
||||
#include "unzip.h"
|
||||
#include "menudraw.h"
|
||||
#include "menu.h"
|
||||
|
||||
#define CASESENSITIVITY (0)
|
||||
#define WRITEBUFFERSIZE (1024*256)
|
||||
|
Loading…
Reference in New Issue
Block a user