Adds stub for initialiseapplication (#18)

* Adds stub for InitialiseApplication
This commit is contained in:
Jeff Harris 2019-12-10 16:36:04 -08:00 committed by GitHub
parent 5f0d3652b5
commit c57fc0e0a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 738 additions and 4 deletions

3
src/BRSRC13/brender.h Normal file
View File

@ -0,0 +1,3 @@
#include "CORE/V1DB/dbsetup.h"
#include "CORE/V1DB/regsupt.h"
#include "CORE/V1DB/matsupt.h"

View File

@ -0,0 +1,15 @@
#include "drdebug.h"
// These functions were compiled out of the release executable. Implementation is just a guess
void DrDebugLog(int unk, char *pStr) {
// maybe this is actually "errors::dprintf"?
printf("%d: %s\n", unk, pStr);
}
void DrDebugMessage(char *pStr, ...) {
va_list args;
va_start(args, pStr);
vprintf(pStr, args);
va_end(args);
}

View File

@ -0,0 +1,11 @@
#ifndef _DRDEBUG_H_
#define _DRDEBUG_H_
#include "dr_types.h"
#include "br_types.h"
void DrDebugLog(int unk, char *pStr);
void DrDebugMessage(char *pStr, ...);
#endif

View File

@ -1,11 +1,596 @@
#include "grafdata.h"
tGraf_data gGraf_data[2];
#include "globvars.h"
#include "pc-dos/dossys.h"
#include "errors.h"
tGraf_data gGraf_data[2] =
{
{
320,
200,
21,
18,
8,
54,
167,
199,
17,
24,
{
1,
3,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
19,
21,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
},
134,
{ 57, 182 },
{ 85, 210 },
118,
67,
58,
147,
124,
190,
58,
270,
124,
15,
10,
350,
220,
{ 38, 166 },
{ 29, 96 },
66,
58,
62,
30,
174,
174,
30,
174,
82,
95,
260,
61,
282,
28,
149,
20,
75,
65,
72,
132,
125,
137,
207,
71,
39,
15,
62,
78,
56,
41,
280,
141,
60,
165,
235,
3,
6,
57,
39,
112,
110,
174,
106,
0,
12,
6,
60,
42,
116,
89,
67,
111,
67,
137,
67,
123,
122,
41,
132,
60,
25,
188,
192,
233,
52,
59,
76,
83,
101,
108,
20,
124,
135,
172,
183,
121,
163,
168,
211,
120,
169,
126,
83,
238,
178,
191,
181,
11,
20,
298,
149,
4,
22,
40,
18,
4,
137,
65,
133,
277,
65,
31,
277,
127,
31,
131,
318,
2,
1,
1,
5,
5,
70,
182,
182,
70,
100,
126,
152,
174,
200,
226,
252,
278,
170,
42,
90,
185,
224,
290,
66,
13,
40,
292,
4294967293,
8,
126,
163,
62,
60,
270,
118,
67,
92,
200,
305,
35,
23,
58,
152,
48,
113,
170,
235,
12,
37,
153,
48,
152,
3,
3,
2,
53,
51,
0,
14,
9,
1,
2,
0,
7,
2,
8,
5,
49,
8,
{ 27, 67 },
{ 36, 76 },
{ 45, 85 },
288,
318,
7,
312,
1,
2,
2,
1,
309,
4,
132,
50,
53,
211,
150,
171,
55,
85,
162,
195,
235,
51,
13,
141,
81,
141,
44,
8,
100,
194,
22
},
{
640,
480,
21,
18,
8,
54,
167,
199,
17,
24,
{
1,
3,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
19,
21,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
},
134,
{ 57, 182 },
{ 85, 210 },
118,
67,
58,
147,
124,
190,
58,
270,
124,
32,
24,
704,
528,
{ 38, 166 },
{ 29, 96 },
66,
58,
62,
30,
174,
174,
30,
174,
82,
95,
260,
61,
282,
28,
149,
20,
75,
65,
72,
132,
125,
137,
207,
71,
39,
15,
62,
78,
56,
56,
268,
141,
60,
165,
235,
3,
6,
57,
39,
112,
110,
174,
106,
0,
12,
6,
60,
42,
116,
89,
67,
111,
67,
137,
67,
123,
122,
41,
132,
60,
25,
188,
192,
233,
52,
59,
76,
83,
101,
108,
20,
124,
135,
172,
183,
121,
163,
168,
211,
120,
169,
126,
83,
238,
178,
191,
181,
11,
20,
298,
149,
8,
44,
96,
43,
10,
137,
65,
133,
277,
65,
31,
277,
127,
31,
131,
636,
5,
2,
2,
10,
12,
140,
437,
437,
140,
200,
252,
304,
348,
400,
452,
504,
556,
408,
42,
90,
185,
224,
290,
66,
13,
40,
292,
4294967293,
8,
126,
163,
62,
60,
270,
118,
67,
92,
200,
305,
35,
23,
58,
152,
48,
113,
170,
235,
12,
37,
150,
48,
152,
6,
7,
4,
106,
102,
0,
31,
18,
2,
4,
0,
17,
4,
18,
12,
98,
19,
{ 65, 161 },
{ 86, 182 },
{ 107, 203 },
576,
636,
18,
624,
3,
2,
4,
3,
618,
11,
132,
50,
53,
211,
150,
171,
55,
85,
162,
195,
235,
51,
13,
141,
81,
141,
44,
16,
200,
388,
55
}
};
tGraf_data *gCurrent_graf_data;
int gGraf_data_index;
// Offset: 0
// Size: 170
void CalcGrafDataIndex() {
int i;
for (i = 0; i < 2; i++) {
if (gGraf_specs[gGraf_spec_index].total_width == gGraf_data[i].width && gGraf_specs[gGraf_spec_index].total_height == gGraf_data[i].height) {
gReal_graf_data_index = i;
gGraf_data_index = i;
gCurrent_graf_data = &gGraf_data[i];
return;
}
}
FatalError(0x18);
}

View File

@ -4,6 +4,10 @@
#include "dr_types.h"
#include "br_types.h"
extern tGraf_data gGraf_data[2];
extern tGraf_data *gCurrent_graf_data;
extern int gGraf_data_index;
// Offset: 0
// Size: 170
void CalcGrafDataIndex();

View File

@ -1,6 +1,29 @@
#include "init.h"
#include <time.h>
#include "pc-dos/dossys.h"
#include "common/globvars.h"
#include "common/errors.h"
#include "common/drmem.h"
#include "common/graphics.h"
#include "common/drdebug.h"
#include "common/loading.h"
#include "common/netgame.h"
#include "common/replay.h"
#include "common/grafdata.h"
#include "common/flicplay.h"
#include "common/sound.h"
#include "common/displays.h"
#include "common/powerup.h"
#include "common/raycast.h"
#include "common/depth.h"
#include "common/world.h"
#include "common/oil.h"
#include "common/skidmark.h"
#include "common/pedestrn.h"
#include "brender.h"
int gInitialisation_finished;
tU32 gAustere_time;
@ -101,6 +124,73 @@ void Init2DStuff() {
// EAX: pArgc
// EDX: pArgv
void InitialiseApplication(int pArgc, char **pArgv) {
gProgram_state.sausage_eater_mode = gSausage_override;
DrDebugLog(gSausage_override, *pArgv);
if (gAustere_override || PDDoWeLeadAnAustereExistance() != 0) {
gAusterity_mode = 1;
}
srand(time(NULL));
BrV1dbBeginWrapper_Float();
CreateStainlessClasses();
InitWobbleStuff();
LoadGeneralParameters();
DefaultNetName();
strcpy(gProgram_state.player_name[0], "MAX DAMAGE");
strcpy(gProgram_state.player_name[1], "DIE ANNA");
RestoreOptions();
LoadKeyMapping();
if (!PDInitScreenVars(pArgc, pArgv)) {
FatalError(0);
}
CalcGrafDataIndex();
InitializeBRenderEnvironment();
InitDRFonts();
InitBRFonts();
LoadMiscStrings();
LoadInRegistees();
FinishLoadingGeneral();
InitializePalettes();
AustereWarning();
LoadInterfaceStrings();
InitializeActionReplay();
FlicPaletteAllocate();
InitInterfaceLoadState();
InitTransientBitmaps();
InitSound();
InitHeadups();
gDefault_track_material = BrMaterialAllocate("gDefault_track_material");
//TODO:
//BYTE2(gDefault_track_material->map_transform.m[2][1]) = -29;
//BYTE3(gDefault_track_material->map_transform.m[2][1]) = 1;
BrMaterialAdd(gDefault_track_material);
InitShadow();
InitFlics();
AllocateStandardLamp();
InitAmbience();
LoadOpponents();
LoadPowerups();
LoadRaces(gRace_list, &gNumber_of_races, -1);
RevertPalette();
InitRayCasting();
InitDepthEffects();
InitialiseStorageSpace(&gOur_car_storage_space, 40, 2, 40, 30);
InitialiseStorageSpace(&gTheir_cars_storage_space, 300, 50, 500, 200);
InitialiseStorageSpace(&gPedestrians_storage_space, 500, 10, 0, 0);
InitialiseStorageSpace(&gTrack_storage_space, 400, 50, 400, 1000);
InitOilSpills();
if (gAustere_time) {
while (PDGetTotalTime() - gAustere_time < 2000) {
}
}
ClearEntireScreen();
InitSkids();
InitPeds();
gProgram_state.cars_available[42] = 0;
gCD_is_in_drive = TestForOriginalCarmaCDinDrive();
SwitchToLoresMode();
DrDebugLog(0, "AFTER APPLICATION INITIALISATION");
}
// Offset: 6004

View File

@ -9,6 +9,7 @@
#include "common/utility.h"
#include "common/structur.h"
#include "common/loadsave.h"
#include "common/drdebug.h"
// Offset: 0
@ -55,7 +56,7 @@ void GameMain(int pArgc, char **pArgv) {
PDSetFileVariables();
PDBuildAppPath(gApplication_path);
//v8 = DRLogMessage(v19, v20);
//DrDebugMessage(*pArgv);
strcat(gApplication_path, "DATA");

View File

@ -13,11 +13,18 @@
#include "common/sound.h"
#include "common/utility.h"
#include "common/loadsave.h"
#include "common/drdebug.h"
int gASCII_table[128];
tU32 gKeyboard_bits[8];
int gASCII_shift_table[128];
tGraf_spec gGraf_specs[2];
tGraf_spec gGraf_specs[2] =
{
{ 8, 1, 0, 320, 200, 0, 0, "32X20X8", "MCGA,W:320,H:200,B:8", 0, 0, 0, NULL },
{ 8, 1, 0, 640, 480, 0, 0, "64X48X8", "VESA,W:640,H:480,B:8", 0, 0, 0, NULL }
};
char gNetwork_profile_fname[256];
tS32 gJoystick_min1y;
tS32 gJoystick_min2y;
@ -292,6 +299,9 @@ void PDRevertPalette() {
// EAX: pArgc
// EDX: pArgv
int PDInitScreenVars(int pArgc, char **pArgv) {
gGraf_specs[gGraf_spec_index].phys_width = gGraf_specs[gGraf_spec_index].total_width;
gGraf_specs[gGraf_spec_index].phys_height = gGraf_specs[gGraf_spec_index].total_height;
return 1;
}
// Offset: 3300
@ -518,6 +528,10 @@ tU32 LargestBlockAvail() {
SREGS sregs;
tMem_info mem_info;
size_t memmax;
// Added >>
return 15000000;
// <<
}
// Offset: 6476
@ -580,7 +594,7 @@ int _main(int pArgc, char **pArgv) {
for (i = 1; i < pArgc; i++) {
if (strcasecmp(pArgv[i], "-hires") == 0) {
gReal_graf_data_index = 1;
gGraf_spec_index = 1;
}
else if (strcasecmp(pArgv[i], "-yon") == 0 && i < pArgc - 1) {
i++;
@ -789,5 +803,16 @@ int PDCheckDriveExists2(char *pThe_path, char *pFile_name, tU32 pMin_size) {
// Offset: 10184
// Size: 108
int PDDoWeLeadAnAustereExistance() {
tU32 block;
block = LargestBlockAvail();
DrDebugMessage("PDDoWeLeadAnAustereExistance (sic): LargestBlockAvail=%d\n", block);
if (gReal_graf_data_index == 0) {
return block < 13000000;
}
return block < 15000000;
}