psx - add "determine lag from GPU frames" option

This commit is contained in:
zeromus 2016-01-28 13:53:07 -06:00
parent bff12a4fdc
commit e855cb39cd
8 changed files with 73 additions and 6 deletions

View File

@ -64,6 +64,8 @@
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.cbLEC = new System.Windows.Forms.CheckBox();
this.cbGpuLag = new System.Windows.Forms.CheckBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
@ -73,6 +75,7 @@
((System.ComponentModel.ISupportInitialize)(this.NTSC_FirstLineNumeric)).BeginInit();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
this.SuspendLayout();
//
// btnCancel
@ -454,10 +457,10 @@
this.groupBox5.Controls.Add(this.cbLEC);
this.groupBox5.Location = new System.Drawing.Point(12, 306);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(299, 85);
this.groupBox5.Size = new System.Drawing.Size(238, 85);
this.groupBox5.TabIndex = 47;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "Emulation";
this.groupBox5.Text = "Emulation Sync Settings";
//
// cbLEC
//
@ -469,6 +472,28 @@
this.cbLEC.Text = "Emulate Sector Error Correction\r\n(usually unneeded; breaks some patches)";
this.cbLEC.UseVisualStyleBackColor = true;
//
// cbGpuLag
//
this.cbGpuLag.AutoSize = true;
this.cbGpuLag.Location = new System.Drawing.Point(16, 19);
this.cbGpuLag.Name = "cbGpuLag";
this.cbGpuLag.Size = new System.Drawing.Size(181, 17);
this.cbGpuLag.TabIndex = 1;
this.cbGpuLag.Text = "Determine Lag from GPU Frames";
this.cbGpuLag.UseVisualStyleBackColor = true;
//
// groupBox6
//
this.groupBox6.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox6.Controls.Add(this.cbGpuLag);
this.groupBox6.Location = new System.Drawing.Point(264, 308);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(238, 85);
this.groupBox6.TabIndex = 48;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Emulation User Settings";
//
// PSXOptions
//
this.AcceptButton = this.btnOk;
@ -476,6 +501,7 @@
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnCancel;
this.ClientSize = new System.Drawing.Size(713, 405);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
@ -501,6 +527,8 @@
this.groupBox4.PerformLayout();
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.groupBox6.PerformLayout();
this.ResumeLayout(false);
}
@ -541,5 +569,7 @@
private System.Windows.Forms.RadioButton rbBob;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.CheckBox cbLEC;
private System.Windows.Forms.CheckBox cbGpuLag;
private System.Windows.Forms.GroupBox groupBox6;
}
}

View File

@ -42,6 +42,7 @@ namespace BizHawk.Client.EmuHawk
rbClipToFramebuffer.Checked = _settings.HorizontalClipping == Octoshock.eHorizontalClipping.Framebuffer;
cbLEC.Checked = _syncSettings.EnableLEC;
cbGpuLag.Checked = _settings.GPULag;
rbWeave.Checked = _settings.DeinterlaceMode == Octoshock.eDeinterlaceMode.Weave;
rbBob.Checked = _settings.DeinterlaceMode == Octoshock.eDeinterlaceMode.Bob;
@ -98,6 +99,8 @@ namespace BizHawk.Client.EmuHawk
settings.ScanlineStart_PAL = (int)PAL_FirstLineNumeric.Value;
settings.ScanlineEnd_PAL = (int)PAL_LastLineNumeric.Value;
settings.GPULag = cbGpuLag.Checked;
syncSettings.EnableLEC = cbLEC.Checked;
}

View File

@ -716,6 +716,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
IsLagFrame = true;
if (pad1 == OctoshockDll.SHOCK_TRUE) IsLagFrame = false;
if (pad2 == OctoshockDll.SHOCK_TRUE) IsLagFrame = false;
if (_Settings.GPULag)
IsLagFrame = OctoshockDll.shock_GetGPUUnlagged(psx) != OctoshockDll.SHOCK_TRUE;
if (IsLagFrame)
LagCount++;
@ -1144,8 +1146,11 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
public class Settings
{
[DisplayName("Determine Lag from GPU Frames")]
[DefaultValue(false)]
public bool GPULag { get; set; }
[DisplayName("Resolution Mode")]
[Description("Stuff")]
[DefaultValue(eResolutionMode.PixelPro)]
public eResolutionMode ResolutionMode { get; set; }

View File

@ -289,5 +289,8 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
[DllImport(dd, CallingConvention = cc)]
public static extern int shock_SetLEC(IntPtr psx, bool enable);
[DllImport(dd, CallingConvention = cc)]
public static extern int shock_GetGPUUnlagged(IntPtr psx);
}
}

Binary file not shown.

View File

@ -44,6 +44,7 @@ enum
CH_OT = 6,
};
extern bool GpuFrameForLag;
// RunChannels(128 - whatevercounter);
//
@ -256,7 +257,11 @@ static INLINE void ChRW(const unsigned ch, const uint32 CRModeCache, uint32 *V,
case CH_GPU:
if(CRModeCache & 0x1)
{
if(DMACH[CH_GPU].ChanControl == 0x01000401)
GpuFrameForLag = true;
GPU->WriteDMA(*V);
}
else
*V = GPU->ReadDMA();
break;

View File

@ -51,6 +51,7 @@
int16 soundbuf[1024 * 1024]; //how big? big enough.
int VTBackBuffer = 0;
bool GpuFrameForLag = false;
static MDFN_Rect VTDisplayRects[2];
#include "video/Deinterlacer.h"
static bool PrevInterlaced;
@ -547,8 +548,15 @@ template<typename T, bool IsWrite, bool Access24> static INLINE void MemRW(pscpu
if(!IsWrite)
timestamp++;
if(IsWrite)
MDEC_Write(timestamp, A, V);
if (IsWrite)
{
if (A == 0x1F801820)
{
//per pcsx-rr:
GpuFrameForLag = true;
}
MDEC_Write(timestamp, A, V);
}
else
V = MDEC_Read(timestamp, A);
@ -1407,6 +1415,8 @@ EW_EXPORT s32 shock_Step(void* psx, eShockStep step)
static const int ResampleQuality = 5;
SPU->StartFrame(espec.SoundRate, ResampleQuality);
GpuFrameForLag = false;
Running = -1;
timestamp = CPU->Run(timestamp, psx_dbg_level >= PSX_DBG_BIOS_PRINT, /*psf_loader != NULL*/ false); //huh?
assert(timestamp);
@ -2725,4 +2735,11 @@ EW_EXPORT s32 shock_SetLEC(void* psx, bool enabled)
{
CDC->SetLEC(enabled);
return SHOCK_OK;
}
//whether "determine lag from GPU frames" signal is set (GPU did something considered non-lag)
//returns SHOCK_TRUE or SHOCK_FALSE
EW_EXPORT s32 shock_GetGPUUnlagged(void* psx)
{
return GpuFrameForLag ? SHOCK_TRUE : SHOCK_FALSE;
}

View File

@ -428,4 +428,8 @@ EW_EXPORT s32 shock_SetRegister_CPU(void* psx, s32 index, u32 value);
EW_EXPORT s32 shock_SetTraceCallback(void* psx, void* opaque, ShockCallback_Trace callback);
//Sets whether LEC is enabled (sector level error correction). Defaults to FALSE (disabled)
EW_EXPORT s32 shock_SetLEC(void* psx, bool enabled);
EW_EXPORT s32 shock_SetLEC(void* psx, bool enabled);
//whether "determine lag from GPU frames" signal is set (GPU did something considered non-lag)
//returns SHOCK_TRUE or SHOCK_FALSE
EW_EXPORT s32 shock_GetGPUUnlagged(void* psx);