Merge pull request #308 from DizzyEggg/pyramid_bag

Decompile pyramid bag
This commit is contained in:
Diegoisawesome 2018-08-30 14:40:22 -05:00 committed by GitHub
commit 1895383352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1596 additions and 3889 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11626,7 +11626,7 @@ c2_815ABFC: @ 81B6254
bl GoToBagMenu bl GoToBagMenu
b _081B6276 b _081B6276
_081B626C: _081B626C:
ldr r0, =gUnknown_0203CF30 ldr r0, =gPyramidBagCursorData
ldr r1, [r0] ldr r1, [r0]
movs r0, 0x4 movs r0, 0x4
bl sub_81C4F98 bl sub_81C4F98

View File

@ -4,6 +4,239 @@
.syntax unified .syntax unified
.text .text
thumb_func_start sub_81C7078
sub_81C7078: @ 81C7078
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
bl is_c1_link_related_active
cmp r0, 0
bne _081C7090
ldr r0, =sub_81C7170
b _081C7092
.pool
_081C7090:
ldr r0, =sub_81C71E4
_081C7092:
lsls r1, r4, 24
lsrs r1, 24
bl CreateTask
lsls r0, 24
lsrs r4, r0, 24
adds r0, r4, 0
movs r1, 0x1
adds r2, r5, 0
bl SetWordTaskArg
ldr r1, =gTasks
lsls r0, r4, 2
adds r0, r4
lsls r0, 3
adds r0, r1
ldr r2, =gUnknown_0203CF3C
ldrb r1, [r2]
strh r1, [r0, 0xE]
ldrb r0, [r2]
adds r1, r0, 0x1
strb r1, [r2]
lsls r0, 24
lsrs r0, 8
orrs r0, r4
pop {r4,r5}
pop {r1}
bx r1
.pool
thumb_func_end sub_81C7078
thumb_func_start sub_81C70D8
sub_81C70D8: @ 81C70D8
push {lr}
ldr r1, =0x0000ffff
ands r1, r0
lsrs r3, r0, 16
ldr r2, =gTasks
lsls r0, r1, 2
adds r0, r1
lsls r0, 3
adds r1, r0, r2
ldrb r0, [r1, 0x4]
cmp r0, 0
beq _081C711C
ldr r2, [r1]
ldr r0, =sub_81C7170
cmp r2, r0
beq _081C70FE
ldr r0, =sub_81C71E4
cmp r2, r0
bne _081C711C
_081C70FE:
movs r2, 0xE
ldrsh r0, [r1, r2]
cmp r0, r3
bne _081C711C
movs r0, 0x1
b _081C711E
.pool
_081C711C:
movs r0, 0
_081C711E:
pop {r1}
bx r1
thumb_func_end sub_81C70D8
thumb_func_start sub_81C7124
sub_81C7124: @ 81C7124
push {r4-r6,lr}
adds r6, r0, 0
movs r5, 0
ldr r4, =gTasks
_081C712C:
ldrb r0, [r4, 0x4]
cmp r0, 0
beq _081C7160
ldr r1, [r4]
ldr r0, =sub_81C7170
cmp r1, r0
beq _081C7140
ldr r0, =sub_81C71E4
cmp r1, r0
bne _081C7160
_081C7140:
lsls r0, r5, 24
lsrs r0, 24
movs r1, 0x1
bl GetWordTaskArg
cmp r0, r6
bne _081C7160
movs r0, 0x1
b _081C716A
.pool
_081C7160:
adds r4, 0x28
adds r5, 0x1
cmp r5, 0xF
ble _081C712C
movs r0, 0
_081C716A:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_81C7124
thumb_func_start sub_81C7170
sub_81C7170: @ 81C7170
push {r4-r7,lr}
lsls r0, 24
lsrs r5, r0, 24
adds r0, r5, 0
movs r1, 0x1
bl GetWordTaskArg
adds r6, r0, 0
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
movs r7, 0
_081C718C:
movs r1, 0
ldrsh r0, [r4, r1]
bl _call_via_r6
cmp r0, 0x4
bhi _081C71D6
lsls r0, 2
ldr r1, =_081C71AC
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081C71AC:
.4byte _081C71C6
.4byte _081C71C0
.4byte _081C71DE
.4byte _081C71DA
.4byte _081C71CE
_081C71C0:
ldrh r0, [r4]
adds r0, 0x1
b _081C71D8
_081C71C6:
ldrh r0, [r4]
adds r0, 0x1
strh r0, [r4]
b _081C71DE
_081C71CE:
adds r0, r5, 0
bl DestroyTask
b _081C71DE
_081C71D6:
subs r0, 0x5
_081C71D8:
strh r0, [r4]
_081C71DA:
cmp r7, 0
beq _081C718C
_081C71DE:
pop {r4-r7}
pop {r0}
bx r0
thumb_func_end sub_81C7170
thumb_func_start sub_81C71E4
sub_81C71E4: @ 81C71E4
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
bl sub_8087598
cmp r0, 0
bne _081C724A
adds r0, r5, 0
movs r1, 0x1
bl GetWordTaskArg
adds r2, r0, 0
lsls r0, r5, 2
adds r0, r5
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
movs r1, 0
ldrsh r0, [r4, r1]
bl _call_via_r2
cmp r0, 0x4
bhi _081C7246
lsls r0, 2
ldr r1, =_081C7224
adds r0, r1
ldr r0, [r0]
mov pc, r0
.pool
.align 2, 0
_081C7224:
.4byte _081C7238
.4byte _081C7238
.4byte _081C724A
.4byte _081C724A
.4byte _081C723E
_081C7238:
ldrh r0, [r4]
adds r0, 0x1
b _081C7248
_081C723E:
adds r0, r5, 0
bl DestroyTask
b _081C724A
_081C7246:
subs r0, 0x5
_081C7248:
strh r0, [r4]
_081C724A:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_81C71E4
thumb_func_start CB2_PokeNav thumb_func_start CB2_PokeNav
CB2_PokeNav: @ 81C7250 CB2_PokeNav: @ 81C7250

View File

@ -3,60 +3,6 @@
.section .rodata .section .rodata
.align 2
gUnknown_0861F2B4:: @ 861F2B4
.4byte 0x000011f0, 0x000001e1, 0x000021de
.align 2
gUnknown_0861F2C0:: @ 861F2C0
.4byte 0x00000000, sub_81C5460, sub_81C5518, 0x00000000, 0x00080000, 0x07003021
.align 2
gUnknown_0861F2D8:: @ 861F2D8
.4byte gMenuText_Use, sub_81C61E0
.4byte gMenuText_Toss, sub_81C62C4
.4byte gMenuText_Give, sub_81C6648
.4byte gText_Cancel2, sub_81C6258
.4byte gMenuText_Use, sub_81C679C
.4byte gText_EmptyString2, NULL
gUnknown_0861F308:: @ 861F308
.byte 0x00, 0x02, 0x01, 0x03
gUnknown_0861F30C:: @ 861F30C
.byte 0x01, 0x03
gUnknown_0861F30E:: @ 861F30E
.byte 0x04, 0x03
gUnknown_0861F310:: @ 861F310
.byte 0x03, 0x00, 0x00, 0x00
gUnknown_0861F314:: @ 861F314
.4byte sub_81C654C
.4byte sub_81C63D0
gUnknown_0861F31C:: @ 861F31C
.byte 0x00, 0x02, 0x03, 0x00, 0x03, 0x01, 0x01, 0x02, 0x03, 0x00, 0x00, 0x00
.align 2
gUnknown_0861F328:: @ 861F328
window_template 0x00, 0x0e, 0x02, 0x0f, 0x10, 0x0f, 0x001e
window_template 0x00, 0x00, 0x0d, 0x0e, 0x06, 0x0f, 0x010e
window_template 0x01, 0x02, 0x0f, 0x1b, 0x04, 0x0f, 0x0162
window_template 0x01, 0x18, 0x11, 0x05, 0x02, 0x0f, 0x01ce
null_window_template
.align 2
gUnknown_0861F350:: @ 861F350
window_template 0x01, 0x16, 0x11, 0x07, 0x02, 0x0f, 0x01d8
window_template 0x01, 0x16, 0x0f, 0x07, 0x04, 0x0f, 0x01d8
window_template 0x01, 0x0f, 0x0f, 0x0e, 0x04, 0x0f, 0x01d8
window_template 0x01, 0x0f, 0x0d, 0x0e, 0x06, 0x0f, 0x01d8
.align 2
gUnknown_0861F370:: @ 861F370
window_template 0x01, 0x18, 0x0f, 0x05, 0x04, 0x0f, 0x01d8
.align 2 .align 2
gOamData_861F378:: @ 861F378 gOamData_861F378:: @ 861F378

View File

@ -0,0 +1,49 @@
#ifndef GUARD_BATTLE_PYRAMID_BAG_H
#define GUARD_BATTLE_PYRAMID_BAG_H
#include "list_menu.h"
struct PyramidBagResources
{
void (*callback2)(void);
u8 tilemapBuffer[0x800];
u8 itemsSpriteIds[PYRAMID_BAG_ITEMS_COUNT + 1];
u8 windowIds[5];
u8 unk814;
u8 unk815;
u8 scrollArrowSpriteId;
const u8 *menuActionIds;
u8 filler81C[0x820 - 0x81C];
u8 menuActionsCount;
u8 listMenuCount;
u8 listMenuMaxShown;
struct ListMenuItem bagListItems[PYRAMID_BAG_ITEMS_COUNT + 1];
u8 itemStrings[PYRAMID_BAG_ITEMS_COUNT + 1][ITEM_NAME_LENGTH + 10];
s16 state;
u8 filler986[0x98C - 0x986];
};
struct PyramidBagCursorData
{
void (*callback)(void);
u8 unk4;
u16 cursorPosition;
u16 scrollPosition;
};
extern struct PyramidBagResources *gPyramidBagResources;
extern struct PyramidBagCursorData gPyramidBagCursorData;
void CB2_PyramidBagMenuFromStartMenu(void);
void sub_81C4F84(void);
void sub_81C5924(void);
void sub_81C59BC(void);
void sub_81C4EFC(void);
void sub_81C4F98(u8 a0, void (*callback)(void));
void sub_81C6714(u8 taskId);
void sub_81C6A94(void);
void sub_81C4F24(void);
void sub_81C5B14(u8 taskId);
void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId));
#endif // GUARD_BATTLE_PYRAMID_BAG_H

View File

@ -27,6 +27,13 @@
#define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0]))
#define SWAP(a, b, temp) \
{ \
temp = a; \
a = b; \
b = temp; \
}
// useful math macros // useful math macros
// Converts a number to Q8.8 fixed-point format // Converts a number to Q8.8 fixed-point format

View File

@ -1,8 +1,6 @@
#ifndef GUARD_ITEM_USE_H #ifndef GUARD_ITEM_USE_H
#define GUARD_ITEM_USE_H #define GUARD_ITEM_USE_H
extern u16 gSpecialVar_ItemId;
void ItemUseOutOfBattle_Mail(u8); void ItemUseOutOfBattle_Mail(u8);
void ItemUseOutOfBattle_Bike(u8); void ItemUseOutOfBattle_Bike(u8);
void ItemUseOnFieldCB_Bike(u8); void ItemUseOnFieldCB_Bike(u8);

View File

@ -11,7 +11,8 @@
#define LIST_MULTIPLE_SCROLL_DPAD 1 #define LIST_MULTIPLE_SCROLL_DPAD 1
#define LIST_MULTIPLE_SCROLL_L_R 2 #define LIST_MULTIPLE_SCROLL_L_R 2
enum { enum
{
SCROLL_ARROW_LEFT, SCROLL_ARROW_LEFT,
SCROLL_ARROW_RIGHT, SCROLL_ARROW_RIGHT,
SCROLL_ARROW_UP, SCROLL_ARROW_UP,

View File

@ -66,9 +66,9 @@ u16 sub_8198AA4(u8, u8, u8, u8, u8, u8, u16);
void *malloc_and_decompress(const void *src, int *sizeOut); void *malloc_and_decompress(const void *src, int *sizeOut);
u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode); u16 copy_decompressed_tile_data_to_vram(u8 bgId, const void *src, u16 size, u16 offset, u8 mode);
void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress); void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress);
void AddItemMenuActionTextPrinters (u8, u8, u8, u8, u8, u8, u8, const struct MenuAction*, const u8*); void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *strs, const u8 *a8);
void sub_8198DBC(u8, u8, u8, u8, u8, u8, u8, const struct MenuAction*, const u8*); void sub_8198DBC(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *strs, const u8 *a8);
u8 sub_8199944(u8, u8, u8, u8, u8); u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos);
u8 sub_8199134(s8, s8); u8 sub_8199134(s8, s8);
u8 GetStartMenuWindowId(void); u8 GetStartMenuWindowId(void);
void sub_819A2BC(u8, u8); void sub_819A2BC(u8, u8);

View File

@ -32,7 +32,7 @@ struct SaveSectionOffsets
}; };
// Emerald changes this definition to be the sectors per slot. // Emerald changes this definition to be the sectors per slot.
#define NUM_SECTORS_PER_SLOT 16 // move to save.h #define NUM_SECTORS_PER_SLOT 16
#define UNKNOWN_CHECK_VALUE 0x8012025 #define UNKNOWN_CHECK_VALUE 0x8012025

View File

@ -776,6 +776,23 @@ extern const u8 gText_TeachWhichMoveToPkmn[];
extern const u8 gText_GiveUpTeachingNewMove[]; extern const u8 gText_GiveUpTeachingNewMove[];
extern const u8 gText_TeachX[]; extern const u8 gText_TeachX[];
extern const u8 gText_DadsAdvice[];
extern const u8 gText_CantDismountBike[];
extern const u8 gText_ItemFinderNothing[];
extern const u8 gText_ItemFinderNearby[];
extern const u8 gText_ItemFinderOnTop[];
extern const u8 gText_CoinCase[];
extern const u8 gText_PowderQty[];
extern const u8 gText_BootedUpHM[];
extern const u8 gText_BootedUpTM[];
extern const u8 gText_TMHMContainedVar1[];
extern const u8 gText_PlayerUsedVar2[];
extern const u8 gText_RepelEffectsLingered[];
extern const u8 gText_UsedVar2WildLured[];
extern const u8 gText_UsedVar2WildRepelled[];
extern const u8 gText_BoxFull[];
extern const u8 gText_WontHaveEffect[];
extern const u8 gText_LevelSymbol[]; extern const u8 gText_LevelSymbol[];
extern const u8 gText_PkmnInfo[]; extern const u8 gText_PkmnInfo[];
extern const u8 gText_PkmnSkills[]; extern const u8 gText_PkmnSkills[];
@ -824,4 +841,6 @@ extern const u8 gText_RibbonsVar1[];
extern const u8 gText_OneDash[]; extern const u8 gText_OneDash[];
extern const u8 gText_TwoDashes[]; extern const u8 gText_TwoDashes[];
extern const u8 *const gReturnToXStringsTable2[];
#endif //GUARD_STRINGS_H #endif //GUARD_STRINGS_H

View File

@ -267,7 +267,6 @@ SECTIONS {
src/pokemon_summary_screen.o(.text); src/pokemon_summary_screen.o(.text);
src/unk_pokedex_area_screen_helper.o(.text); src/unk_pokedex_area_screen_helper.o(.text);
src/battle_pyramid_bag.o(.text); src/battle_pyramid_bag.o(.text);
asm/battle_pyramid_bag.o(.text);
asm/pokenav.o(.text); asm/pokenav.o(.text);
src/match_call.o(.text); src/match_call.o(.text);
asm/pokenav.o(.text.after.match.call); asm/pokenav.o(.text.after.match.call);
@ -545,6 +544,7 @@ SECTIONS {
src/berry_fix_program.o(.rodata); src/berry_fix_program.o(.rodata);
src/pokemon_summary_screen.o(.rodata); src/pokemon_summary_screen.o(.rodata);
src/unk_pokedex_area_screen_helper.o(.rodata); src/unk_pokedex_area_screen_helper.o(.rodata);
src/battle_pyramid_bag.o(.rodata);
data/battle_pyramid_bag.o(.rodata); data/battle_pyramid_bag.o(.rodata);
data/pokenav.o(.rodata); data/pokenav.o(.rodata);
src/match_call.o(.rodata); src/match_call.o(.rodata);

View File

@ -28,7 +28,7 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
#include "battle_setup.h" #include "battle_setup.h"
#include "item_use.h" #include "item_menu.h"
#include "recorded_battle.h" #include "recorded_battle.h"
#include "party_menu.h" #include "party_menu.h"
#include "battle_dome.h" #include "battle_dome.h"
@ -40,7 +40,6 @@ extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;
extern struct UnusedControllerStruct gUnknown_02022D0C; extern struct UnusedControllerStruct gUnknown_02022D0C;
extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_BGM;
extern struct SpriteTemplate gMultiuseSpriteTemplate;
extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[];
extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[]; extern const struct CompressedSpritePalette gTrainerBackPicPaletteTable[];
@ -52,7 +51,6 @@ extern void sub_81851A8(u8 *);
// this file's functions // this file's functions
static void PlayerHandleGetMonData(void); static void PlayerHandleGetMonData(void);
void PlayerHandleGetRawMonData(void);
static void PlayerHandleSetMonData(void); static void PlayerHandleSetMonData(void);
static void PlayerHandleSetRawMonData(void); static void PlayerHandleSetRawMonData(void);
static void PlayerHandleLoadMonSprite(void); static void PlayerHandleLoadMonSprite(void);

View File

@ -21,7 +21,7 @@
#include "pokeball.h" #include "pokeball.h"
#include "data2.h" #include "data2.h"
#include "pokeblock.h" #include "pokeblock.h"
#include "item_use.h" #include "item_menu.h"
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;

View File

@ -29,7 +29,7 @@
#include "data2.h" #include "data2.h"
#include "party_menu.h" #include "party_menu.h"
#include "battle_setup.h" #include "battle_setup.h"
#include "item_use.h" #include "item_menu.h"
extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_X;
extern u16 gBattle_BG0_Y; extern u16 gBattle_BG0_Y;

View File

@ -2810,23 +2810,16 @@ static void CalcDomeMonStats(u16 species, s32 level, s32 ivs, u8 evBits, u8 natu
CALC_STAT(baseSpDefense, STAT_SPDEF); CALC_STAT(baseSpDefense, STAT_SPDEF);
} }
#define SWAP_16(x, y) \
{ \
temp = x; \
x = y; \
y = temp; \
}
static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray) static void SwapDomeTrainers(s32 id1, s32 id2, u16 *statsArray)
{ {
s32 i; s32 i;
u16 temp; u16 temp;
SWAP_16(statsArray[id1], statsArray[id2]); SWAP(statsArray[id1], statsArray[id2], temp);
SWAP_16(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId); SWAP(gSaveBlock2Ptr->frontier.domeTrainers[id1].trainerId, gSaveBlock2Ptr->frontier.domeTrainers[id2].trainerId, temp);
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
SWAP_16(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i]); SWAP(gSaveBlock2Ptr->frontier.domeMonId[id1][i], gSaveBlock2Ptr->frontier.domeMonId[id2][i], temp);
} }
static void sub_818F9B0(void) static void sub_818F9B0(void)

View File

@ -4596,13 +4596,10 @@ static void sub_803CDF8(void)
void SwapTurnOrder(u8 id1, u8 id2) void SwapTurnOrder(u8 id1, u8 id2)
{ {
u32 temp = gActionsByTurnOrder[id1]; u32 temp;
gActionsByTurnOrder[id1] = gActionsByTurnOrder[id2];
gActionsByTurnOrder[id2] = temp; SWAP(gActionsByTurnOrder[id1], gActionsByTurnOrder[id2], temp);
SWAP(gBattlerByTurnOrder[id1], gBattlerByTurnOrder[id2], temp);
temp = gBattlerByTurnOrder[id1];
gBattlerByTurnOrder[id1] = gBattlerByTurnOrder[id2];
gBattlerByTurnOrder[id2] = temp;
} }
u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves) u8 GetWhoStrikesFirst(u8 battler1, u8 battler2, bool8 ignoreChosenMoves)

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
#include "item_menu.h" #include "item_menu.h"
#include "strings.h" #include "strings.h"
#include "load_save.h" #include "load_save.h"
#include "battle_pyramid_bag.h"
extern bool8 InBattlePyramid(void); extern bool8 InBattlePyramid(void);
extern u16 gUnknown_0203CF30[]; extern u16 gUnknown_0203CF30[];
@ -752,9 +753,8 @@ u16 BagGetQuantityByPocketPosition(u8 pocketId, u16 pocketPos)
static void SwapItemSlots(struct ItemSlot *a, struct ItemSlot *b) static void SwapItemSlots(struct ItemSlot *a, struct ItemSlot *b)
{ {
struct ItemSlot temp = *a; struct ItemSlot temp;
*a = *b; SWAP(*a, *b, temp);
*b = temp;
} }
void CompactItemsInBagPocket(struct BagPocket *bagPocket) void CompactItemsInBagPocket(struct BagPocket *bagPocket)
@ -966,7 +966,7 @@ bool8 RemovePyramidBagItem(u16 itemId, u16 count)
u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode]; u16 *items = gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode];
u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode]; u8 *quantities = gSaveBlock2Ptr->frontier.pyramidBag.quantity[gSaveBlock2Ptr->frontier.lvlMode];
i = gUnknown_0203CF30[3] + gUnknown_0203CF30[4]; i = gPyramidBagCursorData.cursorPosition + gPyramidBagCursorData.scrollPosition;
if (items[i] == itemId && quantities[i] >= count) if (items[i] == itemId && quantities[i] >= count)
{ {
quantities[i] -= count; quantities[i] -= count;

View File

@ -29,44 +29,26 @@
#include "string_util.h" #include "string_util.h"
#include "task.h" #include "task.h"
#include "text.h" #include "text.h"
#include "strings.h"
#include "pokeblock.h"
#include "menu.h"
#include "item_menu.h"
#include "battle_pyramid_bag.h"
extern void(**gUnknown_0203CE54)(void);
extern void(**gUnknown_0203CF2C)(void);
extern void(*gUnknown_0203A0F4)(u8 taskId); extern void(*gUnknown_0203A0F4)(u8 taskId);
extern void(*gUnknown_085920D8[])(void); extern void(*gUnknown_085920D8[])(void);
extern void (*gUnknown_03006328)(u8, u16, TaskFunc); extern void (*gUnknown_03006328)(u8, u16, TaskFunc);
extern void unknown_ItemMenu_Confirm(u8 taskId); extern void unknown_ItemMenu_Confirm(u8 taskId);
extern void sub_81C5B14(u8 taskId); extern void sub_81C5B14(u8 taskId);
extern u8 gText_DadsAdvice[];
extern u8 gText_CantDismountBike[];
extern void sub_8197434(u8 a, u8 b);
extern void ScriptUnfreezeEventObjects(void); extern void ScriptUnfreezeEventObjects(void);
extern void ItemUseOutOfBattle_TMHM(u8 a); extern void ItemUseOutOfBattle_TMHM(u8 a);
extern void ItemUseOutOfBattle_EvolutionStone(u8 b); extern void ItemUseOutOfBattle_EvolutionStone(u8 b);
extern void bag_menu_mail_related(void);
extern void OpenPokeblockCase(u8 a, void(*b)(void));
extern void overworld_free_bg_tilemaps(void);
extern bool32 Overworld_IsBikingAllowed(void);
extern bool8 IsPlayerFacingSurfableFishableWater(void); extern bool8 IsPlayerFacingSurfableFishableWater(void);
extern bool8 sub_81221AC(void); extern bool8 sub_81221AC(void);
extern u8 gText_ItemFinderNothing[];
extern u8 gText_ItemFinderNearby[];
extern u8 gText_ItemFinderOnTop[];
extern u8 gText_CoinCase[];
extern u8 gText_PowderQty[];
extern u8 gUnknown_085920E4[]; extern u8 gUnknown_085920E4[];
extern u8 Route102_EventScript_274482[]; extern u8 Route102_EventScript_274482[];
extern u8 Route102_EventScript_2744C0[]; extern u8 Route102_EventScript_2744C0[];
extern u8 BattleFrontier_OutsideEast_EventScript_242CFC[]; extern u8 BattleFrontier_OutsideEast_EventScript_242CFC[];
extern u8 gText_BootedUpHM[];
extern u8 gText_BootedUpTM[];
extern u8 gText_TMHMContainedVar1[];
extern u8 gText_PlayerUsedVar2[];
extern u8 gText_RepelEffectsLingered[];
extern u8 gText_UsedVar2WildLured[];
extern u8 gText_UsedVar2WildRepelled[];
extern u8 gText_BoxFull[];
extern u8 gText_WontHaveEffect[];
extern int sub_80247BC(void); extern int sub_80247BC(void);
extern struct MapHeader* mapconnection_get_mapheader(struct MapConnection *connection); extern struct MapHeader* mapconnection_get_mapheader(struct MapConnection *connection);
extern void SetUpItemUseCallback(u8 taskId); extern void SetUpItemUseCallback(u8 taskId);
@ -86,7 +68,6 @@ extern void sub_81C59BC(void);
extern void sub_81AB9A8(u8); extern void sub_81AB9A8(u8);
extern void sub_81ABA88(u8); extern void sub_81ABA88(u8);
extern void sub_80B7CC8(void); extern void sub_80B7CC8(void);
extern void Overworld_ResetStateAfterDigEscRope(void);
extern u8* sub_806CF78(u16); extern u8* sub_806CF78(u16);
extern void sub_81B89F0(void); extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16); extern u8 GetItemEffectType(u16);
@ -115,8 +96,7 @@ void sub_80FE124(u8 taskId);
void sub_80FE164(u8 taskId); void sub_80FE164(u8 taskId);
void DisplayItemMessage(u8 taskId, u8 a, const u8* str, void(*callback)(u8 taskId)); void DisplayItemMessage(u8 taskId, u8 a, const u8* str, void(*callback)(u8 taskId));
void DisplayItemMessageInBattlePyramid(u8 taskId, u8* str, void(*callback)(u8 taskId)); void DisplayItemMessageOnField(u8 taskId, const u8* str, void(*callback)(u8 taskId));
void DisplayItemMessageOnField(u8 taskId, u8* str, void(*callback)(u8 taskId));
void sub_81C6714(u8 taskId); void sub_81C6714(u8 taskId);
void CleanUpAfterFailingToUseRegisteredKeyItemOnField(u8 taskId); void CleanUpAfterFailingToUseRegisteredKeyItemOnField(u8 taskId);
void StartFishing(u8 a); void StartFishing(u8 a);
@ -137,12 +117,12 @@ void SetUpItemUseCallback(u8 taskId)
type = ItemId_GetType(gSpecialVar_ItemId) - 1; type = ItemId_GetType(gSpecialVar_ItemId) - 1;
if (!InBattlePyramid()) if (!InBattlePyramid())
{ {
*gUnknown_0203CE54 = gUnknown_085920D8[type]; gUnknown_0203CE54->unk0 = gUnknown_085920D8[type];
unknown_ItemMenu_Confirm(taskId); unknown_ItemMenu_Confirm(taskId);
} }
else else
{ {
*gUnknown_0203CF2C = gUnknown_085920D8[type]; gPyramidBagResources->callback2 = gUnknown_085920D8[type];
sub_81C5B14(taskId); sub_81C5B14(taskId);
} }
} }
@ -221,7 +201,7 @@ void sub_80FD254()
void ItemUseOutOfBattle_Mail(u8 taskId) void ItemUseOutOfBattle_Mail(u8 taskId)
{ {
*gUnknown_0203CE54 = sub_80FD254; gUnknown_0203CE54->unk0 = sub_80FD254;
unknown_ItemMenu_Confirm(taskId); unknown_ItemMenu_Confirm(taskId);
} }
@ -617,7 +597,7 @@ void ItemUseOutOfBattle_PokeblockCase(u8 taskId)
} }
else if (gTasks[taskId].data[3] != TRUE) else if (gTasks[taskId].data[3] != TRUE)
{ {
*gUnknown_0203CE54 = sub_80FDBEC; gUnknown_0203CE54->unk0 = sub_80FDBEC;
unknown_ItemMenu_Confirm(taskId); unknown_ItemMenu_Confirm(taskId);
} }
else else
@ -679,7 +659,7 @@ void sub_80FDD10(u8 taskId)
{ {
gUnknown_0203A0F4 = sub_80FDD74; gUnknown_0203A0F4 = sub_80FDD74;
gFieldCallback = MapPostLoadHook_UseItem; gFieldCallback = MapPostLoadHook_UseItem;
*gUnknown_0203CE54 = CB2_ReturnToField; gUnknown_0203CE54->unk0 = CB2_ReturnToField;
unknown_ItemMenu_Confirm(taskId); unknown_ItemMenu_Confirm(taskId);
} }
else else
@ -1002,12 +982,12 @@ void sub_80FE54C(u8 taskId)
{ {
if (!InBattlePyramid()) if (!InBattlePyramid())
{ {
*gUnknown_0203CE54 = sub_81B89F0; gUnknown_0203CE54->unk0 = sub_81B89F0;
unknown_ItemMenu_Confirm(taskId); unknown_ItemMenu_Confirm(taskId);
} }
else else
{ {
*gUnknown_0203CF2C = sub_81B89F0; gPyramidBagResources->callback2 = sub_81B89F0;
sub_81C5B14(taskId); sub_81C5B14(taskId);
} }
} }

View File

@ -33,6 +33,7 @@
#include "international_string_util.h" #include "international_string_util.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "battle_pyramid_bag.h"
// Menu actions // Menu actions
enum enum
@ -73,12 +74,11 @@ EWRAM_DATA static u8 sSaveDialogTimer = 0;
EWRAM_DATA static bool8 sSavingComplete = FALSE; EWRAM_DATA static bool8 sSavingComplete = FALSE;
EWRAM_DATA static u8 sSaveInfoWindowId = 0; EWRAM_DATA static u8 sSaveInfoWindowId = 0;
// Extern variables // Extern variables.
extern u8 gDifferentSaveFile; extern u8 gDifferentSaveFile;
extern u16 gSaveFileStatus;
extern u8 gUnknown_03005DB4; extern u8 gUnknown_03005DB4;
// Extern functions in uncompiled files // Extern functions in not decompiled files.
extern void sub_80AF688(void); extern void sub_80AF688(void);
extern void var_800D_set_xB(void); extern void var_800D_set_xB(void);
extern void sub_808B864(void); extern void sub_808B864(void);
@ -89,7 +89,6 @@ extern void CB2_PokeNav(void);
extern void sub_80C4DDC(void (*)(void)); extern void sub_80C4DDC(void (*)(void));
extern void sub_80C51C4(void (*)(void)); extern void sub_80C51C4(void (*)(void));
extern void sub_80C4E74(u8, void (*)(void)); extern void sub_80C4E74(u8, void (*)(void));
extern void sub_81C4EFC(void);
extern void ScriptUnfreezeEventObjects(void); extern void ScriptUnfreezeEventObjects(void);
extern void sub_81A9EC8(void); extern void sub_81A9EC8(void);
extern void save_serialize_map(void); extern void save_serialize_map(void);
@ -781,7 +780,7 @@ static bool8 StartMenuBattlePyramidBagCallback(void)
play_some_sound(); play_some_sound();
RemoveExtraStartMenuWindows(); RemoveExtraStartMenuWindows();
overworld_free_bg_tilemaps(); overworld_free_bg_tilemaps();
SetMainCallback2(sub_81C4EFC); // Display battle pyramid bag SetMainCallback2(CB2_PyramidBagMenuFromStartMenu);
return TRUE; return TRUE;
} }