This repository has been archived by the owner on Jan 6, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathmain.cpp
229 lines (210 loc) · 6.49 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include "StdInc.h"
static bool bGammaChanged;
static D3DGAMMARAMP savedGamma;
static RwBool Initialize(void)
{
RsGlobal.appName = RWSTRING("GTA: San Andreas");
RsGlobal.maximumWidth = DEFAULT_SCREEN_WIDTH;
RsGlobal.maximumHeight = DEFAULT_SCREEN_HEIGHT;
RsGlobal.ps = (void*)30;
//RsGlobal.frameLimit = 30;
RsGlobal.quit = false;
RsGlobal.keyboard.inputDeviceType = rsKEYBOARD;
RsGlobal.keyboard.inputEventHandler = NULL;
RsGlobal.keyboard.used = false;
RsGlobal.mouse.inputDeviceType = rsMOUSE;
RsGlobal.mouse.inputEventHandler = NULL;
RsGlobal.mouse.used = false;
RsGlobal.pad.inputDeviceType = rsPAD;
RsGlobal.pad.inputEventHandler = NULL;
RsGlobal.pad.used = false;
return RsInitialize();
}
static RwBool Initialize3D(void *param)
{
return RsRwInitialize(param) && CGame::InitialiseRenderWare();
}
static void Terminate3D(void)
{
CGame::ShutdownRenderWare();
if(bGammaChanged)
{
IDirect3DDevice9 *pDevice = (IDirect3DDevice9*)RwD3D9GetCurrentD3DDevice();
pDevice->SetGammaRamp(0, D3DSGR_CALIBRATE, &savedGamma);
bGammaChanged = false;
}
RsRwTerminate();
}
static RwBool AttachPlugins(void)
{
return RpWorldPluginAttach() &&
RpSkinPluginAttach() &&
RtAnimInitialize() &&
RpHAnimPluginAttach() &&
NodeNamePluginAttach() &&
CVisibilityPlugins::PluginAttach() &&
RpAnimBlendPluginAttach() &&
CTxdStore::PluginAttach() &&
RpMatFXPluginAttach() &&
RpUVAnimPluginAttach() &&
CCustomBuildingRenderer::PluginAttach() &&
CCarFxRenderer::RegisterPlugins() &&
RpAnisotPluginAttach() &&
BreakablePluginAttach() &&
CCollisionPlugin::PluginAttach() &&
C2dEffect::PluginAttach() &&
PipelinePluginAttach();
}
static void Idle(void *param)
{
// TODO: some more timer stuff at start
CTimer::Update();
CSprite2d::InitPerFrame();
CFont::InitPerFrame();
CPointLights::NumLights = 0;
CGame::Process();
AudioEngine.Service();
SetLightsWithTimeOfDayColour(Scene);
bool bOk = param;
if(bOk)
{
if(FrontEndMenuManager.bMenuActive)
{
RsCameraShowRaster(Scene.Camera);
CDraw::CalculateAspectRatio();
CameraSize(Scene.Camera, (RwRect *)param, tan(CDraw::GetFOV() * M_PI/360), CDraw::GetAspectRatio());
CVisibilityPlugins::SetRenderWareCamera(Scene.Camera);
RwCameraClear(Scene.Camera, gColourTop, 2);
if(!RsCameraBeginUpdate(Scene.Camera))
{
return false;
}
goto LABEL_16;
}
RwV2d mousePos;
mousePos.x = RsGlobal.maximumWidth * 0.5;
mousePos.y = RsGlobal.maximumHeight * 0.5;
RsMouseSetPos(&mousePos);
CRenderer::ConstructRenderList();
CRenderer::PreRender();
CWorld::ProcessPedsAfterPreRender();
g_realTimeShadowMan.Update();
CMirrors::BeforeMainRender();
short sColours[7];
if(CWeather::LightingFlash)
{
sColours[0] = 255;
sColours[1] = 255;
sColours[2] = 255;
sColours[3] = 255;
sColours[4] = 255;
sColours[5] = 255;
sColours[6] = 255;
}
else
{
sColours[0] = CTimeCycle::m_CurrentColours[0];
sColours[1] = CTimeCycle::m_CurrentColours[1];
sColours[2] = CTimeCycle::m_CurrentColours[2];
sColours[3] = CTimeCycle::m_CurrentColours[3];
sColours[4] = CTimeCycle::m_CurrentColours[4];
sColours[5] = CTimeCycle::m_CurrentColours[5];
sColours[6] = 255;
}
bOk = DoRWStuffStartOfFrame_Horizon(sColours[0], sColours[1], sColours[2], sColours[3], sColours[4], sColours[5], sColours[6]);
if(bOk)
{
DefinedState();
RwCameraSetFarClipPlane(Camera, CTimeCycle::0x50);
RwCameraSetFogDistanceMacro(Camera, CTimeCycle::0x54);
CMirrors::RenderMirrorBuffer();
RenderScene();
CVisibilityPlugins::RenderWeaponPedsForPC();
// HERE: called unk func: sub_53E8D0
RenderEffects();
if(TheCamera.uiBlurType == 0 || TheCamera.uiBlurType == 2)
{
if(TheCamera.fPositionAlongSpline > 0.0)
{
TheCamera.SetMotionBlurAlpha(150);
}
}
TheCamera.RenderMotionBlur();
Render2dStuff();
LABEL_16:
if(FrontEndMenuManager.bMenuActive)
{
FrontEndMenuManager.RenderMenus();
}
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, 0);
DoFade();
CHud::DrawAfterFade();
// sub_69EFC0
// dummy_71A210
if(CCredits::bCreditsGoing)
{
if(!FrontEndMenuManager.bMenuActive)
{
CCredits::Render();
}
if(CCredits::bCreditsGoing)
{
if(!FrontEndMenuManager.bMenuActive)
{
CCredits::Render();
}
}
}
DoRwStuffEndOfFrame(true);
}
}
// Render(); here?
}
RsEventStatus AppEventHandler(RsEvent event, void *param)
{
switch(event)
{
case rsINITIALIZE:
{
CGame::InitialiseOnceBeforeRW();
return Initialize() ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsCAMERASIZE:
{
CameraSize(Scene.Camera, (RwRect *)param, tan(CDraw::GetFOV() * M_PI / 360), DEFAULT_ASPECTRATIO);
return rsEVENTPROCESSED;
}
case rsRWINITIALIZE:
{
return Initialize3D(param) ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsRWTERMINATE:
{
Terminate3D();
return rsEVENTPROCESSED;
}
case rsPLUGINATTACH:
{
return AttachPlugins() ? rsEVENTPROCESSED : rsEVENTERROR;
}
case rsINPUTDEVICEATTACH:
{
AttachInputDevices();
return rsEVENTPROCESSED;
}
case rsIDLE:
{
Idle(param);
return rsEVENTPROCESSED;
}
case rsQUITAPP:
{
CGame::FinalShutdown();
return rsEVENTPROCESSED;
}
default:
{
return rsEVENTNOTPROCESSED;
}
}
}