Automatic aspect ratio switch during FMV playback

Updated to bypass ini setting for automatic aspect ratio switch.
This commit is contained in:
FlatOutPS2 2016-04-26 20:25:21 +02:00
parent df70b8bb0e
commit 6defe6e07d
8 changed files with 67 additions and 26 deletions

View File

@ -25,6 +25,7 @@
#include "Gif.h" #include "Gif.h"
#include "Vif_Dma.h" #include "Vif_Dma.h"
#include <limits.h> #include <limits.h>
#include "AppConfig.h"
#include "Utilities/MemsetFast.inl" #include "Utilities/MemsetFast.inl"
@ -50,8 +51,8 @@ int coded_block_pattern = 0;
u8 indx4[16*16/2]; u8 indx4[16*16/2];
uint eecount_on_last_vdec = 0; uint eecount_on_last_vdec = 0;
bool FMVstarted = 0; bool FMVstarted = false;
bool EnableFMV = 0; bool EnableFMV = false;
void tIPU_cmd::clear() void tIPU_cmd::clear()
{ {
@ -400,12 +401,12 @@ static __ri void ipuBDEC(tIPU_CMD_BDEC bdec)
static __fi bool ipuVDEC(u32 val) static __fi bool ipuVDEC(u32 val)
{ {
if (EmuConfig.Gamefixes.FMVinSoftwareHack) { if (EmuConfig.Gamefixes.FMVinSoftwareHack || g_Conf->GSWindow.IsToggleAspectRatioSwitch) {
static int count = 0; static int count = 0;
if (count++ > 5) { if (count++ > 5) {
if (FMVstarted == 0) { if (!FMVstarted) {
EnableFMV = 1; EnableFMV = true;
FMVstarted = 1; FMVstarted = true;
} }
count = 0; count = 0;
} }

View File

@ -846,6 +846,7 @@ AppConfig::GSWindowOptions::GSWindowOptions()
IsFullscreen = false; IsFullscreen = false;
IsToggleFullscreenOnDoubleClick = true; IsToggleFullscreenOnDoubleClick = true;
IsToggleAspectRatioSwitch = false;
} }
void AppConfig::GSWindowOptions::SanityCheck() void AppConfig::GSWindowOptions::SanityCheck()
@ -883,6 +884,7 @@ void AppConfig::GSWindowOptions::LoadSave( IniInterface& ini )
IniEntry( IsFullscreen ); IniEntry( IsFullscreen );
IniEntry( IsToggleFullscreenOnDoubleClick ); IniEntry( IsToggleFullscreenOnDoubleClick );
IniEntry( IsToggleAspectRatioSwitch );
static const wxChar* AspectRatioNames[] = static const wxChar* AspectRatioNames[] =
{ {

View File

@ -220,6 +220,7 @@ public:
bool IsFullscreen; bool IsFullscreen;
bool IsToggleFullscreenOnDoubleClick; bool IsToggleFullscreenOnDoubleClick;
bool IsToggleAspectRatioSwitch;
GSWindowOptions(); GSWindowOptions();

View File

@ -73,6 +73,9 @@ DEFINE_EVENT_TYPE( pxEvt_ThreadTaskTimeout_SysExec );
std::unique_ptr<AppConfig> g_Conf; std::unique_ptr<AppConfig> g_Conf;
AspectRatioType iniAR;
bool switchAR;
static bool HandlePluginError( BaseException& ex ) static bool HandlePluginError( BaseException& ex )
{ {
if (!pxDialogExists(L"Dialog:" + Dialogs::ComponentsConfigDialog::GetNameStatic())) if (!pxDialogExists(L"Dialog:" + Dialogs::ComponentsConfigDialog::GetNameStatic()))
@ -529,12 +532,26 @@ extern bool FMVstarted;
extern bool renderswitch; extern bool renderswitch;
extern bool EnableFMV; extern bool EnableFMV;
void DoFmvSwitch() void DoFmvSwitch(bool on)
{ {
if (g_Conf->GSWindow.IsToggleAspectRatioSwitch) {
if (on) {
switchAR = true;
iniAR = g_Conf->GSWindow.AspectRatio;
} else {
switchAR = false;
}
if (GSFrame* gsFrame = wxGetApp().GetGsFramePtr())
if (GSPanel* viewport = gsFrame->GetViewport())
viewport->DoResize();
}
if (EmuConfig.Gamefixes.FMVinSoftwareHack) {
ScopedCoreThreadPause paused_core(new SysExecEvent_SaveSinglePlugin(PluginId_GS)); ScopedCoreThreadPause paused_core(new SysExecEvent_SaveSinglePlugin(PluginId_GS));
renderswitch = !renderswitch; renderswitch = !renderswitch;
paused_core.AllowResume(); paused_core.AllowResume();
} }
}
void Pcsx2App::LogicalVsync() void Pcsx2App::LogicalVsync()
{ {
@ -546,19 +563,19 @@ void Pcsx2App::LogicalVsync()
FpsManager.DoFrame(); FpsManager.DoFrame();
if (EmuConfig.Gamefixes.FMVinSoftwareHack) { if (EmuConfig.Gamefixes.FMVinSoftwareHack || g_Conf->GSWindow.IsToggleAspectRatioSwitch) {
if (EnableFMV == 1) { if (EnableFMV) {
Console.Warning("FMV on"); DevCon.Warning("FMV on");
DoFmvSwitch(); DoFmvSwitch(true);
EnableFMV = 0; EnableFMV = false;
} }
if (FMVstarted) { if (FMVstarted) {
int diff = cpuRegs.cycle - eecount_on_last_vdec; int diff = cpuRegs.cycle - eecount_on_last_vdec;
if (diff > 60000000 ) { if (diff > 60000000 ) {
Console.Warning("FMV off"); DevCon.Warning("FMV off");
DoFmvSwitch(); DoFmvSwitch(false);
FMVstarted = 0; FMVstarted = false;
} }
} }
} }

View File

@ -155,11 +155,22 @@ void GSPanel::DoResize()
double clientAr = (double)client.GetWidth()/(double)client.GetHeight(); double clientAr = (double)client.GetWidth()/(double)client.GetHeight();
extern AspectRatioType iniAR;
extern bool switchAR;
double targetAr = clientAr; double targetAr = clientAr;
if (g_Conf->GSWindow.AspectRatio != iniAR) {
switchAR = false;
}
if (!switchAR) {
if (g_Conf->GSWindow.AspectRatio == AspectRatio_4_3) if (g_Conf->GSWindow.AspectRatio == AspectRatio_4_3)
targetAr = 4.0 / 3.0; targetAr = 4.0 / 3.0;
else if (g_Conf->GSWindow.AspectRatio == AspectRatio_16_9) else if (g_Conf->GSWindow.AspectRatio == AspectRatio_16_9)
targetAr = 16.0 / 9.0; targetAr = 16.0 / 9.0;
} else {
targetAr = 4.0 / 3.0;
}
double arr = targetAr / clientAr; double arr = targetAr / clientAr;

View File

@ -33,6 +33,8 @@
// renderswitch - tells GSdx to go into dx9 sw if "renderswitch" is set. // renderswitch - tells GSdx to go into dx9 sw if "renderswitch" is set.
bool renderswitch = false; bool renderswitch = false;
extern bool switchAR;
static int g_Pcsx2Recording = 0; // true 1 if recording video and sound static int g_Pcsx2Recording = 0; // true 1 if recording video and sound
@ -175,6 +177,8 @@ namespace Implementations
{ {
AspectRatioType& art = g_Conf->GSWindow.AspectRatio; AspectRatioType& art = g_Conf->GSWindow.AspectRatio;
wxString arts(L"Not modified"); wxString arts(L"Not modified");
if (art == AspectRatio_Stretch && switchAR) //avoids a double 4:3 when coming from FMV aspect ratio switch
art = AspectRatio_4_3;
switch( art ) switch( art )
{ {
case AspectRatio_Stretch: art = AspectRatio_4_3; arts = L"AspectRatio_4_3"; break; case AspectRatio_Stretch: art = AspectRatio_4_3; arts = L"AspectRatio_4_3"; break;

View File

@ -286,6 +286,7 @@ namespace Panels
pxCheckBox* m_check_HideMouse; pxCheckBox* m_check_HideMouse;
pxCheckBox* m_check_DclickFullscreen; pxCheckBox* m_check_DclickFullscreen;
pxCheckBox* m_check_AspectRatioSwitch;
wxTextCtrl* m_text_WindowWidth; wxTextCtrl* m_text_WindowWidth;
wxTextCtrl* m_text_WindowHeight; wxTextCtrl* m_text_WindowHeight;

View File

@ -49,6 +49,7 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel( wxWindow* parent )
m_check_Fullscreen = new pxCheckBox( this, _("Default to fullscreen mode on open") ); m_check_Fullscreen = new pxCheckBox( this, _("Default to fullscreen mode on open") );
m_check_VsyncEnable = new pxCheckBox( this, _("Wait for Vsync on refresh") ); m_check_VsyncEnable = new pxCheckBox( this, _("Wait for Vsync on refresh") );
m_check_DclickFullscreen = new pxCheckBox( this, _("Double-click toggles fullscreen mode") ); m_check_DclickFullscreen = new pxCheckBox( this, _("Double-click toggles fullscreen mode") );
m_check_AspectRatioSwitch = new pxCheckBox(this, _("Switch to 4:3 aspect ratio when an FMV plays"));
//m_check_ExclusiveFS = new pxCheckBox( this, _("Use exclusive fullscreen mode (if available)") ); //m_check_ExclusiveFS = new pxCheckBox( this, _("Use exclusive fullscreen mode (if available)") );
m_text_Zoom->SetToolTip( pxEt( L"Zoom = 100: Fit the entire image to the window without any cropping.\nAbove/Below 100: Zoom In/Out\n0: Automatic-Zoom-In untill the black-bars are gone (Aspect ratio is kept, some of the image goes out of screen).\n NOTE: Some games draw their own black-bars, which will not be removed with '0'.\n\nKeyboard: CTRL + NUMPAD-PLUS: Zoom-In, CTRL + NUMPAD-MINUS: Zoom-Out, CTRL + NUMPAD-*: Toggle 100/0" m_text_Zoom->SetToolTip( pxEt( L"Zoom = 100: Fit the entire image to the window without any cropping.\nAbove/Below 100: Zoom In/Out\n0: Automatic-Zoom-In untill the black-bars are gone (Aspect ratio is kept, some of the image goes out of screen).\n NOTE: Some games draw their own black-bars, which will not be removed with '0'.\n\nKeyboard: CTRL + NUMPAD-PLUS: Zoom-In, CTRL + NUMPAD-MINUS: Zoom-Out, CTRL + NUMPAD-*: Toggle 100/0"
@ -99,6 +100,7 @@ Panels::GSWindowSettingsPanel::GSWindowSettingsPanel( wxWindow* parent )
*this += m_check_Fullscreen; *this += m_check_Fullscreen;
*this += m_check_DclickFullscreen; *this += m_check_DclickFullscreen;
*this += m_check_AspectRatioSwitch;
//*this += m_check_ExclusiveFS; //*this += m_check_ExclusiveFS;
*this += new wxStaticLine( this ) | StdExpand(); *this += new wxStaticLine( this ) | StdExpand();
@ -132,6 +134,7 @@ void Panels::GSWindowSettingsPanel::ApplyConfigToGui( AppConfig& configToApply,
m_text_Zoom ->ChangeValue( conf.Zoom.ToString() ); m_text_Zoom ->ChangeValue( conf.Zoom.ToString() );
m_check_DclickFullscreen ->SetValue( conf.IsToggleFullscreenOnDoubleClick ); m_check_DclickFullscreen ->SetValue( conf.IsToggleFullscreenOnDoubleClick );
m_check_AspectRatioSwitch->SetValue( conf.IsToggleAspectRatioSwitch );
m_text_WindowWidth ->ChangeValue( wxsFormat( L"%d", conf.WindowSize.GetWidth() ) ); m_text_WindowWidth ->ChangeValue( wxsFormat( L"%d", conf.WindowSize.GetWidth() ) );
m_text_WindowHeight ->ChangeValue( wxsFormat( L"%d", conf.WindowSize.GetHeight() ) ); m_text_WindowHeight ->ChangeValue( wxsFormat( L"%d", conf.WindowSize.GetHeight() ) );
@ -157,6 +160,7 @@ void Panels::GSWindowSettingsPanel::Apply()
gsconf.VsyncEnable = m_check_VsyncEnable->GetValue(); gsconf.VsyncEnable = m_check_VsyncEnable->GetValue();
appconf.IsToggleFullscreenOnDoubleClick = m_check_DclickFullscreen->GetValue(); appconf.IsToggleFullscreenOnDoubleClick = m_check_DclickFullscreen->GetValue();
appconf.IsToggleAspectRatioSwitch = m_check_AspectRatioSwitch->GetValue();
long xr, yr = 1; long xr, yr = 1;