From aa134d42fbcb7fe71cb701b792453dd75df529c8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 27 Oct 2017 20:32:05 -0400 Subject: [PATCH] sub_80EAA64 --- asm/secret_base.s | 73 ----------------------------------------------- src/secret_base.c | 42 +++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 73 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 2c87724d58..047b3e1a1b 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,79 +5,6 @@ .text - thumb_func_start sub_80EAA64 -sub_80EAA64: @ 80EAA64 - push {r4-r7,lr} - adds r5, r0, 0 - adds r6, r1, 0 - adds r7, r2, 0 - ldrb r0, [r5] - cmp r0, 0 - beq _080EAAEC - ldrb r0, [r5] - bl sub_80EA990 - lsls r0, 16 - lsrs r4, r0, 16 - asrs r2, r0, 16 - cmp r2, 0 - beq _080EAAEC - movs r0, 0x1 - negs r0, r0 - cmp r2, r0 - beq _080EAAC4 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 5 - adds r1, r0 - ldr r0, =0x00001a9d - adds r1, r0 - ldrb r1, [r1] - lsls r0, r1, 28 - lsrs r0, 28 - cmp r0, 0x1 - beq _080EAAEC - lsrs r0, r1, 6 - cmp r0, 0x2 - bne _080EAAB4 - ldrb r1, [r5, 0x1] - movs r0, 0xF - ands r0, r1 - cmp r0, 0x1 - bne _080EAAEC -_080EAAB4: - lsls r4, 24 - lsrs r4, 24 - b _080EAADC - .pool -_080EAAC4: - bl sub_80EA9D8 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - bne _080EAADC - bl sub_80EAA18 - lsls r0, 24 - lsrs r4, r0, 24 - cmp r4, 0 - beq _080EAAEC -_080EAADC: - adds r0, r4, 0 - adds r1, r5, 0 - adds r2, r6, 0 - adds r3, r7, 0 - bl sub_80EA828 - adds r0, r4, 0 - b _080EAAEE -_080EAAEC: - movs r0, 0 -_080EAAEE: - pop {r4-r7} - pop {r1} - bx r1 - thumb_func_end sub_80EAA64 - thumb_func_start sub_80EAAF4 sub_80EAAF4: @ 80EAAF4 push {r4-r7,lr} diff --git a/src/secret_base.c b/src/secret_base.c index ddef4938b8..83ae067a3c 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1535,3 +1535,45 @@ u8 sub_80EAA18(void) } return 0; } + +u8 sub_80EAA64(struct SecretBaseRecord *base, u32 version, u32 language) +{ + s16 sbId; + + if (base->secretBaseId == 0) + { + return 0; + } + sbId = sub_80EA990(base->secretBaseId); + if (sbId != 0) + { + if (sbId != -1) + { + if (gSaveBlock1Ptr->secretBases[sbId].sbr_field_1_0 == 1) + { + return 0; + } + if (gSaveBlock1Ptr->secretBases[sbId].sbr_field_1_6 != 2 || base->sbr_field_1_0 == 1) + { + sub_80EA828(sbId, base, version, language); + return sbId; + } + } + else + { + sbId = sub_80EA9D8(); + if (sbId != 0) + { + sub_80EA828(sbId, base, version, language); + return sbId; + } + sbId = sub_80EAA18(); + if (sbId != 0) + { + sub_80EA828(sbId, base, version, language); + return sbId; + } + } + } + return 0; +}