Skip to content

Commit 737214c

Browse files
committed
implemented III PS2 ped splash (for puddles)
1 parent e62077e commit 737214c

File tree

4 files changed

+84
-14
lines changed

4 files changed

+84
-14
lines changed

main.cpp

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,57 @@ curvehook(void)
688688
}
689689
#endif
690690

691+
unsigned __int64 rand_seed = 1;
692+
float ps2randnormalize = 1.0f/0x7FFFFFFF;
693+
694+
int ps2rand()
695+
{
696+
rand_seed = 0x5851F42D4C957F2D * rand_seed + 1;
697+
return ((rand_seed >> 32) & 0x7FFFFFFF);
698+
}
699+
700+
void ps2srand(unsigned int seed)
701+
{
702+
rand_seed = seed;
703+
}
704+
705+
struct CVector { float x, y, z; };
706+
707+
WRAPPER void CParticle__AddParticle(int partcltype,CVector*,CVector*,void*entity,float,uint *rwrgba,int,int,int,int) { EAXJMP(0x50D190); }
708+
709+
void
710+
footsplash_ps2(uchar *ebx, uchar *esp)
711+
{
712+
RwMatrix *mtx;
713+
CVector *speed;
714+
CVector vec1, vec2;
715+
uint col;
716+
mtx = (RwMatrix*)(ebx+4);
717+
speed = (CVector*)(ebx+0x78);
718+
719+
vec1.x = mtx->pos.x - mtx->at.x*0.3f + mtx->up.x*0.3f;
720+
vec1.y = mtx->pos.y - mtx->at.y*0.3f + mtx->up.y*0.3f;
721+
vec1.z = mtx->pos.z - mtx->at.z*0.3f + mtx->up.z*0.3f - 1.2f;
722+
vec2.x = speed->x*0.45;
723+
vec2.y = speed->y*0.45;
724+
vec2.z = (ps2rand()&0xFFFF)/65536.0f * 0.02f + 0.03f;
725+
col = *(uint*)0x5F85C4;
726+
CParticle__AddParticle(44, &vec1, &vec2, NULL, 0.0f, &col, 0, 0, 0, 0);
727+
}
728+
729+
void __declspec(naked)
730+
footsplash_hook(void)
731+
{
732+
_asm {
733+
push esp
734+
push ebx
735+
call footsplash_ps2
736+
add esp,8
737+
push 0x4CCDC3
738+
retn
739+
}
740+
}
741+
691742
//
692743
// real time reflection test; III 1.0
693744
//
@@ -727,6 +778,9 @@ void (*InitialiseGame)(void);
727778
void
728779
InitialiseGame_hook(void)
729780
{
781+
static int x = 0;
782+
assert(x == 0);
783+
x = 1;
730784
if(isIII())
731785
// fall back to generic.txd when reading from dff
732786
InjectHook(AddressByVersion<addr>(0x5AAE1B, 0x5AB0DB, 0x5AD708, 0, 0, 0), RwTextureRead_generic);
@@ -897,9 +951,9 @@ patch(void)
897951
InjectHook(0x405DB0, printf, PATCH_JUMP);
898952

899953
// patch loadscreens
900-
Patch<uint>(0x48D774, 0x6024448b); // 8B 44 24 60 - mov eax,[esp+60h]
901-
Patch<uchar>(0x48D778, 0x50); // push eax
902-
InjectHook(0x48D779, 0x48D79B, PATCH_JUMP);
954+
// ff 74 24 60 push DWORD PTR [esp+0x60]
955+
Patch<uint>(0x48D774, 0x602474ff);
956+
InjectHook(0x48D778, 0x48D79B, PATCH_JUMP);
903957

904958
//MemoryVP::InjectHook(0x48E603, RenderEffectsHook);
905959
//MemoryVP::InjectHook(0x5219B3, CVehicleModelInfo__SetEnvironmentMapCB_hook);
@@ -911,6 +965,22 @@ patch(void)
911965
Patch<uchar>(0x48E6A7+1, 3);
912966
Patch<uchar>(0x48E78C+1, 3);
913967

968+
static float randscl = 1/63556.0f;
969+
static float splashscl = 0.4f;
970+
static float splashadd = -0.2f;
971+
972+
InjectHook(0x4CC4EA, ps2rand);
973+
InjectHook(0x4CC514, ps2rand);
974+
InjectHook(0x4CC53E, ps2rand);
975+
Patch<float*>(0x4CC4FA +2, &randscl);
976+
Patch<float*>(0x4CC524 +2, &randscl);
977+
Patch<float*>(0x4CC500 +2, &splashscl);
978+
Patch<float*>(0x4CC52A +2, &splashscl);
979+
Patch<float*>(0x4CC506 +2, &splashadd);
980+
Patch<float*>(0x4CC530 +2, &splashadd);
981+
// Nop(0x4CCD69, 5);
982+
// Nop(0x4CCDBB, 5);
983+
InjectHook(0x4CCC1A, footsplash_hook, PATCH_JUMP);
914984
}
915985
#endif
916986
#ifndef RELEASE
@@ -928,10 +998,10 @@ patch(void)
928998
//Patch(0x4CF47D, 0xc031); // xor eax, eax
929999
//Nop(0x4CF47D + 2, 2);
9301000

931-
// enable loadscreens. BREAKS FOR SOME REASON (OLA?)
932-
//MemoryVP::Nop(0x4A69D4, 1);
933-
//// ff 74 24 78 push DWORD PTR [esp+0x78]
934-
//MemoryVP::Patch(0x4A69D4+1, 0x782474ff);
1001+
// enable loadscreens. BREAKS WITH OLD OLA
1002+
Nop(0x4A69D4, 1);
1003+
// ff 74 24 78 push DWORD PTR [esp+0x78]
1004+
Patch(0x4A69D4+1, 0x782474ff);
9351005
}
9361006
#endif
9371007

neoGlosspipe.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ GlossPipe::GlossPipe(void)
4242
: specular(1.0f, 1.0f, 1.0f, 1.0f)
4343
{
4444
CreateRwPipeline();
45-
isActive = true;
45+
isActive = config.neoGlossPipe;
4646
texdict = NULL;
4747
}
4848

neoWaterdrops.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ hookWaterDrops(void)
4848
if(is10()){
4949
// ADDRESSES
5050
InterceptCall(&RenderEffects_A, RenderEffects_hook, AddressByVersion<addr>(0x48E603, 0, 0, 0x4A604F, 0, 0));
51-
INTERCEPT(reset_call_1, reset_hook_1, AddressByVersion<addr>(0x48C1AB, 0, 0, 0x4A4DD6, 0, 0));
52-
INTERCEPT(reset_call_2, reset_hook_2, AddressByVersion<addr>(0x48C530, 0, 0, 0x4A48EA, 0, 0));
53-
INTERCEPT(reset_call_3, reset_hook_3, AddressByVersion<addr>(0x42155D, 0, 0, 0x42BCD6, 0, 0));
54-
INTERCEPT(reset_call_4, reset_hook_4, AddressByVersion<addr>(0x42177A, 0, 0, 0x42C0BC, 0, 0));
55-
INTERCEPT(reset_call_5, reset_hook_5, AddressByVersion<addr>(0x421926, 0, 0, 0x42C318, 0, 0));
51+
INTERCEPT(reset_call_1, reset_hook_1, AddressByVersion<addr>(0x48C1AB, 0, 0, 0x4A4DD6, 0, 0)); // CGame::Initialise
52+
INTERCEPT(reset_call_2, reset_hook_2, AddressByVersion<addr>(0x48C530, 0, 0, 0x4A48EA, 0, 0)); // CGame::ReInitGameObjectVariables
53+
INTERCEPT(reset_call_3, reset_hook_3, AddressByVersion<addr>(0x42155D, 0, 0, 0x42BCD6, 0, 0)); // CGameLogic::Update
54+
INTERCEPT(reset_call_4, reset_hook_4, AddressByVersion<addr>(0x42177A, 0, 0, 0x42C0BC, 0, 0)); // "
55+
INTERCEPT(reset_call_5, reset_hook_5, AddressByVersion<addr>(0x421926, 0, 0, 0x42C318, 0, 0)); // "
5656

5757
INTERCEPT(splashbreak, splashhook, AddressByVersion<addr>(0x4BC7D0, 0, 0, 0x4E8721, 0, 0));
5858

skygfx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef uintptr_t addr;
2828

2929
#include "MemoryMgr.h"
3030

31-
#define RELEASE
31+
//#define RELEASE
3232

3333
struct MatFXEnv
3434
{

0 commit comments

Comments
 (0)