[saco] Implement CUnkClass15 constructor

* Implement `CUnkClass15::sub_1006BE40()`
* Implement various RenderWare function calls
* Update `DoInitStuff()`
This commit is contained in:
RD42 2024-04-02 22:40:58 +08:00
parent c01899123c
commit 6506991783
7 changed files with 367 additions and 1 deletions

222
saco/game/rwstuff.cpp Normal file
View File

@ -0,0 +1,222 @@
#include "../main.h"
#include "rwstuff.h"
extern int iGtaVersion;
//----------------------------------------------------------
RwRaster* RwRasterCreate(int width, int height, int depth, int flags)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7FB270 : 0x7FB230;
RwRaster* pRaster = NULL;
_asm push flags
_asm push depth
_asm push height
_asm push width
_asm mov edx, dwFunc
_asm call edx
_asm mov pRaster, eax
_asm pop edx
_asm pop edx
_asm pop edx
_asm pop edx
return pRaster;
}
RwTexture* RwTextureCreate(RwRaster *raster)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7F3800 : 0x7F37C0;
RwTexture* pTexture = NULL;
_asm push raster
_asm mov edx, dwFunc
_asm call edx
_asm mov pTexture, eax
_asm pop edx
return pTexture;
}
RwFrame* RwFrameCreate()
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7F0450 : 0x7F0410;
RwFrame* pFrame = NULL;
_asm mov edx, dwFunc
_asm call edx
_asm mov pFrame, eax
return pFrame;
}
RwCamera* RwCameraCreate()
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7EE530 : 0x7EE4F0;
RwCamera* pCamera = NULL;
_asm mov edx, dwFunc
_asm call edx
_asm mov pCamera, eax
return pCamera;
}
void RpWorldAddCamera(RwCamera *camera)
{
DWORD dwWorld = *(DWORD*)0xC17038;
if(!dwWorld) return;
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x750F70 : 0x750F20;
_asm push camera
_asm push dwWorld
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
}
void RwObjectHasFrameSetFrame(RwCamera *camera, RwFrame *frame)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x804F30 : 0x804EF0l;
_asm push frame
_asm push camera
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
}
void SetCameraFrameAndZBuffer(RwCamera *camera, RwRaster *frameBuffer, RwRaster *zBuffer)
{
_asm mov ebx, camera
_asm mov edx, frameBuffer
_asm mov [ebx+0x60], edx
_asm mov edx, zBuffer
_asm mov [ebx+0x64], edx
}
void RwCameraSetClipPlane(RwCamera *camera, float farClip, float nearClip)
{
DWORD dwRwCameraSetFarClipPlane;
DWORD dwRwCameraSetNearClipPlane;
if(iGtaVersion == GTASA_VERSION_USA10)
{
dwRwCameraSetFarClipPlane = 0x7EE2A0;
dwRwCameraSetNearClipPlane = 0x7EE1D0;
}
else
{
dwRwCameraSetFarClipPlane = 0x7EE2E0;
dwRwCameraSetNearClipPlane = 0x7EE210;
}
_asm push farClip
_asm push camera
_asm mov edx, dwRwCameraSetFarClipPlane
_asm call edx
_asm pop edx
_asm pop edx
_asm push nearClip
_asm push camera
_asm mov edx, dwRwCameraSetNearClipPlane
_asm call edx
_asm pop edx
_asm pop edx
}
void RwCameraSetViewWindow(RwCamera *camera, VECTOR2D *viewWindow)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7EE450 : 0x7EE410;
_asm push viewWindow
_asm push camera
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
}
RpLight* RpLightCreate(int _type)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x752160 : 0x752110;
RpLight* pLight = NULL;
_asm push _type
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm mov pLight, eax
return pLight;
}
void RpLightSetColor(RpLight *light, RwRGBAReal *color)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x751AE0 : 0x751A90;
_asm push color
_asm push light
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
}
void RwCameraSetProjection(RwCamera *camera, int projection)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7EE3E0 : 0x7EE3A0;
_asm push projection
_asm push camera
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
}
void RwFrameTranslate(RwFrame *frame, VECTOR *v, int combine)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7F0E70 : 0x7F0E30;
_asm push combine
_asm push v
_asm push frame
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
_asm pop edx
}
VECTOR stru_10117384[3] = {
{1.0f, 0.0f, 0.0f},
{0.0f, 1.0f, 0.0f},
{0.0f, 0.0f, 1.0f},
};
void RwFrameRotate(RwFrame* frame, int axis, float angle)
{
DWORD dwFunc = (iGtaVersion != GTASA_VERSION_USA10) ? 0x7F1050 : 0x7F1010;
VECTOR* pAxis = &stru_10117384[axis];
_asm push 1
_asm push angle
_asm push pAxis
_asm push frame
_asm mov edx, dwFunc
_asm call edx
_asm pop edx
_asm pop edx
_asm pop edx
_asm pop edx
}

47
saco/game/rwstuff.h Normal file
View File

@ -0,0 +1,47 @@
#pragma once
struct RwRaster
{
char _gap0;
};
struct RwTexture
{
char _gap0;
};
struct RwFrame
{
char _gap0;
};
struct RwCamera
{
char _gap0;
};
struct RpLight
{
char _gap0;
};
struct RwRGBAReal
{
float r, g, b, a;
};
RwRaster* RwRasterCreate(int width, int height, int depth, int flags);
RwTexture* RwTextureCreate(RwRaster *raster);
RwFrame* RwFrameCreate();
RwCamera* RwCameraCreate();
void RpWorldAddCamera(RwCamera *camera);
void RwObjectHasFrameSetFrame(RwCamera *camera, RwFrame *frame);
void SetCameraFrameAndZBuffer(RwCamera *camera, RwRaster *frameBuffer, RwRaster *zBuffer);
void RwCameraSetClipPlane(RwCamera *camera, float farClip, float nearClip);
void RwCameraSetViewWindow(RwCamera *camera, VECTOR2D *viewWindow);
RpLight* RpLightCreate(int type);
void RpLightSetColor(RpLight *light, RwRGBAReal *color);
void RwCameraSetProjection(RwCamera *camera, int projection);
void RwFrameTranslate(RwFrame *frame, VECTOR *v, int combine);
void RwFrameRotate(RwFrame* frame, int axis, float angle);

View File

@ -22,9 +22,9 @@ CSpawnScreen *pSpawnScreen=0;
CNetGame *pNetGame=0; CNetGame *pNetGame=0;
//DWORD dword_1026EB98=0; //DWORD dword_1026EB98=0;
CFontRender *pDefaultFont=0; CFontRender *pDefaultFont=0;
//DWORD dword_1026EBA8=0;
CUnkClass13 *pUnkClass13=0; CUnkClass13 *pUnkClass13=0;
CUnkClass14 *pUnkClass14=0; CUnkClass14 *pUnkClass14=0;
CUnkClass15 *pUnkClass15=0;
BOOL bGameInited=FALSE; BOOL bGameInited=FALSE;
@ -366,6 +366,7 @@ void DoInitStuff()
pUnkClass12 = new CUnkClass12(); pUnkClass12 = new CUnkClass12();
pUnkClass13 = new CUnkClass13(pD3DDevice); pUnkClass13 = new CUnkClass13(pD3DDevice);
pUnkClass14 = new CUnkClass14(pD3DDevice); pUnkClass14 = new CUnkClass14(pD3DDevice);
pUnkClass15 = new CUnkClass15();
// TODO: DoInitStuff // TODO: DoInitStuff

View File

@ -76,6 +76,7 @@ typedef struct _GAME_SETTINGS {
#include "unkclass12.h" #include "unkclass12.h"
#include "unkclass13.h" #include "unkclass13.h"
#include "unkclass14.h" #include "unkclass14.h"
#include "unkclass15.h"
void SetStringFromCommandLine(char *szCmdLine, char *szString); void SetStringFromCommandLine(char *szCmdLine, char *szString);
void SetStringFromQuotedCommandLine(char *szCmdLine, char *szString); void SetStringFromQuotedCommandLine(char *szCmdLine, char *szString);

View File

@ -185,6 +185,12 @@
<File <File
RelativePath=".\game\playerped.h"> RelativePath=".\game\playerped.h">
</File> </File>
<File
RelativePath=".\game\rwstuff.cpp">
</File>
<File
RelativePath=".\game\rwstuff.h">
</File>
<File <File
RelativePath=".\game\scripting.cpp"> RelativePath=".\game\scripting.cpp">
</File> </File>
@ -585,6 +591,12 @@
<File <File
RelativePath=".\unkclass14.h"> RelativePath=".\unkclass14.h">
</File> </File>
<File
RelativePath=".\unkclass15.cpp">
</File>
<File
RelativePath=".\unkclass15.h">
</File>
<File <File
RelativePath=".\unkclass2.cpp"> RelativePath=".\unkclass2.cpp">
</File> </File>

62
saco/unkclass15.cpp Normal file
View File

@ -0,0 +1,62 @@
#include "main.h"
CUnkClass15::CUnkClass15()
{
m_pCamera = NULL;
m_pFrame = NULL;
m_pTexture = NULL;
field_18 = 0;
m_pLight = NULL;
sub_1006BE40();
}
bool CUnkClass15::sub_1006BE40()
{
RwRGBAReal color;
VECTOR v;
VECTOR2D viewWindow;
m_pLight = RpLightCreate(2);
if(!m_pLight) return false;
color.r = 1.0f;
color.g = 1.0f;
color.b = 1.0f;
color.a = 1.0f;
RpLightSetColor(m_pLight, &color);
m_pRaster1 = RwRasterCreate(256, 256, 0, 1285);
m_pRaster2 = RwRasterCreate(256, 256, 0, 1);
m_pCamera = RwCameraCreate();
m_pFrame = RwFrameCreate();
v.X = 0.0f;
v.Y = 0.0f;
v.Z = 50.0f;
RwFrameTranslate(m_pFrame, &v, 1);
RwFrameRotate(m_pFrame, 0, 90.0f);
if(!m_pCamera || !m_pFrame || !m_pRaster1 || !m_pRaster2)
return false;
SetCameraFrameAndZBuffer(m_pCamera, m_pRaster1, m_pRaster2);
RwObjectHasFrameSetFrame(m_pCamera, m_pFrame);
RwCameraSetClipPlane(m_pCamera, 300.0f, 0.01f);
viewWindow.X = 0.5f;
viewWindow.Y = 0.5f;
RwCameraSetViewWindow(m_pCamera, &viewWindow);
RwCameraSetProjection(m_pCamera, 1);
RpWorldAddCamera(m_pCamera);
m_pTexture = RwTextureCreate(m_pRaster1);
return true;
}

21
saco/unkclass15.h Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include "game/rwstuff.h"
class CUnkClass15
{
private:
RwCamera* m_pCamera;
RwFrame* m_pFrame;
RpLight* m_pLight;
RwTexture* m_pTexture;
RwRaster* m_pRaster1;
RwRaster* m_pRaster2;
int field_18;
public:
CUnkClass15();
bool sub_1006BE40();
};