Patterns for timers fix for VC

This commit is contained in:
Silent 2017-09-11 15:18:32 +02:00
parent c58f8ceef6
commit 94fa223e8c
3 changed files with 21 additions and 78 deletions

View file

@ -3,37 +3,25 @@
#include "Patterns.h"
float* CTimer::ms_fTimeScale;
float* CTimer::ms_fTimeStep;
float* CTimer::ms_fTimeStepNotClipped;
bool* CTimer::m_UserPause;
bool* CTimer::m_CodePause;
int* CTimer::m_snTimeInMilliseconds;
int* CTimer::m_snPreviousTimeInMilliseconds;
int* CTimer::m_snTimeInMillisecondsNonClipped;
int* CTimer::m_snTimeInMillisecondsPauseMode;
unsigned int* CTimer::m_FrameCounter;
static unsigned int suspendDepth;
static long long timerFreq;
static long long oldTime, suspendTime;
static long long cyclesTime, cyclesTimeNonClipped, cyclesTimePauseMode, cyclesPreviousTime;
float& CTimer::ms_fTimeScale = **hook::get_pattern<float*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x70 + 2 );
float& CTimer::ms_fTimeStep = **hook::get_pattern<float*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0xF3 + 2 );
bool& CTimer::m_UserPause = **hook::get_pattern<bool*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x4A + 2 );
bool& CTimer::m_CodePause = **hook::get_pattern<bool*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x67 + 2 );
int& CTimer::m_snTimeInMilliseconds = **hook::get_pattern<int*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x102 + 1 );
int& CTimer::m_snTimeInMillisecondsNonClipped = **hook::get_pattern<int*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x13B + 1 );
int& CTimer::m_snTimeInMillisecondsPauseMode = **hook::get_pattern<int*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 0x9C + 1 );
static uint32_t& timerFrequency = **hook::get_pattern<uint32_t*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", -7 );
static LARGE_INTEGER& prevTimer = **hook::get_pattern<LARGE_INTEGER*>( "83 E4 F8 89 44 24 08 C7 44 24 0C 00 00 00 00 DF 6C 24 08", 64 );
extern void (__stdcall *AudioResetTimers)(unsigned int);
extern bool* bSnapShotActive;
void CTimer::Update_SilentPatch()
{
LARGE_INTEGER perfCount;
QueryPerformanceCounter( &perfCount );
double diff = double(perfCount.QuadPart - prevTimer.QuadPart);
if ( !*m_UserPause && !*m_CodePause ) diff *= *ms_fTimeScale;
if ( !m_UserPause && !m_CodePause ) diff *= ms_fTimeScale;
prevTimer = perfCount;
@ -43,15 +31,15 @@ void CTimer::Update_SilentPatch()
DeltaRemainder = modf( delta + DeltaRemainder, &deltaIntegral );
const int deltaInteger = int(deltaIntegral);
*m_snTimeInMillisecondsPauseMode += deltaInteger;
if ( !*m_UserPause && !*m_CodePause )
m_snTimeInMillisecondsPauseMode += deltaInteger;
if ( !m_UserPause && !m_CodePause )
{
*m_snTimeInMillisecondsNonClipped += deltaInteger;
*m_snTimeInMilliseconds += deltaInteger;
*ms_fTimeStep = float(delta * 0.05);
m_snTimeInMillisecondsNonClipped += deltaInteger;
m_snTimeInMilliseconds += deltaInteger;
ms_fTimeStep = float(delta * 0.05);
}
else
{
*ms_fTimeStep = 0.0f;
ms_fTimeStep = 0.0f;
}
}

View file

@ -4,16 +4,13 @@
class CTimer
{
public:
static float* ms_fTimeScale;
static float* ms_fTimeStep;
static float* ms_fTimeStepNotClipped;
static bool* m_UserPause;
static bool* m_CodePause;
static int* m_snTimeInMilliseconds;
static int* m_snPreviousTimeInMilliseconds;
static int* m_snTimeInMillisecondsNonClipped;
static int* m_snTimeInMillisecondsPauseMode;
static unsigned int* m_FrameCounter;
static float& ms_fTimeScale;
static float& ms_fTimeStep;
static bool& m_UserPause;
static bool& m_CodePause;
static int& m_snTimeInMilliseconds;
static int& m_snTimeInMillisecondsNonClipped;
static int& m_snTimeInMillisecondsPauseMode;
public:
static void Update_SilentPatch();

View file

@ -23,11 +23,8 @@ struct RwV2d
float y; /**< Y value */
};
bool* bSnapShotActive;
static const void* RosieAudioFix_JumpBack;
void (__stdcall *AudioResetTimers)(unsigned int);
static void (*PrintString)(float,float,const wchar_t*);
static RsGlobalType* RsGlobal;
@ -218,25 +215,12 @@ void Patch_VC_10(const RECT& desktop)
{
using namespace Memory;
AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F98D0;
PrintString = (void(*)(float,float,const wchar_t*))0x551040;
bSnapShotActive = *(bool**)0x4D1239;
RsGlobal = *(RsGlobalType**)0x602D32;
RosieAudioFix_JumpBack = (void*)0x42BFFE;
SubtitlesShadowFix_JumpBack = (void*)0x551701;
CTimer::ms_fTimeScale = *(float**)0x453D38;
CTimer::ms_fTimeStep = *(float**)0x41A318;
CTimer::ms_fTimeStepNotClipped = *(float**)0x40605B;
CTimer::m_UserPause = *(bool**)0x4D0F91;
CTimer::m_CodePause = *(bool**)0x4D0FAE;
CTimer::m_snTimeInMilliseconds = *(int**)0x418CFC;
CTimer::m_snPreviousTimeInMilliseconds = *(int**)0x41BB3A;
CTimer::m_snTimeInMillisecondsNonClipped = *(int**)0x4D1081;
CTimer::m_snTimeInMillisecondsPauseMode = *(int**)0x4D0FE2;
CTimer::m_FrameCounter = *(unsigned int**)0x4D12CF;
Patch<BYTE>(0x43E983, 16);
Patch<BYTE>(0x43EC03, 16);
Patch<BYTE>(0x43EECB, 16);
@ -361,25 +345,12 @@ void Patch_VC_11(const RECT& desktop)
{
using namespace Memory;
AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F98F0;
PrintString = (void(*)(float,float,const wchar_t*))0x551060;
bSnapShotActive = *(bool**)0x4D1259;
RsGlobal = *(RsGlobalType**)0x602D12;
RosieAudioFix_JumpBack = (void*)0x42BFFE;
SubtitlesShadowFix_JumpBack = (void*)0x551721;
CTimer::ms_fTimeScale = *(float**)0x453D38;
CTimer::ms_fTimeStep = *(float**)0x41A318;
CTimer::ms_fTimeStepNotClipped = *(float**)0x40605B;
CTimer::m_UserPause = *(bool**)0x4D0FB1;
CTimer::m_CodePause = *(bool**)0x4D0FCE;
CTimer::m_snTimeInMilliseconds = *(int**)0x418CFC;
CTimer::m_snPreviousTimeInMilliseconds = *(int**)0x41BB3A;
CTimer::m_snTimeInMillisecondsNonClipped = *(int**)0x4D10A1;
CTimer::m_snTimeInMillisecondsPauseMode = *(int**)0x4D1002;
CTimer::m_FrameCounter = *(unsigned int**)0x4D12EF;
Patch<BYTE>(0x43E983, 16);
Patch<BYTE>(0x43EC03, 16);
Patch<BYTE>(0x43EECB, 16);
@ -495,25 +466,12 @@ void Patch_VC_Steam(const RECT& desktop)
{
using namespace Memory;
AudioResetTimers = (void(__stdcall*)(unsigned int))0x5F9530;
PrintString = (void(*)(float,float,const wchar_t*))0x550F30;
bSnapShotActive = *(bool**)0x4D10F9;
RsGlobal = *(RsGlobalType**)0x602952;
RosieAudioFix_JumpBack = (void*)0x42BFCE;
SubtitlesShadowFix_JumpBack = (void*)0x5515F1;
CTimer::ms_fTimeScale = *(float**)0x453C18;
CTimer::ms_fTimeStep = *(float**)0x41A318;
CTimer::ms_fTimeStepNotClipped = *(float**)0x40605B;
CTimer::m_UserPause = *(bool**)0x4D0E51;
CTimer::m_CodePause = *(bool**)0x4D0E6E;
CTimer::m_snTimeInMilliseconds = *(int**)0x418CFC;
CTimer::m_snPreviousTimeInMilliseconds = *(int**)0x41BB3A;
CTimer::m_snTimeInMillisecondsNonClipped = *(int**)0x4D0F41;
CTimer::m_snTimeInMillisecondsPauseMode = *(int**)0x4D0EA2;
CTimer::m_FrameCounter = *(unsigned int**)0x4D118F;
Patch<BYTE>(0x43E8F3, 16);
Patch<BYTE>(0x43EB73, 16);
Patch<BYTE>(0x43EE3B, 16);