sub_800E3A8

This commit is contained in:
PikalaxALT 2017-12-04 19:10:37 -05:00
parent feb0d13534
commit 0b58905eea
3 changed files with 79 additions and 228 deletions

View File

@ -7,233 +7,6 @@
@ file boundary?
thumb_func_start sub_800E378
sub_800E378: @ 800E378
push {lr}
stm r0!, {r1}
adds r1, r2, 0
bl StringCopy
pop {r0}
bx r0
thumb_func_end sub_800E378
thumb_func_start sub_800E388
sub_800E388: @ 800E388
push {lr}
adds r2, r0, 0
movs r1, 0
_0800E38E:
adds r0, r2, r1
ldrb r0, [r0]
cmp r0, 0
beq _0800E39A
movs r0, 0x1
b _0800E3A2
_0800E39A:
adds r1, 0x1
cmp r1, 0x7
ble _0800E38E
movs r0, 0
_0800E3A2:
pop {r1}
bx r1
thumb_func_end sub_800E388
thumb_func_start sub_800E3A8
sub_800E3A8: @ 800E3A8
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x20
ldr r0, =gWirelessCommType
ldrb r0, [r0]
cmp r0, 0
bne _0800E3BE
b _0800E520
_0800E3BE:
movs r0, 0xF0
bl AllocZeroed
str r0, [sp, 0x14]
movs r4, 0
b _0800E434
.pool
_0800E3D0:
lsls r2, r4, 2
mov r0, sp
adds r1, r0, r2
movs r0, 0x1
negs r0, r0
str r0, [r1]
movs r5, 0
mov r8, r2
lsls r0, r4, 3
adds r1, r4, 0x1
mov r9, r1
subs r0, r4
lsls r0, 2
str r0, [sp, 0x1C]
ldr r7, =gLinkPlayers + 8
mov r10, r7
ldr r6, =0x00003b98
movs r4, 0
mov r0, r10
subs r0, 0x4
ldr r1, [sp, 0x1C]
adds r3, r1, r0
_0800E3FC:
ldrh r1, [r3]
ldr r0, =gSaveBlock1Ptr
ldr r2, [r0]
ldr r7, =0x00003b98
adds r0, r2, r7
adds r0, r4
ldr r0, [r0]
cmp r1, r0
bne _0800E428
adds r1, r2, r6
adds r1, 0x4
ldr r0, [sp, 0x1C]
add r0, r10
str r3, [sp, 0x18]
bl StringCompare
ldr r3, [sp, 0x18]
cmp r0, 0
bne _0800E428
mov r0, sp
add r0, r8
str r5, [r0]
_0800E428:
adds r6, 0xC
adds r4, 0xC
adds r5, 0x1
cmp r5, 0x13
ble _0800E3FC
mov r4, r9
_0800E434:
bl GetLinkPlayerCount
lsls r0, 24
lsrs r0, 24
cmp r4, r0
blt _0800E3D0
movs r0, 0
mov r8, r0
movs r4, 0
mov r7, sp
movs r5, 0
ldr r6, [sp, 0x14]
b _0800E4AC
.pool
_0800E45C:
bl GetMultiplayerId
lsls r0, 24
lsrs r0, 24
cmp r4, r0
beq _0800E4A6
ldr r2, =gLinkPlayers
adds r0, r5, r2
ldrh r0, [r0, 0x1A]
cmp r0, 0x1
beq _0800E4A6
adds r0, r2, 0x4
adds r0, r5, r0
ldrh r1, [r0]
adds r2, 0x8
adds r2, r5, r2
adds r0, r6, 0
bl sub_800E378
ldr r2, [r7]
cmp r2, 0
blt _0800E4A0
ldr r0, =gSaveBlock1Ptr
ldr r1, [r0]
lsls r0, r2, 1
adds r0, r2
lsls r0, 2
adds r0, r1
ldr r1, =0x00003b9c
adds r0, r1
movs r1, 0
movs r2, 0x8
bl memset
_0800E4A0:
adds r6, 0xC
movs r0, 0x1
add r8, r0
_0800E4A6:
adds r7, 0x4
adds r5, 0x1C
adds r4, 0x1
_0800E4AC:
bl GetLinkPlayerCount
lsls r0, 24
lsrs r0, 24
cmp r4, r0
blt _0800E45C
movs r4, 0
ldr r1, =gSaveBlock1Ptr
mov r9, r1
ldr r6, =0x00003b98
movs r7, 0
mov r1, r8
lsls r0, r1, 1
add r0, r8
lsls r0, 2
ldr r1, [sp, 0x14]
adds r5, r0, r1
_0800E4CE:
mov r1, r9
ldr r0, [r1]
adds r0, r6
adds r0, 0x4
bl sub_800E388
cmp r0, 0
beq _0800E500
mov r0, r9
ldr r2, [r0]
ldr r1, =0x00003b98
adds r0, r2, r1
adds r0, r7
ldr r1, [r0]
adds r2, r6
adds r2, 0x4
adds r0, r5, 0
bl sub_800E378
adds r5, 0xC
movs r0, 0x1
add r8, r0
mov r1, r8
cmp r1, 0x13
bgt _0800E50A
_0800E500:
adds r6, 0xC
adds r7, 0xC
adds r4, 0x1
cmp r4, 0x13
ble _0800E4CE
_0800E50A:
ldr r0, =gSaveBlock1Ptr
ldr r0, [r0]
ldr r7, =0x00003b98
adds r0, r7
ldr r1, [sp, 0x14]
movs r2, 0xF0
bl memcpy
ldr r0, [sp, 0x14]
bl Free
_0800E520:
add sp, 0x20
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r0}
bx r0
.pool
thumb_func_end sub_800E3A8
thumb_func_start sub_800E540
sub_800E540: @ 800E540
push {r4-r7,lr}

View File

@ -562,6 +562,11 @@ struct WaldaPhrase
bool8 patternUnlocked;
};
struct UnkSaveSubstruct_3b98 {
u32 trainerId;
u8 trainerName[8];
};
struct SaveBlock1
{
/*0x00*/ struct Coords16 pos;
@ -646,7 +651,9 @@ struct SaveBlock1
/*0x3B14*/ struct RecordMixingGift recordMixingGift;
/*0x3B24*/ u8 seen2[52];
/*0x3B58*/ LilycoveLady lilycoveLady;
/*0x3B88*/ u8 filler_3B88[0x1E8];
/*0x3B88*/ u8 filler_3B88[0x10];
/*0x3B98*/ struct UnkSaveSubstruct_3b98 unk_3B98[20];
/*0x3C88*/ u8 filler_3C88[0xE8];
/*0x3D70*/ struct WaldaPhrase waldaPhrase;
// sizeof: 0x3D88
};

View File

@ -1,9 +1,11 @@
// Includes
#include "global.h"
#include "malloc.h"
#include "rng.h"
#include "decompress.h"
#include "text.h"
#include "string_util.h"
#include "event_data.h"
#include "link.h"
#include "librfu.h"
@ -2221,3 +2223,72 @@ void sub_800E174(void)
}
}
}
void sub_800E378(struct UnkSaveSubstruct_3b98 *dest, u32 trainerId, const u8 *name)
{
dest->trainerId = trainerId;
StringCopy(dest->trainerName, name);
}
bool32 sub_800E388(const u8 *name)
{
int i;
for (i = 0; i < 8; i++)
{
if (name[i] != 0)
{
return TRUE;
}
}
return FALSE;
}
void sub_800E3A8(void)
{
if (gWirelessCommType != 0)
{
int i;
int j;
int cnt;
int sp0[5];
struct UnkSaveSubstruct_3b98 *sp14 = calloc(20, sizeof(struct UnkSaveSubstruct_3b98));
for (i = 0; i < GetLinkPlayerCount(); i++)
{
sp0[i] = -1;
for (j = 0; j < 20; j++)
{
if ((u16)gLinkPlayers[i].trainerId == gSaveBlock1Ptr->unk_3B98[j].trainerId && StringCompare(gLinkPlayers[i].name, gSaveBlock1Ptr->unk_3B98[j].trainerName) == 0)
{
sp0[i] = j;
}
}
}
cnt = 0;
for (i = 0; i < GetLinkPlayerCount(); i++)
{
if (i != GetMultiplayerId() && gLinkPlayers[i].language != LANGUAGE_JAPANESE)
{
sub_800E378(&sp14[cnt], (u16)gLinkPlayers[i].trainerId, gLinkPlayers[i].name);
if (sp0[i] >= 0)
{
memset(gSaveBlock1Ptr->unk_3B98[sp0[i]].trainerName, 0, 8);
}
cnt++;
}
}
for (i = 0; i < 20; i++)
{
if (sub_800E388(gSaveBlock1Ptr->unk_3B98[i].trainerName))
{
sub_800E378(&sp14[cnt], gSaveBlock1Ptr->unk_3B98[i].trainerId, gSaveBlock1Ptr->unk_3B98[i].trainerName);
if (++cnt >= 20)
{
break;
}
}
}
memcpy(gSaveBlock1Ptr->unk_3B98, sp14, 20 * sizeof(struct UnkSaveSubstruct_3b98));
free(sp14);
}
}