Skip to content

Commit ddf2dbf

Browse files
committed
Annotate and stub common function for parsing the import object
1 parent e5a9d78 commit ddf2dbf

4 files changed

Lines changed: 125 additions & 9 deletions

File tree

GolDP/include/gol.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
typedef void FatalErrorMessageCBFN(const char* p_message, const char* p_file, int p_line);
1111
typedef void GolExitCBFN();
1212

13+
class GolFileSource;
14+
1315
struct GolImport {
14-
undefined4* m_unk0x0; // 0x00
15-
undefined4* m_unk0x4; // 0x04
16-
undefined4* m_unk0x8[4]; // 0x08
16+
GolFileSource* m_fileSources; // 0x00
17+
LegoU32 m_fileSourceCount; // 0x04
18+
LegoChar* m_unk0x8[4]; // 0x08
1719
LegoU32 m_unk0x18; // 0x18
1820
undefined4* m_unk0x1c; // 0x1c
1921
HANDLE m_mutex; // 0x20

common/include/golstream.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44
#include "decomp.h"
55
#include "types.h"
66

7+
class GolFileSource;
8+
9+
extern LegoChar* g_unk0x4c7384[4];
10+
11+
extern GolFileSource* g_fileSources;
12+
13+
extern LegoU32 g_fileSourceCount;
14+
15+
extern LegoU32 g_unk0x4c739c;
16+
17+
extern undefined4* g_unk0x4c73a0;
18+
719
// VTABLE: LEGORACERS 0x4b0f38
820
// SIZE 0x30
921
class GolStream {
@@ -71,6 +83,14 @@ class GolStream {
7183
void Init();
7284
LegoS32 OpenFileSource();
7385

86+
undefined4 FUN_0044c9c0(const LegoChar* p_arg1);
87+
#ifdef BUILDING_GOL
88+
static undefined4 FUN_100320d0();
89+
static void FUN_10032110(const char* p_arg1);
90+
#endif
91+
92+
static const char* ErrorCodeToString(int p_code);
93+
static void TransformToUpper(char* p_str);
7494
static LegoS32 IsAbsolutePath(LegoChar* p_path);
7595
static void FUN_0044d190(const LegoChar* p_prefix, const LegoChar* p_path);
7696

common/src/golfsutil.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "decomp.h"
44
#include "gol.h"
5+
#include "golstream.h"
56
#include "types.h"
67

78
#if (defined(_MSC_VER) && defined(_M_X64)) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64)))
@@ -27,21 +28,33 @@ BOOL g_CPU_supports_MMX;
2728
char g_cpuManufacturer[16];
2829

2930
#ifdef BUILDING_LEGORACERS
30-
// STUB: LEGORACERS 0x00450d80
31+
// FUNCTION: LEGORACERS 0x00450d80
3132
void CreateGolImport(GolImport* p_import)
3233
{
33-
// TODO
34-
// result.m_unk0x1c = ;
34+
p_import->m_fileSources = g_fileSources;
35+
p_import->m_fileSourceCount = g_fileSourceCount;
36+
p_import->m_unk0x18 = g_unk0x4c739c;
37+
for (LegoU32 i = 0; i < p_import->m_unk0x18; i++) {
38+
p_import->m_unk0x8[i] = g_unk0x4c7384[i];
39+
}
40+
p_import->m_unk0x1c = g_unk0x4c73a0;
3541
p_import->m_mutex = g_hMutex;
3642
}
3743
#endif
3844

3945
#ifdef BUILDING_GOL
40-
// STUB: GOLDP 0x10032b80
46+
47+
// FUNCTION: GOLDP 0x10032b80
4148
void SetGolImport(GolImport* p_import)
4249
{
43-
// TODO
44-
STUB(0x10032b80);
50+
g_fileSourceCount = p_import->m_fileSourceCount;
51+
g_fileSources = p_import->m_fileSources;
52+
GolStream::FUN_100320d0();
53+
for (LegoU32 i = 0; i < p_import->m_unk0x18; i++) {
54+
GolStream::FUN_10032110(p_import->m_unk0x8[i]);
55+
}
56+
g_unk0x4c73a0 = p_import->m_unk0x1c;
57+
g_hMutex = p_import->m_mutex;
4558
}
4659
#endif
4760

common/src/golstream.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,53 @@
99

1010
DECOMP_SIZE_ASSERT(GolStream, 0x30)
1111

12+
// GLOBAL: GOLDP 0x10065d68
1213
// GLOBAL: LEGORACERS 0x4c7284
1314
LegoChar g_pathBuffer[256];
1415

16+
// GLOBAL: GOLDP 0x10065e68
1517
// GLOBAL: LEGORACERS 0x4c7384
1618
LegoChar* g_unk0x4c7384[4];
1719

20+
// GLOBAL: GOLDP 0x10065e78
1821
// GLOBAL: LEGORACERS 0x4c7394
1922
GolFileSource* g_fileSources;
2023

24+
// GLOBAL: GOLDP 0x10065e7c
2125
// GLOBAL: LEGORACERS 0x4c7398
2226
LegoU32 g_fileSourceCount;
2327

28+
// GLOBAL: GOLDP 0x10065e80
2429
// GLOBAL: LEGORACERS 0x4c739c
2530
LegoU32 g_unk0x4c739c;
2631

32+
// GLOBAL: GOLDP 0x10065e84
33+
// GLOBAL: LEGORACERS 0x004c73a0
34+
undefined4* g_unk0x4c73a0;
35+
36+
// GLOBAL: GOLDP 0x1005f04c
37+
// GLOBAL: LEGORACERS 0x004c1848
38+
static const char* const s_errorCodeStrings[] = {
39+
"Not a error",
40+
"General I/O error",
41+
"Invalid parameter",
42+
"Invalid value",
43+
"Out of memory error",
44+
"I/O Busy error",
45+
"Operation not supported",
46+
"File not open",
47+
"File not found",
48+
"Access denied",
49+
"File already exists",
50+
"Exceeded maximum files open",
51+
"Invalid name",
52+
"Unable to read",
53+
"Unable to write",
54+
"Unable to seek",
55+
"Attempt to read past file end",
56+
"Invalid character encoutered"
57+
};
58+
2759
// FUNCTION: LEGORACERS 0x44c920
2860
GolStream::GolStream()
2961
{
@@ -56,6 +88,25 @@ void GolStream::Init()
5688
m_buffer = NULL;
5789
}
5890

91+
// STUB: GOLDP 0x10031c90
92+
// STUB: LEGORACERS 0x0044c9c0
93+
undefined4 GolStream::FUN_0044c9c0(const LegoChar* p_arg1)
94+
{
95+
// TODO
96+
STUB(0x0044c9c0);
97+
return 0;
98+
}
99+
100+
#ifdef BUILDING_GOL
101+
// STUB: GOLDP 0x100320d0
102+
undefined4 GolStream::FUN_100320d0()
103+
{
104+
// TODO
105+
STUB(0x100320d0);
106+
return 0;
107+
}
108+
#endif
109+
59110
// FUNCTION: LEGORACERS 0x44caa0
60111
LegoS32 GolStream::OpenFileSource()
61112
{
@@ -460,6 +511,24 @@ void GolStream::FUN_0044d190(const LegoChar*, const LegoChar*)
460511
STUB(0x44d190);
461512
}
462513

514+
// FUNCTION: GOLDP 0x10031c80
515+
// FUNCTION: LEGORACERS 0x0044d180
516+
const char* GolStream::ErrorCodeToString(int p_code)
517+
{
518+
519+
return s_errorCodeStrings[p_code];
520+
}
521+
522+
// FUNCTION: LEGORACERS 0x0044d4f0
523+
void GolStream::TransformToUpper(char* p_str)
524+
{
525+
size_t i;
526+
527+
for (i = 0; *p_str != '\0' && i < 256; i++, p_str++) {
528+
*p_str = toupper(*p_str);
529+
}
530+
}
531+
463532
// FUNCTION: LEGORACERS 0x44d530
464533
LegoS32 GolStream::IsAbsolutePath(LegoChar* p_path)
465534
{
@@ -470,6 +539,16 @@ LegoS32 GolStream::IsAbsolutePath(LegoChar* p_path)
470539
return isalpha(p_path[0]) && p_path[1] == ':';
471540
}
472541

542+
#ifdef BUILDING_GOL
543+
// STUB: GOLDP 0x10032110
544+
void GolStream::FUN_10032110(const char* p_arg1)
545+
{
546+
// FIXME
547+
STUB(0x10032110);
548+
}
549+
#endif
550+
551+
// FUNCTION: GOLDP 0x10032190
473552
// FUNCTION: LEGORACERS 0x44d570
474553
LegoS32 GolStream::BufferedWrite(LegoS32 p_offset, const void* p_buf, LegoU32 p_size)
475554
{
@@ -528,6 +607,7 @@ LegoS32 GolStream::BufferedWrite(LegoS32 p_offset, const void* p_buf, LegoU32 p_
528607
}
529608
}
530609

610+
// FUNCTION: GOLDP 0x100322c0
531611
// FUNCTION: LEGORACERS 0x44d6a0
532612
LegoS32 GolStream::WriteLine(const void* p_buf, LegoU32 p_size)
533613
{
@@ -563,6 +643,7 @@ LegoS32 GolStream::WriteLine(const void* p_buf, LegoU32 p_size)
563643
}
564644
}
565645

646+
// FUNCTION: GOLDP 0x100323a0
566647
// FUNCTION: LEGORACERS 0x44d780
567648
LegoS32 GolStream::FlushWriteBuffer()
568649
{

0 commit comments

Comments
 (0)