From d25a9ffe169059715878c0c01bf8f8913b3eeb76 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 2 Mar 2018 18:12:23 -0500 Subject: [PATCH] through sub_81D1898 --- asm/match_call.s | 132 ----------------------------------------------- src/match_call.c | 113 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 103 insertions(+), 142 deletions(-) diff --git a/asm/match_call.s b/asm/match_call.s index 18d9e0852b..b0a322b4d0 100644 --- a/asm/match_call.s +++ b/asm/match_call.s @@ -5,138 +5,6 @@ .text - thumb_func_start sub_81D17E8 -sub_81D17E8: @ 81D17E8 - push {r4,r5,lr} - adds r5, r0, 0 - cmp r5, 0x14 - bhi _081D1832 - ldr r1, =gUnknown_086252A8 - lsls r0, r5, 2 - adds r0, r1 - ldr r4, [r0] - adds r0, r4, 0 - bl sub_81D1574 - adds r2, r0, 0 - ldr r1, =gUnknown_08625338 - lsls r0, r2, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - cmp r0, 0 - beq _081D1820 -_081D1812: - movs r0, 0x1 - b _081D1834 - .pool -_081D1820: - movs r2, 0 - ldr r1, =gUnknown_08625388 -_081D1824: - ldrh r0, [r1] - cmp r0, r5 - beq _081D1812 - adds r1, 0x18 - adds r2, 0x1 - cmp r2, 0x3 - bls _081D1824 -_081D1832: - movs r0, 0 -_081D1834: - pop {r4,r5} - pop {r1} - bx r1 - .pool - thumb_func_end sub_81D17E8 - - thumb_func_start sub_81D1840 -sub_81D1840: @ 81D1840 - movs r0, 0 - bx lr - thumb_func_end sub_81D1840 - - thumb_func_start sub_81D1844 -sub_81D1844: @ 81D1844 - movs r0, 0x1 - bx lr - thumb_func_end sub_81D1844 - - thumb_func_start sub_81D1848 -sub_81D1848: @ 81D1848 - movs r0, 0x1 - bx lr - thumb_func_end sub_81D1848 - - thumb_func_start sub_81D184C -sub_81D184C: @ 81D184C - movs r0, 0 - bx lr - thumb_func_end sub_81D184C - - thumb_func_start sub_81D1850 -sub_81D1850: @ 81D1850 - movs r0, 0 - bx lr - thumb_func_end sub_81D1850 - - thumb_func_start sub_81D1854 -sub_81D1854: @ 81D1854 - push {r4,lr} - cmp r0, 0x14 - bhi _081D1880 - ldr r1, =gUnknown_086252A8 - lsls r0, 2 - adds r0, r1 - ldr r4, [r0] - adds r0, r4, 0 - bl sub_81D1574 - ldr r1, =gUnknown_0862534C - lsls r0, 2 - adds r0, r1 - ldr r1, [r0] - adds r0, r4, 0 - bl _call_via_r1 - b _081D1882 - .pool -_081D1880: - movs r0, 0x4E -_081D1882: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_81D1854 - - thumb_func_start sub_81D1888 -sub_81D1888: @ 81D1888 - movs r0, 0x4E - bx lr - thumb_func_end sub_81D1888 - - thumb_func_start sub_81D188C -sub_81D188C: @ 81D188C - ldrh r0, [r0, 0x4] - bx lr - thumb_func_end sub_81D188C - - thumb_func_start sub_81D1890 -sub_81D1890: @ 81D1890 - ldrh r0, [r0, 0x4] - bx lr - thumb_func_end sub_81D1890 - - thumb_func_start sub_81D1894 -sub_81D1894: @ 81D1894 - movs r0, 0x4E - bx lr - thumb_func_end sub_81D1894 - - thumb_func_start sub_81D1898 -sub_81D1898: @ 81D1898 - movs r0, 0x4E - bx lr - thumb_func_end sub_81D1898 - thumb_func_start sub_81D189C sub_81D189C: @ 81D189C push {r4,r5,lr} diff --git a/src/match_call.c b/src/match_call.c index 557710ea6f..b754b1180c 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -77,6 +77,16 @@ typedef union { struct MatchCallStruct4 *type4; } match_call_t; +struct UnkStruct_08625388 { + u16 idx; + u16 v2; + u16 v4; + const u8 *v8; + const u8 *vC; + const u8 *v10; + const u8 *v14; +}; + // Static RAM declarations // Static ROM declarations @@ -87,10 +97,13 @@ extern const match_call_t gUnknown_086252A8[]; extern bool32 (*const gUnknown_086252FC[])(const match_call_t); extern u8 (*const gUnknown_08625310[])(const match_call_t); extern bool32 (*const gUnknown_08625324[])(const match_call_t); +extern bool32 (*const gUnknown_08625338[])(const match_call_t); +extern const struct UnkStruct_08625388 gUnknown_08625388[]; +extern u32 (*const gUnknown_0862534C[])(const match_call_t); // .text -s32 sub_81D1574(const match_call_t matchCall) +u32 sub_81D1574(const match_call_t matchCall) { switch (matchCall.common->type) { @@ -129,13 +142,13 @@ s32 sub_81D15CC(s32 trainerIdx) bool32 sub_81D15F4(u32 idx) { match_call_t matchCall; - s32 v0; + u32 i; if (idx > 20) return FALSE; matchCall = gUnknown_086252A8[idx]; - v0 = sub_81D1574(matchCall); - return gUnknown_086252FC[v0](matchCall); + i = sub_81D1574(matchCall); + return gUnknown_086252FC[i](matchCall); } bool32 sub_81D1628(match_call_t matchCall) @@ -176,13 +189,13 @@ bool32 sub_81D16CC(match_call_t matchCall) u8 sub_81D16DC(u32 idx) { match_call_t matchCall; - s32 v0; + u32 i; if (idx > 20) return FALSE; matchCall = gUnknown_086252A8[idx]; - v0 = sub_81D1574(matchCall); - return gUnknown_08625310[v0](matchCall); + i = sub_81D1574(matchCall); + return gUnknown_08625310[i](matchCall); } u8 sub_81D1714(match_call_t matchCall) @@ -220,13 +233,13 @@ u8 sub_81D1754(match_call_t matchCall) bool32 sub_81D1758(u32 idx) { match_call_t matchCall; - s32 v0; + u32 i; if (idx > 20) return 0; matchCall = gUnknown_086252A8[idx]; - v0 = sub_81D1574(matchCall); - return gUnknown_08625324[v0](matchCall); + i = sub_81D1574(matchCall); + return gUnknown_08625324[i](matchCall); } bool32 sub_81D178C(match_call_t matchCall) @@ -256,3 +269,83 @@ bool32 sub_81D17E4(match_call_t matchCall) return FALSE; } +bool32 sub_81D17E8(u32 idx) +{ + match_call_t matchCall; + u32 i; + + if (idx > 20) + return FALSE; + matchCall = gUnknown_086252A8[idx]; + i = sub_81D1574(matchCall); + if (gUnknown_08625338[i](matchCall)) + return TRUE; + for (i = 0; i < 4; i++) + { + if (gUnknown_08625388[i].idx == idx) + return TRUE; + } + return FALSE; +} + +bool32 sub_81D1840(match_call_t matchCall) +{ + return FALSE; +} + +bool32 sub_81D1844(match_call_t matchCall) +{ + return TRUE; +} + +bool32 sub_81D1848(match_call_t matchCall) +{ + return TRUE; +} + +bool32 sub_81D184C(match_call_t matchCall) +{ + return FALSE; +} + +bool32 sub_81D1850(match_call_t matchCall) +{ + return FALSE; +} + +u32 sub_81D1854(u32 idx) +{ + match_call_t matchCall; + u32 i; + + if (idx > 20) + return ARRAY_COUNT(gRematchTable); + matchCall = gUnknown_086252A8[idx]; + i = sub_81D1574(matchCall); + return gUnknown_0862534C[i](matchCall); +} + +u32 sub_81D1888(match_call_t matchCall) +{ + return ARRAY_COUNT(gRematchTable); +} + +u32 sub_81D188C(match_call_t matchCall) +{ + return matchCall.type1->v4; +} + +u32 sub_81D1890(match_call_t matchCall) +{ + return matchCall.type2->v4; +} + +u32 sub_81D1894(match_call_t matchCall) +{ + return ARRAY_COUNT(gRematchTable); +} + +u32 sub_81D1898(match_call_t matchCall) +{ + return ARRAY_COUNT(gRematchTable); +}