through sub_81D16DC

This commit is contained in:
PikalaxALT 2018-02-28 22:09:28 -05:00
parent 7f7b182ca4
commit 9abc121fa2
2 changed files with 95 additions and 198 deletions

View File

@ -20700,202 +20700,6 @@ _081D156A:
// MATCH CALL
.section .text.after.match.call
thumb_func_start sub_81D15BC
sub_81D15BC: @ 81D15BC
ldr r1, =gRematchTable
lsls r0, 4
adds r0, r1
ldrh r0, [r0]
bx lr
.pool
thumb_func_end sub_81D15BC
thumb_func_start sub_81D15CC
sub_81D15CC: @ 81D15CC
push {lr}
adds r3, r0, 0
movs r1, 0
ldr r2, =gRematchTable
_081D15D4:
ldrh r0, [r2]
cmp r0, r3
bne _081D15E4
adds r0, r1, 0
b _081D15F0
.pool
_081D15E4:
adds r2, 0x10
adds r1, 0x1
cmp r1, 0x4D
ble _081D15D4
movs r0, 0x1
negs r0, r0
_081D15F0:
pop {r1}
bx r1
thumb_func_end sub_81D15CC
thumb_func_start sub_81D15F4
sub_81D15F4: @ 81D15F4
push {r4,lr}
cmp r0, 0x14
bhi _081D1620
ldr r1, =gUnknown_086252A8
lsls r0, 2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl sub_81D1574
ldr r1, =gUnknown_086252FC
lsls r0, 2
adds r0, r1
ldr r1, [r0]
adds r0, r4, 0
bl _call_via_r1
b _081D1622
.pool
_081D1620:
movs r0, 0
_081D1622:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81D15F4
thumb_func_start sub_81D1628
sub_81D1628: @ 81D1628
push {lr}
adds r2, r0, 0
ldrh r1, [r2, 0x2]
ldr r0, =0x0000ffff
cmp r1, r0
beq _081D1644
adds r0, r1, 0
bl FlagGet
lsls r0, 24
lsrs r0, 24
b _081D1646
.pool
_081D1644:
movs r0, 0x1
_081D1646:
pop {r1}
bx r1
thumb_func_end sub_81D1628
thumb_func_start sub_81D164C
sub_81D164C: @ 81D164C
push {lr}
adds r2, r0, 0
ldrh r1, [r2, 0x2]
ldr r0, =0x0000ffff
cmp r1, r0
beq _081D1668
adds r0, r1, 0
bl FlagGet
lsls r0, 24
lsrs r0, 24
b _081D166A
.pool
_081D1668:
movs r0, 0x1
_081D166A:
pop {r1}
bx r1
thumb_func_end sub_81D164C
thumb_func_start sub_81D1670
sub_81D1670: @ 81D1670
push {lr}
adds r2, r0, 0
ldrh r1, [r2, 0x2]
ldr r0, =0x0000ffff
cmp r1, r0
beq _081D168C
adds r0, r1, 0
bl FlagGet
lsls r0, 24
lsrs r0, 24
b _081D168E
.pool
_081D168C:
movs r0, 0x1
_081D168E:
pop {r1}
bx r1
thumb_func_end sub_81D1670
thumb_func_start sub_81D1694
sub_81D1694: @ 81D1694
push {lr}
adds r2, r0, 0
ldr r0, =gSaveBlock2Ptr
ldr r1, [r0]
ldrb r0, [r2, 0x1]
ldrb r1, [r1, 0x8]
cmp r0, r1
beq _081D16AC
movs r0, 0
b _081D16C6
.pool
_081D16AC:
ldrh r1, [r2, 0x2]
ldr r0, =0x0000ffff
cmp r1, r0
beq _081D16C4
adds r0, r1, 0
bl FlagGet
lsls r0, 24
lsrs r0, 24
b _081D16C6
.pool
_081D16C4:
movs r0, 0x1
_081D16C6:
pop {r1}
bx r1
thumb_func_end sub_81D1694
thumb_func_start sub_81D16CC
sub_81D16CC: @ 81D16CC
push {lr}
ldrh r0, [r0, 0x2]
bl FlagGet
lsls r0, 24
lsrs r0, 24
pop {r1}
bx r1
thumb_func_end sub_81D16CC
thumb_func_start sub_81D16DC
sub_81D16DC: @ 81D16DC
push {r4,lr}
cmp r0, 0x14
bhi _081D170C
ldr r1, =gUnknown_086252A8
lsls r0, 2
adds r0, r1
ldr r4, [r0]
adds r0, r4, 0
bl sub_81D1574
ldr r1, =gUnknown_08625310
lsls r0, 2
adds r0, r1
ldr r1, [r0]
adds r0, r4, 0
bl _call_via_r1
lsls r0, 24
lsrs r0, 24
b _081D170E
.pool
_081D170C:
movs r0, 0
_081D170E:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_81D16DC
thumb_func_start sub_81D1714
sub_81D1714: @ 81D1714
ldrb r0, [r0, 0x1]

View File

@ -1,20 +1,37 @@
// Includes
#include "global.h"
#include "battle_setup.h"
#include "event_data.h"
#define NELEMS(a) (s32)( sizeof (a) / sizeof (*(a)) )
// Static type declarations
typedef struct {
u8 v0;
u8 v1;
u16 v2;
void *v4;
void *v8;
void *vC;
} match_call_t;
// Static RAM declarations
// Static ROM declarations
// .rodata
extern const void *const gUnknown_086252A8[];
extern bool32 (*const gUnknown_086252FC[])(const match_call_t *);
extern bool8 (*const gUnknown_08625310[])(const match_call_t *);
// .text
u32 sub_81D1574(u8 *a)
s32 sub_81D1574(const match_call_t *matchCall)
{
switch (*a)
switch (matchCall->v0)
{
case 0:
default:
@ -30,3 +47,79 @@ u32 sub_81D1574(u8 *a)
return 4;
}
}
s32 sub_81D15BC(s32 rematchIdx)
{
return gRematchTable[rematchIdx].trainerIds[0];
}
s32 sub_81D15CC(s32 trainerIdx)
{
s32 rematchIdx;
for (rematchIdx = 0; rematchIdx < NELEMS(gRematchTable); rematchIdx++)
{
if (gRematchTable[rematchIdx].trainerIds[0] == trainerIdx)
return rematchIdx;
}
return -1;
}
bool32 sub_81D15F4(u32 idx)
{
const match_call_t *matchCall;
s32 v0;
if (idx > 20)
return FALSE;
matchCall = gUnknown_086252A8[idx];
v0 = sub_81D1574(matchCall);
return gUnknown_086252FC[v0](matchCall);
}
bool32 sub_81D1628(const match_call_t *matchCall)
{
if (matchCall->v2 == 0xffff)
return TRUE;
return FlagGet(matchCall->v2);
}
bool32 sub_81D164C(const match_call_t *matchCall)
{
if (matchCall->v2 == 0xffff)
return TRUE;
return FlagGet(matchCall->v2);
}
bool32 sub_81D1670(const match_call_t *matchCall)
{
if (matchCall->v2 == 0xffff)
return TRUE;
return FlagGet(matchCall->v2);
}
bool32 sub_81D1694(const match_call_t *matchCall)
{
if (matchCall->v1 != gSaveBlock2Ptr->playerGender)
return FALSE;
if (matchCall->v2 == 0xffff)
return TRUE;
return FlagGet(matchCall->v2);
}
bool32 sub_81D16CC(const match_call_t *matchCall)
{
return FlagGet(matchCall->v2);
}
bool8 sub_81D16DC(u32 idx)
{
const match_call_t *matchCall;
s32 v0;
if (idx > 20)
return FALSE;
matchCall = gUnknown_086252A8[idx];
v0 = sub_81D1574(matchCall);
return gUnknown_08625310[v0](matchCall);
}