From 2aa6dbe4737c60128c8a8326ddd607aa4fc313b4 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Thu, 26 Oct 2017 08:40:08 -0400 Subject: [PATCH] through sub_80E9AD0 --- asm/secret_base.s | 90 ----------------------------------------------- src/secret_base.c | 33 +++++++++++++++++ 2 files changed, 33 insertions(+), 90 deletions(-) diff --git a/asm/secret_base.s b/asm/secret_base.s index 1a0d69e0eb..58fe224ae0 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,96 +5,6 @@ .text - thumb_func_start sub_80E9AC0 -sub_80E9AC0: @ 80E9AC0 - push {lr} - movs r0, 0x14 - bl IncrementGameStat - bl sub_80E9A90 - pop {r0} - bx r0 - thumb_func_end sub_80E9AC0 - - thumb_func_start sub_80E9AD0 -sub_80E9AD0: @ 80E9AD0 - push {r4-r7,lr} - ldr r0, =gMapHeader - ldr r4, [r0, 0x4] - movs r6, 0 - b _080E9B62 - .pool -_080E9AE0: - ldr r2, [r4, 0x10] - lsls r1, r6, 1 - adds r0, r1, r6 - lsls r0, 2 - adds r2, r0, r2 - ldrb r0, [r2, 0x5] - adds r7, r1, 0 - cmp r0, 0x8 - bne _080E9B5C - ldr r0, =gSaveBlock1Ptr - ldr r0, [r0] - ldr r1, =0x00001a9c - adds r0, r1 - ldrb r1, [r0] - ldr r0, [r2, 0x8] - cmp r1, r0 - bne _080E9B5C - ldrh r0, [r2] - adds r0, 0x7 - ldrh r1, [r2, 0x2] - adds r1, 0x7 - bl MapGridGetMetatileIdAt - movs r1, 0 - ldr r5, =gUnknown_0858CFCC - lsls r0, 16 - asrs r2, r0, 16 -_080E9B16: - lsls r0, r1, 2 - adds r3, r0, r5 - ldrh r0, [r3, 0x2] - cmp r0, r2 - beq _080E9B3C - adds r0, r1, 0x1 - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0x6 - bls _080E9B16 -_080E9B2A: - bl DrawWholeMapView - b _080E9B68 - .pool -_080E9B3C: - ldr r0, [r4, 0x10] - adds r1, r7, r6 - lsls r1, 2 - adds r1, r0 - ldrh r0, [r1] - adds r0, 0x7 - ldrh r1, [r1, 0x2] - adds r1, 0x7 - ldrh r3, [r3] - movs r4, 0xC0 - lsls r4, 4 - adds r2, r4, 0 - orrs r2, r3 - bl MapGridSetMetatileIdAt - b _080E9B2A -_080E9B5C: - adds r0, r6, 0x1 - lsls r0, 16 - lsrs r6, r0, 16 -_080E9B62: - ldrb r0, [r4, 0x3] - cmp r6, r0 - bcc _080E9AE0 -_080E9B68: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end sub_80E9AD0 - thumb_func_start sub_80E9B70 sub_80E9B70: @ 80E9B70 push {r4-r6,lr} diff --git a/src/secret_base.c b/src/secret_base.c index 210149ee98..60e29fa1e2 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -860,3 +860,36 @@ void sub_80E9A90(void) gSaveBlock1Ptr->secretBases[0].sbr_field_e = sbr_e; sub_80E9728(); } + +void sub_80E9AC0(void) +{ + IncrementGameStat(GAME_STAT_MOVED_SECRET_BASE); + sub_80E9A90(); +} + +void sub_80E9AD0(void) +{ + u16 i; + u16 j; + s16 tile; + struct MapEvents *events; + + events = gMapHeader.events; + for (i = 0; i < events->bgEventCount; i ++) + { + if (events->bgEvents[i].kind == 8 && gSaveBlock1Ptr->secretBases[0].secretBaseId == events->bgEvents[i].bgUnion.secretBaseId) + { + tile = MapGridGetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7); + for (j = 0; j < 7; j ++) + { + if (gUnknown_0858CFCC[j].tile2 == tile) + { + MapGridSetMetatileIdAt(events->bgEvents[i].x + 7, events->bgEvents[i].y + 7, gUnknown_0858CFCC[j].tile1 | 0xc00); + break; + } + } + DrawWholeMapView(); + break; + } + } +}