From f61795ab47f77cb3b55378ee75f445897901149b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 27 Oct 2017 08:38:54 -0400 Subject: [PATCH] through sub_80EA990 --- asm/secret_base.s | 148 ---------------------------------------------- src/secret_base.c | 50 ++++++++++++++++ 2 files changed, 50 insertions(+), 148 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 1a570aac35..5e919e76c3 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,154 +5,6 @@ .text - thumb_func_start sub_80EA8D4 -sub_80EA8D4: @ 80EA8D4 - push {r4,lr} - movs r2, 0 - adds r4, r0, 0 - adds r4, 0x9 - adds r3, r1, 0 - adds r3, 0x9 -_080EA8E0: - adds r0, r4, r2 - adds r1, r3, r2 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - beq _080EA8F0 - movs r0, 0 - b _080EA8FC -_080EA8F0: - adds r0, r2, 0x1 - lsls r0, 24 - lsrs r2, r0, 24 - cmp r2, 0x3 - bls _080EA8E0 - movs r0, 0x1 -_080EA8FC: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80EA8D4 - - thumb_func_start sub_80EA904 -sub_80EA904: @ 80EA904 - push {r4-r6,lr} - adds r6, r0, 0 - adds r5, r1, 0 - movs r3, 0 - ldrb r0, [r6, 0x2] - cmp r0, 0xFF - bne _080EA918 - ldrb r0, [r5, 0x2] - cmp r0, 0xFF - beq _080EA946 -_080EA918: - adds r2, r6, 0x2 - adds r0, r2, r3 - adds r4, r5, 0x2 - adds r1, r4, r3 - ldrb r0, [r0] - ldrb r1, [r1] - cmp r0, r1 - beq _080EA92C - movs r0, 0 - b _080EA948 -_080EA92C: - adds r0, r3, 0x1 - lsls r0, 24 - lsrs r3, r0, 24 - cmp r3, 0x6 - bhi _080EA946 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r0, 0xFF - bne _080EA918 - adds r0, r4, r3 - ldrb r0, [r0] - cmp r0, 0xFF - bne _080EA918 -_080EA946: - movs r0, 0x1 -_080EA948: - pop {r4-r6} - pop {r1} - bx r1 - thumb_func_end sub_80EA904 - - thumb_func_start sub_80EA950 -sub_80EA950: @ 80EA950 - push {r4,r5,lr} - adds r4, r0, 0 - adds r5, r1, 0 - ldrb r2, [r4, 0x1] - movs r0, 0x10 - adds r1, r0, 0 - ands r1, r2 - ldrb r2, [r5, 0x1] - ands r0, r2 - cmp r1, r0 - bne _080EA986 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80EA8D4 - lsls r0, 24 - cmp r0, 0 - beq _080EA986 - adds r0, r4, 0 - adds r1, r5, 0 - bl sub_80EA904 - lsls r0, 24 - cmp r0, 0 - beq _080EA986 - movs r0, 0x1 - b _080EA988 -_080EA986: - movs r0, 0 -_080EA988: - pop {r4,r5} - pop {r1} - bx r1 - thumb_func_end sub_80EA950 - - thumb_func_start sub_80EA990 -sub_80EA990: @ 80EA990 - push {r4,lr} - lsls r0, 24 - lsrs r3, r0, 24 - movs r1, 0 - ldr r0, =gSaveBlock1Ptr - ldr r2, [r0] - ldr r4, =0x00001a9c -_080EA99E: - lsls r0, r1, 16 - asrs r1, r0, 16 - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 5 - adds r0, r2, r0 - adds r0, r4 - ldrb r0, [r0] - cmp r0, r3 - bne _080EA9C0 - adds r0, r1, 0 - b _080EA9D0 - .pool -_080EA9C0: - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - asrs r0, 16 - cmp r0, 0x13 - ble _080EA99E - movs r0, 0x1 - negs r0, r0 -_080EA9D0: - pop {r4} - pop {r1} - bx r1 - thumb_func_end sub_80EA990 - thumb_func_start sub_80EA9D8 sub_80EA9D8: @ 80EA9D8 push {r4,lr} diff --git a/src/secret_base.c b/src/secret_base.c index 68b66a6eff..b30c913b21 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1457,3 +1457,53 @@ void sub_80EA828(u8 sbId, struct SecretBaseRecord *base, u32 version, u32 langua } } } + +bool8 sub_80EA8D4(struct SecretBaseRecord *sbr1, struct SecretBaseRecord *sbr2) +{ + u8 i; + for (i = 0; i < 4; i ++) + { + if (sbr1->trainerId[i] != sbr2->trainerId[i]) + { + return FALSE; + } + } + return TRUE; +} + +bool8 sub_80EA904(struct SecretBaseRecord *sbr1, struct SecretBaseRecord *sbr2) +{ + u8 i; + + for (i = 0; i < OT_NAME_LENGTH && (sbr1->trainerName[i] != EOS || sbr2->trainerName[i] != EOS); i++) + { + if (sbr1->trainerName[i] != sbr2->trainerName[i]) + { + return FALSE; + } + } + return TRUE; +} + +bool8 sub_80EA950(struct SecretBaseRecord *sbr1, struct SecretBaseRecord *sbr2) +{ + if (sbr1->gender == sbr2->gender && sub_80EA8D4(sbr1, sbr2) && sub_80EA904(sbr1, sbr2)) + { + return TRUE; + } + return FALSE; +} + +s16 sub_80EA990(u8 sbId) +{ + s16 i; + + for (i = 0; i < 20; i ++) + { + if (gSaveBlock1Ptr->secretBases[i].secretBaseId == sbId) + { + return i; + } + } + return -1; +}