diff --git a/linker.ld b/linker.ld index 81cb59d2..fa025fc3 100644 --- a/linker.ld +++ b/linker.ld @@ -428,7 +428,7 @@ SECTIONS { src/enemy/enemy66.o(.text); /* END enemies */ src/code_08049CD4.o(.text); /* enemyUtils.c */ - src/code_08049D30.o(.text); + src/code_08049DF4.o(.text); src/enemyUtils.o(.text); src/createEnemy.o(.text); src/enterPortalSubtask.o(.text); diff --git a/src/code_08049CD4.c b/src/code_08049CD4.c index 8fb02487..c79effa8 100644 --- a/src/code_08049CD4.c +++ b/src/code_08049CD4.c @@ -5,6 +5,9 @@ extern void MemFill32(u32, void*, u32); +void sub_08049DCC(RoomMemory*); +RoomMemory* sub_08049D88(void); + void ClearRoomMemory(void) { MemFill32(0xFFFFFFFF, gRoomMemory, 0x40); gUnk_020354B0 = gRoomMemory; @@ -23,3 +26,53 @@ u32 sub_08049D1C(u32 arg0) { output &= ~bitmask; return output; } + + +void UpdateRoomTracker(void) { + gUnk_020354B0 = gRoomMemory; + + do { + if (gUnk_020354B0->area == gRoomControls.area && gUnk_020354B0->room == gRoomControls.room) { + sub_08049DCC(gUnk_020354B0); + return; + } + gUnk_020354B0++; + + } while (gUnk_020354B0 < gRoomMemory + 8); + gUnk_020354B0 = sub_08049D88(); +} + +RoomMemory* sub_08049D88(void) { + RoomMemory* r4 = gRoomMemory; + RoomMemory* r1 = r4 + 1; + + do { + if (r1->unk_02 > r4->unk_02) { + r4 = r1; + } + r1++; + } while (r1 < gRoomMemory + 8); + + r4->area = gRoomControls.area; + r4->room = gRoomControls.room; + + r4->unk_02 = 0xFFFF; + r4->unk_04 = 0; + + sub_08049DCC(r4); + + return r4; +} + +void sub_08049DCC(RoomMemory* rm) { + RoomMemory* r1 = gRoomMemory; + + do { + if (r1->unk_02 < rm->unk_02) { + r1->unk_02++; + } + r1++; + } while (r1 < gRoomMemory + 8); + + rm->unk_02 = 0; +} \ No newline at end of file diff --git a/src/code_08049D30.c b/src/code_08049DF4.c similarity index 90% rename from src/code_08049D30.c rename to src/code_08049DF4.c index f91477f2..f8b4ca89 100644 --- a/src/code_08049D30.c +++ b/src/code_08049DF4.c @@ -10,58 +10,6 @@ extern Entity* (*const gUnk_080D3BE8[])(void); extern void ReplaceMonitoredEntity(Entity*, Entity*); -void sub_08049DCC(RoomMemory*); -RoomMemory* sub_08049D88(void); - -void UpdateRoomTracker(void) { - gUnk_020354B0 = gRoomMemory; - - do { - if (gUnk_020354B0->area == gRoomControls.area && gUnk_020354B0->room == gRoomControls.room) { - sub_08049DCC(gUnk_020354B0); - return; - } - gUnk_020354B0++; - - } while (gUnk_020354B0 < gRoomMemory + 8); - gUnk_020354B0 = sub_08049D88(); -} - -RoomMemory* sub_08049D88(void) { - RoomMemory* r4 = gRoomMemory; - RoomMemory* r1 = r4 + 1; - - do { - if (r1->unk_02 > r4->unk_02) { - r4 = r1; - } - r1++; - } while (r1 < gRoomMemory + 8); - - r4->area = gRoomControls.area; - r4->room = gRoomControls.room; - - r4->unk_02 = 0xFFFF; - r4->unk_04 = 0; - - sub_08049DCC(r4); - - return r4; -} - -void sub_08049DCC(RoomMemory* rm) { - RoomMemory* r1 = gRoomMemory; - - do { - if (r1->unk_02 < rm->unk_02) { - r1->unk_02++; - } - r1++; - } while (r1 < gRoomMemory + 8); - - rm->unk_02 = 0; -} - Entity* sub_08049DF4(u32 arg0) { if (gUnk_020000B0 != NULL) { return gUnk_020000B0;