mirror of
https://github.com/dborth/fceugx.git
synced 2024-10-31 22:45:05 +01:00
Fix compilation errors with latest libOGC/devkitPPC
(Partially ported from snes9xgx: a417745817
)
This commit is contained in:
parent
da54d31681
commit
28e304aeb5
@ -47,15 +47,16 @@
|
|||||||
|
|
||||||
#include "fceultra/types.h"
|
#include "fceultra/types.h"
|
||||||
|
|
||||||
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int32 Count);
|
||||||
void FCEUD_UpdatePulfrich(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_UpdatePulfrich(uint8 *XBuf, int32 *Buffer, int32 Count);
|
||||||
void FCEUD_UpdateLeft(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_UpdateLeft(uint8 *XBuf, int32 *Buffer, int32 Count);
|
||||||
void FCEUD_UpdateRight(uint8 *XBuf, int32 *Buffer, int Count);
|
void FCEUD_UpdateRight(uint8 *XBuf, int32 *Buffer, int32 Count);
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#ifdef USE_VM
|
#ifdef USE_VM
|
||||||
#include "utils/vm/vm.h"
|
#include "utils/vm/vm.h"
|
||||||
#endif
|
#endif
|
||||||
|
extern char* strcasestr(const char *, const char *);
|
||||||
extern void __exception_setreload(int t);
|
extern void __exception_setreload(int t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +293,7 @@ bool SaneIOS(u32 ios)
|
|||||||
static bool gecko = false;
|
static bool gecko = false;
|
||||||
static mutex_t gecko_mutex = 0;
|
static mutex_t gecko_mutex = 0;
|
||||||
|
|
||||||
static ssize_t __out_write(struct _reent *r, int fd, const char *ptr, size_t len)
|
static ssize_t __out_write(struct _reent *r, void* fd, const char *ptr, size_t len)
|
||||||
{
|
{
|
||||||
if (!gecko || len == 0)
|
if (!gecko || len == 0)
|
||||||
return len;
|
return len;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#ifndef _FCEUGX_H_
|
#ifndef _FCEUGX_H_
|
||||||
#define _FCEUGX_H_
|
#define _FCEUGX_H_
|
||||||
|
|
||||||
|
#define MAXPATHLEN 1024
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "fceultra/driver.h"
|
#include "fceultra/driver.h"
|
||||||
|
@ -17,14 +17,14 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned char uint8 ;
|
typedef uint8_t uint8 ;
|
||||||
typedef signed char int8 ;
|
typedef int8_t int8 ;
|
||||||
|
|
||||||
typedef unsigned short uint16 ;
|
typedef uint16_t uint16 ;
|
||||||
typedef signed short int16 ;
|
typedef int16_t int16 ;
|
||||||
|
|
||||||
typedef unsigned int uint32 ;
|
typedef uint32_t uint32 ;
|
||||||
typedef signed int int32 ;
|
typedef int32_t int32 ;
|
||||||
|
|
||||||
#define PI 3.14159265358979323846
|
#define PI 3.14159265358979323846
|
||||||
|
|
||||||
|
@ -240,7 +240,7 @@ void setchr2r(int r, uint32 A, uint32 V) {
|
|||||||
PPUCHRRAM &= ~(3 << (A >> 10));
|
PPUCHRRAM &= ~(3 << (A >> 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setchr4r(int r, unsigned int A, unsigned int V) {
|
void setchr4r(int r, uint32 A, uint32 V) {
|
||||||
if (!CHRptr[r]) return;
|
if (!CHRptr[r]) return;
|
||||||
FCEUPPU_LineUpdate();
|
FCEUPPU_LineUpdate();
|
||||||
V &= CHRmask4[r];
|
V &= CHRmask4[r];
|
||||||
|
@ -66,21 +66,21 @@ void setprg8(uint32 A, uint32 V);
|
|||||||
void setprg16(uint32 A, uint32 V);
|
void setprg16(uint32 A, uint32 V);
|
||||||
void setprg32(uint32 A, uint32 V);
|
void setprg32(uint32 A, uint32 V);
|
||||||
|
|
||||||
void setprg2r(int r, unsigned int A, unsigned int V);
|
void setprg2r(int r, uint32 A, uint32 V);
|
||||||
void setprg4r(int r, unsigned int A, unsigned int V);
|
void setprg4r(int r, uint32 A, uint32 V);
|
||||||
void setprg8r(int r, unsigned int A, unsigned int V);
|
void setprg8r(int r, uint32 A, uint32 V);
|
||||||
void setprg16r(int r, unsigned int A, unsigned int V);
|
void setprg16r(int r, uint32 A, uint32 V);
|
||||||
void setprg32r(int r, unsigned int A, unsigned int V);
|
void setprg32r(int r, uint32 A, uint32 V);
|
||||||
|
|
||||||
void setchr1r(int r, unsigned int A, unsigned int V);
|
void setchr1r(int r, uint32 A, uint32 V);
|
||||||
void setchr2r(int r, unsigned int A, unsigned int V);
|
void setchr2r(int r, uint32 A, uint32 V);
|
||||||
void setchr4r(int r, unsigned int A, unsigned int V);
|
void setchr4r(int r, uint32 A, uint32 V);
|
||||||
void setchr8r(int r, unsigned int V);
|
void setchr8r(int r, uint32 V);
|
||||||
|
|
||||||
void setchr1(unsigned int A, unsigned int V);
|
void setchr1(uint32 A, uint32 V);
|
||||||
void setchr2(unsigned int A, unsigned int V);
|
void setchr2(uint32 A, uint32 V);
|
||||||
void setchr4(unsigned int A, unsigned int V);
|
void setchr4(uint32 A, uint32 V);
|
||||||
void setchr8(unsigned int V);
|
void setchr8(uint32 V);
|
||||||
|
|
||||||
void setmirror(int t);
|
void setmirror(int t);
|
||||||
void setmirrorw(int a, int b, int c, int d);
|
void setmirrorw(int a, int b, int c, int d);
|
||||||
|
@ -331,7 +331,7 @@ int FileSortCallback(const void *f1, const void *f2)
|
|||||||
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
|
if(((BROWSERENTRY *)f1)->isdir && !(((BROWSERENTRY *)f2)->isdir)) return -1;
|
||||||
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
|
if(!(((BROWSERENTRY *)f1)->isdir) && ((BROWSERENTRY *)f2)->isdir) return 1;
|
||||||
|
|
||||||
return stricmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
|
return strcasecmp(((BROWSERENTRY *)f1)->filename, ((BROWSERENTRY *)f2)->filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -366,7 +366,7 @@ static bool IsValidROM()
|
|||||||
|
|
||||||
char * zippedFilename = NULL;
|
char * zippedFilename = NULL;
|
||||||
|
|
||||||
if(stricmp(p, ".zip") == 0 && !inSz)
|
if(strcasecmp(p, ".zip") == 0 && !inSz)
|
||||||
{
|
{
|
||||||
// we need to check the file extension of the first file in the archive
|
// we need to check the file extension of the first file in the archive
|
||||||
zippedFilename = GetFirstZipFilename ();
|
zippedFilename = GetFirstZipFilename ();
|
||||||
@ -380,12 +380,12 @@ static bool IsValidROM()
|
|||||||
if(p != NULL)
|
if(p != NULL)
|
||||||
{
|
{
|
||||||
if (
|
if (
|
||||||
stricmp(p, ".nes") == 0 ||
|
strcasecmp(p, ".nes") == 0 ||
|
||||||
stricmp(p, ".fds") == 0 ||
|
strcasecmp(p, ".fds") == 0 ||
|
||||||
stricmp(p, ".nsf") == 0 ||
|
strcasecmp(p, ".nsf") == 0 ||
|
||||||
stricmp(p, ".unf") == 0 ||
|
strcasecmp(p, ".unf") == 0 ||
|
||||||
stricmp(p, ".nez") == 0 ||
|
strcasecmp(p, ".nez") == 0 ||
|
||||||
stricmp(p, ".unif") == 0
|
strcasecmp(p, ".unif") == 0
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(zippedFilename) free(zippedFilename);
|
if(zippedFilename) free(zippedFilename);
|
||||||
@ -411,7 +411,7 @@ bool IsSz()
|
|||||||
char * p = strrchr(browserList[browser.selIndex].filename, '.');
|
char * p = strrchr(browserList[browser.selIndex].filename, '.');
|
||||||
|
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
if(stricmp(p, ".7z") == 0)
|
if(strcasecmp(p, ".7z") == 0)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -566,11 +566,11 @@ static bool ParseDirEntries()
|
|||||||
if(ext == NULL)
|
if(ext == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( stricmp(ext, "nes") != 0 && stricmp(ext, "fds") != 0 &&
|
if( strcasecmp(ext, "nes") != 0 && strcasecmp(ext, "fds") != 0 &&
|
||||||
stricmp(ext, "nsf") != 0 && stricmp(ext, "unf") != 0 &&
|
strcasecmp(ext, "nsf") != 0 && strcasecmp(ext, "unf") != 0 &&
|
||||||
stricmp(ext, "nez") != 0 && stricmp(ext, "unif") != 0 &&
|
strcasecmp(ext, "nez") != 0 && strcasecmp(ext, "unif") != 0 &&
|
||||||
stricmp(ext, "gba") != 0 &&
|
strcasecmp(ext, "gba") != 0 &&
|
||||||
stricmp(ext, "zip") != 0 && stricmp(ext, "7z") != 0)
|
strcasecmp(ext, "zip") != 0 && strcasecmp(ext, "7z") != 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,7 @@ void ShutdownAudio()
|
|||||||
* Puts incoming mono samples into mixbuffer
|
* Puts incoming mono samples into mixbuffer
|
||||||
* Splits mono samples into two channels (stereo)
|
* Splits mono samples into two channels (stereo)
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void PlaySound( int *Buffer, int count )
|
void PlaySound( int32 *Buffer, int count )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
u16 sample;
|
u16 sample;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
void InitialiseAudio();
|
void InitialiseAudio();
|
||||||
void ResetAudio();
|
void ResetAudio();
|
||||||
void PlaySound( int *Buffer, int samples );
|
void PlaySound( int32 *Buffer, int samples );
|
||||||
void SwitchAudioMode(int mode);
|
void SwitchAudioMode(int mode);
|
||||||
void ShutdownAudio();
|
void ShutdownAudio();
|
||||||
void UpdateSampleRate(int rate);
|
void UpdateSampleRate(int rate);
|
||||||
|
@ -34,7 +34,7 @@ int FDSSwitchRequested;
|
|||||||
/*** External 2D Video ***/
|
/*** External 2D Video ***/
|
||||||
/*** 2D Video Globals ***/
|
/*** 2D Video Globals ***/
|
||||||
GXRModeObj *vmode = NULL; // Graphics Mode Object
|
GXRModeObj *vmode = NULL; // Graphics Mode Object
|
||||||
static unsigned int *xfb[2] = { NULL, NULL }; // Framebuffers
|
static u32 *xfb[2] = { NULL, NULL }; // Framebuffers
|
||||||
static int whichfb = 0; // Frame buffer toggle
|
static int whichfb = 0; // Frame buffer toggle
|
||||||
int screenheight = 480;
|
int screenheight = 480;
|
||||||
int screenwidth = 640;
|
int screenwidth = 640;
|
||||||
|
@ -1,400 +1,400 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* FCE Ultra
|
* FCE Ultra
|
||||||
* Nintendo Wii/Gamecube Port
|
* Nintendo Wii/Gamecube Port
|
||||||
*
|
*
|
||||||
* Tantric December 2008
|
* Tantric December 2008
|
||||||
*
|
*
|
||||||
* networkop.cpp
|
* networkop.cpp
|
||||||
*
|
*
|
||||||
* Network and SMB support routines
|
* Network and SMB support routines
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <gccore.h>
|
#include <gccore.h>
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <ogc/lwp_watchdog.h>
|
#include <ogc/lwp_watchdog.h>
|
||||||
#include <smb.h>
|
#include <smb.h>
|
||||||
#include <mxml.h>
|
#include <mxml.h>
|
||||||
|
|
||||||
#include "fceugx.h"
|
#include "fceugx.h"
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "fileop.h"
|
#include "fileop.h"
|
||||||
#include "filebrowser.h"
|
#include "filebrowser.h"
|
||||||
#include "utils/http.h"
|
#include "utils/http.h"
|
||||||
#include "utils/unzip/unzip.h"
|
#include "utils/unzip/unzip.h"
|
||||||
#include "utils/unzip/miniunz.h"
|
#include "utils/unzip/miniunz.h"
|
||||||
|
|
||||||
static bool networkInit = false;
|
static bool networkInit = false;
|
||||||
static bool networkShareInit = false;
|
static bool networkShareInit = false;
|
||||||
char wiiIP[16] = { 0 };
|
char wiiIP[16] = { 0 };
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
static int netHalt = 0;
|
static int netHalt = 0;
|
||||||
static bool updateChecked = false; // true if checked for app update
|
static bool updateChecked = false; // true if checked for app update
|
||||||
static char updateURL[128]; // URL of app update
|
static char updateURL[128]; // URL of app update
|
||||||
bool updateFound = false; // true if an app update was found
|
bool updateFound = false; // true if an app update was found
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* UpdateCheck
|
* UpdateCheck
|
||||||
* Checks for an update for the application
|
* Checks for an update for the application
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
void UpdateCheck()
|
void UpdateCheck()
|
||||||
{
|
{
|
||||||
// we only check for an update if we have internet + SD/USB
|
// we only check for an update if we have internet + SD/USB
|
||||||
if(updateChecked || !networkInit)
|
if(updateChecked || !networkInit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!isMounted[DEVICE_SD] && !isMounted[DEVICE_USB])
|
if(!isMounted[DEVICE_SD] && !isMounted[DEVICE_USB])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
updateChecked = true;
|
updateChecked = true;
|
||||||
u8 tmpbuffer[256];
|
u8 tmpbuffer[256];
|
||||||
|
|
||||||
if (http_request("http://www.wiimc.org/files/fceugx-update.xml", NULL, tmpbuffer, 256, SILENT) <= 0)
|
if (http_request("http://www.wiimc.org/files/fceugx-update.xml", NULL, tmpbuffer, 256, SILENT) <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mxml_node_t *xml;
|
mxml_node_t *xml;
|
||||||
mxml_node_t *item;
|
mxml_node_t *item;
|
||||||
|
|
||||||
xml = mxmlLoadString(NULL, (char *)tmpbuffer, MXML_TEXT_CALLBACK);
|
xml = mxmlLoadString(NULL, (char *)tmpbuffer, MXML_TEXT_CALLBACK);
|
||||||
|
|
||||||
if(!xml)
|
if(!xml)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// check settings version
|
// check settings version
|
||||||
item = mxmlFindElement(xml, xml, "app", "version", NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "app", "version", NULL, MXML_DESCEND);
|
||||||
if(item) // a version entry exists
|
if(item) // a version entry exists
|
||||||
{
|
{
|
||||||
const char * version = mxmlElementGetAttr(item, "version");
|
const char * version = mxmlElementGetAttr(item, "version");
|
||||||
|
|
||||||
if(version && strlen(version) == 5)
|
if(version && strlen(version) == 5)
|
||||||
{
|
{
|
||||||
int verMajor = version[0] - '0';
|
int verMajor = version[0] - '0';
|
||||||
int verMinor = version[2] - '0';
|
int verMinor = version[2] - '0';
|
||||||
int verPoint = version[4] - '0';
|
int verPoint = version[4] - '0';
|
||||||
int curMajor = APPVERSION[0] - '0';
|
int curMajor = APPVERSION[0] - '0';
|
||||||
int curMinor = APPVERSION[2] - '0';
|
int curMinor = APPVERSION[2] - '0';
|
||||||
int curPoint = APPVERSION[4] - '0';
|
int curPoint = APPVERSION[4] - '0';
|
||||||
|
|
||||||
// check that the versioning is valid and is a newer version
|
// check that the versioning is valid and is a newer version
|
||||||
if((verMajor >= 0 && verMajor <= 9 &&
|
if((verMajor >= 0 && verMajor <= 9 &&
|
||||||
verMinor >= 0 && verMinor <= 9 &&
|
verMinor >= 0 && verMinor <= 9 &&
|
||||||
verPoint >= 0 && verPoint <= 9) &&
|
verPoint >= 0 && verPoint <= 9) &&
|
||||||
(verMajor > curMajor ||
|
(verMajor > curMajor ||
|
||||||
(verMajor == curMajor && verMinor > curMinor) ||
|
(verMajor == curMajor && verMinor > curMinor) ||
|
||||||
(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
|
(verMajor == curMajor && verMinor == curMinor && verPoint > curPoint)))
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "file", NULL, NULL, MXML_DESCEND);
|
||||||
if(item)
|
if(item)
|
||||||
{
|
{
|
||||||
const char * tmp = mxmlElementGetAttr(item, "url");
|
const char * tmp = mxmlElementGetAttr(item, "url");
|
||||||
if(tmp)
|
if(tmp)
|
||||||
{
|
{
|
||||||
snprintf(updateURL, 128, "%s", tmp);
|
snprintf(updateURL, 128, "%s", tmp);
|
||||||
updateFound = true;
|
updateFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mxmlDelete(xml);
|
mxmlDelete(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool unzipArchive(char * zipfilepath, char * unzipfolderpath)
|
static bool unzipArchive(char * zipfilepath, char * unzipfolderpath)
|
||||||
{
|
{
|
||||||
unzFile uf = unzOpen(zipfilepath);
|
unzFile uf = unzOpen(zipfilepath);
|
||||||
if (uf==NULL)
|
if (uf==NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(chdir(unzipfolderpath)) // can't access dir
|
if(chdir(unzipfolderpath)) // can't access dir
|
||||||
{
|
{
|
||||||
makedir(unzipfolderpath); // attempt to make dir
|
makedir(unzipfolderpath); // attempt to make dir
|
||||||
if(chdir(unzipfolderpath)) // still can't access dir
|
if(chdir(unzipfolderpath)) // still can't access dir
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
extractZip(uf,0,1,0);
|
extractZip(uf,0,1,0);
|
||||||
|
|
||||||
unzCloseCurrentFile(uf);
|
unzCloseCurrentFile(uf);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadUpdate()
|
bool DownloadUpdate()
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if(updateURL[0] == 0 || appPath[0] == 0 || !ChangeInterface(appPath, NOTSILENT))
|
if(updateURL[0] == 0 || appPath[0] == 0 || !ChangeInterface(appPath, NOTSILENT))
|
||||||
{
|
{
|
||||||
ErrorPrompt("Update failed!");
|
ErrorPrompt("Update failed!");
|
||||||
updateFound = false; // updating is finished (successful or not!)
|
updateFound = false; // updating is finished (successful or not!)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop checking if devices were removed/inserted
|
// stop checking if devices were removed/inserted
|
||||||
// since we're saving a file
|
// since we're saving a file
|
||||||
HaltDeviceThread();
|
HaltDeviceThread();
|
||||||
|
|
||||||
int device;
|
int device;
|
||||||
FindDevice(appPath, &device);
|
FindDevice(appPath, &device);
|
||||||
|
|
||||||
char updateFile[50];
|
char updateFile[50];
|
||||||
sprintf(updateFile, "%s%s Update.zip", pathPrefix[device], APPNAME);
|
sprintf(updateFile, "%s%s Update.zip", pathPrefix[device], APPNAME);
|
||||||
|
|
||||||
FILE * hfile = fopen (updateFile, "wb");
|
FILE * hfile = fopen (updateFile, "wb");
|
||||||
|
|
||||||
if (hfile)
|
if (hfile)
|
||||||
{
|
{
|
||||||
if(http_request(updateURL, hfile, NULL, (1024*1024*10), NOTSILENT) > 0)
|
if(http_request(updateURL, hfile, NULL, (1024*1024*10), NOTSILENT) > 0)
|
||||||
{
|
{
|
||||||
fclose (hfile);
|
fclose (hfile);
|
||||||
result = unzipArchive(updateFile, (char *)pathPrefix[device]);
|
result = unzipArchive(updateFile, (char *)pathPrefix[device]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose (hfile);
|
fclose (hfile);
|
||||||
}
|
}
|
||||||
remove(updateFile); // delete update file
|
remove(updateFile); // delete update file
|
||||||
}
|
}
|
||||||
|
|
||||||
// go back to checking if devices were inserted/removed
|
// go back to checking if devices were inserted/removed
|
||||||
ResumeDeviceThread();
|
ResumeDeviceThread();
|
||||||
|
|
||||||
if(result)
|
if(result)
|
||||||
InfoPrompt("Update successful!");
|
InfoPrompt("Update successful!");
|
||||||
else
|
else
|
||||||
ErrorPrompt("Update failed!");
|
ErrorPrompt("Update failed!");
|
||||||
|
|
||||||
updateFound = false; // updating is finished (successful or not!)
|
updateFound = false; // updating is finished (successful or not!)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* InitializeNetwork
|
* InitializeNetwork
|
||||||
* Initializes the Wii/GameCube network interface
|
* Initializes the Wii/GameCube network interface
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static lwp_t networkthread = LWP_THREAD_NULL;
|
static lwp_t networkthread = LWP_THREAD_NULL;
|
||||||
static u8 netstack[32768] ATTRIBUTE_ALIGN (32);
|
static u8 netstack[32768] ATTRIBUTE_ALIGN (32);
|
||||||
|
|
||||||
static void * netcb (void *arg)
|
static void * netcb (void *arg)
|
||||||
{
|
{
|
||||||
s32 res=-1;
|
s32 res=-1;
|
||||||
int retry;
|
int retry;
|
||||||
int wait;
|
int wait;
|
||||||
static bool prevInit = false;
|
static bool prevInit = false;
|
||||||
|
|
||||||
while(netHalt != 2)
|
while(netHalt != 2)
|
||||||
{
|
{
|
||||||
retry = 5;
|
retry = 5;
|
||||||
|
|
||||||
while (retry>0 && (netHalt != 2))
|
while (retry>0 && (netHalt != 2))
|
||||||
{
|
{
|
||||||
if(prevInit)
|
if(prevInit)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
net_deinit();
|
net_deinit();
|
||||||
for(i=0; i < 400 && (netHalt != 2); i++) // 10 seconds to try to reset
|
for(i=0; i < 400 && (netHalt != 2); i++) // 10 seconds to try to reset
|
||||||
{
|
{
|
||||||
res = net_get_status();
|
res = net_get_status();
|
||||||
if(res != -EBUSY) // trying to init net so we can't kill the net
|
if(res != -EBUSY) // trying to init net so we can't kill the net
|
||||||
{
|
{
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
net_wc24cleanup(); //kill the net
|
net_wc24cleanup(); //kill the net
|
||||||
prevInit=false; // net_wc24cleanup is called only once
|
prevInit=false; // net_wc24cleanup is called only once
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
res = net_init_async(NULL, NULL);
|
res = net_init_async(NULL, NULL);
|
||||||
|
|
||||||
if(res != 0)
|
if(res != 0)
|
||||||
{
|
{
|
||||||
sleep(1);
|
sleep(1);
|
||||||
retry--;
|
retry--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = net_get_status();
|
res = net_get_status();
|
||||||
wait = 400; // only wait 8 sec
|
wait = 400; // only wait 8 sec
|
||||||
while (res == -EBUSY && wait > 0 && (netHalt != 2))
|
while (res == -EBUSY && wait > 0 && (netHalt != 2))
|
||||||
{
|
{
|
||||||
usleep(20000);
|
usleep(20000);
|
||||||
res = net_get_status();
|
res = net_get_status();
|
||||||
wait--;
|
wait--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(res==0) break;
|
if(res==0) break;
|
||||||
retry--;
|
retry--;
|
||||||
usleep(2000);
|
usleep(2000);
|
||||||
}
|
}
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
struct in_addr hostip;
|
struct in_addr hostip;
|
||||||
hostip.s_addr = net_gethostip();
|
hostip.s_addr = net_gethostip();
|
||||||
if (hostip.s_addr)
|
if (hostip.s_addr)
|
||||||
{
|
{
|
||||||
strcpy(wiiIP, inet_ntoa(hostip));
|
strcpy(wiiIP, inet_ntoa(hostip));
|
||||||
networkInit = true;
|
networkInit = true;
|
||||||
prevInit = true;
|
prevInit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(netHalt != 2) LWP_SuspendThread(networkthread);
|
if(netHalt != 2) LWP_SuspendThread(networkthread);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* StartNetworkThread
|
* StartNetworkThread
|
||||||
*
|
*
|
||||||
* Signals the network thread to resume, or creates a new thread
|
* Signals the network thread to resume, or creates a new thread
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void StartNetworkThread()
|
void StartNetworkThread()
|
||||||
{
|
{
|
||||||
netHalt = 0;
|
netHalt = 0;
|
||||||
|
|
||||||
if(networkthread == LWP_THREAD_NULL)
|
if(networkthread == LWP_THREAD_NULL)
|
||||||
LWP_CreateThread(&networkthread, netcb, NULL, netstack, 8192, 40);
|
LWP_CreateThread(&networkthread, netcb, NULL, netstack, 8192, 40);
|
||||||
else
|
else
|
||||||
LWP_ResumeThread(networkthread);
|
LWP_ResumeThread(networkthread);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* StopNetworkThread
|
* StopNetworkThread
|
||||||
*
|
*
|
||||||
* Signals the network thread to stop
|
* Signals the network thread to stop
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void StopNetworkThread()
|
void StopNetworkThread()
|
||||||
{
|
{
|
||||||
if(networkthread == LWP_THREAD_NULL || !LWP_ThreadIsSuspended(networkthread))
|
if(networkthread == LWP_THREAD_NULL || !LWP_ThreadIsSuspended(networkthread))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
netHalt = 2;
|
netHalt = 2;
|
||||||
LWP_ResumeThread(networkthread);
|
LWP_ResumeThread(networkthread);
|
||||||
|
|
||||||
// wait for thread to finish
|
// wait for thread to finish
|
||||||
LWP_JoinThread(networkthread, NULL);
|
LWP_JoinThread(networkthread, NULL);
|
||||||
networkthread = LWP_THREAD_NULL;
|
networkthread = LWP_THREAD_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool InitializeNetwork(bool silent)
|
bool InitializeNetwork(bool silent)
|
||||||
{
|
{
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
StopNetworkThread();
|
StopNetworkThread();
|
||||||
|
|
||||||
if(networkInit && net_gethostip() > 0)
|
if(networkInit && net_gethostip() > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
networkInit = false;
|
networkInit = false;
|
||||||
#else
|
#else
|
||||||
if(networkInit)
|
if(networkInit)
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int retry = 1;
|
int retry = 1;
|
||||||
|
|
||||||
while(retry)
|
while(retry)
|
||||||
{
|
{
|
||||||
ShowAction("Initializing network...");
|
ShowAction("Initializing network...");
|
||||||
|
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
u64 start = gettime();
|
u64 start = gettime();
|
||||||
StartNetworkThread();
|
StartNetworkThread();
|
||||||
|
|
||||||
while (!LWP_ThreadIsSuspended(networkthread))
|
while (!LWP_ThreadIsSuspended(networkthread))
|
||||||
{
|
{
|
||||||
usleep(50 * 1000);
|
usleep(50 * 1000);
|
||||||
|
|
||||||
if(diff_sec(start, gettime()) > 10) // wait for 10 seconds max for net init
|
if(diff_sec(start, gettime()) > 10) // wait for 10 seconds max for net init
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
networkInit = !(if_config(wiiIP, NULL, NULL, true) < 0);
|
networkInit = !(if_config(wiiIP, NULL, NULL, true, 10) < 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CancelAction();
|
CancelAction();
|
||||||
|
|
||||||
if(networkInit || silent)
|
if(networkInit || silent)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
retry = ErrorPromptRetry("Unable to initialize network!");
|
retry = ErrorPromptRetry("Unable to initialize network!");
|
||||||
#ifdef HW_RVL
|
#ifdef HW_RVL
|
||||||
if(networkInit && net_gethostip() > 0)
|
if(networkInit && net_gethostip() > 0)
|
||||||
#else
|
#else
|
||||||
if(networkInit)
|
if(networkInit)
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return networkInit;
|
return networkInit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseShare()
|
void CloseShare()
|
||||||
{
|
{
|
||||||
if(networkShareInit)
|
if(networkShareInit)
|
||||||
smbClose("smb");
|
smbClose("smb");
|
||||||
networkShareInit = false;
|
networkShareInit = false;
|
||||||
isMounted[DEVICE_SMB] = false;
|
isMounted[DEVICE_SMB] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Mount SMB Share
|
* Mount SMB Share
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConnectShare (bool silent)
|
ConnectShare (bool silent)
|
||||||
{
|
{
|
||||||
if(!InitializeNetwork(silent))
|
if(!InitializeNetwork(silent))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(networkShareInit)
|
if(networkShareInit)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
int retry = 1;
|
int retry = 1;
|
||||||
int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
|
int chkS = (strlen(GCSettings.smbshare) > 0) ? 0:1;
|
||||||
int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;
|
int chkI = (strlen(GCSettings.smbip) > 0) ? 0:1;
|
||||||
|
|
||||||
// check that all parameters have been set
|
// check that all parameters have been set
|
||||||
if(chkS + chkI > 0)
|
if(chkS + chkI > 0)
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
{
|
{
|
||||||
char msg[50];
|
char msg[50];
|
||||||
char msg2[100];
|
char msg2[100];
|
||||||
if(chkS + chkI > 1) // more than one thing is wrong
|
if(chkS + chkI > 1) // more than one thing is wrong
|
||||||
sprintf(msg, "Check settings.xml.");
|
sprintf(msg, "Check settings.xml.");
|
||||||
else if(chkS)
|
else if(chkS)
|
||||||
sprintf(msg, "Share name is blank.");
|
sprintf(msg, "Share name is blank.");
|
||||||
else if(chkI)
|
else if(chkI)
|
||||||
sprintf(msg, "Share IP is blank.");
|
sprintf(msg, "Share IP is blank.");
|
||||||
|
|
||||||
sprintf(msg2, "Invalid network settings - %s", msg);
|
sprintf(msg2, "Invalid network settings - %s", msg);
|
||||||
ErrorPrompt(msg2);
|
ErrorPrompt(msg2);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(retry)
|
while(retry)
|
||||||
{
|
{
|
||||||
if(!silent)
|
if(!silent)
|
||||||
ShowAction ("Connecting to network share...");
|
ShowAction ("Connecting to network share...");
|
||||||
|
|
||||||
if(smbInit(GCSettings.smbuser, GCSettings.smbpwd, GCSettings.smbshare, GCSettings.smbip))
|
if(smbInit(GCSettings.smbuser, GCSettings.smbpwd, GCSettings.smbshare, GCSettings.smbip))
|
||||||
networkShareInit = true;
|
networkShareInit = true;
|
||||||
|
|
||||||
if(networkShareInit || silent)
|
if(networkShareInit || silent)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
retry = ErrorPromptRetry("Failed to connect to network share.");
|
retry = ErrorPromptRetry("Failed to connect to network share.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!silent)
|
if(!silent)
|
||||||
CancelAction();
|
CancelAction();
|
||||||
|
|
||||||
return networkShareInit;
|
return networkShareInit;
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ static void createXMLSetting(const char * name, const char * description, const
|
|||||||
mxmlElementSetAttr(item, "description", description);
|
mxmlElementSetAttr(item, "description", description);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void createXMLController(unsigned int controller[], const char * name, const char * description)
|
static void createXMLController(u32 controller[], const char * name, const char * description)
|
||||||
{
|
{
|
||||||
item = mxmlNewElement(section, "controller");
|
item = mxmlNewElement(section, "controller");
|
||||||
mxmlElementSetAttr(item, "name", name);
|
mxmlElementSetAttr(item, "name", name);
|
||||||
@ -154,7 +154,9 @@ preparePrefsData ()
|
|||||||
|
|
||||||
createXMLSection("Menu", "Menu Settings");
|
createXMLSection("Menu", "Menu Settings");
|
||||||
|
|
||||||
|
#ifdef HW_RVL
|
||||||
createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
|
createXMLSetting("WiimoteOrientation", "Wiimote Orientation", toStr(GCSettings.WiimoteOrientation));
|
||||||
|
#endif
|
||||||
createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
|
createXMLSetting("ExitAction", "Exit Action", toStr(GCSettings.ExitAction));
|
||||||
createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
|
createXMLSetting("MusicVolume", "Music Volume", toStr(GCSettings.MusicVolume));
|
||||||
createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
|
createXMLSetting("SFXVolume", "Sound Effects Volume", toStr(GCSettings.SFXVolume));
|
||||||
@ -225,7 +227,7 @@ static void loadXMLSetting(float * var, const char * name)
|
|||||||
* Load XML elements into variables for a controller mapping
|
* Load XML elements into variables for a controller mapping
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static void loadXMLController(unsigned int controller[], const char * name)
|
static void loadXMLController(u32 controller[], const char * name)
|
||||||
{
|
{
|
||||||
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
item = mxmlFindElement(xml, xml, "controller", "name", name, MXML_DESCEND);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user