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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
#include "global.h"
#include "pokedex.h"
#include "unk_02029FB0.h"
const u16 UNK_020EEA7C[] = {
0x0001, // 00
0x0001, // 01
0x0001, // 02
0x0001, // 03
0x0001, // 04
0x0001, // 05
0x0002, // 06
0x0002, // 07
0x0002, // 08
0x0002, // 09
0x0003, // 10
0x0003, // 11
0x0003, // 12
0x0007, // 13
0x0007, // 14
0x0007, // 15
0x000A, // 16
0x000A, // 17
0x000B, // 18
0x000B, // 19
0x000B, // 20
0x000B, // 21
0x0014, // 22
0x001E, // 23
0x0023, // 24
0x0028, // 25
0x01F4, // 26
0x2710, // 27
0x001E, // 28
0x001E, // 29
0x0002, // 30
0x0005, // 31
0x0001, // 32
0x0001, // 33
0x0005, // 34
0x0003, // 35
0x0001, // 36
0x0001, // 37
};
u8 UNK_02105CD8[] = {
TRUE, // 000
TRUE, // 001
FALSE, // 002
TRUE, // 003
TRUE, // 004
TRUE, // 005
TRUE, // 006
TRUE, // 007
TRUE, // 008
FALSE, // 009
FALSE, // 010
FALSE, // 011
TRUE, // 012
TRUE, // 013
TRUE, // 014
TRUE, // 015
TRUE, // 016
TRUE, // 017
TRUE, // 018
TRUE, // 019
TRUE, // 020
TRUE, // 021
TRUE, // 022
TRUE, // 023
TRUE, // 024
TRUE, // 025
TRUE, // 026
TRUE, // 027
TRUE, // 028
TRUE, // 029
TRUE, // 030
TRUE, // 031
TRUE, // 032
TRUE, // 033
TRUE, // 034
TRUE, // 035
TRUE, // 036
TRUE, // 037
TRUE, // 038
TRUE, // 039
TRUE, // 040
FALSE, // 041
FALSE, // 042
FALSE, // 043
TRUE, // 044
TRUE, // 045
FALSE, // 046
TRUE, // 047
TRUE, // 048
FALSE, // 049
FALSE, // 050
FALSE, // 051
FALSE, // 052
FALSE, // 053
FALSE, // 054
FALSE, // 055
FALSE, // 056
FALSE, // 057
FALSE, // 058
FALSE, // 059
FALSE, // 060
FALSE, // 061
FALSE, // 062
FALSE, // 063
FALSE, // 064
FALSE, // 065
FALSE, // 066
TRUE, // 067
FALSE, // 068
FALSE, // 069
FALSE, // 070
FALSE, // 071
FALSE, // 072
FALSE, // 073
FALSE, // 074
FALSE, // 075
FALSE, // 076
FALSE, // 077
FALSE, // 078
FALSE, // 079
FALSE, // 080
FALSE, // 081
FALSE, // 082
FALSE, // 083
FALSE, // 084
TRUE, // 085
FALSE, // 086
FALSE, // 087
FALSE, // 088
FALSE, // 089
FALSE, // 090
FALSE, // 091
FALSE, // 092
FALSE, // 093
FALSE, // 094
FALSE, // 095
FALSE, // 096
FALSE, // 097
FALSE, // 098
FALSE, // 099
FALSE, // 100
FALSE, // 101
FALSE, // 102
FALSE, // 103
FALSE, // 104
FALSE, // 105
FALSE, // 106
FALSE, // 107
FALSE, // 108
FALSE, // 109
FALSE, // 110
FALSE, // 111
FALSE, // 112
FALSE, // 113
FALSE, // 114
FALSE, // 115
FALSE, // 116
FALSE, // 117
FALSE, // 118
FALSE, // 119
FALSE, // 120
FALSE, // 121
};
static inline s32 GetOffsetToUnk00(s32 a0)
{
return a0;
}
static inline s32 GetOffsetToUnkB0(s32 a0)
{
return a0 - 44;
}
THUMB_FUNC u32 Sav2_GameStats_sizeof(void)
{
return sizeof(struct GameStats);
}
THUMB_FUNC void Sav2_GameStats_init(struct GameStats * ptr)
{
MI_CpuClear32(ptr, sizeof(struct GameStats));
}
THUMB_FUNC struct GameStats * Sav2_GameStats_get(struct SaveBlock2 * sav2)
{
return SavArray_get(sav2, 20);
}
THUMB_FUNC u32 GameStats_GetValue(struct GameStats * ptr, s32 a1)
{
if (a1 < 44)
{
return ptr->unk_00[GetOffsetToUnk00(a1)];
}
else if (a1 < 121)
{
return ptr->unk_B0[GetOffsetToUnkB0(a1)];
}
else
{
GF_ASSERT(0);
return 0;
}
}
THUMB_FUNC u32 GameStats_SetValue(struct GameStats * ptr, s32 a1, u32 a2)
{
if (a1 < 44)
{
ptr->unk_00[GetOffsetToUnk00(a1)] = a2;
}
else if (a1 < 121)
{
ptr->unk_B0[GetOffsetToUnkB0(a1)] = a2;
}
else
{
GF_ASSERT(0);
}
return GameStats_GetValue(ptr, a1);
}
THUMB_FUNC u32 GameStats_GetMaxValue(s32 a0)
{
if (a0 < 44)
{
if (UNK_02105CD8[a0])
return 999999999;
else
return 999999;
}
else if (a0 < 121)
{
if (UNK_02105CD8[a0])
return 0xFFFF;
else
return 9999;
}
else
{
GF_ASSERT(0);
return 0;
}
}
THUMB_FUNC u16 GameStats_GetStdInc(s32 a0)
{
return UNK_020EEA7C[a0];
}
THUMB_FUNC u32 GameStats_SetCapped(struct GameStats * ptr, s32 a1, u32 a2)
{
u32 r2 = GameStats_GetMaxValue(a1);
if (a2 < r2)
{
return GameStats_SetValue(ptr, a1, a2);
}
else
{
return GameStats_SetValue(ptr, a1, r2);
}
}
THUMB_FUNC u32 GameStats_UpdateBounded(struct GameStats * ptr, s32 a1, u32 a2)
{
u32 r4 = GameStats_GetMaxValue(a1);
u32 r0 = GameStats_GetValue(ptr, a1);
if (a2 > r4)
{
a2 = r4;
}
if (r0 < a2)
{
return GameStats_SetValue(ptr, a1, a2);
}
else if (r0 > r4)
{
return GameStats_SetValue(ptr, a1, r4);
}
else
{
return r0;
}
}
THUMB_FUNC u32 GameStats_Inc(struct GameStats * ptr, s32 a1)
{
u32 r4 = GameStats_GetMaxValue(a1);
u32 r2 = GameStats_GetValue(ptr, a1) + 1;
if (r2 < r4)
{
return GameStats_SetValue(ptr, a1, r2);
}
else
{
return GameStats_SetValue(ptr, a1, r4);
}
}
THUMB_FUNC u32 GameStats_Add(struct GameStats * ptr, s32 a1, u32 a2)
{
u32 r6 = GameStats_GetMaxValue(a1);
u32 r2 = GameStats_GetValue(ptr, a1);
r2 += a2;
if (r2 < r6)
{
return GameStats_SetValue(ptr, a1, r2);
}
else
{
return GameStats_SetValue(ptr, a1, r6);
}
}
THUMB_FUNC u32 GameStats_GetCapped(struct GameStats * ptr, s32 a1)
{
u32 r4 = GameStats_GetMaxValue(a1);
u32 r0 = GameStats_GetValue(ptr, a1);
if (r0 <= r4)
r4 = r0;
return r4;
}
THUMB_FUNC u32 GameStats_AddSpecial(struct GameStats * ptr, s32 a1)
{
GF_ASSERT(a1 < 38);
u32 r0 = GameStats_GetCapped(ptr, 0) + GameStats_GetStdInc(a1);
if (r0 > 99999999)
{
return GameStats_SetCapped(ptr, 0, 99999999);
}
else
{
return GameStats_Add(ptr, 0, GameStats_GetStdInc(a1));
}
}
THUMB_FUNC u32 GameStats_GetStat0(struct GameStats * ptr)
{
return GameStats_GetCapped(ptr, 0);
}
THUMB_FUNC void GameStats_IncSpeciesCaught(struct GameStats * ptr, struct Pokedex * pokedex, u16 species)
{
if (!Pokedex_CheckMonCaughtFlag(pokedex, species))
{
GameStats_AddSpecial(ptr, 22);
}
}
|