Rev 11 | Rev 20 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | #include "init.h" |
2 | |||
3 | #include <stdlib.h> |
||
4 | #include <time.h> |
||
5 | |||
6 | #include "car.h" |
||
7 | #include "controls.h" |
||
8 | #include "depth.h" |
||
9 | #include "displays.h" |
||
10 | #include "drfile.h" |
||
11 | #include "drmem.h" |
||
12 | #include "errors.h" |
||
13 | #include "flicplay.h" |
||
14 | #include "globvars.h" |
||
15 | #include "globvrkm.h" |
||
16 | #include "globvrpb.h" |
||
17 | #include "grafdata.h" |
||
18 | #include "graphics.h" |
||
19 | #include "harness/config.h" |
||
20 | #include "harness/trace.h" |
||
21 | #include "loading.h" |
||
22 | #include "loadsave.h" |
||
23 | #include "netgame.h" |
||
24 | #include "network.h" |
||
25 | #include "oil.h" |
||
26 | #include "opponent.h" |
||
27 | #include "pd/sys.h" |
||
28 | #include "pedestrn.h" |
||
29 | #include "piping.h" |
||
30 | #include "powerup.h" |
||
31 | #include "pratcam.h" |
||
32 | #include "raycast.h" |
||
33 | #include "replay.h" |
||
34 | #include "skidmark.h" |
||
35 | #include "sound.h" |
||
36 | #include "spark.h" |
||
37 | #include "trig.h" |
||
38 | #include "utility.h" |
||
39 | #include "world.h" |
||
40 | |||
18 | pmbaty | 41 | #include "brender.h" |
1 | pmbaty | 42 | |
43 | int gGame_initialized; |
||
44 | int gBr_initialized; |
||
45 | int gBrZb_initialized; |
||
46 | int gInitialisation_finished; |
||
47 | int gRender_indent; |
||
48 | tU32 gAustere_time; |
||
49 | int gInitial_rank; |
||
50 | int gCredits_per_rank[3]; |
||
51 | int gInitial_credits[3]; |
||
52 | int gNet_mode_of_last_game; |
||
53 | br_material* gDefault_track_material; |
||
54 | |||
55 | // IDA: void __cdecl AllocateSelf() |
||
56 | void AllocateSelf(void) { |
||
57 | LOG_TRACE("()"); |
||
58 | |||
59 | gSelf = BrActorAllocate(BR_ACTOR_NONE, NULL); |
||
60 | if (gSelf == NULL) { |
||
61 | FatalError(kFatalError_AllocateSelf); |
||
62 | } |
||
63 | gSelf = BrActorAdd(gNon_track_actor, gSelf); |
||
64 | if (gSelf == NULL) { |
||
65 | FatalError(kFatalError_AllocateSelf); |
||
66 | } |
||
67 | } |
||
68 | |||
69 | // IDA: void __cdecl AllocateCamera() |
||
70 | void AllocateCamera(void) { |
||
71 | br_camera* camera_ptr; |
||
72 | int i; |
||
73 | LOG_TRACE("()"); |
||
74 | |||
75 | for (i = 0; i < COUNT_OF(gCamera_list); i++) { |
||
76 | gCamera_list[i] = BrActorAllocate(BR_ACTOR_CAMERA, NULL); |
||
77 | if (gCamera_list[i] == NULL) { |
||
78 | FatalError(kFatalError_AllocateCamera); |
||
79 | } |
||
80 | |||
81 | camera_ptr = gCamera_list[i]->type_data; |
||
82 | camera_ptr->type = BR_CAMERA_PERSPECTIVE_FOV; |
||
83 | camera_ptr->field_of_view = BrDegreeToAngle(gCamera_angle); |
||
84 | camera_ptr->hither_z = gCamera_hither; |
||
85 | camera_ptr->yon_z = gCamera_yon; |
||
86 | camera_ptr->aspect = (double)gWidth / (double)gHeight; |
||
87 | } |
||
88 | |||
89 | gCamera_list[0] = BrActorAdd(gSelf, gCamera_list[0]); |
||
90 | if (gCamera_list[0] == NULL) { |
||
91 | FatalError(kFatalError_AllocateCamera); |
||
92 | } |
||
93 | gCamera_list[1] = BrActorAdd(gUniverse_actor, gCamera_list[1]); |
||
94 | if (gCamera_list[1] == NULL) { |
||
95 | FatalError(kFatalError_AllocateCamera); |
||
96 | } |
||
97 | gCamera = gCamera_list[0]; |
||
98 | gRearview_camera = BrActorAllocate(BR_ACTOR_CAMERA, NULL); |
||
99 | if (gRearview_camera == NULL) { |
||
100 | FatalError(kFatalError_AllocateCamera); |
||
101 | } |
||
102 | |||
103 | gRearview_camera->t.t.mat.m[2][2] = -1.0f; |
||
104 | camera_ptr = (br_camera*)gRearview_camera->type_data; |
||
105 | camera_ptr->hither_z = gCamera_hither; |
||
106 | camera_ptr->type = BR_CAMERA_PERSPECTIVE_FOV; |
||
107 | camera_ptr->yon_z = gCamera_yon; |
||
108 | camera_ptr->field_of_view = BrDegreeToAngle(gCamera_angle); |
||
109 | camera_ptr->aspect = (double)gWidth / (double)gHeight; |
||
110 | gRearview_camera = BrActorAdd(gSelf, gRearview_camera); |
||
111 | if (gRearview_camera == NULL) { |
||
112 | FatalError(kFatalError_AllocateCamera); |
||
113 | } |
||
114 | SetSightDistance(camera_ptr->yon_z); |
||
115 | } |
||
116 | |||
117 | // IDA: void __cdecl ReinitialiseForwardCamera() |
||
118 | void ReinitialiseForwardCamera(void) { |
||
119 | br_camera* camera_ptr; |
||
120 | float the_angle; |
||
121 | float d; |
||
122 | float w; |
||
123 | LOG_TRACE("()"); |
||
124 | |||
125 | camera_ptr = (br_camera*)gCamera->type_data; |
||
126 | if (gProgram_state.cockpit_on) { |
||
127 | the_angle = gCamera_angle / 2.0; |
||
128 | |||
129 | d = atan( |
||
130 | tandeg(the_angle) |
||
131 | * (double)gRender_screen->height |
||
132 | / (double)(gProgram_state.current_car.render_bottom[0] - gProgram_state.current_car.render_top[0])) |
||
133 | * 114.5915590261646; |
||
134 | camera_ptr->field_of_view = BrDegreeToAngle(d); |
||
135 | BrMatrix34Identity(&gCamera->t.t.mat); |
||
136 | gCamera->t.t.mat.m[3][0] = gProgram_state.current_car.driver_x_offset; |
||
137 | gCamera->t.t.mat.m[3][1] = gProgram_state.current_car.driver_y_offset; |
||
138 | gCamera->t.t.mat.m[3][2] = gProgram_state.current_car.driver_z_offset; |
||
139 | w = (float)(gRender_screen->base_y |
||
140 | + (gRender_screen->height / 2) |
||
141 | - (gProgram_state.current_car.render_bottom[0] + gProgram_state.current_car.render_top[0]) / 2); |
||
142 | |||
143 | gCamera->t.t.mat.m[2][1] = tandeg(d / 2.0) * w * 2.0 / (float)gRender_screen->height; |
||
144 | camera_ptr->aspect = (float)gWidth / gHeight; |
||
145 | camera_ptr->yon_z = gYon_multiplier * gCamera_yon; |
||
146 | if (gProgram_state.which_view == eView_left) { |
||
147 | DRMatrix34PostRotateY( |
||
148 | &gCamera->t.t.mat, |
||
149 | BrDegreeToAngle(gProgram_state.current_car.head_left_angle)); |
||
150 | } else if (gProgram_state.which_view == eView_right) { |
||
151 | DRMatrix34PostRotateY( |
||
152 | &gCamera->t.t.mat, |
||
153 | BrDegreeToAngle(gProgram_state.current_car.head_right_angle)); |
||
154 | } |
||
155 | gCamera->t.t.mat.m[3][0] = gProgram_state.current_car.driver_x_offset; |
||
156 | gCamera->t.t.mat.m[3][1] = gProgram_state.current_car.driver_y_offset; |
||
157 | gCamera->t.t.mat.m[3][2] = gProgram_state.current_car.driver_z_offset; |
||
158 | SetSightDistance(camera_ptr->yon_z); |
||
159 | MungeForwardSky(); |
||
160 | } |
||
161 | AssertYons(); |
||
162 | } |
||
163 | |||
164 | // IDA: void __cdecl AllocateRearviewPixelmap() |
||
165 | void AllocateRearviewPixelmap(void) { |
||
166 | char* rear_screen_pixels; |
||
167 | LOG_TRACE("()"); |
||
168 | |||
169 | if (gRearview_screen) { |
||
170 | BrMemFree(gRearview_screen->pixels); |
||
171 | BrPixelmapFree(gRearview_screen); |
||
172 | BrPixelmapFree(gRearview_depth_buffer); |
||
173 | gRearview_screen = NULL; |
||
174 | } |
||
175 | if (gProgram_state.mirror_on) { |
||
176 | rear_screen_pixels = BrMemAllocate( |
||
177 | (gProgram_state.current_car.mirror_bottom - gProgram_state.current_car.mirror_top + 1) |
||
178 | * (gProgram_state.current_car.mirror_right - gProgram_state.current_car.mirror_left + 4) |
||
179 | * gGraf_specs[gGraf_spec_index].depth_bytes, |
||
180 | kMem_rear_screen_pixels); |
||
181 | if (gScreen->row_bytes < 0) { |
||
182 | BrFatal("..\\..\\source\\common\\init.c", 260, "Bruce bug at line %d, file ..\\..\\source\\common\\init.c", 4); |
||
183 | } |
||
184 | gRearview_screen = DRPixelmapAllocate( |
||
185 | gScreen->type, |
||
186 | gProgram_state.current_car.mirror_right - gProgram_state.current_car.mirror_left, |
||
187 | gProgram_state.current_car.mirror_bottom - gProgram_state.current_car.mirror_top, |
||
188 | rear_screen_pixels, |
||
189 | 0); |
||
190 | |||
191 | gRearview_screen->origin_x = gRearview_screen->width / 2; |
||
192 | gRearview_screen->origin_y = gRearview_screen->height / 2; |
||
193 | gRearview_depth_buffer = BrPixelmapMatch(gRearview_screen, BR_PMMATCH_DEPTH_16); |
||
194 | } |
||
195 | } |
||
196 | |||
197 | // IDA: void __cdecl ReinitialiseRearviewCamera() |
||
198 | void ReinitialiseRearviewCamera(void) { |
||
199 | br_camera* camera_ptr; |
||
200 | LOG_TRACE("()"); |
||
201 | |||
202 | camera_ptr = gRearview_camera->type_data; |
||
203 | camera_ptr->field_of_view = BrDegreeToAngle(gProgram_state.current_car.rearview_camera_angle); |
||
204 | camera_ptr->aspect = (gProgram_state.current_car.mirror_right - gProgram_state.current_car.mirror_left) / (float)(gProgram_state.current_car.mirror_bottom - gProgram_state.current_car.mirror_top); |
||
205 | gRearview_camera->t.t.translate.t.v[0] = gProgram_state.current_car.mirror_x_offset; |
||
206 | gRearview_camera->t.t.translate.t.v[1] = gProgram_state.current_car.mirror_y_offset; |
||
207 | gRearview_camera->t.t.translate.t.v[2] = gProgram_state.current_car.mirror_z_offset; |
||
208 | AllocateRearviewPixelmap(); |
||
209 | MungeRearviewSky(); |
||
210 | } |
||
211 | |||
212 | // IDA: void __cdecl ReinitialiseRenderStuff() |
||
213 | void ReinitialiseRenderStuff(void) { |
||
214 | int x_diff; |
||
215 | int y_diff; |
||
216 | LOG_TRACE("()"); |
||
217 | |||
218 | if (gProgram_state.cockpit_on) { |
||
219 | gProgram_state.current_render_left = gProgram_state.current_car.render_left[gProgram_state.cockpit_image_index]; |
||
220 | gProgram_state.current_render_top = gProgram_state.current_car.render_top[gProgram_state.cockpit_image_index]; |
||
221 | gProgram_state.current_render_right = gProgram_state.current_car.render_right[gProgram_state.cockpit_image_index]; |
||
222 | gProgram_state.current_render_bottom = gProgram_state.current_car.render_bottom[gProgram_state.cockpit_image_index]; |
||
223 | } else { |
||
224 | gProgram_state.current_render_top = (gGraf_specs[gGraf_spec_index].total_height / 18 & ~1) * gRender_indent; |
||
225 | gProgram_state.current_render_left = (gGraf_specs[gGraf_spec_index].total_width / 18 & ~3) * gRender_indent; |
||
226 | x_diff = gGraf_specs[gGraf_spec_index].total_width - gProgram_state.current_render_left; |
||
227 | y_diff = gGraf_specs[gGraf_spec_index].total_height - gProgram_state.current_render_top; |
||
228 | gProgram_state.current_render_right = x_diff; |
||
229 | gProgram_state.current_render_bottom = y_diff; |
||
230 | } |
||
231 | } |
||
232 | |||
233 | // IDA: void __cdecl InstallFindFailedHooks() |
||
234 | void InstallFindFailedHooks(void) { |
||
235 | LOG_TRACE("()"); |
||
236 | NOT_IMPLEMENTED(); |
||
237 | } |
||
238 | |||
239 | // IDA: void __cdecl AllocateStandardLamp() |
||
240 | void AllocateStandardLamp(void) { |
||
18 | pmbaty | 241 | br_actor* lamp; |
242 | int i; |
||
243 | |||
244 | for (i = 0; i < gNumber_of_lights; i++) { |
||
245 | BrActorAdd(gUniverse_actor, gLight_array[i]); |
||
246 | lamp = gLight_array[i]->children; |
||
247 | if (lamp) { |
||
248 | BrActorRemove(lamp); |
||
249 | gLight_array[i]->children = NULL; |
||
250 | BrActorFree(lamp); |
||
251 | } |
||
252 | BrLightEnable(gLight_array[i]); |
||
253 | } |
||
1 | pmbaty | 254 | } |
255 | |||
256 | // IDA: void __cdecl InitializeBRenderEnvironment() |
||
257 | void InitializeBRenderEnvironment(void) { |
||
258 | br_model* arrow_model; |
||
259 | LOG_TRACE("()"); |
||
260 | |||
261 | gBr_initialized = 1; |
||
262 | InstallDRMemCalls(); |
||
263 | InstallDRFileCalls(); |
||
264 | SetBRenderScreenAndBuffers(0, 0, 0, 0); |
||
265 | gUniverse_actor = BrActorAllocate(BR_ACTOR_NONE, NULL); |
||
266 | if (gUniverse_actor == NULL) { |
||
267 | FatalError(kFatalError_AllocateRootActor); |
||
268 | } |
||
269 | gUniverse_actor->identifier = BrResStrDup(gUniverse_actor, "Root"); |
||
270 | BrEnvironmentSet(gUniverse_actor); |
||
271 | gNon_track_actor = BrActorAllocate(BR_ACTOR_NONE, NULL); |
||
272 | if (gNon_track_actor == NULL) { |
||
273 | FatalError(kFatalError_AllocateRootActor); |
||
274 | } |
||
275 | BrActorAdd(gUniverse_actor, gNon_track_actor); |
||
276 | gDont_render_actor = BrActorAllocate(BR_ACTOR_NONE, 0); |
||
277 | if (gDont_render_actor == NULL) { |
||
278 | FatalError(kFatalError_AllocateRootActor); |
||
279 | } |
||
280 | gDont_render_actor->render_style = BR_RSTYLE_NONE; |
||
281 | BrActorAdd(gUniverse_actor, gDont_render_actor); |
||
282 | AllocateSelf(); |
||
283 | AllocateCamera(); |
||
284 | arrow_model = LoadModel("CPOINT.DAT"); |
||
285 | BrModelAdd(arrow_model); |
||
286 | gArrow_actor = LoadActor("CPOINT.ACT"); |
||
287 | gArrow_actor->model = arrow_model; |
||
288 | } |
||
289 | |||
290 | // IDA: void __cdecl InitBRFonts() |
||
291 | void InitBRFonts(void) { |
||
292 | LOG_TRACE("()"); |
||
293 | gBig_font = LoadBRFont("BIGFONT.FNT"); |
||
294 | gFont_7 = LoadBRFont("FONT7.FNT"); |
||
295 | gHeadup_font = LoadBRFont("HEADUP.FNT"); |
||
296 | } |
||
297 | |||
298 | // IDA: void __cdecl AustereWarning() |
||
299 | void AustereWarning(void) { |
||
300 | LOG_TRACE("()"); |
||
301 | |||
302 | ClearEntireScreen(); |
||
303 | |||
304 | if (gAusterity_mode) { |
||
305 | LoadFont(FONT_GRNLIT); |
||
306 | TransDRPixelmapText(gBack_screen, |
||
307 | (gBack_screen->width - DRTextWidth(&gFonts[FONT_GRNLIT], GetMiscString(kMiscString_LOW_MEMORY_MODE_INVOKED))) / 2, |
||
308 | 0, |
||
309 | &gFonts[FONT_GRNLIT], |
||
310 | GetMiscString(kMiscString_LOW_MEMORY_MODE_INVOKED), |
||
311 | gBack_screen->width); |
||
312 | PDScreenBufferSwap(0); |
||
313 | gAustere_time = PDGetTotalTime(); |
||
314 | DisposeFont(FONT_GRNLIT); |
||
315 | } else { |
||
316 | gAustere_time = gAusterity_mode; |
||
317 | } |
||
318 | } |
||
319 | |||
320 | // IDA: void __cdecl InitLineStuff() |
||
321 | void InitLineStuff(void) { |
||
322 | LOG_TRACE("()"); |
||
323 | NOT_IMPLEMENTED(); |
||
324 | } |
||
325 | |||
326 | // IDA: void __cdecl InitSmokeStuff() |
||
327 | void InitSmokeStuff(void) { |
||
328 | //static br_token_value fadealpha[3]; // Pierre-Marie Baty -- unused variable |
||
329 | //tPath_name path; // Pierre-Marie Baty -- unused variable |
||
330 | LOG_TRACE("()"); |
||
331 | NOT_IMPLEMENTED(); |
||
332 | } |
||
333 | |||
334 | // IDA: void __cdecl Init2DStuff() |
||
335 | void Init2DStuff(void) { |
||
336 | //br_camera* camera; // Pierre-Marie Baty -- unused variable |
||
337 | //static br_token_value fadealpha[3]; // Pierre-Marie Baty -- unused variable |
||
338 | //tPath_name path; // Pierre-Marie Baty -- unused variable |
||
339 | //br_scalar prat_u; // Pierre-Marie Baty -- unused variable |
||
340 | //br_scalar prat_v; // Pierre-Marie Baty -- unused variable |
||
341 | LOG_TRACE("()"); |
||
342 | NOT_IMPLEMENTED(); |
||
343 | } |
||
344 | |||
345 | // IDA: void __usercall InitialiseApplication(int pArgc@<EAX>, char **pArgv@<EDX>) |
||
346 | void InitialiseApplication(int pArgc, char** pArgv) { |
||
347 | |||
11 | pmbaty | 348 | if (harness_game_config.gore_check) { |
1 | pmbaty | 349 | gProgram_state.sausage_eater_mode = gSausage_override ? 1 : (PDGetGorePassword() ? 0 : 1); |
350 | PDDisplayGoreworthiness(!gProgram_state.sausage_eater_mode); |
||
351 | } else { |
||
352 | gProgram_state.sausage_eater_mode = gSausage_override; |
||
353 | } |
||
354 | |||
355 | MAMSInitMem(); |
||
356 | PrintMemoryDump(gSausage_override, *pArgv); |
||
357 | if (gAustere_override || PDDoWeLeadAnAustereExistance() != 0) { |
||
358 | gAusterity_mode = 1; |
||
359 | } |
||
360 | |||
361 | srand(time(NULL)); |
||
362 | BrV1dbBeginWrapper_Float(); |
||
363 | CreateStainlessClasses(); |
||
364 | InitWobbleStuff(); |
||
365 | LoadGeneralParameters(); |
||
366 | DefaultNetName(); |
||
367 | strcpy(gProgram_state.player_name[0], "MAX DAMAGE"); |
||
368 | strcpy(gProgram_state.player_name[1], "DIE ANNA"); |
||
369 | RestoreOptions(); |
||
370 | LoadKeyMapping(); |
||
371 | if (!PDInitScreenVars(pArgc, pArgv)) { |
||
372 | FatalError(kFatalError_UnsupportedScreenDepth); |
||
373 | } |
||
374 | CalcGrafDataIndex(); |
||
375 | PDInitScreen(); |
||
376 | InitializeBRenderEnvironment(); |
||
377 | InitDRFonts(); |
||
378 | InitBRFonts(); |
||
379 | LoadMiscStrings(); |
||
380 | LoadInRegistees(); |
||
381 | FinishLoadingGeneral(); |
||
382 | InitializePalettes(); |
||
383 | AustereWarning(); |
||
384 | LoadInterfaceStrings(); |
||
385 | InitializeActionReplay(); |
||
386 | FlicPaletteAllocate(); |
||
387 | InitInterfaceLoadState(); |
||
388 | InitTransientBitmaps(); |
||
389 | InitSound(); |
||
390 | InitHeadups(); |
||
391 | gDefault_track_material = BrMaterialAllocate("gDefault_track_material"); |
||
392 | gDefault_track_material->index_base = 227; |
||
393 | gDefault_track_material->index_range = 1; |
||
394 | BrMaterialAdd(gDefault_track_material); |
||
395 | InitShadow(); |
||
396 | InitFlics(); |
||
397 | AllocateStandardLamp(); |
||
398 | InitAmbience(); |
||
399 | LoadOpponents(); |
||
400 | LoadPowerups(); |
||
401 | LoadRaces(gRace_list, &gNumber_of_races, -1); |
||
402 | InitPaletteAnimate(); |
||
403 | InitRayCasting(); |
||
404 | InitDepthEffects(); |
||
405 | InitialiseStorageSpace(&gOur_car_storage_space, 40, 2, 40, 30); |
||
406 | InitialiseStorageSpace(&gTheir_cars_storage_space, 300, 50, 500, 200); |
||
407 | InitialiseStorageSpace(&gPedestrians_storage_space, 500, 10, 0, 0); |
||
408 | InitialiseStorageSpace(&gTrack_storage_space, 400, 50, 400, 1000); |
||
409 | InitOilSpills(); |
||
410 | if (gAustere_time) { |
||
411 | while (PDGetTotalTime() - gAustere_time < 2000) { |
||
412 | } |
||
413 | } |
||
414 | ClearEntireScreen(); |
||
415 | InitSkids(); |
||
416 | InitPeds(); |
||
417 | gProgram_state.track_spec.the_actor = NULL; |
||
418 | gCD_is_in_drive = TestForOriginalCarmaCDinDrive(); |
||
419 | SwitchToLoresMode(); |
||
420 | PrintMemoryDump(0, "AFTER APPLICATION INITIALISATION"); |
||
421 | } |
||
422 | |||
423 | // IDA: void __usercall InitialiseDeathRace(int pArgc@<EAX>, char **pArgv@<EDX>) |
||
424 | void InitialiseDeathRace(int pArgc, char** pArgv) { |
||
425 | PDInitialiseSystem(); |
||
426 | |||
427 | InitialiseApplication(pArgc, pArgv); |
||
428 | // dword_112DF8 = 1; // never checked by game |
||
429 | } |
||
430 | |||
431 | // IDA: void __usercall InitGame(int pStart_race@<EAX>) |
||
432 | void InitGame(int pStart_race) { |
||
433 | int i; |
||
434 | LOG_TRACE("(%d)", pStart_race); |
||
435 | |||
436 | gWaiting_for_unpause = 1; |
||
437 | gWait_for_it = 1; |
||
438 | if (gNet_mode != eNet_mode_none) { |
||
439 | gCredit_period = gCredit_period_network[gCurrent_net_game->type]; |
||
440 | } else { |
||
441 | gCredit_period = gCredit_period_single[gProgram_state.skill_level]; |
||
442 | } |
||
443 | SwitchToRealResolution(); |
||
444 | gGame_to_load = -1; |
||
445 | gCurrent_race.number_of_racers = 0; |
||
446 | LoadHeadupImages(); |
||
447 | gGame_initialized = 1; |
||
448 | gNet_mode_of_last_game = gNet_mode; |
||
449 | gNo_races_yet = 1; |
||
450 | NetPlayerStatusChanged(ePlayer_status_loading); |
||
451 | gProgram_state.current_race_index = pStart_race; |
||
452 | if (harness_game_info.mode == eGame_carmageddon_demo || harness_game_info.mode == eGame_splatpack_demo || harness_game_info.mode == eGame_splatpack_xmas_demo) { |
||
453 | gProgram_state.current_car.power_up_levels[0] = gDemo_armour; |
||
454 | gProgram_state.current_car.power_up_levels[1] = gDemo_power; |
||
455 | gProgram_state.current_car.power_up_levels[2] = gDemo_offensive; |
||
456 | } else { |
||
457 | for (i = 0; i < COUNT_OF(gProgram_state.current_car.power_up_levels); i++) { |
||
458 | gProgram_state.current_car.power_up_levels[i] = 0; |
||
459 | } |
||
460 | } |
||
461 | for (i = 0; i < gNumber_of_races; i++) { |
||
462 | gRace_list[i].been_there_done_that = 0; |
||
463 | } |
||
464 | for (i = 0; i < gNumber_of_racers; i++) { |
||
465 | gOpponents[i].dead = 0; |
||
466 | } |
||
467 | gProgram_state.rank = gInitial_rank; |
||
468 | gProgram_state.credits = gInitial_credits[gProgram_state.skill_level]; |
||
469 | gProgram_state.credits_per_rank = gCredits_per_rank[gProgram_state.skill_level]; |
||
470 | gProgram_state.number_of_cars = 1; |
||
471 | gProgram_state.cars_available[0] = gProgram_state.frank_or_anniness; |
||
472 | gProgram_state.game_completed = 0; |
||
473 | gProgram_state.redo_race_index = -1; |
||
474 | gWait_for_it = 0; |
||
475 | SwitchToLoresMode(); |
||
476 | } |
||
477 | |||
478 | // IDA: void __cdecl DisposeGameIfNecessary() |
||
479 | void DisposeGameIfNecessary(void) { |
||
480 | int i; |
||
481 | LOG_TRACE("()"); |
||
482 | |||
483 | if (gNet_mode != eNet_mode_none) { |
||
484 | NetLeaveGame(gCurrent_net_game); |
||
485 | } |
||
486 | if (gGame_initialized) { |
||
487 | DisposeHeadupImages(); |
||
488 | gGame_initialized = 0; |
||
489 | if (gNet_mode_of_last_game) { |
||
490 | for (i = 0; i < gNumber_of_net_players; i++) { |
||
491 | DisposeCar(gNet_players[i].car, gNet_players[i].car_index); |
||
492 | } |
||
493 | PossibleService(); |
||
494 | LoadRaces(gRace_list, &gNumber_of_races, -1); |
||
495 | DisposeStorageSpace(&gNet_cars_storage_space); |
||
496 | } |
||
497 | } |
||
498 | ShutdownNetIfRequired(); |
||
499 | } |
||
500 | |||
501 | // IDA: void __cdecl LoadInTrack() |
||
502 | void LoadInTrack(void) { |
||
503 | LOG_TRACE("()"); |
||
504 | |||
505 | LoadTrack(gProgram_state.track_file_name, &gProgram_state.track_spec, &gCurrent_race); |
||
506 | } |
||
507 | |||
508 | // IDA: void __cdecl DisposeTrack() |
||
509 | void DisposeTrack(void) { |
||
510 | LOG_TRACE("()"); |
||
511 | |||
512 | FreeTrack(&gProgram_state.track_spec); |
||
513 | } |
||
514 | |||
515 | // IDA: void __usercall CopyMaterialColourFromIndex(br_material *pMaterial@<EAX>) |
||
516 | void CopyMaterialColourFromIndex(br_material* pMaterial) { |
||
517 | LOG_TRACE("(%p)", pMaterial); |
||
518 | NOT_IMPLEMENTED(); |
||
519 | } |
||
520 | |||
521 | // IDA: void __cdecl InitRace() |
||
522 | void InitRace(void) { |
||
523 | LOG_TRACE("()"); |
||
524 | |||
525 | SwitchToRealResolution(); |
||
526 | // TODO: dword_5454C4 = 0; |
||
527 | ClearConcussion(); |
||
528 | ClearWobbles(); |
||
529 | ClearHeadups(); |
||
530 | ResetOilSpills(); |
||
531 | HideSkids(); |
||
532 | PossibleService(); |
||
533 | BuildColourTable(gRender_palette); |
||
534 | PossibleService(); |
||
535 | // TODO: dword_55142C = 0; |
||
536 | gStart_race_sent = 0; |
||
537 | gProgram_state.frame_rate_headup = NewTextHeadupSlot(0, 0, 0, -1, ""); |
||
538 | if (TranslationMode()) { |
||
539 | if (gAusterity_mode) { |
||
540 | FlushInterfaceFonts(); |
||
541 | } |
||
542 | } else { |
||
11 | pmbaty | 543 | LoadFont(kFont_ORANGHED); |
544 | LoadFont(kFont_BLUEHEAD); |
||
545 | LoadFont(kFont_GREENHED); |
||
1 | pmbaty | 546 | } |
11 | pmbaty | 547 | LoadFont(kFont_MEDIUMHD); |
548 | LoadFont(kFont_TIMER); |
||
1 | pmbaty | 549 | PossibleService(); |
11 | pmbaty | 550 | LoadFont(kFont_NEWHITE); |
551 | LoadFont(kFont_NEWRED); |
||
552 | LoadFont(kFont_NEWBIGGR); |
||
1 | pmbaty | 553 | PossibleService(); |
554 | ResetRecoveryVouchers(); |
||
555 | gMap_mode = 0; |
||
556 | gProgram_state.cockpit_image_index = 0; |
||
557 | if (gNet_mode != eNet_mode_none) { |
||
558 | gNet_cash_headup = NewTextHeadupSlot(13, 0, 0, -6, ""); |
||
559 | gNet_ped_headup = NewTextHeadupSlot(14, 0, 0, -6, ""); |
||
560 | } else { |
||
561 | gCredits_won_headup = NewTextHeadupSlot(1, 0, 0, -6, ""); |
||
562 | gPed_kill_count_headup = NewTextHeadupSlot(2, 0, 0, -6, ""); |
||
563 | gCar_kill_count_headup = NewTextHeadupSlot(12, 0, 0, -6, ""); |
||
564 | gTimer_headup = NewTextHeadupSlot(7, 0, 0, -5, ""); |
||
565 | gTime_awarded_headup = NewTextHeadupSlot(11, 0, 0, -2, ""); |
||
566 | gLaps_headup = NewTextHeadupSlot(8, 0, 0, -6, ""); |
||
567 | } |
||
568 | PossibleService(); |
||
569 | gProgram_state.which_view = eView_forward; |
||
570 | gProgram_state.new_view = eView_undefined; |
||
571 | gProgram_state.pratcam_move_start = 0; |
||
572 | gAction_replay_mode = 0; |
||
573 | SwitchToRealResolution(); |
||
574 | InitPratcam(); |
||
575 | SwitchToLoresMode(); |
||
576 | gProgram_state.credits_earned = 0; |
||
577 | gProgram_state.credits_lost = 0; |
||
578 | gProgram_state.peds_killed = 0; |
||
579 | gProgram_state.revs = 2000; |
||
580 | gProgram_state.current_car.speed = 0.0; |
||
581 | gProgram_state.current_car.steering_angle = 0.0; |
||
582 | gProgram_state.current_car.lf_sus_position = 0.0; |
||
583 | gProgram_state.current_car.rf_sus_position = 0.0; |
||
584 | gProgram_state.current_car.lr_sus_position = 0.0; |
||
585 | gProgram_state.current_car.rr_sus_position = 0.0; |
||
586 | PossibleService(); |
||
587 | gAuto_repair = 0; |
||
588 | SetIntegerMapRenders(); |
||
589 | AdjustRenderScreenSize(); |
||
590 | PrintMemoryDump(0, "DIRECTLY BEFORE LOADING IN TRACK"); |
||
591 | LoadInTrack(); |
||
592 | if (gYon_multiplier != 1.0) { |
||
593 | AdjustRenderScreenSize(); |
||
594 | } |
||
595 | PrintMemoryDump(0, "DIRECTLY AFTER LOADING IN TRACK"); |
||
596 | LoadCopCars(); |
||
597 | PrintMemoryDump(0, "AFTER LOADING IN COPS"); |
||
598 | SaveShadeTables(); |
||
599 | gCountdown = 7; |
||
600 | gTimer = 1000 * gCurrent_race.initial_timer[gProgram_state.skill_level]; |
||
601 | gLap = 1; |
||
602 | gTotal_laps = gCurrent_race.total_laps; |
||
603 | gCheckpoint = 1; |
||
604 | gCheckpoint_count = gCurrent_race.check_point_count; |
||
605 | gFreeze_timer = 0; |
||
606 | gFree_repairs = 0; |
||
607 | if (gNet_mode) { |
||
608 | gShow_opponents = gCurrent_net_game->options.show_players_on_map; |
||
609 | } else { |
||
610 | gShow_opponents = 1; |
||
611 | } |
||
612 | gOn_drugs = 0; |
||
613 | gRace_finished = 0; |
||
614 | gOpponent_speed_factor = 1.0f; |
||
615 | gCop_speed_factor = 1.0f; |
||
616 | gGravity_multiplier = gDefault_gravity; |
||
617 | gPinball_factor = 0; |
||
618 | gInstant_handbrake = 0; |
||
619 | if (gNet_mode) { |
||
620 | gShow_peds_on_map = gCurrent_net_game->options.show_peds_on_map; |
||
621 | } else { |
||
622 | gShow_peds_on_map = 0; |
||
623 | } |
||
624 | PossibleService(); |
||
625 | SetCarSuspGiveAndHeight(&gProgram_state.current_car, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f); |
||
626 | InitPowerups(); |
||
627 | PossibleService(); |
||
628 | ResetSparks(); |
||
629 | PossibleService(); |
||
630 | MakeSavedGame(&gPre_race_saved_game); |
||
631 | PossibleService(); |
||
632 | InitPlayers(); |
||
633 | if (gNet_mode) { |
||
634 | gProgram_state.credits_earned = gInitial_net_credits[gCurrent_net_game->options.starting_money_index]; |
||
635 | InitNetGameplayStuff(); |
||
636 | } |
||
637 | gInitialised_grid = 0; |
||
638 | SwitchToLoresMode(); |
||
639 | } |
||
640 | |||
641 | // IDA: void __cdecl DisposeRace() |
||
642 | void DisposeRace(void) { |
||
643 | LOG_TRACE("()"); |
||
644 | |||
645 | PossibleService(); |
||
646 | DisposePiping(); |
||
647 | PossibleService(); |
||
648 | CloseDownPowerUps(); |
||
649 | PossibleService(); |
||
650 | if (!TranslationMode()) { |
||
651 | DisposeFont(1); |
||
652 | DisposeFont(2); |
||
653 | DisposeFont(3); |
||
654 | } |
||
655 | PossibleService(); |
||
656 | DisposeFont(6); |
||
657 | DisposeFont(7); |
||
658 | DisposeFont(8); |
||
659 | DisposeFont(4); |
||
660 | DisposeFont(5); |
||
661 | PossibleService(); |
||
662 | DisposeSavedShadeTables(); |
||
663 | PossibleService(); |
||
664 | DisposeSoundSources(); |
||
665 | PossibleService(); |
||
666 | DisposeOpponents(); |
||
667 | PossibleService(); |
||
668 | DisposePedestrians(); |
||
669 | PossibleService(); |
||
670 | DisposePratcam(); |
||
671 | PossibleService(); |
||
672 | } |
||
673 | |||
674 | // IDA: int __cdecl GetScreenSize() |
||
675 | int GetScreenSize(void) { |
||
676 | LOG_TRACE("()"); |
||
677 | |||
678 | return gRender_indent; |
||
679 | } |
||
680 | |||
681 | // IDA: void __usercall SetScreenSize(int pNew_size@<EAX>) |
||
682 | void SetScreenSize(int pNew_size) { |
||
683 | LOG_TRACE("(%d)", pNew_size); |
||
684 | |||
685 | gRender_indent = pNew_size; |
||
686 | } |