diff --git a/asm/non_matching/playerUtils/sub_0807BFD0.inc b/asm/non_matching/playerUtils/sub_0807BFD0.inc deleted file mode 100644 index f53eb74d..00000000 --- a/asm/non_matching/playerUtils/sub_0807BFD0.inc +++ /dev/null @@ -1,123 +0,0 @@ - .syntax unified - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - bl ClearBgAnimations - bl sub_0807BFA8 - ldr r7, _0807C0B8 @ =0x0000FFFF - ldr r6, _0807C0BC @ =gMapBottom+0x5004 - movs r0, #0x80 - lsls r0, r0, #5 - mov r8, r0 - adds r0, r7, #0 - adds r1, r6, #0 - mov r2, r8 - bl MemFill16 - movs r5, #0 - strh r5, [r6] - ldr r4, _0807C0C0 @ =gMapTop+0x5004 - adds r0, r7, #0 - adds r1, r4, #0 - mov r2, r8 - bl MemFill16 - strh r5, [r4] - ldr r2, _0807C0C4 @ =gRoomControls - ldr r0, _0807C0C8 @ =gArea - ldr r1, _0807C0CC @ =0x0000085C - adds r4, r0, r1 - ldr r0, [r4] - ldr r1, [r2, #0x34] - ldr r0, [r0, #8] - cmp r1, r0 - beq _0807C01C - str r0, [r2, #0x34] - bl sub_080197D4 -_0807C01C: - ldr r0, [r4] - ldr r0, [r0, #0x10] - bl sub_080197D4 - ldr r1, _0807C0D0 @ =gPaletteBuffer - adds r0, r1, #0 - adds r0, #0x60 - movs r2, #0xa8 - lsls r2, r2, #2 - adds r1, r1, r2 - movs r2, #0x20 - bl MemCopy - ldr r2, _0807C0D4 @ =gUsedPalettes - ldr r0, [r2] - movs r1, #0x80 - lsls r1, r1, #0xe - orrs r0, r1 - str r0, [r2] - ldr r0, [r4] - ldr r0, [r0, #0x14] - cmp r0, #0 - beq _0807C04E - bl LoadBgAnimations -_0807C04E: - adds r5, r6, #0 - movs r0, #0x80 - lsls r0, r0, #5 - adds r6, r5, r0 - adds r0, r7, #0 - adds r1, r6, #0 - mov r2, r8 - bl MemFill16 - movs r2, #0 - ldr r3, _0807C0D8 @ =0x000007FF - adds r4, r7, #0 -_0807C066: - ldrh r0, [r5] - cmp r0, r3 - bhi _0807C078 - lsls r0, r0, #1 - adds r1, r0, r6 - ldrh r0, [r1] - cmp r0, r4 - bne _0807C078 - strh r2, [r1] -_0807C078: - adds r2, #1 - adds r5, #2 - cmp r2, r3 - ble _0807C066 - movs r2, #0x80 - lsls r2, r2, #5 - ldr r5, _0807C0C0 @ =gMapTop+0x5004 - adds r6, r5, r2 - ldr r4, _0807C0B8 @ =0x0000FFFF - adds r0, r4, #0 - adds r1, r6, #0 - bl MemFill16 - movs r2, #0 - ldr r3, _0807C0D8 @ =0x000007FF -_0807C096: - ldrh r0, [r5] - cmp r0, r3 - bhi _0807C0A8 - lsls r0, r0, #1 - adds r1, r0, r6 - ldrh r0, [r1] - cmp r0, r4 - bne _0807C0A8 - strh r2, [r1] -_0807C0A8: - adds r2, #1 - adds r5, #2 - cmp r2, r3 - ble _0807C096 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7, pc} - .align 2, 0 -_0807C0B8: .4byte 0x0000FFFF -_0807C0BC: .4byte gMapBottom+0x5004 -_0807C0C0: .4byte gMapTop+0x5004 -_0807C0C4: .4byte gRoomControls -_0807C0C8: .4byte gArea -_0807C0CC: .4byte 0x0000085C -_0807C0D0: .4byte gPaletteBuffer -_0807C0D4: .4byte gUsedPalettes -_0807C0D8: .4byte 0x000007FF - .syntax divided diff --git a/src/playerUtils.c b/src/playerUtils.c index c2c28364..d1769c0c 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -18,6 +18,7 @@ #include "save.h" #include "screen.h" #include "screenTransitions.h" +#include "main.h" static void sub_08077E54(ItemBehavior* beh); @@ -157,6 +158,14 @@ extern const u8 gUnk_080084BC[]; u32 sub_0807A180(Entity*, Entity*, u32, u32); +extern u32 gUsedPalettes; + +extern void ClearBgAnimations(void); +extern void sub_080197D4(const void*); +extern void LoadBgAnimations(u16*); + +void sub_0807BFA8(void); + void UpdateActiveItems(PlayerEntity* this) { u32 index; @@ -3577,7 +3586,54 @@ void sub_0807BFA8(void) { gRoomControls.height = (gArea.pCurrentRoomInfo)->pixel_height; } -ASM_FUNC("asm/non_matching/playerUtils/sub_0807BFD0.inc", void sub_0807BFD0()) +void sub_0807BFD0(void) { + s32 index; + u16* puVar2; + u16* puVar3; + u16* ptr; + typeof(gMapTop)* newptr; + + ClearBgAnimations(); + sub_0807BFA8(); + MemFill16(0xffff, gMapBottom.metatileTypes, 0x1000); + gMapBottom.metatileTypes[0] = 0; + MemFill16(0xffff, gMapTop.metatileTypes, 0x1000); + gMapTop.metatileTypes[0] = 0; + + if ((void*)gRoomControls.unk_34 != (gArea.pCurrentRoomInfo)->tileset) { + gRoomControls.unk_34 = (u32)(gArea.pCurrentRoomInfo)->tileset; + sub_080197D4((gArea.pCurrentRoomInfo)->tileset); + } + + sub_080197D4((gArea.pCurrentRoomInfo)->metatiles); + ptr = gPaletteBuffer; + MemCopy(&ptr[0x30], &ptr[0x150], 0x20); + gUsedPalettes |= 0x200000; + + if ((gArea.pCurrentRoomInfo)->bg_anim != NULL) { + LoadBgAnimations((gArea.pCurrentRoomInfo)->bg_anim); + } + + puVar2 = gMapBottom.metatileTypes; + puVar3 = gMapBottom.unkData2; + MemFill16(0xffff, puVar3, 0x1000); + + for (index = 0; index < 0x800; index++, puVar2++) { + if ((*puVar2 < 0x800) && (puVar3[*puVar2] == 0xffff)) { + puVar3[*puVar2] = index; + } + } + + puVar2 = gMapTop.metatileTypes; + puVar3 = gMapTop.unkData2; + MemFill16(0xffff, puVar3, 0x1000); + + for (index = 0; index < 0x800; index++, puVar2++) { + if ((*puVar2 < 0x800) && (puVar3[*puVar2] == 0xffff)) { + puVar3[*puVar2] = index; + } + } +} void LoadRoomGfx(void) { RoomControls* roomControls;