diff options
-rw-r--r-- | asm/party_menu.s | 331 | ||||
-rw-r--r-- | include/global.berry.h | 46 | ||||
-rw-r--r-- | include/menu.h | 3 | ||||
-rw-r--r-- | include/party_menu.h | 23 | ||||
-rw-r--r-- | include/pokemon_menu.h | 3 | ||||
-rw-r--r-- | ld_script.txt | 1 | ||||
-rw-r--r-- | src/battle_party_menu.c | 13 | ||||
-rw-r--r-- | src/choose_party.c | 16 | ||||
-rw-r--r-- | src/party_menu.c | 357 | ||||
-rw-r--r-- | src/pokemon_menu.c | 18 |
10 files changed, 410 insertions, 401 deletions
diff --git a/asm/party_menu.s b/asm/party_menu.s index c9b9ee346..0ac05c847 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -7328,335 +7328,4 @@ sub_806E720: @ 806E720 bx r0 thumb_func_end sub_806E720 - thumb_func_start sub_806E750 -sub_806E750: @ 806E750 - push {r4-r6,lr} - mov r6, r9 - mov r5, r8 - push {r5,r6} - sub sp, 0xC - adds r5, r0, 0 - adds r4, r1, 0 - mov r9, r2 - adds r6, r3, 0 - lsls r5, 24 - lsrs r5, 24 - lsls r6, 24 - lsrs r6, 24 - movs r0, 0x9 - add r0, sp - mov r8, r0 - adds r0, r5, 0 - add r1, sp, 0x8 - mov r2, r8 - adds r3, r4, 0 - bl sub_806E720 - add r0, sp, 0x8 - ldrb r0, [r0] - mov r2, r8 - ldrb r1, [r2] - lsls r5, 3 - adds r5, r4 - ldrb r2, [r5, 0x1] - ldrb r3, [r5] - mov r4, r9 - str r4, [sp] - ldr r4, [r5, 0x4] - str r4, [sp, 0x4] - bl sub_8089C50 - add r0, sp, 0x8 - ldrb r1, [r0] - adds r1, 0x1 - lsls r1, 24 - lsrs r1, 24 - mov r0, r8 - ldrb r2, [r0] - adds r2, 0x1 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r5] - str r6, [sp] - ldrb r0, [r5, 0x1] - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - str r0, [sp, 0x4] - movs r0, 0 - bl InitMenu - add sp, 0xC - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_806E750 - - thumb_func_start sub_806E7D0 -sub_806E7D0: @ 806E7D0 - push {r4-r6,lr} - sub sp, 0x4 - adds r4, r0, 0 - adds r6, r1, 0 - lsls r4, 24 - lsrs r4, 24 - mov r5, sp - adds r5, 0x1 - adds r0, r4, 0 - mov r1, sp - adds r2, r5, 0 - adds r3, r6, 0 - bl sub_806E720 - mov r0, sp - ldrb r0, [r0] - ldrb r1, [r5] - lsls r4, 3 - adds r4, r6 - ldrb r2, [r4, 0x1] - adds r2, r0, r2 - lsls r2, 24 - lsrs r2, 24 - ldrb r3, [r4] - lsls r3, 1 - adds r3, r1, r3 - adds r3, 0x1 - lsls r3, 24 - lsrs r3, 24 - bl MenuZeroFillWindowRect - bl HandleDestroyMenuCursors - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - thumb_func_end sub_806E7D0 - - thumb_func_start PartyMenuGetPopupMenuFunc -PartyMenuGetPopupMenuFunc: @ 806E81C - lsls r0, 24 - lsls r3, 24 - lsrs r3, 24 - lsrs r0, 21 - adds r0, r1 - ldr r0, [r0, 0x4] - adds r0, r3 - ldrb r0, [r0] - lsls r0, 3 - adds r0, r2 - ldr r0, [r0, 0x4] - bx lr - thumb_func_end PartyMenuGetPopupMenuFunc - - .section .text_8070968 - - thumb_func_start GetItemEffectType -GetItemEffectType: @ 8070E48 - push {r4,r5,lr} - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xAF - bne _08070E5C - ldr r4, _08070E58 @ =gSaveBlock1 + 0x3676 - b _08070E66 - .align 2, 0 -_08070E58: .4byte gSaveBlock1 + 0x3676 -_08070E5C: - ldr r1, _08070E8C @ =gItemEffectTable - subs r0, 0xD - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] -_08070E66: - ldrb r1, [r4] - movs r5, 0x3F - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - bne _08070E88 - ldrb r0, [r4, 0x1] - cmp r0, 0 - bne _08070E88 - ldrb r0, [r4, 0x2] - cmp r0, 0 - bne _08070E88 - ldrb r3, [r4, 0x3] - movs r0, 0x80 - ands r0, r3 - cmp r0, 0 - beq _08070E90 -_08070E88: - movs r0, 0 - b _08070F8A - .align 2, 0 -_08070E8C: .4byte gItemEffectTable -_08070E90: - movs r2, 0x40 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _08070E9E - movs r0, 0xA - b _08070F8A -_08070E9E: - adds r0, r2, 0 - ands r0, r3 - cmp r0, 0 - beq _08070EAA - movs r0, 0x1 - b _08070F8A -_08070EAA: - adds r2, r5, 0 - ands r2, r3 - cmp r2, 0 - bne _08070EB8 - lsrs r0, r1, 7 - cmp r0, 0 - beq _08070EFA -_08070EB8: - cmp r2, 0x20 - bne _08070EC0 - movs r0, 0x4 - b _08070F8A -_08070EC0: - cmp r2, 0x10 - bne _08070EC8 - movs r0, 0x3 - b _08070F8A -_08070EC8: - cmp r2, 0x8 - bne _08070ED0 - movs r0, 0x5 - b _08070F8A -_08070ED0: - cmp r2, 0x4 - bne _08070ED8 - movs r0, 0x6 - b _08070F8A -_08070ED8: - cmp r2, 0x2 - bne _08070EE0 - movs r0, 0x7 - b _08070F8A -_08070EE0: - cmp r2, 0x1 - bne _08070EE8 - movs r0, 0x8 - b _08070F8A -_08070EE8: - lsrs r0, r1, 7 - cmp r0, 0 - beq _08070EF6 - cmp r2, 0 - bne _08070EF6 - movs r0, 0x9 - b _08070F8A -_08070EF6: - movs r0, 0xB - b _08070F8A -_08070EFA: - ldrb r1, [r4, 0x4] - movs r0, 0x44 - ands r0, r1 - adds r2, r1, 0 - cmp r0, 0 - beq _08070F0A - movs r0, 0x2 - b _08070F8A -_08070F0A: - movs r5, 0x2 - adds r0, r5, 0 - ands r0, r2 - cmp r0, 0 - beq _08070F18 - movs r0, 0xC - b _08070F8A -_08070F18: - movs r3, 0x1 - adds r0, r3, 0 - ands r0, r2 - cmp r0, 0 - beq _08070F26 - movs r0, 0xD - b _08070F8A -_08070F26: - ldrb r1, [r4, 0x5] - movs r0, 0x8 - ands r0, r1 - cmp r0, 0 - beq _08070F34 - movs r0, 0xE - b _08070F8A -_08070F34: - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08070F40 - movs r0, 0xF - b _08070F8A -_08070F40: - adds r0, r5, 0 - ands r0, r1 - cmp r0, 0 - beq _08070F4C - movs r0, 0x10 - b _08070F8A -_08070F4C: - adds r0, r3, 0 - ands r0, r1 - cmp r0, 0 - beq _08070F58 - movs r0, 0x11 - b _08070F8A -_08070F58: - movs r0, 0x80 - ands r0, r2 - cmp r0, 0 - beq _08070F64 - movs r0, 0x12 - b _08070F8A -_08070F64: - movs r0, 0x20 - ands r0, r2 - cmp r0, 0 - beq _08070F70 - movs r0, 0x13 - b _08070F8A -_08070F70: - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _08070F7C - movs r0, 0x14 - b _08070F8A -_08070F7C: - movs r0, 0x18 - ands r0, r2 - cmp r0, 0 - bne _08070F88 - movs r0, 0x16 - b _08070F8A -_08070F88: - movs r0, 0x15 -_08070F8A: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end GetItemEffectType - - thumb_func_start unref_sub_8070F90 -unref_sub_8070F90: @ 8070F90 - push {lr} - ldr r0, _08070FAC @ =0x00000801 - bl FlagSet - movs r0, 0x80 - lsls r0, 4 - bl FlagSet - ldr r0, _08070FB0 @ =0x00000802 - bl FlagSet - pop {r0} - bx r0 - .align 2, 0 -_08070FAC: .4byte 0x00000801 -_08070FB0: .4byte 0x00000802 - thumb_func_end unref_sub_8070F90 - .align 2, 0 @ Don't pad with nop. diff --git a/include/global.berry.h b/include/global.berry.h index 6632e55e2..096d8b1d8 100644 --- a/include/global.berry.h +++ b/include/global.berry.h @@ -3,33 +3,33 @@ struct Berry { - const u8 name[7]; - u8 firmness; - u16 size; - u8 maxYield; - u8 minYield; - const u8 *description1; - const u8 *description2; - u8 stageDuration; - u8 spicy; - u8 dry; - u8 sweet; - u8 bitter; - u8 sour; - u8 smoothness; + /*0x00*/const u8 name[7]; + /*0x07*/u8 firmness; + /*0x08*/u16 size; + /*0x0A*/u8 maxYield; + /*0x0B*/u8 minYield; + /*0x0C*/const u8 *description1; + /*0x10*/const u8 *description2; + /*0x14*/u8 stageDuration; + /*0x15*/u8 spicy; + /*0x16*/u8 dry; + /*0x17*/u8 sweet; + /*0x18*/u8 bitter; + /*0x19*/u8 sour; + /*0x1A*/u8 smoothness; }; struct EnigmaBerry { - struct Berry berry; - u8 pic[(6 * 6) * TILE_SIZE_4BPP]; - u16 palette[16]; - u8 description1[45]; - u8 description2[45]; - u8 itemEffect[18]; - u8 holdEffect; - u8 holdEffectParam; - u32 checksum; + /*0x000*/struct Berry berry; + /*0x01B*/u8 pic[(6 * 6) * TILE_SIZE_4BPP]; + /*0x49C*/u16 palette[16]; + /*0x4BC*/u8 description1[45]; + /*0x4E9*/u8 description2[45]; + /*0x516*/u8 itemEffect[18]; + /*0x528*/u8 holdEffect; + /*0x529*/u8 holdEffectParam; + /*0x52C*/u32 checksum; }; struct BattleEnigmaBerry diff --git a/include/menu.h b/include/menu.h index 3cf47b9b8..9a5ca62a0 100644 --- a/include/menu.h +++ b/include/menu.h @@ -1,6 +1,7 @@ #ifndef GUARD_MENU_H #define GUARD_MENU_H +#include "task.h" #include "text.h" struct MenuAction @@ -12,7 +13,7 @@ struct MenuAction struct MenuAction2 { const u8 *text; - void (*func)(u8); + TaskFunc func; }; extern const struct MenuAction gMenuYesNoItems[]; diff --git a/include/party_menu.h b/include/party_menu.h index 8734cbe65..5eee17fd2 100644 --- a/include/party_menu.h +++ b/include/party_menu.h @@ -1,19 +1,14 @@ #ifndef GUARD_PARTY_MENU_H #define GUARD_PARTY_MENU_H +#include "menu.h" #include "task.h" -struct PartyMenuItem -{ - const u8 *text; - TaskFunc func; -}; - struct PartyPopupMenu { - u8 unk0; - u8 unk1; - const u8 *unk4; + /*0x0*/u8 numChoices; // number of menu choices + /*0x1*/u8 width; // menu width (number of characters it can fit horizontally) + /*0x4*/const u8 *items; // menu item ids (ids for a MenuAction2 array) }; // TODO: Unify these two structs @@ -119,11 +114,9 @@ void PartyMenuTryPrintMonsHP(void); void nullsub_13(void); void PartyMenuDrawHPBars(void); void sub_806E6F0(); -void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); -void sub_806E7D0(u8, const struct PartyPopupMenu *); -TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); -void DoEvolutionStoneItemEffect(u8, u16, TaskFunc); -u8 GetItemEffectType(); +void ShowPartyPopupMenu(u8 menuIndex, const struct PartyPopupMenu *menu, const struct MenuAction2 *menuActions, u8 cursorPos); +void ClosePartyPopupMenu(u8 index, const struct PartyPopupMenu *menu); +TaskFunc PartyMenuGetPopupMenuFunc(u8 menuIndex, const struct PartyPopupMenu *menus, const struct MenuAction2 *menuActions, u8 itemIndex); u8 sub_806E834(const u8 *message, u8 arg1); void sub_806E8D0(u8 taskId, u16 b, TaskFunc c); void party_menu_link_mon_held_item_object(u8); @@ -169,6 +162,7 @@ void RedrawPokemonInfoInMenu(u8, struct Pokemon *); void Task_RareCandy3(u8); void TeachMonMoveInPartyMenu(u8); void DoEvolutionStoneItemEffect(u8 taskId, u16 evolutionStoneItem, TaskFunc c); +u8 GetItemEffectType(u16 item); void sub_806CA60(u8 taskId); void sub_806CD5C(u8 taskId); void DoTakeMail(u8 taskId, TaskFunc func); @@ -177,5 +171,6 @@ void PartyMenuTryGiveMonMail(u8 taskId, TaskFunc func); void sub_806D668(u8 partyID); void TaughtMove(u8 taskId); void StopTryingToTeachMove_806F588(u8 taskId); +void sub_806E720(u8, u8 *, u8 *, const struct PartyPopupMenu *); #endif // GUARD_PARTY_MENU_H diff --git a/include/pokemon_menu.h b/include/pokemon_menu.h index 06f905577..1c8e6772f 100644 --- a/include/pokemon_menu.h +++ b/include/pokemon_menu.h @@ -1,6 +1,8 @@ #ifndef GUARD_POKEMON_MENU_H #define GUARD_POKEMON_MENU_H +#include "menu.h" + #define POKEMENU_FIRST_FIELD_MOVE_ID 10 enum @@ -36,6 +38,7 @@ extern void (*gUnknown_03005CE4)(void); void sub_808B5B4(u32 taskID); void sub_8089A70(void); +void sub_8089C50(u8 arg0, u8 arg1, u8 arg2, u8 noOfOptions, const struct MenuAction2 *menuActions, const u8 *order); void sub_808A004(u8 taskID); void FieldCallback_Teleport(void); void sub_808AD58(void); diff --git a/ld_script.txt b/ld_script.txt index 7648f98c7..b122d8ab5 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -109,7 +109,6 @@ SECTIONS { src/reset_rtc_screen.o(.text); asm/party_menu.o(.text); src/party_menu.o(.text); - asm/party_menu.o(.text_8070968); src/start_menu.o(.text); src/menu.o(.text); src/tileset_anim.o(.text); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index 49e0b8432..ca883daec 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -33,15 +33,11 @@ extern void PartyMenuTryPrintMonsHP(void); extern void nullsub_13(void); extern void PartyMenuDrawHPBars(void); extern u8 sub_806B58C(u8); -extern u8 GetItemEffectType(); -extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); extern void sub_806D5A4(void); extern void sub_802E414(void); extern void sub_80A6DCC(void); extern void sub_806AF4C(); extern void sub_806AEDC(void); -extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); -extern void sub_806E7D0(u8, const struct PartyPopupMenu *); extern u8 *sub_8040D08(); extern void sub_8040B8C(void); extern void sub_806E6F0(); @@ -79,7 +75,7 @@ static void Task_BattlePartyMenuSummary(u8 taskId); static void Task_BattlePartyMenuShift(u8 taskId); static void Task_BattlePartyMenuCancel(u8 taskId); -static const struct PartyMenuItem sBattlePartyMenuActions[] = +static const struct MenuAction2 sBattlePartyMenuActions[] = { {OtherText_Summary, Task_BattlePartyMenuSummary}, {gOtherText_CancelNoTerminator, Task_BattlePartyMenuCancel}, @@ -475,7 +471,8 @@ static void sub_8095050(u8 a, u8 b) gTasks[EWRAM_1B000.unk260].data[4] = 2; gTasks[EWRAM_1B000.unk260].data[5] = 2; } - sub_806E750(gTasks[a].data[4], sBattlePartyPopupMenus, sBattlePartyMenuActions, 0); + + ShowPartyPopupMenu(gTasks[a].data[4], sBattlePartyPopupMenus, sBattlePartyMenuActions, 0); } void SetUpBattlePokemonMenu(u8 a) @@ -660,7 +657,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) u8 i; u8 r4; - sub_806E7D0(gTasks[taskId].data[4], sBattlePartyPopupMenus); + ClosePartyPopupMenu(gTasks[taskId].data[4], sBattlePartyPopupMenus); partySelection = sub_806CA38(taskId); if (IsLinkDoubleBattle() == TRUE && (partySelection == 1 || partySelection == 4 || partySelection == 5)) { @@ -742,7 +739,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) static void Task_BattlePartyMenuCancel(u8 taskId) { HandleDestroyMenuCursors(); - sub_806E7D0(gTasks[taskId].data[4], sBattlePartyPopupMenus); + ClosePartyPopupMenu(gTasks[taskId].data[4], sBattlePartyPopupMenus); gTasks[taskId].data[4] = gTasks[taskId].data[5]; sub_806D538(0, 0); SwitchTaskToFollowupFunc(taskId); diff --git a/src/choose_party.c b/src/choose_party.c index 9cdf63fc8..38533ba02 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -53,7 +53,6 @@ extern void sub_806BC3C(u8, u8); extern u8 sub_806B58C(u8); extern u16 sub_806BE38(); extern u8 sub_806CA38(); -extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); extern u8 sub_806B124(); extern void sub_806C994(); extern void sub_806C658(); @@ -82,7 +81,6 @@ extern void PartyMenuDoDrawHPBar(u8, u8, u16, u16); extern void PartyMenuDoPutNicknameTilemap(u16, u8, u8, u8, const u8 *); extern void box_print(u8, int, const u8 *); extern void sub_806BCE8(void); -extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); static void ClearPartySelection(void); static bool8 IsMonAllowedInBattleTower(struct Pokemon *); @@ -273,7 +271,7 @@ static void BattleTowerEntryMenuCallback_Enter(u8); static void BattleTowerEntryMenuCallback_NoEntry(u8); static void BattleTowerEntryMenuCallback_Exit(u8); -static const struct PartyMenuItem sBattleTowerEntryMenuItems[] = +static const struct MenuAction2 sBattleTowerEntryMenuItems[] = { {OtherText_Summary, BattleTowerEntryMenuCallback_Summary}, {OtherText_Enter2, BattleTowerEntryMenuCallback_Enter}, @@ -313,18 +311,18 @@ static void sub_81221F8(u8 taskId) if (IsPartyMemberAlreadySelected(gLastFieldPokeMenuOpened + 1) == TRUE) { gTasks[taskId].data[4] = 1; - sub_806E750(1, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + ShowPartyPopupMenu(1, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } else { gTasks[taskId].data[4] = 0; - sub_806E750(0, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + ShowPartyPopupMenu(0, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } } else { gTasks[taskId].data[4] = 2; - sub_806E750(2, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + ShowPartyPopupMenu(2, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); } } @@ -795,7 +793,7 @@ static void DaycareStorageMenuCallback_Store(u8); static void DaycareStorageMenuCallback_Summary(u8); static void DaycareStorageMenuCallback_Exit(u8); -static const struct PartyMenuItem sDaycareStorageMenuItems[] = +static const struct MenuAction2 sDaycareStorageMenuItems[] = { {OtherText_Store, DaycareStorageMenuCallback_Store}, {OtherText_Summary, DaycareStorageMenuCallback_Summary}, @@ -816,12 +814,12 @@ static void sub_8122D94(u8 taskId) if (!GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_IS_EGG)) { gTasks[taskId].data[4] = 0; - sub_806E750(0, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + ShowPartyPopupMenu(0, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); } else { gTasks[taskId].data[4] = 1; - sub_806E750(1, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + ShowPartyPopupMenu(1, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); } } diff --git a/src/party_menu.c b/src/party_menu.c index e1eb9cdae..7e515462a 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -9,6 +9,7 @@ #include "item.h" #include "item_use.h" #include "item_menu.h" +#include "items.h" #include "mail_data.h" #include "main.h" #include "menu.h" @@ -30,7 +31,6 @@ #include "palette.h" #include "event_data.h" #include "main.h" -#include "item.h" #include "battle_interface.h" #include "species.h" #include "party_menu.h" @@ -111,6 +111,34 @@ void sub_806AEDC(void) #define WINDOW_RIGHT (29) #endif +void ShowPartyPopupMenu(u8 menuIndex, const struct PartyPopupMenu *menu, const struct MenuAction2 *menuActions, u8 cursorPos) +{ + u8 left; + u8 top; + + sub_806E720(menuIndex, &left, &top, menu); + sub_8089C50(left, top, menu[menuIndex].width, menu[menuIndex].numChoices, menuActions, menu[menuIndex].items); + + InitMenu(0, left + 1, top + 1, menu[menuIndex].numChoices, cursorPos, menu[menuIndex].width - 1); +} + +void ClosePartyPopupMenu(u8 index, const struct PartyPopupMenu *menu) +{ + u8 left; + u8 top; + + sub_806E720(index, &left, &top, menu); + + MenuZeroFillWindowRect(left, top, left + menu[index].width, menu[index].numChoices * 2 + top + 1); + HandleDestroyMenuCursors(); +} + +TaskFunc PartyMenuGetPopupMenuFunc(u8 menuIndex, const struct PartyPopupMenu *menus, const struct MenuAction2 *menuActions, u8 itemIndex) +{ + u8 action = menus[menuIndex].items[itemIndex]; + return menuActions[action].func; +} + u8 sub_806E834(const u8 *message, u8 arg1) { u8 taskId; @@ -881,10 +909,10 @@ bool8 IsHPRecoveryItem(u16 item) { const u8 *itemEffect; - if (item == 0xAF) + if (item == ITEM_ENIGMA_BERRY) itemEffect = gSaveBlock1.enigmaBerry.itemEffect; else - itemEffect = gItemEffectTable[item - 13]; + itemEffect = gItemEffectTable[item - ITEM_POTION]; if (itemEffect[4] & 4) return TRUE; @@ -1199,10 +1227,10 @@ void DoPPRecoveryItemEffect(u8 taskId, u16 b, TaskFunc c) const u8 *itemEffect; u8 taskId2; - if (b == 0xAF) + if (b == ITEM_ENIGMA_BERRY) itemEffect = gSaveBlock1.enigmaBerry.itemEffect; else - itemEffect = gItemEffectTable[b - 13]; + itemEffect = gItemEffectTable[b - ITEM_POTION]; gTasks[taskId].func = TaskDummy; taskId2 = CreateTask(TaskDummy, 5); sub_806E8D0(taskId, b, c); @@ -1691,3 +1719,322 @@ void DoEvolutionStoneItemEffect(u8 taskId, u16 evolutionStoneItem, TaskFunc c) RemoveBagItem(evolutionStoneItem, 1); } } + +// u8 GetItemEffectType(u16 item) +// { +// const u8 *itemEffect; +// register u8 itemEffect0 asm("r1"); +// u8 mask; + +// // Read the item's effect properties. +// if (item == ITEM_ENIGMA_BERRY) +// { +// itemEffect = gSaveBlock1.enigmaBerry.itemEffect; +// } +// else +// { +// itemEffect = gItemEffectTable[item - ITEM_POTION]; +// } + +// itemEffect0 = itemEffect[0]; +// mask = 0x3F; + +// if ((itemEffect0 & mask) || itemEffect[1] || itemEffect[2] || (itemEffect[3] & 0x80)) +// { +// return 0; +// } +// else if (itemEffect0 & 0x40) +// { +// return 10; +// } +// else if (itemEffect[3] & 0x40) +// { +// return 1; +// } +// else if ((itemEffect[3] & mask) || (itemEffect0 >> 7)) +// { +// if ((itemEffect[3] & mask) == 0x20) +// { +// return 4; +// } +// else if ((itemEffect[3] & mask) == 0x10) +// { +// return 3; +// } +// else if ((itemEffect[3] & mask) == 0x8) +// { +// return 5; +// } +// else if ((itemEffect[3] & mask) == 0x4) +// { +// return 6; +// } +// else if ((itemEffect[3] & mask) == 0x2) +// { +// return 7; +// } +// else if ((itemEffect[3] & mask) == 0x1) +// { +// return 8; +// } +// else if ((itemEffect0 >> 7) != 0 && (itemEffect[3] & mask) == 0) +// { +// return 9; +// } +// else +// { +// return 11; +// } +// } +// else if (itemEffect[4] & 0x44) +// { +// return 2; +// } +// else if (itemEffect[4] & 0x2) +// { +// return 12; +// } +// else if (itemEffect[4] & 0x1) +// { +// return 13; +// } +// else if (itemEffect[5] & 0x8) +// { +// return 14; +// } +// else if (itemEffect[5] & 0x4) +// { +// return 15; +// } +// else if (itemEffect[5] & 0x2) +// { +// return 16; +// } +// else if (itemEffect[5] & 0x1) +// { +// return 17; +// } +// else if (itemEffect[4] & 0x80) +// { +// return 18; +// } +// else if (itemEffect[4] & 0x20) +// { +// return 19; +// } +// else if (itemEffect[5] & 0x10) +// { +// return 20; +// } +// else if (itemEffect[4] & 0x18) +// { +// return 21; +// } +// else +// { +// return 22; +// } +// } +__attribute__((naked)) +u8 GetItemEffectType(u16 item) +{ + asm(".syntax unified\n\ + push {r4,r5,lr}\n\ + lsls r0, 16\n\ + lsrs r0, 16\n\ + cmp r0, 0xAF\n\ + bne _08070E5C\n\ + ldr r4, _08070E58 @ =gSaveBlock1 + 0x3676\n\ + b _08070E66\n\ + .align 2, 0\n\ +_08070E58: .4byte gSaveBlock1 + 0x3676\n\ +_08070E5C:\n\ + ldr r1, _08070E8C @ =gItemEffectTable\n\ + subs r0, 0xD\n\ + lsls r0, 2\n\ + adds r0, r1\n\ + ldr r4, [r0]\n\ +_08070E66:\n\ + ldrb r1, [r4]\n\ + movs r5, 0x3F\n\ + adds r0, r5, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08070E88\n\ + ldrb r0, [r4, 0x1]\n\ + cmp r0, 0\n\ + bne _08070E88\n\ + ldrb r0, [r4, 0x2]\n\ + cmp r0, 0\n\ + bne _08070E88\n\ + ldrb r3, [r4, 0x3]\n\ + movs r0, 0x80\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _08070E90\n\ +_08070E88:\n\ + movs r0, 0\n\ + b _08070F8A\n\ + .align 2, 0\n\ +_08070E8C: .4byte gItemEffectTable\n\ +_08070E90:\n\ + movs r2, 0x40\n\ + adds r0, r2, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070E9E\n\ + movs r0, 0xA\n\ + b _08070F8A\n\ +_08070E9E:\n\ + adds r0, r2, 0\n\ + ands r0, r3\n\ + cmp r0, 0\n\ + beq _08070EAA\n\ + movs r0, 0x1\n\ + b _08070F8A\n\ +_08070EAA:\n\ + adds r2, r5, 0\n\ + ands r2, r3\n\ + cmp r2, 0\n\ + bne _08070EB8\n\ + lsrs r0, r1, 7\n\ + cmp r0, 0\n\ + beq _08070EFA\n\ +_08070EB8:\n\ + cmp r2, 0x20\n\ + bne _08070EC0\n\ + movs r0, 0x4\n\ + b _08070F8A\n\ +_08070EC0:\n\ + cmp r2, 0x10\n\ + bne _08070EC8\n\ + movs r0, 0x3\n\ + b _08070F8A\n\ +_08070EC8:\n\ + cmp r2, 0x8\n\ + bne _08070ED0\n\ + movs r0, 0x5\n\ + b _08070F8A\n\ +_08070ED0:\n\ + cmp r2, 0x4\n\ + bne _08070ED8\n\ + movs r0, 0x6\n\ + b _08070F8A\n\ +_08070ED8:\n\ + cmp r2, 0x2\n\ + bne _08070EE0\n\ + movs r0, 0x7\n\ + b _08070F8A\n\ +_08070EE0:\n\ + cmp r2, 0x1\n\ + bne _08070EE8\n\ + movs r0, 0x8\n\ + b _08070F8A\n\ +_08070EE8:\n\ + lsrs r0, r1, 7\n\ + cmp r0, 0\n\ + beq _08070EF6\n\ + cmp r2, 0\n\ + bne _08070EF6\n\ + movs r0, 0x9\n\ + b _08070F8A\n\ +_08070EF6:\n\ + movs r0, 0xB\n\ + b _08070F8A\n\ +_08070EFA:\n\ + ldrb r1, [r4, 0x4]\n\ + movs r0, 0x44\n\ + ands r0, r1\n\ + adds r2, r1, 0\n\ + cmp r0, 0\n\ + beq _08070F0A\n\ + movs r0, 0x2\n\ + b _08070F8A\n\ +_08070F0A:\n\ + movs r5, 0x2\n\ + adds r0, r5, 0\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _08070F18\n\ + movs r0, 0xC\n\ + b _08070F8A\n\ +_08070F18:\n\ + movs r3, 0x1\n\ + adds r0, r3, 0\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _08070F26\n\ + movs r0, 0xD\n\ + b _08070F8A\n\ +_08070F26:\n\ + ldrb r1, [r4, 0x5]\n\ + movs r0, 0x8\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070F34\n\ + movs r0, 0xE\n\ + b _08070F8A\n\ +_08070F34:\n\ + movs r0, 0x4\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070F40\n\ + movs r0, 0xF\n\ + b _08070F8A\n\ +_08070F40:\n\ + adds r0, r5, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070F4C\n\ + movs r0, 0x10\n\ + b _08070F8A\n\ +_08070F4C:\n\ + adds r0, r3, 0\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070F58\n\ + movs r0, 0x11\n\ + b _08070F8A\n\ +_08070F58:\n\ + movs r0, 0x80\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _08070F64\n\ + movs r0, 0x12\n\ + b _08070F8A\n\ +_08070F64:\n\ + movs r0, 0x20\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + beq _08070F70\n\ + movs r0, 0x13\n\ + b _08070F8A\n\ +_08070F70:\n\ + movs r0, 0x10\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + beq _08070F7C\n\ + movs r0, 0x14\n\ + b _08070F8A\n\ +_08070F7C:\n\ + movs r0, 0x18\n\ + ands r0, r2\n\ + cmp r0, 0\n\ + bne _08070F88\n\ + movs r0, 0x16\n\ + b _08070F8A\n\ +_08070F88:\n\ + movs r0, 0x15\n\ +_08070F8A:\n\ + pop {r4,r5}\n\ + pop {r1}\n\ + bx r1\n\ + .syntax divided\n"); +} + +void unref_sub_8070F90() +{ + FlagSet(SYS_POKEDEX_GET); + FlagSet(SYS_POKEMON_GET); + FlagSet(SYS_POKENAV_GET); +} diff --git a/src/pokemon_menu.c b/src/pokemon_menu.c index dd6b576a3..dc5d018d4 100644 --- a/src/pokemon_menu.c +++ b/src/pokemon_menu.c @@ -389,18 +389,18 @@ static void sub_808A060(u8 taskID) if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F578, (void *)sPokemonMenuActions, sPokeMenuCursorPos)(taskID); + PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F578, sPokemonMenuActions, sPokeMenuCursorPos)(taskID); } else if (gMain.newKeys & B_BUTTON) { - sub_806E7D0(0, &sUnknown_0839F578); + ClosePartyPopupMenu(0, &sUnknown_0839F578); PokemonMenu_CancelSubmenu(taskID); } } static void sub_808A100(u8 taskID) { - sub_806E750(0, &sUnknown_0839F578, (void*)(sPokemonMenuActions), 0); + ShowPartyPopupMenu(0, &sUnknown_0839F578, (void*)(sPokemonMenuActions), 0); sub_806D538(0xD, 2); gTasks[taskID].func = sub_808A060; } @@ -619,7 +619,7 @@ static void PokemonMenu_Mail(u8 taskID) HandleDestroyMenuCursors(); sPokeMenuCursorPos = 0; MenuZeroFillWindowRect(19, 0, 29, 19); - sub_806E750(0, &sUnknown_0839F584, (void*) sPokemonMenuActions, 0); + ShowPartyPopupMenu(0, &sUnknown_0839F584, (void*) sPokemonMenuActions, 0); gTasks[taskID].func = sub_808A73C; } @@ -629,26 +629,26 @@ static void sub_808A73C(u8 taskID) { PlaySE(SE_SELECT); if (sPokeMenuCursorPos == 0) - sPokeMenuCursorPos = MoveMenuCursor(sUnknown_0839F584.unk0 - 1); + sPokeMenuCursorPos = MoveMenuCursor(sUnknown_0839F584.numChoices - 1); else sPokeMenuCursorPos = MoveMenuCursor(-1); } if (gMain.newAndRepeatedKeys == DPAD_DOWN) { PlaySE(SE_SELECT); - if (sPokeMenuCursorPos == sUnknown_0839F584.unk0 - 1) - sPokeMenuCursorPos = MoveMenuCursor(1 - sUnknown_0839F584.unk0); + if (sPokeMenuCursorPos == sUnknown_0839F584.numChoices - 1) + sPokeMenuCursorPos = MoveMenuCursor(1 - sUnknown_0839F584.numChoices); else sPokeMenuCursorPos = MoveMenuCursor(1); } if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F584, (void*) sPokemonMenuActions, sPokeMenuCursorPos)(taskID); + PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F584, sPokemonMenuActions, sPokeMenuCursorPos)(taskID); } else if (gMain.newKeys & B_BUTTON) { - sub_806E7D0(0, &sUnknown_0839F584); + ClosePartyPopupMenu(0, &sUnknown_0839F584); PokemonMenu_Cancel(taskID); } } |