2017-10-03 03:51:22 +02:00
|
|
|
#include "global.h"
|
2017-11-11 14:45:08 +01:00
|
|
|
#include "pokemon_storage_system.h"
|
|
|
|
#include "pokemon.h"
|
|
|
|
#include "species.h"
|
|
|
|
#include "event_data.h"
|
|
|
|
#include "string_util.h"
|
|
|
|
#include "text.h"
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
IWRAM_DATA u8 gUnknown_03000F78[0x188];
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
u8 CountMonsInBox(u8 boxId)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
for (i = 0, count = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) != SPECIES_NONE)
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
s16 GetFirstFreeBoxSpot(u8 boxId)
|
|
|
|
{
|
|
|
|
u16 i;
|
|
|
|
|
|
|
|
for (i = 0; i < IN_BOX_COUNT; i++)
|
|
|
|
{
|
|
|
|
if (GetBoxMonDataFromAnyBox(boxId, i, MON_DATA_SPECIES) == SPECIES_NONE)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1; // all spots are taken
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyNonEggMons(void)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyAliveNonEggMonsExcept(u8 slotToIgnore)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (i != slotToIgnore
|
|
|
|
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE
|
|
|
|
&& !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG)
|
|
|
|
&& GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
u16 CountPartyAliveNonEggMons_IgnoreVar0x8004Slot(void)
|
|
|
|
{
|
|
|
|
return CountPartyAliveNonEggMonsExcept(gSpecialVar_0x8004);
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 CountPartyMons(void)
|
|
|
|
{
|
|
|
|
u16 i, count;
|
|
|
|
|
|
|
|
for (i = 0, count = 0; i < PARTY_SIZE; i++)
|
|
|
|
{
|
|
|
|
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != SPECIES_NONE)
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u8 *StringCopyAndFillWithSpaces(u8 *dst, const u8 *src, u16 n)
|
|
|
|
{
|
|
|
|
u8 *str;
|
|
|
|
|
|
|
|
for (str = StringCopy(dst, src); str < dst + n; str++)
|
|
|
|
*str = CHAR_SPACE;
|
|
|
|
|
|
|
|
*str = EOS;
|
|
|
|
return str;
|
|
|
|
}
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
static void sub_80C7128(u16 *dst, u16 dstToAdd, u16 dstToMul, const u16 *src, u16 srcToAdd, u16 srcToMul, u32 size, u16 count, u16 srcBy)
|
|
|
|
{
|
|
|
|
u16 i;
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
size <<= 0x11;
|
|
|
|
dst += (dstToMul * 32) + dstToAdd;
|
|
|
|
src += (srcToMul * srcBy) + srcToAdd;
|
2017-10-03 03:51:22 +02:00
|
|
|
|
2017-11-11 14:45:08 +01:00
|
|
|
i = 0;
|
|
|
|
if (i < count)
|
|
|
|
{
|
|
|
|
size >>= 1;
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
CpuSet(src, dst, size >> 0x10);
|
|
|
|
dst += 0x20;
|
|
|
|
src += srcBy;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|