mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-26 12:47:37 +00:00
802 lines
23 KiB
C
802 lines
23 KiB
C
/* 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 <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include <sysutil/sysutil_screenshot.h>
|
|
#include <cell/dbgfont.h>
|
|
|
|
#include "cellframework2/input/pad_input.h"
|
|
#include "cellframework2/fileio/file_browser.h"
|
|
|
|
#include "ps3_video_psgl.h"
|
|
|
|
#include "shared.h"
|
|
#include "../general.h"
|
|
|
|
#include "menu.h"
|
|
#include "menu-entries.h"
|
|
|
|
#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 ROM_EXTENSIONS "fds|FDS|zip|ZIP|nes|NES|unif|UNIF|smc|fig|sfc|gd3|gd7|dx2|bsx|swc|SMC|FIG|SFC|BSX|GD3|GD7|DX2|SWC"
|
|
|
|
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;
|
|
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:
|
|
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));
|
|
break;
|
|
case PRESET_CHOICE:
|
|
break;
|
|
case INPUT_PRESET_CHOICE:
|
|
break;
|
|
case BORDER_CHOICE:
|
|
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:
|
|
break;
|
|
case PATH_SRAM_DIR_CHOICE:
|
|
break;
|
|
case PATH_CHEATS_DIR_CHOICE:
|
|
strcpy(g_settings.cheat_database, path);
|
|
break;
|
|
case PATH_DEFAULT_ROM_DIR_CHOICE:
|
|
break;
|
|
}
|
|
menuStackindex--;
|
|
}
|
|
}
|
|
|
|
if (CTRL_TRIANGLE(button_was_pressed))
|
|
{
|
|
strcpy(path, usrDirPath);
|
|
switch(menu_id)
|
|
{
|
|
case PATH_SAVESTATES_DIR_CHOICE:
|
|
break;
|
|
case PATH_SRAM_DIR_CHOICE:
|
|
break;
|
|
case PATH_CHEATS_DIR_CHOICE:
|
|
strcpy(g_settings.cheat_database, path);
|
|
break;
|
|
case PATH_DEFAULT_ROM_DIR_CHOICE:
|
|
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)
|
|
{
|
|
}
|
|
|
|
static void display_label_value(uint64_t switchvalue)
|
|
{
|
|
}
|
|
|
|
static void apply_scaling(void)
|
|
{
|
|
}
|
|
|
|
#include "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;
|
|
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, "/", 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();
|
|
g_frame_count++;
|
|
|
|
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();
|
|
}while (menu_is_running);
|
|
}
|