From 7345ecd97e131907d2d1ce6de9438dcd60793d6c Mon Sep 17 00:00:00 2001 From: zilmar Date: Sat, 7 Feb 2015 10:19:49 +1100 Subject: [PATCH] basic timing support for VI_V_CURRENT_LINE_REG alternating scan fields by cxd4 --- Source/Project64/N64 System/Mips/Memory Class.h | 3 ++- .../N64 System/Mips/Memory Virtual Mem.cpp | 13 +++++++++---- .../Project64/N64 System/Mips/Memory Virtual Mem.h | 2 ++ Source/Project64/N64 System/N64 Class.cpp | 2 ++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Memory Class.h b/Source/Project64/N64 System/Mips/Memory Class.h index 9994eb8e2..e10dc7302 100644 --- a/Source/Project64/N64 System/Mips/Memory Class.h +++ b/Source/Project64/N64 System/Mips/Memory Class.h @@ -48,7 +48,8 @@ public: virtual bool ValidVaddr ( DWORD VAddr ) const = 0; virtual int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer ) = 0; - + virtual void UpdateFieldSerration ( unsigned int interlaced ) = 0; + //Protect the Memory from being written to virtual void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0; virtual void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ) = 0; diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index f6335c9ba..2249b13de 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -31,6 +31,7 @@ CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOn m_RomWroteValue(0), m_HalfLine(0), m_HalfLineCheck(false), + m_FieldSerration(0), m_TempValue(0) { g_Settings->RegisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged); @@ -2633,8 +2634,6 @@ void CMipsMemoryVM::UpdateHalfLine (void) m_HalfLine = 0; return; } - m_HalfLine = (DWORD)(NextViTimer / g_System->ViRefreshRate()); - m_HalfLine &= ~1; int check_value = (int)(m_HalfLineCheck - NextViTimer); if (check_value > 0 && check_value < 40) @@ -2646,11 +2645,17 @@ void CMipsMemoryVM::UpdateHalfLine (void) } g_SystemTimer->UpdateTimers(); NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); - m_HalfLine = (DWORD)(NextViTimer / g_System->ViRefreshRate()); - m_HalfLine &= ~1; } + m_HalfLine = (DWORD)(NextViTimer / g_System->ViRefreshRate()); + m_HalfLine &= ~1; + m_HalfLine |= m_FieldSerration; m_HalfLineCheck = NextViTimer; +} +void CMipsMemoryVM::UpdateFieldSerration (unsigned int interlaced) +{ + m_FieldSerration ^= 1; + m_FieldSerration &= interlaced; } void CMipsMemoryVM::ProtectMemory( DWORD StartVaddr, DWORD EndVaddr ) diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h index 9e1f30ede..07aeafe39 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -57,6 +57,7 @@ public: BOOL SD_PAddr ( DWORD PAddr, QWORD Value ); int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer ); + void UpdateFieldSerration (unsigned int interlaced); //Protect the Memory from being written to void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr ); @@ -156,6 +157,7 @@ private: void UpdateHalfLine ( void ); DWORD m_HalfLine; DWORD m_HalfLineCheck; + DWORD m_FieldSerration; DWORD m_TempValue; //Initilizing and reseting information about the memory system diff --git a/Source/Project64/N64 System/N64 Class.cpp b/Source/Project64/N64 System/N64 Class.cpp index 5e4705fd9..1399672ba 100644 --- a/Source/Project64/N64 System/N64 Class.cpp +++ b/Source/Project64/N64 System/N64 Class.cpp @@ -1797,6 +1797,8 @@ void CN64System::RefreshScreen ( void ) { WriteTrace(TraceError,__FUNCTION__ ": Exception caught"); } + g_MMU->UpdateFieldSerration((m_Reg.VI_STATUS_REG & 0x40) != 0); + if ((bBasicMode() || bLimitFPS() ) && !bSyncToAudio()) { if (bShowCPUPer()) { m_CPU_Usage.StartTimer(Timer_Idel); } DWORD FrameRate;