summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-05-31 00:33:01 +0200
committeraap <aap@papnet.eu>2019-05-31 00:33:01 +0200
commitc4368b7432b4484d3f086afb5589fcddc62a1915 (patch)
tree2cce45d6ba4feabb229eb349c5b32beb22849d39 /src
parentadded CCredits (diff)
parentMerge pull request #3 from Fire-Head/master (diff)
downloadre3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar.gz
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar.bz2
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar.lz
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar.xz
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.tar.zst
re3-c4368b7432b4484d3f086afb5589fcddc62a1915.zip
Diffstat (limited to 'src')
-rw-r--r--src/General.h4
-rw-r--r--src/common.h6
-rw-r--r--src/config.h3
-rw-r--r--src/re3.cpp13
-rw-r--r--src/render/Particle.cpp3
-rw-r--r--src/render/Shadows.cpp6
6 files changed, 24 insertions, 11 deletions
diff --git a/src/General.h b/src/General.h
index aa52bf4d..f957ab2f 100644
--- a/src/General.h
+++ b/src/General.h
@@ -45,8 +45,8 @@ public:
{ return myrand() & 0xFFFF; }
// Probably don't want to ever reach high
static float GetRandomNumberInRange(float low, float high)
- { return low + (high - low)*(GetRandomNumber()/65536.0f); }
+ { return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); }
static Int32 GetRandomNumberInRange(Int32 low, Int32 high)
- { return low + (high - low)*(GetRandomNumber()/65536.0f); }
+ { return low + (high - low)*(GetRandomNumber()/float(MYRAND_MAX + 1)); }
};
diff --git a/src/common.h b/src/common.h
index a82e4c7f..47dd13f2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -145,6 +145,12 @@ inline float sq(float x) { return x*x; }
#define DEGTORAD(x) ((x) * PI / 180.0f)
#define RADTODEG(x) ((x) * 180.0f / PI)
+#if USE_PS2_RAND == TRUE
+#define MYRAND_MAX 65535
+#else
+#define MYRAND_MAX 32767
+#endif
+
int myrand(void);
void mysrand(unsigned int seed);
diff --git a/src/config.h b/src/config.h
index 94692fa0..c12f2da2 100644
--- a/src/config.h
+++ b/src/config.h
@@ -53,3 +53,6 @@ enum Config {
NUMANTENNAS = 8,
};
+
+#define GTA3_1_1_PATCH FALSE
+#define USE_PS2_RAND FALSE \ No newline at end of file
diff --git a/src/re3.cpp b/src/re3.cpp
index 289c7f7a..0d235cc0 100644
--- a/src/re3.cpp
+++ b/src/re3.cpp
@@ -21,15 +21,24 @@ WRAPPER void gtadelete(void *p) { EAXJMP(0x5A07E0); }
void *operator new(size_t sz) { return gtanew(sz); }
void operator delete(void *ptr) noexcept { gtadelete(ptr); }
-// Use our own implementation of rand, stolen from PS2
-
+#if USE_PS2_RAND == TRUE
unsigned __int64 myrand_seed = 1;
+#else
+unsigned long int myrand_seed = 1;
+#endif
int
myrand(void)
{
+#if USE_PS2_RAND == TRUE
+ // Use our own implementation of rand, stolen from PS2
myrand_seed = 0x5851F42D4C957F2D * myrand_seed + 1;
return ((myrand_seed >> 32) & 0x7FFFFFFF);
+#else
+ // or original codewarrior rand
+ myrand_seed = myrand_seed * 1103515245 + 12345;
+ return((myrand_seed >> 16) & 0x7FFF);
+#endif
}
void
diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp
index bd4f7696..03ff6bb2 100644
--- a/src/render/Particle.cpp
+++ b/src/render/Particle.cpp
@@ -210,7 +210,7 @@ RwTexture * (&gpRainDropTex)[MAX_RAINDROP_FILES] = *(RwTexture * (*)[MAX_RA
RwRaster *gpRainDropRaster[MAX_RAINDROP_FILES];
//Float CParticle::ms_afRandTable[CParticle::RAND_TABLE_SIZE]; //
-Float (&CParticle::ms_afRandTable)[CParticle::RAND_TABLE_SIZE] = *(Float (*)[CParticle::RAND_TABLE_SIZE])*(int *)0x6E9878;
+Float (&CParticle::ms_afRandTable)[CParticle::RAND_TABLE_SIZE] = *(Float (*)[CParticle::RAND_TABLE_SIZE])*(int *)0x6E98C8;
CParticle *CParticle::m_pUnusedListHead;
@@ -1853,7 +1853,6 @@ void CParticle::AddYardieDoorSmoke(CVector const &vecPos, CMatrix const &matMatr
}
STARTPATCHES
-return; // causes crash, out temporarily
//InjectHook(0x50C410, &CParticle::ctor, PATCH_JUMP);
//InjectHook(0x50C420, &CParticle::dtor, PATCH_JUMP);
InjectHook(0x50C430, CParticle::ReloadConfig, PATCH_JUMP);
diff --git a/src/render/Shadows.cpp b/src/render/Shadows.cpp
index 587dda99..81ba75aa 100644
--- a/src/render/Shadows.cpp
+++ b/src/render/Shadows.cpp
@@ -2,10 +2,6 @@
#include "patcher.h"
#include "Shadows.h"
-void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, unsigned char nRed, unsigned char nGreen, unsigned char nBlue, float fZDistance, unsigned int nTime, float fScale)
-{
- ((void (__cdecl *)(unsigned char, RwTexture*, CVector*, float, float, float, float, short, unsigned char, unsigned char, unsigned char, float, unsigned int, float))0x56EC50)(ShadowType, pTexture, pPosn, fX1, fY1, fX2, fY2, nTransparency, nRed, nGreen, nBlue, fZDistance, nTime, fScale);
-}
-
+WRAPPER void CShadows::AddPermanentShadow(unsigned char ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, unsigned char nRed, unsigned char nGreen, unsigned char nBlue, float fZDistance, unsigned int nTime, float fScale) { EAXJMP(0x512FD0); }
WRAPPER void CShadows::RenderStaticShadows(void) { EAXJMP(0x5145F0); }
WRAPPER void CShadows::RenderStoredShadows(void) { EAXJMP(0x514010); }