nonmatching sub_81D199C
This commit is contained in:
parent
df128cbfed
commit
19a89f2362
2 changed files with 171 additions and 183 deletions
176
asm/match_call.s
176
asm/match_call.s
|
@ -5,182 +5,6 @@
|
|||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_81D1920
|
||||
sub_81D1920: @ 81D1920
|
||||
push {r4-r7,lr}
|
||||
mov r7, r9
|
||||
mov r6, r8
|
||||
push {r6,r7}
|
||||
adds r6, r0, 0
|
||||
mov r9, r1
|
||||
movs r5, 0
|
||||
ldr r0, [r6]
|
||||
cmp r0, 0
|
||||
beq _081D1940
|
||||
adds r1, r6, 0
|
||||
_081D1936:
|
||||
adds r1, 0x8
|
||||
adds r5, 0x1
|
||||
ldr r0, [r1]
|
||||
cmp r0, 0
|
||||
bne _081D1936
|
||||
_081D1940:
|
||||
cmp r5, 0
|
||||
beq _081D1946
|
||||
subs r5, 0x1
|
||||
_081D1946:
|
||||
ldr r0, =0x0000ffff
|
||||
mov r8, r0
|
||||
lsls r0, r5, 3
|
||||
adds r0, 0x4
|
||||
adds r4, r0, r6
|
||||
b _081D195C
|
||||
.pool
|
||||
_081D1958:
|
||||
subs r4, 0x8
|
||||
subs r5, 0x1
|
||||
_081D195C:
|
||||
lsls r7, r5, 3
|
||||
cmp r5, 0
|
||||
beq _081D1974
|
||||
ldrh r0, [r4]
|
||||
cmp r0, r8
|
||||
beq _081D1958
|
||||
bl FlagGet
|
||||
lsls r0, 24
|
||||
lsrs r0, 24
|
||||
cmp r0, 0x1
|
||||
bne _081D1958
|
||||
_081D1974:
|
||||
adds r4, r7, r6
|
||||
ldrh r1, [r4, 0x6]
|
||||
ldr r0, =0x0000ffff
|
||||
cmp r1, r0
|
||||
beq _081D1984
|
||||
adds r0, r1, 0
|
||||
bl FlagSet
|
||||
_081D1984:
|
||||
ldr r1, [r4]
|
||||
mov r0, r9
|
||||
bl StringExpandPlaceholders
|
||||
pop {r3,r4}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_81D1920
|
||||
|
||||
thumb_func_start sub_81D199C
|
||||
sub_81D199C: @ 81D199C
|
||||
push {r4-r7,lr}
|
||||
mov r7, r10
|
||||
mov r6, r9
|
||||
mov r5, r8
|
||||
push {r5-r7}
|
||||
adds r6, r0, 0
|
||||
mov r10, r2
|
||||
lsls r1, 16
|
||||
lsrs r7, r1, 16
|
||||
movs r5, 0
|
||||
ldr r0, [r6]
|
||||
cmp r0, 0
|
||||
beq _081D19E6
|
||||
ldrh r0, [r6, 0x4]
|
||||
ldr r1, =0x0000fffe
|
||||
cmp r0, r1
|
||||
beq _081D1A24
|
||||
ldr r0, =0x0000ffff
|
||||
mov r9, r0
|
||||
mov r8, r1
|
||||
adds r4, r6, 0
|
||||
_081D19C6:
|
||||
ldrh r0, [r4, 0x4]
|
||||
cmp r0, r9
|
||||
beq _081D19D6
|
||||
bl FlagGet
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _081D19E6
|
||||
_081D19D6:
|
||||
adds r4, 0x8
|
||||
adds r5, 0x1
|
||||
ldr r0, [r4]
|
||||
cmp r0, 0
|
||||
beq _081D19E6
|
||||
ldrh r0, [r4, 0x4]
|
||||
cmp r0, r8
|
||||
bne _081D19C6
|
||||
_081D19E6:
|
||||
lsls r0, r5, 3
|
||||
adds r0, r6
|
||||
ldrh r1, [r0, 0x4]
|
||||
ldr r0, =0x0000fffe
|
||||
cmp r1, r0
|
||||
beq _081D1A24
|
||||
cmp r5, 0
|
||||
beq _081D19F8
|
||||
subs r5, 0x1
|
||||
_081D19F8:
|
||||
lsls r0, r5, 3
|
||||
adds r4, r0, r6
|
||||
ldrh r1, [r4, 0x6]
|
||||
ldr r0, =0x0000ffff
|
||||
cmp r1, r0
|
||||
beq _081D1A0A
|
||||
adds r0, r1, 0
|
||||
bl FlagSet
|
||||
_081D1A0A:
|
||||
ldr r1, [r4]
|
||||
mov r0, r10
|
||||
bl StringExpandPlaceholders
|
||||
b _081D1A5C
|
||||
.pool
|
||||
_081D1A1C:
|
||||
adds r5, 0x2
|
||||
b _081D1A50
|
||||
_081D1A20:
|
||||
adds r5, 0x3
|
||||
b _081D1A50
|
||||
_081D1A24:
|
||||
ldr r0, =0x00000864
|
||||
bl FlagGet
|
||||
lsls r0, 24
|
||||
cmp r0, 0
|
||||
beq _081D1A50
|
||||
ldr r0, =gSaveBlock1Ptr
|
||||
ldr r0, [r0]
|
||||
ldr r1, =0x000009ca
|
||||
adds r0, r1
|
||||
adds r0, r7
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
bne _081D1A1C
|
||||
adds r0, r7, 0
|
||||
bl CountBattledRematchTeams
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
cmp r0, 0x1
|
||||
bhi _081D1A20
|
||||
adds r5, 0x1
|
||||
_081D1A50:
|
||||
lsls r0, r5, 3
|
||||
adds r0, r6
|
||||
ldr r1, [r0]
|
||||
mov r0, r10
|
||||
bl StringExpandPlaceholders
|
||||
_081D1A5C:
|
||||
pop {r3-r5}
|
||||
mov r8, r3
|
||||
mov r9, r4
|
||||
mov r10, r5
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_81D199C
|
||||
|
||||
thumb_func_start sub_81D1A78
|
||||
sub_81D1A78: @ 81D1A78
|
||||
push {r4-r6,lr}
|
||||
|
|
178
src/match_call.c
178
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
|
||||
|
|
Loading…
Reference in a new issue