From 2cb99f0e05d2b82912739afbe92a61edbf273a22 Mon Sep 17 00:00:00 2001 From: ramapcsx2 Date: Thu, 26 Apr 2012 17:07:36 +0000 Subject: [PATCH] Preliminary NTSC progressive scan support. The detection is based on a quickly reversed smode1 flag and needs to be done properly. The timing itself also needs reversing and has only been tested on the VP2 intro video. (That video now runs without audio / video desync when progressive scan is enabled :) ) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5179 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Counters.cpp | 28 ++++++++++++++++++++++------ pcsx2/GS.cpp | 3 ++- pcsx2/GS.h | 3 ++- plugins/GSdx/GSRenderer.cpp | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/pcsx2/Counters.cpp b/pcsx2/Counters.cpp index 415cd0b577..0a908567ac 100644 --- a/pcsx2/Counters.cpp +++ b/pcsx2/Counters.cpp @@ -209,6 +209,12 @@ static void vSyncInfoCalc( vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 u64 Scanline = Frame / scansPerFrame; u64 hBlank = Scanline / 2; u64 hRender = Scanline - hBlank; + + if ( gsRegionMode == Region_NTSC_PROGRESSIVE ) + { + hBlank /= 2; + hRender /= 2; + } info->Framerate = framesPerSecond; info->Render = (u32)(Render/10000); @@ -226,12 +232,14 @@ static void vSyncInfoCalc( vSyncTimingInfo* info, Fixed100 framesPerSecond, u32 else if( ( hBlank - info->hBlank ) >= 5000 ) info->hBlank++; // Calculate accumulative hSync rounding error per half-frame: + if ( gsRegionMode != Region_NTSC_PROGRESSIVE ) // gets off the chart in that mode { - u32 hSyncCycles = ((info->hRender + info->hBlank) * scansPerFrame) / 2; - u32 vSyncCycles = (info->Render + info->Blank); - info->hSyncError = vSyncCycles - hSyncCycles; + u32 hSyncCycles = ((info->hRender + info->hBlank) * scansPerFrame) / 2; + u32 vSyncCycles = (info->Render + info->Blank); + info->hSyncError = vSyncCycles - hSyncCycles; + //Console.Warning("%d",info->hSyncError); } - + else info->hSyncError = 0; // Note: In NTSC modes there is some small rounding error in the vsync too, // however it would take thousands of frames for it to amount to anything and // is thus not worth the effort at this time. @@ -256,17 +264,25 @@ u32 UpdateVSyncRate() framerate = EmuConfig.GS.FrameratePAL / 2; scanlines = SCANLINES_TOTAL_PAL; } - else + else if ( gsRegionMode == Region_NTSC ) { isCustom = (EmuConfig.GS.FramerateNTSC != 59.94); framerate = EmuConfig.GS.FramerateNTSC / 2; scanlines = SCANLINES_TOTAL_NTSC; } + else if ( gsRegionMode == Region_NTSC_PROGRESSIVE ) + { + isCustom = (EmuConfig.GS.FramerateNTSC != 59.94); + framerate = 30; // Cheating here to avoid a complex change to the below "vSyncInfo.Framerate != framerate" branch + scanlines = SCANLINES_TOTAL_NTSC; + } if( vSyncInfo.Framerate != framerate ) { vSyncInfoCalc( &vSyncInfo, framerate, scanlines ); - Console.WriteLn( Color_Green, "(UpdateVSyncRate) Mode Changed to %s.", ( gsRegionMode == Region_PAL ) ? "PAL" : "NTSC" ); + Console.WriteLn( Color_Green, "(UpdateVSyncRate) Mode Changed to %s.", ( gsRegionMode == Region_PAL ) ? "PAL" : + ( gsRegionMode == Region_NTSC ) ? "NTSC" : "Progressive Scan" ); + if( isCustom ) Console.Indent().WriteLn( Color_StrongGreen, "... with user configured refresh rate: %.02f Hz", framerate.ToFloat() ); } diff --git a/pcsx2/GS.cpp b/pcsx2/GS.cpp index c43c797876..b5dc488ea6 100644 --- a/pcsx2/GS.cpp +++ b/pcsx2/GS.cpp @@ -173,7 +173,8 @@ static __fi void _gsSMODEwrite( u32 mem, u32 value ) switch (mem) { case GS_SMODE1: - gsSetRegionMode( ((value & 0x6000) == 0x6000) ? Region_PAL : Region_NTSC ); + // ToDo: There's other flags determining which mode to set. The only tested one so far is the PAL / NTSC one. + gsSetRegionMode( ((value & 0x6000) == 0x6000) ? Region_PAL : (value & 0x400000) ? Region_NTSC_PROGRESSIVE : Region_NTSC ); break; case GS_SMODE2: diff --git a/pcsx2/GS.h b/pcsx2/GS.h index a9631824b3..05943c9211 100644 --- a/pcsx2/GS.h +++ b/pcsx2/GS.h @@ -220,7 +220,8 @@ struct GSRegSIGBLID enum GS_RegionMode { Region_NTSC, - Region_PAL + Region_PAL, + Region_NTSC_PROGRESSIVE }; extern GS_RegionMode gsRegionMode; diff --git a/plugins/GSdx/GSRenderer.cpp b/plugins/GSdx/GSRenderer.cpp index daf9605745..a028e33983 100644 --- a/plugins/GSdx/GSRenderer.cpp +++ b/plugins/GSdx/GSRenderer.cpp @@ -94,7 +94,7 @@ bool GSRenderer::Merge(int field) baseline = min(dr[i].top, baseline); - // printf("[%d]: %d %d %d %d, %d %d %d %d\n", i, fr[i], dr[i]); + //printf("[%d]: %d %d %d %d, %d %d %d %d\n", i, fr[i].x,fr[i].y,fr[i].z,fr[i].w , dr[i].x,dr[i].y,dr[i].z,dr[i].w); } }