Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync some mon data and pokemon.c with pokeemerald #2

Merged
merged 8 commits into from
Mar 21, 2024
Prev Previous commit
Next Next commit
Rename some stuff in pokemon.c
  • Loading branch information
citrusbolt committed Feb 20, 2024
commit 17cff727bf956e71b3f204f3217ad809581cd69e
2 changes: 1 addition & 1 deletion payload/include/constants/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@
#define MOVE_DOOM_DESIRE 353
#define MOVE_PSYCHO_BOOST 354

#define NUM_MOVES 355
#define MOVES_COUNT 355

// Used for checks for moves affected by Disable, Mimic, etc.
#define MOVE_UNAVAILABLE 0xFFFF
Expand Down
2 changes: 1 addition & 1 deletion payload/include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ struct SpindaSpot
u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data);
const struct CompressedSpritePalette *GetBoxMonPalettePtr(u32 partyId);
u32 GetBoxMonAbility(struct BoxPokemon *boxMon);
const u32 *BoxMonCaughtBallToItemId(struct BoxPokemon *boxMon);
const u32 *BoxMonGetCaughtBallItemSpriteSheet(struct BoxPokemon *boxMon);
const u32 *BoxMonGetCaughtBallItemPalette(struct BoxPokemon *boxMon);
u32 GetBoxMonMoveBySlot(struct BoxPokemon *boxMon, s32 slot);
u32 GetBoxMonPPByMoveSlot(struct BoxPokemon *boxMon, u8 slot);
Expand Down
2 changes: 1 addition & 1 deletion payload/src/all2.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ static void sub_02003D80(u32 monId, bool32 a1)
if (gUnknown_02021990.unkC == NULL)
gUnknown_02021990.unkC = AddSprite(0, 128, gUnknown_0201FA5C);
SetSpritePaletteNum(gUnknown_02021990.unkC, 3);
LZ77UnCompVram(BoxMonCaughtBallToItemId(&mon->box), (void *)VRAM + 0x12800);
LZ77UnCompVram(BoxMonGetCaughtBallItemSpriteSheet(&mon->box), (void *)VRAM + 0x12800);
LZ77UnCompVram(BoxMonGetCaughtBallItemPalette(&mon->box), (void *)PLTT + 0x260);
primaryStatus = GetMonStatus(mon);
if (primaryStatus != STATUS_PRIMARY_NONE)
Expand Down
66 changes: 33 additions & 33 deletions payload/src/pokemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ static u16 CalculateBoxMonChecksum(struct BoxPokemon *boxMon)
union PokemonSubstruct *substruct3 = GetSubstruct(boxMon, boxMon->personality, 3);
s32 i;

for (i = 0; i < 6; i++)
for (i = 0; i < (s32)NELEMS(substruct0->raw); i++)
GriffinRichards marked this conversation as resolved.
Show resolved Hide resolved
checksum += substruct0->raw[i];

for (i = 0; i < 6; i++)
for (i = 0; i < (s32)NELEMS(substruct1->raw); i++)
checksum += substruct1->raw[i];

for (i = 0; i < 6; i++)
for (i = 0; i < (s32)NELEMS(substruct2->raw); i++)
checksum += substruct2->raw[i];

for (i = 0; i < 6; i++)
for (i = 0; i < (s32)NELEMS(substruct3->raw); i++)
checksum += substruct3->raw[i];

return checksum;
Expand Down Expand Up @@ -199,7 +199,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
if (language == LANGUAGE_JAPANESE)
{
text[0] = EXT_CTRL_CODE_BEGIN;
text[1] = 21;
text[1] = EXT_CTRL_CODE_JPN;
StringCopy(text + 2, data);
StringCopy(data, text);
}
Expand Down Expand Up @@ -415,7 +415,7 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data)
u16 *moves = (u16 *)data;
s32 i = 0;

while (moves[i] != NUM_MOVES)
while (moves[i] != MOVES_COUNT)
{
u16 move = moves[i];
if (substruct1->moves[0] == move
Expand Down Expand Up @@ -551,26 +551,26 @@ u32 GetBoxMonAbility(struct BoxPokemon *boxMon)
return ability;
}

const u32 *BoxMonCaughtBallToItemId(struct BoxPokemon *boxMon)
const u32 *BoxMonGetCaughtBallItemSpriteSheet(struct BoxPokemon *boxMon)
{
u32 id;
u16 ball = GetBoxMonData(boxMon, MON_DATA_POKEBALL, NULL);

switch (ball)
{
case 1: id = 4; break;
case 2: id = 3; break;
case 3: id = 1; break;
case 4: id = 0; break;
case 5: id = 2; break;
case 6: id = 5; break;
case 7: id = 6; break;
case 8: id = 7; break;
case 9: id = 8; break;
case 10: id = 9; break;
case 11: id = 10; break;
case 12: id = 11; break;
default: id = 0; break;
case ITEM_MASTER_BALL: id = BALL_MASTER; break;
case ITEM_ULTRA_BALL: id = BALL_ULTRA; break;
case ITEM_GREAT_BALL: id = BALL_GREAT; break;
case ITEM_POKE_BALL: id = BALL_POKE; break;
case ITEM_SAFARI_BALL: id = BALL_SAFARI; break;
case ITEM_NET_BALL: id = BALL_NET; break;
case ITEM_DIVE_BALL: id = BALL_DIVE; break;
case ITEM_NEST_BALL: id = BALL_NEST; break;
case ITEM_REPEAT_BALL: id = BALL_REPEAT; break;
case ITEM_TIMER_BALL: id = BALL_TIMER; break;
case ITEM_LUXURY_BALL: id = BALL_LUXURY; break;
case ITEM_PREMIER_BALL: id = BALL_PREMIER; break;
default: id = BALL_POKE; break;
}

return gAgbPmRomParams->ballSpriteSheets[id].data;
Expand All @@ -583,19 +583,19 @@ const u32 *BoxMonGetCaughtBallItemPalette(struct BoxPokemon *boxMon)

switch (ball)
{
case 1: id = 4; break;
case 2: id = 3; break;
case 3: id = 1; break;
case 4: id = 0; break;
case 5: id = 2; break;
case 6: id = 5; break;
case 7: id = 6; break;
case 8: id = 7; break;
case 9: id = 8; break;
case 10: id = 9; break;
case 11: id = 10; break;
case 12: id = 11; break;
default: id = 0; break;
case ITEM_MASTER_BALL: id = BALL_MASTER; break;
case ITEM_ULTRA_BALL: id = BALL_ULTRA; break;
case ITEM_GREAT_BALL: id = BALL_GREAT; break;
case ITEM_POKE_BALL: id = BALL_POKE; break;
case ITEM_SAFARI_BALL: id = BALL_SAFARI; break;
case ITEM_NET_BALL: id = BALL_NET; break;
case ITEM_DIVE_BALL: id = BALL_DIVE; break;
case ITEM_NEST_BALL: id = BALL_NEST; break;
case ITEM_REPEAT_BALL: id = BALL_REPEAT; break;
case ITEM_TIMER_BALL: id = BALL_TIMER; break;
case ITEM_LUXURY_BALL: id = BALL_LUXURY; break;
case ITEM_PREMIER_BALL: id = BALL_PREMIER; break;
default: id = BALL_POKE; break;
}

return gAgbPmRomParams->ballSpritePalettes[id].data;
Expand Down