Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <stdio.h>
- #include <patch\CPatch.h>
- #include <game_sa\RenderWare.h>
- #define NativeTexRead(stream, pTex) ((bool (__cdecl *)(int, RwTexture **))0x63EFE0)(stream, pTex)
- #define RwRasterGetNumLevels(raster) ((signed int (__cdecl *)(RwRaster *))0x655420)(raster)
- #pragma pack(push, 1)
- struct TextureRasterNativeStream
- {
- int rasterFormat;
- int d3d9Format;
- unsigned __int16 width;
- unsigned __int16 height;
- unsigned __int8 stride;
- char numLevels;
- unsigned __int8 rasterType;
- char compressionType;
- };
- #pragma pack(pop)
- TextureRasterNativeStream texInfo;
- #define StreamRead(stream, pInfo, len) ((bool (__cdecl *)(int, TextureRasterNativeStream *, unsigned int))0x6454B0)(stream, pInfo, len)
- unsigned int ReadTextureInfo(int stream, TextureRasterNativeStream *info, unsigned int len)
- {
- unsigned int result = StreamRead(stream, info, len);
- memcpy(&texInfo, info, sizeof(TextureRasterNativeStream));
- return result;
- }
- #define d3dCreateTexture(width, height, numLevels, format, pTexture) ((signed int (__stdcall *)(unsigned int, int, int, unsigned int, int, unsigned int, int, unsigned int))*(unsigned int *)(**(unsigned int **)0x7897A8 + 0x50))(*(unsigned int *)0x7897A8, width, height, numLevels, 0, format, 1, pTexture)
- signed int gtaCreateTexture(int width, int height, unsigned int numLevels, unsigned int format, unsigned int pTexture)
- {
- // Get the raster
- RwRaster *raster = (RwRaster *)(pTexture - *(unsigned int *)0xA0D8B0);
- unsigned int levels = texInfo.numLevels;
- if((raster->cFormat & 0x80u) == 0)
- levels = 1;
- return d3dCreateTexture(width, height, levels, format, pTexture);
- }
- void ViceMipsPatch()
- {
- CPatch::RedirectCall(0x63F09B, ReadTextureInfo);
- CPatch::RedirectCall(0x63F19F, gtaCreateTexture);
- CPatch::Nop(0x63F0B9, 8);
- }
- void ViceMips()
- {
- ViceMipsPatch();
- }
- BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID reserved)
- {
- switch(reason)
- {
- case DLL_PROCESS_ATTACH:
- ViceMips();
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement