Skip to content

Commit

Permalink
Merge pull request #106 from lhearachel/pokegra
Browse files Browse the repository at this point in the history
Document functions for loading front/back Pokemon sprites
  • Loading branch information
lhearachel authored Nov 4, 2023
2 parents a0a56b8 + 9b3f227 commit 9d26c9f
Show file tree
Hide file tree
Showing 49 changed files with 514 additions and 416 deletions.
4 changes: 2 additions & 2 deletions include/overlay016/struct_ov16_0225EA80.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POKEPLATINUM_STRUCT_OV16_0225EA80_H
#define POKEPLATINUM_STRUCT_OV16_0225EA80_H

#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_decls/battle_system.h"
#include "overlay012/struct_ov12_0221FCDC_decl.h"
#include "overlay012/struct_ov12_02223764.h"
Expand All @@ -16,7 +16,7 @@ typedef struct {
UnkStruct_ov12_02235FE0 * unk_08;
BallRotation * unk_0C;
UnkStruct_ov12_02223764 * unk_10;
UnkStruct_02008A90 unk_14;
ArchivedSprite unk_14;
UnkStruct_ov12_0221FCDC * unk_24;
UnkStruct_ov16_02265BBC unk_28;
u8 unk_80;
Expand Down
8 changes: 4 additions & 4 deletions include/overlay022/ov22_022578F4.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef POKEPLATINUM_OV22_022578F4_H
#define POKEPLATINUM_OV22_022578F4_H

#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "pokemon.h"
#include "overlay022/struct_ov22_02257964.h"
#include "overlay022/struct_ov22_02259560.h"
Expand All @@ -12,9 +12,9 @@

void ov22_022578F4(UnkStruct_ov22_02257964 * param0, UnkStruct_ov22_0225B388 * param1);
void ov22_02257948(UnkStruct_ov22_02257964 * param0);
void ov22_02257964(UnkStruct_ov22_02257964 * param0, Pokemon * param1, UnkStruct_02008A90 * param2, int param3, int param4, int param5, int param6);
void ov22_02257998(UnkStruct_ov22_02257964 * param0, Pokemon * param1, UnkStruct_02008A90 * param2, int param3);
void ov22_022579B4(UnkStruct_ov22_02257964 * param0, Pokemon * param1, UnkStruct_02008A90 * param2, int param3);
void ov22_02257964(UnkStruct_ov22_02257964 * param0, Pokemon * param1, ArchivedSprite * param2, int param3, int param4, int param5, int param6);
void ov22_02257998(UnkStruct_ov22_02257964 * param0, Pokemon * param1, ArchivedSprite * param2, int param3);
void ov22_022579B4(UnkStruct_ov22_02257964 * param0, Pokemon * param1, ArchivedSprite * param2, int param3);
void ov22_022579D8(UnkStruct_ov22_02257964 * param0, UnkStruct_ov22_02259560 * param1);
void ov22_022579E8(UnkStruct_ov22_02259560 * param0);
void ov22_022579F0(UnkStruct_ov22_02257964 * param0);
Expand Down
8 changes: 4 additions & 4 deletions include/overlay022/ov22_02259098.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#define POKEPLATINUM_OV22_02259098_H

#include "struct_decls/struct_02007768_decl.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_defs/struct_020298D8.h"
#include "pokemon.h"
#include "overlay022/struct_ov22_022596B0.h"
#include "overlay022/struct_ov22_0225A0E4.h"

#include <nnsys.h>

void ov22_02259098(UnkStruct_ov22_0225A0E4 * param0, UnkStruct_02008A90 * param1);
void ov22_022590C0(UnkStruct_020298D8 * param0, UnkStruct_02007768 * param1, Pokemon * param2, UnkStruct_02008A90 * param3, int param4);
void ov22_022590D4(UnkStruct_020298D8 * param0, UnkStruct_02007768 * param1, Pokemon * param2, UnkStruct_02008A90 * param3, int param4, BOOL param5);
void ov22_02259098(UnkStruct_ov22_0225A0E4 * param0, ArchivedSprite * param1);
void ov22_022590C0(UnkStruct_020298D8 * param0, UnkStruct_02007768 * param1, Pokemon * param2, ArchivedSprite * param3, int param4);
void ov22_022590D4(UnkStruct_020298D8 * param0, UnkStruct_02007768 * param1, Pokemon * param2, ArchivedSprite * param3, int param4, BOOL param5);
void ov22_022591B8(UnkStruct_020298D8 * param0);
void ov22_022591D0(UnkStruct_020298D8 * param0, int param1);
int ov22_022591E0(UnkStruct_020298D8 * param0);
Expand Down
4 changes: 2 additions & 2 deletions include/overlay079/struct_ov79_021D3820.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
#define POKEPLATINUM_STRUCT_OV79_021D3820_H

#include "struct_decls/struct_02007C7C_decl.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_decls/struct_020203AC_decl.h"

typedef struct {
UnkStruct_020203AC * unk_00;
void * unk_04;
UnkStruct_02008A90 unk_08;
ArchivedSprite unk_08;
UnkStruct_02007C7C * unk_18;
} UnkStruct_ov79_021D3820;

Expand Down
63 changes: 56 additions & 7 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "struct_decls/struct_02006C24_decl.h"
#include "struct_defs/struct_02007C10.h"
#include "struct_decls/struct_02007C7C_decl.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_decls/struct_0200C6E4_decl.h"
#include "struct_decls/struct_0200C704_decl.h"
#include "struct_decls/cell_actor_data.h"
Expand All @@ -22,6 +22,9 @@
#define OTID_SET 1
#define OTID_NOT_SHINY 2

#define FACE_BACK 0
#define FACE_FRONT 2

/**
* @brief Pokemon Personal data structure. This contains data that is the same across all pokemon of the same species/form
*/
Expand Down Expand Up @@ -538,11 +541,57 @@ u8 Pokemon_IsShiny(Pokemon *mon);
*/
u8 Pokemon_IsPersonalityShiny(u32 monOTID, u32 monPersonality);

u32 sub_02075E64(u32 param0);
void sub_02075EF4(UnkStruct_02008A90 *param0, Pokemon *mon, u8 param2);
void sub_02075F00(UnkStruct_02008A90 *param0, Pokemon *mon, u8 param2);
void sub_02075F0C(UnkStruct_02008A90 *param0, BoxPokemon *boxMon, u8 param2, BOOL param3);
void sub_02075FB4(UnkStruct_02008A90 *param0, u16 monSpecies, u8 monGender, u8 param3, u8 monShininess, u8 monForm, u32 monPersonality);
/**
* @brief Computes a personality value which, when applied to the given trainer ID, will result
* in a shiny Pokemon.
*
* @param monOTID
* @return The computed personality value
*/
u32 Pokemon_FindShinyPersonality(u32 monOTID);

/**
* @brief Build an ArchivedSprite for a Pokemon.
*
* @param sprite Pointer to the sprite structure to be populated
* @param mon The Pokemon whose data will be used to build the sprite
* @param face Which face of the Pokemon the player sees
*/
void Pokemon_BuildArchivedSprite(ArchivedSprite *sprite, Pokemon *mon, u8 face);

/**
* @brief Build an ArchivedSprite for a Pokemon, preferring sprites from
* Diamond/Pearl where possible.
*
* @param sprite Pointer to the sprite structure to be populated
* @param mon The Pokemon whose data will be used to build the sprite
* @param face Which face of the Pokemon the player sees
*/
void Pokemon_BuildArchivedDPSprite(ArchivedSprite *sprite, Pokemon *mon, u8 face);

/**
* @brief Build an ArchivedSprite for a BoxPokemon.
*
* @param sprite Pointer to the sprite structure to be populated
* @param mon The Pokemon whose data will be used to build the sprite
* @param face Which face of the Pokemon the player sees
* @param preferDP If TRUE, prefer sprites from Diamond/Pearl over Platinum
*/
void BoxPokemon_BuildArchivedSprite(ArchivedSprite *sprite, BoxPokemon *boxMon, u8 face, BOOL preferDP);

/**
* @brief Build an ArchivedSprite for a Pokemon sprite according to the input
* species, form, and gender.
*
* @param sprite Pointer to the sprite structure to be populated
* @param species The Pokemon's species
* @param gender The Pokemon's gender
* @param face Which face of the Pokemon the player sees
* @param shiny 1 if the Pokemon is shiny, 0 if not
* @param form The Pokemon's form
* @param personality The Pokemon's personality value
*/
void BuildArchivedPokemonSprite(ArchivedSprite *sprite, u16 monSpecies, u8 monGender, u8 param3, u8 monShininess, u8 monForm, u32 monPersonality);

/**
* @brief Sanitizes a pokemon form. If the given form is greater than the max for the given species, returns zero, else returns the form unchanged
Expand All @@ -557,7 +606,7 @@ u8 sub_020765AC(Pokemon *mon, u8 param1);
u8 sub_020765B8(Pokemon *mon, u8 param1);
u8 sub_020765C4(BoxPokemon *boxMon, u8 param1, BOOL param2);
u8 sub_02076648(u16 monSpecies, u8 monGender, u8 param2, u8 monForm, u32 monPersonality);
void sub_0207697C(UnkStruct_02008A90 *param0, u16 param1);
void sub_0207697C(ArchivedSprite *param0, u16 param1);
CellActorData *sub_02076994(UnkStruct_0200C6E4 *param0, UnkStruct_0200C704 *param1, PaletteSys *param2, int param3, int param4, int param5, int param6, int param7, int heapID);
void sub_02076AAC(int param0, int param1, UnkStruct_ov5_021DE5D0 *param2);

Expand Down
15 changes: 15 additions & 0 deletions include/struct_defs/archived_sprite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef POKEPLATINUM_STRUCT_ARCHIVED_SPRITE_H
#define POKEPLATINUM_STRUCT_ARCHIVED_SPRITE_H

typedef struct ArchivedSprite {
u16 archive; //< ID of the sprite archive
u16 character; //< File index to pull from the archive for the character data (tiles)
u16 palette; //< File index to pull from the archive for the palette data
u16 spindaSpots; //< Simple flag denoting whether the rendered sprite should be pseudo-randomized with splotches (only for Spinda's front-sprite).

u8 dummy; //< Dummy value; never used or set to anything other than 0.

u32 personality; //< Cached personality value for Pokemon front-sprites. Specifically used for Spinda spots.
} ArchivedSprite;

#endif // POKEPLATINUM_STRUCT_ARCHIVED_SPRITE_H
6 changes: 3 additions & 3 deletions include/struct_defs/struct_02007C7C.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
#include "functypes/funcptr_02007C34.h"
#include "struct_defs/struct_02007C7C_sub1.h"
#include "struct_defs/struct_02007C7C_sub2.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"

typedef struct UnkStruct_02007C7C_t {
u32 unk_00_0 : 1;
u32 unk_00_1 : 6;
u32 unk_00_7 : 1;
u32 unk_00_8 : 1;
u32 : 23;
UnkStruct_02008A90 unk_04;
UnkStruct_02008A90 unk_14;
ArchivedSprite unk_04;
ArchivedSprite unk_14;
UnkStruct_02007C7C_sub1 unk_24;
u8 unk_58;
u8 unk_59;
Expand Down
14 changes: 0 additions & 14 deletions include/struct_defs/struct_02008A90.h

This file was deleted.

4 changes: 2 additions & 2 deletions include/struct_defs/struct_02095E80_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "struct_decls/struct_0200112C_decl.h"
#include "struct_decls/struct_02001AF4_decl.h"
#include "struct_decls/struct_020067E8_decl.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_decls/struct_02009714_decl.h"
#include "struct_decls/struct_02009DC8_decl.h"
#include "message.h"
Expand Down Expand Up @@ -104,7 +104,7 @@ struct UnkStruct_02095E80_t {
void * unk_7E8[12];
NNSG2dCharacterData * unk_818[12];
u8 unk_848[2][3200];
UnkStruct_02008A90 unk_2148[2];
ArchivedSprite unk_2148[2];
int unk_2168;
u8 unk_216C[256];
int (* unk_226C)(UnkStruct_02095E80 *);
Expand Down
8 changes: 4 additions & 4 deletions include/unk_0200762C.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
#include "functypes/funcptr_02007C34.h"
#include "struct_decls/struct_02007C7C_decl.h"
#include "struct_defs/struct_02008900.h"
#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"

void * sub_0200762C(int param0);
void sub_02007768(UnkStruct_02007768 * param0);
void sub_02007B6C(UnkStruct_02007768 * param0);
void sub_02007B98(UnkStruct_02007C7C * param0, int param1);
void sub_02007C10(UnkStruct_02007C7C * param0, UnkStruct_02007C10 * param1);
BOOL sub_02007C24(UnkStruct_02007C7C * param0);
UnkStruct_02007C7C * sub_02007C34(UnkStruct_02007768 * param0, UnkStruct_02008A90 * param1, int param2, int param3, int param4, int param5, UnkStruct_02007C10 * param6, UnkFuncPtr_02007C34 * param7);
UnkStruct_02007C7C * sub_02007C7C(UnkStruct_02007768 * param0, UnkStruct_02008A90 * param1, int param2, int param3, int param4, int param5, int param6, UnkStruct_02007C10 * param7, UnkFuncPtr_02007C34 * param8);
UnkStruct_02007C7C * sub_02007C34(UnkStruct_02007768 * param0, ArchivedSprite * param1, int param2, int param3, int param4, int param5, UnkStruct_02007C10 * param6, UnkFuncPtr_02007C34 * param7);
UnkStruct_02007C7C * sub_02007C7C(UnkStruct_02007768 * param0, ArchivedSprite * param1, int param2, int param3, int param4, int param5, int param6, UnkStruct_02007C10 * param7, UnkFuncPtr_02007C34 * param8);
void sub_02007DC8(UnkStruct_02007C7C * param0);
void sub_02007DD4(UnkStruct_02007768 * param0);
void sub_02007DEC(UnkStruct_02007C7C * param0, int param1, int param2);
Expand All @@ -34,7 +34,7 @@ void sub_020089B0(UnkStruct_02007C7C * param0);
void sub_02008A0C(UnkStruct_02007C7C * param0);
void sub_02008A78(UnkStruct_02007768 * param0, u32 param1, u32 param2);
void sub_02008A84(UnkStruct_02007768 * param0, u32 param1, u32 param2);
UnkStruct_02008A90 * sub_02008A90(UnkStruct_02007C7C * param0);
ArchivedSprite * sub_02008A90(UnkStruct_02007C7C * param0);
void sub_02008A94(UnkStruct_02007768 * param0);
void sub_02008B2C(UnkStruct_02007768 * param0, int param1);
BOOL sub_02008B38(UnkStruct_02007C7C * param0);
Expand Down
6 changes: 3 additions & 3 deletions src/overlay006/ov6_02240C9C.c
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ static void ov6_02241BAC (const u16 param0, const u8 param1, const int param2, c
}
}

v1 = sub_02075E64(param3);
v1 = Pokemon_FindShinyPersonality(param3);

if (v2) {
u8 v7, v8;
Expand All @@ -1174,15 +1174,15 @@ static void ov6_02241BAC (const u16 param0, const u8 param1, const int param2, c
if (v7 != v3) {
break;
} else {
v1 = sub_02075E64(param3);
v1 = Pokemon_FindShinyPersonality(param3);
}
} else if (param4->unk_0E == 28) {
v8 = Pokemon_GetNatureOf(v1);

if (v8 == v4) {
break;
} else {
v1 = sub_02075E64(param3);
v1 = Pokemon_FindShinyPersonality(param3);
}
}
} while (TRUE);
Expand Down
10 changes: 5 additions & 5 deletions src/overlay006/ov6_022426AC.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "struct_decls/struct_020218BC_decl.h"
#include "struct_decls/struct_02022550_decl.h"

#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_defs/struct_0200C738.h"
#include "overlay019/struct_ov19_021DA864.h"
#include "overlay115/struct_ov115_02261520.h"
Expand All @@ -30,7 +30,7 @@ typedef struct UnkStruct_ov6_022426B8_t {
UnkStruct_02009DC8 * unk_10[4];
void * unk_20;
void * unk_24;
UnkStruct_02008A90 unk_28;
ArchivedSprite unk_28;
UnkStruct_020218BC * unk_38;
UnkStruct_0200C738 unk_3C;
UnkStruct_02022550 * unk_1C8;
Expand Down Expand Up @@ -93,7 +93,7 @@ void ov6_022426C0 (UnkStruct_ov6_022426B8 * param0, const int param1)
}
}

sub_02075FB4(&param0->unk_28, param1, v2, 2, 0, NULL, NULL);
BuildArchivedPokemonSprite(&param0->unk_28, param1, v2, 2, 0, NULL, NULL);
}

param0->unk_38 = sub_020095C4(1, &param0->unk_3C, 4);
Expand All @@ -110,8 +110,8 @@ void ov6_022426C0 (UnkStruct_ov6_022426B8 * param0, const int param1)
param0->unk_10[3] = sub_02009BC4(param0->unk_00[3], v1, 12, 0, 3, 3, 4);
}

param0->unk_20 = sub_0201363C(param0->unk_28.unk_00, param0->unk_28.unk_02, 4);
param0->unk_24 = sub_02013660(param0->unk_28.unk_00, param0->unk_28.unk_04, 4);
param0->unk_20 = sub_0201363C(param0->unk_28.archive, param0->unk_28.character, 4);
param0->unk_24 = sub_02013660(param0->unk_28.archive, param0->unk_28.palette, 4);

ov6_02242880(param0->unk_00[0], param0->unk_00[1], param0->unk_20, param0->unk_24);

Expand Down
22 changes: 11 additions & 11 deletions src/overlay006/ov6_02243258.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "pokemon.h"
#include "overlay101/struct_ov101_021D5D90_decl.h"

#include "struct_defs/struct_02008A90.h"
#include "struct_defs/archived_sprite.h"
#include "struct_defs/struct_0200C738.h"
#include "struct_defs/struct_0203CDB0.h"
#include "overlay019/struct_ov19_021DA864.h"
Expand Down Expand Up @@ -87,7 +87,7 @@ typedef struct {
UnkStruct_02022550 * unk_24C;
UnkStruct_ov101_021D5D90 * unk_250;
UnkStruct_ov101_021D5D90 * unk_254;
UnkStruct_02008A90 unk_258;
ArchivedSprite unk_258;
int unk_268;
int unk_26C;
void * unk_270;
Expand Down Expand Up @@ -291,9 +291,9 @@ static void ov6_02244F80(UnkStruct_ov6_02243FFC * param0, fx32 param1, fx32 para
static void ov6_02244F8C(UnkStruct_ov6_02243FFC * param0);
static void ov6_02244FB4(UnkStruct_ov6_02243FFC * param0);
static void ov6_02244FE4(SysTask * param0, void * param1);
static void ov6_0224508C(UnkStruct_ov6_02243FFC * param0, UnkStruct_02008A90 * param1);
static void * ov6_0224509C(Pokemon * param0, UnkStruct_02008A90 * param1, u32 param2);
static void * ov6_022450E4(UnkStruct_02008A90 * param0, u32 param1);
static void ov6_0224508C(UnkStruct_ov6_02243FFC * param0, ArchivedSprite * param1);
static void * ov6_0224509C(Pokemon * param0, ArchivedSprite * param1, u32 param2);
static void * ov6_022450E4(ArchivedSprite * param0, u32 param1);
static UnkStruct_02009DC8 * ov6_022450F4(UnkStruct_ov6_02243FFC * param0, NARC * param1);
static void ov6_02245118(UnkStruct_ov6_02243FFC * param0, void * param1);
static UnkStruct_02009DC8 * ov6_0224514C(UnkStruct_ov6_02243FFC * param0, NARC * param1);
Expand Down Expand Up @@ -2057,28 +2057,28 @@ static void ov6_02244FE4 (SysTask * param0, void * param1)
G2_SetWnd0Position(v0->unk_44 / FX32_ONE, v0->unk_4C / FX32_ONE, v0->unk_48 / FX32_ONE, v0->unk_50 / FX32_ONE);
}

static void ov6_0224508C (UnkStruct_ov6_02243FFC * param0, UnkStruct_02008A90 * param1)
static void ov6_0224508C (UnkStruct_ov6_02243FFC * param0, ArchivedSprite * param1)
{
sub_02075EF4(param1, param0->unk_5C, 2);
Pokemon_BuildArchivedSprite(param1, param0->unk_5C, 2);
}

static void * ov6_0224509C (Pokemon * param0, UnkStruct_02008A90 * param1, u32 param2)
static void * ov6_0224509C (Pokemon * param0, ArchivedSprite * param1, u32 param2)
{
void * v0 = Heap_AllocFromHeap(4, (32 * 10) * 10);

GF_ASSERT(v0 != NULL);

{
int v1 = Pokemon_GetValue(param0, MON_DATA_PERSONALITY, NULL);
sub_02013750(param1->unk_00, param1->unk_02, param2, v0, v1, 0, 2, param1->unk_06);
sub_02013750(param1->archive, param1->character, param2, v0, v1, 0, 2, param1->spindaSpots);
}

return v0;
}

static void * ov6_022450E4 (UnkStruct_02008A90 * param0, u32 param1)
static void * ov6_022450E4 (ArchivedSprite * param0, u32 param1)
{
void * v0 = sub_02013660(param0->unk_00, param0->unk_04, param1);
void * v0 = sub_02013660(param0->archive, param0->palette, param1);
return v0;
}

Expand Down
Loading

0 comments on commit 9d26c9f

Please sign in to comment.