2008-09-16 07:42:21 +02:00
|
|
|
/****************************************************************************
|
2008-09-17 04:27:55 +02:00
|
|
|
* Visual Boy Advance GX
|
2008-09-16 07:42:21 +02:00
|
|
|
*
|
2008-09-17 03:54:21 +02:00
|
|
|
* Tantric September 2008
|
2008-09-16 07:42:21 +02:00
|
|
|
*
|
|
|
|
* menu.cpp
|
|
|
|
*
|
|
|
|
* Menu flow routines - handles all menu logic
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <wiiuse/wpad.h>
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
#ifdef HW_RVL
|
2008-09-16 07:42:21 +02:00
|
|
|
extern "C" {
|
|
|
|
#include <di/di.h>
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "vba.h"
|
|
|
|
#include "vbasupport.h"
|
|
|
|
#include "audio.h"
|
|
|
|
#include "video.h"
|
|
|
|
#include "filesel.h"
|
|
|
|
#include "gcunzip.h"
|
2008-12-24 08:52:35 +01:00
|
|
|
#include "networkop.h"
|
2008-09-16 07:42:21 +02:00
|
|
|
#include "memcardop.h"
|
|
|
|
#include "fileop.h"
|
|
|
|
#include "dvd.h"
|
|
|
|
#include "preferences.h"
|
|
|
|
#include "button_mapping.h"
|
|
|
|
#include "menudraw.h"
|
|
|
|
#include "input.h"
|
2008-10-24 08:16:15 +02:00
|
|
|
#include "vbaconfig.h"
|
2008-09-16 07:42:21 +02:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#include "tbtime.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int menu;
|
2008-09-29 09:35:26 +02:00
|
|
|
extern bool ROMLoaded;
|
2008-09-16 07:42:21 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Load Manager
|
|
|
|
***************************************************************************/
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
static int
|
2008-09-16 07:42:21 +02:00
|
|
|
LoadManager ()
|
|
|
|
{
|
|
|
|
int loadROM = OpenROM(GCSettings.LoadMethod);
|
|
|
|
|
|
|
|
/***
|
2008-09-17 03:54:21 +02:00
|
|
|
* check for autoload battery / state
|
2008-09-16 07:42:21 +02:00
|
|
|
***/
|
2008-09-17 03:54:21 +02:00
|
|
|
if ( loadROM == 1 ) // if ROM was loaded, load the battery / state
|
2008-09-16 07:42:21 +02:00
|
|
|
{
|
2008-09-17 03:54:21 +02:00
|
|
|
if (GCSettings.AutoLoad == 1)
|
2008-11-12 08:53:25 +01:00
|
|
|
LoadBatteryOrState(GCSettings.SaveMethod, FILE_SRAM, SILENT); // load battery
|
2008-09-17 03:54:21 +02:00
|
|
|
else if (GCSettings.AutoLoad == 2)
|
2008-11-12 08:53:25 +01:00
|
|
|
LoadBatteryOrState(GCSettings.SaveMethod, FILE_SNAPSHOT, SILENT); // load state
|
2008-09-16 07:42:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return loadROM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Preferences Menu
|
|
|
|
***************************************************************************/
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
static void
|
2008-09-16 07:42:21 +02:00
|
|
|
PreferencesMenu ()
|
|
|
|
{
|
2008-12-30 01:10:12 +01:00
|
|
|
int prefmenuCount = 12;
|
|
|
|
char prefmenu[][50] = {
|
|
|
|
|
|
|
|
"Load Method",
|
|
|
|
"Load Folder",
|
|
|
|
"Save Method",
|
|
|
|
"Save Folder",
|
|
|
|
|
|
|
|
"Auto Load",
|
|
|
|
"Auto Save",
|
|
|
|
"Verify MC Saves",
|
|
|
|
"Enable Zooming",
|
|
|
|
"Video Rendering",
|
|
|
|
"Video Scaling",
|
|
|
|
|
|
|
|
"Reset Preferences",
|
|
|
|
"Back to Main Menu"
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
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
|
2008-09-17 03:54:21 +02:00
|
|
|
// they need to be skipped in the order they were enumerated in vba.h
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
// no USB ports on GameCube
|
2008-10-11 10:06:36 +02:00
|
|
|
#ifdef HW_DOL
|
2008-09-16 07:42:21 +02:00
|
|
|
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++;
|
|
|
|
|
2008-10-11 10:06:36 +02:00
|
|
|
// disable DVD in GC mode (not implemented)
|
|
|
|
#ifdef HW_DOL
|
|
|
|
if(GCSettings.LoadMethod == METHOD_DVD)
|
|
|
|
GCSettings.LoadMethod++;
|
|
|
|
#endif
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
// disable SMB in GC mode (stalls out)
|
2008-10-11 10:06:36 +02:00
|
|
|
#ifdef HW_DOL
|
2008-09-16 07:42:21 +02:00
|
|
|
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 08:48:46 +02:00
|
|
|
prefmenu[6][0] = 0;
|
|
|
|
#else
|
|
|
|
sprintf (prefmenu[6], "Verify MC Saves %s", GCSettings.VerifySaves == true ? " ON" : "OFF");
|
2008-09-16 07:42: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");
|
|
|
|
else if (GCSettings.AutoLoad == 1) sprintf (prefmenu[4],"Auto Load SRAM");
|
|
|
|
else if (GCSettings.AutoLoad == 2) sprintf (prefmenu[4],"Auto Load SNAPSHOT");
|
|
|
|
|
|
|
|
if (GCSettings.AutoSave == 0) sprintf (prefmenu[5],"Auto Save OFF");
|
|
|
|
else if (GCSettings.AutoSave == 1) sprintf (prefmenu[5],"Auto Save SRAM");
|
|
|
|
else if (GCSettings.AutoSave == 2) sprintf (prefmenu[5],"Auto Save SNAPSHOT");
|
|
|
|
else if (GCSettings.AutoSave == 3) sprintf (prefmenu[5],"Auto Save BOTH");
|
|
|
|
|
2008-10-09 08:48:46 +02:00
|
|
|
sprintf (prefmenu[7], "Enable Zooming %s",
|
2008-10-24 08:16:15 +02:00
|
|
|
GCSettings.Zoom == true ? " ON" : "OFF");
|
2008-09-16 07:42:21 +02:00
|
|
|
|
2008-10-28 08:50:13 +01:00
|
|
|
// original mode not implemented
|
|
|
|
if(GCSettings.render == 0)
|
|
|
|
GCSettings.render++;
|
|
|
|
|
|
|
|
if (GCSettings.render == 0)
|
|
|
|
sprintf (prefmenu[8], "Video Rendering Original");
|
|
|
|
if (GCSettings.render == 1)
|
2008-10-10 07:28:16 +02:00
|
|
|
sprintf (prefmenu[8], "Video Rendering Filtered");
|
2008-10-28 08:50:13 +01:00
|
|
|
if (GCSettings.render == 2)
|
2008-10-10 07:28:16 +02:00
|
|
|
sprintf (prefmenu[8], "Video Rendering Unfiltered");
|
|
|
|
|
2008-10-24 08:16:15 +02:00
|
|
|
sprintf (prefmenu[9], "Video Scaling %s",
|
|
|
|
GCSettings.widescreen == true ? "16:9 Correction" : "Default");
|
|
|
|
|
2008-12-18 19:58:30 +01:00
|
|
|
ret = RunMenu (prefmenu, prefmenuCount, "Preferences", 16);
|
2008-09-16 07:42:21 +02:00
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
GCSettings.LoadMethod ++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
GCSettings.SaveMethod ++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
GCSettings.AutoLoad ++;
|
|
|
|
if (GCSettings.AutoLoad > 2)
|
|
|
|
GCSettings.AutoLoad = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
GCSettings.AutoSave ++;
|
|
|
|
if (GCSettings.AutoSave > 3)
|
|
|
|
GCSettings.AutoSave = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
GCSettings.VerifySaves ^= 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
2008-10-24 08:16:15 +02:00
|
|
|
GCSettings.Zoom ^= 1;
|
2008-10-09 08:48:46 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 8:
|
2008-10-10 07:28:16 +02:00
|
|
|
GCSettings.render++;
|
2008-10-28 08:50:13 +01:00
|
|
|
if (GCSettings.render > 2)
|
2008-10-10 07:28:16 +02:00
|
|
|
GCSettings.render = 0;
|
|
|
|
// reset zoom
|
|
|
|
zoom_reset ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9:
|
2008-10-24 08:16:15 +02:00
|
|
|
GCSettings.widescreen ^= 1;
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
2008-10-10 07:28:16 +02:00
|
|
|
case 10:
|
2008-10-24 08:16:15 +02:00
|
|
|
DefaultSettings ();
|
2008-12-18 19:58:30 +01:00
|
|
|
WaitPrompt("Preferences Reset");
|
2008-10-24 08:16:15 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
case -1: /*** Button B ***/
|
2008-12-19 00:21:51 +01:00
|
|
|
SavePrefs(SILENT);
|
2008-09-16 07:42:21 +02:00
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu = oldmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Game Options Menu
|
|
|
|
***************************************************************************/
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
static int
|
2008-09-16 07:42:21 +02:00
|
|
|
GameMenu ()
|
|
|
|
{
|
2008-10-09 08:48:46 +02:00
|
|
|
int gamemenuCount = 8;
|
2008-09-16 07:42:21 +02:00
|
|
|
char gamemenu[][50] = {
|
|
|
|
"Return to Game",
|
|
|
|
"Reset Game",
|
|
|
|
"Load SRAM", "Save SRAM",
|
|
|
|
"Load Game Snapshot", "Save Game Snapshot",
|
2008-10-09 08:48:46 +02:00
|
|
|
"Reset Zoom",
|
2008-09-16 07:42:21 +02:00
|
|
|
"Back to Main Menu"
|
|
|
|
};
|
|
|
|
|
|
|
|
int ret, retval = 0;
|
|
|
|
int quit = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
// disable SRAM/SNAPSHOT saving/loading if AUTO is on
|
|
|
|
|
|
|
|
if (GCSettings.AutoLoad == 1) // Auto Load SRAM
|
|
|
|
gamemenu[2][0] = '\0';
|
|
|
|
else if (GCSettings.AutoLoad == 2) // Auto Load SNAPSHOT
|
|
|
|
gamemenu[4][0] = '\0';
|
|
|
|
|
|
|
|
if (GCSettings.AutoSave == 1) // Auto Save SRAM
|
|
|
|
gamemenu[3][0] = '\0';
|
|
|
|
else if (GCSettings.AutoSave == 2) // Auto Save SNAPSHOT
|
|
|
|
gamemenu[5][0] = '\0';
|
|
|
|
else if (GCSettings.AutoSave == 3) // Auto Save BOTH
|
|
|
|
{
|
|
|
|
gamemenu[3][0] = '\0';
|
|
|
|
gamemenu[5][0] = '\0';
|
|
|
|
}
|
2008-10-09 08:48:46 +02:00
|
|
|
// disable Reset Zoom if Zooming is off
|
2008-10-24 08:16:15 +02:00
|
|
|
if(!GCSettings.Zoom)
|
2008-10-09 08:48:46 +02:00
|
|
|
gamemenu[6][0] = '\0';
|
2008-09-16 07:42:21 +02:00
|
|
|
|
2008-12-18 19:58:30 +01:00
|
|
|
ret = RunMenu (gamemenu, gamemenuCount, "Game Menu");
|
2008-09-16 07:42:21 +02:00
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0: // Return to Game
|
|
|
|
quit = retval = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // Reset Game
|
|
|
|
emulator.emuReset();
|
|
|
|
quit = retval = 1;
|
|
|
|
break;
|
|
|
|
|
2008-09-17 03:54:21 +02:00
|
|
|
case 2: // Load Battery
|
2008-11-12 08:53:25 +01:00
|
|
|
quit = retval = LoadBatteryOrState(GCSettings.SaveMethod, FILE_SRAM, NOTSILENT);
|
2008-09-22 07:01:57 +02:00
|
|
|
emulator.emuReset();
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
2008-09-17 03:54:21 +02:00
|
|
|
case 3: // Save Battery
|
2008-11-12 08:53:25 +01:00
|
|
|
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SRAM, NOTSILENT);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
2008-09-17 03:54:21 +02:00
|
|
|
case 4: // Load State
|
2008-11-12 08:53:25 +01:00
|
|
|
quit = retval = LoadBatteryOrState(GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
2008-09-17 03:54:21 +02:00
|
|
|
case 5: // Save State
|
2008-11-12 08:53:25 +01:00
|
|
|
SaveBatteryOrState(GCSettings.SaveMethod, FILE_SNAPSHOT, NOTSILENT);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
2008-10-09 08:48:46 +02:00
|
|
|
case 6: // Reset Zoom
|
|
|
|
zoom_reset ();
|
|
|
|
quit = retval = 1;
|
|
|
|
break;
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
case -1: // Button B
|
2008-10-09 08:48:46 +02:00
|
|
|
case 7: // Return to previous menu
|
2008-09-16 07:42:21 +02:00
|
|
|
retval = 0;
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = oldmenu;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Controller Configuration
|
|
|
|
***************************************************************************/
|
2008-12-30 01:10:12 +01:00
|
|
|
static u32
|
2008-09-16 07:42:21 +02:00
|
|
|
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
|
|
|
|
{
|
2008-09-17 03:54:21 +02:00
|
|
|
pressed = WPAD_ButtonsHeld (0);
|
2008-09-16 07:42:21 +02:00
|
|
|
}
|
|
|
|
#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()
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
static u32
|
2008-09-16 07:42:21 +02:00
|
|
|
GetButtonMap(u16 ctrlr_type, char* btn_name)
|
|
|
|
{
|
2008-12-30 01:10:12 +01:00
|
|
|
int cfg_text_count = 7;
|
|
|
|
char cfg_text[][50] = {
|
|
|
|
"Remapping ",
|
|
|
|
"Press Any Button",
|
|
|
|
"on the",
|
|
|
|
" ", // identify controller
|
|
|
|
" ",
|
|
|
|
"Press C-Left or",
|
|
|
|
"Home to exit"
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
u32 pressed, previous;
|
|
|
|
char temp[50] = "";
|
|
|
|
uint k;
|
|
|
|
pressed = 0; previous = 1;
|
|
|
|
|
|
|
|
switch (ctrlr_type) {
|
|
|
|
case CTRLR_NUNCHUK:
|
2008-12-18 19:58:30 +01:00
|
|
|
strncpy (cfg_text[3], "NUNCHUK", 7);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
case CTRLR_CLASSIC:
|
2008-12-18 19:58:30 +01:00
|
|
|
strncpy (cfg_text[3], "CLASSIC", 7);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
case CTRLR_GCPAD:
|
2008-12-18 19:58:30 +01:00
|
|
|
strncpy (cfg_text[3], "GC PAD", 7);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
case CTRLR_WIIMOTE:
|
2008-12-18 19:58:30 +01:00
|
|
|
strncpy (cfg_text[3], "WIIMOTE", 7);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*** note which button we are remapping ***/
|
2008-12-18 19:58:30 +01:00
|
|
|
sprintf (temp, "Remapping ");
|
2008-09-16 07:42:21 +02:00
|
|
|
for (k=0; k<9-strlen(btn_name); k++) strcat(temp, " "); // add whitespace padding to align text
|
|
|
|
strncat (temp, btn_name, 9); // snes 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); // display text
|
|
|
|
|
2008-09-17 03:54:21 +02:00
|
|
|
pressed = GetInput(ctrlr_type);
|
2008-09-16 07:42:21 +02:00
|
|
|
return pressed;
|
|
|
|
} // end getButtonMap()
|
|
|
|
|
2008-12-30 01:10:12 +01:00
|
|
|
static void
|
2008-09-16 07:42:21 +02:00
|
|
|
ConfigureButtons (u16 ctrlr_type)
|
|
|
|
{
|
2008-12-30 01:10:12 +01:00
|
|
|
int cfg_btns_count = 11;
|
|
|
|
char cfg_btns_menu[][50] = {
|
|
|
|
"B - ",
|
|
|
|
"A - ",
|
|
|
|
"SELECT - ",
|
|
|
|
"START - ",
|
|
|
|
"UP - ",
|
|
|
|
"DOWN - ",
|
|
|
|
"LEFT - ",
|
|
|
|
"RIGHT - ",
|
|
|
|
"L TRIG - ",
|
|
|
|
"R TRIG - ",
|
|
|
|
"Return to previous"
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
int quit = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
2008-12-18 19:58:30 +01:00
|
|
|
char menu_title[50];
|
2008-09-16 07:42:21 +02:00
|
|
|
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:
|
2008-12-18 19:58:30 +01:00
|
|
|
sprintf(menu_title, "VBA - NUNCHUK");
|
2008-09-16 07:42:21 +02:00
|
|
|
currentpadmap = ncpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_CLASSIC:
|
2008-12-18 19:58:30 +01:00
|
|
|
sprintf(menu_title, "VBA - CLASSIC");
|
2008-09-16 07:42:21 +02:00
|
|
|
currentpadmap = ccpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_GCPAD:
|
2008-12-18 19:58:30 +01:00
|
|
|
sprintf(menu_title, "VBA - GC PAD");
|
2008-09-16 07:42:21 +02:00
|
|
|
currentpadmap = gcpadmap;
|
|
|
|
break;
|
|
|
|
case CTRLR_WIIMOTE:
|
2008-12-18 19:58:30 +01:00
|
|
|
sprintf(menu_title, "VBA - WIIMOTE");
|
2008-09-16 07:42:21 +02:00
|
|
|
currentpadmap = wmpadmap;
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
/*** Update Menu with Current ButtonMap ***/
|
|
|
|
for (i=0; i<10; i++) // vba pad has 10 buttons to config (go thru them)
|
|
|
|
{
|
|
|
|
// 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 vba 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
|
2008-12-18 19:58:30 +01:00
|
|
|
strcat (temp, "---"); // otherwise, button is 'unmapped'
|
2008-09-16 07:42:21 +02:00
|
|
|
strncpy (cfg_btns_menu[i], temp, 19); // move back updated information
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = RunMenu (cfg_btns_menu, cfg_btns_count, menu_title, 16);
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
case 6:
|
|
|
|
case 7:
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
/*** Change button map ***/
|
|
|
|
// wait for input
|
|
|
|
memset (temp, 0, sizeof(temp));
|
|
|
|
strncpy(temp, cfg_btns_menu[ret], 6); // get the name of the vba 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-09-17 03:54:21 +02:00
|
|
|
case 10:
|
2008-09-16 07:42:21 +02:00
|
|
|
/*** Return ***/
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
menu = oldmenu;
|
|
|
|
} // end configurebuttons()
|
|
|
|
|
|
|
|
void
|
|
|
|
ConfigureControllers ()
|
|
|
|
{
|
2008-12-30 01:10:12 +01:00
|
|
|
int ctlrmenucount = 6;
|
|
|
|
char ctlrmenu[][50] = {
|
|
|
|
"Nunchuk",
|
|
|
|
"Classic Controller",
|
|
|
|
"Wiimote",
|
|
|
|
"Gamecube Pad",
|
|
|
|
"Save Preferences",
|
|
|
|
"Go Back"
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
int quit = 0;
|
|
|
|
int ret = 0;
|
|
|
|
int oldmenu = menu;
|
|
|
|
menu = 0;
|
|
|
|
|
|
|
|
// disable unavailable controller options if in GC mode
|
|
|
|
#ifndef HW_RVL
|
2008-10-29 07:34:15 +01:00
|
|
|
ctlrmenu[0][0] = 0;
|
|
|
|
ctlrmenu[1][0] = 0;
|
|
|
|
ctlrmenu[2][0] = 0;
|
2008-09-16 07:42:21 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*** Controller Config Menu ***/
|
2008-12-18 19:58:30 +01:00
|
|
|
ret = RunMenu (ctlrmenu, ctlrmenucount, "Configure Controllers");
|
2008-09-16 07:42:21 +02:00
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
/*** Configure Nunchuk ***/
|
|
|
|
ConfigureButtons (CTRLR_NUNCHUK);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
/*** Configure Classic ***/
|
|
|
|
ConfigureButtons (CTRLR_CLASSIC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
/*** Configure Wiimote ***/
|
|
|
|
ConfigureButtons (CTRLR_WIIMOTE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
/*** Configure GC Pad ***/
|
|
|
|
ConfigureButtons (CTRLR_GCPAD);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
/*** Save Preferences Now ***/
|
2008-12-19 00:21:51 +01:00
|
|
|
SavePrefs(NOTSILENT);
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: /*** Button B ***/
|
|
|
|
case 5:
|
|
|
|
/*** Return ***/
|
|
|
|
quit = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu = oldmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Main Menu
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
void
|
2008-09-17 03:54:21 +02:00
|
|
|
MainMenu (int selectedMenu)
|
2008-09-16 07:42:21 +02:00
|
|
|
{
|
2008-12-30 01:10:12 +01:00
|
|
|
int menucount = 8;
|
|
|
|
char menuitems[][50] = {
|
|
|
|
"Choose Game",
|
|
|
|
"Controller Configuration",
|
|
|
|
"Preferences",
|
|
|
|
"Game Menu",
|
|
|
|
"Credits",
|
|
|
|
"DVD Motor Off",
|
|
|
|
"Reset System",
|
|
|
|
"Return to Loader"
|
|
|
|
};
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
tb_t start,end;
|
|
|
|
mftb(&start);
|
|
|
|
|
|
|
|
int quit = 0;
|
|
|
|
int ret;
|
|
|
|
|
2008-11-13 09:00:16 +01:00
|
|
|
#ifdef HW_RVL
|
|
|
|
// don't show dvd motor off on the wii
|
|
|
|
menuitems[5][0] = 0;
|
|
|
|
// rename reset/exit items
|
|
|
|
sprintf (menuitems[6], "Return to Wii Menu");
|
|
|
|
sprintf (menuitems[7], "Return to Homebrew Channel");
|
|
|
|
#endif
|
|
|
|
|
2008-09-16 07:42:21 +02:00
|
|
|
// disable game-specific menu items if a ROM isn't loaded
|
2008-09-29 09:35:26 +02:00
|
|
|
if (!ROMLoaded)
|
2008-09-16 07:42:21 +02:00
|
|
|
menuitems[3][0] = '\0';
|
|
|
|
else
|
|
|
|
sprintf (menuitems[3], "Game Menu");
|
|
|
|
|
|
|
|
VIDEO_WaitVSync ();
|
|
|
|
|
|
|
|
while (quit == 0)
|
|
|
|
{
|
|
|
|
if(selectedMenu >= 0)
|
|
|
|
{
|
|
|
|
ret = selectedMenu;
|
|
|
|
selectedMenu = -1; // default back to main menu
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-12-18 19:58:30 +01:00
|
|
|
ret = RunMenu (menuitems, menucount, "Main Menu");
|
2008-09-16 07:42:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (ret)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
// Load ROM Menu
|
|
|
|
quit = LoadManager ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
// Configure Controllers
|
|
|
|
ConfigureControllers ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// Preferences
|
|
|
|
PreferencesMenu ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
// Game Options
|
|
|
|
quit = GameMenu ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
// Credits
|
|
|
|
Credits ();
|
|
|
|
WaitButtonA ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5:
|
2008-11-13 09:00:16 +01:00
|
|
|
// turn the dvd motor off (GC only)
|
|
|
|
#ifdef HW_DOL
|
|
|
|
dvd_motor_off ();
|
|
|
|
#endif
|
2008-11-20 18:59:47 +01:00
|
|
|
break;
|
2008-11-13 09:00:16 +01:00
|
|
|
|
|
|
|
case 6:
|
2008-09-16 07:42:21 +02:00
|
|
|
// Reset the Gamecube/Wii
|
|
|
|
Reboot();
|
|
|
|
break;
|
|
|
|
|
2008-11-13 09:00:16 +01:00
|
|
|
case 7:
|
2008-10-24 08:16:15 +02:00
|
|
|
ExitToLoader();
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case -1: // Button B
|
|
|
|
// Return to Game
|
2008-09-29 09:35:26 +02:00
|
|
|
if(ROMLoaded)
|
|
|
|
quit = 1;
|
2008-09-16 07:42:21 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-04 04:37: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-16 07:42:21 +02:00
|
|
|
|
|
|
|
mftb(&end);
|
|
|
|
loadtimeradjust += tb_diff_msec(&end, &start);
|
|
|
|
}
|