summaryrefslogtreecommitdiffstats
path: root/src/rw
diff options
context:
space:
mode:
Diffstat (limited to 'src/rw')
-rw-r--r--src/rw/ClumpRead.cpp6
-rw-r--r--src/rw/Lights.cpp24
-rw-r--r--src/rw/NodeName.cpp2
-rw-r--r--src/rw/RwHelper.cpp4
-rw-r--r--src/rw/RwMatFX.cpp4
-rw-r--r--src/rw/TexRead.cpp36
-rw-r--r--src/rw/TxdStore.cpp4
-rw-r--r--src/rw/TxdStore.h4
-rw-r--r--src/rw/VisibilityPlugins.cpp63
-rw-r--r--src/rw/VisibilityPlugins.h34
-rw-r--r--src/rw/rw.cpp7
11 files changed, 113 insertions, 75 deletions
diff --git a/src/rw/ClumpRead.cpp b/src/rw/ClumpRead.cpp
index c9f027e7..0bf62f32 100644
--- a/src/rw/ClumpRead.cpp
+++ b/src/rw/ClumpRead.cpp
@@ -153,7 +153,7 @@ RpClumpGtaStreamRead1(RwStream *stream)
if(!RwStreamFindChunk(stream, rwID_FRAMELIST, nil, &version))
return false;
- if(_rwFrameListStreamRead(stream, &gFrameList) == nil)
+ if(rwFrameListStreamRead(stream, &gFrameList) == nil)
return false;
if(!RwStreamFindChunk(stream, rwID_GEOMETRYLIST, nil, &version)){
@@ -164,7 +164,7 @@ RpClumpGtaStreamRead1(RwStream *stream)
rwFrameListDeinitialize(&gFrameList);
return false;
}
- streamPosition = stream->Type.memory.position;
+ streamPosition = STREAMPOS(stream);
return true;
}
@@ -180,7 +180,7 @@ RpClumpGtaStreamRead2(RwStream *stream)
if(clump == nil)
return nil;
- RwStreamSkip(stream, streamPosition - stream->Type.memory.position);
+ RwStreamSkip(stream, streamPosition - STREAMPOS(stream));
if(GeometryListStreamRead2(stream, &gGeomList) == nil){
GeometryListDeinitialize(&gGeomList);
diff --git a/src/rw/Lights.cpp b/src/rw/Lights.cpp
index cd83a898..9218a055 100644
--- a/src/rw/Lights.cpp
+++ b/src/rw/Lights.cpp
@@ -9,18 +9,18 @@
#include "ZoneCull.h"
#include "Frontend.h"
-RpLight *&pAmbient = *(RpLight**)0x885B6C;
-RpLight *&pDirect = *(RpLight**)0x880F7C;
-RpLight **pExtraDirectionals = (RpLight**)0x60009C;
-int *LightStrengths = (int*)0x87BEF0;
-int &NumExtraDirLightsInWorld = *(int*)0x64C608;
-
-RwRGBAReal &AmbientLightColourForFrame = *(RwRGBAReal*)0x6F46F8;
-RwRGBAReal &AmbientLightColourForFrame_PedsCarsAndObjects = *(RwRGBAReal*)0x6F1D10;
-RwRGBAReal &DirectionalLightColourForFrame = *(RwRGBAReal*)0x87C6B8;
-
-RwRGBAReal &AmbientLightColour = *(RwRGBAReal*)0x86B0F8;
-RwRGBAReal &DirectionalLightColour = *(RwRGBAReal*)0x72E308;
+RpLight *pAmbient;// = *(RpLight**)0x885B6C;
+RpLight *pDirect;// = *(RpLight**)0x880F7C;
+RpLight *pExtraDirectionals[] = { nil, nil, nil, nil };// = (RpLight**)0x60009C;
+int LightStrengths[4];// = (int*)0x87BEF0;
+int NumExtraDirLightsInWorld;// = *(int*)0x64C608;
+
+RwRGBAReal AmbientLightColourForFrame;// = *(RwRGBAReal*)0x6F46F8;
+RwRGBAReal AmbientLightColourForFrame_PedsCarsAndObjects;// = *(RwRGBAReal*)0x6F1D10;
+RwRGBAReal DirectionalLightColourForFrame;// = *(RwRGBAReal*)0x87C6B8;
+
+RwRGBAReal AmbientLightColour;// = *(RwRGBAReal*)0x86B0F8;
+RwRGBAReal DirectionalLightColour;// = *(RwRGBAReal*)0x72E308;
void
SetLightsWithTimeOfDayColour(RpWorld *)
diff --git a/src/rw/NodeName.cpp b/src/rw/NodeName.cpp
index 2aea3c83..7422a323 100644
--- a/src/rw/NodeName.cpp
+++ b/src/rw/NodeName.cpp
@@ -2,7 +2,7 @@
#include "patcher.h"
#include "NodeName.h"
-static int32 &gPluginOffset = *(int32*)0x64C610;
+static int32 gPluginOffset;// = *(int32*)0x64C610;
enum
{
diff --git a/src/rw/RwHelper.cpp b/src/rw/RwHelper.cpp
index 44ca3a0a..cf1a6f2b 100644
--- a/src/rw/RwHelper.cpp
+++ b/src/rw/RwHelper.cpp
@@ -90,9 +90,13 @@ DefinedState(void)
RwRenderStateSet(rwRENDERSTATEFOGTYPE, (void*)rwFOGTYPELINEAR);
RwRenderStateSet(rwRENDERSTATECULLMODE, (void*)rwCULLMODECULLNONE);
+#ifdef LIBRW
+ #pragma message (" TODO: alphatest func")
+#else
// D3D stuff
RwD3D8SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATER);
RwD3D8SetRenderState(D3DRS_ALPHAREF, 2);
+#endif
}
RwFrame*
diff --git a/src/rw/RwMatFX.cpp b/src/rw/RwMatFX.cpp
index 3af6fabe..c4fe0b0b 100644
--- a/src/rw/RwMatFX.cpp
+++ b/src/rw/RwMatFX.cpp
@@ -1,3 +1,5 @@
+#ifndef LIBRW
+
#define WITHD3D
#include "common.h"
#include "patcher.h"
@@ -224,3 +226,5 @@ STARTPATCHES
ENDPATCHES
#endif
+
+#endif
diff --git a/src/rw/TexRead.cpp b/src/rw/TexRead.cpp
index 50b99d47..1ac5a75e 100644
--- a/src/rw/TexRead.cpp
+++ b/src/rw/TexRead.cpp
@@ -22,8 +22,14 @@
#include "RwHelper.h"
#endif //GTA_PC
-float &texLoadTime = *(float*)0x8F1B50;
-int32 &texNumLoaded = *(int32*)0x8F252C;
+float texLoadTime;// = *(float*)0x8F1B50;
+int32 texNumLoaded;// = *(int32*)0x8F252C;
+
+#ifdef LIBRW
+#define READNATIVE(stream, tex, size) rwNativeTextureHackRead(stream, tex, size)
+#else
+#define READNATIVE(stream, tex, size) RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD](stream, tex, size))
+#endif
RwTexture*
RwTextureGtaStreamRead(RwStream *stream)
@@ -36,7 +42,7 @@ RwTextureGtaStreamRead(RwStream *stream)
float preloadTime = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond();
- if(!RWSRCGLOBAL(stdFunc[rwSTANDARDNATIVETEXTUREREAD](stream, &tex, size)))
+ if(!READNATIVE(stream, &tex, size))
return nil;
if (gGameState == GS_INIT_PLAYING_GAME) {
@@ -64,7 +70,9 @@ RwTexDictionaryGtaStreamRead(RwStream *stream)
if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version))
return nil;
assert(size == 4);
- if(RwStreamRead(stream, &numTextures, size) != size)
+int foo = RwStreamRead(stream, &numTextures, size);
+if(foo != size)
+// if(RwStreamRead(stream, &numTextures, size) != size)
return nil;
texDict = RwTexDictionaryCreate();
@@ -121,7 +129,7 @@ RwTexDictionaryGtaStreamRead1(RwStream *stream)
}
numberTextures = numTextures;
- streamPosition = stream->Type.memory.position;
+ streamPosition = STREAMPOS(stream);
return texDict;
}
@@ -131,7 +139,7 @@ RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict)
{
RwTexture *tex;
- RwStreamSkip(stream, streamPosition - stream->Type.memory.position);
+ RwStreamSkip(stream, streamPosition - STREAMPOS(stream));
while(numberTextures--){
tex = RwTextureGtaStreamRead(stream);
@@ -150,9 +158,8 @@ RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict)
#ifdef RWLIBS
extern "C" RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
#else
-WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); }
+RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
#endif
-
void
ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8)
{
@@ -251,6 +258,12 @@ DealWithTxdWriteError(uint32 num, uint32 count, const char *text)
RsGlobal.quit = true;
}
+#ifdef LIBRW
+#define STREAMTELL(str) str->tell()
+#else
+#define STREAMTELL(str) filesys->rwftell((str)->Type.file.fpFile)
+#endif
+
bool
CreateTxdImageForVideoCard()
{
@@ -260,7 +273,9 @@ CreateTxdImageForVideoCard()
CStreaming::FlushRequestList();
+#ifndef LIBRW
RwFileFunctions *filesys = RwOsGetFileInterface();
+#endif
RwStream *img = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMWRITE, "models\\txd.img");
if (img == nil) {
@@ -287,7 +302,8 @@ CreateTxdImageForVideoCard()
sprintf(filename, "%s.txd", CTxdStore::GetTxdName(i));
if (CTxdStore::GetSlot(i)->texDict) {
- int32 pos = filesys->rwftell(img->Type.file.fpFile);
+
+ int32 pos = STREAMTELL(img);
if (RwTexDictionaryStreamWrite(CTxdStore::GetSlot(i)->texDict, img) == nil) {
DealWithTxdWriteError(i, TXDSTORESIZE, "CVT_ERR");
@@ -298,7 +314,7 @@ CreateTxdImageForVideoCard()
return false;
}
- int32 size = filesys->rwftell(img->Type.file.fpFile) - pos;
+ int32 size = STREAMTELL(img) - pos;
int32 num = size % CDSTREAM_SECTOR_SIZE;
size /= CDSTREAM_SECTOR_SIZE;
diff --git a/src/rw/TxdStore.cpp b/src/rw/TxdStore.cpp
index c751147d..a32755a4 100644
--- a/src/rw/TxdStore.cpp
+++ b/src/rw/TxdStore.cpp
@@ -6,8 +6,8 @@
#include "RwHelper.h"
#include "TxdStore.h"
-CPool<TxdDef,TxdDef> *&CTxdStore::ms_pTxdPool = *(CPool<TxdDef,TxdDef>**)0x8F5FB8;
-RwTexDictionary *&CTxdStore::ms_pStoredTxd = *(RwTexDictionary**)0x9405BC;
+CPool<TxdDef,TxdDef> *CTxdStore::ms_pTxdPool;// = *(CPool<TxdDef,TxdDef>**)0x8F5FB8;
+RwTexDictionary *CTxdStore::ms_pStoredTxd;// = *(RwTexDictionary**)0x9405BC;
void
CTxdStore::Initialise(void)
diff --git a/src/rw/TxdStore.h b/src/rw/TxdStore.h
index 12ac708f..937fd1b7 100644
--- a/src/rw/TxdStore.h
+++ b/src/rw/TxdStore.h
@@ -10,8 +10,8 @@ struct TxdDef {
class CTxdStore
{
- static CPool<TxdDef,TxdDef> *&ms_pTxdPool;
- static RwTexDictionary *&ms_pStoredTxd;
+ static CPool<TxdDef,TxdDef> *ms_pTxdPool;
+ static RwTexDictionary *ms_pStoredTxd;
public:
static void Initialise(void);
static void Shutdown(void);
diff --git a/src/rw/VisibilityPlugins.cpp b/src/rw/VisibilityPlugins.cpp
index f8b1f6b2..5438ed0f 100644
--- a/src/rw/VisibilityPlugins.cpp
+++ b/src/rw/VisibilityPlugins.cpp
@@ -11,40 +11,37 @@
#define FADE_DISTANCE 20.0f
-/*
-CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList;
-CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList;
-
-int32 CVisibilityPlugins::ms_atomicPluginOffset = -1;
-int32 CVisibilityPlugins::ms_framePluginOffset = -1;
-int32 CVisibilityPlugins::ms_clumpPluginOffset = -1;
-*/
-CLinkList<CVisibilityPlugins::AlphaObjectInfo> &CVisibilityPlugins::m_alphaList = *(CLinkList<CVisibilityPlugins::AlphaObjectInfo>*)0x8F42E4;
-CLinkList<CVisibilityPlugins::AlphaObjectInfo> &CVisibilityPlugins::m_alphaEntityList = *(CLinkList<CVisibilityPlugins::AlphaObjectInfo>*)0x943084;
-
-int32 &CVisibilityPlugins::ms_atomicPluginOffset = *(int32*)0x600124;
-int32 &CVisibilityPlugins::ms_framePluginOffset = *(int32*)0x600128;
-int32 &CVisibilityPlugins::ms_clumpPluginOffset = *(int32*)0x60012C;
-
-RwCamera *&CVisibilityPlugins::ms_pCamera = *(RwCamera**)0x8F2514;
-RwV3d *&CVisibilityPlugins::ms_pCameraPosn = *(RwV3d**)0x8F6270;
-float &CVisibilityPlugins::ms_cullCompsDist = *(float*)0x8F2BC4;
-float &CVisibilityPlugins::ms_vehicleLod0Dist = *(float*)0x885B28;
-float &CVisibilityPlugins::ms_vehicleLod1Dist = *(float*)0x885B30;
-float &CVisibilityPlugins::ms_vehicleFadeDist = *(float*)0x8E28B4;
-float &CVisibilityPlugins::ms_bigVehicleLod0Dist = *(float*)0x8E2A84;
-float &CVisibilityPlugins::ms_bigVehicleLod1Dist = *(float*)0x8E2A8C;
-float &CVisibilityPlugins::ms_pedLod0Dist = *(float*)0x8F2BD4;
-float &CVisibilityPlugins::ms_pedLod1Dist = *(float*)0x8F2BD8;
-float &CVisibilityPlugins::ms_pedFadeDist = *(float*)0x8E2C34;
+CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaList;// = *(CLinkList<CVisibilityPlugins::AlphaObjectInfo>*)0x8F42E4;
+CLinkList<CVisibilityPlugins::AlphaObjectInfo> CVisibilityPlugins::m_alphaEntityList;// = *(CLinkList<CVisibilityPlugins::AlphaObjectInfo>*)0x943084;
+
+int32 CVisibilityPlugins::ms_atomicPluginOffset = -1;// = *(int32*)0x600124;
+int32 CVisibilityPlugins::ms_framePluginOffset = -1;// = *(int32*)0x600128;
+int32 CVisibilityPlugins::ms_clumpPluginOffset = -1;// = *(int32*)0x60012C;
+
+RwCamera *CVisibilityPlugins::ms_pCamera;// = *(RwCamera**)0x8F2514;
+RwV3d *CVisibilityPlugins::ms_pCameraPosn;// = *(RwV3d**)0x8F6270;
+float CVisibilityPlugins::ms_cullCompsDist;// = *(float*)0x8F2BC4;
+float CVisibilityPlugins::ms_vehicleLod0Dist;// = *(float*)0x885B28;
+float CVisibilityPlugins::ms_vehicleLod1Dist;// = *(float*)0x885B30;
+float CVisibilityPlugins::ms_vehicleFadeDist;// = *(float*)0x8E28B4;
+float CVisibilityPlugins::ms_bigVehicleLod0Dist;// = *(float*)0x8E2A84;
+float CVisibilityPlugins::ms_bigVehicleLod1Dist;// = *(float*)0x8E2A8C;
+float CVisibilityPlugins::ms_pedLod0Dist;// = *(float*)0x8F2BD4;
+float CVisibilityPlugins::ms_pedLod1Dist;// = *(float*)0x8F2BD8;
+float CVisibilityPlugins::ms_pedFadeDist;// = *(float*)0x8E2C34;
void
CVisibilityPlugins::Initialise(void)
{
- m_alphaList.Init(20);
+ m_alphaList.Init(NUMALPHALIST);
m_alphaList.head.item.sort = 0.0f;
m_alphaList.tail.item.sort = 100000000.0f;
- m_alphaEntityList.Init(150);
+#ifdef ASPECT_RATIO_SCALE
+ // default 150 if not enough for bigger FOVs
+ m_alphaEntityList.Init(NUMALPHAENTITYLIST * 3);
+#else
+ m_alphaEntityList.Init(NUMALPHAENTITYLIST);
+#endif // ASPECT_RATIO_SCALE
m_alphaEntityList.head.item.sort = 0.0f;
m_alphaEntityList.tail.item.sort = 100000000.0f;
}
@@ -603,6 +600,16 @@ CVisibilityPlugins::DefaultVisibilityCB(RpClump *clump)
}
bool
+CVisibilityPlugins::MloVisibilityCB(RpClump *clump)
+{
+ RwFrame *frame = RpClumpGetFrame(clump);
+ CMloModelInfo *modelInfo = (CMloModelInfo*)GetFrameHierarchyId(frame);
+ if (sq(modelInfo->field_34) < GetDistanceSquaredFromCamera(frame))
+ return false;
+ return CVisibilityPlugins::FrustumSphereCB(clump);
+}
+
+bool
CVisibilityPlugins::FrustumSphereCB(RpClump *clump)
{
RwSphere sphere;
diff --git a/src/rw/VisibilityPlugins.h b/src/rw/VisibilityPlugins.h
index 65d2675a..63bc95e4 100644
--- a/src/rw/VisibilityPlugins.h
+++ b/src/rw/VisibilityPlugins.h
@@ -20,19 +20,19 @@ public:
float sort;
};
- static CLinkList<AlphaObjectInfo> &m_alphaList;
- static CLinkList<AlphaObjectInfo> &m_alphaEntityList;
- static RwCamera *&ms_pCamera;
- static RwV3d *&ms_pCameraPosn;
- static float &ms_cullCompsDist;
- static float &ms_vehicleLod0Dist;
- static float &ms_vehicleLod1Dist;
- static float &ms_vehicleFadeDist;
- static float &ms_bigVehicleLod0Dist;
- static float &ms_bigVehicleLod1Dist;
- static float &ms_pedLod0Dist;
- static float &ms_pedLod1Dist;
- static float &ms_pedFadeDist;
+ static CLinkList<AlphaObjectInfo> m_alphaList;
+ static CLinkList<AlphaObjectInfo> m_alphaEntityList;
+ static RwCamera *ms_pCamera;
+ static RwV3d *ms_pCameraPosn;
+ static float ms_cullCompsDist;
+ static float ms_vehicleLod0Dist;
+ static float ms_vehicleLod1Dist;
+ static float ms_vehicleFadeDist;
+ static float ms_bigVehicleLod0Dist;
+ static float ms_bigVehicleLod1Dist;
+ static float ms_pedLod0Dist;
+ static float ms_pedLod1Dist;
+ static float ms_pedFadeDist;
static void Initialise(void);
static void Shutdown(void);
@@ -70,7 +70,7 @@ public:
// All actually unused
static bool DefaultVisibilityCB(RpClump *clump);
static bool FrustumSphereCB(RpClump *clump);
-// static bool MloVisibilityCB(RpClump *clump);
+ static bool MloVisibilityCB(RpClump *clump);
static bool VehicleVisibilityCB(RpClump *clump);
static bool VehicleVisibilityCB_BigVehicle(RpClump *clump);
@@ -97,7 +97,7 @@ public:
static void *AtomicDestructor(void *object, int32 offset, int32 len);
static void *AtomicCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
- static int32 &ms_atomicPluginOffset;
+ static int32 ms_atomicPluginOffset;
struct FrameExt
{
@@ -111,7 +111,7 @@ public:
static void *FrameDestructor(void *object, int32 offset, int32 len);
static void *FrameCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
- static int32 &ms_framePluginOffset;
+ static int32 ms_framePluginOffset;
// Not actually used
struct ClumpExt
@@ -127,7 +127,7 @@ public:
static void *ClumpDestructor(void *object, int32 offset, int32 len);
static void *ClumpCopyConstructor(void *dst, const void *src,
int32 offset, int32 len);
- static int32 &ms_clumpPluginOffset;
+ static int32 ms_clumpPluginOffset;
static bool PluginAttach(void);
};
diff --git a/src/rw/rw.cpp b/src/rw/rw.cpp
index 3875f2a1..c525f49f 100644
--- a/src/rw/rw.cpp
+++ b/src/rw/rw.cpp
@@ -1,3 +1,4 @@
+#ifndef LIBRW
#include "common.h"
#include "patcher.h"
#include "rwcore.h"
@@ -414,6 +415,9 @@ WRAPPER RxNodeDefinition* RxNodeDefinitionGetMaterialScatter() { EAXJMP(0x5DDAA0
WRAPPER RxNodeDefinition* RxNodeDefinitionGetLight() { EAXJMP(0x5DF040); }
WRAPPER RxNodeDefinition* RxNodeDefinitionGetPostLight() { EAXJMP(0x5DF560); }
WRAPPER void RxD3D8AllInOneSetRenderCallBack(RxPipelineNode* node, RxD3D8AllInOneRenderCallBack callback) { EAXJMP(0x5DFC60); }
+
+WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); }
+
#else
extern "C"
@@ -432,6 +436,8 @@ extern "C"
void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size);
RwBool _rwPluginRegistryOpen();
RwBool _rwPluginRegistryClose();
+
+ RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
}
STARTPATCHES
@@ -836,4 +842,5 @@ InjectHook(0x5DF040, &RxNodeDefinitionGetLight, PATCH_JUMP);
InjectHook(0x5DF560, &RxNodeDefinitionGetPostLight, PATCH_JUMP);
InjectHook(0x5DFC60, &RxD3D8AllInOneSetRenderCallBack, PATCH_JUMP);
ENDPATCHES
+#endif
#endif \ No newline at end of file