From e848cbcded9c377dc16ff8bf544f5cc5485b0801 Mon Sep 17 00:00:00 2001 From: zilmar Date: Mon, 31 Dec 2012 07:56:49 +1100 Subject: [PATCH] Half life: Update if hard loop checking value --- .../N64 System/Mips/Memory Virtual Mem.cpp | 25 ++++++++++++++++--- .../N64 System/Mips/Memory Virtual Mem.h | 1 + 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp index eac713a81..407267681 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.cpp @@ -28,13 +28,15 @@ CMipsMemoryVM::CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOn m_Rom(NULL), m_RomSize(0), m_RomWrittenTo(false), - m_RomWroteValue(0) + m_RomWroteValue(0), + m_HalfLine(0), + m_HalfLineCheck(false), + m_TempValue(0) { g_Settings->RegisterChangeCB(Game_RDRamSize,this,(CSettings::SettingChangedFunc)RdramChanged); m_RDRAM = NULL; m_DMEM = NULL; m_IMEM = NULL; - m_HalfLine = 0; } CMipsMemoryVM::~CMipsMemoryVM (void) @@ -2413,12 +2415,27 @@ int CMipsMemoryVM::SW_NonMemory ( DWORD PAddr, DWORD Value ) { void CMipsMemoryVM::UpdateHalfLine (void) { - if (*g_NextTimer < 0) { + DWORD NextViTimer = g_SystemTimer->GetTimer(CSystemTimer::ViTimer); + + if (*g_NextTimer < 0) { m_HalfLine = 0; return; } - m_HalfLine = (DWORD)(*g_NextTimer / g_System->ViRefreshRate()); + m_HalfLine = (DWORD)(NextViTimer / g_System->ViRefreshRate()); m_HalfLine &= ~1; + + int check_value = (int)(m_HalfLineCheck - NextViTimer); + if (check_value > 0 && check_value < 40) + { + *g_NextTimer -= g_System->ViRefreshRate(); + if (*g_NextTimer < 0) + { + *g_NextTimer = 0 - g_System->CountPerOp(); + } + g_SystemTimer->UpdateTimers(); + } + m_HalfLineCheck = NextViTimer; + } 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 13c5690a6..bc27488d4 100644 --- a/Source/Project64/N64 System/Mips/Memory Virtual Mem.h +++ b/Source/Project64/N64 System/Mips/Memory Virtual Mem.h @@ -140,6 +140,7 @@ private: //Current Half line void UpdateHalfLine ( void ); DWORD m_HalfLine; + DWORD m_HalfLineCheck; DWORD m_TempValue; //Initilizing and reseting information about the memory system