Skip to content

Commit

Permalink
Merge pull request #105 from lhearachel/pokeicon
Browse files Browse the repository at this point in the history
Clean-up and document pokemon_icon.c
  • Loading branch information
lhearachel authored Nov 4, 2023
2 parents 04363ae + 61855cc commit a0a56b8
Show file tree
Hide file tree
Showing 49 changed files with 1,119 additions and 958 deletions.
598 changes: 598 additions & 0 deletions include/data/pokeicon_palettes.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions include/pokemon.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef POKEPLATINUM_UNK_02073C2C_H
#define POKEPLATINUM_UNK_02073C2C_H
#ifndef POKEPLATINUM_POKEMON_H
#define POKEPLATINUM_POKEMON_H

#include "struct_decls/struct_02002F38_decl.h"
#include "struct_decls/struct_02006C24_decl.h"
Expand Down Expand Up @@ -870,4 +870,4 @@ BOOL Pokemon_SetBallSeal(int param0, Pokemon *mon, int heapID);
void sub_02078B40(Pokemon *mon, UnkStruct_02078B40 *param1);
void sub_02078E0C(UnkStruct_02078B40 *param0, Pokemon *mon);

#endif // POKEPLATINUM_UNK_02073C2C_H
#endif // POKEPLATINUM_POKEMON_H
122 changes: 122 additions & 0 deletions include/pokemon_icon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#ifndef POKEPLATINUM_POKEMON_ICON_H
#define POKEPLATINUM_POKEMON_ICON_H

#include "pokemon.h"

/**
* @brief Get the index of the sprite-tiles file used for a given BoxPokemon.
*
* @param mon
* @return Index of the sprite-tiles file for this Pokemon in pl_poke_icon.narc
*/
u32 BoxPokemon_IconSpriteIndex(const BoxPokemon *mon);

/**
* @brief Get the index of the sprite-tiles file used for a given Pokemon.
*
* @param mon
* @return Index of the sprite-tiles file for this Pokemon in pl_poke_icon.narc
*/
u32 Pokemon_IconSpriteIndex(Pokemon *mon);

/**
* @brief Get the index of the sprite-tiles file used for a given combination
* of species+form and whether or not the Pokemon is in an egg.
*
* @param species
* @param isEgg
* @param form
* @return Index of the sprite-tiles file for the given tuple in pl_poke_icon.narc
*/
u32 PokeIconSpriteIndex(u32 species, u32 isEgg, u32 form);

/**
* @brief Get the form offset for a given BoxPokemon's icon.
*
* In essence, this is just a nice wrapper around BoxPokemon_GetForm for species
* known to have alternate forms (visual or mechanical).
*
* @param mon
* @return Form offset
*/
u16 BoxPokemon_IconFormOffset(const BoxPokemon *mon);

/**
* @brief Get the index of the palette used by a given combination of species+form
* and whether or not the Pokemon is in an egg.
*
* @param species
* @param form
* @param isEgg
* @return Index in the shared palette file for all Pokemon icons.
*/
const u8 PokeIconPaletteIndex(u32 species, u32 form, u32 isEgg);

/**
* @brief Get the index of the palette used by a given BoxPokemon.
*
* @param mon
* @return Index in the shared palette file for all Pokemon icons.
*/
const u8 BoxPokemon_IconPaletteIndex(const BoxPokemon *mon);

/**
* @brief Get the index of the palette used by a given Pokemon.
*
* @param mon
* @return Index in the shared palette file for all Pokemon icons.
*/
const u8 Pokemon_IconPaletteIndex(Pokemon *mon);

/**
* @brief Get the file-index of the shared palettes file in pl_poke_icon.narc.
*
* @return File-index of the shared palettes file
*/
u32 PokeIconPalettesFileIndex(void);

/**
* @brief Get the file-index of the shared cells file in pl_poke_icon.narc.
*
* @return File-index of the shared cells file
*/
u32 PokeIconCellsFileIndex(void);

/**
* @brief Get the file-index of the shared 32K cells file in pl_poke_icon.narc.
*
* @return File-index of the shared cells file
*/
u32 PokeIcon32KCellsFileIndex(void);

/**
* @brief Get the file-index of the shared 64K cells file in pl_poke_icon.narc.
*
* @return File-index of the shared cells file
*/
u32 PokeIcon64KCellsFileIndex(void);

/**
* @brief Get the file-index of the shared animation file in pl_poke_icon.narc.
*
* @return File-index of the shared animation file
*/
u32 PokeIconAnimationFileIndex(void);

/**
* @brief Get the file-index of the shared 32K animation file in
* pl_poke_icon.narc.
*
* @return File-index of the shared 32K animation file
*/
u32 PokeIcon32KAnimationFileIndex(void);

/**
* @brief Get the file-index of the shared 64K animation file in
* pl_poke_icon.narc.
*
* @return File-index of the shared 64K animation file
*/
u32 PokeIcon64KAnimationFileIndex(void);

#endif // POKEPLATINUM_POKEMON_ICON_H
21 changes: 0 additions & 21 deletions include/unk_02079D40.h

This file was deleted.

2 changes: 1 addition & 1 deletion platinum.us/main.lsf
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Static main
Object main.nef.p/src_move_table.c.o
Object main.nef.p/src_trainer_data.c.o
Object main.nef.p/src_unk_020797C8.c.o
Object main.nef.p/src_unk_02079D40.c.o
Object main.nef.p/src_pokemon_icon.c.o
Object main.nef.p/src_party.c.o
Object main.nef.p/src_unk_0207A274.c.o
Object main.nef.p/src_unk_0207A2A8.c.o
Expand Down
2 changes: 1 addition & 1 deletion src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pokeplatinum_c = files(
'pokemon.c',
'trainer_data.c',
'unk_020797C8.c',
'unk_02079D40.c',
'pokemon_icon.c',
'unk_0207A274.c',
'unk_0207A2A8.c',
'unk_0207A6DC.c',
Expand Down
14 changes: 7 additions & 7 deletions src/overlay010/ov10_0221F800.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#include "map_header.h"
#include "pokemon.h"
#include "trainer_data.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "party.h"
#include "item.h"
#include "unk_0207D3B8.h"
Expand Down Expand Up @@ -2033,13 +2033,13 @@ static void ov10_02221D14 (UnkStruct_ov10_0221FB28 * param0, Party * param1, u8

for (v1 = 0; v1 < 3; v1++) {
if (v2 <= v1) {
param0->unk_214[v1 + param2].unk_00 = sub_02079D8C(0, 0, 0);
param0->unk_214[v1 + param2].unk_00 = PokeIconSpriteIndex(0, 0, 0);
continue;
}

v0 = Party_GetPokemonBySlotIndex(param1, v1);

param0->unk_214[v1 + param2].unk_00 = sub_02079D80(v0);
param0->unk_214[v1 + param2].unk_00 = Pokemon_IconSpriteIndex(v0);
param0->unk_214[v1 + param2].unk_04 = (u16)Pokemon_GetValue(v0, MON_DATA_SPECIES, NULL);

if (param0->unk_214[v1 + param2].unk_04 == 0) {
Expand Down Expand Up @@ -2111,7 +2111,7 @@ static void ov10_02221EEC (UnkStruct_ov10_0221FB28 * param0, u32 param1)
sub_0200D3F4(param0->unk_198[param1 * 5 + v0], 0);
}
} else {
sub_0200D41C(param0->unk_198[param1 * 5 + 0], sub_02079EDC(param0->unk_214[param1].unk_04, param0->unk_214[param1].unk_11, param0->unk_214[param1].unk_0F));
sub_0200D41C(param0->unk_198[param1 * 5 + 0], PokeIconPaletteIndex(param0->unk_214[param1].unk_04, param0->unk_214[param1].unk_11, param0->unk_214[param1].unk_0F));
sub_0200D364(param0->unk_198[param1 * 5 + 0], ov10_02221E84(param0, param1));

if (param0->unk_214[param1].unk_0A == 0) {
Expand Down Expand Up @@ -2165,9 +2165,9 @@ static void ov10_022220B4 (UnkStruct_ov10_0221FB28 * param0)

v1 = NARC_ctor(NARC_INDEX_POKETOOL__ICONGRA__PL_POKE_ICON, param0->unk_00->unk_24);

sub_0200CD0C(param0->unk_190, param0->unk_194, v1, sub_02079FD0(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 47112);
sub_0200CE24(param0->unk_190, param0->unk_194, v1, sub_02079FD8(), 0, 47113);
sub_0200CE54(param0->unk_190, param0->unk_194, v1, sub_02079FE4(), 0, 47113);
sub_0200CD0C(param0->unk_190, param0->unk_194, v1, PokeIconPalettesFileIndex(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 47112);
sub_0200CE24(param0->unk_190, param0->unk_194, v1, PokeIcon32KCellsFileIndex(), 0, 47113);
sub_0200CE54(param0->unk_190, param0->unk_194, v1, PokeIcon32KAnimationFileIndex(), 0, 47113);

for (v0 = 0; v0 < 6; v0++) {
sub_0200CC3C(param0->unk_190, param0->unk_194, v1, param0->unk_214[v0].unk_00, 0, NNS_G2D_VRAM_TYPE_2DMAIN, 47113 + v0);
Expand Down
14 changes: 7 additions & 7 deletions src/overlay013/ov13_02224500.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "unk_0200C6E4.h"
#include "gx_layers.h"
#include "move_table.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "party.h"
#include "unk_0207C908.h"
#include "item.h"
Expand Down Expand Up @@ -255,15 +255,15 @@ static void ov13_02224588 (UnkStruct_ov13_022213F0 * param0)
v2 = NARC_ctor(NARC_INDEX_POKETOOL__ICONGRA__PL_POKE_ICON, param0->unk_00->unk_0C);
v0 = ov16_0223E010(param0->unk_00->unk_08);

sub_0200CDC4(param0->unk_1E4, 3, v0, param0->unk_1FB0, v2, sub_02079FD0(), 0, 3, NNS_G2D_VRAM_TYPE_2DSUB, 45063);
sub_0200CE24(v0, param0->unk_1FB0, v2, sub_02079FD8(), 0, 45063);
sub_0200CE54(v0, param0->unk_1FB0, v2, sub_02079FE4(), 0, 45063);
sub_0200CDC4(param0->unk_1E4, 3, v0, param0->unk_1FB0, v2, PokeIconPalettesFileIndex(), 0, 3, NNS_G2D_VRAM_TYPE_2DSUB, 45063);
sub_0200CE24(v0, param0->unk_1FB0, v2, PokeIcon32KCellsFileIndex(), 0, 45063);
sub_0200CE54(v0, param0->unk_1FB0, v2, PokeIcon32KAnimationFileIndex(), 0, 45063);

for (v1 = 0; v1 < 6; v1++) {
if (param0->unk_04[v1].unk_04 != 0) {
sub_0200CC3C(v0, param0->unk_1FB0, v2, sub_02079D80(param0->unk_04[v1].unk_00), 0, NNS_G2D_VRAM_TYPE_2DSUB, 45063 + v1);
sub_0200CC3C(v0, param0->unk_1FB0, v2, Pokemon_IconSpriteIndex(param0->unk_04[v1].unk_00), 0, NNS_G2D_VRAM_TYPE_2DSUB, 45063 + v1);
} else {
sub_0200CC3C(v0, param0->unk_1FB0, v2, sub_02079D8C(0, 0, 0), 0, NNS_G2D_VRAM_TYPE_2DSUB, 45063 + v1);
sub_0200CC3C(v0, param0->unk_1FB0, v2, PokeIconSpriteIndex(0, 0, 0), 0, NNS_G2D_VRAM_TYPE_2DSUB, 45063 + v1);
}
}

Expand Down Expand Up @@ -392,7 +392,7 @@ static void ov13_022249CC (UnkStruct_ov13_022213F0 * param0)
continue;
}

sub_0200D41C(param0->unk_1FB4[7 + v0], sub_02079EDC(param0->unk_04[v0].unk_04, param0->unk_04[v0].unk_2E, param0->unk_04[v0].unk_17_7));
sub_0200D41C(param0->unk_1FB4[7 + v0], PokeIconPaletteIndex(param0->unk_04[v0].unk_04, param0->unk_04[v0].unk_2E, param0->unk_04[v0].unk_17_7));
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/overlay016/battle_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
#include "unk_020218BC.h"
#include "unk_02022594.h"
#include "unk_020797C8.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "unk_0207A274.h"
#include "unk_0208694C.h"
#include "unk_0208C098.h"
Expand Down Expand Up @@ -12249,14 +12249,14 @@ static void BattleScript_LoadPartyLevelUpIcon (BattleSystem * param0, BattleScri
param1->cellActorData[0] = sub_0200CE6C(v1, v2, &Unk_ov16_0226E6C4);

sub_0200D330(param1->cellActorData[0]);
sub_0200D888(v1, v2, 19, sub_02079D80(param2), 0, NNS_G2D_VRAM_TYPE_2DMAIN, 20022);
sub_0200CD7C(v3, 2, v1, v2, 19, sub_02079FD0(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 20017);
sub_0200CE0C(v1, v2, 19, sub_02079FDC(), 0, 20014);
sub_0200CE3C(v1, v2, 19, sub_02079FE8(), 0, 20014);
sub_0200D888(v1, v2, 19, Pokemon_IconSpriteIndex(param2), 0, NNS_G2D_VRAM_TYPE_2DMAIN, 20022);
sub_0200CD7C(v3, 2, v1, v2, 19, PokeIconPalettesFileIndex(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 20017);
sub_0200CE0C(v1, v2, 19, PokeIcon64KCellsFileIndex(), 0, 20014);
sub_0200CE3C(v1, v2, 19, PokeIcon64KAnimationFileIndex(), 0, 20014);

param1->cellActorData[1] = sub_0200CE6C(v1, v2, &Unk_ov16_0226E6F8);

sub_02021F24(param1->cellActorData[1]->unk_00, sub_02079FC4(param2));
sub_02021F24(param1->cellActorData[1]->unk_00, Pokemon_IconPaletteIndex(param2));
sub_0200D330(param1->cellActorData[1]);

param1->tmpPtr[0] = sub_02012744(1, 5);
Expand Down
12 changes: 6 additions & 6 deletions src/overlay016/ov16_0226871C.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include "strbuf.h"
#include "pokemon.h"
#include "move_table.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "unk_0207C908.h"
#include "unk_0208C098.h"
#include "overlay011/ov11_0221F800.h"
Expand Down Expand Up @@ -2448,9 +2448,9 @@ static void ov16_0226A698 (UnkStruct_ov16_02268A14 * param0)
v1 = ov16_0223E018(param0->unk_00);
v5 = BattleSystem_PaletteSys(param0->unk_00);

sub_0200CD7C(v5, 3, v0, v1, 19, sub_02079FD0(), 0, 3, NNS_G2D_VRAM_TYPE_2DSUB, 20022);
sub_0200CE0C(v0, v1, 19, sub_02079FD8(), 0, 20021);
sub_0200CE3C(v0, v1, 19, sub_02079FE4(), 0, 20021);
sub_0200CD7C(v5, 3, v0, v1, 19, PokeIconPalettesFileIndex(), 0, 3, NNS_G2D_VRAM_TYPE_2DSUB, 20022);
sub_0200CE0C(v0, v1, 19, PokeIcon32KCellsFileIndex(), 0, 20021);
sub_0200CE3C(v0, v1, 19, PokeIcon32KAnimationFileIndex(), 0, 20021);
}

static void ov16_0226A718 (UnkStruct_ov16_02268A14 * param0)
Expand Down Expand Up @@ -2522,7 +2522,7 @@ static CellActorData * ov16_0226A7A4 (UnkStruct_ov16_02268A14 * param0, Pokemon
v0 = ov16_0223E010(param0->unk_00);
v1 = ov16_0223E018(param0->unk_00);

sub_0200CBDC(v0, v1, 19, sub_02079D80(param1), 0, NNS_G2D_VRAM_TYPE_2DSUB, v2);
sub_0200CBDC(v0, v1, 19, Pokemon_IconSpriteIndex(param1), 0, NNS_G2D_VRAM_TYPE_2DSUB, v2);

v3 = Unk_ov16_022704B0;
v3.unk_14[0] = v2;
Expand All @@ -2531,7 +2531,7 @@ static CellActorData * ov16_0226A7A4 (UnkStruct_ov16_02268A14 * param0, Pokemon
v4 = sub_0200CE6C(v0, v1, &v3);

sub_0200D500(v4, v3.unk_00, v3.unk_02, ((192 + 80) << FX32_SHIFT));
sub_02021F24(v4->unk_00, sub_02079FC4(param1));
sub_02021F24(v4->unk_00, Pokemon_IconPaletteIndex(param1));

{
int v6 = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/overlay017/ov17_02250744.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "strbuf.h"
#include "unk_020279FC.h"
#include "pokemon.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "unk_020933F8.h"
#include "unk_02094EDC.h"
#include "overlay017/ov17_0223F118.h"
Expand Down Expand Up @@ -407,20 +407,20 @@ void ov17_02250DB0 (UnkStruct_ov17_0224FCA0 * param0)

v3 = NARC_ctor(NARC_INDEX_POKETOOL__ICONGRA__PL_POKE_ICON, 24);

sub_0200CDC4(param0->unk_10.unk_C0, 2, param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, sub_02079FD0(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 33003);
sub_0200CE24(param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, sub_02079FDC(), 0, 33002);
sub_0200CE54(param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, sub_02079FE8(), 0, 33002);
sub_0200CDC4(param0->unk_10.unk_C0, 2, param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, PokeIconPalettesFileIndex(), 0, 3, NNS_G2D_VRAM_TYPE_2DMAIN, 33003);
sub_0200CE24(param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, PokeIcon64KCellsFileIndex(), 0, 33002);
sub_0200CE54(param0->unk_10.unk_18, param0->unk_10.unk_1C, v3, PokeIcon64KAnimationFileIndex(), 0, 33002);

v0 = Unk_ov17_02254C5C;

for (v2 = 0; v2 < 4; v2++) {
sub_0200D888(param0->unk_10.unk_18, param0->unk_10.unk_1C, 19, sub_02079D80(param0->unk_00->unk_00.unk_00[v2]), 0, NNS_G2D_VRAM_TYPE_2DMAIN, 33002 + v2);
sub_0200D888(param0->unk_10.unk_18, param0->unk_10.unk_1C, 19, Pokemon_IconSpriteIndex(param0->unk_00->unk_00.unk_00[v2]), 0, NNS_G2D_VRAM_TYPE_2DMAIN, 33002 + v2);

v0.unk_14[0] = 33002 + v2;
param0->unk_10.unk_128[v2] = sub_0200CE6C(param0->unk_10.unk_18, param0->unk_10.unk_1C, &v0);

sub_0200D364(param0->unk_10.unk_128[v2], 1);
sub_02021F24(param0->unk_10.unk_128[v2]->unk_00, sub_02079FC4(param0->unk_00->unk_00.unk_00[v2]));
sub_02021F24(param0->unk_10.unk_128[v2]->unk_00, Pokemon_IconPaletteIndex(param0->unk_00->unk_00.unk_00[v2]));
sub_0200D330(param0->unk_10.unk_128[v2]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/overlay019/ov19_021D79F8.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "unk_020218BC.h"
#include "pokemon.h"
#include "unk_020797C8.h"
#include "unk_02079D40.h"
#include "pokemon_icon.h"
#include "overlay019/ov19_021D0D80.h"
#include "overlay019/ov19_021D61B0.h"
#include "overlay019/ov19_021D79F8.h"
Expand Down Expand Up @@ -437,7 +437,7 @@ static void ov19_021D813C (UnkStruct_ov19_021D8318 * param0, u32 param1)

if (v3) {
param0->unk_5814[v2] = v3;
param0->unk_57D8[v2] = sub_02079D40(v1);
param0->unk_57D8[v2] = BoxPokemon_IconSpriteIndex(v1);
ov19_021DA744(param0->unk_58F0, param0->unk_CD8[v2], param0->unk_57D8[v2], ((4 * 4) * 0x20 + 0x80));
}
}
Expand Down
Loading

0 comments on commit a0a56b8

Please sign in to comment.