diff --git a/asm/secret_base.s b/asm/secret_base.s index 837928764c..5b5912d6d6 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,72 +5,6 @@ .text - thumb_func_start sub_80E8B6C -sub_80E8B6C: @ 80E8B6C - push {r4,lr} - ldr r0, =gScriptResult - movs r1, 0 - strh r1, [r0] - movs r3, 0 - adds r4, r0, 0 - b _080E8B86 - .pool -_080E8B80: - adds r0, r3, 0x1 - lsls r0, 16 - lsrs r3, r0, 16 -_080E8B86: - cmp r3, 0x13 - bhi _080E8BB0 - ldr r2, =gUnknown_0203A01C - ldr r0, =gSaveBlock1Ptr - ldr r1, [r0] - lsls r0, r3, 2 - adds r0, r3 - lsls r0, 5 - adds r1, r0 - ldr r0, =0x00001a9c - adds r1, r0 - ldrb r0, [r2] - ldrb r1, [r1] - cmp r0, r1 - bne _080E8B80 - movs r0, 0x1 - strh r0, [r4] - ldr r0, =0x00004054 - adds r1, r3, 0 - bl VarSet -_080E8BB0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E8B6C - - thumb_func_start sub_80E8BC8 -sub_80E8BC8: @ 80E8BC8 - push {lr} - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00001a9c - adds r0, r1 - ldrb r1, [r0] - cmp r1, 0 - beq _080E8BEC - ldr r1, =gScriptResult - movs r0, 0x1 - strh r0, [r1] - b _080E8BF0 - .pool -_080E8BEC: - ldr r0, =gScriptResult - strh r1, [r0] -_080E8BF0: - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E8BC8 - thumb_func_start sub_80E8BF8 sub_80E8BF8: @ 80E8BF8 push {r4,lr} @@ -375,7 +309,7 @@ sub_80E8E18: @ 80E8E18 push {r6} ldr r2, =gSaveBlock1Ptr ldr r0, [r2] - ldr r1, =gUnknown_0203A01C + ldr r1, =sCurSecretBaseId ldrb r1, [r1] ldr r3, =0x00001a9c adds r0, r3 @@ -548,7 +482,7 @@ _080E8F8A: thumb_func_start sub_80E8F9C sub_80E8F9C: @ 80E8F9C push {lr} - ldr r0, =gUnknown_0203A01C + ldr r0, =sCurSecretBaseId ldrb r0, [r0] movs r1, 0xA bl __udivsi3 @@ -767,7 +701,7 @@ sub_80E916C: @ 80E916C ands r0, r1 cmp r0, 0 bne _080E91D4 - ldr r0, =gUnknown_0203A01C + ldr r0, =sCurSecretBaseId ldrb r0, [r0] movs r1, 0xA bl __udivsi3 @@ -1302,7 +1236,7 @@ sub_80E9608: @ 80E9608 ldrb r0, [r4, 0x3] cmp r3, r0 bge _080E9660 - ldr r6, =gUnknown_0203A01C + ldr r6, =sCurSecretBaseId _080E9618: lsls r3, 16 asrs r1, r3, 16 @@ -1456,7 +1390,7 @@ sub_80E9744: @ 80E9744 ldr r0, [r0] ldr r1, =0x00001a9c adds r0, r1 - ldr r1, =gUnknown_0203A01C + ldr r1, =sCurSecretBaseId ldrb r0, [r0] ldrb r1, [r1] cmp r0, r1 diff --git a/include/global.h b/include/global.h index 8860b4ae39..3ac8fa6959 100644 --- a/include/global.h +++ b/include/global.h @@ -236,12 +236,12 @@ extern struct SaveBlock2 *gSaveBlock2Ptr; struct SecretBaseRecord { - /*ID?*/ /*0x1A9C*/ u8 sbr_field_0; + /*0x1A9C*/ u8 secretBaseId; /*0x1A9D*/ u8 sbr_field_1_0:4; /*0x1A9D*/ u8 gender:1; /*0x1A9D*/ u8 sbr_field_1_5:1; /*0x1A9D*/ u8 sbr_field_1_6:2; - /*0x1A9E*/ u8 trainerName[7]; // 0xFF bytes? + /*0x1A9E*/ u8 trainerName[OT_NAME_LENGTH]; /*0x1AA5*/ u8 trainerId[4]; // byte 0 is used for determining trainer class /*0x1AA9*/ u8 language; /*0x1AAA*/ u16 sbr_field_e; diff --git a/src/secret_base.c b/src/secret_base.c index 5c20b9b183..9398e94283 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -16,7 +16,7 @@ struct SecretBaseListMenuBuffer { }; // Static RAM declarations -EWRAM_DATA u8 gUnknown_0203A01C = 0; +EWRAM_DATA u8 sCurSecretBaseId = 0; EWRAM_DATA u8 gUnknown_0203A01D = 0; EWRAM_DATA struct SecretBaseListMenuBuffer *gUnknown_0203A020 = NULL; @@ -45,7 +45,36 @@ void ResetSecretBases(void) void sub_80E8B58(void) { - gUnknown_0203A01C = gSpecialVar_0x8004; + sCurSecretBaseId = gSpecialVar_0x8004; +} + +void sub_80E8B6C(void) +{ + u16 i; + + gScriptResult = FALSE; + for (i = 0; i < 20; i ++) + { + if (sCurSecretBaseId != gSaveBlock1Ptr->secretBases[i].secretBaseId) + { + continue; + } + gScriptResult = TRUE; + VarSet(VAR_0x4054, i); + break; + } +} + +void sub_80E8BC8(void) +{ + if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0) + { + gScriptResult = TRUE; + } + else + { + gScriptResult = FALSE; + } } // .rodata