From d1ec130d7f3329239b6b43889c01e061fc2f33d4 Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 5 Aug 2014 15:27:04 +0200 Subject: [PATCH] Ready to support multiple EXEs --- SAFix/PNGFile.cpp | 1 - SAFix/SilentPatchSA.cpp | 77 ++++++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/SAFix/PNGFile.cpp b/SAFix/PNGFile.cpp index ffc4027..41a9e2d 100644 --- a/SAFix/PNGFile.cpp +++ b/SAFix/PNGFile.cpp @@ -27,7 +27,6 @@ RwTexture* CPNGFile::ReadFromMemory(const void* pMemory, unsigned int nLen) static BYTE* pMem = AddressByVersion(0x7CF9CA, 0, 0); RwTexture* pTexture = nullptr; - // TOOO: EXEs MemoryVP::Patch(pMem, rwSTREAMMEMORY); RwMemory PNGMemory; diff --git a/SAFix/SilentPatchSA.cpp b/SAFix/SilentPatchSA.cpp index 7933699..858227f 100644 --- a/SAFix/SilentPatchSA.cpp +++ b/SAFix/SilentPatchSA.cpp @@ -9,34 +9,51 @@ #include "PNGFile.h" // RW wrappers -// TODO: Multiple EXEs -WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { WRAPARG(frame); WRAPARG(callBack); WRAPARG(data); EAXJMP(0x7F1200); } -WRAPPER RpClump* RpClumpForAllAtomics(RpClump* clump, RpAtomicCallBack callback, void* pData) { WRAPARG(clump); WRAPARG(callback); WRAPARG(pData); EAXJMP(0x749B70); } -WRAPPER RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData) { WRAPARG(geometry); WRAPARG(fpCallBack); WRAPARG(pData); EAXJMP(0x74C790); } -WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { WRAPARG(atomic); EAXJMP(0x7491C0); } -WRAPPER RwImage* RtPNGImageRead(const RwChar* imageName) { WRAPARG(imageName); EAXJMP(0x7CF9B0); } -WRAPPER RwTexture* RwTextureCreate(RwRaster* raster) { WRAPARG(raster); EAXJMP(0x7F37C0); } -WRAPPER RwRaster* RwRasterCreate(RwInt32 width, RwInt32 height, RwInt32 depth, RwInt32 flags) { WRAPARG(width); WRAPARG(height); WRAPARG(depth); WRAPARG(flags); EAXJMP(0x7FB230); } -WRAPPER RwRaster* RwRasterSetFromImage(RwRaster* raster, RwImage* image) { WRAPARG(raster); WRAPARG(image); EAXJMP(0x804290); } -WRAPPER RwBool RwImageDestroy(RwImage* image) { WRAPARG(image); EAXJMP(0x802740); } -WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { WRAPARG(ipImage); WRAPARG(nRasterType); WRAPARG(npWidth); WRAPARG(npHeight); WRAPARG(npDepth); WRAPARG(npFormat); EAXJMP(0x8042C0); } -WRAPPER RpMaterial *RpMaterialSetTexture(RpMaterial *material, RwTexture *texture) { EAXJMP(0x74DBC0); } -WRAPPER RwBool RwTextureDestroy(RwTexture* texture) { EAXJMP(0x7F3820); } -WRAPPER void RwD3D9SetRenderState(RwUInt32 state, RwUInt32 value) { WRAPARG(state); WRAPARG(value); EAXJMP(0x7FC2D0); } -WRAPPER void _rwD3D9SetVertexShader(void *shader) { EAXJMP(0x7F9FB0); } -WRAPPER RwBool RwD3D9CreateVertexShader(const RwUInt32 *function, void **shader) { EAXJMP(0x7FAC60); } -WRAPPER void RwD3D9DeleteVertexShader(void *shader) { EAXJMP(0x7FAC90); } -WRAPPER void _rwD3D9VSGetComposedTransformMatrix(void *transformMatrix) { EAXJMP(0x7646E0); } -WRAPPER void _rwD3D9VSSetActiveWorldMatrix(const RwMatrix *worldMatrix) { EAXJMP(0x764650); } -WRAPPER RwMatrix* RwFrameGetLTM(RwFrame* frame) { EAXJMP(0x7F0990); } +static void* varRwFrameForAllObjects = AddressByVersion(0x7F1200, 0, 0); +WRAPPER RwFrame* RwFrameForAllObjects(RwFrame* frame, RwObjectCallBack callBack, void* data) { WRAPARG(frame); WRAPARG(callBack); WRAPARG(data); VARJMP(varRwFrameForAllObjects); } +static void* varRpClumpForAllAtomics = AddressByVersion(0x749B70, 0, 0); +WRAPPER RpClump* RpClumpForAllAtomics(RpClump* clump, RpAtomicCallBack callback, void* pData) { WRAPARG(clump); WRAPARG(callback); WRAPARG(pData); VARJMP(varRpClumpForAllAtomics); } +static void* varRpGeometryForAllMaterials = AddressByVersion(0x74C790, 0, 0); +WRAPPER RpGeometry* RpGeometryForAllMaterials(RpGeometry* geometry, RpMaterialCallBack fpCallBack, void* pData) { WRAPARG(geometry); WRAPARG(fpCallBack); WRAPARG(pData); VARJMP(varRpGeometryForAllMaterials); } +static void* varAtomicDefaultRenderCallBack = AddressByVersion(0x7491C0, 0, 0); +WRAPPER RpAtomic* AtomicDefaultRenderCallBack(RpAtomic* atomic) { WRAPARG(atomic); VARJMP(varAtomicDefaultRenderCallBack); } +static void* varRtPNGImageRead = AddressByVersion(0x7CF9B0, 0, 0); +WRAPPER RwImage* RtPNGImageRead(const RwChar* imageName) { WRAPARG(imageName); VARJMP(varRtPNGImageRead); } +static void* varRwTextureCreate = AddressByVersion(0x7F37C0, 0, 0); +WRAPPER RwTexture* RwTextureCreate(RwRaster* raster) { WRAPARG(raster); VARJMP(varRwTextureCreate); } +static void* varRwRasterCreate = AddressByVersion(0x7FB230, 0, 0); +WRAPPER RwRaster* RwRasterCreate(RwInt32 width, RwInt32 height, RwInt32 depth, RwInt32 flags) { WRAPARG(width); WRAPARG(height); WRAPARG(depth); WRAPARG(flags); VARJMP(varRwRasterCreate); } +static void* varRwRasterSetFromImage = AddressByVersion(0x804290, 0, 0); +WRAPPER RwRaster* RwRasterSetFromImage(RwRaster* raster, RwImage* image) { WRAPARG(raster); WRAPARG(image); VARJMP(varRwRasterSetFromImage); } +static void* varRwImageDestroy = AddressByVersion(0x802740, 0, 0); +WRAPPER RwBool RwImageDestroy(RwImage* image) { WRAPARG(image); VARJMP(varRwImageDestroy); } +static void* varRwImageFindRasterFormat = AddressByVersion(0x8042C0, 0, 0); +WRAPPER RwImage* RwImageFindRasterFormat(RwImage* ipImage, RwInt32 nRasterType, RwInt32* npWidth, RwInt32* npHeight, RwInt32* npDepth, RwInt32* npFormat) { WRAPARG(ipImage); WRAPARG(nRasterType); WRAPARG(npWidth); WRAPARG(npHeight); WRAPARG(npDepth); WRAPARG(npFormat); VARJMP(varRwImageFindRasterFormat); } +static void* varRpMaterialSetTexture = AddressByVersion(0x74DBC0, 0, 0); +WRAPPER RpMaterial *RpMaterialSetTexture(RpMaterial *material, RwTexture *texture) { VARJMP(varRpMaterialSetTexture); } +static void* varRwD3D9SetRenderState = AddressByVersion(0x7FC2D0, 0, 0); +WRAPPER void RwD3D9SetRenderState(RwUInt32 state, RwUInt32 value) { WRAPARG(state); WRAPARG(value); VARJMP(varRwD3D9SetRenderState); } +static void* var_rwD3D9SetVertexShader = AddressByVersion(0x7F9FB0, 0, 0); +WRAPPER void _rwD3D9SetVertexShader(void *shader) { VARJMP(var_rwD3D9SetVertexShader); } +static void* varRwD3D9CreateVertexShader = AddressByVersion(0x7FAC60, 0, 0); +WRAPPER RwBool RwD3D9CreateVertexShader(const RwUInt32 *function, void **shader) { VARJMP(varRwD3D9CreateVertexShader); } +static void* varRwD3D9DeleteVertexShader = AddressByVersion(0x7FAC90, 0, 0); +WRAPPER void RwD3D9DeleteVertexShader(void *shader) { VARJMP(varRwD3D9DeleteVertexShader); } +static void* var_rwD3D9VSGetComposedTransformMatrix = AddressByVersion(0x7646E0, 0, 0); +WRAPPER void _rwD3D9VSGetComposedTransformMatrix(void *transformMatrix) { VARJMP(var_rwD3D9VSGetComposedTransformMatrix); } +static void* var_rwD3D9VSSetActiveWorldMatrix = AddressByVersion(0x764650, 0, 0); +WRAPPER void _rwD3D9VSSetActiveWorldMatrix(const RwMatrix *worldMatrix) { VARJMP(var_rwD3D9VSSetActiveWorldMatrix); } +static void* varRwFrameGetLTM = AddressByVersion(0x7F0990, 0, 0); +WRAPPER RwMatrix* RwFrameGetLTM(RwFrame* frame) { VARJMP(varRwFrameGetLTM); } +static void* var_rwD3D9SetVertexShaderConstant = AddressByVersion(0x7FACA0, 0, 0); WRAPPER void _rwD3D9SetVertexShaderConstant(RwUInt32 registerAddress, const void *constantData, - RwUInt32 constantCount) { EAXJMP(0x7FACA0); } - + RwUInt32 constantCount) { VARJMP(var_rwD3D9SetVertexShaderConstant); } +static void* var_rpD3D9VertexDeclarationInstColor = AddressByVersion(0x754AE0, 0, 0); WRAPPER RwBool _rpD3D9VertexDeclarationInstColor(RwUInt8 *mem, const RwRGBA *color, RwInt32 numVerts, - RwUInt32 stride) { EAXJMP(0x754AE0); } + RwUInt32 stride) { VARJMP(var_rpD3D9VertexDeclarationInstColor); } // Other wrappers void (*GTAdelete)(void*) = AddressByVersion(0x82413F, 0, 0); @@ -55,6 +72,7 @@ static BOOL (*IsAlreadyRunning)(); static void (*TheScriptsLoad)(); static bool (*InitialiseRenderWare)(); static void (*ShutdownRenderWare)(); +static void (*DoSunAndMoon)(); static void (*sub_5DA6A0)(void*, void*, void*, void*); @@ -85,6 +103,7 @@ CLinkListSA& m_alphaList = **AddressByVersion(0x6FC5B0, &fSunMult); + Patch(0x6FC5AA, &fSunFarClip); //Patch(0x6FB172, 0x0BEB); //Patch(0x6FB1A7, 8);