From 5ac53054a83e5c8cab8fe72d8178d1d1b6257674 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 27 Oct 2017 20:39:02 -0400 Subject: [PATCH] sub_80EAAF4 --- asm/secret_base.s | 92 ----------------------------------------------- src/secret_base.c | 22 ++++++++++++ 2 files changed, 22 insertions(+), 92 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 047b3e1a1b..be07ad5bb6 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,98 +5,6 @@ .text - thumb_func_start sub_80EAAF4 -sub_80EAAF4: @ 80EAAF4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - sub sp, 0xA0 - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00001a9c - adds r7, r0, r1 - movs r2, 0x1 -_080EAB08: - adds r1, r2, 0x1 - lsls r0, r1, 24 - lsrs r5, r0, 24 - mov r9, r1 - cmp r5, 0x13 - bhi _080EAB84 - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 5 - adds r6, r0, r7 - movs r0, 0xC0 - mov r8, r0 -_080EAB20: - ldrb r0, [r6, 0x1] - mov r3, r8 - ands r3, r0 - cmp r3, 0 - bne _080EAB3E - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 5 - adds r0, r7 - ldrb r1, [r0, 0x1] - mov r0, r8 - ands r0, r1 - adds r4, r2, 0 - cmp r0, 0x40 - beq _080EAB56 -_080EAB3E: - cmp r3, 0x80 - bne _080EAB7A - lsls r2, r5, 2 - adds r0, r2, r5 - lsls r0, 5 - adds r0, r7 - ldrb r1, [r0, 0x1] - mov r0, r8 - ands r0, r1 - adds r4, r2, 0 - cmp r0, 0x80 - beq _080EAB7A -_080EAB56: - mov r0, sp - adds r1, r6, 0 - movs r2, 0xA0 - bl memcpy - adds r4, r5 - lsls r4, 5 - adds r4, r7 - adds r0, r6, 0 - adds r1, r4, 0 - movs r2, 0xA0 - bl memcpy - adds r0, r4, 0 - mov r1, sp - movs r2, 0xA0 - bl memcpy -_080EAB7A: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x13 - bls _080EAB20 -_080EAB84: - mov r1, r9 - lsls r0, r1, 24 - lsrs r2, r0, 24 - cmp r2, 0x12 - bls _080EAB08 - add sp, 0xA0 - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80EAAF4 - thumb_func_start sub_80EABA4 sub_80EABA4: @ 80EABA4 push {r4-r6,lr} diff --git a/src/secret_base.c b/src/secret_base.c index 83ae067a3c..ed4361f403 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1577,3 +1577,25 @@ u8 sub_80EAA64(struct SecretBaseRecord *base, u32 version, u32 language) } return 0; } + +void sub_80EAAF4(void) +{ + u8 i; + u8 j; + struct SecretBaseRecord base; + struct SecretBaseRecord *secretBases; + + secretBases = gSaveBlock1Ptr->secretBases; + for (i = 1; i < 19; i ++) + { + for (j = i + 1; j < 20; j ++) + { + if ((secretBases[i].sbr_field_1_6 == 0 && secretBases[j].sbr_field_1_6 == 1) || (secretBases[i].sbr_field_1_6 == 2 && secretBases[j].sbr_field_1_6 != 2)) + { + base = secretBases[i]; + secretBases[i] = secretBases[j]; + secretBases[j] = base; + } + } + } +}