Backport PCSXR widescreen hack

This commit is contained in:
twinaphex 2015-07-28 20:46:24 +02:00
parent 9df056ef2d
commit 63082b2adc
2 changed files with 44 additions and 2 deletions

View File

@ -22,6 +22,10 @@ static retro_input_state_t input_state_cb;
static retro_rumble_interface rumble;
static unsigned players = 2;
unsigned char widescreen_hack;
unsigned char widescreen_auto_ar;
unsigned char widescreen_auto_ar_old;
/* start of Mednafen psx.cpp */
/* Mednafen - Multi-system Emulator
@ -2443,6 +2447,30 @@ static void check_variables(void)
}
}
var.key = "beetle_psx_widescreen_hack";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
widescreen_hack = true;
else if (strcmp(var.value, "disabled") == 0)
widescreen_hack = false;
}
else
widescreen_hack = false;
var.key = "beetle_psx_widescreen_auto_ar";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0 && widescreen_hack)
widescreen_auto_ar = true;
else if (strcmp(var.value, "disabled") == 0)
widescreen_auto_ar = false;
}
else
widescreen_auto_ar = false;
var.key = "beetle_psx_analog_toggle";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
@ -3205,8 +3233,18 @@ void retro_run(void)
{
bool updated = false;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE, &updated) && updated)
{
widescreen_auto_ar_old = widescreen_auto_ar;
check_variables();
if (widescreen_auto_ar != widescreen_auto_ar_old)
{
struct retro_system_av_info new_av_info;
retro_get_system_av_info(&new_av_info);
environ_cb(RETRO_ENVIRONMENT_SET_GEOMETRY, &new_av_info);
}
}
if(pending_messages)
{
if(video_frames%120 == 0 && video_frames > 0)
@ -3434,7 +3472,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.base_height = MEDNAFEN_CORE_GEOMETRY_BASE_H;
info->geometry.max_width = MEDNAFEN_CORE_GEOMETRY_MAX_W;
info->geometry.max_height = MEDNAFEN_CORE_GEOMETRY_MAX_H;
info->geometry.aspect_ratio = MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO;
info->geometry.aspect_ratio = !widescreen_auto_ar ? MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO : (float)16/9;
}
void retro_deinit(void)
@ -3507,6 +3545,8 @@ void retro_set_environment(retro_environment_t cb)
static const struct retro_variable vars[] = {
{ "beetle_psx_cdimagecache", "CD Image Cache (restart); disabled|enabled" },
{ "beetle_psx_widescreen_hack", "Widescreen mode hack; disabled|enabled" },
{ "beetle_psx_widescreen_auto_ar", "Widescreen hack auto aspect ratio; disabled|enabled" },
{ "beetle_psx_use_mednafen_memcard0_method", "Memcard 0 method; libretro|mednafen" },
{ "beetle_psx_shared_memory_cards", "Shared memcards (restart); disabled|enabled" },
{ "beetle_psx_experimental_save_states", "Savestates (restart); disabled|enabled" },

View File

@ -134,6 +134,8 @@ static uint32_t LZCR;
static uint32_t Reg23;
// end DR
extern unsigned char widescreen_hack;
static INLINE uint8_t Sat5(int16_t cc)
{
if(cc < 0)
@ -1051,7 +1053,7 @@ static INLINE uint32_t Divide(uint32_t dividend, uint32_t divisor)
static INLINE void TransformXY(int64_t h_div_sz)
{
MAC[0] = F((int64)OFX + IR1 * h_div_sz) >> 16;
MAC[0] = F((int64)OFX + IR1 * h_div_sz * (widescreen_hack) ? 0.75 : 1.00) >> 16;
XY_FIFO[3].X = Lm_G(0, MAC[0]);
MAC[0] = F((int64)OFY + IR2 * h_div_sz) >> 16;