summaryrefslogtreecommitdiff
path: root/include/pokemon.h
blob: 60fa1838327616a85f6384b96b8ef68b9ad0a5c3 (plain)
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
#ifndef POKEDIAMOND_POKEMON_H
#define POKEDIAMOND_POKEMON_H

#include "nitro/types.h"

// Enums

#include "constants/species.h"
#include "mail.h"
#include "constants/pokemon.h"
#include "string16.h"
#include "player_data.h"
#include "sound_chatot.h"

struct BaseStats {
    /* 0x00 */ u8 hp;
    /* 0x01 */ u8 atk;
    /* 0x02 */ u8 def;
    /* 0x03 */ u8 speed;
    /* 0x04 */ u8 spatk;
    /* 0x05 */ u8 spdef;
    /* 0x06 */ u8 types[2];
    /* 0x08 */ u8 catchRate;
    /* 0x09 */ u8 expYield;
    /* 0x0A */ u16 hp_yield:2;
               u16 atk_yield:2;
               u16 def_yield:2;
               u16 speed_yield:2;
    /* 0x0B */ u16 spatk_yield:2;
               u16 spdef_yield:2;
               u16 padding_B_4:4;
    /* 0x0C */ u16 item1;
    /* 0x0E */ u16 item2;
    /* 0x10 */ u8 genderRatio;
    /* 0x11 */ u8 eggCycles;
    /* 0x12 */ u8 friendship;
    /* 0x13 */ u8 growthRate;
    /* 0x14 */ u8 eggGroups[2];
    /* 0x16 */ u8 abilities[2];
    /* 0x18 */ u8 greatMarshRate;
    /* 0x19 */ u8 color:7;
               u8 flip:1;
               u8 padding_1A[2];
    /* 0x1C */ u32 unk1C;
    /* 0x20 */ u32 unk20;
    /* 0x24 */ u32 unk24;
    /* 0x28 */ u32 unk28;
};

// Structs

typedef struct {
    /* 0x00 */ u16 species;
    /* 0x02 */ u16 heldItem;
    /* 0x04 */ u32 otID; // low 16: visible; high 16: secret
    /* 0x08 */ u32 exp;
    /* 0x0C */ u8 friendship;
    /* 0x0D */ u8 ability;
    /* 0x0E */ u8 markings; // circle, triangle, square, heart, star, diamond
    /* 0x0F */ u8 originLanguage;
    /* 0x10 */ u8 hpEV;
    /* 0x11 */ u8 atkEV;
    /* 0x12 */ u8 defEV;
    /* 0x13 */ u8 spdEV;
    /* 0x14 */ u8 spatkEV;
    /* 0x15 */ u8 spdefEV;
    /* 0x16 */ u8 coolStat;
    /* 0x17 */ u8 beautyStat;
    /* 0x18 */ u8 cuteStat;
    /* 0x19 */ u8 smartStat;
    /* 0x1A */ u8 toughStat;
    /* 0x1B */ u8 sheen;
    // TODO: Finish SinnohRibbonSet1
    /* 0x1C */ u32 sinnohRibbons;
//    u8 sinnohChampRibbon:1, abilityRibbon:1;
//    u8 field_0x1d;
//    u8 gorgeousRoyalRibbon:1, footprintRibbon:1;
//    u8 field_0x1f;
} PokemonDataBlockA;

typedef struct {
    /* 0x00 */ u16 moves[4];
    /* 0x08 */ u8 movePP[4];
    /* 0x0C */ u8 movePpUps[4];
    /* 0x10 */ u32 hpIV:5, atkIV:5, defIV:5, spdIV:5, spatkIV:5, spdefIV:5, isEgg:1, isNicknamed:1;
    // TODO: Finish HoennRibbonSet
    /* 0x14 */ u32 ribbonFlags; // cool, ...
    /* 0x18 */ u8 fatefulEncounter:1, gender:2, alternateForm:5;
    /* 0x19 */ u8 HGSS_shinyLeaves; // TODO: Turn into bitfield
    /* 0x1A */ u16 Unused;
    /* 0x1C */ u16 Platinum_EggLocation;
    /* 0x1E */ u16 Platinum_MetLocation;
} PokemonDataBlockB;

typedef struct {
    /* 0x00 */ u16 nickname[11];
    /* 0x16 */ u8 Unused;
    /* 0x17 */ u8 originGame;
    // TODO: Finish SinnohRibbonSet2
    /* 0x18 */ u64 sinnohRibbons2; // cool, ...
} PokemonDataBlockC;

typedef struct {
    /* 0x00 */ u16 otTrainerName[8];
    /* 0x10 */ u8 dateEggReceived[3];
    /* 0x13 */ u8 dateMet[3];
    /* 0x16 */ u16 DP_EggLocation;
    /* 0x18 */ u16 DP_MetLocation;
    /* 0x1A */ u8 pokerus;
    /* 0x1B */ u8 pokeball;
    /* 0x1C */ u8 metLevel:7;
               u8 metGender:1;
    /* 0x1D */ u8 encounterType;
    /* 0x1E */ u16 HGSS_Pokeball;
} PokemonDataBlockD;

typedef union {
    PokemonDataBlockA blockA;
    PokemonDataBlockB blockB;
    PokemonDataBlockC blockC;
    PokemonDataBlockD blockD;
} PokemonDataBlock;

struct BoxPokemon {
    /* 0x000 */ u32 pid;
    /* 0x004 */ u16 party_lock:1;
                u16 box_lock:1;
                u16 checksum_fail:1;
                u16 Unused:13;    // Might be used for validity checks
    /* 0x006 */ u16 checksum;  // Stored checksum of pokemon
    /* 0x008 */ PokemonDataBlock substructs[4];
};

struct PartyPokemon
{
    /* 0x088 */ u32 status; // slp:3, psn:1, brn:1, frz:1, prz:1, tox:1, ...
    /* 0x08C */ u8 level;
    /* 0x08D */ u8 capsule;
    /* 0x08E */ u16 hp;
    /* 0x090 */ u16 maxHp;
    /* 0x092 */ u16 atk;
    /* 0x094 */ u16 def;
    /* 0x096 */ u16 speed;
    /* 0x098 */ u16 spatk;
    /* 0x09A */ u16 spdef;
    /* 0x09C */ struct Mail mail;
    /* 0x0D4 */ u8 sealCoords[8][3]; // seal coords
};

struct Pokemon {
    /* 0x000 */ struct BoxPokemon box;
    /* 0x088 */ struct PartyPokemon party;
}; // size: 0xEC

struct SomeDrawPokemonStruct
{
    u16 unk0;
    u16 unk2;
    u16 unk4;
    u16 unk6;
    u8 unk8;
    u8 filler_9[3];
    u32 unkC;
};

struct PokeanmSub
{
    s8 unk0;
    u8 unk1;
};

struct Pokeanm
{
    struct PokeanmSub unk0[4];
    u8 unk8[20];
};

struct UnkStruct_02069038
{
    u16 unk0;
    u16 unk2;
    u8 unk4;
    u8 padding;
    struct Pokeanm anim;
};

struct Evolution
{
    u16 method;
    u16 param;
    u16 target;
};

#define PARTY_SIZE 6

struct PlayerParty
{
    int maxCount;
    int curCount;
    struct Pokemon mons[PARTY_SIZE];
};

void ZeroMonData(struct Pokemon * pokemon);
void ZeroBoxMonData(struct BoxPokemon * boxmon);
u32 SizeOfStructPokemon(void);
struct Pokemon * AllocMonZeroed(u32 heap_id);
BOOL AcquireMonLock(struct Pokemon * mon);
BOOL ReleaseMonLock(struct Pokemon * mon, BOOL decrypt_result);
BOOL AcquireBoxMonLock(struct BoxPokemon * mon);
BOOL ReleaseBoxMonLock(struct BoxPokemon * mon, BOOL decrypt_result);
void CreateMon(struct Pokemon * pokemon, int species, int level, int fixedIV, int hasFixedPersonality, int fixedPersonality, int otIdType, int fixedOtId);
void CreateBoxMon(struct BoxPokemon * boxPokemon, int species, int level, int fixedIV, int hasFixedPersonality, int fixedPersonality, int otIdType, int fixedOtId);
void CreateMonWithNature(struct Pokemon * pokemon, u16 species, u8 level, u8 fixedIv, u8 nature);
void CreateMonWithGenderNatureLetter(struct Pokemon * pokemon, u16 species, u8 level, u8 fixedIv, u8 gender, u8 nature, u8 letter);
u32 GenPersonalityByGenderAndNature(u16 species, u8 gender, u8 nature);
void CreateMonWithFixedIVs(struct Pokemon * pokemon, int species, int level, int ivs, int personality);
void CalcMonLevelAndStats(struct Pokemon * pokemon);
void CalcMonStats(struct Pokemon * pokemon);
#ifndef IN_POKEMON_C
u32 GetMonData();
u32 GetBoxMonData();
#else
u32 GetMonData(struct Pokemon * pokemon, int attr, void * ptr);
u32 GetBoxMonData(struct BoxPokemon * pokemon, int attr, void * ptr);
#endif
void SetMonData(struct Pokemon * pokemon, int attr, void * ptr);
void SetBoxMonData(struct BoxPokemon * pokemon, int attr, void * ptr);
void AddMonData(struct Pokemon * pokemon, int attr, int amount);
struct BaseStats * AllocAndLoadMonPersonal(int species, u32 heap_id);
int GetPersonalAttr(struct BaseStats * baseStats, enum BaseStat attr);
void FreeMonPersonal(struct BaseStats * personal);
int GetMonBaseStat_HandleFormeConversion(int species, int form, enum BaseStat stat_id);
int GetMonBaseStat(int species, enum BaseStat stat_id);
u8 GetPercentProgressTowardsNextLevel(struct Pokemon * pokemon);
u32 CalcMonExpToNextLevel(struct Pokemon * pokemon);
u32 GetMonBaseExperienceAtCurrentLevel(struct Pokemon * pokemon);
u32 GetMonExpBySpeciesAndLevel(int species, int level);
void LoadGrowthTable(int growthRate, u32 * table);
u32 GetExpByGrowthRateAndLevel(int rate, int level);
int CalcMonLevel(struct Pokemon * pokemon);
int CalcBoxMonLevel(struct BoxPokemon * boxmon);
int CalcLevelBySpeciesAndExp(u16 species, u32 experience);
int CalcLevelBySpeciesAndExp_PreloadedPersonal(struct BaseStats * personal, u16 species, u32 experience);
u8 GetBoxMonNature(struct BoxPokemon * boxmon);
u8 GetMonNature(struct Pokemon * mon);
u8 GetNatureFromPersonality(u32 pid);
void MonApplyFriendshipMod(struct Pokemon * pokemon, u32 kind, u32 location);
u8 GetMonGender(struct Pokemon * pokemon);
u8 GetBoxMonGender(struct BoxPokemon * boxmon);
u8 GetGenderBySpeciesAndPersonality(u16 species, u32 pid);
u8 MonIsShiny(struct Pokemon * pokemon);
u32 GenerateShinyPersonality(u32 otid);
void FUN_02068B70(struct SomeDrawPokemonStruct * spC, struct BoxPokemon * boxmon, u8 sp10);
void FUN_02068C00(struct SomeDrawPokemonStruct * spC, int species, u8 gender, u8 sp10, u8 shiny, u8 forme, u32 personality);
u8 FUN_02068E14(struct Pokemon * pokemon, u32 a1);
u8 FUN_02068E1C(struct BoxPokemon * boxmon, u32 a1);
u8 FUN_02068E88(int species, u8 gender, u32 a2, u8 forme, u32 pid);
u32 GetArceusTypeByHeldItemEffect(u16 plate);
int FUN_0206AA30(int a0);
void FUN_02068B68(struct SomeDrawPokemonStruct * spC, struct Pokemon * pokemon, u8 sp10);
void FUN_02068FE0(struct SomeDrawPokemonStruct * a0, u16 a1, int a2);
void FUN_02069010(void * dest, int a1);
void FUN_02069038(u32 a0, u32 a1, u32 a2, s32 a3, u32 a4, u32 a5, u32 a6);
void FUN_020690AC(struct SomeDrawPokemonStruct * a0, u32 a1);
u32 FUN_020690C4(void);
u32 FUN_020690C8(void);
u8 GetBoxMonUnownLetter(struct BoxPokemon * boxmon);
u8 GetMonUnownLetter(struct Pokemon * pokemon);
struct BoxPokemon * FUN_020690E4(struct Pokemon * pokemon);

u16 GetMonEvolution(struct PlayerParty * party, struct Pokemon * pokemon, u32 context, u32 usedItem, u32 * method_ret);
u16 ReadFromPersonalPmsNarc(u16 species);
u16 GetEggSpecies(u16 species);
BOOL FUN_020690E8(struct Pokemon * pokemon);
u32 FUN_02069698(struct Pokemon * pokemon, u16 move);
void FUN_02069708(struct Pokemon * pokemon, u16 move);
void FUN_02069718(struct BoxPokemon * boxmon, u16 move);
void MonSetMoveInSlot(struct Pokemon * pokemon, u16 move, u8 slot);
u32 FUN_02069818(struct Pokemon * pokemon, u32 * r5, u16 * sp0);
void FUN_020698E0(struct Pokemon * pokemon, int slot1, int slot2);
void FUN_020698E8(struct BoxPokemon * boxmon, int slot1, int slot2);
void FUN_020699A4(struct Pokemon * pokemon, u32 slot);
void CopyBoxPokemonToPokemon(struct BoxPokemon * src, struct Pokemon * dest);
u8 Party_GetMaxLevel(struct PlayerParty * party);
u16 SpeciesToSinnohDexNo(u16 species);
u16 SinnohDexNoToSpecies(u16 sinnoh_dex);
void CopyPokemonToPokemon(struct Pokemon * src, struct Pokemon * dest);
void CopyPokemonToBoxPokemon(struct Pokemon * src, struct BoxPokemon * dest);
void CopyBoxPokemonToBoxPokemon(struct BoxPokemon * src, struct BoxPokemon * dest);
s8 MonGetFlavorPreference(struct Pokemon * pokemon, int flavor);
int Species_LoadLearnsetTable(u16 species, u32 forme, u16 * dest);
void Party_GivePokerusAtRandom(struct PlayerParty * party);
void Party_UpdatePokerus(struct PlayerParty * party, int r5);
void Party_SpreadPokerus(struct PlayerParty * party);
BOOL Pokemon_HasPokerus(struct Pokemon * pokemon);
BOOL Pokemon_IsImmuneToPokerus(struct Pokemon * pokemon);
void Pokemon_UpdateArceusForme(struct Pokemon * pokemon);
void FUN_02069FB0(struct SaveChatotSoundClip *r7, u32 r5, u16 r4, s32 r6, s32 sp18, u32 sp1C, u32 sp20);
void FUN_0206A014(struct Pokemon * pokemon, struct PlayerData * a1, u32 pokeball, u32 a3, u32 encounterType, u32 heap_id);
void FUN_0206A094(struct Pokemon * pokemon, u32 a1, u32 a2);
BOOL FUN_0206A13C(struct Pokemon * pokemon, u32 a1);
void FUN_0206A1C4(struct Pokemon * pokemon);
void FUN_0206A23C(struct Pokemon * r5, u32 personality);
int LowestFlagNo(u32 mask);
BOOL IsPokemonLegendaryOrMythical(u16 species);
u16 GetLegendaryMon(u32 idx);
BOOL FUN_0206A998(struct Pokemon * pokemon);
BOOL FUN_0206A9AC(struct BoxPokemon * boxmon, struct PlayerData * sb2, u32 heap_id);
void Pokemon_RemoveCapsule(struct Pokemon * pokemon);
void RestoreBoxMonPP(struct BoxPokemon * boxmon);

#endif //POKEDIAMOND_POKEMON_H