summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPikalaxALT <pikalaxalt@gmail.com>2018-03-03 13:22:38 -0500
committerPikalaxALT <pikalaxalt@gmail.com>2018-03-03 13:22:38 -0500
commit19a89f2362f06130e765805e4564d6c8ddcfc688 (patch)
treeb8b216bb030994e90c5da5037dcb01ce4cf30b87 /src
parentdf128cbfedcaf8a0da698ba9a9e62bed21721e1c (diff)
nonmatching sub_81D199C
Diffstat (limited to 'src')
-rw-r--r--src/match_call.c178
1 files changed, 171 insertions, 7 deletions
diff --git a/src/match_call.c b/src/match_call.c
index 8712cbf3a..fd92d8a9a 100644
--- a/src/match_call.c
+++ b/src/match_call.c
@@ -3,6 +3,8 @@
#include "global.h"
#include "battle_setup.h"
#include "event_data.h"
+#include "string_util.h"
+#include "gym_leader_rematch.h"
#define NELEMS(a) (s32)( sizeof (a) / sizeof (*(a)) )
@@ -10,8 +12,8 @@
typedef struct MatchCallSusbtruct0 {
const u8 *text;
- u16 v4;
- u16 v6;
+ u16 flag;
+ u16 flag2;
} match_call_sub0_t;
struct MatchCallStructCommon {
@@ -265,7 +267,7 @@ bool32 sub_81D178C(match_call_t matchCall)
bool32 sub_81D1790(match_call_t matchCall)
{
- if (matchCall.type1->v4 > 0x48)
+ if (matchCall.type1->v4 >= REMATCH_ELITE_FOUR_ENTRIES)
return FALSE;
return gSaveBlock1Ptr->trainerRematches[matchCall.type1->v4] ? TRUE : FALSE;
}
@@ -335,7 +337,7 @@ u32 sub_81D1854(u32 idx)
u32 i;
if (idx > 20)
- return ARRAY_COUNT(gRematchTable);
+ return REMATCH_TABLE_ENTRIES;
matchCall = gUnknown_086252A8[idx];
i = sub_81D1574(matchCall);
return gUnknown_0862534C[i](matchCall);
@@ -343,7 +345,7 @@ u32 sub_81D1854(u32 idx)
u32 sub_81D1888(match_call_t matchCall)
{
- return ARRAY_COUNT(gRematchTable);
+ return REMATCH_TABLE_ENTRIES;
}
u32 sub_81D188C(match_call_t matchCall)
@@ -358,12 +360,12 @@ u32 sub_81D1890(match_call_t matchCall)
u32 sub_81D1894(match_call_t matchCall)
{
- return ARRAY_COUNT(gRematchTable);
+ return REMATCH_TABLE_ENTRIES;
}
u32 sub_81D1898(match_call_t matchCall)
{
- return ARRAY_COUNT(gRematchTable);
+ return REMATCH_TABLE_ENTRIES;
}
void sub_81D189C(u32 idx, u8 *dest)
@@ -405,3 +407,165 @@ void sub_81D1914(match_call_t matchCall, u8 *dest)
{
sub_8197080(dest);
}
+
+void sub_81D1920(const match_call_sub0_t *sub0, u8 *dest)
+{
+ u32 i;
+ for (i = 0; sub0[i].text != NULL; i++)
+ ;
+ if (i)
+ i--;
+ while (i)
+ {
+ if (sub0[i].flag != 0xffff && FlagGet(sub0[i].flag) == TRUE)
+ break;
+ i--;
+ }
+ if (sub0[i].flag2 != 0xffff)
+ FlagSet(sub0[i].flag2);
+ StringExpandPlaceholders(dest, sub0[i].text);
+}
+
+#ifdef NONMATCHING
+// There's some weird upmerge going on that I cannot replicate at this time.
+void sub_81D199C(const match_call_sub0_t *sub0, u16 idx, u8 *dest)
+{
+ u32 i;
+ for (i = 0; sub0[i].text != NULL; i++)
+ {
+ if (sub0[i].flag == 0xfffe)
+ break;
+ if (sub0[i].flag == 0xffff && !FlagGet(sub0[i].flag))
+ break;
+ }
+ if (sub0[i].flag != 0xfffe)
+ {
+ if (i)
+ i--;
+ if (sub0[i].flag2 != 0xffff)
+ FlagSet(sub0[i].flag2);
+ StringExpandPlaceholders(dest, sub0[i].text);
+ }
+ else
+ {
+ if (!FlagGet(FLAG_SYS_GAME_CLEAR))
+ ;
+ else if (gSaveBlock1Ptr->trainerRematches[idx])
+ i += 2;
+ else if (CountBattledRematchTeams(idx) >= 2)
+ i += 3;
+ else
+ i++;
+ StringExpandPlaceholders(dest, sub0[i].text);
+ }
+}
+#else
+ASM_DIRECT void sub_81D199C(const match_call_sub0_t *sub0, u16 idx, u8 *dest)
+{
+ asm_unified("\tpush {r4-r7,lr}\n"
+ "\tmov r7, r10\n"
+ "\tmov r6, r9\n"
+ "\tmov r5, r8\n"
+ "\tpush {r5-r7}\n"
+ "\tadds r6, r0, 0\n"
+ "\tmov r10, r2\n"
+ "\tlsls r1, 16\n"
+ "\tlsrs r7, r1, 16\n"
+ "\tmovs r5, 0\n"
+ "\tldr r0, [r6]\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _081D19E6\n"
+ "\tldrh r0, [r6, 0x4]\n"
+ "\tldr r1, =0x0000fffe\n"
+ "\tcmp r0, r1\n"
+ "\tbeq _081D1A24\n"
+ "\tldr r0, =0x0000ffff\n"
+ "\tmov r9, r0\n"
+ "\tmov r8, r1\n"
+ "\tadds r4, r6, 0\n"
+ "_081D19C6:\n"
+ "\tldrh r0, [r4, 0x4]\n"
+ "\tcmp r0, r9\n"
+ "\tbeq _081D19D6\n"
+ "\tbl FlagGet\n"
+ "\tlsls r0, 24\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _081D19E6\n"
+ "_081D19D6:\n"
+ "\tadds r4, 0x8\n"
+ "\tadds r5, 0x1\n"
+ "\tldr r0, [r4]\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _081D19E6\n"
+ "\tldrh r0, [r4, 0x4]\n"
+ "\tcmp r0, r8\n"
+ "\tbne _081D19C6\n"
+ "_081D19E6:\n"
+ "\tlsls r0, r5, 3\n"
+ "\tadds r0, r6\n"
+ "\tldrh r1, [r0, 0x4]\n"
+ "\tldr r0, =0x0000fffe\n"
+ "\tcmp r1, r0\n"
+ "\tbeq _081D1A24\n"
+ "\tcmp r5, 0\n"
+ "\tbeq _081D19F8\n"
+ "\tsubs r5, 0x1\n"
+ "_081D19F8:\n"
+ "\tlsls r0, r5, 3\n"
+ "\tadds r4, r0, r6\n"
+ "\tldrh r1, [r4, 0x6]\n"
+ "\tldr r0, =0x0000ffff\n"
+ "\tcmp r1, r0\n"
+ "\tbeq _081D1A0A\n"
+ "\tadds r0, r1, 0\n"
+ "\tbl FlagSet\n"
+ "_081D1A0A:\n"
+ "\tldr r1, [r4]\n"
+ "\tmov r0, r10\n"
+ "\tbl StringExpandPlaceholders\n"
+ "\tb _081D1A5C\n"
+ "\t.pool\n"
+ "_081D1A1C:\n"
+ "\tadds r5, 0x2\n"
+ "\tb _081D1A50\n"
+ "_081D1A20:\n"
+ "\tadds r5, 0x3\n"
+ "\tb _081D1A50\n"
+ "_081D1A24:\n"
+ "\tldr r0, =0x00000864\n"
+ "\tbl FlagGet\n"
+ "\tlsls r0, 24\n"
+ "\tcmp r0, 0\n"
+ "\tbeq _081D1A50\n"
+ "\tldr r0, =gSaveBlock1Ptr\n"
+ "\tldr r0, [r0]\n"
+ "\tldr r1, =0x000009ca\n"
+ "\tadds r0, r1\n"
+ "\tadds r0, r7\n"
+ "\tldrb r0, [r0]\n"
+ "\tcmp r0, 0\n"
+ "\tbne _081D1A1C\n"
+ "\tadds r0, r7, 0\n"
+ "\tbl CountBattledRematchTeams\n"
+ "\tlsls r0, 16\n"
+ "\tlsrs r0, 16\n"
+ "\tcmp r0, 0x1\n"
+ "\tbhi _081D1A20\n"
+ "\tadds r5, 0x1\n"
+ "_081D1A50:\n"
+ "\tlsls r0, r5, 3\n"
+ "\tadds r0, r6\n"
+ "\tldr r1, [r0]\n"
+ "\tmov r0, r10\n"
+ "\tbl StringExpandPlaceholders\n"
+ "_081D1A5C:\n"
+ "\tpop {r3-r5}\n"
+ "\tmov r8, r3\n"
+ "\tmov r9, r4\n"
+ "\tmov r10, r5\n"
+ "\tpop {r4-r7}\n"
+ "\tpop {r0}\n"
+ "\tbx r0\n"
+ "\t.pool");
+}
+#endif