summaryrefslogtreecommitdiffstats
path: root/src/rw/TexRead.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/rw/TexRead.cpp36
1 files changed, 26 insertions, 10 deletions
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;