diff --git a/asm/kinstone.s b/asm/kinstone.s index adc9fdf8..ed6a123e 100644 --- a/asm/kinstone.s +++ b/asm/kinstone.s @@ -892,55 +892,3 @@ _08018B8A: .align 2, 0 _08018BAC: .4byte gUnk_080FE320 _08018BB0: .4byte 0x00000219 - - thumb_func_start sub_08018BB4 -sub_08018BB4: @ 0x08018BB4 - push {r4, r5, lr} - sub sp, #8 - adds r4, r0, #0 - lsls r0, r4, #3 - ldr r1, _08018C14 @ =gUnk_080FEAC8 - adds r0, r0, r1 - mov r5, sp - mov r1, sp - movs r2, #8 - bl MemCopy - lsls r0, r4, #2 - adds r0, r0, r4 - lsls r0, r0, #2 - ldr r1, _08018C18 @ =gUnk_080FE320 - adds r0, r0, r1 - ldrh r1, [r0, #8] - lsrs r1, r1, #4 - movs r2, #0x3f - ands r1, r2 - ldrh r0, [r0, #0xa] - lsrs r0, r0, #4 - ands r0, r2 - lsls r0, r0, #6 - orrs r1, r0 - strh r1, [r5, #4] - mov r0, sp - bl sub_0804B3C4 - ldrb r0, [r5, #1] - bl CheckLocalFlag - cmp r0, #0 - bne _08018C10 - ldrh r3, [r5, #4] - ldrb r1, [r5, #6] - movs r0, #1 - ands r0, r1 - movs r2, #2 - cmp r0, #0 - bne _08018C08 - movs r2, #1 -_08018C08: - movs r0, #0x73 - adds r1, r3, #0 - bl SetTileType -_08018C10: - add sp, #8 - pop {r4, r5, pc} - .align 2, 0 -_08018C14: .4byte gUnk_080FEAC8 -_08018C18: .4byte gUnk_080FE320 diff --git a/include/room.h b/include/room.h index 747379b6..cb3a456f 100644 --- a/include/room.h +++ b/include/room.h @@ -190,15 +190,17 @@ typedef struct { typedef struct { u8 type; - u8 _1; + u8 localFlag; u8 _2; u8 _3; - u16 _4; + u16 tilePos; u8 _6; u8 _7; } TileEntity; extern TileEntity gSmallChests[8]; +extern TileEntity gUnk_080FEAC8[]; + typedef enum { NONE, ROOM_VISIT_MARKER, @@ -230,7 +232,7 @@ void LoadRoomEntityList(EntityData* listPtr); bool32 LoadFixedGFX(Entity*, u32); void UnloadGFXSlots(Entity*); -void sub_0804B3C4(void*); +void sub_0804B3C4(TileEntity*); void sub_0804B0B0(u32 arg0, u32 arg1); void DoExitTransition(const ScreenTransitionData* data); diff --git a/src/kinstone.c b/src/kinstone.c index f9f4b5f8..1c42e02f 100644 --- a/src/kinstone.c +++ b/src/kinstone.c @@ -1,5 +1,29 @@ #include "global.h" #include "room.h" +#include "subtask.h" +#include "common.h" +#include "flags.h" + +void sub_08018BB4(int param_1) { + u32 layer; + TileEntity tile; + struct_080FE320* ptr; + u32 position; + + MemCopy(gUnk_080FEAC8 + param_1, &tile, sizeof(TileEntity)); + ptr = &gUnk_080FE320[param_1]; + tile.tilePos = (ptr->x >> 4 & 0x3f) | (((ptr->y) >> 4 & 0x3f) << 6); + sub_0804B3C4(&tile); + if (CheckLocalFlag(tile.localFlag) == 0) { + position = tile.tilePos; + if ((tile._6 & 1) == 0) { + layer = 1; + } else { + layer = 2; + } + SetTileType(0x73, position, layer); + } +} void CreateMinishEntrance(u32 tilePos) { u32 x, y; diff --git a/src/object/objectOnPillar.c b/src/object/objectOnPillar.c index 7f0456c8..5b5e8010 100644 --- a/src/object/objectOnPillar.c +++ b/src/object/objectOnPillar.c @@ -294,9 +294,9 @@ void sub_080971E0(ObjectOnPillarEntity* this) { bool32 sub_08097348(u32 tilePosition) { u32 index; TileEntity* tileEntity = gSmallChests; - for (index = 0; index < 8; index++, tileEntity++) { - if (tileEntity->_4 == tilePosition) { - return CheckLocalFlag(tileEntity->_1); + for (index = 0; index < ARRAY_COUNT(gSmallChests); index++, tileEntity++) { + if (tileEntity->tilePos == tilePosition) { + return CheckLocalFlag(tileEntity->localFlag); } } return FALSE; diff --git a/src/playerItemUtils.c b/src/playerItemUtils.c index 8364caf3..aa1d15a0 100644 --- a/src/playerItemUtils.c +++ b/src/playerItemUtils.c @@ -56,14 +56,14 @@ void sub_080A7C8C(u32 pos, u32 layer) { u32 found = 0; u32 i; for (i = 0; i < 8; ++i, ++t) { - if (*(u16*)&t->_4 == pos) { + if (*(u16*)&t->tilePos == pos) { found = 1; break; } } if ((layer >> 1) == ((u32)(t->_6 << 31) >> 31)) { if (found) { - SetLocalFlag(t->_1); + SetLocalFlag(t->localFlag); CreateItemEntity(t->_2, t->_3, 0); } else { CreateItemEntity(0x60, 0, 0); @@ -81,7 +81,7 @@ u32 sub_080A7CFC(u32 a1) { TileEntity* t = GetCurrentRoomProperty(3); if (t != 0) { do { - if (t->_4 == a1) { + if (t->tilePos == a1) { switch (t->type) { case SIGN: hint = FALSE; @@ -95,7 +95,7 @@ u32 sub_080A7CFC(u32 a1) { break; } t++; - } while (t->_4 != 0); + } while (t->tilePos != 0); } InitTileMessage(msg, hint); } diff --git a/src/room.c b/src/room.c index 92c4057a..f1051403 100644 --- a/src/room.c +++ b/src/room.c @@ -251,8 +251,8 @@ void* GetCurrentRoomProperty(u32 idx) { void sub_0804B16C(void) { TileEntity* tile = gSmallChests; do { - if (tile->_4 != 0 && CheckLocalFlag(tile->_1)) { - SetTileType(0x74, tile->_4, tile->_6 & 1 ? 2 : 1); + if (tile->tilePos != 0 && CheckLocalFlag(tile->localFlag)) { + SetTileType(0x74, tile->tilePos, tile->_6 & 1 ? 2 : 1); } } while (++tile < gSmallChests + 8); } @@ -297,28 +297,28 @@ void LoadRoomTileEntities(TileEntity* list) { } static void LoadGrassDropTile(TileEntity* tile) { - MemCopy(&gAreaDroptables[tile->_1], &gRoomVars.currentAreaDroptable, 0x20); + MemCopy(&gAreaDroptables[tile->localFlag], &gRoomVars.currentAreaDroptable, 0x20); } static void LoadLocationTile(TileEntity* tile) { - gArea.locationIndex = tile->_1; + gArea.locationIndex = tile->localFlag; sub_08054524(); } static void LoadRoomVisitTile(TileEntity* tile) { - SetLocalFlag(tile->_1); + SetLocalFlag(tile->localFlag); } static void LoadSmallChestTile(TileEntity* tile) { TileEntity* t = gSmallChests; u32 i = 0; for (i = 0; i < 8; ++i, ++t) { - if (!t->_4) { + if (!t->tilePos) { MemCopy(tile, t, sizeof(TileEntity)); - if ((t->_6 & 1) && (gRoomControls.scroll_flags & 2) && !CheckLocalFlag(t->_1)) { - Entity* e = CreateObject(OBJECT_52, t->_1, 0); + if ((t->_6 & 1) && (gRoomControls.scroll_flags & 2) && !CheckLocalFlag(t->localFlag)) { + Entity* e = CreateObject(OBJECT_52, t->localFlag, 0); if (e != NULL) { - sub_0806F704(e, t->_4); + sub_0806F704(e, t->tilePos); } } return; @@ -331,10 +331,10 @@ static void LoadBombableWallTile(TileEntity* tile) { if (mgr != NULL) { mgr->manager.type = 9; mgr->manager.subtype = 0x24; - mgr->x = tile->_4; + mgr->x = tile->tilePos; mgr->y = *(u16*)&tile->_6; mgr->field_0x35 = tile->_2; - mgr->field_0x3e = tile->_1; + mgr->field_0x3e = tile->localFlag; AppendEntityToList((Entity*)mgr, 6); } } @@ -345,7 +345,7 @@ static void LoadDarknessTile(TileEntity* tile) { static void LoadDestructibleTile(TileEntity* tile) { if (CheckLocalFlag(*(u16*)&tile->_2)) { - SetTileType(*(u16*)&tile->_6, tile->_4, tile->_1); + SetTileType(*(u16*)&tile->_6, tile->tilePos, tile->localFlag); } else if (!gRoomVars.filler_0x1) { Manager* mgr; gRoomVars.filler_0x1 = 1; @@ -369,6 +369,6 @@ void sub_0804B388(u32 a1, u32 a2) { sub_080526F8(-1); } -void sub_0804B3C4(void* arg0) { - LoadSmallChestTile(arg0); +void sub_0804B3C4(TileEntity* tile) { + LoadSmallChestTile(tile); } diff --git a/src/roomInit.c b/src/roomInit.c index 680b3a2d..d48595ed 100644 --- a/src/roomInit.c +++ b/src/roomInit.c @@ -4681,10 +4681,7 @@ u32 sub_unk3_SimonsSimulation_Main(void) { extern u8* gUnk_080F0D58[4]; extern Entity* gUnk_080F0CB8[15]; extern u8* gUnk_080F0E08[]; -extern struct { - u32 unk_00; - u32 unk_04; -} gUnk_080F0E1C[]; +extern TileEntity gUnk_080F0E1C[]; void sub_StateChange_SimonsSimulation_Main(void) { u32 r; diff --git a/src/subtask.c b/src/subtask.c index 2c847d87..4adbe0bd 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -90,13 +90,6 @@ extern void (*const gUnk_080FF330[])(void); void sub_08055994(void); -typedef struct { - u8 unk_0[6]; - u8 unk_6; - u8 unk_7; -} struct_080FEAC8; -extern struct_080FEAC8 gUnk_080FEAC8[]; - extern void (*const gUnk_080FF35C[])(void); extern const EntityData gUnk_080FF33C[]; @@ -676,8 +669,8 @@ void sub_08055978(void) { void sub_08055994(void) { u32 layer; - struct_080FEAC8* ptr = &gUnk_080FEAC8[gMenu.field_0x4]; - if ((ptr->unk_6 & 1) != 0) { + TileEntity* ptr = &gUnk_080FEAC8[gMenu.field_0x4]; + if ((ptr->_6 & 1) != 0) { layer = 2; } else { layer = 1;