decompiled up to sub_81AC10C

This commit is contained in:
golem galvanize 2018-01-31 20:22:51 -05:00
parent e78697494c
commit 0a67b1d80c
2 changed files with 280 additions and 372 deletions

View File

@ -5,375 +5,6 @@
.text
thumb_func_start GetSwitchBagPocketDirection
GetSwitchBagPocketDirection: @ 81ABF10
push {lr}
ldr r0, =gUnknown_0203CE54
ldr r0, [r0]
ldr r1, =0x0000081b
adds r0, r1
ldrb r1, [r0]
movs r0, 0xF
ands r0, r1
cmp r0, 0
bne _081ABF6A
bl GetLRKeysState
lsls r0, 24
lsrs r2, r0, 24
ldr r0, =gMain
ldrh r1, [r0, 0x2E]
movs r0, 0x20
ands r0, r1
cmp r0, 0
bne _081ABF3C
cmp r2, 0x1
bne _081ABF54
_081ABF3C:
movs r0, 0x5
bl PlaySE
movs r0, 0x1
b _081ABF6C
.pool
_081ABF54:
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _081ABF60
cmp r2, 0x2
bne _081ABF6A
_081ABF60:
movs r0, 0x5
bl PlaySE
movs r0, 0x2
b _081ABF6C
_081ABF6A:
movs r0, 0
_081ABF6C:
pop {r1}
bx r1
thumb_func_end GetSwitchBagPocketDirection
thumb_func_start ChangeBagPocketId
@ void ChangeBagPocketId(u8 *bagPocketId, u8 deltaBagPocketId)
ChangeBagPocketId: @ 81ABF70
push {r4,lr}
adds r2, r0, 0
lsls r1, 24
lsrs r4, r1, 24
asrs r1, 24
cmp r1, 0x1
bne _081ABF88
ldrb r0, [r2]
cmp r0, 0x4
bne _081ABF88
movs r0, 0
b _081ABFA0
_081ABF88:
lsls r0, r4, 24
asrs r0, 24
movs r1, 0x1
negs r1, r1
ldrb r3, [r2]
cmp r0, r1
bne _081ABF9E
cmp r3, 0
bne _081ABF9E
movs r0, 0x4
b _081ABFA0
_081ABF9E:
adds r0, r3, r4
_081ABFA0:
strb r0, [r2]
pop {r4}
pop {r0}
bx r0
thumb_func_end ChangeBagPocketId
thumb_func_start SwitchBagPocket
@ void SwitchBagPocket(u8 taskId, u16 deltaBagPocketId, u16 a3)
SwitchBagPocket: @ 81ABFA8
push {r4-r6,lr}
sub sp, 0xC
lsls r0, 24
lsrs r6, r0, 24
lsls r1, 16
lsrs r5, r1, 16
lsls r2, 16
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r4, r0, r1
movs r0, 0
strh r0, [r4, 0x1A]
strh r0, [r4, 0x18]
strh r5, [r4, 0x16]
cmp r2, 0
bne _081AC026
movs r0, 0
bl ClearWindowTilemap
movs r0, 0x1
bl ClearWindowTilemap
ldrb r0, [r4]
ldr r3, =gUnknown_0203CE58
ldrb r2, [r3, 0x5]
lsls r2, 1
adds r1, r3, 0
adds r1, 0x12
adds r1, r2, r1
adds r3, 0x8
adds r2, r3
bl sub_81AE6C8
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
ldr r3, =gSprites
ldr r0, =gUnknown_0203CE54
ldr r2, [r0]
ldr r1, =0x0000081b
adds r0, r2, r1
ldrb r1, [r0]
lsls r1, 26
lsrs r1, 30
movs r0, 0x1
eors r0, r1
adds r2, r0
ldr r0, =0x00000806
adds r2, r0
ldrb r1, [r2]
lsls r0, r1, 4
adds r0, r1
lsls r0, 2
adds r0, r3
adds r0, 0x3E
ldrb r1, [r0]
movs r2, 0x4
orrs r1, r2
strb r1, [r0]
bl sub_81AB824
_081AC026:
ldr r4, =gUnknown_0203CE58
ldrb r1, [r4, 0x5]
add r0, sp, 0x8
strb r1, [r0]
lsls r1, r5, 24
asrs r1, 24
bl ChangeBagPocketId
lsls r0, r5, 16
asrs r1, r0, 16
adds r5, r0, 0
cmp r1, 0x1
bne _081AC07C
ldr r2, =gPocketNamesStringsTable
ldrb r0, [r4, 0x5]
lsls r0, 2
adds r0, r2
ldr r0, [r0]
add r1, sp, 0x8
ldrb r1, [r1]
lsls r1, 2
adds r1, r2
ldr r1, [r1]
bl bag_menu_print_pocket_names
movs r0, 0
bl bag_menu_copy_pocket_name_to_window
b _081AC09A
.pool
_081AC07C:
ldr r2, =gPocketNamesStringsTable
add r0, sp, 0x8
ldrb r0, [r0]
lsls r0, 2
adds r0, r2
ldr r0, [r0]
ldrb r1, [r4, 0x5]
lsls r1, 2
adds r1, r2
ldr r1, [r1]
bl bag_menu_print_pocket_names
movs r0, 0x8
bl bag_menu_copy_pocket_name_to_window
_081AC09A:
ldr r0, =gUnknown_0203CE58
ldrb r0, [r0, 0x5]
movs r1, 0
bl bag_menu_draw_pocket_indicator_square
add r0, sp, 0x8
ldrb r0, [r0]
movs r1, 0x1
bl bag_menu_draw_pocket_indicator_square
movs r0, 0xF
str r0, [sp]
movs r0, 0x10
str r0, [sp, 0x4]
movs r0, 0x2
movs r1, 0xB
movs r2, 0xE
movs r3, 0x2
bl FillBgTilemapBufferRect_Palette0
movs r0, 0x2
bl schedule_bg_copy_tilemap_to_vram
add r0, sp, 0x8
ldrb r0, [r0]
movs r1, 0x1
bl SetBagVisualPocketId
movs r0, 0x1
bl RemoveBagObject
asrs r0, r5, 16
bl AddSwitchPocketRotatingBallObject
ldr r1, =sub_81AC10C
ldr r2, =gTasks
lsls r0, r6, 2
adds r0, r6
lsls r0, 3
adds r0, r2
ldr r2, [r0]
adds r0, r6, 0
bl SetTaskFuncWithFollowupFunc
add sp, 0xC
pop {r4-r6}
pop {r0}
bx r0
.pool
thumb_func_end SwitchBagPocket
thumb_func_start sub_81AC10C
sub_81AC10C: @ 81AC10C
push {r4-r7,lr}
lsls r0, 24
lsrs r7, r0, 24
lsls r0, r7, 2
adds r0, r7
lsls r0, 3
ldr r1, =gTasks + 0x8
adds r6, r0, r1
bl sub_81221AC
lsls r0, 24
cmp r0, 0
bne _081AC184
bl IsWallysBag
lsls r0, 24
cmp r0, 0
bne _081AC184
bl GetSwitchBagPocketDirection
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
beq _081AC148
cmp r0, 0x2
beq _081AC164
b _081AC184
.pool
_081AC148:
ldr r0, =gUnknown_0203CE5D
movs r1, 0x16
ldrsb r1, [r6, r1]
bl ChangeBagPocketId
adds r0, r7, 0
bl SwitchTaskToFollowupFunc
movs r1, 0x1
negs r1, r1
adds r0, r7, 0
b _081AC178
.pool
_081AC164:
ldr r0, =gUnknown_0203CE5D
movs r1, 0x16
ldrsb r1, [r6, r1]
bl ChangeBagPocketId
adds r0, r7, 0
bl SwitchTaskToFollowupFunc
adds r0, r7, 0
movs r1, 0x1
_081AC178:
movs r2, 0x1
bl SwitchBagPocket
b _081AC22E
.pool
_081AC184:
movs r1, 0x1A
ldrsh r0, [r6, r1]
cmp r0, 0
beq _081AC192
cmp r0, 0x1
beq _081AC1DC
b _081AC22E
_081AC192:
ldrb r0, [r6, 0x18]
bl sub_81AC23C
ldrh r0, [r6, 0x18]
adds r1, r0, 0x1
strh r1, [r6, 0x18]
movs r0, 0x1
ands r0, r1
cmp r0, 0
bne _081AC1CC
movs r2, 0x16
ldrsh r0, [r6, r2]
cmp r0, 0x1
bne _081AC1BC
lsls r0, r1, 16
asrs r0, 17
lsls r0, 24
lsrs r0, 24
bl bag_menu_copy_pocket_name_to_window
b _081AC1CC
_081AC1BC:
lsls r1, 16
asrs r1, 17
movs r0, 0x8
subs r0, r1
lsls r0, 24
lsrs r0, 24
bl bag_menu_copy_pocket_name_to_window
_081AC1CC:
movs r1, 0x18
ldrsh r0, [r6, r1]
cmp r0, 0x10
bne _081AC22E
ldrh r0, [r6, 0x1A]
adds r0, 0x1
strh r0, [r6, 0x1A]
b _081AC22E
_081AC1DC:
ldr r4, =gUnknown_0203CE5D
movs r1, 0x16
ldrsb r1, [r6, r1]
adds r0, r4, 0
bl ChangeBagPocketId
subs r5, r4, 0x5
ldrb r0, [r5, 0x5]
bl load_bag_item_list_buffers
ldr r0, =gMultiuseListMenuTemplate
ldrb r2, [r5, 0x5]
lsls r2, 1
adds r1, r4, 0
adds r1, 0xD
adds r1, r2, r1
ldrh r1, [r1]
adds r4, 0x3
adds r2, r4
ldrh r2, [r2]
bl ListMenuInit
lsls r0, 24
lsrs r0, 24
strh r0, [r6]
movs r0, 0x1
bl PutWindowTilemap
movs r0, 0x2
bl PutWindowTilemap
movs r0, 0
bl schedule_bg_copy_tilemap_to_vram
bl bag_menu_add_pocket_scroll_arrow_indicators_maybe
bl bag_menu_add_list_scroll_arrow_indicators_maybe
adds r0, r7, 0
bl SwitchTaskToFollowupFunc
_081AC22E:
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_81AC10C
thumb_func_start sub_81AC23C
sub_81AC23C: @ 81AC23C
push {lr}

View File

@ -39,7 +39,8 @@ struct unkBagStruct {
void* unk0;
u8 unk4[0x800];
u8 unk804;
u8 filler4[11];
u8 filler4;
u8 unk806[10];
u8 unk810[10];
u8 unk81A;
u8 unk81B:4;
@ -92,6 +93,8 @@ extern u8 GetMenuCursorDimensionByFont(u8, u8);
extern u8 AddScrollIndicatorArrowPair(void*, void*);
extern void sub_80D6FB4(struct BagPocket*);
extern void sub_80D6F64(struct BagPocket*);
extern u8 GetLRKeysState(void);
extern void sub_81AC23C(u8);
void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)());
void CB2_Bag(void);
@ -101,7 +104,7 @@ bool8 load_bag_menu_graphics(void);
void setup_bag_menu_textboxes(void);
void allocate_bag_item_list_buffers(void);
void load_bag_item_list_buffers(u8);
void bag_menu_print_pocket_names(u8*, u8);
void bag_menu_print_pocket_names(u8*, u8*);
void bag_menu_copy_pocket_name_to_window(u8);
void bag_menu_draw_pocket_indicator_square(u8, u8);
void AddBagVisualObject(u8);
@ -129,9 +132,13 @@ void set_callback3_to_bag(u8);
void sub_81ABC54(u8, s16);
u8 bag_menu_add_window(u8);
u8 GetSwitchBagPocketDirection(void);
void SwitchBagPocket(u8, s8, u8);
void SwitchBagPocket(u8, s16, u16);
bool8 sub_81AC2C0(void);
void bag_menu_swap_items(u8);
void SetBagVisualPocketId(u8, u8);
void RemoveBagObject(u8);
void AddSwitchPocketRotatingBallObject(s16);
void sub_81AC10C(u8);
extern u8 *gPocketNamesStringsTable[];
extern struct BgTemplate gUnknown_08613F90[];
@ -842,3 +849,273 @@ void set_callback3_to_bag(u8 taskId)
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = Task_BagMenu;
}
u8 GetSwitchBagPocketDirection(void)
{
u8 LRKeys;
if (gUnknown_0203CE54->unk81B != 0)
return 0;
LRKeys = GetLRKeysState();
if ((gMain.newKeys & DPAD_LEFT) || LRKeys == 1)
{
PlaySE(SE_SELECT);
return 1;
}
if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == 2)
{
PlaySE(SE_SELECT);
return 2;
}
return 0;
}
void ChangeBagPocketId(u8 *bagPocketId, s8 deltaBagPocketId)
{
if (deltaBagPocketId == 1 && *bagPocketId == 4)
*bagPocketId = 0;
else if (deltaBagPocketId == -1 && *bagPocketId == 0)
{
*bagPocketId = 4;
}
else
*bagPocketId += deltaBagPocketId;
}
#ifdef NONMATCHING
void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3)
{
s16* data = gTasks[taskId].data;
u8 pocketId;
data[13] = 0;
data[12] = 0;
data[11] = deltaBagPocketId;
if (a3 == 0)
{
ClearWindowTilemap(0);
ClearWindowTilemap(1);
sub_81AE6C8(data[0], &gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], &gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]);
schedule_bg_copy_tilemap_to_vram(0);
gSprites[gUnknown_0203CE54->unk806[gUnknown_0203CE54->unk81B_1 ^ 1]].invisible = 1;
sub_81AB824();
}
pocketId = gUnknown_0203CE58.pocket;
ChangeBagPocketId(&pocketId, deltaBagPocketId);
if (deltaBagPocketId == 1)
{
bag_menu_print_pocket_names(gPocketNamesStringsTable[gUnknown_0203CE58.pocket], gPocketNamesStringsTable[pocketId]);
bag_menu_copy_pocket_name_to_window(0);
}
else
{
bag_menu_print_pocket_names(gPocketNamesStringsTable[pocketId], gPocketNamesStringsTable[gUnknown_0203CE58.pocket]);
bag_menu_copy_pocket_name_to_window(8);
}
bag_menu_draw_pocket_indicator_square(gUnknown_0203CE58.pocket, 0);
bag_menu_draw_pocket_indicator_square(pocketId, 1);
FillBgTilemapBufferRect_Palette0(2, 11, 14, 2, 15, 16);
schedule_bg_copy_tilemap_to_vram(2);
SetBagVisualPocketId(pocketId, 1);
RemoveBagObject(1);
AddSwitchPocketRotatingBallObject(deltaBagPocketId);
SetTaskFuncWithFollowupFunc(taskId, sub_81AC10C, gTasks[taskId].func);
}
#else
__attribute__((naked))
void SwitchBagPocket(u8 taskId, s16 deltaBagPocketId, u16 a3)
{
asm(".syntax unified\n\
push {r4-r6,lr}\n\
sub sp, 0xC\n\
lsls r0, 24\n\
lsrs r6, r0, 24\n\
lsls r1, 16\n\
lsrs r5, r1, 16\n\
lsls r2, 16\n\
lsls r0, r6, 2\n\
adds r0, r6\n\
lsls r0, 3\n\
ldr r1, =gTasks + 0x8\n\
adds r4, r0, r1\n\
movs r0, 0\n\
strh r0, [r4, 0x1A]\n\
strh r0, [r4, 0x18]\n\
strh r5, [r4, 0x16]\n\
cmp r2, 0\n\
bne _081AC026\n\
movs r0, 0\n\
bl ClearWindowTilemap\n\
movs r0, 0x1\n\
bl ClearWindowTilemap\n\
ldrb r0, [r4]\n\
ldr r3, =gUnknown_0203CE58\n\
ldrb r2, [r3, 0x5]\n\
lsls r2, 1\n\
adds r1, r3, 0\n\
adds r1, 0x12\n\
adds r1, r2, r1\n\
adds r3, 0x8\n\
adds r2, r3\n\
bl sub_81AE6C8\n\
movs r0, 0\n\
bl schedule_bg_copy_tilemap_to_vram\n\
ldr r3, =gSprites\n\
ldr r0, =gUnknown_0203CE54\n\
ldr r2, [r0]\n\
ldr r1, =0x0000081b\n\
adds r0, r2, r1\n\
ldrb r1, [r0]\n\
lsls r1, 26\n\
lsrs r1, 30\n\
movs r0, 0x1\n\
eors r0, r1\n\
adds r2, r0\n\
ldr r0, =0x00000806\n\
adds r2, r0\n\
ldrb r1, [r2]\n\
lsls r0, r1, 4\n\
adds r0, r1\n\
lsls r0, 2\n\
adds r0, r3\n\
adds r0, 0x3E\n\
ldrb r1, [r0]\n\
movs r2, 0x4\n\
orrs r1, r2\n\
strb r1, [r0]\n\
bl sub_81AB824\n\
_081AC026:\n\
ldr r4, =gUnknown_0203CE58\n\
ldrb r1, [r4, 0x5]\n\
add r0, sp, 0x8\n\
strb r1, [r0]\n\
lsls r1, r5, 24\n\
asrs r1, 24\n\
bl ChangeBagPocketId\n\
lsls r0, r5, 16\n\
asrs r1, r0, 16\n\
adds r5, r0, 0\n\
cmp r1, 0x1\n\
bne _081AC07C\n\
ldr r2, =gPocketNamesStringsTable\n\
ldrb r0, [r4, 0x5]\n\
lsls r0, 2\n\
adds r0, r2\n\
ldr r0, [r0]\n\
add r1, sp, 0x8\n\
ldrb r1, [r1]\n\
lsls r1, 2\n\
adds r1, r2\n\
ldr r1, [r1]\n\
bl bag_menu_print_pocket_names\n\
movs r0, 0\n\
bl bag_menu_copy_pocket_name_to_window\n\
b _081AC09A\n\
.pool\n\
_081AC07C:\n\
ldr r2, =gPocketNamesStringsTable\n\
add r0, sp, 0x8\n\
ldrb r0, [r0]\n\
lsls r0, 2\n\
adds r0, r2\n\
ldr r0, [r0]\n\
ldrb r1, [r4, 0x5]\n\
lsls r1, 2\n\
adds r1, r2\n\
ldr r1, [r1]\n\
bl bag_menu_print_pocket_names\n\
movs r0, 0x8\n\
bl bag_menu_copy_pocket_name_to_window\n\
_081AC09A:\n\
ldr r0, =gUnknown_0203CE58\n\
ldrb r0, [r0, 0x5]\n\
movs r1, 0\n\
bl bag_menu_draw_pocket_indicator_square\n\
add r0, sp, 0x8\n\
ldrb r0, [r0]\n\
movs r1, 0x1\n\
bl bag_menu_draw_pocket_indicator_square\n\
movs r0, 0xF\n\
str r0, [sp]\n\
movs r0, 0x10\n\
str r0, [sp, 0x4]\n\
movs r0, 0x2\n\
movs r1, 0xB\n\
movs r2, 0xE\n\
movs r3, 0x2\n\
bl FillBgTilemapBufferRect_Palette0\n\
movs r0, 0x2\n\
bl schedule_bg_copy_tilemap_to_vram\n\
add r0, sp, 0x8\n\
ldrb r0, [r0]\n\
movs r1, 0x1\n\
bl SetBagVisualPocketId\n\
movs r0, 0x1\n\
bl RemoveBagObject\n\
asrs r0, r5, 16\n\
bl AddSwitchPocketRotatingBallObject\n\
ldr r1, =sub_81AC10C\n\
ldr r2, =gTasks\n\
lsls r0, r6, 2\n\
adds r0, r6\n\
lsls r0, 3\n\
adds r0, r2\n\
ldr r2, [r0]\n\
adds r0, r6, 0\n\
bl SetTaskFuncWithFollowupFunc\n\
add sp, 0xC\n\
pop {r4-r6}\n\
pop {r0}\n\
bx r0\n\
.pool\n\
.syntax divided\n");
}
#endif
void sub_81AC10C(u8 taskId)
{
s16* data = gTasks[taskId].data;
if (!sub_81221AC() && !IsWallysBag())
{
switch (GetSwitchBagPocketDirection())
{
case 1:
ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]);
SwitchTaskToFollowupFunc(taskId);
SwitchBagPocket(taskId, -1, 1);
return;
case 2:
ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]);
SwitchTaskToFollowupFunc(taskId);
SwitchBagPocket(taskId, 1, 1);
return;
}
}
switch (data[13])
{
case 0:
sub_81AC23C(data[12]);
if (!(++data[12] & 1))
{
if (data[11] == 1)
bag_menu_copy_pocket_name_to_window(data[12] >> 1);
else
bag_menu_copy_pocket_name_to_window(8 - (data[12] >> 1));
}
if (data[12] == 16)
data[13]++;
break;
case 1:
ChangeBagPocketId(&gUnknown_0203CE58.pocket, data[11]);
load_bag_item_list_buffers(gUnknown_0203CE58.pocket);
data[0] = ListMenuInit(&gMultiuseListMenuTemplate, gUnknown_0203CE58.unk12[gUnknown_0203CE58.pocket], gUnknown_0203CE58.unk8[gUnknown_0203CE58.pocket]);
PutWindowTilemap(1);
PutWindowTilemap(2);
schedule_bg_copy_tilemap_to_vram(0);
bag_menu_add_pocket_scroll_arrow_indicators_maybe();
bag_menu_add_list_scroll_arrow_indicators_maybe();
SwitchTaskToFollowupFunc(taskId);
}
}