summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcamthesaxman <cameronghall@cox.net>2017-05-17 17:40:04 -0500
committercamthesaxman <cameronghall@cox.net>2017-05-17 17:40:04 -0500
commit14c5c79f3e3f903e3e7b34b5c0c9bb3b90e7ab75 (patch)
tree52e00e2812506d5252649d7abbd0f9de3eb2f258 /src
parent7801f9cd2e1471cd33e33047f049bbdc6da6e785 (diff)
fill holes in party_menu.c and add battle_interface.h header
Diffstat (limited to 'src')
-rw-r--r--src/battle_interface.c32
-rw-r--r--src/menu.c2
-rw-r--r--src/party_menu.c1182
3 files changed, 1161 insertions, 55 deletions
diff --git a/src/battle_interface.c b/src/battle_interface.c
index 9938c4b54..ba3cba894 100644
--- a/src/battle_interface.c
+++ b/src/battle_interface.c
@@ -8,6 +8,7 @@
#include "songs.h"
#include "battle.h"
#include "palette.h"
+#include "battle_interface.h"
struct UnknownStruct5
{
@@ -35,15 +36,6 @@ struct UnknownStruct7
u8 filler0[0x180];
};
-struct UnknownStruct9
-{
- s32 unk0;
- u32 unk4;
- u32 unk8;
- u32 unkC_0:5;
- u32 unk10;
-};
-
extern u8 ewram[];
#define ewram520 ((struct UnknownStruct7 *)(ewram + 0x00520))
#define ewram16088 (*(u8 *) (ewram + 0x16088))
@@ -109,9 +101,8 @@ extern void load_gfxc_health_bar();
static void sub_8043D5C(struct Sprite *);
static const void *sub_8043CDC(u8);
-void sub_8044210(u8, s16, u8);
+static void sub_8044210(u8, s16, u8);
static void draw_status_ailment_maybe(u8);
-void sub_8045A5C(u8 a, struct Pokemon *pkmn, u8 c);
extern void sub_8045180(struct Sprite *);
static void sub_8045110(struct Sprite *);
static void sub_8045048(struct Sprite *);
@@ -119,12 +110,11 @@ static void sub_8044F70(u8 taskId);
static void sub_8044E74(u8 taskId);
static void sub_8044ECC(u8 taskId);
static u8 sub_80457E8(u8, u8);
-s32 sub_8045C78(u8, u8, u8, u8);
static int sub_8045F58(s32, s32, int, int *, u8, u16);
static u8 GetScaledExpFraction(int, int, int, u8);
static void sub_8045D58(u8, u8);
static u8 sub_804602C(int, int, int, int *, u8 *, u8);
-static void sub_8046128(struct UnknownStruct9 *a, int *b, void *c);
+static void sub_8046128(struct BattleInterfaceStruct1 *a, int *b, void *c);
static int do_nothing(s16 unused1, s16 unused2, int unused3)
{
@@ -937,7 +927,7 @@ _0804420C: .4byte 0x04000008\n\
}
#endif
-void sub_8044210(u8 a, s16 b, u8 c)
+static void sub_8044210(u8 a, s16 b, u8 c)
{
u8 str[0x14];
u8 *ptr;
@@ -1377,15 +1367,9 @@ void sub_804454C(void)
}
}
-struct UnknownStruct8
-{
- u16 unk0;
- u32 unk4;
-};
-
// This function almost matches except for just two instructions around 0x08044B52 that are swapped.
#ifdef NONMATCHING
-u8 sub_8044804(u8 a, const struct UnknownStruct8 *b, u8 c, u8 d)
+u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
{
u8 r7;
s16 x;
@@ -1594,7 +1578,7 @@ u8 sub_8044804(u8 a, const struct UnknownStruct8 *b, u8 c, u8 d)
}
#else
__attribute__((naked))
-u8 sub_8044804(u8 a, const struct UnknownStruct8 *b, u8 c, u8 d)
+u8 sub_8044804(u8 a, const struct BattleInterfaceStruct2 *b, u8 c, u8 d)
{
asm(".syntax unified\n\
push {r4-r7,lr}\n\
@@ -3005,7 +2989,7 @@ static u8 sub_804602C(int a, int b, int c, int *d, u8 *e, u8 f)
return r3;
}
-s16 sub_80460C8(struct UnknownStruct9 *a, int *b, void *c, int d)
+s16 sub_80460C8(struct BattleInterfaceStruct1 *a, int *b, void *c, int d)
{
u16 r7;
s16 r1;
@@ -3020,7 +3004,7 @@ s16 sub_80460C8(struct UnknownStruct9 *a, int *b, void *c, int d)
return r7;
}
-static void sub_8046128(struct UnknownStruct9 *a, int *b, void *c)
+static void sub_8046128(struct BattleInterfaceStruct1 *a, int *b, void *c)
{
u8 sp8[6];
u16 sp10[6];
diff --git a/src/menu.c b/src/menu.c
index ba98ff057..3759d22c9 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -598,7 +598,7 @@ s8 ProcessMenuInputNoWrap_(void)
return ProcessMenuInputNoWrap();
}
-u8 MenuPrint_PixelCoords(u8 *text, u8 left, u16 top, u8 a4)
+u8 MenuPrint_PixelCoords(const u8 *text, u8 left, u16 top, u8 a4)
{
return sub_8004D04(gMenuWindowPtr, text, gMenuTextTileOffset, left, top, a4);
}
diff --git a/src/party_menu.c b/src/party_menu.c
index b38e89376..8eb181f46 100644
--- a/src/party_menu.c
+++ b/src/party_menu.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "asm.h"
#include "menu.h"
#include "pokemon.h"
#include "songs.h"
@@ -9,18 +10,17 @@
#include "palette.h"
#include "event_data.h"
#include "main.h"
+#include "item.h"
+#include "battle_interface.h"
+#include "species.h"
#define DATA_COUNT (6)
-struct Unk201C000
+struct Unk2001000
{
- /*0x00*/ struct Pokemon *pokemon;
- /*0x04*/ u8 unk4;
- /*0x05*/ u8 unk5;
- /*0x06*/ u16 unk6;
- /*0x08*/ u8 pad_08[4];
- /*0x0C*/ s32 var0C;
- /*0x10*/ TaskFunc unk10;
+ u8 unk0;
+ u8 unk1;
+ u8 unk2;
};
struct Unk201B000
@@ -33,7 +33,26 @@ struct Unk201B000
u8 filler27C[2];
s16 unk27E;
s16 unk280;
- u16 unk282;
+ s16 unk282;
+};
+
+struct Unk201C000
+{
+ /*0x00*/ struct Pokemon *pokemon;
+ /*0x04*/ u8 unk4;
+ /*0x05*/ u8 unk5;
+ /*0x06*/ u16 unk6;
+ /*0x08*/ u16 unk8;
+ /*0x0A*/ u8 pad_0A[2];
+ /*0x0C*/ s32 unkC;
+ /*0x10*/ TaskFunc unk10;
+ /*0x14*/ TaskFunc unk14;
+};
+
+struct Unk201F000
+{
+ u8 filler0[0xE00];
+ u8 unkE00[3]; // not sure if this is an array or struct, or how big it is
};
struct UnknownStruct5
@@ -44,44 +63,143 @@ struct UnknownStruct5
};
extern u8 ewram[];
+#define ewram01000 (*(struct Unk2001000 *)(ewram + 0x01000))
#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000))
#define ewram1C000 (*(struct Unk201C000 *)(ewram + 0x1C000))
+#define ewram1F000 (*(struct Unk201F000 *)(ewram + 0x1F000))
extern u8 gUnknown_0202E8F4;
extern u8 gUnknown_0202E8F6;
+extern u16 gUnknown_0202E8F8;
extern u8 gUnknown_0202E8FA;
extern u8 gLastFieldPokeMenuOpened;
+extern u8 gPlayerPartyCount;
+extern u16 gScriptItemId;
+extern s32 gBattleMoveDamage;
//extern const u16 gUnknown_083769A8[][6];
//extern const u8 gUnknown_083769A8[][12];
+extern void *const gUnknown_08376858[][6];
extern const u8 gUnknown_083769A8[];
-extern u8 gUnknown_08376D1C[DATA_COUNT];
-extern u8 *gUnknown_08376D04[DATA_COUNT];
+extern const u8 gUnknown_08376D1C[DATA_COUNT];
+extern const u16 gUnknown_08376504[];
extern void (*const gUnknown_08376B54[])(u8);
+extern const u8 *const gUnknown_08376D04[DATA_COUNT];
extern const struct UnknownStruct5 gUnknown_08376BB4[][6];
-extern u8 gOtherText_TallPlusAndRightArrow[];
-extern u8 gOtherText_WontHaveAnyEffect[];
+extern const u8 gOtherText_TallPlusAndRightArrow[];
+extern const u8 gOtherText_WontHaveAnyEffect[];
+extern const u8 gOtherText_ElevatedTo[];
+extern const u8 gOtherText_MailMustBeRemoved[];
+extern const u8 gOtherText_AlreadyHolding[];
+extern const u8 gOtherText_TakenAndReplaced[];
+extern const u8 gOtherText_BagFullCannotRemoveItem[];
+extern const u8 gOtherText_WasGivenToHold[];
+extern const u8 gOtherText_PokeHoldingItemCantMail[];
+extern const u8 gOtherText_MailTransferredMailbox[];
+extern const u8 gOtherText_NotHoldingAnything[];
+extern const u8 gOtherText_ReceivedTheThingFrom[];
+extern const u8 gOtherText_SendRemovedMailPrompt[];
+extern const u8 gOtherText_MailTaken[];
+extern const u8 gOtherText_MailWasSent[];
+extern const u8 gOtherText_MailboxIsFull[];
+extern const u8 gOtherText_MailRemovedMessageLost[];
+extern const u8 gOtherText_WantsToLearn[];
+extern const u8 gOtherText_NotCompatible[];
+extern const u8 gOtherText_AlreadyKnows[];
+extern const u8 gOtherText_LearnedMove[];
+extern const u8 gOtherText_WhichMoveToForget2[];
+extern const u8 gOtherText_ForgetMove123_2[];
+extern const u8 gOtherText_StopTryingTo[];
+extern const u8 gOtherText_DidNotLearnMove2[];
+extern const u8 gOtherText_RegainedHealth[];
+extern const u8 gOtherText_HPRestoredBy[];
+extern const u8 gOtherText_CuredPoisoning[];
+extern const u8 gOtherText_WokeUp[];
+extern const u8 gOtherText_BurnHealed[];
+extern const u8 gOtherText_ThawedOut[];
+extern const u8 gOtherText_CuredParalysis[];
+extern const u8 gOtherText_SnapConfusion[];
+extern const u8 gOtherText_GotOverLove[];
+extern const u8 gOtherText_BecameHealthy[];
+extern const u8 gOtherText_Hp2[];
+extern const u8 gOtherText_Attack[];
+extern const u8 gOtherText_Defense[];
+extern const u8 gOtherText_Speed[];
+extern const u8 gOtherText_SpAtk2[];
+extern const u8 gOtherText_SpDef2[];
+extern const u8 gOtherText_WasRaised[];
+extern const u8 gOtherText_PPIncreased[];
+extern const u8 gOtherText_PPRestored[];
extern const u8 gMoveNames[][13];
-extern u8 *const gItemEffectTable[];
+extern const u8 *const gItemEffectTable[];
extern bool8 IsDoubleBattle(void);
-extern void AddBagItem();
-extern void RemoveBagItem();
extern void SetUpBattlePokemonMenu(u8);
extern void sub_808B0C0(u8);
+extern u8 GiveMailToMon(struct Pokemon *, u16);
+extern bool8 ItemIsMail(u16);
+extern void ClearMailStruct(struct MailStruct *);
+extern u8 GiveMailToMon2(struct Pokemon *, struct MailStruct *);
+extern void TakeMailFromMon(struct Pokemon *);
+extern u8 TakeMailFromMon2(struct Pokemon *);
+extern u32 CanMonLearnTMHM(struct Pokemon *, u8);
+extern void sub_809D9F0(struct Pokemon *, u8, u8, void *, u32);
+extern void sub_808B564();
+extern u8 sub_809FA30(void);
+extern void sub_808B508(u8);
+extern void sub_8032638();
+extern u8 sub_8094C20();
+extern bool8 ExecuteTableBasedItemEffect_();
+extern u8 GetMonStatusAndPokerus();
+u8 sub_806CA38(u8);
void task_pc_turn_off();
static void sub_806E884(u8 taskId);
void sub_806F8AC(u8 taskId);
void sub_806FB0C(u8 taskId);
void PartyMenuUpdateLevelOrStatus(struct Pokemon *, u8);
-u8 ExecuteTableBasedItemEffect__(u8, u16, u8);
+bool8 ExecuteTableBasedItemEffect__(u8, u16, u8);
void sub_80701DC(u8 taskId);
void DoRecoverPP(u8);
+void Task_RareCandy1(u8);
+void Task_RareCandy2(u8);
+void Task_RareCandy3(u8);
void sub_806D538();
void sub_806D5A4(void);
-void sub_806E8D0();
-void GetMedicineItemEffectMessage();
+void sub_806E8D0(u8 taskId, u16 b, TaskFunc c);
+void GetMedicineItemEffectMessage(u16);
+void sub_8070A20();
+void sub_8070848(u8 taskId);
+void sub_8070968();
+void party_menu_link_mon_held_item_object(u8);
+void Task_ConfirmGiveHeldItem(u8);
+void DisplayGiveHeldItemMessage(u8, u16, u8);
+void SetHeldItemIconVisibility();
+void DisplayTakeHeldItemMessage(u8, u16, u8);
+void Task_ConfirmTakeHeldMail(u8);
+void Task_TeamMonTMMove(u8);
+void Task_TeamMonTMMove2(u8);
+void Task_TeamMonTMMove3(u8);
+void Task_TeamMonTMMove4(u8);
+void sub_806F358(u8);
+void sub_806F390(u8);
+void sub_806F44C(u8);
+void TMMoveUpdateMoveSlot(u8);
+void StopTryingToTeachMove_806F614(u8);
+void StopTryingToTeachMove_806F67C(u8);
+void StopTryingToTeachMove_806F6B4(u8);
+void sub_806FB44(u8);
+void sub_8070C54();
+void SetMonIconAnim();
+u8 GetMonIconSpriteId_maybe();
+void PartyMenuDoPrintHP(u8, int, u16, u16);
+void PartyMenuClearLevelStatusTilemap();
+void PartyMenuPrintMonLevelOrStatus();
+u8 GetItemEffectType();
+bool8 IsBlueYellowRedFlute(u16);
+void TryPrintPartyMenuMonNickname();
+void sub_8070088(u8);
+
/*
void sub_806AEDC(void)
@@ -99,7 +217,7 @@ void sub_806AEDC(void)
}
*/
-u8 sub_806E834(u8 *message, u8 arg1)
+u8 sub_806E834(const u8 *message, u8 arg1)
{
u8 taskId;
@@ -116,22 +234,953 @@ u8 sub_806E834(u8 *message, u8 arg1)
static void sub_806E884(u8 taskId)
{
- if (MenuUpdateWindowText() == 0)
+ if (MenuUpdateWindowText())
{
- return;
+ gUnknown_0202E8F6 = 0;
+ if (gTasks[taskId].data[0] == 0)
+ MenuZeroFillWindowRect(3, 14, 26, 19);
+ DestroyTask(taskId);
}
+}
+
+void sub_806E8D0(u8 taskId, u16 b, TaskFunc c)
+{
+ ewram1C000.unk10 = c;
+ ewram1C000.unk4 = taskId;
+ ewram1C000.unk5 = sub_806CA38(taskId);
+ ewram1C000.unk6 = b;
+ ewram1C000.pokemon = &gPlayerParty[ewram1C000.unk5];
+}
- gUnknown_0202E8F6 = 0;
+bool8 PartyMenuUpdateMonHeldItem(struct Pokemon *pkmn, u16 item)
+{
+ u8 itemData[2];
- if (gTasks[taskId].data[0] == 0)
+ if (ItemIsMail(item) == TRUE)
{
- MenuZeroFillWindowRect(3, 14, 26, 19);
+ if (GiveMailToMon(pkmn, item) == 0xFF)
+ return TRUE;
+ gUnknown_0202E8F4 = 2;
+ }
+ else
+ {
+ gUnknown_0202E8F4 = 1;
}
- DestroyTask(taskId);
+ itemData[0] = item;
+ itemData[1] = item >> 8;
+ SetMonData(pkmn, MON_DATA_HELD_ITEM, itemData);
+ return FALSE;
+}
+
+void PartyMenuTryGiveMonHeldItem(u8 taskId, u16 newItem, TaskFunc c)
+{
+ u16 currentItem;
+
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, newItem, c);
+ currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM);
+ gUnknown_0202E8F4 = 0;
+ gUnknown_0202E8F8 = 0;
+ if (currentItem != 0)
+ {
+ if (ItemIsMail(currentItem) == TRUE)
+ {
+ sub_806E834(gOtherText_MailMustBeRemoved, 1);
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+ else
+ {
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ CopyItemName(currentItem, gStringVar2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_AlreadyHolding);
+ sub_806E834(gStringVar4, 1);
+ CreateTask(Task_ConfirmGiveHeldItem, 5);
+ if (ItemIsMail(newItem) == TRUE)
+ gUnknown_0202E8F8 = currentItem;
+ }
+ }
+ else
+ {
+ PartyMenuUpdateMonHeldItem(ewram1C000.pokemon, newItem);
+ RemoveBagItem(newItem, 1);
+ if (ItemIsMail(newItem))
+ {
+ gTasks[taskId].func = c;
+ }
+ else
+ {
+ DisplayGiveHeldItemMessage(ewram1C000.unk5, newItem, 1);
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+ }
+}
+
+void party_menu_link_mon_held_item_object(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5);
+ gTasks[ewram1C000.unk4].func = ewram1C000.unk10;
+ DestroyTask(taskId);
+ }
+}
+
+void PartyMenuTryGiveMonHeldItem_806EACC(u8 taskId)
+{
+ s8 selection = ProcessMenuInputNoWrap_();
+
+ if (selection == 0)
+ {
+ u16 currentItem;
+
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM);
+ RemoveBagItem(ewram1C000.unk6, 1);
+ if (AddBagItem(currentItem, 1) == TRUE)
+ {
+ PartyMenuUpdateMonHeldItem(ewram1C000.pokemon, ewram1C000.unk6);
+ if (ItemIsMail(ewram1C000.unk6))
+ {
+ DisplayTakeHeldItemMessage(ewram1C000.unk5, currentItem, 1);
+ }
+ else
+ {
+ CopyItemName(ewram1C000.unk6, gStringVar1);
+ StringExpandPlaceholders(gStringVar4, gOtherText_TakenAndReplaced);
+ sub_806E834(gStringVar4, 1);
+ }
+ }
+ else
+ {
+ sub_806E834(gOtherText_BagFullCannotRemoveItem, 0);
+ AddBagItem(ewram1C000.unk6, 1);
+ }
+ }
+ else
+ {
+ if (selection != 1 && selection != -1)
+ return;
+ if (selection == -1)
+ PlaySE(SE_SELECT);
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ }
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+}
+
+void Task_ConfirmGiveHeldItem(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ DisplayYesNoMenu(23, 8, 1);
+ gTasks[taskId].func = PartyMenuTryGiveMonHeldItem_806EACC;
+ }
+}
+
+void DisplayGiveHeldItemMessage(u8 a, u16 b, u8 c)
+{
+ GetMonNickname(&gPlayerParty[a], gStringVar1);
+ CopyItemName(b, gStringVar2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasGivenToHold);
+ sub_806E834(gStringVar4, c);
+}
+
+
+// Not sure about this one for now.
+/*
+void PartyMenuTryGiveMonMail(u8 taskId, TaskFunc func)
+{
+ u16 currentItem;
+ struct MailStruct *r4;
+
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, 0, func);
+ currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM);
+ gUnknown_0202E8F4 = 0;
+ r4 = &gSaveBlock1.mail[ewram1F000.unkE00[0] + ewram1F000.unkE00[2]];
+ if (currentItem != 0)
+ {
+ sub_806E834(gOtherText_PokeHoldingItemCantMail, 1);
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+ else
+ {
+ GiveMailToMon2(ewram1C000.pokemon, r4);
+ ClearMailStruct(r4);
+ sub_806E834(gOtherText_MailTransferredMailbox, 1);
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+}
+*/
+__attribute__((naked))
+void PartyMenuTryGiveMonMail(u8 taskId, TaskFunc func)
+{
+ asm(".syntax unified\n\
+ push {r4,r5,lr}\n\
+ adds r2, r1, 0\n\
+ lsls r0, 24\n\
+ lsrs r0, 24\n\
+ ldr r3, _0806ECA0 @ =gTasks\n\
+ lsls r1, r0, 2\n\
+ adds r1, r0\n\
+ lsls r1, 3\n\
+ adds r1, r3\n\
+ ldr r3, _0806ECA4 @ =TaskDummy\n\
+ str r3, [r1]\n\
+ movs r1, 0\n\
+ bl sub_806E8D0\n\
+ ldr r5, _0806ECA8 @ =0x0201c000\n\
+ ldr r0, [r5]\n\
+ movs r1, 0xC\n\
+ bl GetMonData\n\
+ lsls r0, 16\n\
+ ldr r2, _0806ECAC @ =gUnknown_0202E8F4\n\
+ movs r1, 0\n\
+ strb r1, [r2]\n\
+ movs r1, 0xF8\n\
+ lsls r1, 6\n\
+ adds r2, r5, r1\n\
+ ldrb r1, [r2]\n\
+ adds r1, 0x6\n\
+ ldrb r2, [r2, 0x2]\n\
+ adds r1, r2\n\
+ lsls r2, r1, 3\n\
+ adds r2, r1\n\
+ lsls r2, 2\n\
+ ldr r1, _0806ECB0 @ =gSaveBlock1 + 0x2B4C\n\
+ adds r4, r2, r1\n\
+ cmp r0, 0\n\
+ beq _0806ECBC\n\
+ ldr r0, _0806ECB4 @ =gOtherText_PokeHoldingItemCantMail\n\
+ movs r1, 0x1\n\
+ bl sub_806E834\n\
+ ldr r0, _0806ECB8 @ =party_menu_link_mon_held_item_object\n\
+ movs r1, 0x5\n\
+ bl CreateTask\n\
+ b _0806ECDA\n\
+ .align 2, 0\n\
+_0806ECA0: .4byte gTasks\n\
+_0806ECA4: .4byte TaskDummy\n\
+_0806ECA8: .4byte 0x0201c000\n\
+_0806ECAC: .4byte gUnknown_0202E8F4\n\
+_0806ECB0: .4byte gSaveBlock1 + 0x2B4C\n\
+_0806ECB4: .4byte gOtherText_PokeHoldingItemCantMail\n\
+_0806ECB8: .4byte party_menu_link_mon_held_item_object\n\
+_0806ECBC:\n\
+ ldr r0, [r5]\n\
+ adds r1, r4, 0\n\
+ bl GiveMailToMon2\n\
+ adds r0, r4, 0\n\
+ bl ClearMailStruct\n\
+ ldr r0, _0806ECE0 @ =gOtherText_MailTransferredMailbox\n\
+ movs r1, 0x1\n\
+ bl sub_806E834\n\
+ ldr r0, _0806ECE4 @ =party_menu_link_mon_held_item_object\n\
+ movs r1, 0x5\n\
+ bl CreateTask\n\
+_0806ECDA:\n\
+ pop {r4,r5}\n\
+ pop {r0}\n\
+ bx r0\n\
+ .align 2, 0\n\
+_0806ECE0: .4byte gOtherText_MailTransferredMailbox\n\
+_0806ECE4: .4byte party_menu_link_mon_held_item_object\n\
+ .syntax divided\n");
+}
+
+void PartyMenuTryGiveMonHeldItem_806ECE8(u8 taskId, TaskFunc func)
+{
+ u16 currentItem;
+
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, 0, func);
+ currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM);
+ if (currentItem == 0)
+ {
+ StringExpandPlaceholders(gStringVar4, gOtherText_NotHoldingAnything);
+ sub_806E834(gStringVar4, 0);
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+ else
+ {
+ u8 itemData[2];
+
+ itemData[0] = 0;
+ itemData[1] = 0;
+ if (AddBagItem(currentItem, 1) == TRUE)
+ {
+ if (ItemIsMail(currentItem) == TRUE)
+ TakeMailFromMon(ewram1C000.pokemon);
+ DisplayTakeHeldItemMessage(ewram1C000.unk5, currentItem, 0);
+ SetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM, itemData);
+ }
+ else
+ {
+ sub_806E834(gOtherText_BagFullCannotRemoveItem, 0);
+ }
+ CreateTask(party_menu_link_mon_held_item_object, 5);
+ }
+}
+
+void DisplayTakeHeldItemMessage(u8 a, u16 b, u8 c)
+{
+ GetMonNickname(&gPlayerParty[a], gStringVar1);
+ CopyItemName(b, gStringVar2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_ReceivedTheThingFrom);
+ sub_806E834(gStringVar4, c);
+}
+
+void DoTakeMail(u8 taskId, TaskFunc func)
+{
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, 0, func);
+ ewram1C000.unk6 = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM);
+ sub_806E834(gOtherText_SendRemovedMailPrompt, 1);
+ CreateTask(Task_ConfirmTakeHeldMail, 5);
+}
+
+void Task_LoseMailMessage(u8 taskId)
+{
+ s8 selection = ProcessMenuInputNoWrap_();
+
+ if (selection == 0)
+ {
+ if (AddBagItem(ewram1C000.unk6, 1) == TRUE)
+ {
+ TakeMailFromMon(ewram1C000.pokemon);
+ sub_806E834(gOtherText_MailTaken, 0);
+ }
+ else
+ {
+ sub_806E834(gOtherText_BagFullCannotRemoveItem, 0);
+ }
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+ }
+ else
+ {
+ if (selection != 1 && selection != -1)
+ return;
+ if (selection == -1)
+ PlaySE(SE_SELECT);
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ MenuZeroFillWindowRect(0, 14, 29, 19);
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+ }
+}
+
+void Task_ConfirmLoseMailMessage(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ DisplayYesNoMenu(23, 8, 1);
+ gTasks[taskId].func = Task_LoseMailMessage;
+ }
+}
+
+void Task_TakeHeldMail(u8 taskId)
+{
+ s8 selection = ProcessMenuInputNoWrap_();
+
+ if (selection == 0)
+ {
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ if (TakeMailFromMon2(ewram1C000.pokemon) != 0xFF)
+ sub_806E834(gOtherText_MailWasSent, 0);
+ else
+ sub_806E834(gOtherText_MailboxIsFull, 0);
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+ }
+ else
+ {
+ if (selection != 1 && selection != -1)
+ return;
+ if (selection == -1)
+ PlaySE(SE_SELECT);
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ sub_806E834(gOtherText_MailRemovedMessageLost, 1);
+ gTasks[taskId].func = Task_ConfirmLoseMailMessage;
+ }
+}
+
+void Task_ConfirmTakeHeldMail(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ DisplayYesNoMenu(23, 8, 1);
+ gTasks[taskId].func = Task_TakeHeldMail;
+ }
+}
+
+u16 ItemIdToBattleMoveId(u16 item)
+{
+ u16 moveId = item - 289;
+
+ return gUnknown_08376504[moveId];
+}
+
+bool8 pokemon_has_move(struct Pokemon *pkmn, u16 move)
+{
+ u8 i;
+
+ for (i = 0; i < 4; i++)
+ {
+ if (GetMonData(pkmn, MON_DATA_MOVE1 + i) == move)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void TeachMonTMMove(u8 taskId, u16 move, TaskFunc func)
+{
+ PlaySE(SE_SELECT);
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, move, func);
+ CreateTask(Task_TeamMonTMMove, 5);
+}
+
+void Task_TeamMonTMMove(u8 taskId)
+{
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ ewram1C000.unk8 = ItemIdToBattleMoveId(ewram1C000.unk6);
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ ewram1B000.unk282 = 0;
+ if (pokemon_has_move(ewram1C000.pokemon, ewram1C000.unk8))
+ {
+ StringExpandPlaceholders(gStringVar4, gOtherText_AlreadyKnows);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+ }
+ else
+ {
+ if (!CanMonLearnTMHM(ewram1C000.pokemon, ewram1C000.unk6 - 33))
+ {
+ StringExpandPlaceholders(gStringVar4, gOtherText_NotCompatible);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = party_menu_link_mon_held_item_object;
+ }
+ else
+ {
+ if (GiveMoveToMon(ewram1C000.pokemon, ewram1C000.unk8) != 0xFFFF)
+ {
+ Task_TeamMonTMMove2(taskId);
+ }
+ else
+ {
+ StringExpandPlaceholders(gStringVar4, gOtherText_WantsToLearn);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = sub_806F358;
+ }
+ }
+ }
+}
+
+void Task_TeamMonTMMove2(u8 taskId)
+{
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_LearnedMove);
+ sub_806E834(gStringVar4, 1);
+ AdjustFriendship(ewram1C000.pokemon, 4);
+ if (ewram1B000.unk282 == 0 && ewram1C000.unk6 <= 0x152)
+ RemoveBagItem(ewram1C000.unk6, 1);
+ gTasks[taskId].func = Task_TeamMonTMMove3;
+}
+
+void Task_TeamMonTMMove3(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ PlayFanfare(BGM_FANFA1);
+ gTasks[taskId].func = Task_TeamMonTMMove4;
+ }
+}
+
+void Task_TeamMonTMMove4(u8 taskId)
+{
+ if (IsFanfareTaskInactive())
+ {
+ if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ {
+ SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5);
+ if (ewram1B000.unk282 == 1)
+ {
+ sub_8070C54(taskId);
+ }
+ else
+ {
+ gTasks[ewram1C000.unk4].func = ewram1C000.unk10;
+ DestroyTask(taskId);
+ }
+ }
+ }
+}
+
+void sub_806F2FC(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ SetHeldItemIconVisibility(ewram1C000.unk4, ewram1C000.unk5);
+ if (ewram1B000.unk282 == 1)
+ {
+ sub_8070C54(taskId);
+ }
+ else
+ {
+ gTasks[ewram1C000.unk4].func = ewram1C000.unk10;
+ DestroyTask(taskId);
+ }
+ }
}
-asm(".section .text_b");
+void sub_806F358(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ DisplayYesNoMenu(23, 8, 1);
+ gTasks[taskId].func = sub_806F390;
+ }
+}
+
+void sub_806F390(u8 taskId)
+{
+ s8 selection = ProcessMenuInputNoWrap_();
+
+ if (selection == 0)
+ {
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ sub_806E834(gOtherText_WhichMoveToForget2, 1);
+ gTasks[taskId].func = sub_806F44C;
+ }
+ else
+ {
+ if (selection != 1 && selection != -1)
+ return;
+ if (selection == -1)
+ PlaySE(SE_SELECT);
+ StopTryingToTeachMove_806F614(taskId);
+ }
+}
+
+void sub_806F3FC(u8 taskId)
+{
+ if (!gPaletteFade.active)
+ {
+ sub_809D9F0(gPlayerParty, ewram1C000.unk5, gPlayerPartyCount - 1, sub_808B564, ewram1C000.unk8);
+ DestroyTask(taskId);
+ }
+}
+
+void sub_806F44C(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0);
+ gTasks[taskId].func = sub_806F3FC;
+ }
+}
+
+void TaughtMove(u8 taskId)
+{
+ if (!gPaletteFade.active)
+ {
+ u8 moveIndex;
+ u16 r4;
+
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, gScriptItemId, sub_808B508);
+ moveIndex = sub_809FA30();
+ r4 = GetMonData(ewram1C000.pokemon, MON_DATA_MOVE1 + moveIndex);
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ StringCopy(gStringVar2, gMoveNames[r4]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_ForgetMove123_2);
+ sub_806E834(gStringVar4, 1);
+ CreateTask(TMMoveUpdateMoveSlot, 5);
+ }
+}
+
+void TMMoveUpdateMoveSlot(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ RemoveMonPPBonus(ewram1C000.pokemon, sub_809FA30());
+ SetMonMoveSlot(ewram1C000.pokemon, ewram1C000.unk8, sub_809FA30());
+ Task_TeamMonTMMove2(taskId);
+ }
+}
+
+void StopTryingToTeachMove_806F588(u8 taskId)
+{
+ if (!gPaletteFade.active)
+ {
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, gScriptItemId, sub_808B508);
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_StopTryingTo);
+ sub_806E834(gStringVar4, 1);
+ CreateTask(StopTryingToTeachMove_806F67C, 5);
+ }
+}
+
+void StopTryingToTeachMove_806F614(u8 taskId)
+{
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_StopTryingTo);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = StopTryingToTeachMove_806F67C;
+}
+
+void StopTryingToTeachMove_806F67C(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ DisplayYesNoMenu(23, 8, 1);
+ gTasks[taskId].func = StopTryingToTeachMove_806F6B4;
+ }
+}
+
+void StopTryingToTeachMove_806F6B4(u8 taskId)
+{
+ s8 selection = ProcessMenuInputNoWrap_();
+
+ if (selection == 0)
+ {
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_DidNotLearnMove2);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = sub_806F2FC;
+ }
+ else
+ {
+ if (selection != 1 && selection != -1)
+ return;
+ if (selection == -1)
+ PlaySE(SE_SELECT);
+ MenuZeroFillWindowRect(23, 8, 29, 13);
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WantsToLearn);
+ sub_806E834(gStringVar4, 1);
+ gTasks[taskId].func = sub_806F358;
+ }
+}
+
+bool8 IsHMMove(u16 move)
+{
+ u8 i;
+
+ for (i = 0; i < 8; i++)
+ {
+ if (gUnknown_08376504[50 + i] == move)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+s16 sub_806F7E8(u8 taskId, struct BattleInterfaceStruct1 *b, s8 c)
+{
+ s16 *taskData;
+ u8 hpBarLevel;
+ void *vramPtr;
+
+ taskData = gTasks[taskId].data;
+
+ b->unk0 = taskData[10];
+ b->unk4 = taskData[11];
+ b->unk8 = taskData[12] * c;
+ b->unk10 = 0x100;
+ hpBarLevel = GetHPBarLevel(ewram1B000.unk282, b->unk0);
+ if (hpBarLevel > 2)
+ b->unkC_0 = 4;
+ if (hpBarLevel == 2)
+ b->unkC_0 = 5;
+ if (hpBarLevel < 2)
+ b->unkC_0 = 6;
+ vramPtr = gUnknown_08376858[IsDoubleBattle()][ewram1C000.unk5];
+ return sub_80460C8(b, &ewram1C000.unkC, vramPtr, 0);
+}
+
+void sub_806F8AC(u8 taskId)
+{
+ struct BattleInterfaceStruct1 sp0;
+ u16 sp14;
+
+ ewram1B000.unk282 = sub_806F7E8(taskId, &sp0, -1);
+ if (ewram1B000.unk282 == -1)
+ {
+ ewram1C000.unkC = 0;
+ if (-sp0.unk8 + sp0.unk4 > sp0.unk0)
+ sp14 = sp0.unk0 - sp0.unk4;
+ else
+ sp14 = -sp0.unk8;
+ gBattleMoveDamage = -sp14;
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ ConvertIntToDecimalStringN(gStringVar2, sp14, 0, 3);
+ if (gTasks[taskId].data[14] == 0)
+ StringExpandPlaceholders(gStringVar4, gOtherText_HPRestoredBy);
+ else
+ StringExpandPlaceholders(gStringVar4, gOtherText_RegainedHealth);
+ SetMonIconAnim(GetMonIconSpriteId_maybe(ewram1C000.unk4, ewram1C000.unk5), ewram1C000.pokemon);
+ task_pc_turn_off(&gUnknown_083769A8[IsDoubleBattle() * 12 + ewram1C000.unk5 * 2], 7);
+ ewram1B000.unk261 = 2;
+ sub_806E834(gStringVar4, 1);
+ sp14 += sp0.unk4;
+ SetMonData(ewram1C000.pokemon, MON_DATA_HP, (u8 *)&sp14);
+ RemoveBagItem(ewram1C000.unk6, 1);
+ sub_8032638();
+ gTasks[taskId].func = sub_806FB44;
+ }
+ else
+ {
+ PartyMenuDoPrintHP(ewram1C000.unk5, IsDoubleBattle(), ewram1B000.unk282, sp0.unk0);
+ }
+}
+
+void sub_806FA18(u8 taskId)
+{
+ struct BattleInterfaceStruct1 sp0;
+
+ ewram1B000.unk282 = sub_806F7E8(taskId, &sp0, 1);
+ if (ewram1B000.unk282 == -1)
+ {
+ PlaySE(SE_KAIFUKU);
+ ewram1C000.unkC = 0;
+ gTasks[taskId].data[11] -= gTasks[taskId].data[12];
+ SetMonData(ewram1C000.pokemon, MON_DATA_HP, (u8 *)&gTasks[taskId].data[11]);
+ SetMonIconAnim(GetMonIconSpriteId_maybe(ewram1C000.unk4, ewram01000.unk1), ewram1C000.pokemon);
+ ewram1C000.unk5 = gSprites[ewram01000.unk2].data0;
+ ewram1C000.pokemon = &gPlayerParty[ewram1C000.unk5];
+ gTasks[taskId].data[10] = GetMonData(ewram1C000.pokemon, MON_DATA_MAX_HP);
+ gTasks[taskId].data[11] = GetMonData(ewram1C000.pokemon, MON_DATA_HP);
+ ewram1C000.unkC = -32768;
+ ewram1C000.unk14 = ewram1C000.unk10;
+ gTasks[taskId].func = sub_806F8AC;
+ ewram1B000.unk282 = gTasks[taskId].data[11];
+ }
+ else
+ {
+ PartyMenuDoPrintHP(ewram1C000.unk5, IsDoubleBattle(), ewram1B000.unk282, sp0.unk0);
+ }
+}
+
+void sub_806FB0C(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ gTasks[ewram1C000.unk4].func = ewram1C000.unk10;
+ DestroyTask(taskId);
+ }
+}
+
+void sub_806FB44(u8 taskId)
+{
+ if (gUnknown_0202E8F6 == 0)
+ {
+ gTasks[ewram1C000.unk4].func = ewram1C000.unk14;
+ DestroyTask(taskId);
+ }
+}
+
+bool8 IsHPRecoveryItem(u16 item)
+{
+ const u8 *itemEffect;
+
+ if (item == 0xAF)
+ itemEffect = gSaveBlock1.enigmaBerry.itemEffect;
+ else
+ itemEffect = gItemEffectTable[item - 13];
+
+ if (itemEffect[4] & 4)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+void PartyMenuUpdateLevelOrStatus(struct Pokemon *pkmn, u8 b)
+{
+ PartyMenuClearLevelStatusTilemap(b);
+ PartyMenuPrintMonLevelOrStatus(b, pkmn);
+}
+
+void GetMedicineItemEffectMessage(u16 item)
+{
+ switch (GetItemEffectType(item))
+ {
+ case 3:
+ StringExpandPlaceholders(gStringVar4, gOtherText_CuredPoisoning);
+ break;
+ case 4:
+ StringExpandPlaceholders(gStringVar4, gOtherText_WokeUp);
+ break;
+ case 5:
+ StringExpandPlaceholders(gStringVar4, gOtherText_BurnHealed);
+ break;
+ case 6:
+ StringExpandPlaceholders(gStringVar4, gOtherText_ThawedOut);
+ break;
+ case 7:
+ StringExpandPlaceholders(gStringVar4, gOtherText_CuredParalysis);
+ break;
+ case 8:
+ StringExpandPlaceholders(gStringVar4, gOtherText_SnapConfusion);
+ break;
+ case 9:
+ StringExpandPlaceholders(gStringVar4, gOtherText_GotOverLove);
+ break;
+ case 11:
+ StringExpandPlaceholders(gStringVar4, gOtherText_BecameHealthy);
+ break;
+ case 13:
+ StringCopy(gStringVar2, gOtherText_Hp2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 12:
+ StringCopy(gStringVar2, gOtherText_Attack);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 17:
+ StringCopy(gStringVar2, gOtherText_Defense);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 16:
+ StringCopy(gStringVar2, gOtherText_Speed);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 14:
+ StringCopy(gStringVar2, gOtherText_SpAtk2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 15:
+ StringCopy(gStringVar2, gOtherText_SpDef2);
+ StringExpandPlaceholders(gStringVar4, gOtherText_WasRaised);
+ break;
+ case 19:
+ case 20:
+ StringExpandPlaceholders(gStringVar4, gOtherText_PPIncreased);
+ break;
+ case 21:
+ StringExpandPlaceholders(gStringVar4, gOtherText_PPRestored);
+ break;
+ default:
+ StringExpandPlaceholders(gStringVar4, gOtherText_WontHaveAnyEffect);
+ break;
+ }
+}
+
+bool8 IsMedicineIneffective(struct Pokemon *pkmn, u16 item)
+{
+ if (GetItemEffectType(item) == 13
+ && GetMonData(pkmn, MON_DATA_SPECIES) == SPECIES_SHEDINJA)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+bool8 ExecuteTableBasedItemEffect__(u8 a, u16 b, u8 c)
+{
+ if (gMain.inBattle)
+ return ExecuteTableBasedItemEffect_(&gPlayerParty[a], b, sub_8094C20(a), c);
+ else
+ return ExecuteTableBasedItemEffect_(&gPlayerParty[a], b, a, c);
+}
+
+void UseMedicine(u8 taskId, u16 item, TaskFunc func)
+{
+ u8 r7;
+ bool8 r9 = FALSE;
+ bool8 r0;
+
+ gTasks[taskId].func = TaskDummy;
+ r7 = CreateTask(TaskDummy, 5);
+ sub_806E8D0(taskId, item, func);
+ if (!IsMedicineIneffective(ewram1C000.pokemon, item))
+ {
+ r9 = IsHPRecoveryItem(item);
+ if (r9 == TRUE)
+ {
+ gTasks[r7].data[10] = GetMonData(ewram1C000.pokemon, MON_DATA_MAX_HP);
+ gTasks[r7].data[11] = GetMonData(ewram1C000.pokemon, MON_DATA_HP);
+ if (gTasks[r7].data[10] == gTasks[r7].data[11])
+ {
+ r9 = FALSE;
+ gTasks[r7].data[10] = 0;
+ gTasks[r7].data[11] = 0;
+ }
+ }
+ r0 = ExecuteTableBasedItemEffect__(ewram1C000.unk5, item, 0);
+ }
+ else
+ {
+ r0 = TRUE;
+ }
+
+ if (r0)
+ {
+ gUnknown_0202E8F4 = 0;
+ PlaySE(SE_SELECT);
+ sub_806E834(gOtherText_WontHaveAnyEffect, 1);
+ gTasks[r7].func = sub_806FB0C;
+ }
+ else
+ {
+ u8 statusAndPkrs;
+
+ gUnknown_0202E8F4 = 1;
+ if (!IsBlueYellowRedFlute(item))
+ PlaySE(SE_KAIFUKU);
+ else
+ PlaySE(SE_BIDORO);
+ statusAndPkrs = GetMonStatusAndPokerus(ewram1C000.pokemon);
+ if (statusAndPkrs == 6 || statusAndPkrs == 0)
+ PartyMenuUpdateLevelOrStatus(ewram1C000.pokemon, ewram1C000.unk5);
+ if (r9 == TRUE)
+ {
+ gTasks[r7].data[12] = GetMonData(ewram1C000.pokemon, MON_DATA_HP) - gTasks[r7].data[11];
+ ewram1C000.unkC = -32768;
+ if (gTasks[r7].data[11] == 0)
+ gTasks[r7].data[14] = 1;
+ else
+ gTasks[r7].data[14] = 0;
+ ewram1C000.unk14 = ewram1C000.unk10;
+ gTasks[r7].func = sub_806F8AC;
+ ewram1B000.unk282 = gTasks[r7].data[11];
+ }
+ else
+ {
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ if (!IsBlueYellowRedFlute(item))
+ RemoveBagItem(item, 1);
+ GetMedicineItemEffectMessage(item);
+ TryPrintPartyMenuMonNickname(ewram1C000.unk5, ewram1C000.pokemon);
+ sub_806E834(gStringVar4, 1);
+ gTasks[r7].func = sub_806FB0C;
+ }
+ }
+}
+
+bool8 IsBlueYellowRedFlute(u16 item)
+{
+ if (item == 0x27
+ || item == 0x29
+ || item == 0x28)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+void sub_8070048(u8 taskId, u16 item, TaskFunc func)
+{
+ ewram1C000.unk10 = func;
+ ewram1C000.unk4 = taskId;
+ ewram1C000.unk6 = item;
+ ewram1C000.unk5 = 0;
+ ewram1C000.unk14 = sub_80701DC;
+ ewram1B000.unk27E = 0;
+ ewram1B000.unk280 = 0;
+ sub_8070088(taskId);
+}
void sub_8070088(u8 taskId)
{
@@ -169,7 +1218,7 @@ void sub_8070088(u8 taskId)
ewram1B000.unk27E = 1;
ewram1B000.unk280 = 1;
ewram1B000.unk282 = taskData[11];
- ewram1C000.var0C = -32768;
+ ewram1C000.unkC = -32768;
gTasks[taskId2].func = sub_806F8AC;
}
}
@@ -253,7 +1302,7 @@ void Task_HandleItemUseMoveMenuInput(u8 taskId)
void DoPPRecoveryItemEffect(u8 taskId, u16 b, TaskFunc c)
{
- u8 *itemEffect;
+ const u8 *itemEffect;
u8 taskId2;
if (b == 0xAF)
@@ -322,7 +1371,80 @@ void DoRecoverPP(u8 taskId)
gTasks[taskId].func = sub_806FB0C;
}
-asm(".section .text_c");
+void DoPPUpItemEffect(u8 taskId, u16 b, TaskFunc c)
+{
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, b, c);
+ PlaySE(SE_SELECT);
+ sub_806D538(11, 3);
+ CreateItemUseMoveMenu(ewram1C000.unk5);
+ CreateTask(Task_HandleItemUseMoveMenuInput, 5);
+ gMain.newKeys = 0;
+}
+
+void DoRareCandyItemEffect(u8 taskId, u16 b, TaskFunc c)
+{
+ u8 i;
+ bool8 r0;
+
+ gTasks[taskId].func = TaskDummy;
+ sub_806E8D0(taskId, b, c);
+
+ if (GetMonData(ewram1C000.pokemon, MON_DATA_LEVEL) != 100)
+ {
+ for (i = 0; i < 6; i++)
+ ewram1B000.unk264[i] = GetMonData(ewram1C000.pokemon, gUnknown_08376D1C[i]);
+ r0 = ExecuteTableBasedItemEffect__(ewram1C000.unk5, b, 0);
+ }
+ else
+ r0 = TRUE;
+
+ if (r0)
+ {
+ gUnknown_0202E8F4 = 0;
+ PlaySE(SE_SELECT);
+ sub_806E834(gOtherText_WontHaveAnyEffect, 1);
+ CreateTask(sub_806FB0C, 5);
+ }
+ else
+ {
+ u8 level;
+
+ gUnknown_0202E8F4 = 1;
+ PlayFanfareByFanfareNum(0);
+ sub_8070A20(ewram1C000.unk5, ewram1C000.pokemon);
+ RemoveBagItem(b, 1);
+ GetMonNickname(ewram1C000.pokemon, gStringVar1);
+ level = GetMonData(ewram1C000.pokemon, MON_DATA_LEVEL);
+ ConvertIntToDecimalStringN(gStringVar2, level, 0, 3);
+ StringExpandPlaceholders(gStringVar4, gOtherText_ElevatedTo);
+ sub_806E834(gStringVar4, 1);
+ CreateTask(Task_RareCandy1, 5);
+ }
+}
+
+void Task_RareCandy1(u8 taskId)
+{
+ if (WaitFanfare(0) && gUnknown_0202E8F6 == 0)
+ {
+ if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ {
+ PlaySE(SE_SELECT);
+ sub_8070848(taskId);
+ gTasks[taskId].func = Task_RareCandy2;
+ }
+ }
+}
+
+void Task_RareCandy2(u8 taskId)
+{
+ if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))
+ {
+ PlaySE(SE_SELECT);
+ sub_8070968(taskId);
+ gTasks[taskId].func = Task_RareCandy3;
+ }
+}
void sub_8070848(u8 taskId)
{