Reduce stencil shadows memory usage

This commit is contained in:
Silent 2016-04-24 22:00:51 +02:00
parent 27d80800a0
commit 181f492a03

View file

@ -863,6 +863,20 @@ void UpdateEscalators()
} }
static char** pStencilShadowsPad = *AddressByVersion<char***>(0x70FC4F, 0, 0);
void StencilShadowAlloc( )
{
static char* pMemory = nullptr;
if ( pMemory == nullptr )
{
pMemory = static_cast<char*>( orgNewAlloc( 3 * 0x6000 ) );
pStencilShadowsPad[0] = pMemory;
pStencilShadowsPad[1] = pMemory+0x6000;
pStencilShadowsPad[2] = pMemory+(2*0x6000);
}
}
#include <xnamath.h> #include <xnamath.h>
static void* pNVCShader = nullptr; static void* pNVCShader = nullptr;
@ -2920,6 +2934,13 @@ void Patch_SA_10()
InjectHook(0x71791F, &CEscalator::SwitchOffNoRemove); InjectHook(0x71791F, &CEscalator::SwitchOffNoRemove);
// Don't allocate constant memory for stencil shadows every frame
InjectHook(0x711DD5, StencilShadowAlloc, PATCH_CALL);
Nop(0x711E0D, 3);
Patch<WORD>(0x711DDA, 0x2CEB);
Patch<DWORD>(0x711E5F, 0x90C35D5F); // pop edi, pop ebp, ret
// Fixed police scanner names // Fixed police scanner names
char* pScannerNames = *(char**)0x4E72D4; char* pScannerNames = *(char**)0x4E72D4;