diff --git a/asm/secret_base.s b/asm/secret_base.s index 879e6445a..8f32ad43b 100644 --- a/asm/secret_base.s +++ b/asm/secret_base.s @@ -5,124 +5,6 @@ .text - thumb_func_start sub_80E9238 -sub_80E9238: @ 80E9238 - push {r4-r7,lr} - mov r7, r8 - push {r7} - sub sp, 0x4 - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - bl CurrentMapIsSecretBase - lsls r0, 24 - cmp r0, 0 - beq _080E9328 - ldr r0, =0x00004054 - bl VarGet - lsls r0, 16 - lsrs r5, r0, 16 - ldr r1, =gSaveBlock1Ptr - lsls r0, r5, 2 - adds r0, r5 - lsls r0, 5 - ldr r2, =0x00001a9c - adds r0, r2 - ldr r1, [r1] - adds r1, r0 - adds r7, r1, 0 - adds r7, 0x12 - adds r6, r1, 0 - adds r6, 0x22 - movs r1, 0 - mov r0, sp - strh r1, [r0] - mov r4, sp -_080E927A: - ldrh r2, [r4] - adds r1, r7, r2 - ldrb r0, [r1] - subs r0, 0x1 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x77 - bhi _080E92AC - ldr r0, =gDecorations - ldrb r3, [r1] - lsls r1, r3, 5 - adds r1, r0 - ldrb r0, [r1, 0x11] - cmp r0, 0x4 - beq _080E92AC - adds r0, r6, r2 - ldrb r2, [r0] - lsrs r0, r2, 4 - adds r0, 0x7 - movs r1, 0xF - ands r1, r2 - adds r1, 0x7 - adds r2, r3, 0 - bl sub_8127D38 -_080E92AC: - ldrh r0, [r4] - adds r0, 0x1 - lsls r0, 16 - lsrs r0, 16 - strh r0, [r4] - cmp r0, 0xF - bls _080E927A - cmp r5, 0 - beq _080E92F4 - mov r4, sp - adds r4, 0x2 - movs r2, 0x88 - lsls r2, 2 - mov r0, sp - adds r1, r4, 0 - bl sub_80E8CB0 - mov r0, sp - ldrh r0, [r0] - adds r0, 0x7 - ldrh r1, [r4] - adds r1, 0x7 - ldr r2, =0x00000e21 - bl MapGridSetMetatileIdAt - b _080E9328 - .pool -_080E92F4: - mov r0, r8 - cmp r0, 0x1 - bne _080E9328 - ldr r0, =0x00004089 - bl VarGet - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0x1 - bne _080E9328 - mov r4, sp - adds r4, 0x2 - movs r2, 0x88 - lsls r2, 2 - mov r0, sp - adds r1, r4, 0 - bl sub_80E8CB0 - mov r0, sp - ldrh r0, [r0] - adds r0, 0x7 - ldrh r1, [r4] - adds r1, 0x7 - ldr r2, =0x00000e0a - bl MapGridSetMetatileIdAt -_080E9328: - add sp, 0x4 - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_80E9238 - thumb_func_start sub_80E933C sub_80E933C: @ 80E933C push {r4-r7,lr} diff --git a/include/decoration.h b/include/decoration.h index adefb2fd1..f4f34d8b5 100644 --- a/include/decoration.h +++ b/include/decoration.h @@ -191,5 +191,6 @@ extern EWRAM_DATA u8 *gCurDecorInventoryItems; extern EWRAM_DATA u8 gCurDecorationIndex; void sub_8126968(void); +void sub_8127D38(u16 mapX, u16 mapY, u16 decor); #endif //GUARD_DECORATION_H diff --git a/src/secret_base.c b/src/secret_base.c index 6f888eb4b..c55c48af7 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -362,3 +362,35 @@ bool8 CurrentMapIsSecretBase(void) } return FALSE; } + +void sub_80E9238(u8 flagIn) +{ + u16 curBaseId; + u16 x; + u16 y; + u8 *decorations; + u8 *decorPos; + + if (CurrentMapIsSecretBase()) + { + curBaseId = VarGet(VAR_0x4054); + decorations = gSaveBlock1Ptr->secretBases[curBaseId].decorations; + decorPos = gSaveBlock1Ptr->secretBases[curBaseId].decorationPos; + for (x = 0; x < 16; x ++) + { + if (decorations[x] > 0 && decorations[x] <= 0x78 && gDecorations[decorations[x]].permission != DECORPERM_SOLID_MAT) { + sub_8127D38((decorPos[x] >> 4) + 7, (decorPos[x] & 0xF) + 7, decorations[x]); + } + } + if (curBaseId != 0) + { + sub_80E8CB0(&x, &y, 0x220); + MapGridSetMetatileIdAt(x + 7, y + 7, 0x221 | 0xc00); + } + else if (flagIn == 1 && VarGet(VAR_0x4089) == 1) + { + sub_80E8CB0(&x, &y, 0x220); + MapGridSetMetatileIdAt(x + 7, y + 7, 0x20a | 0xc00); + } + } +}