summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2017-11-11 14:45:08 +0100
committerDizzyEggg <jajkodizzy@wp.pl>2017-11-11 14:45:08 +0100
commitfa3691ca40d431d3f533c6e1bad47c4c4af81ccf (patch)
tree3258ed19ae342ab161ca047b28ebd9526670498a /src
parentaf197ccd3bd62fab813154dc4311e65f9992a676 (diff)
start pss
Diffstat (limited to 'src')
-rw-r--r--src/egg_hatch.c4
-rw-r--r--src/pokemon_storage_system.c122
2 files changed, 116 insertions, 10 deletions
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index 589e8901d..13c088883 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -75,7 +75,7 @@ extern void CreateYesNoMenu(const struct WindowTemplate*, u16, u8, u8);
extern void DoNamingScreen(u8, const u8*, u16, u8, u32, MainCallback);
extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str);
extern u16 sub_80D22D0(void);
-extern u8 sub_80C7050(u8);
+extern u8 CountPartyAliveNonEggMonsExcept(u8);
static void Task_EggHatch(u8 taskID);
static void CB2_EggHatch_0(void);
@@ -888,6 +888,6 @@ u8 GetEggStepsToSubtract(void)
u16 sub_80722E0(void)
{
u16 value = sub_80D22D0();
- value += sub_80C7050(6);
+ value += CountPartyAliveNonEggMonsExcept(6);
return value;
}
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index 3e409244c..8eeac96b1 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -1,15 +1,121 @@
-
-// Includes
#include "global.h"
+#include "pokemon_storage_system.h"
+#include "pokemon.h"
+#include "species.h"
+#include "event_data.h"
+#include "string_util.h"
+#include "text.h"
-// Static type declarations
+IWRAM_DATA u8 gUnknown_03000F78[0x188];
-// Static RAM declarations
+u8 CountMonsInBox(u8 boxId)
+{
+ u16 i, count;
-IWRAM_DATA u8 gUnknown_03000F78[0x188];
+ 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;
+}
-// Static ROM declarations
+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;
-// .rodata
+ size <<= 0x11;
+ dst += (dstToMul * 32) + dstToAdd;
+ src += (srcToMul * srcBy) + srcToAdd;
-// .text
+ i = 0;
+ if (i < count)
+ {
+ size >>= 1;
+ for (i = 0; i < count; i++)
+ {
+ CpuSet(src, dst, size >> 0x10);
+ dst += 0x20;
+ src += srcBy;
+ }
+ }
+}