(PS3) WIP aspect ratio settings

This commit is contained in:
TwinAphex51224 2012-01-31 14:12:00 +01:00
parent 56a1877d15
commit cab8fd2a80
4 changed files with 110 additions and 12 deletions

View File

@ -178,6 +178,7 @@ struct console_settings
bool screenshots_enable;
bool throttle_enable;
bool triple_buffering_enable;
uint32_t aspect_ratio_index;
uint32_t screen_orientation;
uint32_t current_resolution_index;
uint32_t current_resolution_id;
@ -185,6 +186,7 @@ struct console_settings
uint32_t *supported_resolutions;
uint32_t supported_resolutions_count;
char rom_path[PATH_MAX];
char aspect_ratio_name[PATH_MAX];
char default_rom_startup_dir[PATH_MAX];
char default_savestate_dir[PATH_MAX];
char default_sram_dir[PATH_MAX];

View File

@ -124,6 +124,8 @@ static void set_default_settings(void)
strlcpy(g_console.default_rom_startup_dir, "/", sizeof(g_console.default_rom_startup_dir));
strlcpy(g_console.default_savestate_dir, usrDirPath, sizeof(g_console.default_savestate_dir));
strlcpy(g_console.default_sram_dir, usrDirPath, sizeof(g_console.default_sram_dir));
g_console.aspect_ratio_index = 0;
strlcpy(g_console.aspect_ratio_name, "4/3", sizeof(g_console.aspect_ratio_name));
// g_extern
g_extern.state_slot = 0;
@ -162,6 +164,7 @@ static void init_settings(void)
CONFIG_GET_BOOL_CONSOLE(screenshots_enable, "screenshots_enable");
CONFIG_GET_BOOL_CONSOLE(throttle_enable, "throttle_enable");
CONFIG_GET_BOOL_CONSOLE(triple_buffering_enable, "triple_buffering_enable");
CONFIG_GET_INT_CONSOLE(aspect_ratio_index, "aspect_ratio_index");
CONFIG_GET_INT_CONSOLE(current_resolution_id, "current_resolution_id");
CONFIG_GET_INT_CONSOLE(screen_orientation, "screen_orientation");
CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir");
@ -190,6 +193,7 @@ static void save_settings(void)
config_set_bool(conf, "rewind_enable", g_settings.rewind_enable);
config_set_string(conf, "video_cg_shader", g_settings.video.cg_shader_path);
config_set_string(conf, "video_second_pass_shader", g_settings.video.second_pass_shader);
config_set_float(conf, "video_aspect_ratio", g_settings.video.aspect_ratio);
config_set_float(conf, "video_fbo_scale_x", g_settings.video.fbo_scale_x);
config_set_float(conf, "video_fbo_scale_y", g_settings.video.fbo_scale_y);
config_set_bool(conf, "video_render_to_texture", g_settings.video.render_to_texture);
@ -201,6 +205,7 @@ static void save_settings(void)
config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable);
config_set_bool(conf, "throttle_enable", g_console.throttle_enable);
config_set_bool(conf, "triple_buffering_enable", g_console.triple_buffering_enable);
config_set_int(conf, "aspect_ratio_index", g_console.aspect_ratio_index);
config_set_int(conf, "current_resolution_id", g_console.current_resolution_id);
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
@ -404,12 +409,24 @@ static void ingame_menu(void)
case MENU_ITEM_KEEP_ASPECT_RATIO:
if(CTRL_LEFT(button_was_pressed) || CTRL_LSTICK_LEFT(button_was_pressed))
{
if(g_console.aspect_ratio_index > 0)
{
g_console.aspect_ratio_index--;
ps3graphics_set_aspect_ratio(g_console.aspect_ratio_index);
}
}
if(CTRL_RIGHT(button_was_pressed) || CTRL_LSTICK_RIGHT(button_was_pressed))
{
if(g_console.aspect_ratio_index < LAST_ASPECT_RATIO)
{
g_console.aspect_ratio_index++;
ps3graphics_set_aspect_ratio(g_console.aspect_ratio_index);
}
}
if(CTRL_START(button_was_pressed))
{
g_console.aspect_ratio_index = ASPECT_RATIO_4_3;
ps3graphics_set_aspect_ratio(g_console.aspect_ratio_index);
}
ingame_menu_reset_entry_colors (ingame_menu_item);
strcpy(comment, "Press LEFT or RIGHT to change the [Aspect Ratio].\nPress START to reset back to default values.");
@ -579,8 +596,8 @@ static void ingame_menu(void)
cellDbgFontPrintf(x_position, ypos+(ypos_increment*MENU_ITEM_SAVE_STATE), font_size, menuitem_colors[MENU_ITEM_SAVE_STATE], "Save State #%d", g_extern.state_slot);
cellDbgFontDraw();
cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size+0.01f, BLUE, "Aspect Ratio:");
cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size, menuitem_colors[MENU_ITEM_KEEP_ASPECT_RATIO], "Aspect Ratio:");
cellDbgFontPrintf (x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size+0.01f, BLUE, "Aspect Ratio: %s", g_console.aspect_ratio_name);
cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size, menuitem_colors[MENU_ITEM_KEEP_ASPECT_RATIO], "Aspect Ratio: %s", g_console.aspect_ratio_name);
cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_OVERSCAN_AMOUNT)), font_size, menuitem_colors[MENU_ITEM_OVERSCAN_AMOUNT], "Overscan: ");

View File

@ -1258,6 +1258,67 @@ void ps3_set_filtering(unsigned index, bool set_smooth)
glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]);
}
void ps3graphics_set_aspect_ratio(uint32_t aspectratio_index)
{
gl_t * gl = g_gl;
switch(aspectratio_index)
{
case ASPECT_RATIO_4_3:
g_settings.video.aspect_ratio = 1.33333333333;
strlcpy(g_console.aspect_ratio_name, "4:3", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_5_4:
g_settings.video.aspect_ratio = 1.25;
strlcpy(g_console.aspect_ratio_name, "5:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_7:
g_settings.video.aspect_ratio = 1.14287142857;
strlcpy(g_console.aspect_ratio_name, "8:7", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_9:
g_settings.video.aspect_ratio = 1.77777777777;
strlcpy(g_console.aspect_ratio_name, "16:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_10:
g_settings.video.aspect_ratio = 1.6;
strlcpy(g_console.aspect_ratio_name, "16:10", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_16_15:
g_settings.video.aspect_ratio = 3.2;
strlcpy(g_console.aspect_ratio_name, "16:15", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_19_14:
g_settings.video.aspect_ratio = 1.35714285714;
strlcpy(g_console.aspect_ratio_name, "19:14", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_2_1:
g_settings.video.aspect_ratio = 2.0;
strlcpy(g_console.aspect_ratio_name, "2:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_2:
g_settings.video.aspect_ratio = 1.5;
strlcpy(g_console.aspect_ratio_name, "3:2", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_3_4:
g_settings.video.aspect_ratio = 1.5;
strlcpy(g_console.aspect_ratio_name, "3:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_1_1:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "1:1", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_AUTO:
strlcpy(g_console.aspect_ratio_name, "(Auto)", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_CUSTOM:
strlcpy(g_console.aspect_ratio_name, "(Custom)", sizeof(g_console.aspect_ratio_name));
break;
}
g_settings.video.force_aspect = false;
set_viewport(gl, gl->win_width, gl->win_height, false);
}
/* PS3 needs a working graphics stack before SSNES even starts.
To deal with this main.c, the top level module owns the instance,

View File

@ -23,21 +23,39 @@
#include "../gfx/gfx_common.h"
#include <cell/dbgfont.h>
void ps3graphics_video_init(bool get_all_resolutions);
void ps3graphics_video_reinit(void);
void ps3_video_deinit(void);
enum
{
ASPECT_RATIO_4_3,
ASPECT_RATIO_5_4,
ASPECT_RATIO_8_7,
ASPECT_RATIO_16_9,
ASPECT_RATIO_16_10,
ASPECT_RATIO_16_15,
ASPECT_RATIO_19_14,
ASPECT_RATIO_2_1,
ASPECT_RATIO_3_2,
ASPECT_RATIO_3_4,
ASPECT_RATIO_1_1,
ASPECT_RATIO_AUTO,
ASPECT_RATIO_CUSTOM,
LAST_ASPECT_RATIO
};
void ps3_next_resolution (void);
void ps3_previous_resolution (void);
bool ps3_setup_texture(void);
const char * ps3_get_resolution_label(uint32_t resolution);
int ps3_check_resolution(uint32_t resolution_id);
void ps3graphics_block_swap (void);
void ps3graphics_unblock_swap (void);
void ps3graphics_set_vsync(uint32_t vsync);
void ps3graphics_set_orientation(uint32_t orientation);
void gl_frame_menu(void);
bool ps3_setup_texture(void);
void ps3_previous_resolution (void);
void ps3_next_resolution (void);
void ps3_set_filtering(unsigned index, bool set_smooth);
void ps3_video_deinit(void);
void ps3graphics_block_swap (void);
void ps3graphics_set_aspect_ratio(uint32_t aspectratio_index);
void ps3graphics_set_orientation(uint32_t orientation);
void ps3graphics_set_vsync(uint32_t vsync);
void ps3graphics_unblock_swap (void);
void ps3graphics_video_init(bool get_all_resolutions);
void ps3graphics_video_reinit(void);
extern void *g_gl;