From bef07a4bba7554c01086f2d28b9f42528fd34848 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Fri, 27 Oct 2017 08:29:58 -0400 Subject: [PATCH] sub_80EA828 --- asm/secret_base.s | 86 ----------------------------------------------- src/secret_base.c | 28 +++++++++++++++ 2 files changed, 28 insertions(+), 86 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 45d1edb4d..1a570aac3 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,92 +5,6 @@ .text - thumb_func_start sub_80EA828 -sub_80EA828: @ 80EA828 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - adds r7, r2, 0 - mov r8, r3 - lsls r0, 24 - lsrs r5, r0, 24 - ldr r6, =gSaveBlock1Ptr - ldr r0, [r6] - lsls r2, r5, 2 - adds r2, r5 - lsls r4, r2, 5 - adds r0, r4 - ldr r2, =0x00001a9c - mov r9, r2 - add r0, r9 - movs r2, 0xA0 - bl memcpy - ldr r2, [r6] - adds r2, r4 - ldr r0, =0x00001a9d - adds r2, r0 - ldrb r1, [r2] - movs r0, 0x3F - ands r0, r1 - movs r1, 0x80 - orrs r0, r1 - strb r0, [r2] - subs r0, r7, 0x1 - cmp r0, 0x1 - bhi _080EA876 - ldr r0, [r6] - adds r0, r4 - ldr r1, =0x00001aa9 - adds r0, r1 - movs r1, 0x2 - strb r1, [r0] -_080EA876: - cmp r7, 0x3 - bne _080EA8B8 - mov r2, r8 - cmp r2, 0x1 - bne _080EA8B8 - mov r1, r9 - adds r0, r4, r1 - ldr r1, [r6] - adds r1, r0 - adds r2, r1, 0x2 - movs r3, 0 - ldrb r0, [r1, 0x2] - cmp r0, 0xFF - beq _080EA8A0 -_080EA892: - adds r3, 0x1 - cmp r3, 0x6 - bgt _080EA8A0 - adds r0, r2, r3 - ldrb r0, [r0] - cmp r0, 0xFF - bne _080EA892 -_080EA8A0: - cmp r3, 0x5 - ble _080EA8B8 - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 5 - adds r1, r0 - ldr r2, =0x00001aa9 - adds r1, r2 - movs r0, 0x2 - strb r0, [r1] -_080EA8B8: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80EA828 - thumb_func_start sub_80EA8D4 sub_80EA8D4: @ 80EA8D4 push {r4,lr} diff --git a/src/secret_base.c b/src/secret_base.c index 522d59f31..68b66a6ef 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -1429,3 +1429,31 @@ void sub_80EA3E4(u8 taskId) break; } } + +void sub_80EA828(u8 sbId, struct SecretBaseRecord *base, u32 version, u32 language) +{ + int strlen; + u8 *name; + + gSaveBlock1Ptr->secretBases[sbId] = *base; + gSaveBlock1Ptr->secretBases[sbId].sbr_field_1_6 = 2; + if (version == VERSION_SAPPHIRE || version == VERSION_RUBY) + { + gSaveBlock1Ptr->secretBases[sbId].language = LANGUAGE_ENGLISH; + } + if (version == VERSION_EMERALD && language == LANGUAGE_JAPANESE) + { + name = gSaveBlock1Ptr->secretBases[sbId].trainerName; + for (strlen = 0; strlen < 7; strlen ++) + { + if (name[strlen] == EOS) + { + break; + } + } + if (strlen > 5) + { + gSaveBlock1Ptr->secretBases[sbId].language = LANGUAGE_ENGLISH; + } + } +}