From 3d01d999c6a93778c204f5c3978f388b870ac2bb Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 27 Oct 2017 21:00:59 -0400 Subject: [PATCH] sub_80EAD14 --- asm/secret_base.s | 70 ----------------------------------------------- src/secret_base.c | 33 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 70 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 19ec41be5..381189e7e 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,76 +5,6 @@ .text - thumb_func_start sub_80EAD14 -sub_80EAD14: @ 80EAD14 - push {r4-r7,lr} - mov r7, r8 - push {r7} - adds r6, r0, 0 - mov r8, r1 - lsls r2, 24 - lsrs r7, r2, 24 - movs r5, 0 -_080EAD24: - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 5 - mov r1, r8 - adds r4, r0, r1 - ldrb r0, [r4] - cmp r0, 0 - beq _080EAD7E - adds r0, r6, 0 - adds r1, r4, 0 - bl sub_80EA950 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _080EAD7E - cmp r7, 0 - bne _080EAD50 - adds r0, r4, 0 - bl ClearSecretBase - b _080EAD88 -_080EAD50: - ldrh r0, [r6, 0xE] - ldrh r3, [r4, 0xE] - cmp r0, r3 - bls _080EAD60 - adds r0, r4, 0 - bl ClearSecretBase - b _080EAD88 -_080EAD60: - ldrb r0, [r6, 0x1] - lsls r0, 28 - lsrs r0, 28 - ldrb r1, [r4, 0x1] - movs r3, 0x10 - negs r3, r3 - adds r2, r3, 0 - ands r1, r2 - orrs r1, r0 - strb r1, [r4, 0x1] - adds r0, r6, 0 - bl ClearSecretBase - movs r0, 0x1 - b _080EAD8A -_080EAD7E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x13 - bls _080EAD24 -_080EAD88: - movs r0, 0 -_080EAD8A: - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80EAD14 - thumb_func_start sub_80EAD94 sub_80EAD94: @ 80EAD94 push {r4-r7,lr} diff --git a/src/secret_base.c b/src/secret_base.c index 508ea429f..2d74c2546 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1679,3 +1679,36 @@ void DeleteFirstOldBaseFromPlayerInRecordMixingFriendsRecords(struct SecretBaseR } } } + +bool8 sub_80EAD14(struct SecretBaseRecord *base, struct SecretBaseRecord *secretBases, u8 c) +{ + u8 i; + + for (i = 0; i < 20; i++) + { + if (secretBases[i].secretBaseId != 0) + { + if (sub_80EA950(base, &secretBases[i]) == TRUE) + { + if (c == 0) + { + ClearSecretBase(&secretBases[i]); + return FALSE; + } + + if (base->sbr_field_e > secretBases[i].sbr_field_e) + { + ClearSecretBase(&secretBases[i]); + return FALSE; + } + + secretBases[i].sbr_field_1_0 = base->sbr_field_1_0; + + ClearSecretBase(base); + return TRUE; + } + } + } + + return FALSE; +}