-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
187 lines (153 loc) · 4.43 KB
/
Copy pathmain.cpp
File metadata and controls
187 lines (153 loc) · 4.43 KB
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
#include "global.h"
#include "unknown_data.h"
#include "unknown_funcs.h"
#include "database.hpp"
#include "map.hpp"
#include "unit.hpp"
#define GetPos(x, y) ((x) | ((y) << 5))
EC void main(void)
{
System_Init();
func_0200f028();
StartGame();
func_020ad244(0x14);
while (TRUE)
func_0200f04c();
}
EC void * func_02000c70(void)
{
return &data_027e00e0;
}
EC void func_02000c7c(struct MapStateManager_08 * buf)
{
buf->unk_086e = gMapStateManager->unk_20;
buf->unk_086f = gMapStateManager->unk_22;
buf->unk_0870 = gMapStateManager->unk_24;
buf->unk_0871 = gMapStateManager->unk_25;
buf->unk_0872 = gMapStateManager->unk_26;
buf->unk_0873 = gMapStateManager->unk_27;
buf->unk_0874 = data_ov000_021e3324->phase;
buf->unk_0854 = buf->unk_0878;
buf->unk_0858 = buf->unk_1078;
buf->unk_085c = buf->unk_10f8;
buf->unk_0860 = gMapStateManager->unk_028;
}
EC void func_02000d14(struct MapStateManager_08 * buf, s32 a)
{
func_020a5824(buf->unk_0854, a & 0xFF, 0x400);
}
EC void func_02000d2c(struct UnkStruct_Func_2000D2C * buf, s32 a, s32 b)
{
s32 tmp1, tmp2;
struct Unit * unit = gMapStateManager->unk_04->unk_00;
tmp1 = func_0203c77c(unit);
if (CheckUnitAttribute(unit, CA_UNK_27))
tmp1 = 0;
tmp2 = func_02001770(buf, a, b);
if (tmp2 >= 0)
{
func_02001bac(buf, tmp2);
return;
}
if ((ABS(a - buf->unk_42) + ABS(b - buf->unk_43)) == 1)
{
s32 tmp_r0 = func_020016e8(buf, unit, a, b);
if ((buf->unk_47 + tmp_r0) <= tmp1)
{
s32 tmp_r2 = buf->unk_42;
s32 tmp_r3 = buf->unk_43;
if (buf->unk_42 < (s8)a)
tmp_r2 = 2;
else if (buf->unk_42 > (s8)a)
tmp_r2 = 1;
else if (buf->unk_43 < (s8)b)
tmp_r2 = 4;
else if (tmp_r3 > (s8)b)
tmp_r2 = 8;
else
tmp_r2 = 0x80;
buf->unk_00[buf->unk_46] = tmp_r2;
buf->unk_42 = a;
buf->unk_43 = b;
buf->unk_47 += tmp_r0;
buf->unk_46++;
return;
}
}
gMapStateManager->unk_08->unk_0854 = gMapStateManager->unk_08->unk_0c78;
func_01ff8000(
gMapStateManager->unk_08,
buf->unk_42,
buf->unk_43,
unit->pJobData->unk_28,
tmp1 - buf->unk_47,
0xA
);
if (gMapStateManager->unk_08->unk_0854[GetPos(a, b)] >= 0)
{
func_02001820(buf, a, b, 1);
gMapStateManager->unk_08->unk_0854 = gMapStateManager->unk_08->unk_0878;
}
else
{
gMapStateManager->unk_08->unk_0854 = gMapStateManager->unk_08->unk_0878;
buf->unk_47 = 0;
buf->unk_46 = 0;
func_02001820(buf, a, b, 1);
}
}
EC BOOL func_02000f18(struct UnkStruct_Func_2000D2C * buf, s32 a, s32 b, s32 c)
{
s32 tmp4;
struct Unit * unit = gMapStateManager->unk_04->unk_00;
if (gMapStateManager->unk_028[GetPos(buf->unk_42, buf->unk_43)] != 0)
return FALSE;
tmp4 = ABS(a - buf->unk_42) + ABS(b - buf->unk_43);
if (c == 2)
{
if (tmp4 != 1)
return FALSE;
buf->unk_48 = -1;
}
else
{
s32 ret = func_02039088(unit, buf->unk_42, buf->unk_43, tmp4, c == 0, c == 1, -1);
if (ret < 0)
return FALSE;
buf->unk_48 = ret;
}
return TRUE;
}
EC s32 func_02000fec(struct UnkStruct_Func_2000D2C * buf, s32 a, s32 b)
{
s32 tmp_r4 = 0;
s32 ret = func_02001770(buf, a, b);
s32 terrainId;
if (ret >= 0)
{
tmp_r4 += 0x40000000;
tmp_r4 += ret << 16;
}
else
{
struct MapStateManager_08 * r2 = gMapStateManager->unk_08;
s8 * unk_0c78 = r2->unk_0c78;
// The temp variable seems to be required
s8 * tmp_r0 = &unk_0c78[GetPos(a, b)];
if (unk_0c78[GetPos(a, b)] >= 0)
{
tmp_r4 += 0x20000000;
tmp_r4 += (0x80 - *tmp_r0) << 16;
}
else
{
tmp_r4 += (0x80 - r2->unk_0854[GetPos(a, b)]) << 16;
}
}
// The temp variable seems to be required
terrainId = gMapStateManager->unk_828[GetPos(a, b)];
tmp_r4 += (gFE11Database->pTerrain[terrainId].unk_08[0] << 8);
tmp_r4 += (gFE11Database->pTerrain[gMapStateManager->unk_828[GetPos(a, b)]].unk_08[1] << 4);
tmp_r4 += (gFE11Database->pTerrain[gMapStateManager->unk_828[GetPos(a, b)]].unk_08[2]);
return tmp_r4;
}