first fake RW implementation working

This commit is contained in:
aap 2020-04-16 10:26:16 +02:00
parent 89b7085353
commit 4b602940eb
6 changed files with 62 additions and 34 deletions

View File

@ -307,6 +307,7 @@ bool CGame::Initialise(const char* datFile)
CDraw::SetFOV(120.0f); CDraw::SetFOV(120.0f);
CDraw::ms_fLODDistance = 500.0f; CDraw::ms_fLODDistance = 500.0f;
LoadingScreen("Loading the Game", "Setup streaming", nil); LoadingScreen("Loading the Game", "Setup streaming", nil);
#ifdef USE_TXD_CDIMAGE
int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r"); int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
if (txdHandle) if (txdHandle)
CFileMgr::CloseFile(txdHandle); CFileMgr::CloseFile(txdHandle);
@ -321,6 +322,9 @@ bool CGame::Initialise(const char* datFile)
CStreaming::Init(); CStreaming::Init();
} }
} }
#else
CStreaming::Init();
#endif
CStreaming::LoadInitialVehicles(); CStreaming::LoadInitialVehicles();
CStreaming::LoadInitialPeds(); CStreaming::LoadInitialPeds();
CStreaming::RequestBigBuildings(LEVEL_NONE); CStreaming::RequestBigBuildings(LEVEL_NONE);

View File

@ -190,6 +190,7 @@ enum Config {
#define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things #define TOGGLEABLE_BETA_FEATURES // toggleable from debug menu. not too many things
#define MORE_LANGUAGES // Add more translations to the game #define MORE_LANGUAGES // Add more translations to the game
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
//#define USE_TXD_CDIMAGE // generate and load textures from txd.img
// Pad // Pad
#define XINPUT #define XINPUT

View File

@ -178,8 +178,8 @@ RwImage *RwImageWrite(RwImage * image, const RwChar * imageName);
RwChar *RwImageGetPath(void); RwChar *RwImageGetPath(void);
const RwChar *RwImageSetPath(const RwChar * path) { Image::setSearchPath(path); return path; } const RwChar *RwImageSetPath(const RwChar * path) { Image::setSearchPath(path); return path; }
RwImage *RwImageSetStride(RwImage * image, RwInt32 stride) { image->stride = stride; return image; } RwImage *RwImageSetStride(RwImage * image, RwInt32 stride) { image->stride = stride; return image; }
RwImage *RwImageSetPixels(RwImage * image, RwUInt8 * pixels) { image->setPixels(pixels); return image; } RwImage *RwImageSetPixels(RwImage * image, RwUInt8 * pixels) { image->pixels = pixels; return image; }
RwImage *RwImageSetPalette(RwImage * image, RwRGBA * palette) { image->setPalette((uint8*)palette); return image; } RwImage *RwImageSetPalette(RwImage * image, RwRGBA * palette) { image->palette = (uint8*)palette; return image; }
RwInt32 RwImageGetWidth(const RwImage * image); RwInt32 RwImageGetWidth(const RwImage * image);
RwInt32 RwImageGetHeight(const RwImage * image); RwInt32 RwImageGetHeight(const RwImage * image);
RwInt32 RwImageGetDepth(const RwImage * image); RwInt32 RwImageGetDepth(const RwImage * image);
@ -252,12 +252,12 @@ RwRaster *RwRasterGetParent(const RwRaster *raster) { return raster->parent;
RwRaster *RwRasterGetOffset(RwRaster *raster, RwInt16 *xOffset, RwInt16 *yOffset); RwRaster *RwRasterGetOffset(RwRaster *raster, RwInt16 *xOffset, RwInt16 *yOffset);
RwInt32 RwRasterGetNumLevels(RwRaster * raster); RwInt32 RwRasterGetNumLevels(RwRaster * raster);
RwRaster *RwRasterSubRaster(RwRaster * subRaster, RwRaster * raster, RwRect * rect); RwRaster *RwRasterSubRaster(RwRaster * subRaster, RwRaster * raster, RwRect * rect);
RwRaster *RwRasterRenderFast(RwRaster * raster, RwInt32 x, RwInt32 y); RwRaster *RwRasterRenderFast(RwRaster * raster, RwInt32 x, RwInt32 y) { return raster->renderFast(x, y) ? raster : nil; }
RwRaster *RwRasterRender(RwRaster * raster, RwInt32 x, RwInt32 y); RwRaster *RwRasterRender(RwRaster * raster, RwInt32 x, RwInt32 y);
RwRaster *RwRasterRenderScaled(RwRaster * raster, RwRect * rect); RwRaster *RwRasterRenderScaled(RwRaster * raster, RwRect * rect);
RwRaster *RwRasterPushContext(RwRaster * raster); RwRaster *RwRasterPushContext(RwRaster * raster) { return Raster::pushContext(raster); }
RwRaster *RwRasterPopContext(void); RwRaster *RwRasterPopContext(void) { return Raster::popContext(); }
RwRaster *RwRasterGetCurrentContext(void); RwRaster *RwRasterGetCurrentContext(void) { return Raster::getCurrentContext(); }
RwBool RwRasterClear(RwInt32 pixelValue); RwBool RwRasterClear(RwInt32 pixelValue);
RwBool RwRasterClearRect(RwRect * rpRect, RwInt32 pixelValue); RwBool RwRasterClearRect(RwRect * rpRect, RwInt32 pixelValue);
RwRaster *RwRasterShowRaster(RwRaster * raster, void *dev, RwUInt32 flags); RwRaster *RwRasterShowRaster(RwRaster * raster, void *dev, RwUInt32 flags);
@ -378,20 +378,27 @@ RwStream *RwStreamOpen(RwStreamType type, RwStreamAccessType accessType, const v
default: return nil; default: return nil;
} }
// oh god this is horrible. librw streams really need fixing
switch(type){ switch(type){
case rwSTREAMFILENAME: case rwSTREAMFILENAME:{
StreamFile fakefile;
file = rwNewT(StreamFile, 1, 0); file = rwNewT(StreamFile, 1, 0);
memcpy(file, &fakefile, sizeof(StreamFile));
if(file->open((char*)pData, mode)) if(file->open((char*)pData, mode))
return file; return file;
rwFree(file); rwFree(file);
return nil; return nil;
case rwSTREAMMEMORY: }
case rwSTREAMMEMORY:{
StreamMemory fakemem;
memargs = (RwMemory*)pData; memargs = (RwMemory*)pData;
mem = rwNewT(StreamMemory, 1, 0); mem = rwNewT(StreamMemory, 1, 0);
memcpy(mem, &fakemem, sizeof(StreamMemory));
if(mem->open(memargs->start, memargs->length)) if(mem->open(memargs->start, memargs->length))
return mem; return mem;
rwFree(mem); rwFree(mem);
return nil; return nil;
}
default: default:
assert(0 && "unknown type"); assert(0 && "unknown type");
return nil; return nil;
@ -501,7 +508,10 @@ RwBool RwEngineOpen(RwEngineOpenParams *initParams) {
openParams.window = (HWND)initParams->displayID; openParams.window = (HWND)initParams->displayID;
return Engine::open(&openParams); return Engine::open(&openParams);
} }
RwBool RwEngineStart(void) { return Engine::start(); } RwBool RwEngineStart(void) {
rw::d3d::isP8supported = false;
return Engine::start();
}
RwBool RwEngineStop(void) { Engine::stop(); return true; } RwBool RwEngineStop(void) { Engine::stop(); return true; }
RwBool RwEngineClose(void) { Engine::close(); return true; } RwBool RwEngineClose(void) { Engine::close(); return true; }
RwBool RwEngineTerm(void) { Engine::term(); return true; } RwBool RwEngineTerm(void) { Engine::term(); return true; }
@ -582,9 +592,8 @@ RpLight *RpLightSetColor(RpLight *light, const RwRGBAReal *color) { light->setCo
RpGeometry *RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format) { return Geometry::create(numVert, numTriangles, format); } RpGeometry *RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format) { return Geometry::create(numVert, numTriangles, format); }
RwBool RpGeometryDestroy(RpGeometry *geometry) { geometry->destroy(); return true; } RwBool RpGeometryDestroy(RpGeometry *geometry) { geometry->destroy(); return true; }
RpGeometry *_rpGeometryAddRef(RpGeometry *geometry); RpGeometry *_rpGeometryAddRef(RpGeometry *geometry);
// TODO: implement this RpGeometry *RpGeometryLock(RpGeometry *geometry, RwInt32 lockMode) { geometry->lock(lockMode); return geometry; }
RpGeometry *RpGeometryLock(RpGeometry *geometry, RwInt32 lockMode) { return geometry; } RpGeometry *RpGeometryUnlock(RpGeometry *geometry) { geometry->unlock(); return geometry; }
RpGeometry *RpGeometryUnlock(RpGeometry *geometry) { return geometry; }
RpGeometry *RpGeometryTransform(RpGeometry *geometry, const RwMatrix *matrix); RpGeometry *RpGeometryTransform(RpGeometry *geometry, const RwMatrix *matrix);
RpGeometry *RpGeometryCreateSpace(RwReal radius); RpGeometry *RpGeometryCreateSpace(RwReal radius);
RpMorphTarget *RpMorphTargetSetBoundingSphere(RpMorphTarget *morphTarget, const RwSphere *boundingSphere) { morphTarget->boundingSphere = *boundingSphere; return morphTarget; } RpMorphTarget *RpMorphTargetSetBoundingSphere(RpMorphTarget *morphTarget, const RwSphere *boundingSphere) { morphTarget->boundingSphere = *boundingSphere; return morphTarget; }
@ -596,7 +605,11 @@ RpGeometry *RpGeometryRemoveMorphTarget(RpGeometry *geometry, RwInt32 morphTarg
RwInt32 RpGeometryGetNumMorphTargets(const RpGeometry *geometry); RwInt32 RpGeometryGetNumMorphTargets(const RpGeometry *geometry);
RpMorphTarget *RpGeometryGetMorphTarget(const RpGeometry *geometry, RwInt32 morphTarget) { return &geometry->morphTargets[morphTarget]; } RpMorphTarget *RpGeometryGetMorphTarget(const RpGeometry *geometry, RwInt32 morphTarget) { return &geometry->morphTargets[morphTarget]; }
RwRGBA *RpGeometryGetPreLightColors(const RpGeometry *geometry) { return geometry->colors; } RwRGBA *RpGeometryGetPreLightColors(const RpGeometry *geometry) { return geometry->colors; }
RwTexCoords *RpGeometryGetVertexTexCoords(const RpGeometry *geometry, RwTextureCoordinateIndex uvIndex) { return geometry->texCoords[uvIndex]; } RwTexCoords *RpGeometryGetVertexTexCoords(const RpGeometry *geometry, RwTextureCoordinateIndex uvIndex) {
if(uvIndex == rwNARWTEXTURECOORDINATEINDEX)
return nil;
return geometry->texCoords[uvIndex-rwTEXTURECOORDINATEINDEX0];
}
RwInt32 RpGeometryGetNumTexCoordSets(const RpGeometry *geometry) { return geometry->numTexCoordSets; } RwInt32 RpGeometryGetNumTexCoordSets(const RpGeometry *geometry) { return geometry->numTexCoordSets; }
RwInt32 RpGeometryGetNumVertices (const RpGeometry *geometry) { return geometry->numVertices; } RwInt32 RpGeometryGetNumVertices (const RpGeometry *geometry) { return geometry->numVertices; }
RwV3d *RpMorphTargetGetVertices(const RpMorphTarget *morphTarget) { return morphTarget->vertices; } RwV3d *RpMorphTargetGetVertices(const RpMorphTarget *morphTarget) { return morphTarget->vertices; }
@ -793,3 +806,9 @@ RpHAnimHierarchy *RpSkinAtomicGetHAnimHierarchy( const RpAtomic *atomic ) { retu
RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName) { rw::writeBMP(image, imageName); return image; } RwImage *RtBMPImageWrite(RwImage * image, const RwChar * imageName) { rw::writeBMP(image, imageName); return image; }
RwImage *RtBMPImageRead(const RwChar * imageName) { return rw::readBMP(imageName); } RwImage *RtBMPImageRead(const RwChar * imageName) { return rw::readBMP(imageName); }
// fake shit
RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { return 1; }

View File

@ -122,21 +122,21 @@ enum RpGeometryFlag
enum RpGeometryLockMode enum RpGeometryLockMode
{ {
rpGEOMETRYLOCKPOLYGONS = 0x01, rpGEOMETRYLOCKPOLYGONS = rw::Geometry::LOCKPOLYGONS,
rpGEOMETRYLOCKVERTICES = 0x02, rpGEOMETRYLOCKVERTICES = rw::Geometry::LOCKVERTICES,
rpGEOMETRYLOCKNORMALS = 0x04, rpGEOMETRYLOCKNORMALS = rw::Geometry::LOCKNORMALS,
rpGEOMETRYLOCKPRELIGHT = 0x08, rpGEOMETRYLOCKPRELIGHT = rw::Geometry::LOCKPRELIGHT,
rpGEOMETRYLOCKTEXCOORDS = 0x10, rpGEOMETRYLOCKTEXCOORDS = rw::Geometry::LOCKTEXCOORDS,
rpGEOMETRYLOCKTEXCOORDS1 = 0x10, rpGEOMETRYLOCKTEXCOORDS1 = rw::Geometry::LOCKTEXCOORDS1,
rpGEOMETRYLOCKTEXCOORDS2 = 0x20, rpGEOMETRYLOCKTEXCOORDS2 = rw::Geometry::LOCKTEXCOORDS2,
rpGEOMETRYLOCKTEXCOORDS3 = 0x40, rpGEOMETRYLOCKTEXCOORDS3 = rw::Geometry::LOCKTEXCOORDS3,
rpGEOMETRYLOCKTEXCOORDS4 = 0x80, rpGEOMETRYLOCKTEXCOORDS4 = rw::Geometry::LOCKTEXCOORDS4,
rpGEOMETRYLOCKTEXCOORDS5 = 0x0100, rpGEOMETRYLOCKTEXCOORDS5 = rw::Geometry::LOCKTEXCOORDS5,
rpGEOMETRYLOCKTEXCOORDS6 = 0x0200, rpGEOMETRYLOCKTEXCOORDS6 = rw::Geometry::LOCKTEXCOORDS6,
rpGEOMETRYLOCKTEXCOORDS7 = 0x0400, rpGEOMETRYLOCKTEXCOORDS7 = rw::Geometry::LOCKTEXCOORDS7,
rpGEOMETRYLOCKTEXCOORDS8 = 0x0800, rpGEOMETRYLOCKTEXCOORDS8 = rw::Geometry::LOCKTEXCOORDS8,
rpGEOMETRYLOCKTEXCOORDSALL = 0x0ff0, rpGEOMETRYLOCKTEXCOORDSALL = rw::Geometry::LOCKTEXCOORDSALL,
rpGEOMETRYLOCKALL = 0x0fff rpGEOMETRYLOCKALL = rw::Geometry::LOCKALL
}; };
RpGeometry *RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format); RpGeometry *RpGeometryCreate(RwInt32 numVert, RwInt32 numTriangles, RwUInt32 format);

View File

@ -70,7 +70,9 @@ RwTexDictionaryGtaStreamRead(RwStream *stream)
if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version)) if(!RwStreamFindChunk(stream, rwID_STRUCT, &size, &version))
return nil; return nil;
assert(size == 4); 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; return nil;
texDict = RwTexDictionaryCreate(); texDict = RwTexDictionaryCreate();
@ -153,11 +155,6 @@ RwTexDictionaryGtaStreamRead2(RwStream *stream, RwTexDictionary *texDict)
} }
#ifdef GTA_PC #ifdef GTA_PC
#ifdef RWLIBS
extern "C" RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
#else
WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); }
#endif
void void
ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8) ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8)
@ -177,6 +174,8 @@ ReadVideoCardCapsFile(uint32 &cap32, uint32 &cap24, uint32 &cap16, uint32 &cap8)
} }
} }
RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
bool bool
CheckVideoCardCaps(void) CheckVideoCardCaps(void)
{ {

View File

@ -415,6 +415,9 @@ WRAPPER RxNodeDefinition* RxNodeDefinitionGetMaterialScatter() { EAXJMP(0x5DDAA0
WRAPPER RxNodeDefinition* RxNodeDefinitionGetLight() { EAXJMP(0x5DF040); } WRAPPER RxNodeDefinition* RxNodeDefinitionGetLight() { EAXJMP(0x5DF040); }
WRAPPER RxNodeDefinition* RxNodeDefinitionGetPostLight() { EAXJMP(0x5DF560); } WRAPPER RxNodeDefinition* RxNodeDefinitionGetPostLight() { EAXJMP(0x5DF560); }
WRAPPER void RxD3D8AllInOneSetRenderCallBack(RxPipelineNode* node, RxD3D8AllInOneRenderCallBack callback) { EAXJMP(0x5DFC60); } WRAPPER void RxD3D8AllInOneSetRenderCallBack(RxPipelineNode* node, RxD3D8AllInOneRenderCallBack callback) { EAXJMP(0x5DFC60); }
WRAPPER RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags) { EAXJMP(0x59A350); }
#else #else
extern "C" extern "C"
@ -433,6 +436,8 @@ extern "C"
void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size); void* _rwVectorOpen(void* instance, RwInt32 offset, RwInt32 size);
RwBool _rwPluginRegistryOpen(); RwBool _rwPluginRegistryOpen();
RwBool _rwPluginRegistryClose(); RwBool _rwPluginRegistryClose();
RwInt32 _rwD3D8FindCorrectRasterFormat(RwRasterType type, RwInt32 flags);
} }
STARTPATCHES STARTPATCHES