diff --git a/source/ngc/dvd.c b/source/ngc/dvd.c index 1d7db2a..9c111a8 100644 --- a/source/ngc/dvd.c +++ b/source/ngc/dvd.c @@ -22,7 +22,7 @@ #include "menudraw.h" #include "gcunzip.h" -#include "fceuconfig.h" +#include "fceugx.h" u64 dvddir = 0; // offset of currently selected file or folder int dvddirlength = 0; // length of currently selected file or folder diff --git a/source/ngc/fceuconfig.c b/source/ngc/fceuconfig.c index cd28f66..663e160 100644 --- a/source/ngc/fceuconfig.c +++ b/source/ngc/fceuconfig.c @@ -15,7 +15,7 @@ #include #include "common.h" -#include "fceuconfig.h" +#include "fceugx.h" struct SGCSettings GCSettings; diff --git a/source/ngc/fceuconfig.h b/source/ngc/fceuconfig.h index 98f5a3b..b46e174 100644 --- a/source/ngc/fceuconfig.h +++ b/source/ngc/fceuconfig.h @@ -15,65 +15,4 @@ void DefaultSettings (); -#define VERSIONNUM "2.0.6" -#define VERSIONSTR "FCE Ultra GX 2.0.6" -#define PREF_FILE_NAME "FCEUGX.xml" - -#define NOTSILENT 0 -#define SILENT 1 - -enum { - METHOD_AUTO, - METHOD_SD, - METHOD_USB, - METHOD_DVD, - METHOD_SMB, - METHOD_MC_SLOTA, - METHOD_MC_SLOTB -}; - -enum { - FILE_ROM, - FILE_RAM, - FILE_STATE, - FILE_FDSBIOS, - FILE_CHEAT, - FILE_PREF -}; - -struct SGCSettings{ - int AutoLoad; - int AutoSave; - int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB) - int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB - char LoadFolder[200]; // Path to game files - char SaveFolder[200]; // Path to save files - char CheatFolder[200]; // Path to cheat files - char gcip[16]; - char gwip[16]; - char mask[16]; - char smbip[16]; - char smbuser[20]; - char smbpwd[20]; - char smbgcid[20]; - char smbsvid[20]; - char smbshare[20]; - int Zoom; // 0 - off, 1 - on - float ZoomLevel; // zoom amount - int VerifySaves; - int render; // 0 - original, 1 - filtered, 2 - unfiltered - int widescreen; - int hideoverscan; - int currpal; - int timing; - int FSDisable; - int zapper; - int crosshair; - int slimit; -}; - -extern struct SGCSettings GCSettings; -extern int ConfigRequested; -extern int frameskip; - #endif diff --git a/source/ngc/fceugx.c b/source/ngc/fceugx.c index b02f2c0..5a5bbba 100644 --- a/source/ngc/fceugx.c +++ b/source/ngc/fceugx.c @@ -4,7 +4,7 @@ * * Tantric September 2008 * - * fceugc.c + * fceugx.c * * This file controls overall program flow. Most things start and end here! ****************************************************************************/ @@ -20,6 +20,7 @@ #include "types.h" +#include "fceugx.h" #include "fceuconfig.h" #include "fceuload.h" #include "fceustate.h" @@ -28,6 +29,7 @@ #include "menudraw.h" #include "menu.h" #include "preferences.h" +#include "fileop.h" #include "gcaudio.h" #include "gcvideo.h" #include "pad.h" @@ -38,6 +40,8 @@ unsigned char * nesrom = NULL; int ConfigRequested = 0; +int ShutdownRequested = 0; +int ResetRequested = 0; bool isWii; uint8 *xbsave=NULL; int frameskip = 0; @@ -45,11 +49,65 @@ int frameskip = 0; extern bool romLoaded; extern int cleanSFMDATA(); -extern void ResetNES(void); +extern void PowerNES(void); extern uint8 FDSBIOS[8192]; void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count); +/**************************************************************************** + * Shutdown / Reboot / Exit + ***************************************************************************/ + +#ifdef HW_DOL + #define PSOSDLOADID 0x7c6000a6 + int *psoid = (int *) 0x80001800; + void (*PSOReload) () = (void (*)()) 0x80001800; +#endif + +void Reboot() +{ + UnmountAllFAT(); +#ifdef HW_RVL + DI_Close(); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); +#else + #define SOFTRESET_ADR ((volatile u32*)0xCC003024) + *SOFTRESET_ADR = 0x00000000; +#endif +} + +void ExitToLoader() +{ + UnmountAllFAT(); + // Exit to Loader + #ifdef HW_RVL + DI_Close(); + exit(0); + #else // gamecube + if (psoid[0] == PSOSDLOADID) + PSOReload (); + #endif +} + +#ifdef HW_RVL +void ShutdownCB() +{ + ConfigRequested = 1; + ShutdownRequested = 1; +} +void ResetCB() +{ + ResetRequested = 1; +} +void ShutdownWii() +{ + UnmountAllFAT(); + DI_Close(); + SYS_ResetSystem(SYS_POWEROFF, 0, 0); +} +#endif + +#ifdef HW_DOL /**************************************************************************** * ipl_set_config * lowlevel Qoob Modchip disable @@ -73,6 +131,7 @@ void ipl_set_config(unsigned char c) exi[0] &= 0x405; //deselect IPL } +#endif /**************************************************************************** * main @@ -100,7 +159,15 @@ int main(int argc, char *argv[]) PAD_Init(); + // Wii Power/Reset buttons +#ifdef HW_RVL + WPAD_SetPowerButtonCallback((WPADShutdownCallback)ShutdownCB); + SYS_SetPowerCallback(ShutdownCB); + SYS_SetResetCallback(ResetCB); +#endif + InitGCVideo (); + ResetVideo_Menu (); // change to menu video mode /*** Initialise freetype ***/ if (FT_Init ()) @@ -119,9 +186,10 @@ int main(int argc, char *argv[]) nesrom = (unsigned char *)malloc(1024*1024*3); // 3 MB should be plenty /*** Minimal Emulation Loop ***/ - if ( !FCEUI_Initialize() ) { - printf("Unable to initialize system\n"); - return 1; + if ( !FCEUI_Initialize() ) + { + WaitPrompt((char *)"Unable to initialize FCE Ultra\n"); + ExitToLoader(); } FCEUI_SetGameGenie(0); // 0 - OFF, 1 - ON @@ -145,7 +213,11 @@ int main(int argc, char *argv[]) while (1) // main loop { - ResetVideo_Menu(); + #ifdef HW_RVL + if(ShutdownRequested) + ShutdownWii(); + #endif + MainMenu(selectedMenu); selectedMenu = 2; // return to game menu from now on @@ -174,8 +246,15 @@ int main(int argc, char *argv[]) FCEUD_Update(gfx, sound, ssize); } + if(ResetRequested) + { + PowerNES(); // reset game + ResetRequested = 0; + } + if(ConfigRequested) { + ResetVideo_Menu(); if (GCSettings.AutoSave == 1) { SaveRAM(GCSettings.SaveMethod, SILENT); diff --git a/source/ngc/fceugx.h b/source/ngc/fceugx.h new file mode 100644 index 0000000..32cf1c5 --- /dev/null +++ b/source/ngc/fceugx.h @@ -0,0 +1,80 @@ +/**************************************************************************** + * FCE Ultra 0.98.12 + * Nintendo Wii/Gamecube Port + * + * Tantric September 2008 + * + * fceugx.h + * + * This file controls overall program flow. Most things start and end here! + ****************************************************************************/ + +#ifndef _FCEUGX_H_ +#define _FCEUGX_H_ + +#define VERSIONNUM "2.0.6" +#define VERSIONSTR "FCE Ultra GX 2.0.6" +#define PREF_FILE_NAME "FCEUGX.xml" + +#define NOTSILENT 0 +#define SILENT 1 + +enum { + METHOD_AUTO, + METHOD_SD, + METHOD_USB, + METHOD_DVD, + METHOD_SMB, + METHOD_MC_SLOTA, + METHOD_MC_SLOTB +}; + +enum { + FILE_ROM, + FILE_RAM, + FILE_STATE, + FILE_FDSBIOS, + FILE_CHEAT, + FILE_PREF +}; + +struct SGCSettings{ + int AutoLoad; + int AutoSave; + int LoadMethod; // For ROMS: Auto, SD, DVD, USB, Network (SMB) + int SaveMethod; // For SRAM, Freeze, Prefs: Auto, SD, Memory Card Slot A, Memory Card Slot B, USB, SMB + char LoadFolder[200]; // Path to game files + char SaveFolder[200]; // Path to save files + char CheatFolder[200]; // Path to cheat files + char gcip[16]; + char gwip[16]; + char mask[16]; + char smbip[16]; + char smbuser[20]; + char smbpwd[20]; + char smbgcid[20]; + char smbsvid[20]; + char smbshare[20]; + int Zoom; // 0 - off, 1 - on + float ZoomLevel; // zoom amount + int VerifySaves; + int render; // 0 - original, 1 - filtered, 2 - unfiltered + int widescreen; + int hideoverscan; + int currpal; + int timing; + int FSDisable; + int zapper; + int crosshair; + int slimit; +}; + +void ExitToLoader(); +void Reboot(); +void ShutdownWii(); +extern struct SGCSettings GCSettings; +extern int ConfigRequested; +extern int ShutdownRequested; +extern int frameskip; + +#endif diff --git a/source/ngc/fceuload.c b/source/ngc/fceuload.c index 978df39..e4ac221 100644 --- a/source/ngc/fceuload.c +++ b/source/ngc/fceuload.c @@ -24,11 +24,11 @@ #include "sound.h" #include "file.h" +#include "fceugx.h" #include "gcaudio.h" #include "common.h" #include "pad.h" #include "menudraw.h" -#include "fceuconfig.h" #include "fileop.h" #include "filesel.h" #include "smbop.h" diff --git a/source/ngc/fceuram.c b/source/ngc/fceuram.c index ec74ede..b223392 100644 --- a/source/ngc/fceuram.c +++ b/source/ngc/fceuram.c @@ -31,7 +31,7 @@ #include "general.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "intl.h" #include "menudraw.h" #include "filesel.h" diff --git a/source/ngc/fceustate.c b/source/ngc/fceustate.c index c7e690e..354ad55 100644 --- a/source/ngc/fceustate.c +++ b/source/ngc/fceustate.c @@ -21,7 +21,7 @@ #include "state.h" #include "images/saveicon.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "intl.h" #include "menudraw.h" #include "filesel.h" diff --git a/source/ngc/fileop.c b/source/ngc/fileop.c index 606bec4..a376f24 100644 --- a/source/ngc/fileop.c +++ b/source/ngc/fileop.c @@ -17,7 +17,7 @@ #include #include "common.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "fileop.h" #include "gcunzip.h" #include "menudraw.h" diff --git a/source/ngc/fileop.h b/source/ngc/fileop.h index 8ab1c46..5e2c844 100644 --- a/source/ngc/fileop.h +++ b/source/ngc/fileop.h @@ -22,6 +22,7 @@ #define ROOTFATDIR "fat:/" +void UnmountAllFAT(); bool ChangeFATInterface(int method, bool silent); int ParseFATdirectory(int method); int LoadFATSzFile(char * filepath, unsigned char * rbuffer); diff --git a/source/ngc/filesel.c b/source/ngc/filesel.c index 742af93..aa294c6 100644 --- a/source/ngc/filesel.c +++ b/source/ngc/filesel.c @@ -20,7 +20,7 @@ #endif #include "common.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "dvd.h" #include "menudraw.h" #include "filesel.h" diff --git a/source/ngc/gcunzip.c b/source/ngc/gcunzip.c index 9092283..3d795fa 100644 --- a/source/ngc/gcunzip.c +++ b/source/ngc/gcunzip.c @@ -19,7 +19,7 @@ #include "../sz/7zIn.h" #include "../sz/7zExtract.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "dvd.h" #include "smbop.h" #include "fileop.h" diff --git a/source/ngc/gcvideo.c b/source/ngc/gcvideo.c index 0dfd883..3020676 100644 --- a/source/ngc/gcvideo.c +++ b/source/ngc/gcvideo.c @@ -19,7 +19,7 @@ #include "driver.h" #include "gcvideo.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "menudraw.h" #include "images/nesback.h" diff --git a/source/ngc/memcardop.c b/source/ngc/memcardop.c index 8db1e2e..7595a4d 100644 --- a/source/ngc/memcardop.c +++ b/source/ngc/memcardop.c @@ -18,7 +18,7 @@ #include "common.h" #include "menudraw.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "menu.h" #include "memcardop.h" #include "fileop.h" diff --git a/source/ngc/menu.c b/source/ngc/menu.c index 17a8214..ef0cd4e 100644 --- a/source/ngc/menu.c +++ b/source/ngc/menu.c @@ -21,6 +21,7 @@ #endif #include "common.h" +#include "fceugx.h" #include "fceuconfig.h" #include "pad.h" #include "button_mapping.h" @@ -43,42 +44,6 @@ extern void PowerNES(void); extern int menu; extern bool romLoaded; -#define SOFTRESET_ADR ((volatile u32*)0xCC003024) - -/**************************************************************************** - * Reboot / Exit - ****************************************************************************/ - -#ifndef HW_RVL -#define PSOSDLOADID 0x7c6000a6 -int *psoid = (int *) 0x80001800; -void (*PSOReload) () = (void (*)()) 0x80001800; -#endif - -void Reboot() -{ -#ifdef HW_RVL - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); -#else -#define SOFTRESET_ADR ((volatile u32*)0xCC003024) - *SOFTRESET_ADR = 0x00000000; -#endif -} - -void ExitToLoader() -{ - // Exit to Loader - #ifdef HW_RVL - #ifdef WII_DVD - DI_Close(); - #endif - exit(0); - #else // gamecube - if (psoid[0] == PSOSDLOADID) - PSOReload (); - #endif -} - /**************************************************************************** * Load Manager ****************************************************************************/ diff --git a/source/ngc/menudraw.c b/source/ngc/menudraw.c index ca1fd26..f3fd2f3 100644 --- a/source/ngc/menudraw.c +++ b/source/ngc/menudraw.c @@ -20,7 +20,7 @@ #include #include FT_FREETYPE_H -#include "fceuconfig.h" +#include "fceugx.h" #include "gcvideo.h" #include "menudraw.h" #include "filesel.h" @@ -501,7 +501,12 @@ RunMenu (char items[][50], int maxitems, char *title, int fontsize, int x) while (quit == 0) { - if (redraw) + #ifdef HW_RVL + if(ShutdownRequested) + ShutdownWii(); + #endif + + if (redraw) { DrawMenu (&items[0], title, maxitems, menu, fontsize, -1); redraw = 0; diff --git a/source/ngc/pad.c b/source/ngc/pad.c index 46894d6..a46274b 100644 --- a/source/ngc/pad.c +++ b/source/ngc/pad.c @@ -16,7 +16,7 @@ #include "fceu.h" #include "input.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "pad.h" #include "gcaudio.h" #include "menu.h" diff --git a/source/ngc/preferences.c b/source/ngc/preferences.c index a60a4d5..514befd 100644 --- a/source/ngc/preferences.c +++ b/source/ngc/preferences.c @@ -20,7 +20,7 @@ #include "fileop.h" #include "smbop.h" #include "filesel.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "pad.h" extern const unsigned short saveicon[1024]; diff --git a/source/ngc/smbop.c b/source/ngc/smbop.c index 418090f..4d421f9 100644 --- a/source/ngc/smbop.c +++ b/source/ngc/smbop.c @@ -20,7 +20,7 @@ #include #include "common.h" -#include "fceuconfig.h" +#include "fceugx.h" #include "smbop.h" #include "gcunzip.h" #include "menudraw.h"