summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-03-02 08:44:33 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2018-03-02 08:44:33 -0500
commit89847427e48b434bbc403066673f89b688b4d9c7 (patch)
treeb5b2bfd227f0feb7c5ffdd629a8657d1fabdb484
parent988be1ab86453db2647c8b79391700fb0a72a436 (diff)
match_call_t; through sub_81D17E4
-rw-r--r--asm/match_call.s141
-rw-r--r--data/event_scripts.s4
-rw-r--r--data/match_call.s7
-rw-r--r--src/match_call.c187
4 files changed, 163 insertions, 176 deletions
diff --git a/asm/match_call.s b/asm/match_call.s
index b65a07a81..18d9e0852 100644
--- a/asm/match_call.s
+++ b/asm/match_call.s
@@ -5,147 +5,6 @@
.text
- thumb_func_start sub_81D1714
-sub_81D1714: @ 81D1714
- ldrb r0, [r0, 0x1]
- bx lr
- thumb_func_end sub_81D1714
-
- thumb_func_start sub_81D1718
-sub_81D1718: @ 81D1718
- ldrb r0, [r0, 0x1]
- bx lr
- thumb_func_end sub_81D1718
-
- thumb_func_start sub_81D171C
-sub_81D171C: @ 81D171C
- push {r4-r7,lr}
- adds r5, r0, 0
- movs r6, 0
- ldr r7, =0x0000ffff
- b _081D172E
- .pool
-_081D172C:
- adds r6, 0x1
-_081D172E:
- ldr r0, [r5, 0x10]
- lsls r4, r6, 2
- adds r1, r4, r0
- ldrh r0, [r1]
- cmp r0, r7
- beq _081D1744
- bl FlagGet
- lsls r0, 24
- cmp r0, 0
- bne _081D172C
-_081D1744:
- ldr r0, [r5, 0x10]
- adds r0, r4, r0
- ldrb r0, [r0, 0x2]
- pop {r4-r7}
- pop {r1}
- bx r1
- thumb_func_end sub_81D171C
-
- thumb_func_start sub_81D1750
-sub_81D1750: @ 81D1750
- movs r0, 0xD5
- bx lr
- thumb_func_end sub_81D1750
-
- thumb_func_start sub_81D1754
-sub_81D1754: @ 81D1754
- movs r0, 0xD5
- bx lr
- thumb_func_end sub_81D1754
-
- thumb_func_start sub_81D1758
-sub_81D1758: @ 81D1758
- push {r4,lr}
- cmp r0, 0x14
- bhi _081D1784
- ldr r1, =gUnknown_086252A8
- lsls r0, 2
- adds r0, r1
- ldr r4, [r0]
- adds r0, r4, 0
- bl sub_81D1574
- ldr r1, =gUnknown_08625324
- lsls r0, 2
- adds r0, r1
- ldr r1, [r0]
- adds r0, r4, 0
- bl _call_via_r1
- b _081D1786
- .pool
-_081D1784:
- movs r0, 0
-_081D1786:
- pop {r4}
- pop {r1}
- bx r1
- thumb_func_end sub_81D1758
-
- thumb_func_start sub_81D178C
-sub_81D178C: @ 81D178C
- movs r0, 0
- bx lr
- thumb_func_end sub_81D178C
-
- thumb_func_start sub_81D1790
-sub_81D1790: @ 81D1790
- push {lr}
- adds r1, r0, 0
- ldrh r0, [r1, 0x4]
- cmp r0, 0x48
- bhi _081D17B8
- ldr r0, =gSaveBlock1Ptr
- ldr r0, [r0]
- ldr r2, =0x000009ca
- adds r0, r2
- ldrh r1, [r1, 0x4]
- adds r0, r1
- ldrb r1, [r0]
- negs r0, r1
- orrs r0, r1
- lsrs r0, 31
- b _081D17BA
- .pool
-_081D17B8:
- movs r0, 0
-_081D17BA:
- pop {r1}
- bx r1
- thumb_func_end sub_81D1790
-
- thumb_func_start sub_81D17C0
-sub_81D17C0: @ 81D17C0
- ldr r1, =gSaveBlock1Ptr
- ldr r1, [r1]
- ldr r2, =0x000009ca
- adds r1, r2
- ldrh r0, [r0, 0x4]
- adds r1, r0
- ldrb r1, [r1]
- negs r0, r1
- orrs r0, r1
- lsrs r0, 31
- bx lr
- .pool
- thumb_func_end sub_81D17C0
-
- thumb_func_start sub_81D17E0
-sub_81D17E0: @ 81D17E0
- movs r0, 0
- bx lr
- thumb_func_end sub_81D17E0
-
- thumb_func_start sub_81D17E4
-sub_81D17E4: @ 81D17E4
- movs r0, 0
- bx lr
- thumb_func_end sub_81D17E4
-
thumb_func_start sub_81D17E8
sub_81D17E8: @ 81D17E8
push {r4,r5,lr}
diff --git a/data/event_scripts.s b/data/event_scripts.s
index 6668f0d1f..f1026d5ff 100644
--- a/data/event_scripts.s
+++ b/data/event_scripts.s
@@ -49,7 +49,7 @@ gStdScripts:: @ 81DC2A0
.4byte Std_5
.4byte Std_6
.4byte Std_ObtainDecoration
- .4byte Std_8
+ .4byte Std_RegisteredInMatchCall
.4byte Std_9
.4byte Std_10
@@ -4075,7 +4075,7 @@ Underwater3_EventScript_2742C0:: @ 82742C0
setescapewarp ROUTE_129, 255, 43, 20
return
-Std_8:: @ 82742C9
+Std_RegisteredInMatchCall:: @ 82742C9
buffertrainerclassname 0, VAR_0x8000
buffertrainername 1, VAR_0x8000
closemessage
diff --git a/data/match_call.s b/data/match_call.s
index fa8fa5a5a..15f28bc7a 100644
--- a/data/match_call.s
+++ b/data/match_call.s
@@ -343,9 +343,10 @@ gUnknown_08624F9C:: @ 8624F9C
.4byte 0xFFFFFFFF
gUnknown_08624FDC:: @ 8624FDC
- .byte 0x24, 3, 5, 0
- .2byte 0x6F, 0xD5
- .byte 0x5A, 3, 0x46, 0, 0xFF, 0xFF, 0xD5, 0
+ .2byte 0x0324, 0x05
+ .2byte 0x006F, 0xD5
+ .2byte 0x035A, 0x46
+ .2byte 0xFFFF, 0xD5
gUnknown_08624FEC:: @ 8624FEC
.byte 2, 0, 0xD6, 0
diff --git a/src/match_call.c b/src/match_call.c
index 58278bfbe..557710ea6 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -8,19 +8,73 @@
// Static type declarations
-typedef struct {
+struct MatchCallSusbtruct0 {
const u8 *text;
u16 v4;
u16 v6;
-} match_call_script_t;
+};
-typedef struct {
- u8 v0;
- u8 gender;
+struct MatchCallStructCommon {
+ u8 type;
+ u8 v1;
u16 flag;
- const u8 *name;
- const u8 *desc;
- match_call_script_t *script;
+};
+
+struct MatchCallStruct0 {
+ u8 type;
+ u8 v1;
+ u16 flag;
+ const u8 *v4;
+ const u8 *v8;
+ const struct MatchCallSusbtruct0 *vC;
+};
+
+struct MatchCallStruct1 {
+ u8 type;
+ u8 v1;
+ u16 flag;
+ u16 v4;
+};
+
+struct MatchCallSubstruct2 {
+ u16 v0;
+ u8 v2;
+};
+
+struct MatchCallStruct2 {
+ u8 type;
+ u8 v1;
+ u16 flag;
+ u16 v4;
+ const u8 *v8;
+ const u8 *vC;
+ const struct MatchCallSubstruct2 *v10;
+};
+
+struct MatchCallStruct3 {
+ u8 type;
+ u8 v1;
+ u16 flag;
+ const u8 *v4;
+ const u8 *v8;
+};
+
+struct MatchCallStruct4 {
+ u8 type;
+ u8 v1;
+ u16 flag;
+ const u8 *v4;
+ const u8 *v8;
+ const struct MatchCallSusbtruct0 *vC;
+};
+
+typedef union {
+ struct MatchCallStructCommon *common;
+ struct MatchCallStruct0 *type0;
+ struct MatchCallStruct1 *type1;
+ struct MatchCallStruct2 *type2;
+ struct MatchCallStruct3 *type3;
+ struct MatchCallStruct4 *type4;
} match_call_t;
// Static RAM declarations
@@ -29,15 +83,16 @@ typedef struct {
// .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 *);
+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);
// .text
-s32 sub_81D1574(const match_call_t *matchCall)
+s32 sub_81D1574(const match_call_t matchCall)
{
- switch (matchCall->v0)
+ switch (matchCall.common->type)
{
case 0:
default:
@@ -73,7 +128,7 @@ s32 sub_81D15CC(s32 trainerIdx)
bool32 sub_81D15F4(u32 idx)
{
- const match_call_t *matchCall;
+ match_call_t matchCall;
s32 v0;
if (idx > 20)
@@ -83,44 +138,44 @@ bool32 sub_81D15F4(u32 idx)
return gUnknown_086252FC[v0](matchCall);
}
-bool32 sub_81D1628(const match_call_t *matchCall)
+bool32 sub_81D1628(match_call_t matchCall)
{
- if (matchCall->flag == 0xffff)
+ if (matchCall.type0->flag == 0xffff)
return TRUE;
- return FlagGet(matchCall->flag);
+ return FlagGet(matchCall.type0->flag);
}
-bool32 sub_81D164C(const match_call_t *matchCall)
+bool32 sub_81D164C(match_call_t matchCall)
{
- if (matchCall->flag == 0xffff)
+ if (matchCall.type1->flag == 0xffff)
return TRUE;
- return FlagGet(matchCall->flag);
+ return FlagGet(matchCall.type1->flag);
}
-bool32 sub_81D1670(const match_call_t *matchCall)
+bool32 sub_81D1670(match_call_t matchCall)
{
- if (matchCall->flag == 0xffff)
+ if (matchCall.type2->flag == 0xffff)
return TRUE;
- return FlagGet(matchCall->flag);
+ return FlagGet(matchCall.type2->flag);
}
-bool32 sub_81D1694(const match_call_t *matchCall)
+bool32 sub_81D1694(match_call_t matchCall)
{
- if (matchCall->gender != gSaveBlock2Ptr->playerGender)
+ if (matchCall.type4->v1 != gSaveBlock2Ptr->playerGender)
return FALSE;
- if (matchCall->flag == 0xffff)
+ if (matchCall.type4->flag == 0xffff)
return TRUE;
- return FlagGet(matchCall->flag);
+ return FlagGet(matchCall.type4->flag);
}
-bool32 sub_81D16CC(const match_call_t *matchCall)
+bool32 sub_81D16CC(match_call_t matchCall)
{
- return FlagGet(matchCall->flag);
+ return FlagGet(matchCall.type3->flag);
}
u8 sub_81D16DC(u32 idx)
{
- const match_call_t *matchCall;
+ match_call_t matchCall;
s32 v0;
if (idx > 20)
@@ -129,3 +184,75 @@ u8 sub_81D16DC(u32 idx)
v0 = sub_81D1574(matchCall);
return gUnknown_08625310[v0](matchCall);
}
+
+u8 sub_81D1714(match_call_t matchCall)
+{
+ return matchCall.type0->v1;
+}
+
+u8 sub_81D1718(match_call_t matchCall)
+{
+ return matchCall.type1->v1;
+}
+
+u8 sub_81D171C(match_call_t matchCall)
+{
+ s32 i;
+
+ for (i = 0; matchCall.type2->v10[i].v0 != 0xffff; i++)
+ {
+ if (!FlagGet(matchCall.type2->v10[i].v0))
+ break;
+ }
+ return matchCall.type2->v10[i].v2;
+}
+
+u8 sub_81D1750(match_call_t matchCall)
+{
+ return 0xd5;
+}
+
+u8 sub_81D1754(match_call_t matchCall)
+{
+ return 0xd5;
+}
+
+bool32 sub_81D1758(u32 idx)
+{
+ match_call_t matchCall;
+ s32 v0;
+
+ if (idx > 20)
+ return 0;
+ matchCall = gUnknown_086252A8[idx];
+ v0 = sub_81D1574(matchCall);
+ return gUnknown_08625324[v0](matchCall);
+}
+
+bool32 sub_81D178C(match_call_t matchCall)
+{
+ return FALSE;
+}
+
+bool32 sub_81D1790(match_call_t matchCall)
+{
+ if (matchCall.type1->v4 > 0x48)
+ return FALSE;
+ return gSaveBlock1Ptr->trainerRematches[matchCall.type1->v4] ? TRUE : FALSE;
+}
+
+bool32 sub_81D17C0(match_call_t matchCall)
+{
+ return gSaveBlock1Ptr->trainerRematches[matchCall.type2->v4] ? TRUE : FALSE;
+}
+
+bool32 sub_81D17E0(match_call_t matchCall)
+{
+ return FALSE;
+}
+
+bool32 sub_81D17E4(match_call_t matchCall)
+{
+ return FALSE;
+}
+