From 51ab2f2509eb50eec6221656d1306af9ad6aa41b Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Tue, 10 Jan 2012 23:33:44 +0100 Subject: [PATCH] (PS3) Added initial menu - not yet compiled in --- Makefile.ps3 | 2 +- ps3/cellframework2/fileio/file_browser.c | 185 ++++ ps3/cellframework2/fileio/file_browser.h | 121 +++ ps3/main.c | 8 +- ps3/menu-entries.h | 1181 ++++++++++++++++++++++ ps3/menu.c | 1112 ++++++++++++++++++++ ps3/menu.h | 184 ++++ ps3/ps3_video_psgl.c | 11 +- 8 files changed, 2796 insertions(+), 8 deletions(-) create mode 100644 ps3/cellframework2/fileio/file_browser.c create mode 100644 ps3/cellframework2/fileio/file_browser.h create mode 100644 ps3/menu-entries.h create mode 100644 ps3/menu.c create mode 100644 ps3/menu.h diff --git a/Makefile.ps3 b/Makefile.ps3 index 7cdfb3d799..c3038dd664 100644 --- a/Makefile.ps3 +++ b/Makefile.ps3 @@ -43,7 +43,7 @@ INCDIRS = -I. -Icommon MAKE_FSELF_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_fself_npdrm MAKE_PACKAGE_NPDRM = $(CELL_SDK)/$(HOST_DIR)/bin/make_package_npdrm -OBJ = fifo_buffer.o ps3/ps3_audio.o ps3/ps3_input.o ps3/pad_input.o getopt.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o netplay.o gfx/gfx_common.o ps3/ps3_video_psgl.o gfx/shader_cg.o gfx/snes_state.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o ps3/main.o audio/utils.o conf/config_file.o gfx/image.o +OBJ = fifo_buffer.o ps3/cellframework2/fileio/file_browser.o ps3/ps3_audio.o ps3/ps3_input.o ps3/pad_input.o getopt.o ssnes.o driver.o file.o settings.o message.o rewind.o movie.o gfx/gfx_common.o ps3/ps3_video_psgl.o gfx/shader_cg.o gfx/snes_state.o ups.o bps.o strl.o screenshot.o audio/hermite.o dynamic.o ps3/main.o audio/utils.o conf/config_file.o gfx/image.o LIBS = -ldbgfont -lPSGL -lPSGLcgc -lcgc -lgcm_cmd -lgcm_sys_stub -lsnes -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysmodule_stub -laudio_stub -lnet_stub -lpthread diff --git a/ps3/cellframework2/fileio/file_browser.c b/ps3/cellframework2/fileio/file_browser.c new file mode 100644 index 0000000000..0832896c6c --- /dev/null +++ b/ps3/cellframework2/fileio/file_browser.c @@ -0,0 +1,185 @@ +/************************************************************************************* + * -- Cellframework Mk.II - Open framework to abstract the common tasks related to + * PS3 application development. + * + * Copyright (C) 2010-2012 + * + * This program 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 Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ********************************************************************************/ + +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * 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 . + */ + +#include +#include "file_browser.h" + +static int less_than_key(const void * a, const void * b) +{ + DirectoryEntry * a_dir = (DirectoryEntry*)a; + DirectoryEntry * b_dir = (DirectoryEntry*)b; + + /* compare a directory to a file directory is always lesser than*/ + if ((a_dir->d_type == CELL_FS_TYPE_DIRECTORY && b_dir->d_type == CELL_FS_TYPE_REGULAR)) + return -1; + else if (a_dir->d_type == CELL_FS_TYPE_REGULAR && b_dir->d_type == CELL_FS_TYPE_DIRECTORY) + return 1; + + return strcasecmp(a_dir->d_name, b_dir->d_name); +} + +static const char * filebrowser_get_extension(const char * filename) +{ + const char * ext = strrchr(filename, '.'); + if (ext) + return ext+1; + else + return ""; +} + +static void filebrowser_clear_current_entries(filebrowser_t * filebrowser) +{ + for(uint32_t i = 0; i < MAX_FILE_LIMIT_CFS; i++) + { + filebrowser->cur[filebrowser->file_count].d_type = 0; + filebrowser->cur[filebrowser->file_count].d_namlen = 0; + strcpy(filebrowser->cur[filebrowser->file_count].d_name, "\0"); + } +} + +static bool filebrowser_parse_directory(filebrowser_t * filebrowser, const char * path, const char * extensions) +{ + int fd; + + /* bad path*/ + if (strcmp(path,"") == 0) + return false; + + /* delete old path*/ + filebrowser_clear_current_entries(filebrowser); + + if (cellFsOpendir(path, &fd) == CELL_FS_SUCCEEDED) + { + uint64_t nread = 0; + + strcpy(filebrowser->dir[filebrowser->directory_stack_size], path); + + filebrowser->file_count = 0; + + filebrowser->currently_selected = 0; + + CellFsDirent dirent; + while (cellFsReaddir(fd, &dirent, &nread) == CELL_FS_SUCCEEDED) + { + if (nread == 0) + break; + + if ((dirent.d_type != CELL_FS_TYPE_REGULAR) && (dirent.d_type != CELL_FS_TYPE_DIRECTORY)) + continue; + + if (dirent.d_type == CELL_FS_TYPE_DIRECTORY && !(strcmp(dirent.d_name, "."))) + continue; + + if (dirent.d_type == CELL_FS_TYPE_REGULAR) + { + char tmp_extensions[512]; + strncpy(tmp_extensions, extensions, sizeof(tmp_extensions)); + const char * current_extension = filebrowser_get_extension(dirent.d_name); + bool found_rom = false; + + if(current_extension) + { + char * pch = strtok(tmp_extensions, "|"); + while (pch != NULL) + { + if(strcmp(current_extension, pch) == 0) + { + found_rom = true; + break; + } + pch = strtok(NULL, "|"); + } + } + + if(!found_rom) + continue; + } + + + filebrowser->cur[filebrowser->file_count].d_type = dirent.d_type; + filebrowser->cur[filebrowser->file_count].d_namlen = dirent.d_namlen; + strcpy(filebrowser->cur[filebrowser->file_count].d_name, dirent.d_name); + + ++filebrowser->file_count; + } + + cellFsClosedir(fd); + } + else + return false; + + qsort(filebrowser->cur, filebrowser->file_count, sizeof(DirectoryEntry), less_than_key); + + return true; +} + +void filebrowser_new(filebrowser_t * filebrowser, const char * start_dir, const char * extensions) +{ + filebrowser->directory_stack_size = 0; + strncpy(filebrowser->extensions, extensions, sizeof(filebrowser->extensions)); + + filebrowser_parse_directory(filebrowser, start_dir, filebrowser->extensions); +} + + +void filebrowser_reset_start_directory(filebrowser_t * filebrowser, const char * start_dir, const char * extensions) +{ + filebrowser_clear_current_entries(filebrowser); + filebrowser->directory_stack_size = 0; + strncpy(filebrowser->extensions, extensions, sizeof(filebrowser->extensions)); + + filebrowser_parse_directory(filebrowser, start_dir, filebrowser->extensions); +} + +void filebrowser_push_directory(filebrowser_t * filebrowser, const char * path, bool with_extension) +{ + filebrowser->directory_stack_size++; + if(with_extension) + filebrowser_parse_directory(filebrowser, path, filebrowser->extensions); + else + filebrowser_parse_directory(filebrowser, path, "empty"); +} + +void filebrowser_pop_directory (filebrowser_t * filebrowser) +{ + if (filebrowser->directory_stack_size > 0) + filebrowser->directory_stack_size--; + + filebrowser_parse_directory(filebrowser, filebrowser->dir[filebrowser->directory_stack_size], filebrowser->extensions); +} diff --git a/ps3/cellframework2/fileio/file_browser.h b/ps3/cellframework2/fileio/file_browser.h new file mode 100644 index 0000000000..d33a6f0f54 --- /dev/null +++ b/ps3/cellframework2/fileio/file_browser.h @@ -0,0 +1,121 @@ +/************************************************************************************* + * -- Cellframework Mk.II - Open framework to abstract the common tasks related to + * PS3 application development. + * + * Copyright (C) 2010-2012 + * + * This program 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 Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + ********************************************************************************/ + +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * 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 . + */ + +#ifndef FILEBROWSER_H_ +#define FILEBROWSER_H_ + +#define MAXJOLIET 255 +#define MAX_PATH_LENGTH 1024 +#define CELL_FS_MAX_FS_FILE_NAME_LENGTH (255) +#define MAX_FILE_LIMIT_CFS 30000 + +#include +#include + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + uint8_t d_type; + uint8_t d_namlen; + char d_name[CELL_FS_MAX_FS_FILE_NAME_LENGTH+1]; +} DirectoryEntry; + +typedef struct +{ + uint32_t file_count; /* amount of files in current dir*/ + uint32_t currently_selected; /* currently select browser entry*/ + uint32_t directory_stack_size; + char dir[128][CELL_FS_MAX_FS_PATH_LENGTH]; /* info of the current directory*/ + DirectoryEntry cur[MAX_FILE_LIMIT_CFS]; /* current file listing*/ + char extensions[512]; /* allowed extensions*/ +} filebrowser_t; + +void filebrowser_new(filebrowser_t * filebrowser, const char * start_dir, const char * extensions); +void filebrowser_reset_start_directory(filebrowser_t * filebrowser, const char * start_dir, const char * extensions); +void filebrowser_push_directory(filebrowser_t * filebrowser, const char * path, bool with_extension); +void filebrowser_pop_directory (filebrowser_t * filebrowser); + +#define FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(filebrowser) (filebrowser.dir[filebrowser.directory_stack_size]) +#define FILEBROWSER_GET_CURRENT_DIRECTORY_FILE_COUNT(filebrowser) (filebrowser.file_count) +#define FILEBROWSER_GOTO_ENTRY(filebrowser, i) filebrowser.currently_selected = i; + +#define FILEBROWSER_INCREMENT_ENTRY(filebrowser) \ +{ \ + filebrowser.currently_selected++; \ + if (filebrowser.currently_selected >= filebrowser.file_count) \ + filebrowser.currently_selected = 0; \ +} + +#define FILEBROWSER_INCREMENT_ENTRY_POINTER(filebrowser) \ +{ \ + filebrowser->currently_selected++; \ + if (filebrowser->currently_selected >= filebrowser->file_count) \ + filebrowser->currently_selected = 0; \ +} + +#define FILEBROWSER_DECREMENT_ENTRY(filebrowser) \ +{ \ + filebrowser.currently_selected--; \ + if (filebrowser.currently_selected >= filebrowser.file_count) \ + filebrowser.currently_selected = filebrowser.file_count - 1; \ +} + +#define FILEBROWSER_DECREMENT_ENTRY_POINTER(filebrowser) \ +{ \ + filebrowser->currently_selected--; \ + if (filebrowser->currently_selected >= filebrowser->file_count) \ + filebrowser->currently_selected = filebrowser->file_count - 1; \ +} + +#define FILEBROWSER_GET_CURRENT_FILENAME(filebrowser) (filebrowser.cur[filebrowser.currently_selected].d_name) +#define FILEBROWSER_GET_CURRENT_ENTRY_INDEX(filebrowser) (filebrowser.currently_selected) +#define FILEBROWSER_IS_CURRENT_A_FILE(filebrowser) (filebrowser.cur[filebrowser.currently_selected].d_type == CELL_FS_TYPE_REGULAR) +#define FILEBROWSER_IS_CURRENT_A_DIRECTORY(filebrowser) (filebrowser.cur[filebrowser.currently_selected].d_type == CELL_FS_TYPE_DIRECTORY) + +#ifdef __cplusplus +} +#endif + +#endif /* FILEBROWSER_H_ */ diff --git a/ps3/main.c b/ps3/main.c index a2958e1620..087d41310a 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -16,10 +16,15 @@ * If not, see . */ +#include +#include +#include + #include #include #include -#include + +bool g_rom_loaded; int ssnes_main(int argc, char *argv[]); @@ -29,6 +34,7 @@ SYS_PROCESS_PARAM(1001, 0x100000) // Temporary, a more sane implementation should go here. int main(int argc, char *argv[]) { + g_rom_loaded = false; sys_spu_initialize(4, 3); char arg1[] = "ssnes"; char arg2[] = "/dev_hdd0/game/SNES90000/USRDIR/main.sfc"; diff --git a/ps3/menu-entries.h b/ps3/menu-entries.h new file mode 100644 index 0000000000..9b3faca67f --- /dev/null +++ b/ps3/menu-entries.h @@ -0,0 +1,1181 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * 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 . + */ + +static item items_generalsettings[MAX_NO_OF_CONTROLS_SETTINGS] = +{ + { + SETTING_CHANGE_RESOLUTION, /* enum ID of item*/ + "Resolution", /* item label */ + 0.0f, /* text X position */ + 0.0f, /* text Y position */ + YELLOW, /* text color if selected */ + WHITE, /* text color if not selected */ + "INFO - Change the display resolution - press X to confirm.", /* item comment */ + LIGHTBLUE, /* color of item comment */ + 0.91f, /* font scale of item comment */ + 0.09f, /* comment X position */ + 0.83f, /* comment Y position */ + NULL, /* associated pointer to setting */ + {0}, /* item comment (yes if setting_ptr true) */ + {0} /* item comment (no if setting_ptr false) */ + }, + { + SETTING_SHADER_PRESETS, + "Shader Preset", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_BORDER, + "Selected border", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Select an image file as the background border for 'border shaders'.\nNOTE: The image has to be in PNG format.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_SHADER, + "Selected shader #1", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Select a shader as [Shader #1]. NOTE: Some shaders might be\ntoo slow at 1080p. If you experience any slowdown, try another shader.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_SHADER_2, + "Selected shader #2", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Select a shader as [Shader #2]. NOTE: Some shaders might be\ntoo slow at 1080p. If you experience any slowdown, try another shader.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, +#ifdef HAVE_GAMEAWARE + { + SETTING_GAME_AWARE_SHADER, + "Game Aware Shader Script", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Select a [Game Aware Shader] script.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, +#endif + { + SETTING_FONT_SIZE, + "Font Size", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Increase or decrease the font size in the menu.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_KEEP_ASPECT_RATIO, + "Aspect Ratio", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Aspect Ratio] is set to 'Scaled (4:3)' - screen will have black\nborders left/right on widescreen TVs/monitors.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Aspect ratio] is set to 'Scaled' - screen will have black\nborders left and right on widescreen TVs/monitors.", + "INFO - [Aspect ratio] is set to 'Stretched' - widescreen TVs/monitors will\n have a full stretched picture.", + 1, + 1 + }, + { + SETTING_HW_TEXTURE_FILTER, + "Hardware Filtering shader #1", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #1].", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #1].", + "INFO - Hardware filtering is set to 'Point filtering' for [Shader #1] -\nmost shaders look much better on this setting.", + 1, + 1 + }, + { + SETTING_HW_TEXTURE_FILTER_2, + "Hardware Filtering shader #2", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #2].", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - Hardware filtering is set to 'Bilinear filtering' for [Shader #2].", + "INFO - Hardware filtering is set to 'Point filtering' for [Shader #2] -\nmost shaders look much better on this setting.", + 1, + 1 + }, + { + SETTING_SCALE_ENABLED, + "Custom Scaling/Dual Shaders", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Custom Scaling] is set to 'ON' - 2x shaders will look much\nbetter, and you can select a shader for [Shader #2].", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Custom Scaling] is set to 'ON' - 2x shaders will look much\nbetter, and you can select a shader for [Shader #2].", + "INFO - [Custom Scaling] is set to 'OFF'. You will only be able to select\na shader for [Shader #1].", + 1, + 1 + }, + { + SETTING_SCALE_FACTOR, + "Custom Scaling Factor", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Custom Scaling Factor] is set to '2x'.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 2, + 1 + }, + { + SETTING_HW_OVERSCAN_AMOUNT, + "Overscan", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Adjust or decrease [Overscan]. Set this to higher than 0.000\nif the screen doesn't fit on your TV/monitor.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_THROTTLE_MODE, + "Throttle Mode", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Throttle Mode] is set to 'ON' - VSync is enabled and sound\nis turned on.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Throttle mode] is set to 'ON' - VSync is enabled and sound\nis turned on.", + "INFO - [Throttle Mode] is set to 'OFF' - VSync is disabled and sound\nis turned off. NOTE: Useful for benchmarking (measure raw FPS).", + 1, + 1 + }, + { + SETTING_TRIPLE_BUFFERING, + "Triple Buffering", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Triple Buffering] is set to 'ON' - faster graphics/shaders at\nthe possible expense of input lag.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Triple Buffering] is set to 'ON' - faster graphics/shaders at\nthe possible expense of input lag", + "INFO - [Triple Buffering] is set to 'OFF' - slower graphics, but\npossibly better input response times.", + 1, + 1 + }, + { + SETTING_ENABLE_SCREENSHOTS, + "Enable Screenshots Feature", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Enable Screenshots] feature is set to 'OFF'.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Enable Screenshots] is set to 'ON'.", + "INFO - [Enable Screenshots] is set to 'OFF'.", + 1, + 1 + }, + { + SETTING_SAVE_SHADER_PRESET, + "SAVE SETTINGS AS SHADER PRESET", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Save the current video settings to a shader preset file.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_APPLY_SHADER_PRESET_ON_STARTUP, + "APPLY SHADER PRESET ON STARTUP", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Automatically load the shader preset on startup.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + "INFO - [Apply Shader Preset On Startup] is set to 'ON'.", + "INFO - [Apply Shader Preset On Startup] is set to 'OFF'.", + 0, + 1 + }, + { + SETTING_DEFAULT_VIDEO_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set all [General Video Settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_SOUND_MODE, + "Sound Output", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - [Sound Output] is set to 'Normal' - normal audio output will be\nused.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_RSOUND_SERVER_IP_ADDRESS, + "RSound Audio Server IP Address", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Enter the IP Address of the [RSound Audio Server]. IP address\nmust be an IPv4 32-bits address, eg: '192.168.1.7'.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_DEFAULT_AUDIO_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set all [General Audio Settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_EMU_DEFAULT_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set [all SSNES settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_EMU_VIDEO_DEFAULT_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set [all SSNES Video settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_EMU_AUDIO_DEFAULT_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set [all SSNES Audio settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_PATH_DEFAULT_ROM_DIRECTORY, + "Startup ROM Directory", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Set the default [Startup ROM directory]. NOTE: You will have to\nrestart the emulator for this change to have any effect.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_PATH_SAVESTATES_DIRECTORY, + "Savestate Directory", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Set the default path where all the savestate files will be saved to.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_PATH_SRAM_DIRECTORY, + "SRAM Directory", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Set the default SRAM (SaveRAM) directory path. All the\nbattery backup saves will be stored in this directory.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, +#ifdef HAVE_CHEATS + { + SETTING_PATH_CHEATS, + "Cheatfile Directory", + 0.0f, + 0.0f, + YELLOW, + WHITE, + "INFO - Set the default [Cheatfile directory] path. All CHT (cheat) files\nwill be stored here.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, +#endif + { + SETTING_PATH_DEFAULT_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set [all Path settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_CONTROLS_SCHEME, + "Control Scheme Preset", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_CONTROLS_NUMBER, + "Controller No", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0} + }, + { + SETTING_CONTROLS_DPAD_UP, + "D-Pad Up", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_UP + }, + { + SETTING_CONTROLS_DPAD_DOWN, + "D-Pad Down", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_DOWN + }, + { + SETTING_CONTROLS_DPAD_LEFT, + "D-Pad Left", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_LEFT + }, + { + SETTING_CONTROLS_DPAD_RIGHT, + "D-Pad Right", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_RIGHT + }, + { + SETTING_CONTROLS_BUTTON_CIRCLE, + "Circle button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_A + }, + { + SETTING_CONTROLS_BUTTON_CROSS, + "Cross button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_B + }, + { + SETTING_CONTROLS_BUTTON_TRIANGLE, + "Triangle button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_X + }, + { + SETTING_CONTROLS_BUTTON_SQUARE, + "Square button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_Y + }, + { + SETTING_CONTROLS_BUTTON_SELECT, + "Select button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_SELECT + }, + { + SETTING_CONTROLS_BUTTON_START, + "Start button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_START + }, + { + SETTING_CONTROLS_BUTTON_L1, + "L1 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_L + }, + { + SETTING_CONTROLS_BUTTON_R1, + "R1 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_R + }, + { + SETTING_CONTROLS_BUTTON_L2, + "L2 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_BUTTON_R2, + "R2 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_BUTTON_L3, + "L3 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_BUTTON_R3, + "R3 button", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_INGAME_MENU + }, + { + SETTING_CONTROLS_BUTTON_L2_BUTTON_L3, + "Button combo: L2 & L3", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_BUTTON_L2_BUTTON_R3, + "Button combo: L2 & R3", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_RIGHT, + "Button combo: L2 & RStick Right", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, +#ifdef HAVE_CHEATS + BTN_INCREMENTCHEAT +#else + BTN_NONE +#endif + }, + { + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_LEFT, + "Button combo: L2 & RStick Left", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, +#ifdef HAVE_CHEATS + BTN_DECREMENTCHEAT +#else + BTN_NONE +#endif + }, + { + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_UP, + "Button combo: L2 & RStick Up", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, +#ifdef HAVE_CHEATS + BTN_CHEATTOGGLE +#else + BTN_NONE +#endif + }, + { + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_DOWN, + "Button combo: L2 & RStick Down", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, +#ifdef HAVE_CHEATS + BTN_CHEATINPUT +#else + BTN_NONE +#endif + }, + { + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_RIGHT, + "Button combo: R2 & RStick Right", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_INCREMENTSAVE + }, + { + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_LEFT, + "Button combo: R2 & RStick Left", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_DECREMENTSAVE + }, + { + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_UP, + "Button combo: R2 & RStick Up", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_QUICKLOAD + }, + { + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_DOWN, + "Button combo: R2 & RStick Down", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_QUICKSAVE + }, + { + SETTING_CONTROLS_BUTTON_R2_BUTTON_R3, + "Button combo: R2 & R3", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_SRAM_WRITEPROTECT + }, + { + SETTING_CONTROLS_BUTTON_R3_BUTTON_L3, + "Button combo: R3 & L3", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_EXITTOMENU + }, + { + SETTING_CONTROLS_ANALOG_R_UP, + "Right Stick - Up", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE + }, + { + SETTING_CONTROLS_ANALOG_R_DOWN, + "Right Stick - Down", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_FASTFORWARD + }, + { + SETTING_CONTROLS_ANALOG_R_LEFT, + "Right Stick - Left", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE, + 1 + }, + { + SETTING_CONTROLS_ANALOG_R_RIGHT, + "Right Stick - Right", + 0.0f, + 0.0f, + YELLOW, + WHITE, + {0}, + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, //setting ptr + {0}, + {0}, + BTN_NONE, + 1 + }, + { + SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS, + "SAVE CUSTOM CONTROLS", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Save the custom control settings.\nNOTE: This option will not do anything with Control Scheme [New] or [Default].", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + }, + { + SETTING_CONTROLS_DEFAULT_ALL, + "DEFAULT", + 0.0f, + 0.0f, + YELLOW, + GREEN, + "INFO - Set all [Controls settings] back to their 'DEFAULT' values.", + LIGHTBLUE, + 0.91f, + 0.09f, + 0.83f, + NULL, + {0}, + {0}, + 0, + 1 + } +}; diff --git a/ps3/menu.c b/ps3/menu.c new file mode 100644 index 0000000000..7688250452 --- /dev/null +++ b/ps3/menu.c @@ -0,0 +1,1112 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * 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 . + */ + +#include +#include + +//#include "cellframework2/input/pad_input.h" +#include "cellframework2/fileio/file_browser.h" + +#include "../general.h" + +#include "menu.h" +#include "menu-entries.h" + +extern unsigned g_frame_count; +extern bool g_rom_loaded; + +#define MIN(x,y) ((x) < (y) ? (x) : (y)) +#define MAX(x,y) ((x) > (y) ? (x) : (y)) + +#define NUM_ENTRY_PER_PAGE 19 + +static int menuStackindex = 0; +static menu menuStack[25]; +uint32_t menu_is_running = 0; /* is the menu running?*/ +static bool set_initial_dir_tmpbrowser; +filebrowser_t browser; /* main file browser->for rom browser*/ +filebrowser_t tmpBrowser; /* tmp file browser->for everything else*/ + +uint32_t set_shader = 0; +static uint32_t currently_selected_controller_menu = 0; + + +static menu menu_filebrowser = { + "FILE BROWSER |", /* title*/ + FILE_BROWSER_MENU, /* enum*/ + 0, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + NULL /* items*/ +}; + +static menu menu_generalvideosettings = { + "VIDEO |", /* title*/ + GENERAL_VIDEO_MENU, /* enum*/ + FIRST_VIDEO_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_VIDEO_SETTING, /* first setting*/ + MAX_NO_OF_VIDEO_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_generalaudiosettings = { + "AUDIO |", /* title*/ + GENERAL_AUDIO_MENU, /* enum*/ + FIRST_AUDIO_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_AUDIO_SETTING, /* first setting*/ + MAX_NO_OF_AUDIO_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_emu_settings = { + "SSNES |", /* title*/ + EMU_GENERAL_MENU, /* enum*/ + FIRST_EMU_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_EMU_SETTING, /* first setting*/ + MAX_NO_OF_EMU_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_emu_videosettings = { + "SSNES VIDEO |", /* title*/ + EMU_VIDEO_MENU, /* enum*/ + FIRST_EMU_VIDEO_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_EMU_VIDEO_SETTING, /* first setting*/ + MAX_NO_OF_EMU_VIDEO_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_emu_audiosettings = { + "SSNES AUDIO |", /* title*/ + EMU_AUDIO_MENU, /* enum*/ + FIRST_EMU_AUDIO_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_EMU_AUDIO_SETTING, /* first setting*/ + MAX_NO_OF_EMU_AUDIO_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_pathsettings = { + "PATH |", /* title*/ + PATH_MENU, /* enum*/ + FIRST_PATH_SETTING, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_PATH_SETTING, /* first setting*/ + MAX_NO_OF_PATH_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static menu menu_controlssettings = { + "CONTROLS |", /* title*/ + CONTROLS_MENU, /* enum*/ + FIRST_CONTROLS_SETTING_PAGE_1, /* selected item*/ + 0, /* page*/ + 1, /* refreshpage*/ + FIRST_CONTROLS_SETTING_PAGE_1, /* first setting*/ + MAX_NO_OF_CONTROLS_SETTINGS, /* max no of path settings*/ + items_generalsettings /* items*/ +}; + +static void display_menubar(uint32_t menu_enum) +{ + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, menu_enum == GENERAL_VIDEO_MENU ? RED : GREEN, menu_generalvideosettings.title); + cellDbgFontPuts (0.19f, 0.05f, FONT_SIZE, menu_enum == GENERAL_AUDIO_MENU ? RED : GREEN, menu_generalaudiosettings.title); + cellDbgFontPuts (0.29f, 0.05f, FONT_SIZE, menu_enum == EMU_GENERAL_MENU ? RED : GREEN, menu_emu_settings.title); + cellDbgFontPuts (0.38f, 0.05f, FONT_SIZE, menu_enum == EMU_VIDEO_MENU ? RED : GREEN, menu_emu_videosettings.title); + cellDbgFontPuts (0.54f, 0.05f, FONT_SIZE, menu_enum == EMU_AUDIO_MENU ? RED : GREEN, menu_emu_audiosettings.title); + cellDbgFontPuts (0.70f, 0.05f, FONT_SIZE, menu_enum == PATH_MENU ? RED : GREEN, menu_pathsettings.title); + cellDbgFontPuts (0.80f, 0.05f, FONT_SIZE, menu_enum == CONTROLS_MENU ? RED : GREEN, menu_controlssettings.title); + cellDbgFontDraw(); +} + +#define FILEBROWSER_DELAY 100000 +#define FILEBROWSER_DELAY_DIVIDED_BY_3 33333 +#define SETTINGS_DELAY 150000 +. +#define ROM_EXTENSIONS "fds|FDS|zip|ZIP|nes|NES|unif|UNIF" + +static void UpdateBrowser(filebrowser_t * b) +{ + static uint64_t old_state = 0; + uint64_t state = cell_pad_input_poll_device(0); + uint64_t diff_state = old_state ^ state; + uint64_t button_was_pressed = old_state & diff_state; + + if(g_frame_count < special_action_msg_expired) + { + } + else + { + if (CTRL_LSTICK_DOWN(state)) + { + if(b->currently_selected < b->file_count-1) + { + FILEBROWSER_INCREMENT_ENTRY_POINTER(b); + set_text_message("", 4); + } + } + + if (CTRL_DOWN(state)) + { + if(b->currently_selected < b->file_count-1) + { + FILEBROWSER_INCREMENT_ENTRY_POINTER(b); + set_text_message("", 7); + } + } + + if (CTRL_LSTICK_UP(state)) + { + if(b->currently_selected > 0) + { + FILEBROWSER_DECREMENT_ENTRY_POINTER(b); + set_text_message("", 4); + } + } + + if (CTRL_UP(state)) + { + if(b->currently_selected > 0) + { + FILEBROWSER_DECREMENT_ENTRY_POINTER(b); + set_text_message("", 7); + } + } + + if (CTRL_RIGHT(state)) + { + b->currently_selected = (MIN(b->currently_selected + 5, b->file_count-1)); + set_text_message("", 7); + } + + if (CTRL_LSTICK_RIGHT(state)) + { + b->currently_selected = (MIN(b->currently_selected + 5, b->file_count-1)); + set_text_message("", 4); + } + + if (CTRL_LEFT(state)) + { + if (b->currently_selected <= 5) + b->currently_selected = 0; + else + b->currently_selected -= 5; + + set_text_message("", 7); + } + + if (CTRL_LSTICK_LEFT(state)) + { + if (b->currently_selected <= 5) + b->currently_selected = 0; + else + b->currently_selected -= 5; + + set_text_message("", 4); + } + + if (CTRL_R1(state)) + { + b->currently_selected = (MIN(b->currently_selected + NUM_ENTRY_PER_PAGE, b->file_count-1)); + set_text_message("", 7); + } + + if (CTRL_L1(state)) + { + if (b->currently_selected <= NUM_ENTRY_PER_PAGE) + b->currently_selected= 0; + else + b->currently_selected -= NUM_ENTRY_PER_PAGE; + + set_text_message("", 7); + } + + if (CTRL_CIRCLE(button_was_pressed)) + { + old_state = state; + filebrowser_pop_directory(b); + } + + + if (CTRL_L3(state) && CTRL_R3(state)) + { + /* if a rom is loaded then resume it*/ + if (g_rom_loaded) + { + menu_is_running = 0; + Emulator_StartROMRunning(1); + set_text_message("", 15); + } + } + + old_state = state; + } +} + +static void RenderBrowser(filebrowser_t * b) +{ + uint32_t file_count = b->file_count; + int current_index = b->currently_selected; + + int page_number = current_index / NUM_ENTRY_PER_PAGE; + int page_base = page_number * NUM_ENTRY_PER_PAGE; + float currentX = 0.09f; + float currentY = 0.09f; + float ySpacing = 0.035f; + + for (int i = page_base; i < file_count && i < page_base + NUM_ENTRY_PER_PAGE; ++i) + { + currentY = currentY + ySpacing; + cellDbgFontPuts(currentX, currentY, FONT_SIZE, i == current_index ? RED : b->cur[i].d_type == CELL_FS_TYPE_DIRECTORY ? GREEN : WHITE, b->cur[i].d_name); + cellDbgFontDraw(); + } + cellDbgFontDraw(); +} + +static void do_select_file(uint32_t menu_id) +{ + char extensions[256], title[256], object[256], comment[256], dir_path[MAX_PATH_LENGTH]; + switch(menu_id) + { + case GAME_AWARE_SHADER_CHOICE: + strncpy(dir_path, GAME_AWARE_SHADER_DIR_PATH, sizeof(dir_path)); + strncpy(extensions, "cfg|CFG", sizeof(extensions)); + strncpy(title, "GAME AWARE SHADER SELECTION", sizeof(title)); + strncpy(object, "Game Aware Shader", sizeof(object)); + strncpy(comment, "INFO - Select a 'Game Aware Shader' script from the menu by pressing X.", sizeof(comment)); + break; + case SHADER_CHOICE: + strncpy(dir_path, SHADERS_DIR_PATH, sizeof(dir_path)); + strncpy(extensions, "cg|CG", sizeof(extensions)); + strncpy(title, "SHADER SELECTION", sizeof(title)); + strncpy(object, "Shader", sizeof(object)); + strncpy(comment, "INFO - Select a shader from the menu by pressing the X button.", sizeof(comment)); + break; + case PRESET_CHOICE: + strncpy(dir_path, PRESETS_DIR_PATH, sizeof(dir_path)); + strncpy(extensions, "conf|CONF", sizeof(extensions)); + strncpy(title, "SHADER PRESETS SELECTION", sizeof(title)); + strncpy(object, "Shader preset", sizeof(object)); + strncpy(comment, "INFO - Select a shader preset from the menu by pressing the X button. ", sizeof(comment)); + break; + case INPUT_PRESET_CHOICE: + strncpy(dir_path, INPUT_PRESETS_DIR_PATH, sizeof(dir_path)); + strncpy(extensions, "conf|CONF", sizeof(extensions)); + strncpy(title, "INPUT PRESETS SELECTION", sizeof(title)); + strncpy(object, "Input", sizeof(object)); + strncpy(object, "Input preset", sizeof(object)); + strncpy(comment, "INFO - Select an input preset from the menu by pressing the X button. ", sizeof(comment)); + break; + case BORDER_CHOICE: + strncpy(dir_path, BORDERS_DIR_PATH, sizeof(dir_path)); + strncpy(extensions, "png|PNG|jpg|JPG|JPEG|jpeg", sizeof(extensions)); + strncpy(title, "BORDER SELECTION", sizeof(title)); + strncpy(object, "Border image file", sizeof(object)); + strncpy(comment, "INFO - Select a border image file from the menu by pressing the X button. ", sizeof(comment)); + break; + } + + if(set_initial_dir_tmpbrowser) + { + filebrowser_new(&tmpBrowser, dir_path, extensions); + set_initial_dir_tmpbrowser = false; + } + + char path[MAX_PATH_LENGTH]; + + uint64_t state = cell_pad_input_poll_device(0); + static uint64_t old_state = 0; + uint64_t diff_state = old_state ^ state; + uint64_t button_was_pressed = old_state & diff_state; + + UpdateBrowser(&tmpBrowser); + + if (CTRL_START(button_was_pressed)) + filebrowser_reset_start_directory(&tmpBrowser, "/", extensions); + + if (CTRL_CROSS(button_was_pressed)) + { + if(FILEBROWSER_IS_CURRENT_A_DIRECTORY(tmpBrowser)) + { + /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path*/ + if(tmpBrowser.currently_selected == 0) + { + old_state = state; + filebrowser_pop_directory(&tmpBrowser); + } + else + { + const char * separatorslash = (strcmp(FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser),"/") == 0) ? "" : "/"; + snprintf(path, sizeof(path), "%s%s%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser), separatorslash, FILEBROWSER_GET_CURRENT_FILENAME(tmpBrowser)); + filebrowser_push_directory(&tmpBrowser, path, true); + } + } + else if (FILEBROWSER_IS_CURRENT_A_FILE(tmpBrowser)) + { + snprintf(path, sizeof(path), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser), FILEBROWSER_GET_CURRENT_FILENAME(tmpBrowser)); + + switch(menu_id) + { + case GAME_AWARE_SHADER_CHOICE: + /*emulator_implementation_set_gameaware(path);*/ + strncpy(Settings.GameAwareShaderPath, path, sizeof(Settings.GameAwareShaderPath)); + break; + case SHADER_CHOICE: + if(set_shader) + strncpy(g_settings.video.second_pass_shader, path, sizeof(g_settings.video.second_pass_shader)); + else + strncpy(g_settings.video.cg_shader_path, path, sizeof(g_settings.video.cg_shader_path)); + ps3graphics_load_fragment_shader(path, set_shader); + break; + case PRESET_CHOICE: + emulator_implementation_set_shader_preset(path); + break; + case INPUT_PRESET_CHOICE: + emulator_set_controls(path, READ_CONTROLS, ""); + break; + case BORDER_CHOICE: + strncpy(Settings.PS3CurrentBorder, path, sizeof(Settings.PS3CurrentBorder)); + emulator_implementation_set_texture(path); + break; + } + + menuStackindex--; + } + } + + if (CTRL_TRIANGLE(button_was_pressed)) + menuStackindex--; + + cellDbgFontPrintf (0.09f, 0.09f, FONT_SIZE, YELLOW, "PATH: %s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser)); + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, title); + cellDbgFontPrintf(0.09f, 0.92f, 0.92, YELLOW, "X - Select %s /\\ - return to settings START - Reset Startdir", object); + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "%s", comment); + cellDbgFontDraw(); + + RenderBrowser(&tmpBrowser); + old_state = state; +} + +static void do_pathChoice(uint32_t menu_id) +{ + if(set_initial_dir_tmpbrowser) + { + filebrowser_new(&tmpBrowser, "/\0", "empty"); + set_initial_dir_tmpbrowser = false; + } + + char path[1024]; + char newpath[1024]; + + uint64_t state = cell_pad_input_poll_device(0); + static uint64_t old_state = 0; + uint64_t diff_state = old_state ^ state; + uint64_t button_was_pressed = old_state & diff_state; + + UpdateBrowser(&tmpBrowser); + + if (CTRL_START(button_was_pressed)) + filebrowser_reset_start_directory(&tmpBrowser, "/","empty"); + + if (CTRL_SQUARE(button_was_pressed)) + { + if(FILEBROWSER_IS_CURRENT_A_DIRECTORY(tmpBrowser)) + { + snprintf(path, sizeof(path), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser), FILEBROWSER_GET_CURRENT_FILENAME(tmpBrowser)); + switch(menu_id) + { + case PATH_SAVESTATES_DIR_CHOICE: + strcpy(Settings.PS3PathSaveStates, path); + break; + case PATH_SRAM_DIR_CHOICE: + strcpy(Settings.PS3PathSRAM, path); + break; + case PATH_CHEATS_DIR_CHOICE: + strcpy(Settings.PS3PathCheats, path); + break; + case PATH_BASE_DIR_CHOICE: + strcpy(Settings.PS3PathBaseDirectory, path); + break; + case PATH_DEFAULT_ROM_DIR_CHOICE: + strcpy(Settings.PS3PathROMDirectory, path); + break; + } + menuStackindex--; + } + } + + if (CTRL_TRIANGLE(button_was_pressed)) + { + strcpy(path, usrDirPath); + switch(menu_id) + { + case PATH_SAVESTATES_DIR_CHOICE: + strcpy(Settings.PS3PathSaveStates, path); + break; + case PATH_SRAM_DIR_CHOICE: + strcpy(Settings.PS3PathSRAM, path); + break; + case PATH_CHEATS_DIR_CHOICE: + strcpy(Settings.PS3PathCheats, path); + break; + case PATH_BASE_DIR_CHOICE: + strcpy(Settings.PS3PathBaseDirectory, path); + break; + case PATH_DEFAULT_ROM_DIR_CHOICE: + strcpy(Settings.PS3PathROMDirectory, path); + break; + } + menuStackindex--; + } + + if (CTRL_CROSS(button_was_pressed)) + { + if(FILEBROWSER_IS_CURRENT_A_DIRECTORY(tmpBrowser)) + { + /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path*/ + if(tmpBrowser.currently_selected == 0) + { + old_state = state; + filebrowser_pop_directory(&tmpBrowser); + } + else + { + const char * separatorslash = (strcmp(FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser),"/") == 0) ? "" : "/"; + snprintf(newpath, sizeof(newpath), "%s%s%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser), separatorslash, FILEBROWSER_GET_CURRENT_FILENAME(tmpBrowser)); + filebrowser_push_directory(&tmpBrowser, newpath, false); + } + } + } + + cellDbgFontPrintf (0.09f, 0.09f, FONT_SIZE, YELLOW, "PATH: %s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(tmpBrowser)); + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "DIRECTORY SELECTION"); + cellDbgFontPuts (0.09f, 0.93f, 0.92f, YELLOW, "X - Enter dir /\\ - return to settings START - Reset Startdir"); + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - Browse to a directory and assign it as the path by pressing SQUARE."); + cellDbgFontDraw(); + + RenderBrowser(&tmpBrowser); + old_state = state; +} + +#define print_help_message_yesno(menu, currentsetting) \ + snprintf(menu.items[currentsetting].comment, sizeof(menu.items[currentsetting].comment), *(menu.items[currentsetting].setting_ptr) ? menu.items[currentsetting].comment_yes : menu.items[currentsetting].comment_no); \ + print_help_message(menu, currentsetting); + +#define print_help_message(menu, currentsetting) \ + cellDbgFontPrintf(menu.items[currentsetting].comment_xpos, menu.items[currentsetting].comment_ypos, menu.items[currentsetting].comment_scalefont, menu.items[currentsetting].comment_color, menu.items[currentsetting].comment); + +static void display_help_text(int currentsetting) +{ + switch(currentsetting) + { + case SETTING_HW_TEXTURE_FILTER: + case SETTING_HW_TEXTURE_FILTER_2: + case SETTING_SCALE_ENABLED: + case SETTING_ENABLE_SCREENSHOTS: + case SETTING_TRIPLE_BUFFERING: + case SETTING_THROTTLE_MODE: + case SETTING_APPLY_SHADER_PRESET_ON_STARTUP: + print_help_message_yesno(menu_generalvideosettings, currentsetting); + break; + case SETTING_SCALE_FACTOR: + snprintf(menu_generalvideosettings.items[currentsetting].comment, sizeof(menu_generalvideosettings.items[currentsetting].comment), "INFO - [Custom Scaling Factor] is set to: '%dx'.", Settings.ScaleFactor); + print_help_message(menu_generalvideosettings, currentsetting); + break; + case SETTING_KEEP_ASPECT_RATIO: + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - [Aspect ratio] is set to '%d:%d'.", ps3graphics_get_aspect_ratio_int(0), ps3graphics_get_aspect_ratio_int(1)); + break; + case SETTING_SOUND_MODE: + snprintf(menu_generalaudiosettings.items[currentsetting].comment, sizeof(menu_generalaudiosettings.items[currentsetting].comment), Settings.SoundMode == SOUND_MODE_RSOUND ? "INFO - [Sound Output] is set to 'RSound' - the sound will be streamed over the\n network to the RSound audio server." : Settings.SoundMode == SOUND_MODE_HEADSET ? "INFO - [Sound Output] is set to 'USB/Bluetooth Headset' - sound will\n be output through the headset" : "INFO - [Sound Output] is set to 'Normal' - normal audio output will be\nused."); + print_help_message(menu_generalaudiosettings, currentsetting); + break; + case SETTING_BORDER: + /*case SETTING_GAME_AWARE_SHADER:*/ + case SETTING_SHADER: + case SETTING_SHADER_2: + case SETTING_FONT_SIZE: + case SETTING_CHANGE_RESOLUTION: + case SETTING_HW_OVERSCAN_AMOUNT: + case SETTING_DEFAULT_VIDEO_ALL: + case SETTING_SAVE_SHADER_PRESET: + print_help_message(menu_generalvideosettings, currentsetting); + break; + case SETTING_DEFAULT_AUDIO_ALL: + case SETTING_RSOUND_SERVER_IP_ADDRESS: + print_help_message(menu_generalaudiosettings, currentsetting); + break; + case SETTING_CONTROLS_SCHEME: + cellDbgFontPrintf(0.09f, 0.83f, 0.86f, LIGHTBLUE, + Settings.ControlScheme == CONTROL_SCHEME_DEFAULT ? "INFO - Control scheme [Default] is selected.\nNOTE: You can't customize the controls with this scheme." : "INFO - Control scheme [Custom] is selected.\nNOTE: You can customize the controls with this scheme."); + break; + case SETTING_CONTROLS_DPAD_UP: + case SETTING_CONTROLS_DPAD_DOWN: + case SETTING_CONTROLS_DPAD_LEFT: + case SETTING_CONTROLS_DPAD_RIGHT: + case SETTING_CONTROLS_BUTTON_CIRCLE: + case SETTING_CONTROLS_BUTTON_CROSS: + case SETTING_CONTROLS_BUTTON_TRIANGLE: + case SETTING_CONTROLS_BUTTON_SQUARE: + case SETTING_CONTROLS_BUTTON_SELECT: + case SETTING_CONTROLS_BUTTON_START: + case SETTING_CONTROLS_BUTTON_L1: + case SETTING_CONTROLS_BUTTON_R1: + case SETTING_CONTROLS_BUTTON_L2: + case SETTING_CONTROLS_BUTTON_R2: + case SETTING_CONTROLS_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_R3_BUTTON_L3: + case SETTING_CONTROLS_ANALOG_R_UP: + case SETTING_CONTROLS_ANALOG_R_DOWN: + case SETTING_CONTROLS_ANALOG_R_LEFT: + case SETTING_CONTROLS_ANALOG_R_RIGHT: + //cellDbgFontPrintf(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - [%s] on the PS3 controller is mapped to action:\n[%s].", menu_controlssettings.items[currentsetting].text, Input_PrintMappedButton(control_binds[currently_selected_controller_menu][currentsetting-FIRST_CONTROL_BIND])); + break; + case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS: + cellDbgFontPuts(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - Save the custom control settings.\nNOTE: This option will not do anything with Control Scheme [New] or [Default]."); + break; + case SETTING_CONTROLS_DEFAULT_ALL: + cellDbgFontPuts(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - Set all 'Controls' settings back to their default values."); + break; + case SETTING_EMU_CURRENT_SAVE_STATE_SLOT: + case SETTING_EMU_DEFAULT_ALL: + print_help_message(menu_emu_settings, currentsetting); + case SETTING_EMU_VIDEO_DEFAULT_ALL: + print_help_message(menu_emu_videosettings, currentsetting); + break; + case SETTING_EMU_AUDIO_DEFAULT_ALL: + print_help_message(menu_emu_audiosettings, currentsetting); + break; + case SETTING_PATH_SAVESTATES_DIRECTORY: + case SETTING_PATH_DEFAULT_ROM_DIRECTORY: + case SETTING_PATH_SRAM_DIRECTORY: + case SETTING_PATH_CHEATS: + case SETTING_PATH_DEFAULT_ALL: + print_help_message(menu_pathsettings, currentsetting); + break; + /* + case SETTING_PAL60_MODE: + cellDbgFontPrintf(0.09f, 0.83f, 0.86f, LIGHTBLUE, "%s", Settings.PS3PALTemporalMode60Hz ? "INFO - PAL 60Hz mode is enabled - 60Hz NTSC games will run correctly at 576p PAL\nresolution. NOTE: This is configured on-the-fly." : "INFO - PAL 60Hz mode disabled - 50Hz PAL games will run correctly at 576p PAL\nresolution. NOTE: This is configured on-the-fly."); + break; + */ + case SETTING_CONTROLS_SCHEME: + cellDbgFontPrintf(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - Input Control scheme preset [%s] is selected.\n", Settings.PS3CurrentInputPresetTitle); + break; + case SETTING_CONTROLS_DPAD_UP: + case SETTING_CONTROLS_DPAD_DOWN: + case SETTING_CONTROLS_DPAD_LEFT: + case SETTING_CONTROLS_DPAD_RIGHT: + case SETTING_CONTROLS_BUTTON_CIRCLE: + case SETTING_CONTROLS_BUTTON_CROSS: + case SETTING_CONTROLS_BUTTON_TRIANGLE: + case SETTING_CONTROLS_BUTTON_SQUARE: + case SETTING_CONTROLS_BUTTON_SELECT: + case SETTING_CONTROLS_BUTTON_START: + case SETTING_CONTROLS_BUTTON_L1: + case SETTING_CONTROLS_BUTTON_R1: + case SETTING_CONTROLS_BUTTON_L2: + case SETTING_CONTROLS_BUTTON_R2: + case SETTING_CONTROLS_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_R3_BUTTON_L3: + case SETTING_CONTROLS_ANALOG_R_UP: + case SETTING_CONTROLS_ANALOG_R_DOWN: + case SETTING_CONTROLS_ANALOG_R_LEFT: + case SETTING_CONTROLS_ANALOG_R_RIGHT: + cellDbgFontPrintf(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - [%s] on the PS3 controller is mapped to action:\n[%s].", menu_controlssettings.items[currentsetting].text, Input_PrintMappedButton(control_binds[currently_selected_controller_menu][currentsetting-FIRST_CONTROL_BIND])); + break; + case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS: + cellDbgFontPuts(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - Save the custom control settings.\nNOTE: This option will not do anything with Control Scheme [New] or [Default]."); + break; + case SETTING_CONTROLS_DEFAULT_ALL: + cellDbgFontPuts(0.09f, 0.83f, 0.86f, LIGHTBLUE, "INFO - Set all 'Controls' settings back to their default values."); + break; + + } +} + +static void display_label_value(uint64_t switchvalue) +{ + switch(switchvalue) + { + case SETTING_CHANGE_RESOLUTION: + { + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, ps3graphics_get_initial_resolution() == ps3graphics_get_current_resolution() ? GREEN : ORANGE, ps3graphics_get_resolution_label(ps3graphics_get_current_resolution())); + cellDbgFontDraw(); + break; + } +#if 0 + case SETTING_PAL60_MODE: + cellDbgFontPuts (menu_generalvideosettings.items[switchvalue].text_xpos, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, currently_selected_setting == menu_generalvideosettings.items[switchvalue].enum_id ? YELLOW : WHITE, "PAL60 Mode (576p only)"); + cellDbgFontPrintf (0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, Settings.PS3PALTemporalMode60Hz ? ORANGE : GREEN, Settings.PS3PALTemporalMode60Hz ? "ON" : "OFF"); + break; +#endif +#if 0 + case SETTING_GAME_AWARE_SHADER: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, Settings.GameAwareShaderPath == "" ? GREEN : ORANGE, "%s", Settings.GameAwareShaderPath); + break; +#endif + case SETTING_SHADER_PRESETS: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, + (menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].enabled == 0) ? SILVER : strcmp(Settings.ShaderPresetPath, DEFAULT_PRESET_FILE) == 0 ? GREEN : ORANGE, + "%s", Settings.ShaderPresetTitle); + break; + case SETTING_BORDER: + { + extract_filename_only(Settings.PS3CurrentBorder); + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, GREEN, "%s", fname_without_path_extension); + } + break; + case SETTING_SHADER: + { + extract_filename_only(g_settings.video.cg_shader_path); + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, GREEN, "%s", fname_without_path_extension); + } + break; + case SETTING_SHADER_2: + { + extract_filename_only(g_settings.second_pass_shader); + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, !(Settings.ScaleEnabled) ? SILVER : GREEN, "%s", fname_without_path_extension); + } + break; + case SETTING_FONT_SIZE: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, Settings.PS3FontSize == 100 ? GREEN : ORANGE, "%f", FONT_SIZE); + break; + case SETTING_KEEP_ASPECT_RATIO: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, 0.91f, ps3graphics_get_aspect_ratio_float(Settings.PS3KeepAspect) == SCREEN_4_3_ASPECT_RATIO ? GREEN : ORANGE, "%s%d:%d", ps3graphics_calculate_aspect_ratio_before_game_load() ? "(Auto)" : "", (int)ps3graphics_get_aspect_ratio_int(0), (int)ps3graphics_get_aspect_ratio_int(1)); + cellDbgFontDraw(); + break; + case SETTING_HW_TEXTURE_FILTER: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, Settings.PS3Smooth ? GREEN : ORANGE, Settings.PS3Smooth ? "Linear interpolation" : "Point filtering"); + break; + case SETTING_HW_TEXTURE_FILTER_2: + cellDbgFontPrintf(0.5f, menu_generalvideosettings.items[switchvalue].text_ypos, FONT_SIZE, !(menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].enabled) ? SILVER : Settings.PS3Smooth2 ? GREEN : ORANGE, Settings.PS3Smooth2 ? "Linear interpolation" : "Point filtering"); + break; + case SETTING_SCALE_FACTOR: + cellDbgFontPrintf (0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, (menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].enabled == 0) ? SILVER : Settings.ScaleFactor == 2 ? GREEN : ORANGE, "%dx", Settings.ScaleFactor); + break; + case SETTING_HW_OVERSCAN_AMOUNT: + cellDbgFontPrintf (0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, Settings.PS3OverscanAmount == 0 ? GREEN : ORANGE, "%f", (float)Settings.PS3OverscanAmount/100); + break; + case SETTING_SOUND_MODE: + cellDbgFontPuts(0.5f, menu_generalaudiosettings.items[menu_generalaudiosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, Settings.SoundMode == SOUND_MODE_NORMAL ? GREEN : ORANGE, Settings.SoundMode == SOUND_MODE_RSOUND ? "RSound" : Settings.SoundMode == SOUND_MODE_HEADSET ? "USB/Bluetooth Headset" : "Normal"); + break; + case SETTING_RSOUND_SERVER_IP_ADDRESS: + cellDbgFontPuts(0.5f, menu_generalaudiosettings.items[menu_generalaudiosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, strcmp(Settings.RSoundServerIPAddress,"0.0.0.0") ? ORANGE : GREEN, Settings.RSoundServerIPAddress); + break; + case SETTING_THROTTLE_MODE: + case SETTING_ENABLE_SCREENSHOTS: + case SETTING_TRIPLE_BUFFERING: + case SETTING_SCALE_ENABLED: + case SETTING_APPLY_SHADER_PRESET_ON_STARTUP: + cellDbgFontPuts(0.5f, menu_generalvideosettings.items[menu_generalvideosettings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, *(menu_generalvideosettings.items[switchvalue].setting_ptr) ? GREEN : ORANGE, *(menu_generalvideosettings.items[switchvalue].setting_ptr) ? "ON" : "OFF"); + break; + case SETTING_EMU_CURRENT_SAVE_STATE_SLOT: + cellDbgFontPrintf(0.5f, menu_emu_settings.items[menu_emu_settings.items[switchvalue].enum_id].text_ypos, FONT_SIZE, Settings.CurrentSaveStateSlot == MIN_SAVE_STATE_SLOT ? GREEN : ORANGE, "%d", Settings.CurrentSaveStateSlot); + break; + case SETTING_PATH_DEFAULT_ROM_DIRECTORY: + cellDbgFontPuts (0.5f, menu_pathsettings.items[switchvalue].text_ypos, FONT_SIZE, !(strcmp(Settings.PS3PathROMDirectory,"/")) ? GREEN : ORANGE, Settings.PS3PathROMDirectory); + break; + case SETTING_PATH_SAVESTATES_DIRECTORY: + cellDbgFontPuts (0.5f, menu_pathsettings.items[switchvalue].text_ypos, FONT_SIZE, !(strcmp(Settings.PS3PathSaveStates,usrDirPath)) ? GREEN : ORANGE, Settings.PS3PathSaveStates); + break; + case SETTING_PATH_SRAM_DIRECTORY: + cellDbgFontPuts (0.5f, menu_pathsettings.items[switchvalue].text_ypos, FONT_SIZE, !(strcmp(Settings.PS3PathSRAM,usrDirPath)) ? GREEN : ORANGE, Settings.PS3PathSRAM); + break; + case SETTING_PATH_BASE_DIRECTORY: + cellDbgFontPuts (0.5f, menu_pathsettings.items[switchvalue].text_ypos, FONT_SIZE, !(strcmp(Settings.PS3PathBaseDirectory,usrDirPath)) ? GREEN : ORANGE, Settings.PS3PathBaseDirectory); + break; + case SETTING_PATH_CHEATS: + cellDbgFontPuts (0.5f, menu_pathsettings.items[switchvalue].text_ypos, FONT_SIZE, !(strcmp(Settings.PS3PathCheats,usrDirPath)) ? GREEN : ORANGE, Settings.PS3PathCheats); + break; + case SETTING_DEFAULT_VIDEO_ALL: + case SETTING_SAVE_SHADER_PRESET: + case SETTING_DEFAULT_AUDIO_ALL: + case SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS: + cellDbgFontDraw(); + break; + case SETTING_CONTROLS_SCHEME: + cellDbgFontPrintf(0.5f, menu_controlssettings.items[switchvalue].text_ypos, FONT_SIZE, Settings.ControlScheme == CONTROL_SCHEME_DEFAULT ? GREEN : ORANGE, Settings.PS3CurrentInputPresetTitle); + break; + case SETTING_CONTROLS_NUMBER: + cellDbgFontPrintf(0.5f, menu_controlssettings.items[switchvalue].text_ypos, FONT_SIZE, currently_selected_controller_menu == 0 ? GREEN : ORANGE, "%d", currently_selected_controller_menu+1); + break; + case SETTING_CONTROLS_DPAD_UP: + case SETTING_CONTROLS_DPAD_DOWN: + case SETTING_CONTROLS_DPAD_LEFT: + case SETTING_CONTROLS_DPAD_RIGHT: + case SETTING_CONTROLS_BUTTON_CIRCLE: + case SETTING_CONTROLS_BUTTON_CROSS: + case SETTING_CONTROLS_BUTTON_TRIANGLE: + case SETTING_CONTROLS_BUTTON_SQUARE: + case SETTING_CONTROLS_BUTTON_SELECT: + case SETTING_CONTROLS_BUTTON_START: + case SETTING_CONTROLS_BUTTON_L1: + case SETTING_CONTROLS_BUTTON_R1: + case SETTING_CONTROLS_BUTTON_L2: + case SETTING_CONTROLS_BUTTON_R2: + case SETTING_CONTROLS_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_L3: + case SETTING_CONTROLS_BUTTON_L2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_L2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_RIGHT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_LEFT: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_UP: + case SETTING_CONTROLS_BUTTON_R2_ANALOG_R_DOWN: + case SETTING_CONTROLS_BUTTON_R2_BUTTON_R3: + case SETTING_CONTROLS_BUTTON_R3_BUTTON_L3: + case SETTING_CONTROLS_ANALOG_R_UP: + case SETTING_CONTROLS_ANALOG_R_DOWN: + case SETTING_CONTROLS_ANALOG_R_LEFT: + case SETTING_CONTROLS_ANALOG_R_RIGHT: + //cellDbgFontPuts(0.5f, menu_controlssettings.items[switchvalue].text_ypos, FONT_SIZE, control_binds[currently_selected_controller_menu][switchvalue-(FIRST_CONTROL_BIND)] == default_control_binds[switchvalue-FIRST_CONTROL_BIND] ? GREEN : ORANGE, Input_PrintMappedButton(control_binds[currently_selected_controller_menu][switchvalue-FIRST_CONTROL_BIND])); + break; + } +} + +static void apply_scaling(void) +{ +} + +#include "menu/settings-logic.h" + +static void do_settings(menu * menu_obj) +{ + uint64_t state, diff_state, button_was_pressed, i; + static uint64_t old_state = 0; + + state = cell_pad_input_poll_device(0); + diff_state = old_state ^ state; + button_was_pressed = old_state & diff_state; + + + if(g_frame_count < special_action_msg_expired) + { + } + else + { + /* back to ROM menu if CIRCLE is pressed */ + if (CTRL_L1(button_was_pressed) || CTRL_CIRCLE(button_was_pressed)) + { + menuStackindex--; + old_state = state; + return; + } + + if (CTRL_R1(button_was_pressed)) + { + switch(menu_obj->enum_id) + { + case GENERAL_VIDEO_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_generalaudiosettings; + old_state = state; + break; + case GENERAL_AUDIO_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_emu_settings; + old_state = state; + break; + case EMU_GENERAL_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_emu_videosettings; + old_state = state; + break; + case EMU_VIDEO_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_emu_audiosettings; + old_state = state; + break; + case EMU_AUDIO_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_pathsettings; + old_state = state; + break; + case PATH_MENU: + menuStackindex++; + menuStack[menuStackindex] = menu_controlssettings; + old_state = state; + break; + case CONTROLS_MENU: + break; + } + } + + /* down to next setting */ + + if (CTRL_DOWN(state) || CTRL_LSTICK_DOWN(state)) + { + menu_obj->selected++; + + if (menu_obj->selected >= menu_obj->max_settings) + menu_obj->selected = menu_obj->first_setting; + + if (menu_obj->items[menu_obj->selected].page != menu_obj->page) + menu_obj->page = menu_obj->items[menu_obj->selected].page; + + set_text_message("", 7); + } + + /* up to previous setting */ + + if (CTRL_UP(state) || CTRL_LSTICK_UP(state)) + { + if (menu_obj->selected == menu_obj->first_setting) + menu_obj->selected = menu_obj->max_settings-1; + else + menu_obj->selected--; + + if (menu_obj->items[menu_obj->selected].page != menu_obj->page) + menu_obj->page = menu_obj->items[menu_obj->selected].page; + + set_text_message("", 7); + } + + /* if a rom is loaded then resume it */ + + if (CTRL_L3(state) && CTRL_R3(state)) + { + if (g_rom_loaded) + { + menu_is_running = 0; + Emulator_StartROMRunning(1); + set_text_message("", 15); + } + old_state = state; + return; + } + + + producesettingentry(menu_obj->selected); + } + + display_menubar(menu_obj->enum_id); + cellDbgFontDraw(); + + for ( i = menu_obj->first_setting; i < menu_obj->max_settings; i++) + { + if(menu_obj->items[i].page == menu_obj->page) + { + cellDbgFontPuts(menu_obj->items[i].text_xpos, menu_obj->items[i].text_ypos, FONT_SIZE, menu_obj->selected == menu_obj->items[i].enum_id ? menu_obj->items[i].text_selected_color : menu_obj->items[i].text_unselected_color, menu_obj->items[i].text); + display_label_value(i); + cellDbgFontDraw(); + } + } + + display_help_text(menu_obj->selected); + + cellDbgFontPuts(0.09f, 0.91f, FONT_SIZE, YELLOW, "UP/DOWN - select L3+R3 - resume game X/LEFT/RIGHT - change"); + cellDbgFontPuts(0.09f, 0.95f, FONT_SIZE, YELLOW, "START - default L1/CIRCLE - go back R1 - go forward"); + cellDbgFontDraw(); + old_state = state; +} + +static void do_ROMMenu(void) +{ + char newpath[1024]; + + uint64_t state = cell_pad_input_poll_device(0); + static uint64_t old_state = 0; + uint64_t diff_state = old_state ^ state; + uint64_t button_was_pressed = old_state & diff_state; + + UpdateBrowser(&browser); + + if (CTRL_SELECT(button_was_pressed)) + { + menuStackindex++; + menuStack[menuStackindex] = menu_generalvideosettings; + } + + if (CTRL_START(button_was_pressed)) + filebrowser_reset_start_directory(&browser, "/", ROM_EXTENSIONS); + + if (CTRL_CROSS(button_was_pressed)) + { + if(FILEBROWSER_IS_CURRENT_A_DIRECTORY(browser)) + { + /*if 'filename' is in fact '..' - then pop back directory instead of adding '..' to filename path*/ + if(browser.currently_selected == 0) + { + old_state = state; + filebrowser_pop_directory(&browser); + } + else + { + const char * separatorslash = (strcmp(FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser),"/") == 0) ? "" : "/"; + snprintf(newpath, sizeof(newpath), "%s%s%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), separatorslash, FILEBROWSER_GET_CURRENT_FILENAME(browser)); + filebrowser_push_directory(&browser, newpath, true); + } + } + else if (FILEBROWSER_IS_CURRENT_A_FILE(browser)) + { + snprintf(g_extern.system.fullpath, sizeof(g_extern.system.fullpath), "%s/%s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser), FILEBROWSER_GET_CURRENT_FILENAME(browser)); + + menu_is_running = 0; + old_state = state; + return; + } + } + + + if (FILEBROWSER_IS_CURRENT_A_DIRECTORY(browser)) + { + if(!strcmp(FILEBROWSER_GET_CURRENT_FILENAME(browser),"app_home") || !strcmp(FILEBROWSER_GET_CURRENT_FILENAME(browser),"host_root")) + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, RED, "WARNING - This path only works on DEX PS3 systems. Do not attempt to open\n this directory on CEX PS3 systems, or you might have to restart!"); + else if(!strcmp(FILEBROWSER_GET_CURRENT_FILENAME(browser),"..")) + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - Press X to go back to the previous directory."); + else + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - Press X to enter the directory."); + } + + if (FILEBROWSER_IS_CURRENT_A_FILE(browser)) + cellDbgFontPrintf(0.09f, 0.83f, 0.91f, LIGHTBLUE, "INFO - Press X to load the game. "); + + cellDbgFontPuts (0.09f, 0.05f, FONT_SIZE, RED, "FILE BROWSER"); + cellDbgFontPrintf (0.7f, 0.05f, 0.82f, WHITE, "%s v%s", "SSNES", PACKAGE_VERSION); + cellDbgFontPrintf (0.09f, 0.09f, FONT_SIZE, YELLOW, "PATH: %s", FILEBROWSER_GET_CURRENT_DIRECTORY_NAME(browser)); + cellDbgFontPuts (0.09f, 0.93f, FONT_SIZE, YELLOW, + "L3 + R3 - resume game SELECT - Settings screen"); + cellDbgFontDraw(); + + RenderBrowser(&browser); + old_state = state; +} + +static void menu_init_settings_pages(menu * menu_obj) +{ + int page, i, j; + float increment; + + page = 0; + j = 0; + increment = 0.13f; + + for(i = menu_obj->first_setting; i < menu_obj->max_settings; i++) + { + if(!(j < (NUM_ENTRY_PER_PAGE))) + { + j = 0; + increment = 0.13f; + page++; + } + + menu_obj->items[i].text_xpos = 0.09f; + menu_obj->items[i].text_ypos = increment; + menu_obj->items[i].page = page; + increment += 0.03f; + j++; + } + menu_obj->refreshpage = 0; +} + +void menu_init(void) +{ + filebrowser_new(&browser, Settings.PS3PathROMDirectory, ROM_EXTENSIONS); + + menu_init_settings_pages(&menu_generalvideosettings); + menu_init_settings_pages(&menu_generalaudiosettings); + menu_init_settings_pages(&menu_emu_settings); + menu_init_settings_pages(&menu_emu_videosettings); + menu_init_settings_pages(&menu_emu_audiosettings); + menu_init_settings_pages(&menu_pathsettings); + menu_init_settings_pages(&menu_controlssettings); +} + +void menu_loop(void) +{ + menuStack[0] = menu_filebrowser; + menuStack[0].enum_id = FILE_BROWSER_MENU; + + menu_is_running = true; + + do + { + glClear(GL_COLOR_BUFFER_BIT); + ps3graphics_draw_menu(); + + switch(menuStack[menuStackindex].enum_id) + { + case FILE_BROWSER_MENU: + do_ROMMenu(); + break; + case GENERAL_VIDEO_MENU: + case GENERAL_AUDIO_MENU: + case EMU_GENERAL_MENU: + case EMU_VIDEO_MENU: + case EMU_AUDIO_MENU: + case PATH_MENU: + case CONTROLS_MENU: + do_settings(&menuStack[menuStackindex]); + break; + case GAME_AWARE_SHADER_CHOICE: + case SHADER_CHOICE: + case PRESET_CHOICE: + case BORDER_CHOICE: + case INPUT_PRESET_CHOICE: + do_select_file(menuStack[menuStackindex].enum_id); + break; + case PATH_SAVESTATES_DIR_CHOICE: + case PATH_DEFAULT_ROM_DIR_CHOICE: + case PATH_CHEATS_DIR_CHOICE: + case PATH_SRAM_DIR_CHOICE: + case PATH_BASE_DIR_CHOICE: + do_pathChoice(menuStack[menuStackindex].enum_id); + break; + } + + psglSwap(); + cellSysutilCheckCallback(); + cell_console_poll(); + }while (menu_is_running); +} diff --git a/ps3/menu.h b/ps3/menu.h new file mode 100644 index 0000000000..993d1ecd2e --- /dev/null +++ b/ps3/menu.h @@ -0,0 +1,184 @@ +/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes. + * 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 . + */ + +#ifndef MENU_H_ +#define MENU_H_ + +#define WHITE 0xffffffffu +#define RED 0xff0000ffu +#define GREEN 0xff00ff00u +#define BLUE 0xffff0000u +#define YELLOW 0xff00ffffu +#define PURPLE 0xffff00ffu +#define CYAN 0xffffff00u +#define ORANGE 0xff0063ffu +#define SILVER 0xff8c848cu +#define LIGHTBLUE 0xFFFFE0E0U +#define LIGHTORANGE 0xFFE0EEFFu + +#define FONT_SIZE 1.0f + +typedef struct +{ + uint32_t enum_id; /* enum ID of item */ + char text[256]; /* item label */ + float text_xpos; /* text X position (upper left corner) */ + float text_ypos; /* text Y position (upper left corner) */ + uint32_t text_selected_color; /* text color if selected */ + uint32_t text_unselected_color; /* text color if not selected */ + char comment[256]; /* item comment */ + uint32_t comment_color; /* color of item comment */ + float comment_scalefont; /* font scale of item comment */ + float comment_xpos; /* comment X position (upper left corner) */ + float comment_ypos; /* comment Y position (upper left corner) */ + unsigned int * setting_ptr; /* associated pointer to setting member */ + char comment_yes[256]; /* item comment (yes - if setting_ptr true) */ + char comment_no[256]; /* item comment (no - if setting_ptr false) */ + uint32_t default_value; /* default value of item */ + uint32_t enabled; /* is the item enabled? */ + uint32_t page; /* page */ +} item; + +typedef struct +{ + char title[64]; /* menu title */ + uint32_t enum_id; /* enum ID of menu */ + uint32_t selected; /* index of selected item */ + uint32_t page; /* page */ + uint32_t refreshpage; /* bit whether or not to refresh page */ + uint32_t first_setting; /* first setting */ + uint32_t max_settings; /* max no of settings in menu */ + item *items; /* menu items */ +} menu; + + +#define FILE_BROWSER_MENU 0 +#define GENERAL_VIDEO_MENU 1 +#define GENERAL_AUDIO_MENU 2 +#define EMU_GENERAL_MENU 3 +#define EMU_VIDEO_MENU 4 +#define EMU_AUDIO_MENU 5 +#define PATH_MENU 6 +#define CONTROLS_MENU 7 +#define SHADER_CHOICE 8 +#define PRESET_CHOICE 9 +#define BORDER_CHOICE 10 +#define PATH_CHOICE 11 +#define GAME_AWARE_SHADER_CHOICE 12 +#define PATH_SAVESTATES_DIR_CHOICE 13 +#define PATH_DEFAULT_ROM_DIR_CHOICE 14 +#define PATH_CHEATS_DIR_CHOICE 15 +#define PATH_SRAM_DIR_CHOICE 16 +#define PATH_BASE_DIR_CHOICE 17 +#define INPUT_PRESET_CHOICE 18 + +enum +{ + SETTING_CHANGE_RESOLUTION, + SETTING_SHADER_PRESETS, + SETTING_BORDER, + SETTING_SHADER, + SETTING_SHADER_2, + SETTING_GAME_AWARE_SHADER, + SETTING_FONT_SIZE, + SETTING_KEEP_ASPECT_RATIO, + SETTING_HW_TEXTURE_FILTER, + SETTING_HW_TEXTURE_FILTER_2, + SETTING_SCALE_ENABLED, + SETTING_SCALE_FACTOR, + SETTING_HW_OVERSCAN_AMOUNT, + SETTING_THROTTLE_MODE, + SETTING_TRIPLE_BUFFERING, + SETTING_ENABLE_SCREENSHOTS, + SETTING_SAVE_SHADER_PRESET, + SETTING_APPLY_SHADER_PRESET_ON_STARTUP, + SETTING_DEFAULT_VIDEO_ALL, + SETTING_SOUND_MODE, + SETTING_RSOUND_SERVER_IP_ADDRESS, + SETTING_DEFAULT_AUDIO_ALL, + SETTING_EMU_CURRENT_SAVE_STATE_SLOT, + SETTING_EMU_DEFAULT_ALL, + SETTING_EMU_VIDEO_DEFAULT_ALL, + SETTING_EMU_AUDIO_DEFAULT_ALL, + SETTING_PATH_DEFAULT_ROM_DIRECTORY, + SETTING_PATH_SAVESTATES_DIRECTORY, + SETTING_PATH_SRAM_DIRECTORY, + SETTING_PATH_CHEATS, + SETTING_PATH_BASE_DIRECTORY, + SETTING_PATH_DEFAULT_ALL, + SETTING_CONTROLS_SCHEME, + SETTING_CONTROLS_NUMBER, + SETTING_CONTROLS_DPAD_UP, + SETTING_CONTROLS_DPAD_DOWN, + SETTING_CONTROLS_DPAD_LEFT, + SETTING_CONTROLS_DPAD_RIGHT, + SETTING_CONTROLS_BUTTON_CIRCLE, + SETTING_CONTROLS_BUTTON_CROSS, + SETTING_CONTROLS_BUTTON_TRIANGLE, + SETTING_CONTROLS_BUTTON_SQUARE, + SETTING_CONTROLS_BUTTON_SELECT, + SETTING_CONTROLS_BUTTON_START, + SETTING_CONTROLS_BUTTON_L1, + SETTING_CONTROLS_BUTTON_R1, + SETTING_CONTROLS_BUTTON_L2, + SETTING_CONTROLS_BUTTON_R2, + SETTING_CONTROLS_BUTTON_L3, + SETTING_CONTROLS_BUTTON_R3, + SETTING_CONTROLS_BUTTON_L2_BUTTON_L3, + SETTING_CONTROLS_BUTTON_L2_BUTTON_R3, + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_RIGHT, + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_LEFT, + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_UP, + SETTING_CONTROLS_BUTTON_L2_ANALOG_R_DOWN, + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_RIGHT, + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_LEFT, + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_UP, + SETTING_CONTROLS_BUTTON_R2_ANALOG_R_DOWN, + SETTING_CONTROLS_BUTTON_R2_BUTTON_R3, + SETTING_CONTROLS_BUTTON_R3_BUTTON_L3, + SETTING_CONTROLS_ANALOG_R_UP, + SETTING_CONTROLS_ANALOG_R_DOWN, + SETTING_CONTROLS_ANALOG_R_LEFT, + SETTING_CONTROLS_ANALOG_R_RIGHT, + SETTING_CONTROLS_SAVE_CUSTOM_CONTROLS, + SETTING_CONTROLS_DEFAULT_ALL +}; + +#define FIRST_VIDEO_SETTING 0 +#define FIRST_AUDIO_SETTING SETTING_DEFAULT_VIDEO_ALL+1 +#define FIRST_EMU_SETTING SETTING_DEFAULT_AUDIO_ALL+1 +#define FIRST_EMU_VIDEO_SETTING SETTING_EMU_DEFAULT_ALL+1 +#define FIRST_EMU_AUDIO_SETTING SETTING_EMU_VIDEO_DEFAULT_ALL+1 +#define FIRST_PATH_SETTING SETTING_EMU_AUDIO_DEFAULT_ALL+1 +#define FIRST_CONTROLS_SETTING_PAGE_1 SETTING_PATH_DEFAULT_ALL+1 +#define FIRST_CONTROL_BIND SETTING_CONTROLS_DPAD_UP + +#define MAX_NO_OF_VIDEO_SETTINGS SETTING_DEFAULT_VIDEO_ALL+1 +#define MAX_NO_OF_AUDIO_SETTINGS SETTING_DEFAULT_AUDIO_ALL+1 +#define MAX_NO_OF_EMU_SETTINGS SETTING_EMU_DEFAULT_ALL+1 +#define MAX_NO_OF_EMU_VIDEO_SETTINGS SETTING_EMU_VIDEO_DEFAULT_ALL+1 +#define MAX_NO_OF_EMU_AUDIO_SETTINGS SETTING_EMU_AUDIO_DEFAULT_ALL+1 +#define MAX_NO_OF_PATH_SETTINGS SETTING_PATH_DEFAULT_ALL+1 +#define MAX_NO_OF_CONTROLS_SETTINGS SETTING_CONTROLS_DEFAULT_ALL+1 + +void menu_init(void); +void menu_loop(void); + +extern uint32_t menu_is_running; + +#endif /* MENU_H_ */ diff --git a/ps3/ps3_video_psgl.c b/ps3/ps3_video_psgl.c index 90d0d1ea7b..eb0b391cea 100644 --- a/ps3/ps3_video_psgl.c +++ b/ps3/ps3_video_psgl.c @@ -94,6 +94,7 @@ static bool load_fbo_proc(void) { return true; } #define TEXTURES_MASK (TEXTURES - 1) static bool g_quitting; +unsigned g_frame_count; typedef struct gl { @@ -107,8 +108,6 @@ typedef struct gl GLuint tex_filter; void *empty_buf; - unsigned frame_count; - #ifdef HAVE_FBO // Render-to-texture, multipass shaders GLuint fbo[MAX_SHADERS]; @@ -512,7 +511,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei gl_t *gl = data; gl_shader_use(1); - gl->frame_count++; + g_frame_count++; #if defined(HAVE_CG) glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); @@ -689,7 +688,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei memcpy(tex_info.coord, gl->tex_coords, sizeof(gl->tex_coords)); glClear(GL_COLOR_BUFFER_BIT); - gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, gl->frame_count, + gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, g_frame_count, &tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); glDrawArrays(GL_QUADS, 0, 4); @@ -734,7 +733,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei set_viewport(gl, rect->img_width, rect->img_height, true); gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, - gl->vp_width, gl->vp_height, gl->frame_count, + gl->vp_width, gl->vp_height, g_frame_count, &tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); glDrawArrays(GL_QUADS, 0, 4); @@ -760,7 +759,7 @@ static bool gl_frame(void *data, const void *frame, unsigned width, unsigned hei set_viewport(gl, gl->win_width, gl->win_height, false); gl_shader_set_params(prev_rect->img_width, prev_rect->img_height, prev_rect->width, prev_rect->height, - gl->vp_width, gl->vp_height, gl->frame_count, + gl->vp_width, gl->vp_height, g_frame_count, &tex_info, gl->prev_info, fbo_tex_info, fbo_tex_info_cnt); glVertexPointer(2, GL_FLOAT, 0, vertexes_flipped);