(PS3) Cleaner aspect ratio changing code

This commit is contained in:
Twinaphex 2012-04-13 03:03:21 +02:00
parent 0ec50e8bc4
commit 6c80cd81d0
6 changed files with 43 additions and 97 deletions

View File

@ -25,6 +25,7 @@
#include "../general.h"
#include "../compat/strl.h"
#include "main_wrap.h"
#include "console_ext.h"
#ifdef HAVE_ZLIB
#include "szlib/zlib.h"
@ -532,3 +533,31 @@ void ssnes_input_set_default_keybind_names_for_emulator(void)
"Mode button", sizeof(ssnes_default_libretro_keybind_name_lut[RETRO_DEVICE_ID_JOYPAD_SELECT]));
}
}
/*============================================================
VIDEO EXTENSIONS
============================================================ */
struct aspectratios_list_t aspectratio_lut[ASPECT_RATIO_CUSTOM+1] = {
{"1:1", 1.0f},
{"2:1", 2.0f},
{"3:2", 1.5f},
{"3:4", 0.75f},
{"4:1", 4.0f},
{"4:3", 1.33333333333f},
{"4:4", 1.0f},
{"5:4", 1.25f},
{"6:5", 1.2f},
{"7:9", 0.77777777777f},
{"8:3", 2.66666666666f},
{"8:7", 1.14287142857f},
{"16:9", 1.777778f},
{"16:10", 1.6f},
{"16:15", 3.2f},
{"19:12", 1.58333333333f},
{"19:14", 1.35714285714f},
{"30:17", 1.76470588235f},
{"32:9", 3.55555555555f},
{"Auto", 0.0f},
{"Custom", 0.0f}
};

View File

@ -19,9 +19,13 @@
enum
{
ASPECT_RATIO_1_1,
ASPECT_RATIO_2_1,
ASPECT_RATIO_3_2,
ASPECT_RATIO_3_4,
ASPECT_RATIO_4_1,
ASPECT_RATIO_4_3,
ASPECT_RATIO_4_4,
ASPECT_RATIO_4_1,
ASPECT_RATIO_5_4,
ASPECT_RATIO_6_5,
ASPECT_RATIO_7_9,
@ -34,14 +38,16 @@ enum
ASPECT_RATIO_19_14,
ASPECT_RATIO_30_17,
ASPECT_RATIO_32_9,
ASPECT_RATIO_2_1,
ASPECT_RATIO_3_2,
ASPECT_RATIO_3_4,
ASPECT_RATIO_1_1,
ASPECT_RATIO_AUTO,
ASPECT_RATIO_CUSTOM
};
struct aspectratios_list_t
{
char name[PATH_MAX];
float value;
};
#define LAST_ASPECT_RATIO ASPECT_RATIO_CUSTOM
#include "console_ext_input.h"

View File

@ -225,7 +225,6 @@ struct console_settings
char input_cfg_path[PATH_MAX];
char rom_path[PATH_MAX];
char rsound_ip_address[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

@ -141,7 +141,6 @@ static void set_default_settings(void)
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_console.menu_font_size = 1.0f;
g_console.overscan_enable = false;
g_console.overscan_amount = 0.0f;
@ -240,7 +239,6 @@ static void init_settings(bool load_libretro_path)
CONFIG_GET_INT_CONSOLE(custom_viewport_height, "custom_viewport_height");
CONFIG_GET_INT_CONSOLE(screen_orientation, "screen_orientation");
CONFIG_GET_INT_CONSOLE(sound_mode, "sound_mode");
CONFIG_GET_STRING_CONSOLE(aspect_ratio_name, "aspect_ratio_name");
CONFIG_GET_STRING_CONSOLE(default_rom_startup_dir, "default_rom_startup_dir");
CONFIG_GET_FLOAT_CONSOLE(menu_font_size, "menu_font_size");
CONFIG_GET_FLOAT_CONSOLE(overscan_amount, "overscan_amount");
@ -303,7 +301,6 @@ static void save_settings(void)
config_set_int(conf, "custom_viewport_x", g_console.custom_viewport_x);
config_set_int(conf, "custom_viewport_y", g_console.custom_viewport_y);
config_set_int(conf, "screen_orientation", g_console.screen_orientation);
config_set_string(conf, "aspect_ratio_name", g_console.aspect_ratio_name);
config_set_string(conf, "default_rom_startup_dir", g_console.default_rom_startup_dir);
config_set_float(conf, "menu_font_size", g_console.menu_font_size);
config_set_float(conf, "overscan_amount", g_console.overscan_amount);

View File

@ -431,7 +431,7 @@ static void set_setting_label(menu * menu_obj, uint64_t currentsetting)
menu_obj->items[currentsetting].text_color = GREEN;
else
menu_obj->items[currentsetting].text_color = ORANGE;
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), g_console.aspect_ratio_name);
snprintf(menu_obj->items[currentsetting].setting_text, sizeof(menu_obj->items[currentsetting].setting_text), aspectratio_lut[g_console.aspect_ratio_index].name);
break;
case SETTING_HW_TEXTURE_FILTER:
if(g_settings.video.smooth)
@ -2499,7 +2499,7 @@ static void ingame_menu(uint32_t menu_id)
cellDbgFontPrintf(x_position, ypos+(ypos_increment*MENU_ITEM_SAVE_STATE), font_size, MENU_ITEM_SELECTED(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, MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO), "Aspect Ratio: %s", g_console.aspect_ratio_name);
cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_KEEP_ASPECT_RATIO)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_KEEP_ASPECT_RATIO), "Aspect Ratio: %s", aspectratio_lut[g_console.aspect_ratio_index].name);
cellDbgFontPrintf(x_position, (ypos+(ypos_increment*MENU_ITEM_OVERSCAN_AMOUNT)), font_size, MENU_ITEM_SELECTED(MENU_ITEM_OVERSCAN_AMOUNT), "Overscan: %f", g_console.overscan_amount);

View File

@ -980,92 +980,7 @@ static void ps3graphics_set_aspect_ratio(void * data, uint32_t aspectratio_index
(void)data;
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_4_4:
g_settings.video.aspect_ratio = 1.0;
strlcpy(g_console.aspect_ratio_name, "4:4", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_4_1:
g_settings.video.aspect_ratio = 4.0;
strlcpy(g_console.aspect_ratio_name, "4:1", 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_6_5:
g_settings.video.aspect_ratio = 1.2;
strlcpy(g_console.aspect_ratio_name, "6:5", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_7_9:
g_settings.video.aspect_ratio = 0.77777777777;
strlcpy(g_console.aspect_ratio_name, "7:9", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_8_3:
g_settings.video.aspect_ratio = 2.66666666666;
strlcpy(g_console.aspect_ratio_name, "8:3", 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.777778;
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_12:
g_settings.video.aspect_ratio = 1.58333333333;
strlcpy(g_console.aspect_ratio_name, "19:12", 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_30_17:
g_settings.video.aspect_ratio = 1.76470588235;
strlcpy(g_console.aspect_ratio_name, "30:17", sizeof(g_console.aspect_ratio_name));
break;
case ASPECT_RATIO_32_9:
g_settings.video.aspect_ratio = 3.55555555555;
strlcpy(g_console.aspect_ratio_name, "32:9", 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 = 0.75;
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.aspect_ratio = aspectratio_lut[g_console.aspect_ratio_index].value;
g_settings.video.force_aspect = false;
gl->keep_aspect = true;
set_viewport(gl, gl->win_width, gl->win_height, false);