Skip to content

Commit

Permalink
gtasade port, dx11 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ThirteenAG committed Nov 27, 2024
1 parent 9dee055 commit a588e7a
Show file tree
Hide file tree
Showing 13 changed files with 916 additions and 425 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
runs-on: windows-2022
strategy:
matrix:
platform: [Win32]
buildtype: [Release]

steps:
Expand All @@ -24,14 +23,14 @@ jobs:
- name: Configure build
shell: cmd
run: ./premake5.bat
- name: Build xrd
- name: Build XboxRainDroplets
shell: cmd
run: msbuild -m build/${{github.event.repository.name}}.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=${{matrix.platform}}
- name: Build xrd11
run: msbuild -m build/${{github.event.repository.name}}.sln /property:Configuration=${{matrix.buildtype}}
- name: Build XboxRainDropletsWrapper
shell: cmd
run: |
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=Win32
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=Win64
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=${{matrix.buildtype}} /property:Platform=x64
- name: Download Ultimate ASI Loader x86
uses: robinraju/[email protected]
with:
Expand Down Expand Up @@ -172,3 +171,10 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
tag: scb
artifacts: bin/SplinterCellBlacklist.XboxRainDroplets.zip
- name: GTASADE.XboxRainDroplets
uses: ./.github/workflows/release_tag
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: gtasade
artifacts: bin/GTASADE.XboxRainDroplets.zip
4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ before_build:
- ps: >-
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=Release /property:Platform=Win32
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=Release /property:Platform=Win64
msbuild -m build/XboxRainDropletsWrapper.sln /property:Configuration=Release /property:Platform=x64
Start-FileDownload https://github.com/ThirteenAG/Ultimate-ASI-Loader/releases/download/Win32-latest/version-Win32.zip
Expand Down Expand Up @@ -47,4 +47,4 @@ before_package:
release.bat
after_build:
- ps: Get-ChildItem .\bin\*.zip | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
- ps: Get-ChildItem .\bin\*.zip | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
2 changes: 1 addition & 1 deletion external/sire
Submodule sire updated 1 files
+93 −49 sire.h
Binary file modified premake5.exe
Binary file not shown.
57 changes: 35 additions & 22 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ workspace "XboxRainDroplets"
language "C++"
targetextension ".asi"
linkoptions "/SAFESEH:NO"
buildoptions { "/Zc:__cplusplus /utf-8" }
flags { "MultiProcessorCompile" }
defines { "_CRT_SECURE_NO_WARNINGS" }
characterset ("Unicode")

defines { "rsc_CompanyName=\"ThirteenAG\"" }
defines { "rsc_LegalCopyright=\"MIT License\""}
Expand All @@ -31,19 +34,7 @@ workspace "XboxRainDroplets"
includedirs { "external/FusionDxHook/includes" }
includedirs { "external/sire" }
files { "external/sire/sire.h" }
local dxsdk = os.getenv "DXSDK_DIR"
if dxsdk then
includedirs { dxsdk .. "/include" }
libdirs { dxsdk .. "/lib/x86" }
else
includedirs { "source/dxsdk" }
libdirs { "source/dxsdk/lib/x86" }
end
includedirs { "source/dxsdk/dx8" }
libdirs { "source/dxsdk/dx8" }

characterset ("Unicode")


pbcommands = {
"setlocal EnableDelayedExpansion",
--"set \"path=" .. (gamepath) .. "\"",
Expand Down Expand Up @@ -71,11 +62,26 @@ workspace "XboxRainDroplets"
targetdir ("bin")
end

prebuildcommands {
"for /R \"../source/resources/shaders/ps/\" %%f in (*.hlsl) do (\"../source/dxsdk/lib/x86/fxc.exe\" /T ps_3_0 /nologo /E main /Fo \"../source/resources/%%~nf.cso\" %%f)",
"for /R \"../source/resources/shaders/vs/\" %%f in (*.hlsl) do (\"../source/dxsdk/lib/x86/fxc.exe\" /T vs_3_0 /nologo /E main /Fo \"../source/resources/%%~nf.cso\" %%f)",
}

function add_kananlib()
defines { "BDDISASM_HAS_MEMSET", "BDDISASM_HAS_VSNPRINTF" }
files { "external/injector/kananlib/include/utility/**.hpp", "external/injector/kananlib/src/**.cpp" }
files { "external/injector/bddisasm/bddisasm/*.c" }
files { "external/injector/bddisasm/bdshemu/*.c" }
includedirs { "external/injector/kananlib/include" }
includedirs { "external/injector/bddisasm/inc" }
includedirs { "external/injector/bddisasm/bddisasm/include" }
end

filter "architecture:x32"
includedirs { "source/dxsdk" }
libdirs { "source/dxsdk/lib/x86" }
includedirs { "source/dxsdk/dx8" }
libdirs { "source/dxsdk/dx8" }

filter "architecture:x64"
includedirs { "source/dxsdk" }
libdirs { "source/dxsdk/lib/x64" }

filter "configurations:Debug"
defines { "DEBUG" }
symbols "On"
Expand All @@ -100,6 +106,10 @@ project "GTAIV.XboxRainDroplets"
project "Mafia.XboxRainDroplets"
setpaths("Z:/WFP/Games/Mafia/", "GameV12.exe")
project "Scarface.XboxRainDroplets"
prebuildcommands {
"for /R \"../source/resources/shaders/ps/\" %%f in (*.hlsl) do (\"../source/dxsdk/lib/x86/fxc.exe\" /T ps_3_0 /nologo /E main /Fo \"../source/resources/%%~nf.cso\" %%f)",
"for /R \"../source/resources/shaders/vs/\" %%f in (*.hlsl) do (\"../source/dxsdk/lib/x86/fxc.exe\" /T vs_3_0 /nologo /E main /Fo \"../source/resources/%%~nf.cso\" %%f)",
}
setpaths("Z:/WFP/Games/Scarface/", "Scarface.exe")
project "Manhunt.XboxRainDroplets"
setpaths("Z:/WFP/Games/Manhunt/", "manhunt.exe", "scripts/")
Expand All @@ -111,6 +121,10 @@ project "MaxPayne3.XboxRainDroplets"
setpaths("E:/Games/Steam/steamapps/common/Max Payne 3/Max Payne 3/", "MaxPayne3.exe", "plugins/")
project "SplinterCellBlacklist.XboxRainDroplets"
setpaths("Z:/WFP/Games/Splinter Cell/Splinter Cell Blacklist/src/SYSTEM/", "Blacklist_DX11_game.exe", "scripts/")
project "GTASADE.XboxRainDroplets"
architecture "x64"
add_kananlib()
setpaths("Z:/WFP/Games/Grand Theft Auto The Definitive Edition/GTA San Andreas - Definitive Edition/", "Gameface/Binaries/Win64/SanAndreas.exe", "Gameface/Binaries/Win64/scripts/")
--tests
--project "GTA3.XboxRainDroplets"
-- setpaths("Z:/WFP/Games/Grand Theft Auto/GTAIII/", "gta3.exe", "scripts/")
Expand All @@ -119,11 +133,11 @@ project "SplinterCellBlacklist.XboxRainDroplets"

workspace "XboxRainDropletsWrapper"
configurations { "Release", "Debug" }
platforms { "Win32", "Win64" }
platforms { "Win32", "x64" }
location "build"
objdir ("build/obj")
buildlog ("build/log/%{prj.name}.log")
buildoptions {"-std:c++latest"}
cppdialect "C++latest"

kind "SharedLib"
language "C++"
Expand Down Expand Up @@ -172,7 +186,7 @@ workspace "XboxRainDropletsWrapper"
includedirs { "source/dxsdk" }
libdirs { "source/dxsdk/lib/x86" }

filter "platforms:Win64"
filter "platforms:x64"
architecture "x64"
targetname "%{prj.name}64"
includedirs { "source/dxsdk" }
Expand All @@ -183,5 +197,4 @@ project "XboxRainDropletsWrapper"
project "PPSSPP.XboxRainDroplets"
setpaths("Z:/WFP/Games/PPSSPP/", "PPSSPPWindows.exe")
project "PCSX2F.XboxRainDroplets"
architecture "x64"
setpaths("Z:/GitHub/PCSX2-Fork-With-Plugins/bin/", "pcsx2-qtx64-clang.exe")
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Various ini settings allow to customize the appearance and can be edited while i

[![[MaxPayne2] Xbox Rain Droplets Mod](https://img.youtube.com/vi/wodoq5-YPYc/maxresdefault.jpg)](https://www.youtube.com/watch?v=wodoq5-YPYc)

## GTA San Andreas The Definitive Edition - [Download Link](https://github.com/ThirteenAG/XboxRainDroplets/releases/tag/gtasade)

#### Screen:

![scb](https://github.com/user-attachments/assets/af077a90-a75f-4e28-bca0-5ecd0b194ce3)

## Other

More plugins available on [appveyor artifacts page](https://ci.appveyor.com/project/ThirteenAG/xboxraindroplets/build/artifacts), but they are incomplete. It is not recommended to use them.
1 change: 1 addition & 0 deletions release.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ MaxPayne3.XboxRainDroplets
Driv3r.XboxRainDroplets
DriverParallelLines.XboxRainDroplets
SplinterCellBlacklist.XboxRainDroplets
GTASADE.XboxRainDroplets
) do (
7za a -tzip ".\bin\%%x.zip" ".\bin\%%x.asi" ".\bin\%%x.ini"
)
Expand Down
170 changes: 160 additions & 10 deletions source/GTASA.XboxRainDroplets.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
#include "xrd.h"

float& CTimer__ms_fTimeStep = *(float*)0xB7CB5C;
//CCamera& TheCamera = *(CCamera*)0xB6F028;
float& CWeather__Rain = *(float*)(0xC81324);
float& CWeather__UnderWaterness = *(float*)(0xC8132C);
bool& CCutsceneMgr__ms_running = *(bool*)(0xB5F851);
int* CGame__currArea = (int*)0xB72914;
int* CEntryExitManager__ms_exitEnterState = (int*)0x96A7CC;
auto CCullZones__CamNoRain = (bool(__cdecl*)())0x72DDB0;
auto CCullZones__PlayerNoRain = (bool(__cdecl*)())0x72DDC0;

bool NoDrops()
{
return CWeather__UnderWaterness > 0.339731634f || *CEntryExitManager__ms_exitEnterState != 0;
}

bool NoRain()
{
return CCullZones__CamNoRain() || CCullZones__PlayerNoRain() || *CGame__currArea != 0 || NoDrops();
}

void Init()
{
CIniReader iniReader("");
WaterDrops::MinSize = iniReader.ReadInteger("MAIN", "MinSize", 4);
WaterDrops::MaxSize = iniReader.ReadInteger("MAIN", "MaxSize", 15);
WaterDrops::MaxDrops = iniReader.ReadInteger("MAIN", "MaxDrops", 2000);
WaterDrops::MaxDropsMoving = iniReader.ReadInteger("MAIN", "MaxMovingDrops", 500);
WaterDrops::bRadial = iniReader.ReadInteger("MAIN", "RadialMovement", 0) != 0;
WaterDrops::bGravity = iniReader.ReadInteger("MAIN", "EnableGravity", 1) != 0;
WaterDrops::fSpeedAdjuster = iniReader.ReadFloat("MAIN", "SpeedAdjuster", 1.0f);
WaterDrops::fMoveStep = iniReader.ReadFloat("MAIN", "MoveStep", 20.0f);
WaterDrops::ReadIniSettings();

static LPDIRECT3DDEVICE9* pDev = (LPDIRECT3DDEVICE9*)0xC97C28;
static auto matrix = (RwMatrix*)((0xB6F97C + 0x20));
Expand All @@ -23,9 +35,147 @@ void Init()
WaterDrops::up = matrix->up;
WaterDrops::at = matrix->at;
WaterDrops::pos = matrix->pos;

//when you put camera underwater, droplets disappear instantly instead of fading out
if (NoDrops()) {
WaterDrops::Clear();
return;
}

if (NoRain())
WaterDrops::ms_rainIntensity = 0.0f;
else
WaterDrops::ms_rainIntensity = CWeather__Rain;


WaterDrops::Process(*pDev);
WaterDrops::Render(*pDev);

if (WaterDrops::ms_numDrops <= 0 || CCutsceneMgr__ms_running)
{

}
else
{
WaterDrops::Render(*pDev);
}

}; CMotionBlurStreaksRender.fun = injector::MakeCALL(0x726AD0, static_cast<void(*)()>(CMotionBlurStreaksRenderHook), true).get();

static injector::hook_back<void(__fastcall*)(void* _this, int edx, int id, RwV3d* point)> CAEFireAudioEntityAddAudioEvent;
auto CAEFireAudioEntityAddAudioEventHook = [](void* _this, int edx, int id, RwV3d* point)
{
RwV3d dist;
RwV3dSub(&dist, point, &WaterDrops::ms_lastPos);
if (RwV3dLength(&dist) <= 10.0f)
WaterDrops::RegisterSplash(point, 20.0f, 20);

return CAEFireAudioEntityAddAudioEvent.fun(_this, edx, id, point);
}; CAEFireAudioEntityAddAudioEvent.fun = injector::MakeCALL(0x4AAE2D, static_cast<void(__fastcall*)(void*, int, int, RwV3d*)>(CAEFireAudioEntityAddAudioEventHook), true).get(); //water_hydrant
injector::MakeCALL(0x4AAE4B, static_cast<void(__fastcall*)(void*, int, int, RwV3d*)>(CAEFireAudioEntityAddAudioEventHook), true); //water_fountain
injector::MakeCALL(0x4AAE69, static_cast<void(__fastcall*)(void*, int, int, RwV3d*)>(CAEFireAudioEntityAddAudioEventHook), true); //water_fnt_tme

//FxManager_c::CreateFxSystem
static injector::hook_back<void*(__fastcall*)(void*, int, char*, RwV3d*, RwMatrix*, char)> CreateFxSystem;
auto CreateFxSystemHook = [](void* _this, int edx, char* name, RwV3d* point, RwMatrix* m, char flag) -> void*
{
RwV3d dist;
RwV3dSub(&dist, point, &WaterDrops::ms_lastPos);
if (RwV3dLength(&dist) <= 10.0f)
WaterDrops::RegisterSplash(point, 10.0f, 1);

return CreateFxSystem.fun(_this, edx, name, point, m, flag);
};
auto f = static_cast<void*(__fastcall*)(void*, int, char*, RwV3d*, RwMatrix*, char)>(CreateFxSystemHook);
CreateFxSystem.fun = injector::MakeCALL(0x4A10C9, f, true).get();// "water_splash_big"
injector::MakeCALL(0x4A1139, f, true); // "water_splash"
injector::MakeCALL(0x4A11A9, f, true); // "water_splsh_sml"
//injector::MakeCALL(0x68AEBA, f, true); // "water_swim"
//injector::MakeCALL(0x68AF15, f, true); // "water_swim"
//injector::MakeCALL(0x68AF66, f, true); // "water_swim"
//injector::MakeCALL(0x68AFB3, f, true); // "water_swim"

//AddParticle
struct Fx_c {
void* prt_blood;
void* prt_boatsplash;
void* prt_bubble;
void* prt_cardebris;
void* prt_collisionsmoke;
void* prt_gunshell;
void* prt_sand;
void* prt_sand2;
void* prt_smoke_huge;
void* prt_smokeII_3_expand;
void* prt_spark;
void* prt_spark_2;
void* prt_splash;
void* prt_wake;
void* prt_watersplash;
void* prt_wheeldirt;
void* prt_glass;
//...
};
static Fx_c &g_fx = *(Fx_c*)0xA9AE00;
static injector::hook_back<void*(__fastcall*)(void*, int, RwV3d*, RwV3d*, float, void*, float, float, float, unsigned char)> AddParticle;
auto AddParticleHook = [](void* _this, int edx, RwV3d* position, RwV3d* velocity, float arg2, void* prtMult, float arg4, float brightness, float arg6, unsigned char arg7) -> void*
{
RwV3d dist;
RwV3dSub(&dist, position, &WaterDrops::ms_lastPos);
float pd = 20.0f;
bool isBlood = false;
if (_this == g_fx.prt_blood) { pd = 5.0; isBlood = true; }
else if (_this == g_fx.prt_boatsplash) { pd = 40.0; }
else if (_this == g_fx.prt_splash) { pd = 15.0; }
else if (_this == g_fx.prt_wake) { pd = 10.0; }
else if (_this == g_fx.prt_watersplash) { pd = 30.0; }

float len = RwV3dLength(&dist);
if (len <= pd)
WaterDrops::FillScreenMoving(1.0f / (len / 2.0f), isBlood);

return AddParticle.fun(_this, edx, position, velocity, arg2, prtMult, arg4, brightness, arg6, arg7);
};
auto f2 = static_cast<void*(__fastcall*)(void*, int, RwV3d*, RwV3d*, float, void*, float, float, float, unsigned char)>(AddParticleHook);
//injector::MakeCALL(0x72AD55, f2, true); // "prt_splash"
AddParticle.fun = injector::MakeCALL(0x7294A6, f2, true).get(); // "prt_watersplash"
//injector::MakeCALL(0x6DE21A, f2, true); // "prt_splash"
injector::MakeCALL(0x6DD6C5, f2, true); // "prt_boatsplash"
injector::MakeCALL(0x6DD589, f2, true); // "prt_boatsplash"
injector::MakeCALL(0x6C3ABE, f2, true); // "prt_wake"
injector::MakeCALL(0x6C3939, f2, true); // "prt_watersplash"
injector::MakeCALL(0x6AA86F, f2, true); // "prt_watersplash"
injector::MakeCALL(0x68ADE2, f2, true); // "prt_wake"
injector::MakeCALL(0x5E7649, f2, true); // "prt_watersplash"
//injector::MakeCALL(0x5E74DC, f2, true); // "prt_splash"
//injector::MakeCALL(0x5E37AF, f2, true); // "prt_splash"
//injector::MakeCALL(0x5E3782, f2, true); // "prt_splash"
injector::MakeCALL(0x49FEEE, f2, true); // "prt_boatsplash"
//injector::MakeCALL(0x49F01F, f2, true); // "prt_blood"
injector::MakeCALL(0x49EC92, f2, true); // "prt_blood"

//chainsaw
static injector::hook_back<void(__fastcall*)(void* _this, int edx, int eventID)> CAEPedWeaponAudioEntityAddAudioEvent;
auto CAEPedWeaponAudioEntityAddAudioEventHook = [](void* _this, int edx, int eventID)
{
WaterDrops::FillScreenMoving(1.0f, true);
return CAEPedWeaponAudioEntityAddAudioEvent.fun(_this, edx, eventID);
}; CAEPedWeaponAudioEntityAddAudioEvent.fun = injector::MakeCALL(0x61CD73, static_cast<void(__fastcall*)(void*, int, int)>(CAEPedWeaponAudioEntityAddAudioEventHook), true).get();

//harvester
//static injector::hook_back<void(__cdecl*)(CEntity*)> WorldAdd;
//auto WorldAddHook = [](CEntity* entity)
//{
// WorldAdd.fun(entity);
//
// if(config->neoWaterDrops){
// RwV3d dist;
// RwV3dSub(&dist, (RwV3d*)&entity->GetPosition(), &WaterDrops::ms_lastPos);
// if(RwV3dLength(&dist) <= 20.0f)
// WaterDrops::FillScreenMoving(0.5f, true);
// }
//};
//WorldAdd.fun = injector::MakeCALL(0x6A9BE2, static_cast<void(__cdecl*)(CEntity*)>(WorldAddHook), true).get();

}

extern "C" __declspec(dllexport) void InitializeASI()
Expand Down
Loading

0 comments on commit a588e7a

Please sign in to comment.