diff options
| author | notyourav <65437533+notyourav@users.noreply.github.com> | 2022-03-20 19:28:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-20 19:28:07 -0700 |
| commit | f57f815879ca5d743557125341bf583b48bbdeaf (patch) | |
| tree | 097531ed20b9f5117cf58386ce81ebc419f7e64e /src/code_08049CD4.c | |
| parent | a767e16cba73ce613ac4c42c2d86eea31f675fbb (diff) | |
| parent | 9143b1f4c79b7a54eb440173acf51031999f0542 (diff) | |
Merge pull request #458 from EllipticEllipsis/code_08049D30
Decompile the file formerly known as `code_08049D30`
Diffstat (limited to 'src/code_08049CD4.c')
| -rw-r--r-- | src/code_08049CD4.c | 69 |
1 files changed, 60 insertions, 9 deletions
diff --git a/src/code_08049CD4.c b/src/code_08049CD4.c index a773306d..c98323d1 100644 --- a/src/code_08049CD4.c +++ b/src/code_08049CD4.c @@ -1,25 +1,76 @@ +#define NENT_DEPRECATED #include "global.h" - -extern u32* gUnk_020354B0; -extern u32 gRoomMemory; +#include "room.h" extern void MemFill32(u32, void*, u32); +void sub_08049DCC(RoomMemory*); +RoomMemory* sub_08049D88(void); + void ClearRoomMemory(void) { - MemFill32(0xFFFFFFFF, &gRoomMemory, 0x40); - gUnk_020354B0 = &gRoomMemory; + MemFill32(0xFFFFFFFF, gRoomMemory, 0x40); + gUnk_020354B0 = gRoomMemory; } -void sub_08049CF4(u8* arg0) { - u8 field_0x6c = *(arg0 + 0x6c); +void sub_08049CF4(GenericEntity* ent) { + u8 field_0x6c = ent->field_0x6c.HALF.LO; if (field_0x6c & 0x80) { - *(gUnk_020354B0 + 1) |= 1 << (field_0x6c & 0x1f); + gUnk_020354B0->unk_04 |= 1 << (field_0x6c & 0x1f); } } u32 sub_08049D1C(u32 arg0) { - u32 bitmask = *(gUnk_020354B0 + 1) >> arg0; + u32 bitmask = gUnk_020354B0->unk_04 >> arg0; u32 output = 1; 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* rm = gRoomMemory; + RoomMemory* r1 = rm + 1; + + do { + if (r1->unk_02 > rm->unk_02) { + rm = r1; + } + r1++; + } while (r1 < gRoomMemory + 8); + + rm->area = gRoomControls.area; + rm->room = gRoomControls.room; + + rm->unk_02 = 0xFFFF; + rm->unk_04 = 0; + + sub_08049DCC(rm); + + return rm; +} + +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; +} |
