2008-09-02 03:57:21 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* FCE Ultra 0.98.12
|
|
|
|
* Nintendo Wii/Gamecube Port
|
|
|
|
*
|
|
|
|
* Tantric September 2008
|
|
|
|
*
|
|
|
|
* menu.c
|
|
|
|
*
|
|
|
|
* Main menu flow control
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
|
|
|
|
#ifdef WII_DVD
|
|
|
|
#include <di/di.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "fceuconfig.h"
|
|
|
|
#include "pad.h"
|
|
|
|
#include "button_mapping.h"
|
|
|
|
#include "filesel.h"
|
|
|
|
#include "gcunzip.h"
|
|
|
|
#include "smbop.h"
|
|
|
|
#include "memcardop.h"
|
|
|
|
#include "fileop.h"
|
|
|
|
#include "dvd.h"
|
|
|
|
#include "menudraw.h"
|
|
|
|
#include "fceustate.h"
|
|
|
|
#include "gcvideo.h"
|
|
|
|
#include "preferences.h"
|
2008-09-06 05:30:42 +02:00
|
|
|
#include "fceuram.h"
|
2008-09-06 20:24:52 +02:00
|
|
|
#include "fceuload.h"
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
extern void ResetNES(void);
|
|
|
|
extern void FCEU_ResetPalette(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
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Load Manager
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int
|
|
|
|
LoadManager ()
|
|
|
|
{
|
|
|
|
int loadROM = OpenROM(GCSettings.LoadMethod);
|
|
|
|
|
|
|
|
if ( loadROM == 1 ) // if ROM was loaded
|
|
|
|
{
|
2008-09-06 05:30:42 +02:00
|
|
|
// load the RAM
|
2008-09-02 03:57:21 +02:00
|
|
|
if (GCSettings.AutoLoad == 1)
|
2008-09-06 05:30:42 +02:00
|
|
|
LoadRAM(GCSettings.SaveMethod, SILENT);
|
2008-09-06 20:24:52 +02:00
|
|
|
else if (GCSettings.AutoLoad == 2)
|
2008-09-02 03:57:21 +02:00
|
|
|
LoadState(GCSettings.SaveMethod, SILENT);
|
2008-09-06 05:30:42 +02:00
|
|
|
|
|
|
|
ResetNES();
|
2008-09-02 03:57:21 +02:00
|
|
|
}
|
|
|
|
return loadROM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Emulator Menu
|
|
|
|
****************************************************************************/
|
2008-09-04 04:46:04 +02:00
|
|
|
static int emulatormenuCount = 6;
|
2008-09-02 03:57:21 +02:00
|
|
|
static char emulatormenu[][50] = {
|
|
|
|
|
|
|
|
"Screen Scaler",
|
|
|
|
"Palette",
|
|
|
|
"8 Sprite Limit",
|
|
|
|
"Timing",
|
|
|
|
|
|
|
|
"Save Preferences",
|
|
|
|
"Back to Main Menu"
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
EmulatorMenu ()
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int quit = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
sprintf (emulatormenu[0], "Screen Scaler - %s",
|
|
|
|
(GCSettings.screenscaler == 0) ? "2x" : (GCSettings.screenscaler == 1) ? "Cheesy" : "GX");
|
|
|
|
|
|
|
|
sprintf (emulatormenu[1], "Palette - %s",
|
|
|
|
GCSettings.currpal ? palettes[GCSettings.currpal-1].name : "Default");
|
|
|
|
|
|
|
|
sprintf (emulatormenu[2], "8 Sprite Limit - %s",
|
|
|
|
GCSettings.slimit == true ? " ON" : "OFF");
|
|
|
|
|
|
|
|
sprintf (emulatormenu[3], "Timing - %s",
|
|
|
|
GCSettings.timing == true ? " PAL" : "NTSC");
|
|
|
|
|
|
|
|
ret = RunMenu (emulatormenu, emulatormenuCount, (char*)"Emulator Options", 16, -1);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0: // screen scaler
|
|
|
|
if (++GCSettings.screenscaler > 2)
|
|
|
|
GCSettings.screenscaler = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // palette
|
|
|
|
if ( ++GCSettings.currpal > MAXPAL )
|
|
|
|
GCSettings.currpal = 0;
|
|
|
|
|
|
|
|
if ( GCSettings.currpal == 0 )
|
|
|
|
{
|
|
|
|
// Do palette reset
|
|
|
|
FCEU_ResetPalette();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Now setup this palette
|
|
|
|
unsigned char i,r,g,b;
|
|
|
|
|
|
|
|
for ( i = 0; i < 64; i++ )
|
|
|
|
{
|
|
|
|
r = palettes[GCSettings.currpal-1].data[i] >> 16;
|
|
|
|
g = ( palettes[GCSettings.currpal-1].data[i] & 0xff00 ) >> 8;
|
|
|
|
b = ( palettes[GCSettings.currpal-1].data[i] & 0xff );
|
|
|
|
FCEUD_SetPalette( i, r, g, b);
|
|
|
|
FCEUD_SetPalette( i+64, r, g, b);
|
|
|
|
FCEUD_SetPalette( i+128, r, g, b);
|
|
|
|
FCEUD_SetPalette( i+192, r, g, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // 8 sprite limit
|
|
|
|
GCSettings.slimit ^=1;
|
|
|
|
FCEUI_DisableSpriteLimitation(GCSettings.slimit);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // timing
|
|
|
|
GCSettings.timing ^= 1;
|
|
|
|
FCEUI_SetVidSystem(GCSettings.timing);
|
|
|
|
break;
|
|
|
|
|
2008-09-04 04:46:04 +02:00
|
|
|
case 4:
|
2008-09-02 03:57:21 +02:00
|
|
|
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: // Button B
|
2008-09-04 04:46:04 +02:00
|
|
|
case 5:
|
2008-09-02 03:57:21 +02:00
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu = oldmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Preferences Menu
|
|
|
|
****************************************************************************/
|
|
|
|
static int prefmenuCount = 9;
|
|
|
|
static char prefmenu[][50] = {
|
|
|
|
|
|
|
|
"Load Method",
|
|
|
|
"Load Folder",
|
|
|
|
"Save Method",
|
|
|
|
"Save Folder",
|
|
|
|
|
|
|
|
"Auto Load",
|
|
|
|
"Auto Save",
|
|
|
|
"Verify MC Saves",
|
|
|
|
|
|
|
|
"Save Preferences",
|
|
|
|
"Back to Main Menu"
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
PreferencesMenu ()
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int quit = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
// some load/save methods are not implemented - here's where we skip them
|
|
|
|
// they need to be skipped in the order they were enumerated in snes9xGX.h
|
|
|
|
|
|
|
|
// no USB ports on GameCube
|
|
|
|
#ifndef HW_RVL
|
|
|
|
if(GCSettings.LoadMethod == METHOD_USB)
|
|
|
|
GCSettings.LoadMethod++;
|
|
|
|
if(GCSettings.SaveMethod == METHOD_USB)
|
|
|
|
GCSettings.SaveMethod++;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// saving to DVD is impossible
|
|
|
|
if(GCSettings.SaveMethod == METHOD_DVD)
|
|
|
|
GCSettings.SaveMethod++;
|
|
|
|
|
|
|
|
// disable SMB in GC mode (stalls out)
|
|
|
|
#ifndef HW_RVL
|
|
|
|
if(GCSettings.LoadMethod == METHOD_SMB)
|
|
|
|
GCSettings.LoadMethod++;
|
|
|
|
if(GCSettings.SaveMethod == METHOD_SMB)
|
|
|
|
GCSettings.SaveMethod++;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// disable MC saving in Wii mode - does not work for some reason!
|
|
|
|
#ifdef HW_RVL
|
|
|
|
if(GCSettings.SaveMethod == METHOD_MC_SLOTA)
|
|
|
|
GCSettings.SaveMethod++;
|
|
|
|
if(GCSettings.SaveMethod == METHOD_MC_SLOTB)
|
|
|
|
GCSettings.SaveMethod++;
|
2008-10-09 06:25:35 +02:00
|
|
|
prefmenu[6][0] = '\0';
|
|
|
|
#else
|
|
|
|
sprintf (prefmenu[6], "Verify MC Saves %s",
|
|
|
|
GCSettings.VerifySaves == true ? " ON" : "OFF");
|
2008-09-02 03:57:21 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// correct load/save methods out of bounds
|
|
|
|
if(GCSettings.LoadMethod > 4)
|
|
|
|
GCSettings.LoadMethod = 0;
|
|
|
|
if(GCSettings.SaveMethod > 6)
|
|
|
|
GCSettings.SaveMethod = 0;
|
|
|
|
|
|
|
|
if (GCSettings.LoadMethod == METHOD_AUTO) sprintf (prefmenu[0],"Load Method AUTO");
|
|
|
|
else if (GCSettings.LoadMethod == METHOD_SD) sprintf (prefmenu[0],"Load Method SD");
|
|
|
|
else if (GCSettings.LoadMethod == METHOD_USB) sprintf (prefmenu[0],"Load Method USB");
|
|
|
|
else if (GCSettings.LoadMethod == METHOD_DVD) sprintf (prefmenu[0],"Load Method DVD");
|
|
|
|
else if (GCSettings.LoadMethod == METHOD_SMB) sprintf (prefmenu[0],"Load Method Network");
|
|
|
|
|
|
|
|
sprintf (prefmenu[1], "Load Folder %s", GCSettings.LoadFolder);
|
|
|
|
|
|
|
|
if (GCSettings.SaveMethod == METHOD_AUTO) sprintf (prefmenu[2],"Save Method AUTO");
|
|
|
|
else if (GCSettings.SaveMethod == METHOD_SD) sprintf (prefmenu[2],"Save Method SD");
|
|
|
|
else if (GCSettings.SaveMethod == METHOD_USB) sprintf (prefmenu[2],"Save Method USB");
|
|
|
|
else if (GCSettings.SaveMethod == METHOD_SMB) sprintf (prefmenu[2],"Save Method Network");
|
|
|
|
else if (GCSettings.SaveMethod == METHOD_MC_SLOTA) sprintf (prefmenu[2],"Save Method MC Slot A");
|
|
|
|
else if (GCSettings.SaveMethod == METHOD_MC_SLOTB) sprintf (prefmenu[2],"Save Method MC Slot B");
|
|
|
|
|
|
|
|
sprintf (prefmenu[3], "Save Folder %s", GCSettings.SaveFolder);
|
|
|
|
|
|
|
|
// disable changing load/save directories for now
|
|
|
|
prefmenu[1][0] = '\0';
|
|
|
|
prefmenu[3][0] = '\0';
|
|
|
|
|
|
|
|
if (GCSettings.AutoLoad == 0) sprintf (prefmenu[4],"Auto Load OFF");
|
2008-09-06 05:30:42 +02:00
|
|
|
else if (GCSettings.AutoLoad == 1) sprintf (prefmenu[4],"Auto Load RAM");
|
|
|
|
else if (GCSettings.AutoLoad == 2) sprintf (prefmenu[4],"Auto Load STATE");
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
if (GCSettings.AutoSave == 0) sprintf (prefmenu[5],"Auto Save OFF");
|
2008-09-06 05:30:42 +02:00
|
|
|
else if (GCSettings.AutoSave == 1) sprintf (prefmenu[5],"Auto Save RAM");
|
|
|
|
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save STATE");
|
|
|
|
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
ret = RunMenu (prefmenu, prefmenuCount, (char*)"Preferences", 16, -1);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
GCSettings.LoadMethod ++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
GCSettings.SaveMethod ++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
GCSettings.AutoLoad ++;
|
2008-09-06 05:30:42 +02:00
|
|
|
if (GCSettings.AutoLoad > 2)
|
2008-09-02 03:57:21 +02:00
|
|
|
GCSettings.AutoLoad = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
GCSettings.AutoSave ++;
|
2008-09-06 05:30:42 +02:00
|
|
|
if (GCSettings.AutoSave > 3)
|
2008-09-02 03:57:21 +02:00
|
|
|
GCSettings.AutoSave = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
GCSettings.VerifySaves ^= 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: // Button B
|
|
|
|
case 8:
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu = oldmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Game Options Menu
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int
|
|
|
|
GameMenu ()
|
|
|
|
{
|
2008-09-06 05:30:42 +02:00
|
|
|
int gamemenuCount = 8;
|
2008-09-02 03:57:21 +02:00
|
|
|
char gamemenu[][50] = {
|
|
|
|
"Return to Game",
|
|
|
|
"Reset Game",
|
|
|
|
"ROM Information",
|
2008-09-06 05:30:42 +02:00
|
|
|
"Load RAM", "Save RAM",
|
2008-09-02 03:57:21 +02:00
|
|
|
"Load State", "Save State",
|
|
|
|
"Back to Main Menu"
|
|
|
|
};
|
|
|
|
|
|
|
|
int ret, retval = 0;
|
|
|
|
int quit = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
2008-10-09 06:51:14 +02:00
|
|
|
if(nesGameType == 4) // FDS game
|
2008-10-09 06:25:35 +02:00
|
|
|
{
|
2008-10-09 06:51:14 +02:00
|
|
|
// disable RAM saving/loading
|
2008-10-09 06:25:35 +02:00
|
|
|
gamemenu[3][0] = '\0';
|
|
|
|
gamemenu[4][0] = '\0';
|
2008-10-09 06:51:14 +02:00
|
|
|
|
|
|
|
// disable ROM Information
|
|
|
|
gamemenu[2][0] = '\0';
|
2008-10-09 06:25:35 +02:00
|
|
|
}
|
|
|
|
|
2008-09-06 05:30:42 +02:00
|
|
|
// disable RAM/STATE saving/loading if AUTO is on
|
|
|
|
if (GCSettings.AutoLoad == 1) // Auto Load RAM
|
2008-09-02 03:57:21 +02:00
|
|
|
gamemenu[3][0] = '\0';
|
2008-09-06 05:30:42 +02:00
|
|
|
else if (GCSettings.AutoLoad == 2) // Auto Load STATE
|
|
|
|
gamemenu[5][0] = '\0';
|
|
|
|
|
|
|
|
if (GCSettings.AutoSave == 1) // Auto Save RAM
|
|
|
|
gamemenu[4][0] = '\0';
|
|
|
|
else if (GCSettings.AutoSave == 2) // Auto Save STATE
|
|
|
|
gamemenu[6][0] = '\0';
|
|
|
|
else if (GCSettings.AutoSave == 3) // Auto Save BOTH
|
|
|
|
{
|
2008-09-02 03:57:21 +02:00
|
|
|
gamemenu[4][0] = '\0';
|
2008-09-06 05:30:42 +02:00
|
|
|
gamemenu[6][0] = '\0';
|
|
|
|
}
|
2008-09-02 03:57:21 +02:00
|
|
|
|
|
|
|
ret = RunMenu (gamemenu, gamemenuCount, (char*)"Game Menu", 20, -1);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0: // Return to Game
|
|
|
|
quit = retval = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // Reset Game
|
|
|
|
ResetNES();
|
|
|
|
quit = retval = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // ROM Information
|
|
|
|
RomInfo();
|
|
|
|
WaitButtonA ();
|
|
|
|
break;
|
|
|
|
|
2008-09-06 05:30:42 +02:00
|
|
|
case 3: // Load RAM
|
|
|
|
quit = retval = LoadRAM(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // Save RAM
|
|
|
|
SaveRAM(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: // Load State
|
2008-09-02 03:57:21 +02:00
|
|
|
quit = retval = LoadState(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
2008-09-06 05:30:42 +02:00
|
|
|
case 6: // Save State
|
2008-09-02 03:57:21 +02:00
|
|
|
SaveState(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: // Button B
|
2008-09-06 05:30:42 +02:00
|
|
|
case 7: // Return to previous menu
|
2008-09-02 03:57:21 +02:00
|
|
|
retval = 0;
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = oldmenu;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Controller Configuration
|
|
|
|
*
|
|
|
|
* Snes9x 1.50 uses a cmd system to work out which button has been pressed.
|
|
|
|
* Here, I simply move the designated value to the gcpadmaps array, which saves
|
|
|
|
* on updating the cmd sequences.
|
|
|
|
****************************************************************************/
|
|
|
|
u32
|
|
|
|
GetInput (u16 ctrlr_type)
|
|
|
|
{
|
|
|
|
//u32 exp_type;
|
|
|
|
u32 pressed;
|
|
|
|
pressed=0;
|
|
|
|
s8 gc_px = 0;
|
|
|
|
|
|
|
|
while( PAD_ButtonsHeld(0)
|
|
|
|
#ifdef HW_RVL
|
|
|
|
| WPAD_ButtonsHeld(0)
|
|
|
|
#endif
|
|
|
|
) VIDEO_WaitVSync(); // button 'debounce'
|
|
|
|
|
|
|
|
while (pressed == 0)
|
|
|
|
{
|
|
|
|
VIDEO_WaitVSync();
|
|
|
|
// get input based on controller type
|
|
|
|
if (ctrlr_type == CTRLR_GCPAD)
|
|
|
|
{
|
|
|
|
pressed = PAD_ButtonsHeld (0);
|
|
|
|
gc_px = PAD_SubStickX (0);
|
|
|
|
}
|
|
|
|
#ifdef HW_RVL
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if ( WPAD_Probe( 0, &exp_type) == 0) // check wiimote and expansion status (first if wiimote is connected & no errors)
|
|
|
|
// {
|
|
|
|
pressed = WPAD_ButtonsHeld (0);
|
|
|
|
|
|
|
|
// if (ctrlr_type != CTRLR_WIIMOTE && exp_type != ctrlr_type+1) // if we need input from an expansion, and its not connected...
|
|
|
|
// pressed = 0;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/*** check for exit sequence (c-stick left OR home button) ***/
|
|
|
|
if ( (gc_px < -70) || (pressed & WPAD_BUTTON_HOME) || (pressed & WPAD_CLASSIC_BUTTON_HOME) )
|
|
|
|
return 0;
|
|
|
|
} // end while
|
|
|
|
while( pressed == (PAD_ButtonsHeld(0)
|
|
|
|
#ifdef HW_RVL
|
|
|
|
| WPAD_ButtonsHeld(0)
|
|
|
|
#endif
|
|
|
|
) ) VIDEO_WaitVSync();
|
|
|
|
|
|
|
|
return pressed;
|
|
|
|
} // end GetInput()
|
|
|
|
|
|
|
|
int cfg_text_count = 7;
|
|
|
|
char cfg_text[][50] = {
|
|
|
|
"Remapping ",
|
|
|
|
"Press Any Button",
|
|
|
|
"on the",
|
|
|
|
" ", // identify controller
|
|
|
|
" ",
|
|
|
|
"Press C-Left or",
|
|
|
|
"Home to exit"
|
|
|
|
};
|
|
|
|
|
|
|
|
u32
|
|
|
|
GetButtonMap(u16 ctrlr_type, char* btn_name)
|
|
|
|
{
|
|
|
|
u32 pressed, previous;
|
|
|
|
char temp[50] = "";
|
|
|
|
uint k;
|
|
|
|
pressed = 0; previous = 1;
|
|
|
|
|
|
|
|
switch (ctrlr_type) {
|
|
|
|
case CTRLR_NUNCHUK:
|
|
|
|
strncpy (cfg_text[3], (char*)"NUNCHUK", 7);
|
|
|
|
break;
|
|
|
|
case CTRLR_CLASSIC:
|
|
|
|
strncpy (cfg_text[3], (char*)"CLASSIC", 7);
|
|
|
|
break;
|
|
|
|
case CTRLR_GCPAD:
|
|
|
|
strncpy (cfg_text[3], (char*)"GC PAD", 7);
|
|
|
|
break;
|
|
|
|
case CTRLR_WIIMOTE:
|
|
|
|
strncpy (cfg_text[3], (char*)"WIIMOTE", 7);
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*** note which button we are remapping ***/
|
|
|
|
sprintf (temp, (char*)"Remapping ");
|
|
|
|
for (k=0; k<9-strlen(btn_name); k++) strcat(temp, " "); // add whitespace padding to align text
|
|
|
|
strncat (temp, btn_name, 9); // nes button we are remapping
|
|
|
|
strncpy (cfg_text[0], temp, 19); // copy this all back to the text we wish to display
|
|
|
|
|
|
|
|
DrawMenu(&cfg_text[0], NULL, cfg_text_count, 1, 20, -1); // display text
|
|
|
|
|
|
|
|
// while (previous != pressed && pressed == 0); // get two consecutive button presses (which are the same)
|
|
|
|
// {
|
|
|
|
// previous = pressed;
|
|
|
|
// VIDEO_WaitVSync(); // slow things down a bit so we don't overread the pads
|
|
|
|
pressed = GetInput(ctrlr_type);
|
|
|
|
// }
|
|
|
|
return pressed;
|
|
|
|
} // end getButtonMap()
|
|
|
|
|
2008-10-01 07:25:38 +02:00
|
|
|
int cfg_btns_count = 10;
|
2008-09-02 03:57:21 +02:00
|
|
|
char cfg_btns_menu[][50] = {
|
2008-10-01 08:03:16 +02:00
|
|
|
"B - ",
|
|
|
|
"A - ",
|
|
|
|
"SELECT - ",
|
|
|
|
"START - ",
|
|
|
|
"UP - ",
|
|
|
|
"DOWN - ",
|
|
|
|
"LEFT - ",
|
|
|
|
"RIGHT - ",
|
2008-10-01 23:00:12 +02:00
|
|
|
"SPECIAL - ",
|
2008-09-02 03:57:21 +02:00
|
|
|
"Return to previous"
|
|
|
|
};
|
|
|
|
|
|
|
|
extern unsigned int gcpadmap[];
|
|
|
|
extern unsigned int wmpadmap[];
|
|
|
|
extern unsigned int ccpadmap[];
|
|
|
|
extern unsigned int ncpadmap[];
|
|
|
|
|
|
|
|
void
|
|
|
|
ConfigureButtons (u16 ctrlr_type)
|
|
|
|
{
|
|
|
|
int quit = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
char* menu_title = NULL;
|
|
|
|
u32 pressed;
|
|
|
|
|
|
|
|
unsigned int* currentpadmap = 0;
|
|
|
|
char temp[50] = "";
|
|
|
|
int i, j;
|
|
|
|
uint k;
|
|
|
|
|
|
|
|
/*** Update Menu Title (based on controller we're configuring) ***/
|
|
|
|
switch (ctrlr_type) {
|
|
|
|
case CTRLR_NUNCHUK:
|
|
|
|
menu_title = (char*)"NES - NUNCHUK";
|
|
|
|
currentpadmap = ncpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_CLASSIC:
|
|
|
|
menu_title = (char*)"NES - CLASSIC";
|
|
|
|
currentpadmap = ccpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_GCPAD:
|
|
|
|
menu_title = (char*)"NES - GC PAD";
|
|
|
|
currentpadmap = gcpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_WIIMOTE:
|
|
|
|
menu_title = (char*)"NES - WIIMOTE";
|
|
|
|
currentpadmap = wmpadmap;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
/*** Update Menu with Current ButtonMap ***/
|
2008-10-01 07:25:38 +02:00
|
|
|
for (i=0; i<MAXJP; i++) // nes pad has 8 buttons to config (plus VS coin insert)
|
2008-09-02 03:57:21 +02:00
|
|
|
{
|
|
|
|
// get current padmap button name to display
|
|
|
|
for ( j=0;
|
|
|
|
j < ctrlr_def[ctrlr_type].num_btns &&
|
|
|
|
currentpadmap[i] != ctrlr_def[ctrlr_type].map[j].btn // match padmap button press with button names
|
|
|
|
; j++ );
|
|
|
|
|
|
|
|
memset (temp, 0, sizeof(temp));
|
|
|
|
strncpy (temp, cfg_btns_menu[i], 12); // copy snes button information
|
|
|
|
if (currentpadmap[i] == ctrlr_def[ctrlr_type].map[j].btn) // check if a match was made
|
|
|
|
{
|
|
|
|
for (k=0; k<7-strlen(ctrlr_def[ctrlr_type].map[j].name) ;k++) strcat(temp, " "); // add whitespace padding to align text
|
|
|
|
strncat (temp, ctrlr_def[ctrlr_type].map[j].name, 6); // update button map display
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcat (temp, (char*)"---"); // otherwise, button is 'unmapped'
|
|
|
|
strncpy (cfg_btns_menu[i], temp, 19); // move back updated information
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RunMenu (cfg_btns_menu, cfg_btns_count, menu_title, 16, -1);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
2008-10-01 07:25:38 +02:00
|
|
|
case 8:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Change button map ***/
|
|
|
|
// wait for input
|
|
|
|
memset (temp, 0, sizeof(temp));
|
|
|
|
strncpy(temp, cfg_btns_menu[ret], 6); // get the name of the snes button we're changing
|
|
|
|
pressed = GetButtonMap(ctrlr_type, temp); // get a button selection from user
|
|
|
|
// FIX: check if input is valid for this controller
|
|
|
|
if (pressed != 0) // check if a the button was configured, or if the user exited.
|
|
|
|
currentpadmap[ret] = pressed; // update mapping
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: /*** Button B ***/
|
2008-10-01 07:25:38 +02:00
|
|
|
case 9:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Return ***/
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu = oldmenu;
|
|
|
|
} // end configurebuttons()
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
int ctlrmenucount = 9;
|
2008-09-02 03:57:21 +02:00
|
|
|
char ctlrmenu[][50] = {
|
2008-09-04 04:46:04 +02:00
|
|
|
"Four Score",
|
|
|
|
"Zapper",
|
2008-10-01 23:00:12 +02:00
|
|
|
"Zapper Crosshair",
|
2008-09-02 03:57:21 +02:00
|
|
|
"Nunchuk",
|
|
|
|
"Classic Controller",
|
|
|
|
"Wiimote",
|
|
|
|
"Gamecube Pad",
|
|
|
|
"Save Preferences",
|
|
|
|
"Go Back"
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
ConfigureControllers ()
|
|
|
|
{
|
|
|
|
int quit = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
// disable unavailable controller options if in GC mode
|
|
|
|
#ifndef HW_RVL
|
2008-09-04 04:46:04 +02:00
|
|
|
ctlrmenu[2][0] = '\0';
|
|
|
|
ctlrmenu[3][0] = '\0';
|
2008-09-02 03:57:21 +02:00
|
|
|
ctlrmenu[4][0] = '\0';
|
|
|
|
#endif
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
2008-09-04 04:46:04 +02:00
|
|
|
sprintf (ctlrmenu[0], "Four Score - %s",
|
2008-09-10 03:02:12 +02:00
|
|
|
GCSettings.FSDisable == false ? " ON" : "OFF");
|
2008-09-04 04:46:04 +02:00
|
|
|
|
|
|
|
if (GCSettings.zapper == 0) sprintf (ctlrmenu[1],"Zapper - Disabled");
|
|
|
|
else if (GCSettings.zapper == 1) sprintf (ctlrmenu[1],"Zapper - Port 1");
|
|
|
|
else if (GCSettings.zapper == 2) sprintf (ctlrmenu[1],"Zapper - Port 2");
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
sprintf (ctlrmenu[2], "Zapper Crosshair - %s",
|
|
|
|
GCSettings.crosshair == true ? " ON" : "OFF");
|
|
|
|
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Controller Config Menu ***/
|
|
|
|
ret = RunMenu (ctlrmenu, ctlrmenucount, (char*)"Configure Controllers", 20, -1);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
2008-09-04 04:46:04 +02:00
|
|
|
case 0: // four score
|
|
|
|
GCSettings.FSDisable ^= 1;
|
2008-10-04 01:31:17 +02:00
|
|
|
ToggleFourScore(GCSettings.FSDisable, romLoaded);
|
2008-09-04 04:46:04 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // zapper
|
|
|
|
GCSettings.zapper -= 1; // we do this so Port 2 is first option shown
|
|
|
|
if(GCSettings.zapper < 0)
|
|
|
|
GCSettings.zapper = 2;
|
2008-10-04 01:31:17 +02:00
|
|
|
ToggleZapper(GCSettings.zapper, romLoaded);
|
2008-09-04 04:46:04 +02:00
|
|
|
break;
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 2: // zapper crosshair
|
|
|
|
GCSettings.crosshair ^= 1;
|
|
|
|
break;
|
2008-10-04 01:31:17 +02:00
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 3:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Configure Nunchuk ***/
|
|
|
|
ConfigureButtons (CTRLR_NUNCHUK);
|
|
|
|
break;
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 4:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Configure Classic ***/
|
|
|
|
ConfigureButtons (CTRLR_CLASSIC);
|
|
|
|
break;
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 5:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Configure Wiimote ***/
|
|
|
|
ConfigureButtons (CTRLR_WIIMOTE);
|
|
|
|
break;
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 6:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Configure GC Pad ***/
|
|
|
|
ConfigureButtons (CTRLR_GCPAD);
|
|
|
|
break;
|
|
|
|
|
2008-10-01 23:00:12 +02:00
|
|
|
case 7:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Save Preferences Now ***/
|
|
|
|
SavePrefs(GCSettings.SaveMethod, NOTSILENT);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: /*** Button B ***/
|
2008-10-01 23:00:12 +02:00
|
|
|
case 8:
|
2008-09-02 03:57:21 +02:00
|
|
|
/*** Return ***/
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = oldmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Main Menu
|
|
|
|
****************************************************************************/
|
|
|
|
int menucount = 8;
|
|
|
|
char menuitems[][50] = {
|
|
|
|
"Choose Game",
|
|
|
|
"Controller Configuration", "Emulator Options", "Preferences",
|
|
|
|
"Game Menu",
|
|
|
|
"Credits", "Reset System", "Exit"
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
MainMenu (int selectedMenu)
|
|
|
|
{
|
|
|
|
int quit = 0;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
VIDEO_WaitVSync ();
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
// disable game-specific menu items if a ROM isn't loaded
|
|
|
|
if(!romLoaded)
|
|
|
|
menuitems[4][0] = '\0';
|
|
|
|
else
|
|
|
|
sprintf (menuitems[4], "Game Menu");
|
|
|
|
|
|
|
|
if(selectedMenu >= 0)
|
|
|
|
{
|
|
|
|
ret = selectedMenu;
|
|
|
|
selectedMenu = -1; // default back to main menu
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = RunMenu (menuitems, menucount, (char*)"Main Menu", 20, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// Load ROM Menu
|
|
|
|
quit = LoadManager ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Configure Controllers
|
|
|
|
ConfigureControllers ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// Emulator Options
|
|
|
|
EmulatorMenu ();
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// Preferences
|
|
|
|
PreferencesMenu ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
// Game Options
|
|
|
|
quit = GameMenu ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
// Credits
|
|
|
|
Credits ();
|
|
|
|
WaitButtonA ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
// Reset the Gamecube/Wii
|
|
|
|
Reboot();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
// Exit to Loader
|
|
|
|
#ifdef HW_RVL
|
|
|
|
#ifdef WII_DVD
|
|
|
|
DI_Close();
|
|
|
|
#endif
|
|
|
|
exit(0);
|
|
|
|
#else // gamecube
|
|
|
|
if (psoid[0] == PSOSDLOADID)
|
|
|
|
PSOReload ();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: // Button B
|
|
|
|
// Return to Game
|
|
|
|
if(romLoaded)
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-04 04:32:54 +02:00
|
|
|
// Wait for buttons to be released
|
|
|
|
int count = 0; // how long we've been waiting for the user to release the button
|
|
|
|
while(count < 50 && (
|
|
|
|
PAD_ButtonsHeld(0)
|
|
|
|
#ifdef HW_RVL
|
|
|
|
|| WPAD_ButtonsHeld(0)
|
|
|
|
#endif
|
|
|
|
))
|
|
|
|
{
|
|
|
|
VIDEO_WaitVSync();
|
|
|
|
count++;
|
|
|
|
}
|
2008-09-02 03:57:21 +02:00
|
|
|
}
|