2012-01-29 22:11:47 +00:00
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
2012-01-29 22:16:39 +00:00
* Copyright ( C ) 2010 - 2012 - Hans - Kristian Arntzen
* Copyright ( C ) 2011 - 2012 - Daniel De Matteis
*
* Some code herein may be based on code found in BSNES .
*
* SSNES is free software : you can redistribute it and / or modify it under the terms
* of the GNU General Public License as published by the Free Software Found -
* ation , either version 3 of the License , or ( at your option ) any later version .
*
* SSNES is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE . See the GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License along with SSNES .
* If not , see < http : //www.gnu.org/licenses/>.
*/
2012-01-05 21:47:34 +00:00
2012-01-10 22:33:44 +00:00
# include <stdint.h>
# include <stdbool.h>
# include <stddef.h>
2012-01-11 00:04:17 +00:00
# include <string.h>
2012-01-10 22:33:44 +00:00
2012-01-05 21:47:34 +00:00
# include <sys/process.h>
2012-01-11 00:04:17 +00:00
# include <cell/sysmodule.h>
2012-01-16 14:45:55 +00:00
# include <sysutil/sysutil_screenshot.h>
2012-01-05 21:47:34 +00:00
# include <sysutil/sysutil_common.h>
# include <sys/spu_initialize.h>
2012-01-11 00:04:17 +00:00
# include <sysutil/sysutil_gamecontent.h>
2012-01-11 21:55:07 +00:00
# include "ps3_input.h"
2012-01-11 22:48:48 +00:00
# include "ps3_video_psgl.h"
2012-01-11 21:55:07 +00:00
2012-01-30 17:17:47 +00:00
# include "../console/main_wrap.h"
2012-01-11 00:04:17 +00:00
# include "../conf/config_file.h"
2012-01-30 12:45:37 +00:00
# include "../conf/config_file_macros.h"
2012-01-11 00:04:17 +00:00
# include "../general.h"
2012-01-30 19:05:36 +00:00
# include "../file.h"
2012-01-12 23:01:52 +00:00
# include "shared.h"
2012-01-11 21:27:07 +00:00
# include "menu.h"
2012-01-11 00:04:17 +00:00
# define MAX_PATH_LENGTH 1024
2012-01-29 22:11:47 +00:00
# define EMULATOR_CONTENT_DIR "SSNE10000"
char special_action_msg [ 256 ] ; /* message which should be overlaid on top of the screen*/
uint32_t special_action_msg_expired ; /* time at which the message no longer needs to be overlaid onscreen*/
2012-01-20 23:30:01 +00:00
uint64_t ingame_menu_item = 0 ;
2012-01-11 01:25:49 +00:00
2012-01-11 00:04:17 +00:00
char contentInfoPath [ MAX_PATH_LENGTH ] ;
char usrDirPath [ MAX_PATH_LENGTH ] ;
char DEFAULT_PRESET_FILE [ MAX_PATH_LENGTH ] ;
char DEFAULT_BORDER_FILE [ MAX_PATH_LENGTH ] ;
char DEFAULT_MENU_BORDER_FILE [ MAX_PATH_LENGTH ] ;
char GAME_AWARE_SHADER_DIR_PATH [ MAX_PATH_LENGTH ] ;
char PRESETS_DIR_PATH [ MAX_PATH_LENGTH ] ;
char INPUT_PRESETS_DIR_PATH [ MAX_PATH_LENGTH ] ;
char BORDERS_DIR_PATH [ MAX_PATH_LENGTH ] ;
char SHADERS_DIR_PATH [ MAX_PATH_LENGTH ] ;
char DEFAULT_SHADER_FILE [ MAX_PATH_LENGTH ] ;
char DEFAULT_MENU_SHADER_FILE [ MAX_PATH_LENGTH ] ;
char SYS_CONFIG_FILE [ MAX_PATH_LENGTH ] ;
char MULTIMAN_GAME_TO_BOOT [ MAX_PATH_LENGTH ] ;
2012-02-01 14:15:15 +00:00
static bool frame_advance_disabled = true ;
2012-01-05 21:47:34 +00:00
int ssnes_main ( int argc , char * argv [ ] ) ;
SYS_PROCESS_PARAM ( 1001 , 0x100000 )
# undef main
2012-01-11 00:04:17 +00:00
2012-01-12 23:01:52 +00:00
uint32_t set_text_message_speed ( uint32_t value )
{
2012-01-29 22:16:39 +00:00
return g_frame_count + value ;
2012-01-12 23:01:52 +00:00
}
2012-01-11 01:25:49 +00:00
void set_text_message ( const char * message , uint32_t speed )
{
2012-01-29 22:16:39 +00:00
snprintf ( special_action_msg , sizeof ( special_action_msg ) , message ) ;
special_action_msg_expired = set_text_message_speed ( speed ) ;
2012-01-11 01:25:49 +00:00
}
2012-01-11 00:04:17 +00:00
static bool file_exists ( const char * filename )
{
2012-01-29 22:16:39 +00:00
CellFsStat sb ;
if ( cellFsStat ( filename , & sb ) = = CELL_FS_SUCCEEDED )
return true ;
else
return false ;
2012-01-11 00:04:17 +00:00
}
2012-01-30 12:45:37 +00:00
static void set_default_settings ( void )
{
// g_settings
strlcpy ( g_settings . cheat_database , usrDirPath , sizeof ( g_settings . cheat_database ) ) ;
g_settings . rewind_enable = false ;
strlcpy ( g_settings . video . cg_shader_path , DEFAULT_SHADER_FILE , sizeof ( g_settings . video . cg_shader_path ) ) ;
g_settings . video . fbo_scale_x = 2.0f ;
g_settings . video . fbo_scale_y = 2.0f ;
g_settings . video . render_to_texture = true ;
strlcpy ( g_settings . video . second_pass_shader , DEFAULT_SHADER_FILE , sizeof ( g_settings . video . second_pass_shader ) ) ;
g_settings . video . second_pass_smooth = true ;
g_settings . video . smooth = true ;
g_settings . video . vsync = true ;
2012-01-30 14:16:29 +00:00
strlcpy ( g_settings . cheat_database , usrDirPath , sizeof ( g_settings . cheat_database ) ) ;
2012-01-30 14:59:15 +00:00
g_settings . video . msg_pos_x = 0.09f ;
g_settings . video . msg_pos_y = 0.90f ;
2012-01-31 11:13:43 +00:00
g_settings . video . aspect_ratio = - 1.0f ;
2012-01-30 12:45:37 +00:00
2012-02-02 14:46:27 +00:00
for ( uint32_t x = 0 ; x < MAX_PLAYERS ; x + + )
{
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_B ] . id = SNES_DEVICE_ID_JOYPAD_B ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_B ] . joykey = CTRL_CROSS_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_Y ] . id = SNES_DEVICE_ID_JOYPAD_Y ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_Y ] . joykey = CTRL_SQUARE_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_SELECT ] . id = SNES_DEVICE_ID_JOYPAD_SELECT ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_SELECT ] . joykey = CTRL_SELECT_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_START ] . id = SNES_DEVICE_ID_JOYPAD_START ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_START ] . joykey = CTRL_START_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_UP ] . id = SNES_DEVICE_ID_JOYPAD_UP ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_UP ] . joykey = CTRL_UP_MASK ;
2012-02-02 15:12:38 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_UP ] . joyaxis = CTRL_LSTICK_UP_MASK ;
2012-02-02 14:46:27 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_DOWN ] . id = SNES_DEVICE_ID_JOYPAD_DOWN ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_DOWN ] . joykey = CTRL_DOWN_MASK ;
2012-02-02 15:12:38 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_DOWN ] . joyaxis = CTRL_LSTICK_DOWN_MASK ;
2012-02-02 14:46:27 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_LEFT ] . id = SNES_DEVICE_ID_JOYPAD_LEFT ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_LEFT ] . joykey = CTRL_LEFT_MASK ;
2012-02-02 15:12:38 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_LEFT ] . joyaxis = CTRL_LSTICK_LEFT_MASK ;
2012-02-02 14:46:27 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_RIGHT ] . id = SNES_DEVICE_ID_JOYPAD_RIGHT ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_RIGHT ] . joykey = CTRL_RIGHT_MASK ;
2012-02-02 15:12:38 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_RIGHT ] . joyaxis = CTRL_LSTICK_RIGHT_MASK ;
2012-02-02 14:46:27 +00:00
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_A ] . id = SNES_DEVICE_ID_JOYPAD_A ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_A ] . joykey = CTRL_CIRCLE_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_X ] . id = SNES_DEVICE_ID_JOYPAD_X ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_X ] . joykey = CTRL_TRIANGLE_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_L ] . id = SNES_DEVICE_ID_JOYPAD_L ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_L ] . joykey = CTRL_L1_MASK ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_R ] . id = SNES_DEVICE_ID_JOYPAD_R ;
g_settings . input . binds [ x ] [ SNES_DEVICE_ID_JOYPAD_R ] . joykey = CTRL_R1_MASK ;
}
2012-01-30 12:45:37 +00:00
// g_console
2012-01-30 16:18:31 +00:00
g_console . block_config_read = true ;
2012-02-09 13:25:13 +00:00
g_console . emulator_initialized = 0 ;
2012-01-30 12:45:37 +00:00
g_console . screenshots_enable = false ;
g_console . throttle_enable = true ;
2012-02-09 13:25:13 +00:00
g_console . initialize_ssnes_enable = false ;
2012-01-30 12:45:37 +00:00
g_console . triple_buffering_enable = true ;
2012-01-30 16:18:31 +00:00
g_console . default_savestate_dir_enable = false ;
g_console . default_sram_dir_enable = false ;
2012-02-09 13:25:13 +00:00
g_console . mode_switch = MODE_MENU ;
2012-01-30 18:44:21 +00:00
g_console . screen_orientation = ORIENTATION_NORMAL ;
2012-01-30 12:45:37 +00:00
g_console . current_resolution_id = CELL_VIDEO_OUT_RESOLUTION_UNDEFINED ;
2012-01-30 14:16:29 +00:00
strlcpy ( g_console . default_rom_startup_dir , " / " , sizeof ( g_console . default_rom_startup_dir ) ) ;
2012-01-30 16:18:31 +00:00
strlcpy ( g_console . default_savestate_dir , usrDirPath , sizeof ( g_console . default_savestate_dir ) ) ;
strlcpy ( g_console . default_sram_dir , usrDirPath , sizeof ( g_console . default_sram_dir ) ) ;
2012-01-31 13:12:00 +00:00
g_console . aspect_ratio_index = 0 ;
2012-01-31 17:21:53 +00:00
strlcpy ( g_console . aspect_ratio_name , " 4:3 " , sizeof ( g_console . aspect_ratio_name ) ) ;
2012-01-31 17:51:45 +00:00
g_console . menu_font_size = 1.0f ;
2012-02-02 17:39:09 +00:00
g_console . overscan_enable = false ;
g_console . overscan_amount = 0.0f ;
2012-01-30 12:45:37 +00:00
// g_extern
g_extern . state_slot = 0 ;
2012-01-30 14:59:15 +00:00
g_extern . audio_data . mute = 0 ;
2012-01-30 16:18:31 +00:00
g_extern . verbose = true ;
2012-01-30 12:45:37 +00:00
}
2012-01-29 22:11:47 +00:00
static void init_settings ( void )
{
2012-01-29 22:16:39 +00:00
if ( ! file_exists ( SYS_CONFIG_FILE ) )
{
2012-01-30 14:59:15 +00:00
SSNES_ERR ( " Config file \" %s \" doesn't exist! Creating... \n " , SYS_CONFIG_FILE ) ;
2012-01-29 22:16:39 +00:00
FILE * f ;
f = fopen ( SYS_CONFIG_FILE , " w " ) ;
fclose ( f ) ;
}
2012-01-30 12:45:37 +00:00
config_file_t * conf = config_file_new ( SYS_CONFIG_FILE ) ;
2012-01-29 22:16:39 +00:00
2012-01-30 08:53:16 +00:00
// g_settings
2012-01-30 14:59:15 +00:00
CONFIG_GET_STRING ( cheat_database , " cheat_database " ) ;
2012-01-30 12:45:37 +00:00
CONFIG_GET_BOOL ( rewind_enable , " rewind_enable " ) ;
CONFIG_GET_STRING ( video . cg_shader_path , " video_cg_shader " ) ;
CONFIG_GET_STRING ( video . second_pass_shader , " video_second_pass_shader " ) ;
2012-01-30 14:14:30 +00:00
CONFIG_GET_FLOAT ( video . fbo_scale_x , " video_fbo_scale_x " ) ;
CONFIG_GET_FLOAT ( video . fbo_scale_y , " video_fbo_scale_y " ) ;
2012-01-30 12:45:37 +00:00
CONFIG_GET_BOOL ( video . render_to_texture , " video_render_to_texture " ) ;
CONFIG_GET_BOOL ( video . second_pass_smooth , " video_second_pass_smooth " ) ;
CONFIG_GET_BOOL ( video . smooth , " video_smooth " ) ;
CONFIG_GET_BOOL ( video . vsync , " video_vsync " ) ;
2012-01-31 11:13:43 +00:00
CONFIG_GET_FLOAT ( video . aspect_ratio , " video_aspect_ratio " ) ;
2012-01-30 08:53:16 +00:00
// g_console
2012-02-02 17:39:09 +00:00
CONFIG_GET_BOOL_CONSOLE ( overscan_enable , " overscan_enable " ) ;
2012-01-30 12:45:37 +00:00
CONFIG_GET_BOOL_CONSOLE ( screenshots_enable , " screenshots_enable " ) ;
CONFIG_GET_BOOL_CONSOLE ( throttle_enable , " throttle_enable " ) ;
CONFIG_GET_BOOL_CONSOLE ( triple_buffering_enable , " triple_buffering_enable " ) ;
2012-01-31 13:12:00 +00:00
CONFIG_GET_INT_CONSOLE ( aspect_ratio_index , " aspect_ratio_index " ) ;
2012-01-30 12:45:37 +00:00
CONFIG_GET_INT_CONSOLE ( current_resolution_id , " current_resolution_id " ) ;
2012-01-30 18:44:21 +00:00
CONFIG_GET_INT_CONSOLE ( screen_orientation , " screen_orientation " ) ;
2012-01-31 17:21:53 +00:00
CONFIG_GET_STRING_CONSOLE ( aspect_ratio_name , " aspect_ratio_name " ) ;
2012-01-30 14:59:15 +00:00
CONFIG_GET_STRING_CONSOLE ( default_rom_startup_dir , " default_rom_startup_dir " ) ;
2012-01-31 17:51:45 +00:00
CONFIG_GET_FLOAT_CONSOLE ( menu_font_size , " menu_font_size " ) ;
2012-02-02 17:39:09 +00:00
CONFIG_GET_FLOAT_CONSOLE ( overscan_amount , " overscan_amount " ) ;
2012-01-30 08:53:16 +00:00
// g_extern
2012-01-30 12:45:37 +00:00
CONFIG_GET_INT_EXTERN ( state_slot , " state_slot " ) ;
2012-01-30 14:59:15 +00:00
CONFIG_GET_INT_EXTERN ( audio_data . mute , " audio_mute " ) ;
}
static void save_settings ( void )
{
if ( ! file_exists ( SYS_CONFIG_FILE ) )
{
FILE * f ;
f = fopen ( SYS_CONFIG_FILE , " w " ) ;
fclose ( f ) ;
}
config_file_t * conf = config_file_new ( SYS_CONFIG_FILE ) ;
2012-01-30 15:36:08 +00:00
if ( conf = = NULL )
conf = config_file_new ( NULL ) ;
2012-01-30 14:59:15 +00:00
// g_settings
config_set_string ( conf , " cheat_database_path " , g_settings . cheat_database ) ;
config_set_bool ( conf , " rewind_enable " , g_settings . rewind_enable ) ;
config_set_string ( conf , " video_cg_shader " , g_settings . video . cg_shader_path ) ;
config_set_string ( conf , " video_second_pass_shader " , g_settings . video . second_pass_shader ) ;
2012-01-31 13:12:00 +00:00
config_set_float ( conf , " video_aspect_ratio " , g_settings . video . aspect_ratio ) ;
2012-01-30 14:59:15 +00:00
config_set_float ( conf , " video_fbo_scale_x " , g_settings . video . fbo_scale_x ) ;
config_set_float ( conf , " video_fbo_scale_y " , g_settings . video . fbo_scale_y ) ;
config_set_bool ( conf , " video_render_to_texture " , g_settings . video . render_to_texture ) ;
config_set_bool ( conf , " video_second_pass_smooth " , g_settings . video . second_pass_smooth ) ;
config_set_bool ( conf , " video_smooth " , g_settings . video . smooth ) ;
config_set_bool ( conf , " video_vsync " , g_settings . video . vsync ) ;
// g_console
2012-02-02 17:39:09 +00:00
config_set_bool ( conf , " overscan_enable " , g_console . overscan_enable ) ;
2012-01-30 14:59:15 +00:00
config_set_bool ( conf , " screenshots_enable " , g_console . screenshots_enable ) ;
config_set_bool ( conf , " throttle_enable " , g_console . throttle_enable ) ;
config_set_bool ( conf , " triple_buffering_enable " , g_console . triple_buffering_enable ) ;
2012-01-31 13:12:00 +00:00
config_set_int ( conf , " aspect_ratio_index " , g_console . aspect_ratio_index ) ;
2012-01-30 14:59:15 +00:00
config_set_int ( conf , " current_resolution_id " , g_console . current_resolution_id ) ;
2012-01-30 18:44:21 +00:00
config_set_int ( conf , " screen_orientation " , g_console . screen_orientation ) ;
2012-01-31 17:21:53 +00:00
config_set_string ( conf , " aspect_ratio_name " , g_console . aspect_ratio_name ) ;
2012-01-30 14:59:15 +00:00
config_set_string ( conf , " default_rom_startup_dir " , g_console . default_rom_startup_dir ) ;
2012-01-31 17:51:45 +00:00
config_set_float ( conf , " menu_font_size " , g_console . menu_font_size ) ;
2012-02-02 17:39:09 +00:00
config_set_float ( conf , " overscan_amount " , g_console . overscan_amount ) ;
2012-01-30 14:59:15 +00:00
// g_extern
config_set_int ( conf , " state_slot " , g_extern . state_slot ) ;
config_set_int ( conf , " audio_mute " , g_extern . audio_data . mute ) ;
if ( ! config_file_write ( conf , SYS_CONFIG_FILE ) )
SSNES_ERR ( " Failed to write config file to \" %s \" ! Check permissions! \n " , SYS_CONFIG_FILE ) ;
2012-01-30 15:36:08 +00:00
free ( conf ) ;
2012-01-29 22:11:47 +00:00
}
2012-02-04 12:29:02 +00:00
static void callback_sysutil_exit ( uint64_t status , uint64_t param , void * userdata )
{
( void ) param ;
( void ) userdata ;
switch ( status )
{
case CELL_SYSUTIL_REQUEST_EXITGAME :
g_console . menu_enable = false ;
g_quitting = true ;
g_console . ingame_menu_enable = false ;
g_console . mode_switch = MODE_EXIT ;
2012-02-09 13:25:13 +00:00
if ( g_console . emulator_initialized )
2012-02-04 12:29:02 +00:00
ssnes_main_deinit ( ) ;
break ;
}
}
static void get_environment_settings ( void )
2012-01-11 00:04:17 +00:00
{
2012-01-29 22:16:39 +00:00
unsigned int get_type ;
unsigned int get_attributes ;
CellGameContentSize size ;
char dirName [ CELL_GAME_DIRNAME_SIZE ] ;
2012-02-04 12:29:02 +00:00
SSNES_LOG ( " Registering Callback \n " ) ;
cellSysutilRegisterCallback ( 0 , callback_sysutil_exit , NULL ) ;
# ifdef MULTIMAN_SUPPORT
g_console . return_to_multiman_enable = true ;
if ( argc > 1 )
{
strncpy ( MULTIMAN_GAME_TO_BOOT , argv [ 1 ] , sizeof ( MULTIMAN_GAME_TO_BOOT ) ) ;
}
# else
g_console . return_to_multiman_enable = false ;
# endif
2012-01-29 22:16:39 +00:00
memset ( & size , 0x00 , sizeof ( CellGameContentSize ) ) ;
int ret = cellGameBootCheck ( & get_type , & get_attributes , & size , dirName ) ;
if ( ret < 0 )
{
2012-02-04 12:29:02 +00:00
SSNES_ERR ( " cellGameBootCheck() Error: 0x%x \n " , ret ) ;
2012-01-29 22:16:39 +00:00
}
else
{
2012-02-04 12:29:02 +00:00
SSNES_LOG ( " cellGameBootCheck() OK \n " ) ;
SSNES_LOG ( " get_type = [%d] get_attributes = [0x%08x] dirName = [%s] \n " , get_type , get_attributes , dirName ) ;
SSNES_LOG ( " hddFreeSizeKB = [%d] sizeKB = [%d] sysSizeKB = [%d] \n " , size . hddFreeSizeKB , size . sizeKB , size . sysSizeKB ) ;
2012-01-29 22:16:39 +00:00
ret = cellGameContentPermit ( contentInfoPath , usrDirPath ) ;
2012-02-04 12:29:02 +00:00
if ( g_console . return_to_multiman_enable )
2012-01-29 22:16:39 +00:00
{
snprintf ( contentInfoPath , sizeof ( contentInfoPath ) , " /dev_hdd0/game/%s " , EMULATOR_CONTENT_DIR ) ;
snprintf ( usrDirPath , sizeof ( usrDirPath ) , " /dev_hdd0/game/%s/USRDIR " , EMULATOR_CONTENT_DIR ) ;
}
if ( ret < 0 )
{
2012-02-04 12:29:02 +00:00
SSNES_ERR ( " cellGameContentPermit() Error: 0x%x \n " , ret ) ;
2012-01-29 22:16:39 +00:00
}
else
{
2012-02-04 12:29:02 +00:00
SSNES_LOG ( " cellGameContentPermit() OK \n " ) ;
SSNES_LOG ( " contentInfoPath:[%s] \n " , contentInfoPath ) ;
SSNES_LOG ( " usrDirPath:[%s] \n " , usrDirPath ) ;
2012-01-29 22:16:39 +00:00
}
/* now we fill in all the variables */
snprintf ( DEFAULT_PRESET_FILE , sizeof ( DEFAULT_PRESET_FILE ) , " %s/presets/stock.conf " , usrDirPath ) ;
snprintf ( DEFAULT_BORDER_FILE , sizeof ( DEFAULT_BORDER_FILE ) , " %s/borders/Centered-1080p/mega-man-2.png " , usrDirPath ) ;
snprintf ( DEFAULT_MENU_BORDER_FILE , sizeof ( DEFAULT_MENU_BORDER_FILE ) , " %s/borders/Menu/main-menu.jpg " , usrDirPath ) ;
snprintf ( GAME_AWARE_SHADER_DIR_PATH , sizeof ( GAME_AWARE_SHADER_DIR_PATH ) , " %s/gameaware " , usrDirPath ) ;
snprintf ( PRESETS_DIR_PATH , sizeof ( PRESETS_DIR_PATH ) , " %s/presets " , usrDirPath ) ;
snprintf ( INPUT_PRESETS_DIR_PATH , sizeof ( INPUT_PRESETS_DIR_PATH ) , " %s/input-presets " , usrDirPath ) ;
snprintf ( BORDERS_DIR_PATH , sizeof ( BORDERS_DIR_PATH ) , " %s/borders " , usrDirPath ) ;
snprintf ( SHADERS_DIR_PATH , sizeof ( SHADERS_DIR_PATH ) , " %s/shaders " , usrDirPath ) ;
snprintf ( DEFAULT_SHADER_FILE , sizeof ( DEFAULT_SHADER_FILE ) , " %s/shaders/stock.cg " , usrDirPath ) ;
2012-01-30 17:45:59 +00:00
snprintf ( DEFAULT_MENU_SHADER_FILE , sizeof ( DEFAULT_MENU_SHADER_FILE ) , " %s/shaders/Borders/Menu/border-only-ssnes.cg " , usrDirPath ) ;
2012-01-29 22:16:39 +00:00
snprintf ( SYS_CONFIG_FILE , sizeof ( SYS_CONFIG_FILE ) , " %s/ssnes.cfg " , usrDirPath ) ;
}
2012-01-11 00:04:17 +00:00
}
2012-01-13 00:27:18 +00:00
2012-01-20 23:30:01 +00:00
# define ingame_menu_reset_entry_colors(ingame_menu_item) \
{ \
2012-01-29 22:16:39 +00:00
for ( int i = 0 ; i < MENU_ITEM_LAST ; i + + ) \
menuitem_colors [ i ] = GREEN ; \
menuitem_colors [ ingame_menu_item ] = RED ; \
2012-01-20 23:30:01 +00:00
}
static void ingame_menu ( void )
{
2012-01-29 22:16:39 +00:00
uint32_t menuitem_colors [ MENU_ITEM_LAST ] ;
char comment [ 256 ] , msg_temp [ 256 ] ;
2012-01-30 08:53:16 +00:00
ps3graphics_block_swap ( ) ;
2012-01-29 22:16:39 +00:00
do
{
uint64_t state = cell_pad_input_poll_device ( 0 ) ;
static uint64_t old_state = 0 ;
uint64_t stuck_in_loop = 1 ;
const uint64_t button_was_pressed = old_state & ( old_state ^ state ) ;
const uint64_t button_was_held = old_state & state ;
static uint64_t blocking = 0 ;
ssnes_render_cached_frame ( ) ;
if ( g_frame_count < special_action_msg_expired & & blocking )
{
}
else
{
if ( CTRL_CIRCLE ( state ) )
{
2012-02-01 14:15:15 +00:00
frame_advance_disabled = true ;
2012-01-29 22:16:39 +00:00
ingame_menu_item = 0 ;
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-01-29 22:16:39 +00:00
}
switch ( ingame_menu_item )
{
case MENU_ITEM_LOAD_STATE :
if ( CTRL_CROSS ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
char msg [ 512 ] ;
bool ret = load_state ( g_extern . savestate_name ) ;
2012-02-02 13:41:05 +00:00
msg_queue_clear ( g_extern . msg_queue ) ;
2012-01-30 19:05:36 +00:00
if ( ret )
2012-02-02 13:41:05 +00:00
snprintf ( msg , sizeof ( msg ) , " Loaded state from slot #%d! " , g_extern . state_slot ) ;
2012-01-30 19:05:36 +00:00
else
snprintf ( msg , sizeof ( msg ) , " Can't load from save state slot #%d " , g_extern . state_slot ) ;
2012-02-02 13:41:05 +00:00
msg_queue_clear ( g_extern . msg_queue ) ;
msg_queue_push ( g_extern . msg_queue , msg , 1 , 180 ) ;
2012-01-30 19:05:36 +00:00
ingame_menu_item = 0 ;
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_LEFT ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
if ( g_extern . state_slot > 0 )
{
char msg [ 512 ] ;
g_extern . state_slot - - ;
snprintf ( msg , sizeof ( msg ) , " Save state slot changed to: #%d " , g_extern . state_slot ) ;
set_text_message ( msg , 60 ) ;
}
blocking = 0 ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_RIGHT ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
char msg [ 512 ] ;
g_extern . state_slot + + ;
snprintf ( msg , sizeof ( msg ) , " Save state slot changed to: #%d " , g_extern . state_slot ) ;
set_text_message ( msg , 60 ) ;
blocking = 0 ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press LEFT or RIGHT to change the current save state slot. \n Press CROSS to load the state from the currently selected save state slot. " ) ;
break ;
case MENU_ITEM_SAVE_STATE :
if ( CTRL_CROSS ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
char msg [ 512 ] ;
bool ret = save_state ( g_extern . savestate_name ) ;
2012-02-02 13:41:05 +00:00
snprintf ( msg , sizeof ( msg ) , " Saved state to slot #%d! " , g_extern . state_slot ) ;
2012-01-30 19:05:36 +00:00
2012-02-02 13:41:05 +00:00
msg_queue_clear ( g_extern . msg_queue ) ;
msg_queue_push ( g_extern . msg_queue , msg , 1 , 180 ) ;
2012-01-30 19:05:36 +00:00
ingame_menu_item = 0 ;
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_LEFT ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
if ( g_extern . state_slot > 0 )
{
char msg [ 512 ] ;
g_extern . state_slot - - ;
snprintf ( msg , sizeof ( msg ) , " Save state slot changed to: #%d " , g_extern . state_slot ) ;
set_text_message ( msg , 60 ) ;
}
blocking = 0 ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_RIGHT ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_pressed ) )
{
2012-01-30 19:05:36 +00:00
char msg [ 512 ] ;
g_extern . state_slot + + ;
snprintf ( msg , sizeof ( msg ) , " Save state slot changed to: #%d " , g_extern . state_slot ) ;
set_text_message ( msg , 60 ) ;
blocking = 0 ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press LEFT or RIGHT to change the current save state slot. \n Press CROSS to save the state to the currently selected save state slot. " ) ;
break ;
case MENU_ITEM_KEEP_ASPECT_RATIO :
if ( CTRL_LEFT ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_pressed ) )
{
2012-01-31 13:12:00 +00:00
if ( g_console . aspect_ratio_index > 0 )
{
g_console . aspect_ratio_index - - ;
ps3graphics_set_aspect_ratio ( g_console . aspect_ratio_index ) ;
}
2012-01-29 22:16:39 +00:00
}
if ( CTRL_RIGHT ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_pressed ) )
{
2012-01-31 13:12:00 +00:00
if ( g_console . aspect_ratio_index < LAST_ASPECT_RATIO )
{
g_console . aspect_ratio_index + + ;
ps3graphics_set_aspect_ratio ( g_console . aspect_ratio_index ) ;
}
2012-01-29 22:16:39 +00:00
}
if ( CTRL_START ( button_was_pressed ) )
{
2012-01-31 13:12:00 +00:00
g_console . aspect_ratio_index = ASPECT_RATIO_4_3 ;
ps3graphics_set_aspect_ratio ( g_console . aspect_ratio_index ) ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press LEFT or RIGHT to change the [Aspect Ratio]. \n Press START to reset back to default values. " ) ;
break ;
case MENU_ITEM_OVERSCAN_AMOUNT :
if ( CTRL_LEFT ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_pressed ) | | CTRL_CROSS ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_held ) )
{
2012-02-02 17:39:09 +00:00
g_console . overscan_amount - = 0.01f ;
g_console . overscan_enable = true ;
if ( g_console . overscan_amount = = 0.00f )
g_console . overscan_enable = false ;
ps3graphics_set_overscan ( g_console . overscan_enable , g_console . overscan_amount , 1 ) ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_RIGHT ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_pressed ) | | CTRL_CROSS ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_held ) )
{
2012-02-02 17:39:09 +00:00
g_console . overscan_amount + = 0.01f ;
g_console . overscan_enable = true ;
if ( g_console . overscan_amount = = 0.0f )
g_console . overscan_amount = false ;
ps3graphics_set_overscan ( g_console . overscan_enable , g_console . overscan_amount , 1 ) ;
2012-01-29 22:16:39 +00:00
}
if ( CTRL_START ( button_was_pressed ) )
{
2012-02-02 17:39:09 +00:00
g_console . overscan_amount = 0.0f ;
g_console . overscan_enable = false ;
ps3graphics_set_overscan ( g_console . overscan_enable , g_console . overscan_amount , 1 ) ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press LEFT or RIGHT to change the [Overscan] settings. \n Press START to reset back to default values. " ) ;
break ;
case MENU_ITEM_ORIENTATION :
if ( CTRL_LEFT ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_pressed ) | | CTRL_CROSS ( button_was_pressed ) | | CTRL_LSTICK_LEFT ( button_was_held ) )
{
2012-01-30 18:44:21 +00:00
if ( g_console . screen_orientation > ORIENTATION_NORMAL )
{
g_console . screen_orientation - - ;
ps3graphics_set_orientation ( g_console . screen_orientation ) ;
}
2012-01-29 22:16:39 +00:00
}
if ( CTRL_RIGHT ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_pressed ) | | CTRL_CROSS ( button_was_pressed ) | | CTRL_LSTICK_RIGHT ( button_was_held ) )
{
2012-01-30 18:44:21 +00:00
if ( ( g_console . screen_orientation + 1 ) < ORIENTATION_END )
{
g_console . screen_orientation + + ;
ps3graphics_set_orientation ( g_console . screen_orientation ) ;
}
2012-01-29 22:16:39 +00:00
}
if ( CTRL_START ( button_was_pressed ) )
{
2012-01-30 18:44:21 +00:00
g_console . screen_orientation = ORIENTATION_NORMAL ;
ps3graphics_set_orientation ( g_console . screen_orientation ) ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press LEFT or RIGHT to change the [Orientation] settings. \n Press START to reset back to default values. " ) ;
break ;
case MENU_ITEM_FRAME_ADVANCE :
if ( CTRL_CROSS ( state ) | | CTRL_R2 ( state ) | | CTRL_L2 ( state ) )
{
2012-02-01 14:15:15 +00:00
frame_advance_disabled = false ;
ingame_menu_item = MENU_ITEM_FRAME_ADVANCE ;
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS', 'L2' or 'R2' button to step one frame. \n NOTE: Pressing the button rapidly will advance the frame more slowly \n and prevent buttons from being input. " ) ;
break ;
case MENU_ITEM_RESIZE_MODE :
if ( CTRL_CROSS ( state ) )
{
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Allows you to resize the screen by moving around the two analog sticks. \n Press TRIANGLE to reset to default values, and CIRCLE to go back to the \n in-game menu. " ) ;
break ;
case MENU_ITEM_SCREENSHOT_MODE :
if ( CTRL_CROSS ( state ) )
{
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Allows you to take a screenshot without any text clutter. \n Press CIRCLE to go back to the in-game menu while in 'Screenshot Mode'. " ) ;
break ;
case MENU_ITEM_RETURN_TO_GAME :
if ( CTRL_CROSS ( button_was_pressed ) )
{
2012-02-01 14:15:15 +00:00
frame_advance_disabled = true ;
2012-01-29 22:16:39 +00:00
ingame_menu_item = 0 ;
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS' to return back to the game. " ) ;
break ;
case MENU_ITEM_RESET :
if ( CTRL_CROSS ( button_was_pressed ) )
{
ingame_menu_item = 0 ;
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EMULATION ;
2012-02-02 19:39:28 +00:00
ssnes_game_reset ( ) ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS' to reset the game. " ) ;
break ;
case MENU_ITEM_RETURN_TO_MENU :
if ( CTRL_CROSS ( button_was_pressed ) )
{
ingame_menu_item = 0 ;
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . menu_enable = false ;
g_console . mode_switch = MODE_MENU ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS' to return to the ROM Browser menu. " ) ;
break ;
2012-01-20 23:30:01 +00:00
# ifdef MULTIMAN_SUPPORT
2012-01-29 22:16:39 +00:00
case MENU_ITEM_RETURN_TO_MULTIMAN :
if ( CTRL_CROSS ( button_was_pressed ) )
{
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EXIT ;
2012-01-29 22:16:39 +00:00
}
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS' to quit the emulator and return to multiMAN. " ) ;
break ;
2012-01-20 23:30:01 +00:00
# endif
2012-01-29 22:16:39 +00:00
case MENU_ITEM_RETURN_TO_XMB :
if ( CTRL_CROSS ( button_was_pressed ) )
{
2012-01-30 08:53:16 +00:00
g_console . ingame_menu_enable = false ;
2012-01-20 23:30:01 +00:00
# ifdef MULTIMAN_SUPPORT
2012-01-29 22:16:39 +00:00
return_to_MM = false ;
2012-01-20 23:30:01 +00:00
# endif
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_EXIT ;
2012-01-29 22:16:39 +00:00
}
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
ingame_menu_reset_entry_colors ( ingame_menu_item ) ;
strcpy ( comment , " Press 'CROSS' to quit the emulator and return to the XMB. " ) ;
break ;
}
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
if ( CTRL_UP ( button_was_pressed ) | | CTRL_LSTICK_UP ( button_was_pressed ) )
{
if ( ingame_menu_item > 0 )
ingame_menu_item - - ;
}
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
if ( CTRL_DOWN ( button_was_pressed ) | | CTRL_LSTICK_DOWN ( button_was_pressed ) )
{
if ( ingame_menu_item < MENU_ITEM_LAST )
ingame_menu_item + + ;
}
}
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
float x_position = 0.3f ;
float font_size = 1.1f ;
float ypos = 0.19f ;
float ypos_increment = 0.04f ;
2012-01-20 23:30:01 +00:00
2012-01-30 18:44:21 +00:00
switch ( g_console . screen_orientation )
{
case ORIENTATION_NORMAL :
snprintf ( msg_temp , sizeof ( msg_temp ) , " Normal " ) ;
break ;
case ORIENTATION_VERTICAL :
snprintf ( msg_temp , sizeof ( msg_temp ) , " Vertical " ) ;
break ;
case ORIENTATION_FLIPPED :
snprintf ( msg_temp , sizeof ( msg_temp ) , " Flipped " ) ;
break ;
case ORIENTATION_FLIPPED_ROTATED :
snprintf ( msg_temp , sizeof ( msg_temp ) , " Flipped Rotated " ) ;
break ;
}
2012-01-29 22:16:39 +00:00
cellDbgFontPrintf ( x_position , 0.10f , 1.4f + 0.01f , BLUE , " Quick Menu " ) ;
cellDbgFontPrintf ( x_position , 0.10f , 1.4f , WHITE , " Quick Menu " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPrintf ( x_position , ypos , font_size + 0.01f , BLUE , " Load State #%d " , g_extern . state_slot ) ;
cellDbgFontPrintf ( x_position , ypos , font_size , menuitem_colors [ MENU_ITEM_LOAD_STATE ] , " Load State #%d " , g_extern . state_slot ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPrintf ( x_position , ypos + ( ypos_increment * MENU_ITEM_SAVE_STATE ) , font_size + 0.01f , BLUE , " Save State #%d " , g_extern . state_slot ) ;
cellDbgFontPrintf ( x_position , ypos + ( ypos_increment * MENU_ITEM_SAVE_STATE ) , font_size , menuitem_colors [ MENU_ITEM_SAVE_STATE ] , " Save State #%d " , g_extern . state_slot ) ;
cellDbgFontDraw ( ) ;
2012-01-20 23:30:01 +00:00
2012-01-31 13:12:00 +00:00
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_KEEP_ASPECT_RATIO ) ) , font_size + 0.01f , BLUE , " Aspect Ratio: %s " , g_console . aspect_ratio_name ) ;
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_KEEP_ASPECT_RATIO ) ) , font_size , menuitem_colors [ MENU_ITEM_KEEP_ASPECT_RATIO ] , " Aspect Ratio: %s " , g_console . aspect_ratio_name ) ;
2012-01-20 23:30:01 +00:00
2012-02-02 17:39:09 +00:00
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_OVERSCAN_AMOUNT ) ) , font_size + 0.01f , BLUE , " Overscan: %f " , g_console . overscan_amount ) ;
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_OVERSCAN_AMOUNT ) ) , font_size , menuitem_colors [ MENU_ITEM_OVERSCAN_AMOUNT ] , " Overscan: %f " , g_console . overscan_amount ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_ORIENTATION ) ) , font_size + 0.01f , BLUE , " Orientation: " ) ;
2012-01-30 18:44:21 +00:00
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_ORIENTATION ) ) , font_size , menuitem_colors [ MENU_ITEM_ORIENTATION ] , " Orientation: %s " , msg_temp ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RESIZE_MODE ) ) , font_size + 0.01f , BLUE , " Resize Mode " ) ;
cellDbgFontPrintf ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RESIZE_MODE ) ) , font_size , menuitem_colors [ MENU_ITEM_RESIZE_MODE ] , " Resize Mode " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_FRAME_ADVANCE ) ) , font_size + 0.01f , BLUE , " Frame Advance " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_FRAME_ADVANCE ) ) , font_size , menuitem_colors [ MENU_ITEM_FRAME_ADVANCE ] , " Frame Advance " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_SCREENSHOT_MODE ) ) , font_size + 0.01f , BLUE , " Screenshot Mode " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_SCREENSHOT_MODE ) ) , font_size , menuitem_colors [ MENU_ITEM_SCREENSHOT_MODE ] , " Screenshot Mode " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontDraw ( ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RESET ) ) , font_size + 0.01f , BLUE , " Reset " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RESET ) ) , font_size , menuitem_colors [ MENU_ITEM_RESET ] , " Reset " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_GAME ) ) , font_size + 0.01f , BLUE , " Return to Game " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_GAME ) ) , font_size , menuitem_colors [ MENU_ITEM_RETURN_TO_GAME ] , " Return to Game " ) ;
2012-01-20 23:30:01 +00:00
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_MENU ) ) , font_size + 0.01f , BLUE , " Return to Menu " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_MENU ) ) , font_size , menuitem_colors [ MENU_ITEM_RETURN_TO_MENU ] , " Return to Menu " ) ;
2012-01-20 23:30:01 +00:00
# ifdef MULTIMAN_SUPPORT
2012-01-29 22:16:39 +00:00
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_MULTIMAN ) ) , font_size + 0.01f , BLUE , " Return to multiMAN " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_MULTIMAN ) ) , font_size , menuitem_colors [ MENU_ITEM_RETURN_TO_MULTIMAN ] , " Return to multiMAN " ) ;
2012-01-20 23:30:01 +00:00
# endif
2012-01-29 22:16:39 +00:00
cellDbgFontDraw ( ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_XMB ) ) , font_size + 0.01f , BLUE , " Return to XMB " ) ;
cellDbgFontPuts ( x_position , ( ypos + ( ypos_increment * MENU_ITEM_RETURN_TO_XMB ) ) , font_size , menuitem_colors [ MENU_ITEM_RETURN_TO_XMB ] , " Return to XMB " ) ;
if ( g_frame_count < special_action_msg_expired )
{
cellDbgFontPrintf ( 0.09f , 0.90f , 1.51f , BLUE , special_action_msg ) ;
cellDbgFontPrintf ( 0.09f , 0.90f , 1.50f , WHITE , special_action_msg ) ;
cellDbgFontDraw ( ) ;
}
else
{
special_action_msg_expired = 0 ;
cellDbgFontPrintf ( 0.09f , 0.90f , 0.98f + 0.01f , BLUE , comment ) ;
cellDbgFontPrintf ( 0.09f , 0.90f , 0.98f , LIGHTBLUE , comment ) ;
}
cellDbgFontDraw ( ) ;
psglSwap ( ) ;
old_state = state ;
cellSysutilCheckCallback ( ) ;
2012-01-30 08:53:16 +00:00
} while ( g_console . ingame_menu_enable ) ;
2012-01-29 22:16:39 +00:00
2012-01-30 08:53:16 +00:00
ps3graphics_unblock_swap ( ) ;
2012-01-20 23:30:01 +00:00
}
2012-01-05 21:47:34 +00:00
int main ( int argc , char * argv [ ] )
{
2012-01-29 22:16:39 +00:00
// Initialize 6 SPUs but reserve 1 SPU as a raw SPU for PSGL
sys_spu_initialize ( 6 , 1 ) ;
2012-01-11 00:04:17 +00:00
2012-01-29 22:16:39 +00:00
cellSysmoduleLoadModule ( CELL_SYSMODULE_IO ) ;
cellSysmoduleLoadModule ( CELL_SYSMODULE_FS ) ;
cellSysmoduleLoadModule ( CELL_SYSMODULE_SYSUTIL_GAME ) ;
cellSysmoduleLoadModule ( CELL_SYSMODULE_AVCONF_EXT ) ;
cellSysmoduleLoadModule ( CELL_SYSMODULE_PNGDEC ) ;
cellSysmoduleLoadModule ( CELL_SYSMODULE_JPGDEC ) ;
2012-01-11 00:04:17 +00:00
2012-02-04 12:29:02 +00:00
get_environment_settings ( ) ;
2012-01-29 22:16:39 +00:00
ssnes_main_clear_state ( ) ;
2012-01-16 03:07:02 +00:00
2012-01-29 22:16:39 +00:00
config_set_defaults ( ) ;
2012-01-21 16:24:25 +00:00
2012-01-30 12:45:37 +00:00
set_default_settings ( ) ;
2012-01-29 22:16:39 +00:00
init_settings ( ) ;
2012-01-11 00:04:17 +00:00
2012-01-16 14:45:55 +00:00
# if(CELL_SDK_VERSION > 0x340000)
2012-01-29 22:16:39 +00:00
if ( g_console . screenshots_enable )
{
cellSysmoduleLoadModule ( CELL_SYSMODULE_SYSUTIL_SCREENSHOT ) ;
CellScreenShotSetParam screenshot_param = { 0 , 0 , 0 , 0 } ;
screenshot_param . photo_title = " SSNES PS3 " ;
screenshot_param . game_title = " SSNES PS3 " ;
cellScreenShotSetParameter ( & screenshot_param ) ;
cellScreenShotEnable ( ) ;
}
2012-01-16 14:45:55 +00:00
# endif
2012-01-30 15:21:22 +00:00
ps3graphics_video_init ( true ) ;
2012-01-29 22:16:39 +00:00
ps3_input_init ( ) ;
2012-01-11 21:27:07 +00:00
2012-01-29 22:16:39 +00:00
menu_init ( ) ;
2012-02-02 15:59:06 +00:00
g_console . mode_switch = MODE_MENU ;
2012-01-16 03:07:02 +00:00
2012-01-20 17:00:33 +00:00
begin_loop :
2012-02-02 15:59:06 +00:00
if ( g_console . mode_switch = = MODE_EMULATION )
2012-01-29 22:16:39 +00:00
{
2012-02-01 14:15:15 +00:00
bool repeat = false ;
if ( ingame_menu_item ! = 0 )
g_console . ingame_menu_enable = true ;
2012-01-29 22:16:39 +00:00
g_extern . is_paused = false ;
input_ps3 . poll ( NULL ) ;
2012-02-01 14:15:15 +00:00
do {
repeat = ssnes_main_iterate ( ) ;
} while ( repeat & & frame_advance_disabled ) ;
2012-01-29 22:16:39 +00:00
g_extern . is_paused = true ;
2012-01-30 08:53:16 +00:00
if ( g_console . ingame_menu_enable )
2012-01-29 22:16:39 +00:00
ingame_menu ( ) ;
}
2012-02-02 15:59:06 +00:00
else if ( g_console . mode_switch = = MODE_MENU )
2012-01-29 22:16:39 +00:00
{
menu_loop ( ) ;
2012-02-09 13:25:13 +00:00
if ( g_console . initialize_ssnes_enable )
2012-01-29 22:16:39 +00:00
{
2012-02-09 13:25:13 +00:00
if ( g_console . emulator_initialized )
2012-01-29 22:16:39 +00:00
ssnes_main_deinit ( ) ;
2012-01-30 17:17:47 +00:00
struct ssnes_main_wrap args = {
. verbose = g_extern . verbose ,
. config_path = SYS_CONFIG_FILE ,
. sram_path = g_console . default_sram_dir_enable ? g_console . default_sram_dir : NULL ,
. state_path = g_console . default_savestate_dir_enable ? g_console . default_savestate_dir : NULL ,
. rom_path = g_console . rom_path
} ;
int init_ret = ssnes_main_init_wrap ( & args ) ;
2012-02-09 13:25:13 +00:00
g_console . emulator_initialized = 1 ;
g_console . initialize_ssnes_enable = 0 ;
2012-01-29 22:16:39 +00:00
}
}
2012-01-20 17:00:33 +00:00
# ifdef MULTIMAN_SUPPORT
2012-02-02 15:59:06 +00:00
else if ( g_console . mode_switch = = MODE_MULTIMAN_STARTUP )
2012-01-29 22:16:39 +00:00
{
}
2012-01-20 17:00:33 +00:00
# endif
2012-01-29 22:16:39 +00:00
else
goto begin_shutdown ;
2012-01-16 03:07:02 +00:00
2012-01-29 22:16:39 +00:00
goto begin_loop ;
2012-01-11 21:27:07 +00:00
2012-01-20 17:00:33 +00:00
begin_shutdown :
2012-01-30 14:59:15 +00:00
if ( file_exists ( SYS_CONFIG_FILE ) )
save_settings ( ) ;
2012-01-29 22:16:39 +00:00
ps3_input_deinit ( ) ;
ps3_video_deinit ( ) ;
sys_process_exit ( 0 ) ;
2012-01-05 21:47:34 +00:00
}