summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xasm/field_specials.s381
-rwxr-xr-xinclude/field_map_obj.h1
-rwxr-xr-xinclude/pokemon.h1
-rw-r--r--include/pokemon_summary_screen.h1
-rwxr-xr-xinclude/vars.h1
-rwxr-xr-xsrc/field_specials.c147
6 files changed, 151 insertions, 381 deletions
diff --git a/asm/field_specials.s b/asm/field_specials.s
index 34caae330..ec0feccff 100755
--- a/asm/field_specials.s
+++ b/asm/field_specials.s
@@ -6,387 +6,6 @@
.text
- thumb_func_start CheckFreePokemonStorageSpace
-CheckFreePokemonStorageSpace: @ 810F6EC
- push {r4-r6,lr}
- movs r5, 0
-_0810F6F0:
- movs r4, 0
- lsls r1, r5, 2
- adds r1, r5
- lsls r0, r1, 4
- subs r0, r1
- lsls r6, r0, 5
-_0810F6FC:
- lsls r0, r4, 2
- adds r0, r4
- lsls r0, 4
- ldr r1, _0810F718 @ =gPokemonStorage + 0x4
- adds r0, r1
- adds r0, r6, r0
- movs r1, 0xB
- movs r2, 0
- bl GetBoxMonData
- cmp r0, 0
- bne _0810F71C
- movs r0, 0x1
- b _0810F732
- .align 2, 0
-_0810F718: .4byte gPokemonStorage + 0x4
-_0810F71C:
- adds r0, r4, 0x1
- lsls r0, 16
- lsrs r4, r0, 16
- cmp r4, 0x1D
- bls _0810F6FC
- adds r0, r5, 0x1
- lsls r0, 16
- lsrs r5, r0, 16
- cmp r5, 0xD
- bls _0810F6F0
- movs r0, 0
-_0810F732:
- pop {r4-r6}
- pop {r1}
- bx r1
- thumb_func_end CheckFreePokemonStorageSpace
-
- thumb_func_start IsPokerusInParty
-IsPokerusInParty: @ 810F738
- push {lr}
- ldr r0, _0810F74C @ =gPlayerParty
- movs r1, 0x3F
- bl CheckPartyPokerus
- lsls r0, 24
- cmp r0, 0
- beq _0810F750
- movs r0, 0x1
- b _0810F752
- .align 2, 0
-_0810F74C: .4byte gPlayerParty
-_0810F750:
- movs r0, 0
-_0810F752:
- pop {r1}
- bx r1
- thumb_func_end IsPokerusInParty
-
- thumb_func_start sub_810F758
-sub_810F758: @ 810F758
- push {lr}
- ldr r0, _0810F798 @ =sub_810F7A8
- movs r1, 0x9
- bl CreateTask
- lsls r0, 24
- lsrs r0, 24
- ldr r2, _0810F79C @ =gTasks
- lsls r1, r0, 2
- adds r1, r0
- lsls r1, 3
- adds r1, r2
- ldr r0, _0810F7A0 @ =gSpecialVar_0x8005
- ldrh r2, [r0]
- movs r0, 0
- strh r2, [r1, 0x8]
- strh r0, [r1, 0xA]
- strh r0, [r1, 0xC]
- strh r0, [r1, 0xE]
- ldr r0, _0810F7A4 @ =gSpecialVar_0x8004
- ldrh r0, [r0]
- strh r0, [r1, 0x10]
- movs r0, 0x5
- strh r0, [r1, 0x12]
- movs r0, 0
- bl SetCameraPanningCallback
- movs r0, 0xD6
- bl PlaySE
- pop {r0}
- bx r0
- .align 2, 0
-_0810F798: .4byte sub_810F7A8
-_0810F79C: .4byte gTasks
-_0810F7A0: .4byte gSpecialVar_0x8005
-_0810F7A4: .4byte gSpecialVar_0x8004
- thumb_func_end sub_810F758
-
- thumb_func_start sub_810F7A8
-sub_810F7A8: @ 810F7A8
- push {r4,r5,lr}
- lsls r0, 24
- lsrs r5, r0, 24
- lsls r0, r5, 2
- adds r0, r5
- lsls r0, 3
- ldr r1, _0810F810 @ =gTasks
- adds r4, r0, r1
- ldrh r0, [r4, 0xA]
- adds r0, 0x1
- strh r0, [r4, 0xA]
- movs r1, 0xA
- ldrsh r0, [r4, r1]
- movs r2, 0x12
- ldrsh r1, [r4, r2]
- bl __modsi3
- cmp r0, 0
- bne _0810F808
- strh r0, [r4, 0xA]
- ldrh r0, [r4, 0xC]
- adds r0, 0x1
- strh r0, [r4, 0xC]
- movs r1, 0xE
- ldrsh r0, [r4, r1]
- cmp r0, 0
- bne _0810F808
- ldrh r0, [r4, 0x8]
- negs r0, r0
- strh r0, [r4, 0x8]
- ldrh r0, [r4, 0x10]
- negs r0, r0
- strh r0, [r4, 0x10]
- movs r2, 0x8
- ldrsh r0, [r4, r2]
- movs r2, 0x10
- ldrsh r1, [r4, r2]
- bl SetCameraPanning
- movs r1, 0xC
- ldrsh r0, [r4, r1]
- cmp r0, 0x8
- bne _0810F808
- adds r0, r5, 0
- bl sub_810F814
- bl InstallCameraPanAheadCallback
-_0810F808:
- pop {r4,r5}
- pop {r0}
- bx r0
- .align 2, 0
-_0810F810: .4byte gTasks
- thumb_func_end sub_810F7A8
-
- thumb_func_start sub_810F814
-sub_810F814: @ 810F814
- push {lr}
- lsls r0, 24
- lsrs r0, 24
- bl DestroyTask
- bl EnableBothScriptContexts
- pop {r0}
- bx r0
- thumb_func_end sub_810F814
-
- thumb_func_start sub_810F828
-sub_810F828: @ 810F828
- push {lr}
- movs r0, 0xAE
- lsls r0, 2
- bl FlagGet
- lsls r0, 24
- lsrs r0, 24
- pop {r1}
- bx r1
- thumb_func_end sub_810F828
-
- thumb_func_start SetRoute119Weather
-SetRoute119Weather: @ 810F83C
- push {lr}
- bl get_map_light_from_warp0
- lsls r0, 24
- lsrs r0, 24
- bl is_light_level_1_2_3_5_or_6
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- beq _0810F858
- movs r0, 0x14
- bl SetSav1Weather
-_0810F858:
- pop {r0}
- bx r0
- thumb_func_end SetRoute119Weather
-
- thumb_func_start SetRoute123Weather
-SetRoute123Weather: @ 810F85C
- push {lr}
- bl get_map_light_from_warp0
- lsls r0, 24
- lsrs r0, 24
- bl is_light_level_1_2_3_5_or_6
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- beq _0810F878
- movs r0, 0x15
- bl SetSav1Weather
-_0810F878:
- pop {r0}
- bx r0
- thumb_func_end SetRoute123Weather
-
- thumb_func_start GetLeadMonIndex
-GetLeadMonIndex: @ 810F87C
- push {r4-r6,lr}
- bl CalculatePlayerPartyCount
- lsls r0, 24
- lsrs r6, r0, 24
- movs r5, 0
- cmp r5, r6
- bcs _0810F8CA
-_0810F88C:
- movs r0, 0x64
- adds r1, r5, 0
- muls r1, r0
- ldr r0, _0810F8BC @ =gPlayerParty
- adds r4, r1, r0
- adds r0, r4, 0
- movs r1, 0x41
- movs r2, 0
- bl GetMonData
- movs r1, 0xCE
- lsls r1, 1
- cmp r0, r1
- beq _0810F8C0
- adds r0, r4, 0
- movs r1, 0x41
- movs r2, 0
- bl GetMonData
- cmp r0, 0
- beq _0810F8C0
- adds r0, r5, 0
- b _0810F8CC
- .align 2, 0
-_0810F8BC: .4byte gPlayerParty
-_0810F8C0:
- adds r0, r5, 0x1
- lsls r0, 24
- lsrs r5, r0, 24
- cmp r5, r6
- bcc _0810F88C
-_0810F8CA:
- movs r0, 0
-_0810F8CC:
- pop {r4-r6}
- pop {r1}
- bx r1
- thumb_func_end GetLeadMonIndex
-
- thumb_func_start ScriptGetPartyMonSpecies
-ScriptGetPartyMonSpecies: @ 810F8D4
- push {lr}
- ldr r0, _0810F8F4 @ =gSpecialVar_0x8004
- ldrh r1, [r0]
- movs r0, 0x64
- muls r0, r1
- ldr r1, _0810F8F8 @ =gPlayerParty
- adds r0, r1
- movs r1, 0x41
- movs r2, 0
- bl GetMonData
- lsls r0, 16
- lsrs r0, 16
- pop {r1}
- bx r1
- .align 2, 0
-_0810F8F4: .4byte gSpecialVar_0x8004
-_0810F8F8: .4byte gPlayerParty
- thumb_func_end ScriptGetPartyMonSpecies
-
- thumb_func_start sub_810F8FC
-sub_810F8FC: @ 810F8FC
- push {lr}
- movs r0, 0x6
- bl sub_805ADDC
- pop {r0}
- bx r0
- thumb_func_end sub_810F8FC
-
- thumb_func_start sub_810F908
-sub_810F908: @ 810F908
- push {r4,lr}
- ldr r0, _0810F928 @ =0x000040c2
- bl VarGet
- lsls r0, 16
- lsrs r0, 16
- adds r3, r0, 0
- ldr r2, _0810F92C @ =gLocalTime
- movs r1, 0
- ldrsh r0, [r2, r1]
- subs r0, r3
- cmp r0, 0x6
- ble _0810F930
- movs r0, 0
- b _0810F948
- .align 2, 0
-_0810F928: .4byte 0x000040c2
-_0810F92C: .4byte gLocalTime
-_0810F930:
- ldrh r1, [r2]
- movs r4, 0
- ldrsh r0, [r2, r4]
- cmp r0, 0
- blt _0810F946
- subs r1, r3
- movs r0, 0x7
- subs r0, r1
- lsls r0, 16
- lsrs r0, 16
- b _0810F948
-_0810F946:
- movs r0, 0x8
-_0810F948:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_810F908
-
- thumb_func_start sub_810F950
-sub_810F950: @ 810F950
- push {r4,lr}
- ldr r0, _0810F964 @ =0x000040c2
- ldr r4, _0810F968 @ =gLocalTime
- ldrh r1, [r4]
- bl VarSet
- ldrh r0, [r4]
- pop {r4}
- pop {r1}
- bx r1
- .align 2, 0
-_0810F964: .4byte 0x000040c2
-_0810F968: .4byte gLocalTime
- thumb_func_end sub_810F950
-
- thumb_func_start sub_810F96C
-sub_810F96C: @ 810F96C
- push {r4,lr}
- ldr r0, _0810F994 @ =gSpecialVar_0x8004
- ldrh r1, [r0]
- movs r0, 0x64
- muls r0, r1
- ldr r1, _0810F998 @ =gPlayerParty
- adds r0, r1
- ldr r4, _0810F99C @ =gStringVar1
- movs r1, 0x7
- adds r2, r4, 0
- bl GetMonData
- ldr r0, _0810F9A0 @ =gSaveBlock2
- adds r1, r4, 0
- bl StringCompareWithoutExtCtrlCodes
- cmp r0, 0
- beq _0810F9A4
- movs r0, 0x1
- b _0810F9A6
- .align 2, 0
-_0810F994: .4byte gSpecialVar_0x8004
-_0810F998: .4byte gPlayerParty
-_0810F99C: .4byte gStringVar1
-_0810F9A0: .4byte gSaveBlock2
-_0810F9A4:
- movs r0, 0
-_0810F9A6:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_810F96C
-
thumb_func_start sub_810F9AC
sub_810F9AC: @ 810F9AC
push {r4,r5,lr}
diff --git a/include/field_map_obj.h b/include/field_map_obj.h
index 5eaa15149..2d62af202 100755
--- a/include/field_map_obj.h
+++ b/include/field_map_obj.h
@@ -199,5 +199,6 @@ u8 GetOppositeDirection(u8);
void sub_80634D0(struct MapObject *, struct Sprite *);
u8 SpawnSpecialFieldObjectParametrized(u8, u8, u8, s16, s16, u8);
void CameraObjectSetFollowedObjectId(u8);
+void sub_805ADDC(u8);
#endif // GUARD_FIELD_MAP_OBJ_H
diff --git a/include/pokemon.h b/include/pokemon.h
index c09f3870e..101ae94ce 100755
--- a/include/pokemon.h
+++ b/include/pokemon.h
@@ -409,6 +409,7 @@ extern u8 gStatStageRatios[][2];
extern struct Pokemon gPlayerParty[PARTY_SIZE];
extern struct Pokemon gEnemyParty[PARTY_SIZE];
+extern struct PokemonStorage gPokemonStorage;
void ZeroBoxMonData(struct BoxPokemon *boxMon);
void ZeroMonData(struct Pokemon *mon);
diff --git a/include/pokemon_summary_screen.h b/include/pokemon_summary_screen.h
index 3f7ed8fad..1d53a131c 100644
--- a/include/pokemon_summary_screen.h
+++ b/include/pokemon_summary_screen.h
@@ -12,5 +12,6 @@ u8 GetMonStatusAndPokerus();
u8 *sub_80A1E9C(u8 *dest, const u8 *src, u8);
u8 *PokemonSummaryScreen_CopyPokemonLevel(u8 *dest, u8 level);
u8 PokemonSummaryScreen_CheckOT(struct Pokemon *pokemon);
+bool8 CheckPartyPokerus(struct Pokemon *, u8);
#endif // GUARD_POKEMON_SUMMARY_SCREEN_H
diff --git a/include/vars.h b/include/vars.h
index fcc3311a6..50ca97818 100755
--- a/include/vars.h
+++ b/include/vars.h
@@ -37,5 +37,6 @@
#define VAR_PORTHOLE 0x40B4
#define VAR_0x40BC 0x40BC
+#define VAR_0x40C2 0x40C2
#endif // GUARD_VARS_H
diff --git a/src/field_specials.c b/src/field_specials.c
index 032939244..02b3581fd 100755
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -31,6 +31,9 @@
#include "menu.h"
#include "starter_choose.h"
#include "menu_helpers.h"
+#include "battle_tower.h"
+#include "field_weather.h"
+#include "pokemon_summary_screen.h"
#if ENGLISH
#define CHAR_DECIMAL_SEPARATOR CHAR_PERIOD
@@ -1906,3 +1909,147 @@ bool8 IsStarterInParty(void)
}
return FALSE;
}
+
+bool8 CheckFreePokemonStorageSpace(void)
+{
+ u16 i, j;
+ for (i=0; i<14; i++)
+ {
+ for (j=0; j<30; j++)
+ {
+ if (GetBoxMonData(&gPokemonStorage.boxes[i][j], MON_DATA_SPECIES, NULL) == SPECIES_NONE)
+ {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
+}
+
+bool8 IsPokerusInParty(void)
+{
+ if (!CheckPartyPokerus(gPlayerParty, 0x3f))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}
+
+static void sub_810F7A8(u8);
+static void sub_810F814(u8);
+
+void sub_810F758(void)
+{
+ u8 taskId = CreateTask(sub_810F7A8, 9);
+ gTasks[taskId].data[0] = gSpecialVar_0x8005;
+ gTasks[taskId].data[1] = 0;
+ gTasks[taskId].data[2] = 0;
+ gTasks[taskId].data[3] = 0;
+ gTasks[taskId].data[4] = gSpecialVar_0x8004;
+ gTasks[taskId].data[5] = 5;
+ SetCameraPanningCallback(NULL);
+ PlaySE(SE_W070);
+}
+
+static void sub_810F7A8(u8 taskId)
+{
+ struct Task *task = &gTasks[taskId];
+ task->data[1]++;
+ if ((task->data[1] % task->data[5]) == 0)
+ {
+ task->data[1] = 0;
+ task->data[2]++;
+ if (task->data[3] == 0)
+ {
+ task->data[0] = -task->data[0];
+ task->data[4] = -task->data[4];
+ SetCameraPanning(task->data[0], task->data[4]);
+ if (task->data[2] == 8)
+ {
+ sub_810F814(taskId);
+ InstallCameraPanAheadCallback();
+ }
+ }
+ }
+}
+
+static void sub_810F814(u8 taskId)
+{
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
+}
+
+bool8 sub_810F828(void)
+{
+ return FlagGet(0x2b8);
+}
+
+void SetRoute119Weather(void)
+{
+ if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE)
+ {
+ SetSav1Weather(0x14);
+ }
+}
+
+void SetRoute123Weather(void)
+{
+ if (is_light_level_1_2_3_5_or_6(get_map_light_from_warp0()) != TRUE)
+ {
+ SetSav1Weather(0x15);
+ }
+}
+
+u8 GetLeadMonIndex(void)
+{
+ u8 i;
+ u8 partyCount = CalculatePlayerPartyCount();
+ for (i=0; i<partyCount; i++)
+ {
+ if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != 0)
+ {
+ return i;
+ }
+ }
+ return 0;
+}
+
+u16 ScriptGetPartyMonSpecies(void)
+{
+ return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL);
+}
+
+void sub_810F8FC(void)
+{
+ sub_805ADDC(6);
+}
+
+u16 sub_810F908(void)
+{
+ u16 var40c2 = VarGet(VAR_0x40C2);
+ if (gLocalTime.days - var40c2 >= 7)
+ {
+ return 0;
+ }
+ else if (gLocalTime.days < 0)
+ {
+ return 8;
+ }
+ return 7 - (gLocalTime.days - var40c2);
+}
+
+u16 sub_810F950(void)
+{
+ VarSet(VAR_0x40C2, gLocalTime.days);
+ return gLocalTime.days;
+}
+
+bool8 sub_810F96C(void)
+{
+ GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_OT_NAME, gStringVar1);
+ if (!StringCompareWithoutExtCtrlCodes(gSaveBlock2.playerName, gStringVar1))
+ {
+ return FALSE;
+ }
+ return TRUE;
+}