mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 11:14:15 +01:00
through (nearly-matching) sub_80172A0
This commit is contained in:
parent
8e0773675c
commit
51d2131dc2
269
asm/union_room.s
269
asm/union_room.s
@ -5,275 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_8017178
|
||||
sub_8017178: @ 8017178
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
sub sp, 0x8
|
||||
adds r7, r0, 0
|
||||
adds r5, r1, 0
|
||||
mov r9, r2
|
||||
ldrb r4, [r7]
|
||||
cmp r4, 0
|
||||
beq _08017194
|
||||
cmp r4, 0x1
|
||||
beq _08017228
|
||||
b _0801728E
|
||||
_08017194:
|
||||
ldr r0, [r3]
|
||||
ldr r1, [r3, 0x4]
|
||||
str r0, [sp]
|
||||
str r1, [sp, 0x4]
|
||||
ldr r0, [sp, 0x24]
|
||||
bl sub_81DB41C
|
||||
adds r1, r0, 0
|
||||
ldr r2, [sp]
|
||||
lsrs r0, r2, 24
|
||||
cmp r0, r1
|
||||
ble _080171B6
|
||||
lsls r1, 24
|
||||
ldr r0, =0x00ffffff
|
||||
ands r0, r2
|
||||
orrs r0, r1
|
||||
str r0, [sp]
|
||||
_080171B6:
|
||||
ldr r2, [sp]
|
||||
lsrs r0, r2, 8
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
lsrs r1, r2, 24
|
||||
adds r0, r1
|
||||
cmp r0, 0x1D
|
||||
ble _080171DC
|
||||
movs r0, 0x1D
|
||||
subs r0, r1
|
||||
cmp r0, 0
|
||||
bge _080171D0
|
||||
movs r0, 0
|
||||
_080171D0:
|
||||
lsls r1, r0, 24
|
||||
lsrs r1, 16
|
||||
ldr r0, =0xffff00ff
|
||||
ands r0, r2
|
||||
orrs r0, r1
|
||||
str r0, [sp]
|
||||
_080171DC:
|
||||
mov r0, sp
|
||||
bl AddWindow
|
||||
strb r0, [r5]
|
||||
ldrb r0, [r5]
|
||||
movs r1, 0
|
||||
bl DrawStdWindowFrame
|
||||
ldr r0, =gMultiuseListMenuTemplate
|
||||
adds r2, r0, 0
|
||||
ldr r1, [sp, 0x24]
|
||||
ldm r1!, {r3,r4,r6}
|
||||
stm r2!, {r3,r4,r6}
|
||||
ldm r1!, {r3,r4,r6}
|
||||
stm r2!, {r3,r4,r6}
|
||||
ldrb r1, [r5]
|
||||
strb r1, [r0, 0x10]
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl ListMenuInit
|
||||
mov r1, r9
|
||||
strb r0, [r1]
|
||||
ldrb r0, [r5]
|
||||
movs r1, 0x1
|
||||
bl CopyWindowToVram
|
||||
ldrb r0, [r7]
|
||||
adds r0, 0x1
|
||||
strb r0, [r7]
|
||||
b _0801728E
|
||||
.pool
|
||||
_08017228:
|
||||
mov r3, r9
|
||||
ldrb r0, [r3]
|
||||
bl ListMenu_ProcessInput
|
||||
mov r8, r0
|
||||
ldr r0, =gMain
|
||||
ldrh r1, [r0, 0x2E]
|
||||
ands r4, r1
|
||||
cmp r4, 0
|
||||
beq _08017264
|
||||
mov r4, r9
|
||||
ldrb r0, [r4]
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl DestroyListMenuTask
|
||||
ldrb r0, [r5]
|
||||
movs r1, 0x1
|
||||
bl ClearStdWindowAndFrame
|
||||
ldrb r0, [r5]
|
||||
bl RemoveWindow
|
||||
movs r0, 0
|
||||
strb r0, [r7]
|
||||
mov r0, r8
|
||||
b _08017292
|
||||
.pool
|
||||
_08017264:
|
||||
movs r0, 0x2
|
||||
ands r0, r1
|
||||
cmp r0, 0
|
||||
beq _0801728E
|
||||
mov r6, r9
|
||||
ldrb r0, [r6]
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl DestroyListMenuTask
|
||||
ldrb r0, [r5]
|
||||
movs r1, 0x1
|
||||
bl ClearStdWindowAndFrame
|
||||
ldrb r0, [r5]
|
||||
bl RemoveWindow
|
||||
strb r4, [r7]
|
||||
movs r0, 0x2
|
||||
negs r0, r0
|
||||
b _08017292
|
||||
_0801728E:
|
||||
movs r0, 0x1
|
||||
negs r0, r0
|
||||
_08017292:
|
||||
add sp, 0x8
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_8017178
|
||||
|
||||
thumb_func_start sub_80172A0
|
||||
sub_80172A0: @ 80172A0
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
adds r5, r0, 0
|
||||
adds r6, r1, 0
|
||||
mov r10, r2
|
||||
mov r9, r3
|
||||
ldrb r4, [r5]
|
||||
cmp r4, 0x1
|
||||
beq _0801730C
|
||||
cmp r4, 0x1
|
||||
bgt _080172C2
|
||||
cmp r4, 0
|
||||
beq _080172C8
|
||||
b _0801739C
|
||||
_080172C2:
|
||||
cmp r4, 0x2
|
||||
beq _0801731C
|
||||
b _0801739C
|
||||
_080172C8:
|
||||
ldr r0, =gUnknown_082F0344
|
||||
bl sub_8017118
|
||||
mov r1, r9
|
||||
strb r0, [r1]
|
||||
ldr r0, [sp, 0x20]
|
||||
bl AddWindow
|
||||
strb r0, [r6]
|
||||
ldrb r0, [r6]
|
||||
movs r1, 0
|
||||
bl DrawStdWindowFrame
|
||||
ldr r0, =gMultiuseListMenuTemplate
|
||||
adds r2, r0, 0
|
||||
ldr r1, [sp, 0x24]
|
||||
ldm r1!, {r3,r4,r7}
|
||||
stm r2!, {r3,r4,r7}
|
||||
ldm r1!, {r3,r4,r7}
|
||||
stm r2!, {r3,r4,r7}
|
||||
ldrb r1, [r6]
|
||||
strb r1, [r0, 0x10]
|
||||
movs r1, 0
|
||||
movs r2, 0x1
|
||||
bl ListMenuInit
|
||||
mov r1, r10
|
||||
strb r0, [r1]
|
||||
b _08017314
|
||||
.pool
|
||||
_0801730C:
|
||||
ldrb r0, [r6]
|
||||
movs r1, 0x1
|
||||
bl CopyWindowToVram
|
||||
_08017314:
|
||||
ldrb r0, [r5]
|
||||
adds r0, 0x1
|
||||
strb r0, [r5]
|
||||
b _0801739C
|
||||
_0801731C:
|
||||
mov r3, r10
|
||||
ldrb r0, [r3]
|
||||
bl ListMenu_ProcessInput
|
||||
adds r1, r0, 0
|
||||
ldr r0, =gMain
|
||||
ldrh r2, [r0, 0x2E]
|
||||
movs r0, 0x3
|
||||
ands r0, r2
|
||||
cmp r0, 0
|
||||
beq _0801739C
|
||||
cmp r1, 0x8
|
||||
beq _0801733E
|
||||
ands r4, r2
|
||||
mov r8, r4
|
||||
cmp r4, 0
|
||||
beq _08017368
|
||||
_0801733E:
|
||||
mov r4, r10
|
||||
ldrb r0, [r4]
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl DestroyListMenuTask
|
||||
ldrb r0, [r6]
|
||||
bl RemoveWindow
|
||||
mov r7, r9
|
||||
ldrb r0, [r7]
|
||||
bl sub_8017168
|
||||
movs r0, 0
|
||||
strb r0, [r5]
|
||||
movs r0, 0x2
|
||||
negs r0, r0
|
||||
b _080173A0
|
||||
.pool
|
||||
_08017368:
|
||||
ldr r0, [sp, 0x28]
|
||||
bl sub_8017CB0
|
||||
adds r4, r0, 0
|
||||
cmp r4, 0
|
||||
blt _08017396
|
||||
mov r1, r10
|
||||
ldrb r0, [r1]
|
||||
movs r1, 0
|
||||
movs r2, 0
|
||||
bl DestroyListMenuTask
|
||||
ldrb r0, [r6]
|
||||
bl RemoveWindow
|
||||
mov r3, r9
|
||||
ldrb r0, [r3]
|
||||
bl sub_8017168
|
||||
mov r7, r8
|
||||
strb r7, [r5]
|
||||
adds r0, r4, 0
|
||||
b _080173A0
|
||||
_08017396:
|
||||
movs r0, 0x7
|
||||
bl PlaySE
|
||||
_0801739C:
|
||||
movs r0, 0x1
|
||||
negs r0, r0
|
||||
_080173A0:
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r1}
|
||||
bx r1
|
||||
thumb_func_end sub_80172A0
|
||||
|
||||
thumb_func_start sub_80173B0
|
||||
sub_80173B0: @ 80173B0
|
||||
push {lr}
|
||||
|
243
src/union_room.c
243
src/union_room.c
@ -34,6 +34,7 @@
|
||||
#include "data2.h"
|
||||
#include "field_screen_effect.h"
|
||||
#include "script_pokemon_util_80F87D8.h"
|
||||
#include "international_string_util.h"
|
||||
#include "mevent.h"
|
||||
|
||||
struct UnkStruct_Shared
|
||||
@ -264,6 +265,7 @@ void sub_801818C(bool32 arg0);
|
||||
void sub_801A3D0(u32 arg0, u32 arg1, struct UnkStruct_Main0 *arg2);
|
||||
s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate);
|
||||
s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6);
|
||||
s32 sub_8017CB0(struct UnkStruct_Main0 * arg);
|
||||
bool32 sub_8018024(void);
|
||||
u32 sub_8017984(u32 arg0);
|
||||
void sub_8018220(u8 *unused, struct UnkStruct_URoom *arg1, bool8 arg2);
|
||||
@ -346,6 +348,7 @@ extern const struct WindowTemplate gUnknown_082F017C;
|
||||
extern const struct WindowTemplate gUnknown_082F021C;
|
||||
extern const struct WindowTemplate gUnknown_082F025C;
|
||||
extern const struct WindowTemplate gUnknown_082F0294;
|
||||
extern const struct WindowTemplate gUnknown_082F0344;
|
||||
extern const struct WindowTemplate gUnknown_082F034C;
|
||||
|
||||
extern const struct ListMenuTemplate gUnknown_082F015C;
|
||||
@ -3678,7 +3681,7 @@ s8 sub_80170B8(u8 *arg0, bool32 arg1)
|
||||
return -2;
|
||||
}
|
||||
|
||||
u8 sub_8017118(struct WindowTemplate * template)
|
||||
u8 sub_8017118(const struct WindowTemplate * template)
|
||||
{
|
||||
u8 windowId = AddWindow(template);
|
||||
DrawStdWindowFrame(windowId, FALSE);
|
||||
@ -3693,3 +3696,241 @@ void sub_8017168(u8 windowId)
|
||||
{
|
||||
RemoveWindow(windowId);
|
||||
}
|
||||
|
||||
s32 sub_8017178(u8 *arg0, u8 *arg1, u8 *arg2, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate)
|
||||
{
|
||||
s32 r1, r8;
|
||||
struct WindowTemplate winTemplateCopy;
|
||||
|
||||
switch (*arg0)
|
||||
{
|
||||
case 0:
|
||||
winTemplateCopy = *winTemplate;
|
||||
r1 = sub_81DB41C(menuTemplate);
|
||||
if (winTemplateCopy.width > r1)
|
||||
{
|
||||
winTemplateCopy.width = r1;
|
||||
}
|
||||
if (winTemplateCopy.tilemapLeft + winTemplateCopy.width > 29)
|
||||
{
|
||||
winTemplateCopy.tilemapLeft = max(29 - winTemplateCopy.width, 0);
|
||||
}
|
||||
*arg1 = AddWindow(&winTemplateCopy);
|
||||
DrawStdWindowFrame(*arg1, FALSE);
|
||||
gMultiuseListMenuTemplate = *menuTemplate;
|
||||
gMultiuseListMenuTemplate.windowId = *arg1;
|
||||
*arg2 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0);
|
||||
CopyWindowToVram(*arg1, TRUE);
|
||||
(*arg0)++;
|
||||
break;
|
||||
case 1:
|
||||
r8 = ListMenu_ProcessInput(*arg2);
|
||||
if (({gMain.newKeys & A_BUTTON;}))
|
||||
{
|
||||
DestroyListMenuTask(*arg2, NULL, NULL);
|
||||
ClearStdWindowAndFrame(*arg1, TRUE);
|
||||
RemoveWindow(*arg1);
|
||||
*arg0 = 0;
|
||||
return r8;
|
||||
}
|
||||
else if (({gMain.newKeys & B_BUTTON;}))
|
||||
{
|
||||
DestroyListMenuTask(*arg2, NULL, NULL);
|
||||
ClearStdWindowAndFrame(*arg1, TRUE);
|
||||
RemoveWindow(*arg1);
|
||||
*arg0 = 0;
|
||||
return -2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef NONMATCHING
|
||||
s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6)
|
||||
{
|
||||
s32 input;
|
||||
s32 r4;
|
||||
|
||||
switch (*arg0)
|
||||
{
|
||||
case 0:
|
||||
*arg3 = sub_8017118(&gUnknown_082F0344);
|
||||
*arg1 = AddWindow(winTemplate);
|
||||
DrawStdWindowFrame(*arg1, FALSE);
|
||||
gMultiuseListMenuTemplate = *menuTemplate;
|
||||
gMultiuseListMenuTemplate.windowId = *arg1;
|
||||
*arg2 = ListMenuInit(&gMultiuseListMenuTemplate, 0, 1);
|
||||
(*arg0)++;
|
||||
break;
|
||||
case 1:
|
||||
CopyWindowToVram(*arg1, TRUE);
|
||||
(*arg0)++;
|
||||
break;
|
||||
case 2:
|
||||
// Register swap r1 <---> r2
|
||||
input = ListMenu_ProcessInput(*arg2);
|
||||
if (({gMain.newKeys & (A_BUTTON | B_BUTTON);}))
|
||||
{
|
||||
if (input == 8 || ({gMain.newKeys & B_BUTTON;}))
|
||||
{
|
||||
DestroyListMenuTask(*arg2, NULL, NULL);
|
||||
RemoveWindow(*arg1);
|
||||
sub_8017168(*arg3);
|
||||
*arg0 = 0;
|
||||
return -2;
|
||||
}
|
||||
else
|
||||
{
|
||||
r4 = sub_8017CB0(arg6);
|
||||
if (r4 >= 0)
|
||||
{
|
||||
DestroyListMenuTask(*arg2, NULL, NULL);
|
||||
RemoveWindow(*arg1);
|
||||
sub_8017168(*arg3);
|
||||
*arg0 = 0;
|
||||
return r4;
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaySE(SE_WALL_HIT);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
NAKED
|
||||
s32 sub_80172A0(u8 *arg0, u8 *arg1, u8 *arg2, u8 *arg3, const struct WindowTemplate *winTemplate, const struct ListMenuTemplate *menuTemplate, struct UnkStruct_Main0 *arg6)
|
||||
{
|
||||
asm_unified("\tpush {r4-r7,lr}\n"
|
||||
"\tmov r7, r10\n"
|
||||
"\tmov r6, r9\n"
|
||||
"\tmov r5, r8\n"
|
||||
"\tpush {r5-r7}\n"
|
||||
"\tadds r5, r0, 0\n"
|
||||
"\tadds r6, r1, 0\n"
|
||||
"\tmov r10, r2\n"
|
||||
"\tmov r9, r3\n"
|
||||
"\tldrb r4, [r5]\n"
|
||||
"\tcmp r4, 0x1\n"
|
||||
"\tbeq _0801730C\n"
|
||||
"\tcmp r4, 0x1\n"
|
||||
"\tbgt _080172C2\n"
|
||||
"\tcmp r4, 0\n"
|
||||
"\tbeq _080172C8\n"
|
||||
"\tb _0801739C\n"
|
||||
"_080172C2:\n"
|
||||
"\tcmp r4, 0x2\n"
|
||||
"\tbeq _0801731C\n"
|
||||
"\tb _0801739C\n"
|
||||
"_080172C8:\n"
|
||||
"\tldr r0, =gUnknown_082F0344\n"
|
||||
"\tbl sub_8017118\n"
|
||||
"\tmov r1, r9\n"
|
||||
"\tstrb r0, [r1]\n"
|
||||
"\tldr r0, [sp, 0x20]\n"
|
||||
"\tbl AddWindow\n"
|
||||
"\tstrb r0, [r6]\n"
|
||||
"\tldrb r0, [r6]\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tbl DrawStdWindowFrame\n"
|
||||
"\tldr r0, =gMultiuseListMenuTemplate\n"
|
||||
"\tadds r2, r0, 0\n"
|
||||
"\tldr r1, [sp, 0x24]\n"
|
||||
"\tldm r1!, {r3,r4,r7}\n"
|
||||
"\tstm r2!, {r3,r4,r7}\n"
|
||||
"\tldm r1!, {r3,r4,r7}\n"
|
||||
"\tstm r2!, {r3,r4,r7}\n"
|
||||
"\tldrb r1, [r6]\n"
|
||||
"\tstrb r1, [r0, 0x10]\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tmovs r2, 0x1\n"
|
||||
"\tbl ListMenuInit\n"
|
||||
"\tmov r1, r10\n"
|
||||
"\tstrb r0, [r1]\n"
|
||||
"\tb _08017314\n"
|
||||
"\t.pool\n"
|
||||
"_0801730C:\n"
|
||||
"\tldrb r0, [r6]\n"
|
||||
"\tmovs r1, 0x1\n"
|
||||
"\tbl CopyWindowToVram\n"
|
||||
"_08017314:\n"
|
||||
"\tldrb r0, [r5]\n"
|
||||
"\tadds r0, 0x1\n"
|
||||
"\tstrb r0, [r5]\n"
|
||||
"\tb _0801739C\n"
|
||||
"_0801731C:\n"
|
||||
"\tmov r3, r10\n"
|
||||
"\tldrb r0, [r3]\n"
|
||||
"\tbl ListMenu_ProcessInput\n"
|
||||
"\tadds r1, r0, 0\n"
|
||||
"\tldr r0, =gMain\n"
|
||||
"\tldrh r2, [r0, 0x2E]\n"
|
||||
"\tmovs r0, 0x3\n"
|
||||
"\tands r0, r2\n"
|
||||
"\tcmp r0, 0\n"
|
||||
"\tbeq _0801739C\n"
|
||||
"\tcmp r1, 0x8\n"
|
||||
"\tbeq _0801733E\n"
|
||||
"\tands r4, r2\n"
|
||||
"\tmov r8, r4\n"
|
||||
"\tcmp r4, 0\n"
|
||||
"\tbeq _08017368\n"
|
||||
"_0801733E:\n"
|
||||
"\tmov r4, r10\n"
|
||||
"\tldrb r0, [r4]\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tmovs r2, 0\n"
|
||||
"\tbl DestroyListMenuTask\n"
|
||||
"\tldrb r0, [r6]\n"
|
||||
"\tbl RemoveWindow\n"
|
||||
"\tmov r7, r9\n"
|
||||
"\tldrb r0, [r7]\n"
|
||||
"\tbl sub_8017168\n"
|
||||
"\tmovs r0, 0\n"
|
||||
"\tstrb r0, [r5]\n"
|
||||
"\tmovs r0, 0x2\n"
|
||||
"\tnegs r0, r0\n"
|
||||
"\tb _080173A0\n"
|
||||
"\t.pool\n"
|
||||
"_08017368:\n"
|
||||
"\tldr r0, [sp, 0x28]\n"
|
||||
"\tbl sub_8017CB0\n"
|
||||
"\tadds r4, r0, 0\n"
|
||||
"\tcmp r4, 0\n"
|
||||
"\tblt _08017396\n"
|
||||
"\tmov r1, r10\n"
|
||||
"\tldrb r0, [r1]\n"
|
||||
"\tmovs r1, 0\n"
|
||||
"\tmovs r2, 0\n"
|
||||
"\tbl DestroyListMenuTask\n"
|
||||
"\tldrb r0, [r6]\n"
|
||||
"\tbl RemoveWindow\n"
|
||||
"\tmov r3, r9\n"
|
||||
"\tldrb r0, [r3]\n"
|
||||
"\tbl sub_8017168\n"
|
||||
"\tmov r7, r8\n"
|
||||
"\tstrb r7, [r5]\n"
|
||||
"\tadds r0, r4, 0\n"
|
||||
"\tb _080173A0\n"
|
||||
"_08017396:\n"
|
||||
"\tmovs r0, 0x7\n"
|
||||
"\tbl PlaySE\n"
|
||||
"_0801739C:\n"
|
||||
"\tmovs r0, 0x1\n"
|
||||
"\tnegs r0, r0\n"
|
||||
"_080173A0:\n"
|
||||
"\tpop {r3-r5}\n"
|
||||
"\tmov r8, r3\n"
|
||||
"\tmov r9, r4\n"
|
||||
"\tmov r10, r5\n"
|
||||
"\tpop {r4-r7}\n"
|
||||
"\tpop {r1}\n"
|
||||
"\tbx r1");
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user