diff options
| author | octorock <79596758+octorock@users.noreply.github.com> | 2023-05-31 23:51:20 +0200 |
|---|---|---|
| committer | octorock <79596758+octorock@users.noreply.github.com> | 2023-05-31 23:51:20 +0200 |
| commit | bbac5ace3fb87828f288ff583f72a5a51af5a05f (patch) | |
| tree | 70fb8b55e62a1d270e9f3cec927519a34ca17100 /src | |
| parent | 134f39a0bdad19fc794e19fba56d072d1ab30022 (diff) | |
| parent | 79bbd540a8846e48f97b77ea03d28828bdcca0ae (diff) | |
Merge remote-tracking branch 'upstream/master' into tilemap-docs
Diffstat (limited to 'src')
113 files changed, 1789 insertions, 1161 deletions
diff --git a/src/beanstalkSubtask.c b/src/beanstalkSubtask.c index 4612e66b..35423fa1 100644 --- a/src/beanstalkSubtask.c +++ b/src/beanstalkSubtask.c @@ -204,7 +204,8 @@ u32 UpdatePlayerCollision(void) { ptr1 = &gUnk_080B4490[index * 2]; if (sub_080B1B44(COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr1[0], -ptr1[1]), gPlayerEntity.collisionLayer) == 0xff) { - if ((((gPlayerState.flags & 0x10002) != 0) || ((gPlayerState.sword_state & 0x10) != 0)) || + if ((((gPlayerState.flags & (PL_FLAGS10000 | PL_FLAGS2)) != 0) || + ((gPlayerState.sword_state & 0x10) != 0)) || ((sub_080806BC(gPlayerEntity.x.HALF.HI - gRoomControls.origin_x, gPlayerEntity.y.HALF.HI - gRoomControls.origin_y, index, 5) == 0 && (((gPlayerState.heldObject != 0 || ((gPlayerState.field_0x1c & 0xf) != 0)) || @@ -234,19 +235,19 @@ u32 UpdatePlayerCollision(void) { return 0; } layer->mapData[position] = 0x4001 + (gPlayerEntity.animationState >> 1); - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xc0; } else { gPlayerState.pushedObject = 0xa0; } gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); return 1; case 0x28: - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { return 0; } gPlayerEntity.action = gPlayerEntity.action; @@ -286,7 +287,7 @@ u32 UpdatePlayerCollision(void) { layer->mapData[position] = 0x401c + (gPlayerEntity.animationState >> 1); gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -304,13 +305,13 @@ u32 UpdatePlayerCollision(void) { case 0x3a: case 0x5b: case 0x4051: - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { return 0; } if (gPlayerEntity.animationState != 0) { return 0; } - gHUD.unk_2d = 4; + gHUD.rActionInteractTile = R_ACTION_READ; if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { return 0; } @@ -321,10 +322,10 @@ u32 UpdatePlayerCollision(void) { if ((animationState1 & 0xff) != 0) { return 0; } - if ((gPlayerState.flags & 0x4080) != 0) { + if ((gPlayerState.flags & (PL_DRUGGED | PL_MINISH)) != 0) { return 0; } - gHUD.unk_2d = 6; + gHUD.rActionInteractTile = R_ACTION_OPEN; if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { return 0; } @@ -332,10 +333,10 @@ u32 UpdatePlayerCollision(void) { OpenSmallChest(position, gPlayerEntity.collisionLayer); return 2; case 0x71: - if (HasDungeonMap() == 0) { + if (HasDungeonSmallKey() == 0) { return 0; } - gHUD.unk_2d = 6; + gHUD.rActionInteractTile = R_ACTION_OPEN; if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { return 0; } @@ -344,7 +345,7 @@ u32 UpdatePlayerCollision(void) { return 2; case 0x3d: case 0x4040 ... 0x4048: - if ((gPlayerState.flags & 0x4000) != 0) { + if ((gPlayerState.flags & PL_DRUGGED) != 0) { return 0; } if (sub_08079778() == 0) { @@ -365,7 +366,7 @@ u32 UpdatePlayerCollision(void) { return 0; } gPlayerState.jump_status = 0x81; - gPlayerState.flags |= 0x20; + gPlayerState.flags |= PL_USE_PORTAL; gPlayerState.queued_action = PLAYER_USEPORTAL; gPlayerEntity.zVelocity = 0x20000; COLLISION_OFF(&gPlayerEntity); @@ -381,7 +382,7 @@ u32 UpdatePlayerCollision(void) { } gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -393,7 +394,7 @@ u32 UpdatePlayerCollision(void) { layer->mapData[position] = 0x405b + (gPlayerEntity.animationState >> 1); gPlayerState.pushedObject = 0x98; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -405,7 +406,7 @@ u32 UpdatePlayerCollision(void) { layer->mapData[position] = 0x4037 + (gPlayerEntity.animationState >> 1); gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -423,7 +424,7 @@ u32 UpdatePlayerCollision(void) { layer->mapData[position] = 0x403f; gPlayerState.pushedObject = 0x82; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -464,7 +465,7 @@ u32 UpdatePlayerCollision(void) { pushedBlock->collisionLayer = gPlayerEntity.collisionLayer; gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = pushedBlock->direction; @@ -472,13 +473,13 @@ u32 UpdatePlayerCollision(void) { case 0x402b ... 0x402d: if (sub_0801A370(layer, position) != 0) { layer->mapData[position] = 0x4030 + ((gPlayerEntity.animationState & 4) >> 2); - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xa0; } else { gPlayerState.pushedObject = 0x90; } gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -491,13 +492,13 @@ u32 UpdatePlayerCollision(void) { return 0; } layer->mapData[position] = 0x404b + (gPlayerEntity.animationState >> 1); - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { gPlayerState.pushedObject = 0xc0; } else { gPlayerState.pushedObject = 0xa0; } gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -563,7 +564,7 @@ u32 UpdatePlayerCollision(void) { SetTile(0x4074, position, gPlayerEntity.collisionLayer); gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; gPlayerEntity.direction = Direction8FromAnimationState(gPlayerEntity.animationState); @@ -831,7 +832,7 @@ bool32 sub_0801AA58(Entity* this, u32 param_2, u32 param_3) { object->collisionLayer = this->collisionLayer; gPlayerState.pushedObject = 0xa0; gPlayerState.queued_action = PLAYER_PUSH; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; this->x.HALF.LO = 0; this->y.HALF.LO = 0; this->direction = param_3; diff --git a/src/code_08049DF4.c b/src/code_08049DF4.c index bbef5e64..a4af4474 100644 --- a/src/code_08049DF4.c +++ b/src/code_08049DF4.c @@ -43,7 +43,7 @@ Entity* sub_08049E4C(void) { } Entity* sub_08049E80(void) { - if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & 0x80)) { + if ((gPlayerState.field_0x3c != 0) || !(gPlayerState.flags & PL_MINISH)) { return NULL; } gUnk_020000B0 = &gPlayerEntity; @@ -51,7 +51,8 @@ Entity* sub_08049E80(void) { } Entity* sub_08049EB0(void) { - if ((gPlayerState.field_0x3c == 0) && !(gPlayerState.flags & 0x80190)) { + if ((gPlayerState.field_0x3c == 0) && + !(gPlayerState.flags & (PL_MOLDWORM_CAPTURED | PL_DISABLE_ITEMS | PL_MINISH | PL_CAPTURED))) { gUnk_020000B0 = &gPlayerEntity; return &gPlayerEntity; } diff --git a/src/common.c b/src/common.c index e5e6de1e..26f44b1d 100644 --- a/src/common.c +++ b/src/common.c @@ -7,6 +7,7 @@ #include "functions.h" #include "game.h" #include "global.h" +#include "item.h" #include "kinstone.h" #include "main.h" #include "message.h" @@ -30,7 +31,7 @@ void ResetScreenRegs(void); void MessageFromFusionTarget(u32); void sub_0801E24C(s32, s32); void sub_0801E290(u32, u32, u32); -s32 sub_0801E8B0(u32); +s32 GetIndexInKinstoneBag(u32); extern u32 sub_0807CB24(u32, u32); @@ -65,7 +66,7 @@ extern const GfxItem* gGfxGroups[]; extern const u32 gUnk_080C9460[]; -void sub_0801E82C(void); +void SortKinstoneBag(void); extern void* GetRoomProperty(u32, u32, u32); @@ -79,6 +80,24 @@ u32 sub_0801DF60(u32 a1, u8* p); u32 sub_0801DF78(u32 a1, u32 a2); void DrawMapPixel(u32 x, u32 y, s32 color); +extern void* GetRoomProperty(u32, u32, u32); + +enum DungeonMapObjectTypes { + DMO_TYPE_NONE, + DMO_TYPE_PLAYER, + DMO_TYPE_CHEST, + DMO_TYPE_ENTRY, + DMO_TYPE_BOSS, +}; + +typedef struct { + u8 type; /**< @see DungeonMapObjectTypes */ + u8 x; + u8 y; +} PACKED DungeonMapObject; + +// More like PrepareTileEntitesForDungeonMap or so + u32 DecToHex(u32 value) { u32 result; FORCE_REGISTER(u32 r1, r1); @@ -415,7 +434,75 @@ u32 sub_0801DB94(void) { return gRoomTransition.player_status.dungeon_map_y >> 11; } -ASM_FUNC("asm/non_matching/common/DrawDungeonMap.inc", void DrawDungeonMap(u32 floor, void* data, u32 size)); +void DrawDungeonMap(u32 floor, DungeonMapObject* specialData, u32 size) { + DungeonLayout* floorMapData; + TileEntity* tileEntity; + u32 flagBankOffset; + RoomHeader* roomHeader; + s32 tmp1; + s32 tmp3; + + MemClear(specialData, size); + specialData->type = DMO_TYPE_PLAYER; + specialData->x = (gRoomTransition.player_status.dungeon_map_x >> 4) & 0x7f; + specialData->y = (gRoomTransition.player_status.dungeon_map_y >> 4) & 0x7f; + specialData++; + floorMapData = (DungeonLayout*)gDungeonLayouts[gArea.dungeon_idx][floor]; + while (floorMapData->area != 0) { + tileEntity = (TileEntity*)GetRoomProperty(floorMapData->area, floorMapData->room, 3); + if (tileEntity == NULL) { + floorMapData++; + } else { + flagBankOffset = sub_0801DF10(floorMapData); + if (HasDungeonCompass()) { + while (tileEntity->type != 0) { + switch (tileEntity->type) { + case SMALL_CHEST: + case BIG_CHEST: + if (!CheckLocalFlagByBank(flagBankOffset, tileEntity->localFlag)) { + roomHeader = gAreaRoomHeaders[floorMapData->area] + floorMapData->room; + specialData->type = DMO_TYPE_CHEST; + if (tileEntity->type == SMALL_CHEST) { + specialData->x = + ((((tileEntity->tilePos << 4 & 0x3f0) | 8) + (roomHeader->map_x % 0x800)) >> 4); + specialData->y = + ((((tileEntity->tilePos >> 2 & 0x3f0) | 8) + (roomHeader->map_y % 0x800)) >> 4); + } else { + specialData->x = (((roomHeader->map_x % 0x800) + tileEntity->tilePos) >> 4); + specialData->y = (((roomHeader->map_y % 0x800) + (*(u16*)&tileEntity->_6)) >> 4); + } + specialData++; + } + break; + } + tileEntity++; + } + } + if ((HasDungeonCompass() && ((floorMapData->unk_2 & 2) != 0)) && + (!CheckGlobalFlag(gArea.dungeon_idx + 1))) { + roomHeader = gAreaRoomHeaders[floorMapData->area] + floorMapData->room; + specialData->type = DMO_TYPE_BOSS; + tmp1 = ((roomHeader->pixel_width / 2) + roomHeader->map_x) / 16; + if (tmp1 < 0) { + tmp1 = tmp1 + 0x7f; + } + specialData->x = tmp1 + (tmp1 / 128) * -128; + tmp3 = ((roomHeader->pixel_height / 2) + roomHeader->map_y) / 16; + specialData->y = tmp3 + (tmp3 / 128) * -128; + specialData++; + } + if (floorMapData->area == gRoomTransition.player_status.dungeon_area && + floorMapData->room == gRoomTransition.player_status.dungeon_room) { + specialData->type = DMO_TYPE_ENTRY; + // TODO rename dungeon_x and dungeon_y to dungeonEntryX/Y? + specialData->x = ((u16)gRoomTransition.player_status.dungeon_x >> 4) & 0x7f; + specialData->y = ((u16)gRoomTransition.player_status.dungeon_y >> 4) & 0x7f; + specialData++; + } + floorMapData++; + } + } +} void sub_0801DD58(u32 area, u32 room) { RoomHeader* hdr = gAreaRoomHeaders[area] + room; @@ -460,7 +547,7 @@ void DrawDungeonFeatures(u32 floor, void* data, u32 size) { if (layout->area == gUI.roomControls.area && layout->room == gUI.roomControls.room) { features = 8; } else { - if (HasDungeonSmallKey()) { + if (HasDungeonMap()) { features = 2; } if (IsRoomVisited(tileEntity, bankOffset)) { @@ -549,7 +636,7 @@ void sub_0801DFB4(Entity* entity, u32 textIndex, u32 a3, u32 a4) { gFuseInfo._8 = a3; gFuseInfo._a = a4; gFuseInfo.ent = entity; - gFuseInfo.kinstoneId = gUnk_03003DF0.unk_2; + gFuseInfo.kinstoneId = gPossibleInteraction.kinstoneId; if (entity != NULL) { gFuseInfo.prevUpdatePriority = entity->updatePriority; entity->updatePriority = 2; @@ -756,102 +843,102 @@ void sub_0801E64C(s32 param_1, s32 param_2, s32 param_3, s32 param_4, s32 param_ } } -void sub_0801E6C8(u32 kinstoneId) { +void NotifyFusersOnFusionDone(KinstoneId kinstoneId) { u32 tmp; u32 index; if (kinstoneId - 1 < 100) { for (index = 0; index < 0x80; index++) { - if (kinstoneId == gSave.unk1C1[index]) { - gSave.unk1C1[index] = 0xf1; + if (kinstoneId == gSave.fuserOffers[index]) { + gSave.fuserOffers[index] = KINSTONE_NEEDS_REPLACEMENT; } } - tmp = sub_08002632(gFuseInfo.ent); - if ((tmp - 1 < 0x7f) && (gSave.unk1C1[tmp] == 0xf1)) { - gSave.unk1C1[tmp] = 0xf2; + tmp = GetFuserId(gFuseInfo.ent); + if ((tmp - 1 < 0x7f) && (gSave.fuserOffers[tmp] == KINSTONE_NEEDS_REPLACEMENT)) { + gSave.fuserOffers[tmp] = KINSTONE_JUST_FUSED; } for (index = 0; index < 0x20; index++) { - if (kinstoneId == gUnk_03003DF0.array[index].unk_3) { - gUnk_03003DF0.array[index].unk_3 = 0xf1; + if (kinstoneId == gPossibleInteraction.candidates[index].kinstoneId) { + gPossibleInteraction.candidates[index].kinstoneId = KINSTONE_NEEDS_REPLACEMENT; } } } } -void sub_0801E738(u32 param_1) { +void AddKinstoneToBag(KinstoneId kinstoneId) { s32 index; s32 tmp; - sub_0801E82C(); - if (param_1 - 0x65 < 0x11) { - index = sub_0801E8B0(param_1); + SortKinstoneBag(); // sometimes called just for this function + if (kinstoneId - 0x65 < 0x11) { + index = GetIndexInKinstoneBag(kinstoneId); if (index < 0) { index = 0; - while (gSave.unk118[index] != 0) { + while (gSave.kinstoneTypes[index] != KINSTONE_NONE) { index++; } } if ((u32)index < 0x12) { - gSave.unk118[index] = param_1; - tmp = gSave.unk12B[index] + 1; + gSave.kinstoneTypes[index] = kinstoneId; + tmp = gSave.kinstoneAmounts[index] + 1; if (tmp > 99) { tmp = 99; } - gSave.unk12B[index] = tmp; + gSave.kinstoneAmounts[index] = tmp; } } } -void sub_0801E798(u32 a1) { - s32 idx = sub_0801E8B0(a1); +void RemoveKinstoneFromBag(KinstoneId kinstoneId) { + s32 idx = GetIndexInKinstoneBag(kinstoneId); if (idx >= 0) { - s32 next = gSave.unk12B[idx] - 1; + s32 next = gSave.kinstoneAmounts[idx] - 1; if (next <= 0) { - gSave.unk118[idx] = 0; + gSave.kinstoneTypes[idx] = KINSTONE_NONE; next = 0; } - gSave.unk12B[idx] = next; + gSave.kinstoneAmounts[idx] = next; } } -u32 sub_0801E7D0(u32 a1) { - s32 tmp = sub_0801E8B0(a1); - if (tmp < 0) { +u32 GetAmountInKinstoneBag(KinstoneId kinstoneId) { + s32 index = GetIndexInKinstoneBag(kinstoneId); + if (index < 0) { return 0; } - return gSave.unk12B[tmp]; + return gSave.kinstoneAmounts[index]; } -u32 CheckKinstoneFused(u32 kinstoneId) { - if (kinstoneId > 100 || kinstoneId < 1) { +u32 CheckKinstoneFused(KinstoneId kinstoneId) { + if (kinstoneId - 1 >= 100) { return 0; } return ReadBit(&gSave.fusedKinstones, kinstoneId); } -bool32 sub_0801E810(u32 kinstoneId) { - if (kinstoneId > 100 || kinstoneId < 1) { +bool32 CheckFusionMapMarkerDisabled(KinstoneId kinstoneId) { + if (kinstoneId - 1 >= 100) { return FALSE; } - return ReadBit(&gSave.unk24E, kinstoneId); + return ReadBit(&gSave.fusionUnmarked, kinstoneId); } -void sub_0801E82C(void) { +void SortKinstoneBag(void) { #ifdef NON_MATCHING u32 r5; for (r5 = 0; r5 < 0x13; r5++) { - if (gSave.unk12B[r5] == 0) { - gSave.unk118[r5] = gSave.unk12B[r5]; + if (gSave.kinstoneAmounts[r5] == 0) { + gSave.kinstoneTypes[r5] = gSave.kinstoneAmounts[r5]; } } - gSave.unk118[0x12] = 0; - gSave.unk12B[0x12] = 0; + gSave.kinstoneTypes[0x12] = 0; + gSave.kinstoneAmounts[0x12] = 0; for (r5 = 0; r5 < 0x12; r5++) { - if ((gSave.unk118[r5] - 0x65) > 0x10) { - MemCopy(&gSave.unk118[r5 + 1], &gSave.unk118[r5], 0x12 - r5); - MemCopy(&gSave.unk12B[r5 + 1], &gSave.unk12B[r5], 0x12 - r5); + if ((gSave.kinstoneTypes[r5] - 0x65) > 0x10) { + MemCopy(&gSave.kinstoneTypes[r5 + 1], &gSave.kinstoneTypes[r5], 0x12 - r5); + MemCopy(&gSave.kinstoneAmounts[r5 + 1], &gSave.kinstoneAmounts[r5], 0x12 - r5); } } #else @@ -862,7 +949,7 @@ void sub_0801E82C(void) { new_var = 4; r1 = &gSave.inventory[34]; r5 = 0; - r2 = gSave.unk118; + r2 = gSave.kinstoneTypes; code0_0: r0 = r2[0x13]; r3 = &r1[4]; @@ -899,21 +986,21 @@ code0_2: #endif } -s32 sub_0801E8B0(u32 idx) { +s32 GetIndexInKinstoneBag(KinstoneId kinstoneId) { u32 i; - for (i = 0; i < 18; ++i) { - if (idx == gSave.unk118[i]) + for (i = 0; i < 0x12; ++i) { + if (kinstoneId == gSave.kinstoneTypes[i]) return i; } return -1; } -// Check conditions, something with kinstones -void sub_0801E8D4(void) { +// For example if a chest from a fusion is opened, hide the chest marker +void UpdateVisibleFusionMapMarkers(void) { u32 kinstoneId; for (kinstoneId = 10; kinstoneId <= 100; ++kinstoneId) { - if (CheckKinstoneFused(kinstoneId) && !sub_0801E810(kinstoneId)) { + if (CheckKinstoneFused(kinstoneId) && !CheckFusionMapMarkerDisabled(kinstoneId)) { u32 worldEventId = gKinstoneWorldEvents[kinstoneId].worldEventId; const WorldEvent* s = &gWorldEvents[worldEventId]; #if !defined EU && !defined JP @@ -971,13 +1058,71 @@ void sub_0801E8D4(void) { #else if (sub_0807CB24(tmp, s->flag)) { #endif - WriteBit(&gSave.unk24E, kinstoneId); + WriteBit(&gSave.fusionUnmarked, kinstoneId); } } } } -ASM_FUNC("asm/non_matching/common/sub_0801E99C.inc", u32 sub_0801E99C(u32 a1)); +extern u8* gUnk_08001DCC[]; + +KinstoneId GetFusionToOffer(Entity* entity) { + u8* fuserData; + u32 fuserId; + u32 offeredFusion; + u32 fuserProgress; + u8* fuserFusionData; + s32 randomMood; + u32 fuserStability; + fuserId = GetFuserId(entity); + fuserData = gUnk_08001DCC[fuserId]; + if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0 || fuserData[0] > gSave.global_progress) { + return KINSTONE_NONE; + } + offeredFusion = gSave.fuserOffers[fuserId]; + fuserProgress = gSave.fuserProgress[fuserId]; + fuserFusionData = (u8*)(fuserProgress + (u32)fuserData); + while (TRUE) { // loop through fusions for this fuser + switch (offeredFusion) { + case KINSTONE_NEEDS_REPLACEMENT: // offered fusion completed with someone else + case KINSTONE_NONE: // no fusion offered yet + offeredFusion = fuserFusionData[5]; + if (offeredFusion == KINSTONE_NONE || offeredFusion == KINSTONE_RANDOM || + CheckKinstoneFused(offeredFusion) == 0) { + break; + } + case KINSTONE_JUST_FUSED: // previous fusion completed + fuserFusionData++; + fuserProgress++; + offeredFusion = fuserFusionData[5]; + } + if (offeredFusion == KINSTONE_RANDOM) { // random shared fusion + offeredFusion = GetRandomSharedFusion(fuserData); + } + if (offeredFusion == KINSTONE_NONE) { // end of fusion list + offeredFusion = KINSTONE_FUSER_DONE; // mark this fuser as done + break; + } + if (offeredFusion == KINSTONE_JUST_FUSED) { // previous fusion completed + continue; + } + if (CheckKinstoneFused(offeredFusion) == 0) { + break; + } + offeredFusion = KINSTONE_NEEDS_REPLACEMENT; // already completed, try next fusion in the list + } + gSave.fuserOffers[fuserId] = offeredFusion; + gSave.fuserProgress[fuserId] = fuserProgress; + randomMood = Random(); + fuserStability = fuserData[1]; + if (fuserStability <= randomMood % 100) { + return KINSTONE_NONE; // fickleness + } + if (offeredFusion - 1 > 99) { + offeredFusion = KINSTONE_NONE; + } + return offeredFusion; +} const u16 gUnk_080C93E0[] = { 3, 9, 16, 22, 28, 35, 41, 48, 54, 61, 67, 74, 81, 88, 95, 102, 110, 117, 125, 133, 141, 149, 158, 167, 176, 185, 195, 205, 215, 226, 238, 250, 262, 276, 290, 304, 320, 336, 354, 373, 394, 415, 439, 465, 493, 525, 559, 597, 640, 689, 744, 808, 883, 971, 1078, 1209, 1375, 1591, 1885, 2308, 2973, 4167, 6950, 20860 }; @@ -1224,20 +1369,19 @@ const u32 gUnk_080CA06C[] = { 139808, 139808, 140320, 140832, 141344, 141856, 14 150560, 151584, 152608, 153632, 154656, 155680, 156704, 157728, 158752, 159776, 160800 }; #endif -// TODO maybe KinstoneFlag? -const u8 gUnk_080CA11C[] = { - 24, 45, 53, 54, 55, 57, 60, 68, 70, 71, 78, 80, 83, 85, 86, 88, 95, 96, 0, 0, +const u8 SharedFusions[] = { + 0x18, 0x2D, 0x35, 0x36, 0x37, 0x39, 0x3C, 0x44, 0x46, 0x47, 0x4E, 0x50, 0x53, 0x55, 0x56, 0x58, 0x5F, 0x60, 0, 0, }; // Get a random kinstone -u32 sub_0801EA74(void) { +u32 GetRandomSharedFusion(u8* fuserData) { s32 r = (s32)Random() % 18; u32 i; for (i = 0; i < 18; ++i) { - u32 kinstoneId = gUnk_080CA11C[r]; + u32 kinstoneId = SharedFusions[r]; if (!CheckKinstoneFused(kinstoneId)) return kinstoneId; r = (r + 1) % 18; } - return 0xF2; + return KINSTONE_JUST_FUSED; } @@ -30,8 +30,6 @@ extern u8 gUnk_08A05751[]; // sprite_table extern void gUnk_089FD1B4; extern void gUnk_089FD2F4; -extern u16 gUnk_0203508E[]; -extern u16 gUnk_0203510E[]; extern u8 gUnk_08A068BF[129]; @@ -190,8 +188,8 @@ void sub_080A30AC(void) { void sub_080A3198(u32 param_1, u32 param_2) { static const Font gUnk_08127C98[] = { - { gUnk_0203508E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, - { gUnk_0203510E, BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, + { &gBG0Buffer[0x1ef], BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x1080, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, + { &gBG0Buffer[0x22f], BG_TILE_ADDR(0x1a0), gTextGfxBuffer, 0, 0x80, 0xd0, 1, 0, 0, 1, 9, 0, 0, 1, 1 }, }; static const u16 gUnk_08127CC8[4] = { TEXT_INDEX(TEXT_WINDCRESTS, 0x1c), diff --git a/src/droptables.c b/src/droptables.c index d239a80d..aafd0879 100644 --- a/src/droptables.c +++ b/src/droptables.c @@ -12,9 +12,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -30,9 +30,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -48,9 +48,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -66,9 +66,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -84,9 +84,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = 5, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -102,9 +102,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -120,9 +120,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 1, .arrows = 1, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -138,9 +138,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, + .kinstoneRed = -999, .kinstoneBlue = -999, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = -999, .none3 = 0, .none4 = 0, @@ -156,9 +156,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, + .kinstoneRed = -999, .kinstoneBlue = -999, - .kinstoneRed = 15, + .kinstoneGreen = 15, .none2 = -999, .none3 = 0, .none4 = 0, @@ -174,9 +174,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = 50, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -192,9 +192,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 100, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -210,9 +210,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = 10, - .kinstoneGreen = 2, + .kinstoneRed = 2, .kinstoneBlue = 3, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = -999, .none3 = 0, .none4 = 0, @@ -228,9 +228,9 @@ const Droptable gEnemyDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -246,9 +246,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 1, .arrows = 1, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -264,9 +264,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 20, .arrows = -999, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -282,9 +282,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -300,9 +300,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 2, + .kinstoneRed = 2, .kinstoneBlue = 5, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = 0, .none3 = 0, .none4 = 0, @@ -318,9 +318,9 @@ const Droptable gEnemyDroptables[] = { .bombs = 9, .arrows = 9, .mysteriousShells = 40, - .kinstoneGreen = 9, + .kinstoneRed = 9, .kinstoneBlue = 12, - .kinstoneRed = 16, + .kinstoneGreen = 16, .none2 = 9, .none3 = 0, .none4 = 0, @@ -339,9 +339,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 10, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -357,9 +357,9 @@ const Droptable gAreaDroptables[] = { .bombs = 200, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = 0, .none3 = 0, .none4 = 0, @@ -375,9 +375,9 @@ const Droptable gAreaDroptables[] = { .bombs = 35, .arrows = 4, .mysteriousShells = 4, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 3, + .kinstoneGreen = 3, .none2 = 0, .none3 = 0, .none4 = 0, @@ -393,9 +393,9 @@ const Droptable gAreaDroptables[] = { .bombs = 7, .arrows = 25, .mysteriousShells = 3, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 9, + .kinstoneGreen = 9, .none2 = 0, .none3 = 0, .none4 = 0, @@ -411,9 +411,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 23, .mysteriousShells = 2, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 28, + .kinstoneGreen = 28, .none2 = 0, .none3 = 0, .none4 = 0, @@ -429,9 +429,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 6, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 11, + .kinstoneGreen = 11, .none2 = 0, .none3 = 0, .none4 = 0, @@ -447,9 +447,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 33, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 6, + .kinstoneGreen = 6, .none2 = 0, .none3 = 0, .none4 = 0, @@ -465,9 +465,9 @@ const Droptable gAreaDroptables[] = { .bombs = 4, .arrows = 4, .mysteriousShells = 3, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 6, + .kinstoneGreen = 6, .none2 = 20, .none3 = 0, .none4 = 0, @@ -483,9 +483,9 @@ const Droptable gAreaDroptables[] = { .bombs = 1, .arrows = 1, .mysteriousShells = 1, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 6, + .kinstoneGreen = 6, .none2 = 0, .none3 = 0, .none4 = 0, @@ -501,9 +501,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 18, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 5, + .kinstoneGreen = 5, .none2 = 15, .none3 = 0, .none4 = 0, @@ -523,9 +523,9 @@ const Droptable gAreaDroptables[] = { .bombs = 1, .arrows = 1, .mysteriousShells = 40, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 5, + .kinstoneGreen = 5, .none2 = 0, .none3 = 0, .none4 = 0, @@ -541,9 +541,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 19, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 15, + .kinstoneGreen = 15, .none2 = 28, .none3 = 0, .none4 = 0, @@ -559,9 +559,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 9, + .kinstoneGreen = 9, .none2 = 0, .none3 = 0, .none4 = 0, @@ -577,9 +577,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 1, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 15, + .kinstoneGreen = 15, .none2 = 0, .none3 = 0, .none4 = 0, @@ -595,9 +595,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 25, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 4, + .kinstoneGreen = 4, .none2 = 0, .none3 = 0, .none4 = 0, @@ -613,9 +613,9 @@ const Droptable gAreaDroptables[] = { .bombs = 20, .arrows = 0, .mysteriousShells = 15, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = -999, .none3 = 0, .none4 = 0, @@ -631,9 +631,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = -999, .mysteriousShells = 0, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = -999, .none3 = 0, .none4 = 0, @@ -649,9 +649,9 @@ const Droptable gAreaDroptables[] = { .bombs = -999, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, + .kinstoneRed = 0, .kinstoneBlue = 0, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = -999, .none3 = 0, .none4 = 0, @@ -667,9 +667,9 @@ const Droptable gAreaDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -687,9 +687,9 @@ const Droptable gObjectDroptables[] = { .bombs = -100, .arrows = -100, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -705,9 +705,9 @@ const Droptable gObjectDroptables[] = { .bombs = 1, .arrows = 1, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 1, .none3 = 0, .none4 = 0, @@ -723,9 +723,9 @@ const Droptable gObjectDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 140, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 20, .none3 = 0, .none4 = 0, @@ -741,9 +741,9 @@ const Droptable gObjectDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -759,9 +759,9 @@ const Droptable gObjectDroptables[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -777,9 +777,9 @@ const Droptable gObjectDroptables[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -796,9 +796,9 @@ const Droptable gObjectDroptables[] = { .bombs = -999, .arrows = 250, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -815,9 +815,9 @@ const Droptable gObjectDroptables[] = { .bombs = -10, .arrows = -10, .mysteriousShells = 12, - .kinstoneGreen = 1, + .kinstoneRed = 1, .kinstoneBlue = 2, - .kinstoneRed = 10, + .kinstoneGreen = 10, .none2 = 30, .none3 = 0, .none4 = 0, @@ -833,9 +833,9 @@ const Droptable gObjectDroptables[] = { .bombs = -10, .arrows = -10, .mysteriousShells = 24, - .kinstoneGreen = 2, + .kinstoneRed = 2, .kinstoneBlue = 4, - .kinstoneRed = 20, + .kinstoneGreen = 20, .none2 = 10, .none3 = 0, .none4 = 0, @@ -854,9 +854,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -872,9 +872,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -890,9 +890,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -908,9 +908,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -927,9 +927,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 20, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -945,9 +945,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 20, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -964,9 +964,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -982,9 +982,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -1000,9 +1000,9 @@ const Droptable gUnk_0800191C[] = { .bombs = -999, .arrows = -999, .mysteriousShells = -999, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = -999, .none3 = 0, .none4 = 0, @@ -1018,9 +1018,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 250, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -1036,9 +1036,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 125, .arrows = 125, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = -999, .none3 = 0, .none4 = 0, @@ -1054,9 +1054,9 @@ const Droptable gUnk_0800191C[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 20, + .kinstoneRed = 20, .kinstoneBlue = 40, - .kinstoneRed = 190, + .kinstoneGreen = 190, .none2 = -999, .none3 = 0, .none4 = 0, @@ -1077,9 +1077,9 @@ const Droptable gDroptableModifiers[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -1096,9 +1096,9 @@ const Droptable gDroptableModifiers[] = { .bombs = 2, .arrows = 2, .mysteriousShells = -999, - .kinstoneGreen = 0, - .kinstoneBlue = 0, .kinstoneRed = 0, + .kinstoneBlue = 0, + .kinstoneGreen = 0, .none2 = 0, .none3 = 0, .none4 = 0, @@ -1115,9 +1115,9 @@ const Droptable gDroptableModifiers[] = { .bombs = 0, .arrows = 0, .mysteriousShells = 0, - .kinstoneGreen = -999, - .kinstoneBlue = -999, .kinstoneRed = -999, + .kinstoneBlue = -999, + .kinstoneGreen = -999, .none2 = 0, .none3 = 0, .none4 = 0, diff --git a/src/enemy/armos.c b/src/enemy/armos.c index 38a30371..e4fa4af1 100644 --- a/src/enemy/armos.c +++ b/src/enemy/armos.c @@ -422,7 +422,7 @@ bool32 sub_0803086C(ArmosEntity* this) { FORCE_REGISTER(u32 r2, r2); if (this->unk_7c != NULL) { - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { centerX = super->x.HALF_U.HI - gRoomControls.origin_x; centerY = super->y.HALF_U.HI - gRoomControls.origin_y; // TODO for some reason the 0x3f of COORD_TO_TILE(super) needs to be forced to r2 here. diff --git a/src/enemy/businessScrub.c b/src/enemy/businessScrub.c index 9084508b..aa1001a5 100644 --- a/src/enemy/businessScrub.c +++ b/src/enemy/businessScrub.c @@ -13,6 +13,7 @@ #include "functions.h" #include "game.h" #include "item.h" +#include "kinstone.h" void sub_08028E9C(Entity*); void sub_08028EDC(Entity*); @@ -28,7 +29,7 @@ void sub_0802922C(Entity*); void sub_0802925C(Entity*); extern const struct SalesOffering gUnk_080CC954[]; -extern const u8 gUnk_080CC9C0[]; +extern const u8 kinstoneTypes[]; extern void (*const BusinessScrub_Functions[])(Entity*); extern void (*const gUnk_080CC9E0[])(Entity*); extern const u8 gUnk_080CCA04[]; @@ -257,8 +258,8 @@ void sub_08028CE8(Entity* this) { switch (offer->field_0x0 >> 2) { case 0: subtype = offer->field_0x9; - if (subtype == 0xff) { - subtype = gUnk_080CC9C0[Random() & 7]; + if (subtype == KINSTONE_RANDOM) { + subtype = kinstoneTypes[Random() & 7]; } CreateItemEntity(offer->offeredItem, subtype, 0); @@ -547,7 +548,7 @@ void sub_0802922C(Entity* this) { } void sub_0802925C(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); + AddInteractableWhenBigFuser(this, GetFusionToOffer(this)); } void sub_08029270(Entity* this) { @@ -577,17 +578,7 @@ const struct SalesOffering gUnk_080CC954[] = { #endif }; -const u8 gUnk_080CC9C0[] = { - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0x73, - 0x74, - 0x75, - -}; +const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; void (*const BusinessScrub_Functions[])(Entity*) = { BusinessScrub_OnTick, diff --git a/src/enemy/gyorgFemale.c b/src/enemy/gyorgFemale.c index 2c853edc..f4dc423e 100644 --- a/src/enemy/gyorgFemale.c +++ b/src/enemy/gyorgFemale.c @@ -239,30 +239,30 @@ void sub_080464C0(GyorgFemaleEntity* this) { gUpdateVisibleTiles = 1; } -NONMATCH("asm/non_matching/gyorg_female/sub_08046518.inc", void sub_08046518(void)) { - u32 r5; - u16* stack1; - u8* stack2; - u8* r6; +#define sub_08046518_offset 0x658 + +void sub_08046518(void) { + u16* ptr = gMapTop.metatileTypes; + u16* sl = &gMapTop.mapData[sub_08046518_offset]; + u16* stack1 = &gMapTop.mapDataClone[sub_08046518_offset]; + u8* stack2 = &gMapTop.unkData3[sub_08046518_offset]; + u8* r6 = &gMapTop.collisionData[sub_08046518_offset]; u32 i; - u16* sl; - sl = &gMapTop.metatileTypes[0xFFFFBCB0]; - stack1 = &gMapTop.metatileTypes[0xFFFFECB0]; - stack2 = (u8*)&gMapTop.metatileTypes[0x00006658]; - r6 = (u8*)&gMapTop.metatileTypes[0xFFFFD658]; - for (i = 0; i < 0x10; i++) { + for (i = 0x10; i != 0; i--) { + u32 j; + for (j = 0x10; j != 0; j--) { + u16 new_var; + stack1[j] = sl[j]; + new_var = ptr[sl[j]]; + stack2[j] = gUnk_080B37A0[new_var]; + r6[j] = gUnk_080B3E80[new_var]; + } sl += 0x40; stack1 += 0x40; - for (r5 = 0; r5 < 0x10; r5++) { - stack1[r5] = sl[r5]; - stack2[r5] = gUnk_080B37A0[gMapTop.metatileTypes[sl[r5]]]; - r6[r5] = gUnk_080B3E80[gMapTop.metatileTypes[sl[r5]]]; - } - stack2 = stack2 + 0x40; - r6 = r6 + 0x40; + stack2 += 0x40; + r6 += 0x40; } } -END_NONMATCH void sub_080465C8(void) { s32 x, y; diff --git a/src/enemy/ropeGolden.c b/src/enemy/ropeGolden.c index 025eaae1..b8921b9a 100644 --- a/src/enemy/ropeGolden.c +++ b/src/enemy/ropeGolden.c @@ -96,7 +96,49 @@ void sub_080382EC(Entity* this) { } } -ASM_FUNC("asm/non_matching/ropeGolden/sub_08038304.inc", void sub_08038304(Entity* this)) +void sub_08038304(Entity* this) { + u32 cVar2; + s32 tmp; + u32 tmp3; + u32 h; + + UpdateAnimationVariableFrames(this, 2); + if (!ProcessMovement0(this)) { + if (this->field_0x78.HALF.LO == this->direction) { +#ifdef EU + this->subtimer = 30; +#else + this->subtimer = 90; +#endif + sub_080383AC(this); + } else { + this->direction = this->field_0x78.HALF.LO; + } + } else { + tmp = 10; + if ((u8)((++this->timer) % tmp) == 0) { + this->timer = 0; + if (this->field_0x78.HALF.LO == this->direction) { + cVar2 = ((Random() & 2) - 1) << 27; + cVar2 = cVar2 >> 24; + h = this->field_0x78.HALF.HI; + tmp3 = (u8)cVar2 << 24; + if (tmp3 >> 24 == h) { + if (h == this->field_0x7a.HALF.LO) { + cVar2 = -tmp3 >> 24; + } + } + this->field_0x7a.HALF.LO = this->field_0x78.HALF.HI; + this->field_0x78.HALF.HI = cVar2; + this->direction = (this->direction + cVar2) & 0x18; + } else { + this->direction = this->field_0x78.HALF.LO; + } + this->animationState = this->direction >> 3; + InitializeAnimation(this, this->animationState + 4); + } + } +} void sub_080383AC(Entity* this) { u32 v; diff --git a/src/entity.c b/src/entity.c index 18f11f75..2ac2b37f 100644 --- a/src/entity.c +++ b/src/entity.c @@ -351,7 +351,7 @@ void DeleteEntity(Entity* ent) { UnloadGFXSlots(ent); UnloadOBJPalette(ent); UnloadOBJPalette2(ent); - sub_080788E0(ent); + RemoveInteractableObject(ent); FreeCarryEntity(ent); sub_0805EC60(ent); sub_08017744(ent); diff --git a/src/fileselect.c b/src/fileselect.c index bc54c39b..48ad54bf 100644 --- a/src/fileselect.c +++ b/src/fileselect.c @@ -210,9 +210,8 @@ const struct_080FC3E4 gUnk_080FC3E4[] = { { 0, 0xffff, 0, 1 }, }; -extern u16 gUnk_02034E4E[]; const Font gUnk_080FC844 = { - gUnk_02034E4E, BG_TILE_ADDR(0x198), gTextGfxBuffer, 0, 96, 224, 1, 1, 0, 1, 3, 0, 0, 1, 0 + &gBG0Buffer[0xcf], BG_TILE_ADDR(0x198), gTextGfxBuffer, 0, 96, 224, 1, 1, 0, 1, 3, 0, 0, 1, 0 }; const u16 gUnk_080FC85C[][3] = { @@ -1359,7 +1358,7 @@ void sub_0805144C(void) { void sub_08051458(void) { sub_080503A8(gMenu.column_idx + 9); - MemCopy(gBG3Buffer + 0x80, &gUnk_02022030, 0x400); + MemCopy(&gBG3Buffer[0x80], &gBG1Buffer[0x80], 0x400); } u32 sub_080514BC(u32); diff --git a/src/gameData.c b/src/gameData.c index 26462587..3009474c 100644 --- a/src/gameData.c +++ b/src/gameData.c @@ -10,24 +10,28 @@ // extern const u8 gUnk_080FE1B4[]; // const u8 gUnk_080FE1B4[] = {0, 84, 85, 86, 95, 96, 93, 94, 63, 252, 253, 254, 255, 0, 0, 0,0,}; const u8 gUnk_080FE1B4[] = { - ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, - ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_GREEN, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_RED, - ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, + ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_RED, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_GREEN, + ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, }; const u8 gUnk_080FE1C6[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 9, 10, 10, 11, 12, 13, 14, 15, 8, 15, 1, 8, }; -const u8 gUnk_080FE1DD[] = { - 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, 112, 111, 110, 110, 110, 111, 112, 112, 110, 111, - 111, 112, 110, 110, 112, 111, 112, 111, 110, 111, 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, - 112, 111, 110, 112, 110, 111, 112, 112, 110, 111, 111, 112, 110, 110, 112, 111, 112, 111, 110, 0, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, - 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 113, 114, 115, 116, 117, 117, - 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 115, 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, - 117, 116, 117, 116, 115, 116, 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 117, - 115, 116, 117, 117, 115, 116, 116, 117, 115, 115, 117, 116, 117, 116, 115, 0, 0, 0, 0, +const u8 gUnk_080FE1DD[3][0x40] = { + { 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x6E, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x6F, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x70, + 0x6E, 0x6F, 0x70, 0x70, 0x6E, 0x6F, 0x6F, 0x70, 0x6E, 0x6E, 0x70, 0x6F, 0x70, 0x6F, 0x6E, 0x00 }, + { 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, + 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72, 0x71, 0x72 }, + { 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x73, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x74, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x75, + 0x73, 0x74, 0x75, 0x75, 0x73, 0x74, 0x74, 0x75, 0x73, 0x73, 0x75, 0x74, 0x75, 0x74, 0x73, 0x00 }, }; +const u8 gPadding[3] = { 0, 0, 0 }; void Subtask_WorldEvent_Init(void); void Subtask_WorldEvent_Update(void); diff --git a/src/gameUtils.c b/src/gameUtils.c index 75ec1ca5..14f95c64 100644 --- a/src/gameUtils.c +++ b/src/gameUtils.c @@ -109,7 +109,7 @@ void InitializePlayer(void) { Entity* pl; - sub_080784C8(); + ResetPossibleInteraction(); MemClear(&gActiveItems, sizeof(gActiveItems)); MemClear(&gPlayerState, sizeof(gPlayerState)); MemFill32(0xffffffff, &gPlayerState.path_memory, sizeof(gPlayerState.path_memory)); @@ -223,8 +223,8 @@ void ModRupees(s32 delta) { if (newRupeeCount < 0) { newRupeeCount = 0; } else { - if (newRupeeCount > (u16)gWalletSizes[s->walletType * 2]) { - newRupeeCount = (u16)gWalletSizes[s->walletType * 2]; + if (newRupeeCount > gWalletSizes[s->walletType].size) { + newRupeeCount = gWalletSizes[s->walletType].size; } } s->rupees = newRupeeCount; @@ -244,7 +244,7 @@ bool32 AreaHasKeys(void) { return (gArea.areaMetadata >> 1) & 1; } -bool32 HasDungeonMap(void) { +bool32 HasDungeonSmallKey(void) { u32 tmp; if (AreaHasKeys()) @@ -252,7 +252,7 @@ bool32 HasDungeonMap(void) { return tmp ? 1 : 0; } -bool32 HasDungeonCompass(void) { +bool32 HasDungeonBigKey(void) { u32 tmp; if (AreaHasKeys()) @@ -260,15 +260,13 @@ bool32 HasDungeonCompass(void) { return tmp ? 1 : 0; } -bool32 HasDungeonBigKey(void) { +bool32 HasDungeonCompass(void) { if (!AreaHasKeys()) return 0; return (gSave.dungeonItems[gArea.dungeon_idx] >> 1) & 1; } -bool32 HasDungeonSmallKey(void) { - u32 tmp; - +bool32 HasDungeonMap(void) { if (!AreaHasKeys()) return 0; return gSave.dungeonItems[gArea.dungeon_idx] & 1; diff --git a/src/interrupts.c b/src/interrupts.c index db6cb6c2..3efa60ad 100644 --- a/src/interrupts.c +++ b/src/interrupts.c @@ -225,9 +225,9 @@ void PlayerUpdate(Entity* this) { static void HandlePlayerLife(Entity* this) { u32 temp; - gHUD.unk_2f = 0; - gHUD.unk_2d = 0; - gHUD.unk_2e = 0; + gHUD.rActionPlayerState = R_ACTION_NONE; + gHUD.rActionInteractTile = R_ACTION_NONE; + gHUD.rActionGrabbing = R_ACTION_NONE; if ((gPlayerEntity.contactFlags & 0x80) && (gPlayerEntity.iframes > 0)) SoundReq(SFX_86); @@ -240,7 +240,7 @@ static void HandlePlayerLife(Entity* this) { if (sub_08079B24() == 0) sub_08079708(this); - gUnk_03003DF0.unk_0 = 0; + gPossibleInteraction.isUpdated = 0; if (gPlayerState.field_0x27[0] != 0) gPlayerState.field_0x27[0]--; @@ -323,9 +323,9 @@ static void sub_080171F0(void) { sub_080028E0(&gPlayerEntity); if (gPlayerState.flags & PL_CLONING) - gHUD.unk_2f = 1; + gHUD.rActionPlayerState = R_ACTION_CANCEL; - sub_08078180(); + DetermineRButtonInteraction(); gPlayerState.field_0x7 &= ~0x80; gPlayerState.field_0xa &= 0xf; gPlayerState.keepFacing &= ~0x80; diff --git a/src/item/itemSword.c b/src/item/itemSword.c index 87b1070a..5598e0d7 100644 --- a/src/item/itemSword.c +++ b/src/item/itemSword.c @@ -127,7 +127,7 @@ void sub_080754B8(ItemBehavior* this, u32 index) { } if ((this->playerFrame & 0x80) != 0) { - if (((gPlayerState.flags & 0x80) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) { + if (((gPlayerState.flags & PL_MINISH) != 0) || ((gPlayerState.skills & SKILL_SPIN_ATTACK) == 0)) { sub_080759B8(this, index); } else { sub_08075580(this, index); diff --git a/src/item/itemTryPickupObject.c b/src/item/itemTryPickupObject.c index ace68c5d..19838963 100644 --- a/src/item/itemTryPickupObject.c +++ b/src/item/itemTryPickupObject.c @@ -95,7 +95,7 @@ void ItemPickupCheck(ItemBehavior* this, u32 index) { carried->subAction = 5; gPlayerState.framestate = PL_STATE_THROW; sub_080762C4(this, carried, 2, index); - gHUD.unk_2e = 8; + gHUD.rActionGrabbing = R_ACTION_GRAB; SoundReq(SFX_102); break; case 1: diff --git a/src/itemUtils.c b/src/itemUtils.c index c77bfa84..99208f41 100644 --- a/src/itemUtils.c +++ b/src/itemUtils.c @@ -12,7 +12,12 @@ #include "enemy.h" #include "message.h" -const s16 gWalletSizes[] = { 100, -4000, 300, -3996, 500, -3992, 999, -3988 }; +const Wallet gWalletSizes[] = { + { 100, 0xf060 }, + { 300, 0xf064 }, + { 500, 0xf068 }, + { 999, 0xf06c }, +}; const u8 gBombBagSizes[] = { 10, 30, @@ -109,7 +114,7 @@ u32 GiveItem(Item item, u32 param_2) { gSave.dungeonItems[gArea.dungeon_idx] |= metaData->unk2; break; case 0xd: - sub_0801E738(0x72); + AddKinstoneToBag(0x72); break; case 0x12: if (item == ITEM_BOOMERANG) { @@ -169,7 +174,7 @@ u32 GiveItem(Item item, u32 param_2) { SoundReq(SFX_103); break; case 0x0f: - sub_0801E738(param_2); + AddKinstoneToBag(param_2); break; case 0x10: gSave.stats.walletType++; @@ -403,9 +408,9 @@ extern u32 sub_08000F2C(s16*, const s16*, const s16*, const s16*); u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter); u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { extern const u8 gUnk_080FE1B4[] /* = { - ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, - ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_GREEN, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_RED, - ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, + ITEM_NONE, ITEM_RUPEE1, ITEM_RUPEE5, ITEM_RUPEE20, ITEM_HEART, ITEM_FAIRY, + ITEM_BOMBS5, ITEM_ARROWS5, ITEM_SHELLS, ITEM_KINSTONE_RED, ITEM_KINSTONE_BLUE, ITEM_KINSTONE_GREEN, + ITEM_ENEMY_BEETLE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, ITEM_NONE, }*/; int r0, r1, rand, summOdds, item; @@ -503,7 +508,7 @@ u32 CreateRandomItemDrop(Entity* arg0, u32 arg1) { return ITEM_NONE; } -extern u8 gUnk_080FE1DD[]; +extern u8 gUnk_080FE1DD[3][0x40]; u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { u32 adjustedParam = itemParameter; Entity* itemEntity; @@ -534,7 +539,7 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { break; } case ITEM_KINSTONE: - case ITEM_KINSTONE_GREEN ... ITEM_KINSTONE_RED: { + case ITEM_KINSTONE_RED ... ITEM_KINSTONE_GREEN: { u32 rand; if (GetInventoryValue(ITEM_KINSTONE_BAG) == 0) { @@ -545,9 +550,9 @@ u32 CreateItemDrop(Entity* arg0, u32 itemId, u32 itemParameter) { } if (itemId != ITEM_KINSTONE) { - adjustedParam = itemId - ITEM_KINSTONE_GREEN; + adjustedParam = itemId - ITEM_KINSTONE_RED; rand = (Random() & 0x3f); - adjustedParam = gUnk_080FE1DD[(rand + adjustedParam * 0x40)]; + adjustedParam = gUnk_080FE1DD[adjustedParam][rand]; if (adjustedParam == 0) { itemId = ITEM_NONE; } else { diff --git a/src/kinstone.c b/src/kinstone.c index 1be80aa3..e6b8f054 100644 --- a/src/kinstone.c +++ b/src/kinstone.c @@ -110,7 +110,7 @@ const struct_gUnk_080B3D20 gUnk_080B3D20[] = { { CHECK_ITEM, ITEM_BLUE_SWORD, 4, 1 }, { LOCAL_BANK_3, LV4_HAKA_08_CAP_0, 4, 2 }, { LOCAL_BANK_3, OUBO_KAKERA, 4, 3 }, - { CHECK_KINSTONE, KINSTONE_9, 4, 4 }, + { CHECK_KINSTONE, KINSTONE_SOURCE_FLOW, 4, 4 }, { LOCAL_BANK_0, TATSUMAKI, 4, 5 }, { LOCAL_BANK_2, SORA_YAKATA_ENTER, 4, 6 }, { LOCAL_BANK_2, SORA_CHIEF_TALK, 4, 7 }, diff --git a/src/manager/enterRoomTextboxManager.c b/src/manager/enterRoomTextboxManager.c index 59f31e2f..959e90f9 100644 --- a/src/manager/enterRoomTextboxManager.c +++ b/src/manager/enterRoomTextboxManager.c @@ -13,8 +13,6 @@ #include "message.h" #include "screen.h" -extern u8 gUnk_02034DF0[0x2F2]; - const u16 gUnk_08108DE8[] = { 0, 0x70b, 0x70c, 0x70d, 0x70e, 0x70f, 0x710, 0x711, 0x712, 0x713, 0x714, 0x715, 0x716, 0x717, 0x718, 0x719, 0x71a, 0x71b, 0x71c, 0x71d, 0x71e, 0x71f, 0x726, 0x720, 0x720, 0x721, 0x722, 0x723, 0x725, 0x727, 0x724, 0x728 }; @@ -67,7 +65,7 @@ void sub_0805E18C(EnterRoomTextboxManager* this) { } void sub_0805E1D8(EnterRoomTextboxManager* this) { - MemClear(&gUnk_02034DF0, 0x80); + MemClear(&gBG0Buffer[0xa0], 0x80); gScreen.bg0.updated = 1; DeleteThisEntity(); } @@ -80,7 +78,7 @@ void sub_0805E1F8(u32 unk0, bool32 isDungeon) { u8 unk_06[3]; } PACKED tmp; const Font* font; - MemClear(&gUnk_02034DF0, 0x80); + MemClear(&gBG0Buffer[0xa0], 0x80); MemCopy(gUnk_08108E60, &tmp, sizeof(tmp)); tmp.unk_04 = unk0 >> 8; tmp.unk_05 = unk0; diff --git a/src/manager/goronMerchantShopManager.c b/src/manager/goronMerchantShopManager.c index 3f6ed6b5..feb2f7c0 100644 --- a/src/manager/goronMerchantShopManager.c +++ b/src/manager/goronMerchantShopManager.c @@ -8,16 +8,17 @@ #include "asm.h" #include "flags.h" #include "object.h" +#include "item.h" typedef struct { u16 minType; - u16 maxType; + u16 numTypes; u16 x; u16 y; } GoronShopSpawnData; void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) { - static const GoronShopSpawnData gUnk_08108D5C[3] = { { 0x6e, 0x3, 0x210, 0x210 }, + static const GoronShopSpawnData shopSpawnData[3] = { { 0x6e, 0x3, 0x210, 0x210 }, { 0x71, 0x2, 0x220, 0x210 }, { 0x73, 0x3, 0x230, 0x210 } }; s32 uVar2; @@ -54,12 +55,12 @@ void GoronMerchantShopManager_Main(GoronMerchantShopManager* this) { this->itemActive[2] = 0; this->itemActive[1] = 0; this->itemActive[0] = 0; - spawnData = gUnk_08108D5C; + spawnData = shopSpawnData; count = 0; for (count = 0; count < 3;) { if (CheckGlobalFlag(GORON_KAKERA_L + count) == 0) { Entity* object = - CreateObject(SHOP_ITEM, 0x5c, ((s32)Random() % spawnData->maxType) + spawnData->minType); + CreateObject(SHOP_ITEM, ITEM_KINSTONE, ((s32)Random() % spawnData->numTypes) + spawnData->minType); if (object != NULL) { object->timer = 1; object->subtimer = count; diff --git a/src/menu/kinstoneMenu.c b/src/menu/kinstoneMenu.c index e9aaad8e..77b55818 100644 --- a/src/menu/kinstoneMenu.c +++ b/src/menu/kinstoneMenu.c @@ -27,8 +27,8 @@ extern u32 sub_08000E44(u32); extern void sub_080A3B74(void); extern u32 sub_080A3B48(void); extern void sub_0805ECEC(u32, u32, u32, u32); -extern void sub_0801E6C8(u32); -extern void sub_0801E798(u32); +extern void NotifyFusersOnFusionDone(u32); +extern void RemoveKinstoneFromBag(u32); extern WStruct* sub_0805F2C8(void); extern void sub_0805F300(WStruct*); extern u32 sub_0805F76C(u8*, WStruct*); @@ -86,7 +86,7 @@ const ScreenTransitionData gUnk_08128024[] = { u32 sub_080A3B48(void) { u32 index; for (index = 0; index <= 0x12; index++) { - if (gSave.unk12B[index] == 0) { + if (gSave.kinstoneAmounts[index] == 0) { break; } } @@ -151,7 +151,7 @@ void KinstoneMenu_Type0(void) { gScreen.bg3.updated = 1; KinstoneMenu_080A4528(); sub_080A4398(); - sub_0801E738(0); + AddKinstoneToBag(KINSTONE_NONE); sub_080A70AC((void*)gUnk_081280DC); SetMenuType(1); SetFade(FADE_BLACK_WHITE | FADE_INSTANT, 8); @@ -206,7 +206,7 @@ void KinstoneMenu_Type1(void) { case A_BUTTON: if (gMenu.column_idx == 2) { tmp3 = gGenericMenu.unk10.i / 0x10000; - gGenericMenu.unk2a = gSave.unk118[tmp3]; + gGenericMenu.unk2a = gSave.kinstoneTypes[tmp3]; SetMenuType(3); } break; @@ -265,8 +265,8 @@ void KinstoneMenu_Type3_Overlay0(void) { } void KinstoneMenu_Type3_Overlay1(void) { - u32 temp = gKinstoneWorldEvents[gKinstoneMenu.unk2a].unk5; - if (temp != gKinstoneWorldEvents[gFuseInfo.kinstoneId].unk5) { + u32 temp = gKinstoneWorldEvents[gKinstoneMenu.unk2a].shape; + if (temp != gKinstoneWorldEvents[gFuseInfo.kinstoneId].shape) { SoundReq(SFX_ITEM_SHIELD_BOUNCE); SetMenuType(4); } else { @@ -448,7 +448,7 @@ NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void K gOamCmd.x = ((gSineTable[(uVar1 + 0x40) & 0xff] * 0x42) / 0x100) - 0x10; iVar2 = gKinstoneMenu.unk10.WORD / 0x10000 + i; if (iVar2 >= 0) { - uVar3 = gSave.unk12B[iVar2]; + uVar3 = gSave.kinstoneAmounts[iVar2]; if (i == 0) { switch (gMenu.column_idx) { case 3: @@ -460,7 +460,7 @@ NONMATCH("asm/non_matching/menu/kinstone_menu/KinstoneMenu_080A414C.inc", void K } } if (0 < uVar3) { - sub_080A42E0(gSave.unk118[iVar2], uVar3); + sub_080A42E0(gSave.kinstoneTypes[iVar2], uVar3); } } } @@ -517,9 +517,9 @@ void sub_080A42E0(u32 kinstoneId, u32 param_2) { const KinstoneWorldEvent* ptr = &gKinstoneWorldEvents[kinstoneId]; if (param_2 == 0xff) { - uVar1 = ptr->unk2; + uVar1 = ptr->gfxOffsetFull; } else { - uVar1 = ptr->unk1; + uVar1 = ptr->gfxOffsetPiece; } iVar4 = sub_080A43A8(uVar1); if ((param_2 != 0) && (param_2 != 0xff)) { @@ -606,10 +606,10 @@ u32 sub_080A4418(u32 param_1, u32 param_2) { } void KinstoneMenu_080A4468(void) { - gUnk_03003DF0.unk_2 = 0; - gUnk_03003DF0.unk_4[3] = 0; - sub_0801E6C8(gFuseInfo.kinstoneId); - sub_0801E798(gKinstoneMenu.unk2a); + gPossibleInteraction.kinstoneId = KINSTONE_NONE; + gPossibleInteraction.currentObject->kinstoneId = KINSTONE_NONE; + NotifyFusersOnFusionDone(gFuseInfo.kinstoneId); + RemoveKinstoneFromBag(gKinstoneMenu.unk2a); } u32 KinstoneMenu_080A4494(void) { @@ -625,9 +625,9 @@ u32 KinstoneMenu_080A4494(void) { psVar1->unk1 = 0; sub_080A44E0(psVar1, gSave.name, 0x80); #if NON_MATCHING - ret = sub_080A44E0(psVar1, sub_08002632(gFuseInfo.ent) >> 0x20, 0xa0); + ret = sub_080A44E0(psVar1, GetFuserId(gFuseInfo.ent) >> 0x20, 0xa0); #else - sub_08002632(gFuseInfo.ent); + GetFuserId(gFuseInfo.ent); asm("" : "=r"(r1)); ret = sub_080A44E0(psVar1, r1, 0xa0); #endif diff --git a/src/menu/pauseMenu.c b/src/menu/pauseMenu.c index 652522fd..19fb7b40 100644 --- a/src/menu/pauseMenu.c +++ b/src/menu/pauseMenu.c @@ -11,6 +11,7 @@ #include "game.h" #include "item.h" #include "itemMetaData.h" +#include "kinstone.h" #include "main.h" #include "menu.h" #include "message.h" @@ -58,14 +59,14 @@ void Subtask_PauseMenu(void) { extern u8 gUnk_02034492[]; -void sub_0801E8D4(void); +void UpdateVisibleFusionMapMarkers(void); s32 sub_080A50A0(s32); void PauseMenu_Variant0(void) { const OverworldLocation* location; int r0, r1; - sub_0801E8D4(); + UpdateVisibleFusionMapMarkers(); sub_080A4D34(); r1 = 4; do { @@ -663,7 +664,7 @@ void sub_080A5594(void) { iVar5 = 0; if (GetInventoryValue(ITEM_KINSTONE_BAG) != 0) { for (i = 0; i < 0x13; i++) { - iVar5 += gSave.unk12B[i]; + iVar5 += gSave.kinstoneAmounts[i]; } if (iVar5 >= 0x50) { @@ -1151,17 +1152,17 @@ void DrawDungeonMapActually(void) { DrawDirect(DRAW_DIRECT_SPRITE_INDEX, (gMain.ticks & 0x20) != 0 ? 0x78 : 0x79); gOamCmd.y = 0x7e; gOamCmd._8 = 0x4380; - if (HasDungeonSmallKey()) { + if (HasDungeonMap()) { gOamCmd.x = 0x18; frameIndex = gSpriteAnimations_322[0x50]->index; DrawDirect(SUB_080A5D1C_SPRITE_INDEX, frameIndex); } - if (HasDungeonCompass()) { + if (HasDungeonBigKey()) { gOamCmd.x = 0x2e; frameIndex = gSpriteAnimations_322[0x52]->index; DrawDirect(SUB_080A5D1C_SPRITE_INDEX, frameIndex); } - if (HasDungeonBigKey()) { + if (HasDungeonCompass()) { gOamCmd.x = 0x45; gOamCmd._8 = 0x380; frameIndex = gSpriteAnimations_322[0x51]->index; @@ -1280,7 +1281,7 @@ void PauseMenu_Screen_7(void) { void sub_080A6024(void) { sub_080A70AC((KeyButtonLayout*)&gUnk_08128D60); - sub_0801E738(0); + AddKinstoneToBag(KINSTONE_NONE); sub_080A4398(); SetMenuType(1); } @@ -1298,11 +1299,11 @@ void sub_080A6044(void) { gOamCmd._6 = 0; uVar4 = 0; uVar2 = 0; - uVar1 = gSave.unk118[0]; + uVar1 = gSave.kinstoneTypes[0]; while (uVar1 != 0) { gOamCmd.x = (uVar4 & 3) * 0x30 + 0x2b; gOamCmd.y = (uVar4 >> 2) * 0x24 + 0x34; - uVar3 = gSave.unk12B[uVar2]; + uVar3 = gSave.kinstoneAmounts[uVar2]; gMenu.column_idx = 0; sub_080A42E0(uVar1, uVar3); uVar4++; @@ -1313,7 +1314,7 @@ void sub_080A6044(void) { if (0x11 < uVar2) { return; } - uVar1 = gSave.unk118[uVar2]; + uVar1 = gSave.kinstoneTypes[uVar2]; } } } diff --git a/src/menu/pauseMenuScreen6.c b/src/menu/pauseMenuScreen6.c index 716cbe42..1f4be228 100644 --- a/src/menu/pauseMenuScreen6.c +++ b/src/menu/pauseMenuScreen6.c @@ -205,8 +205,8 @@ void sub_080A68D4(void) { } for (i = 10; i <= 100; i++) { - if (CheckKinstoneFused(i) && !sub_0801E810(i)) { - uVar4 = gKinstoneWorldEvents[i].unk7; + if (CheckKinstoneFused(i) && !CheckFusionMapMarkerDisabled(i)) { + uVar4 = gKinstoneWorldEvents[i].mapMarkerIcon; ptr = &gWorldEvents[gKinstoneWorldEvents[i].worldEventId]; sub_080A698C(ptr->_c, ptr->_e, DRAW_DIRECT_SPRITE_INDEX, uVar4 + 100); } diff --git a/src/npc/anju.c b/src/npc/anju.c index 224978a9..fa66f537 100644 --- a/src/npc/anju.c +++ b/src/npc/anju.c @@ -28,9 +28,9 @@ void Anju(Entity* this) { } } -void sub_0806C354(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Anju_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Anju_Fusion(Entity* this) { diff --git a/src/npc/beedle.c b/src/npc/beedle.c index 351a53fb..16ed2ec2 100644 --- a/src/npc/beedle.c +++ b/src/npc/beedle.c @@ -9,22 +9,17 @@ #include "item.h" typedef struct { - s8 unk_00; - u8 unk_01; - u8 unk_02; - u8 unk_03; - s8 unk_04; - s8 unk_05; - s8 unk_06; - s8 unk_07; -} gUnk_0810C89C_struct; + Rect customHitbox; + s8 interactDirections; + u8 unused[3]; +} InteractCollisionData; void sub_080632E0(Entity* this); void sub_08063314(Entity* this); void sub_0806336C(Entity* this); void sub_08063390(Entity* this); -static const u8 gUnk_0810C88C[] = { +static const u8 gBeedleItems[] = { ITEM_NONE, ITEM_BOTTLE_PICOLYTE_BLUE, ITEM_BOTTLE_PICOLYTE_GREEN, @@ -32,10 +27,10 @@ static const u8 gUnk_0810C88C[] = { ITEM_BOTTLE_PICOLYTE_ORANGE, ITEM_BOTTLE_PICOLYTE_YELLOW, ITEM_BOTTLE_PICOLYTE_WHITE, - ITEM_NONE, + 0, }; static const Hitbox gUnk_0810C894 = { 0, 0, { 0, 0, 0, 0 }, 16, 6 }; -static const gUnk_0810C89C_struct gUnk_0810C89C[] = { +static const InteractCollisionData gBeedleCollisionData[] = { { 0, 0, 6, 6, 0, 0, 0, 0 }, { -24, 0, 6, 6, 0, 0, 0, 0 }, { -24, 16, 6, 6, 0, 0, 0, 0 }, { -24, 32, 6, 6, 0, 0, 0, 0 }, { 24, 0, 6, 6, 0, 0, 0, 0 }, { 24, 16, 6, 6, 0, 0, 0, 0 }, { 24, 32, 6, 6, 0, 0, 0, 0 }, @@ -72,7 +67,7 @@ void sub_080632C8(Entity* this) { void sub_080632E0(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810C8D4)) { InitializeAnimation(this, 0); - sub_08078778(this); + AddInteractableWhenBigObject(this); this->spriteSettings.draw = 1; this->action = 1; } @@ -103,7 +98,7 @@ void sub_08063390(Entity* this) { if (this->frame & ANIM_DONE) { this->action = 1; InitializeAnimation(this, GetAnimationState(this)); - sub_08078778(this); + AddInteractableWhenBigObject(this); } sub_0806ED78(this); } @@ -136,7 +131,7 @@ void sub_08063410(Entity* this) { this->type2 = 0; } sub_0807DD64(this); - sub_08078778(this); + AddInteractableWhenBigObject(this); } if (this->type != 0) { sub_0806346C(this); @@ -146,8 +141,10 @@ void sub_08063410(Entity* this) { GetNextFrame(this); } +// figures out with which of the 7 objects the player interacts with +// based on the player's position and facing direction void sub_0806346C(Entity* this) { - static const u8 gUnk_0810C8F0[][6][4] = { + static const u8 gUnk_0810C8F0[5][6][4] = { { { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, @@ -216,20 +213,20 @@ void sub_0806346C(Entity* this) { bVar1 = gUnk_0810C8F0[iVar2][iVar3][gPlayerEntity.animationState >> 1]; if (bVar1 != this->type2) { - const gUnk_0810C89C_struct* temp = &gUnk_0810C89C[bVar1]; - sub_08078850(this, 1, temp->unk_04, temp); + const InteractCollisionData* data = &gBeedleCollisionData[bVar1]; + SetInteractableObjectCollision(this, 1, data->interactDirections, data); this->type2 = bVar1; } } -void sub_080634E4(Entity* this, ScriptExecutionContext* context) { +void Beedle_GetObjectType(Entity* this, ScriptExecutionContext* context) { context->intVariable = this->type2; } -void sub_080634EC(Entity* this) { - gRoomVars.shopItemType = gUnk_0810C88C[this->type2]; +void Beedle_ConfirmBuyItem(Entity* this) { + gRoomVars.shopItemType = gBeedleItems[this->type2]; } -void sub_08063504(Entity* this, ScriptExecutionContext* context) { - context->condition = !!GetBottleContaining(gUnk_0810C88C[this->type2]); +void Beedle_IsBottleInInventory(Entity* this, ScriptExecutionContext* context) { + context->condition = !!GetBottleContaining(gBeedleItems[this->type2]); } diff --git a/src/npc/bladeBrothers.c b/src/npc/bladeBrothers.c index fb31384a..4532cfaf 100644 --- a/src/npc/bladeBrothers.c +++ b/src/npc/bladeBrothers.c @@ -235,7 +235,7 @@ void sub_08068A1C(Entity* this) { bVar1 = 3; } else { - sub_08078778(this); + AddInteractableWhenBigObject(this); offset = 2; bVar1 = 1; } @@ -291,8 +291,8 @@ void sub_08068ADC(Entity* this) { void sub_08068AFC(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/brocco.c b/src/npc/brocco.c index 5a860d69..e02ca622 100644 --- a/src/npc/brocco.c +++ b/src/npc/brocco.c @@ -30,7 +30,7 @@ void sub_0806355C(Entity* this) { this->action = this->action + 1; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 4); - sub_08078778(this); + AddInteractableWhenBigObject(this); } void sub_08063584(Entity* this) { @@ -114,9 +114,9 @@ void sub_080636D8(Entity* this) { ShowNPCDialogue(this, &gUnk_0810CAAC[gSave.global_progress]); } -void sub_080636F4(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Brocco_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Brocco_Fusion(Entity* this) { diff --git a/src/npc/carpenter.c b/src/npc/carpenter.c index a4da0fff..f54795e0 100644 --- a/src/npc/carpenter.c +++ b/src/npc/carpenter.c @@ -91,9 +91,9 @@ void sub_08067304(Entity* this) { ShowNPCDialogue(this, &dialog); } -void sub_08067314(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Carpenter_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Carpenter_Fusion(Entity* this) { diff --git a/src/npc/cat.c b/src/npc/cat.c index 11c85fd3..33586cb9 100644 --- a/src/npc/cat.c +++ b/src/npc/cat.c @@ -129,7 +129,7 @@ void sub_080677EC(Entity* this) { this->spriteSettings.flipX = 0; } - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); this->hitbox = (Hitbox*)&gUnk_08110EF0; uVar2 = sub_0805ACC0(this); if (uVar2 == 0) { @@ -281,7 +281,7 @@ void sub_08067AAC(Entity* this) { this->spriteSettings.flipX = this->direction >> 4 ^ 1; sub_08067DCC(this, 3); - sub_08078850(this, 0, gUnk_0811110C[2], gUnk_0811110F); + SetInteractableObjectCollision(this, 0, gUnk_0811110C[2], gUnk_0811110F); } void sub_08067B08(Entity* this) { @@ -293,7 +293,7 @@ void sub_08067B08(Entity* this) { void sub_08067B34(Entity* this) { sub_08067DCC(this, 0); this->frameDuration = (Random() & 0x30) + 0xb4; - sub_08078850(this, 0, gUnk_0811110C[this->spriteSettings.flipX], gUnk_0811110F); + SetInteractableObjectCollision(this, 0, gUnk_0811110C[this->spriteSettings.flipX], gUnk_0811110F); } void sub_08067B70(Entity* this) { @@ -350,9 +350,9 @@ void sub_08067C44(Entity* this) { if (uVar5 != this->field_0x68.HALF.HI) { if (uVar5 == 0) { - sub_08078778(this); + AddInteractableWhenBigObject(this); } else { - sub_080787A8(this, this->field_0x68.HALF.LO); + AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO); } } diff --git a/src/npc/cow.c b/src/npc/cow.c index e418ecd9..e74ed30a 100644 --- a/src/npc/cow.c +++ b/src/npc/cow.c @@ -50,7 +50,7 @@ void sub_08068FC0(Entity* ent) { *(u16*)&ent->field_0x68 = var1; ent->field_0x6a.HWORD = r2; } - ent->field_0x6c.HALF.LO = sub_0801E99C(ent); + ent->field_0x6c.HALF.LO = GetFusionToOffer(ent); InitAnimationForceUpdate(ent, ent->animationState + 4); } @@ -209,9 +209,9 @@ void sub_0806920C(Entity* ent) { if (var1 != ent->field_0x6c.HALF.HI) { if (var1 == 0) { - sub_08078778(ent); + AddInteractableWhenBigObject(ent); } else { - sub_080787A8(ent, ent->field_0x6c.HALF.LO); + AddInteractableAsMinishFuser(ent, ent->field_0x6c.HALF.LO); } } diff --git a/src/npc/cucco.c b/src/npc/cucco.c index c79084a8..28709607 100644 --- a/src/npc/cucco.c +++ b/src/npc/cucco.c @@ -1,5 +1,6 @@ #include "npc.h" #include "functions.h" +#include "kinstone.h" void (*const Cucco_Actions[])(Entity*); const u16 Cucco_Sounds[]; @@ -15,8 +16,8 @@ void Cucco(Entity* this) { void Cucco_Init(Entity* this) { this->action++; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_080787A8(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; sub_0806E4EC(this); @@ -112,8 +113,8 @@ void sub_0806E65C(Entity* this) { void Cucco_ShowMessage(Entity* this) { u32 val = 0; - u32 index = sub_08002632(this); - if (gSave.unk1C1[index] == 0xf3) { + u32 index = GetFuserId(this); + if (gSave.fuserOffers[index] == KINSTONE_FUSER_DONE) { val = 1; } @@ -135,4 +136,4 @@ void (*const Cucco_Actions[])(Entity*) = { }; const u16 Cucco_Sounds[] = { SFX_VO_CUCCO1, SFX_VO_CUCCO2, SFX_VO_CUCCO3, SFX_VO_CUCCO4 }; -const u16 Cucco_Messages[] = { TEXT_INDEX(TEXT_MINISH, 0Xb4), TEXT_INDEX(TEXT_MINISH, 0xb5) }; +const u16 Cucco_Messages[] = { TEXT_INDEX(TEXT_MINISH, 0xb4), TEXT_INDEX(TEXT_MINISH, 0xb5) }; diff --git a/src/npc/cuccoChick.c b/src/npc/cuccoChick.c index e73045ca..75ccdce3 100644 --- a/src/npc/cuccoChick.c +++ b/src/npc/cuccoChick.c @@ -23,8 +23,8 @@ void CuccoChick(Entity* this) { void CuccoChick_Init(Entity* this) { this->action++; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_080787A8(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); this->subAction = 0; sub_0806E764(this); diff --git a/src/npc/dampe.c b/src/npc/dampe.c index dbdff1e9..fad25893 100644 --- a/src/npc/dampe.c +++ b/src/npc/dampe.c @@ -33,9 +33,9 @@ void Dampe(Entity* this) { } } -void sub_0806BE3C(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Dampe_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Dampe_Fusion(Entity* this) { diff --git a/src/npc/din.c b/src/npc/din.c index 894edab4..c5608c7e 100644 --- a/src/npc/din.c +++ b/src/npc/din.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "npc.h" +#include "kinstone.h" void Din(Entity* this) { switch (this->action) { @@ -29,12 +30,12 @@ void Din(Entity* this) { } } -void sub_08064828(Entity* this) { - u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { - tmp = 0; +void Din_MakeInteractable(Entity* this) { + u32 kinstoneId = GetFusionToOffer(this); + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { + kinstoneId = KINSTONE_NONE; } - sub_08078784(this, tmp); + AddInteractableWhenBigFuser(this, kinstoneId); } void Din_Fusion(Entity* this) { diff --git a/src/npc/dog.c b/src/npc/dog.c index fef5cd27..10427419 100644 --- a/src/npc/dog.c +++ b/src/npc/dog.c @@ -206,7 +206,7 @@ void sub_08069B44(Entity* this) { this->timer = 30; this->animationState = 2; this->field_0x6a.HALF.LO = 0xff; - this->field_0x74.HALF.LO = sub_0801E99C(this); + this->field_0x74.HALF.LO = GetFusionToOffer(this); SetDefaultPriority(this, PRIO_MESSAGE); InitAnimationForceUpdate(this, 10); if ((this->flags & ENT_SCRIPTED) != 0) { @@ -351,7 +351,7 @@ void sub_08069E50(Entity* this) { if (GetInventoryValue(ITEM_QST_DOGFOOD) == 2) { this->action = 7; InitAnimationForceUpdate(this, 0x29); - sub_080788E0(this); + RemoveInteractableObject(this); EnqueueSFX(SFX_VO_DOG); EnqueueSFX(SFX_TASK_COMPLETE); } @@ -432,9 +432,9 @@ void sub_08069FE8(Entity* this) { if (tmp != this->field_0x6a.HALF.LO) { if (tmp == 0) { - sub_08078778(this); + AddInteractableWhenBigObject(this); } else { - sub_080787A8(this, this->field_0x74.HALF.LO); + AddInteractableAsMinishFuser(this, this->field_0x74.HALF.LO); } } this->field_0x6a.HALF.LO = tmp; diff --git a/src/npc/drLeft.c b/src/npc/drLeft.c index d991340e..aef5ecc4 100644 --- a/src/npc/drLeft.c +++ b/src/npc/drLeft.c @@ -77,11 +77,6 @@ void sub_0806C038(Entity* this) { } void sub_0806C09C(Entity* this) { - static const u8 gUnk_081133B4[] = { - 0, - 6, - 8, - 12, - }; - sub_08078850(this, 1, 0, &gUnk_081133B4); + static const Rect gUnk_081133B4 = { 0, 6, 8, 12 }; + SetInteractableObjectCollision(this, 1, 0, &gUnk_081133B4); } diff --git a/src/npc/epona.c b/src/npc/epona.c index 5c5adafa..b06a7777 100644 --- a/src/npc/epona.c +++ b/src/npc/epona.c @@ -27,7 +27,7 @@ void sub_080659B8(Entity* this) { this->spriteSettings.draw = 1; this->animationState = 6; this->field_0x68.HALF.HI = -1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); InitAnimationForceUpdate(this, this->animationState / 2); } @@ -73,9 +73,9 @@ void sub_08065A64(Entity* this) { if (uVar2 != this->field_0x68.HALF.HI) { if (uVar2 == 0) { - sub_08078778(this); + AddInteractableWhenBigObject(this); } else { - sub_080787A8(this, this->field_0x68.HALF.LO); + AddInteractableAsMinishFuser(this, this->field_0x68.HALF.LO); } } this->field_0x68.HALF.HI = uVar2; diff --git a/src/npc/farmers.c b/src/npc/farmers.c index 59de6957..d2c4e2fc 100644 --- a/src/npc/farmers.c +++ b/src/npc/farmers.c @@ -53,14 +53,14 @@ void sub_0806BCB8(Entity* this) { this->animationState = this->timer; } -void sub_0806BCC0(Entity* this) { +void Farmers_MarkEenieFuserDoner(Entity* this) { if (this->type == 0) { - sub_0806F188(this); + MarkFuserDone(this); } } -void sub_0806BCD4(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); +void Farmers_MakeInteractable(Entity* this) { + AddInteractableWhenBigFuser(this, GetFusionToOffer(this)); } void sub_0806BCE8(Entity* this) { @@ -69,12 +69,12 @@ void sub_0806BCE8(Entity* this) { DIALOG_KINSTONE, DIALOG_CHECK_FLAG, 1, - { TEXT_INDEX(TEXT_FARMERS, 0X7), TEXT_INDEX(TEXT_FARMERS, 0x2) } }, + { TEXT_INDEX(TEXT_FARMERS, 0x7), TEXT_INDEX(TEXT_FARMERS, 0x2) } }, { 0x29, DIALOG_KINSTONE, DIALOG_CHECK_FLAG, 1, - { TEXT_INDEX(TEXT_FARMERS, 0X11), TEXT_INDEX(TEXT_FARMERS, 0xd) } }, + { TEXT_INDEX(TEXT_FARMERS, 0x11), TEXT_INDEX(TEXT_FARMERS, 0xd) } }, }; ShowNPCDialogue(this, &gUnk_08113158[this->type]); } diff --git a/src/npc/farore.c b/src/npc/farore.c index 32f6e6ee..c802bf6f 100644 --- a/src/npc/farore.c +++ b/src/npc/farore.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "npc.h" +#include "kinstone.h" void Farore(Entity* this) { switch (this->action) { @@ -29,12 +30,12 @@ void Farore(Entity* this) { } } -void sub_08064A28(Entity* this) { - u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { - tmp = 0; +void Farore_MakeInteractable(Entity* this) { + u32 kinstoneId = GetFusionToOffer(this); + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { + kinstoneId = KINSTONE_NONE; } - sub_08078784(this, tmp); + AddInteractableWhenBigFuser(this, kinstoneId); } void Farore_Fusion(Entity* this) { diff --git a/src/npc/festari.c b/src/npc/festari.c index 5d698d36..f9e0cb57 100644 --- a/src/npc/festari.c +++ b/src/npc/festari.c @@ -21,8 +21,8 @@ void sub_0805FE10(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; SetDefaultPriority(this, PRIO_MESSAGE); - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/forestMinish.c b/src/npc/forestMinish.c index 7f3625f0..b002d976 100644 --- a/src/npc/forestMinish.c +++ b/src/npc/forestMinish.c @@ -534,9 +534,9 @@ void ForestMinish(Entity* this) { } } -void sub_08060090(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void ForestMinish_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void ForestMinish_Head(Entity* this) { diff --git a/src/npc/gentari.c b/src/npc/gentari.c index bf7818c1..d2d36028 100644 --- a/src/npc/gentari.c +++ b/src/npc/gentari.c @@ -8,8 +8,8 @@ void Gentari(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; SetDefaultPriority(this, PRIO_MESSAGE); - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); break; case 1: diff --git a/src/npc/ghostBrothers.c b/src/npc/ghostBrothers.c index e427c01e..2fe80a97 100644 --- a/src/npc/ghostBrothers.c +++ b/src/npc/ghostBrothers.c @@ -110,9 +110,9 @@ void sub_08065CCC(Entity* this) { gScreen.controls.alphaBlend = 0x10; } -void sub_08065D00(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void GhostBrothers_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void sub_08065D18(Entity* this) { @@ -219,7 +219,7 @@ void sub_08065EDC(Entity* this) { *(u16**)&this->field_0x6c = (++puVar3); } else { this->action++; - sub_08078778(this); + AddInteractableWhenBigObject(this); } } } diff --git a/src/npc/gina.c b/src/npc/gina.c index 4a729d2e..0095f7b3 100644 --- a/src/npc/gina.c +++ b/src/npc/gina.c @@ -9,8 +9,8 @@ void Gina(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); break; case 1: diff --git a/src/npc/gorman.c b/src/npc/gorman.c index cc2d9aa5..b7d13050 100644 --- a/src/npc/gorman.c +++ b/src/npc/gorman.c @@ -70,7 +70,7 @@ void sub_080697C4(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08111C3C)) { this->action = 1; InitializeAnimation(this, 2); - sub_08078778(this); + AddInteractableWhenBigObject(this); } } diff --git a/src/npc/goron.c b/src/npc/goron.c index e046f7c9..ce2fb731 100644 --- a/src/npc/goron.c +++ b/src/npc/goron.c @@ -30,7 +30,7 @@ void Goron(Entity* this) { } void sub_08069310(Entity* this) { - sub_08078778(this); + AddInteractableWhenBigObject(this); this->action = 1; InitAnimationForceUpdate(this, 2); } @@ -105,7 +105,7 @@ void sub_08069428(Entity* this, s32 offsetX, bool32 createFx65) { } u32 sub_08069480(Entity* this) { - return (u8)sub_0801E99C(this); + return (u8)GetFusionToOffer(this); } void sub_0806948C(Entity* this, ScriptExecutionContext* context) { @@ -113,12 +113,12 @@ void sub_0806948C(Entity* this, ScriptExecutionContext* context) { gActiveScriptInfo.flags |= 1; } -void sub_080694B0(Entity* this) { +void Goron_MakeInteractable(Entity* this) { u32 kinstone = (u8)sub_08069480(this); if (CheckKinstoneFused(kinstone)) { - sub_08078778(this); + AddInteractableWhenBigObject(this); } else { - sub_08078784(this, kinstone); + AddInteractableWhenBigFuser(this, kinstone); } } diff --git a/src/npc/goronMerchant.c b/src/npc/goronMerchant.c index 37f9ef3f..a26eb4b1 100644 --- a/src/npc/goronMerchant.c +++ b/src/npc/goronMerchant.c @@ -5,6 +5,7 @@ #include "flags.h" #include "save.h" #include "npc.h" +#include "item.h" static u32 GoronMerchant_GetSalePrice(Entity*); @@ -13,7 +14,7 @@ extern void (*const gUnk_08111B98[])(Entity*); static const u16 sKinstonePrices[]; -extern u32 sub_0801E7D0(u32); +extern u32 GetAmountInKinstoneBag(u32); void GoronMerchant(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { @@ -132,9 +133,9 @@ static u32 GoronMerchant_GetSalePrice(Entity* this) { void GoronMerchant_TryToBuyKinstone(Entity* this, ScriptExecutionContext* context) { s32 salePrice = GoronMerchant_GetSalePrice(this); if (salePrice <= gSave.stats.rupees) { - if (sub_0801E7D0(gRoomVars.shopItemType2) < 99) { + if (GetAmountInKinstoneBag(gRoomVars.shopItemType2) < 99) { ModRupees(-salePrice); - InitItemGetSequence(0x5c, gRoomVars.shopItemType2, 0); + InitItemGetSequence(ITEM_KINSTONE, gRoomVars.shopItemType2, 0); gRoomVars.shopItemType = 0; gRoomVars.shopItemType2 = 0; context->condition = 1; diff --git a/src/npc/gregal.c b/src/npc/gregal.c index 87333383..8a279a06 100644 --- a/src/npc/gregal.c +++ b/src/npc/gregal.c @@ -42,8 +42,8 @@ void sub_0806CAF4(Entity* this) { SortEntityAbove(this, npc); } sub_0807DD64(this); - sub_08078778(this); - sub_08078850(this, 1, (u8)gUnk_08113D84[1], gUnk_08113D84); + AddInteractableWhenBigObject(this); + SetInteractableObjectCollision(this, 1, (u8)gUnk_08113D84[1], gUnk_08113D84); } ExecuteScriptForEntity(this, NULL); HandleEntity0x82Actions(this); @@ -154,9 +154,9 @@ void sub_0806CD4C(Entity* this) { ChangeObjPalette(this, 0x110); } -void sub_0806CD58(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Gregal_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Gregal_Fusion(Entity* this) { diff --git a/src/npc/guard.c b/src/npc/guard.c index 661739ee..834c2f1b 100644 --- a/src/npc/guard.c +++ b/src/npc/guard.c @@ -294,7 +294,7 @@ void sub_08063D44(Entity* this) { ent->subtimer = 60; break; case 4 ... 5: - sub_08078778(this); + AddInteractableWhenBigObject(this); break; } this->action++; diff --git a/src/npc/hurdyGurdyMan.c b/src/npc/hurdyGurdyMan.c index 4decaced..1c45bbf3 100644 --- a/src/npc/hurdyGurdyMan.c +++ b/src/npc/hurdyGurdyMan.c @@ -26,7 +26,7 @@ void HurdyGurdyMan(Entity* this) { this->interactType = 0; this->field_0x68.HALF.HI = this->animIndex; InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity))); - index = sub_08002632(this); + index = GetFuserId(this); pointerToArray = gUnk_08001A7C[index]; if (this->field_0x68.HALF.LO == 0x32) { pointerToArray = pointerToArray + 3; @@ -100,9 +100,9 @@ void sub_0806E418(Entity* this) { ShowNPCDialogue(this, &dialogs[tmp]); } -void sub_0806E440(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void HurdyGurdyMan_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void HurdyGurdyMan_Fusion(Entity* this) { diff --git a/src/npc/kid.c b/src/npc/kid.c index 7001590f..ee3801db 100644 --- a/src/npc/kid.c +++ b/src/npc/kid.c @@ -76,6 +76,7 @@ void sub_080620F4(Entity*); void sub_08062130(Entity*); void sub_08062194(Entity*); void (*const gUnk_0810BE0C[])(Entity*) = { sub_080620F4, sub_08062130, sub_08062194 }; +extern s32 sub_080041E8(s32 x1, s32 y1, s32 x2, s32 y2); void sub_08062194(Entity*); const Dialog gUnk_0810BE10[] = { @@ -182,16 +183,21 @@ void sub_080622F4(Entity*); void sub_0806265C(Entity*, ScriptExecutionContext*); void sub_0806252C(Entity*); -typedef struct { - u16 unk_0; /* u16 */ - u16 unk_2; /* u16 */ - u16 unk_4; /* u16 */ - u8 unk_6; - u8 unk_7; +typedef union { + struct { + s16 x; + s16 y; + s16 z; + u8 framestate; + u8 animationState : 6; + u8 collisionLayer : 2; + } FIELDS; + u64 DWORD; } KidHeapItem; #define KID_HEAP_COUNT 0x14 typedef KidHeapItem KidHeap[KID_HEAP_COUNT]; +#define KID_HEAP ((KidHeapItem*)this->myHeap) void Kid(Entity* this) { if ((this->flags & ENT_SCRIPTED) != 0) { @@ -207,7 +213,7 @@ void sub_080620F4(Entity* this) { this->field_0x68.HALF.LO = 0; this->action = 1; InitAnimationForceUpdate(this, 2); - sub_08078778(this); + AddInteractableWhenBigObject(this); } } @@ -306,57 +312,198 @@ void sub_080621AC(Entity* this) { } } -ASM_FUNC("asm/non_matching/kid/sub_080622F4.inc", void sub_080622F4(Entity* this)) +#define KID_HEAP_SHIFT_RIGHT \ + heapPtr = KID_HEAP; \ + heapPtr += (KID_HEAP_COUNT - 2); \ + for (i = 0; i < (KID_HEAP_COUNT - 1); i++) { \ + heapPtr[1] = heapPtr[0]; \ + heapPtr--; \ + } + +void sub_080622F4(Entity* this) { + s32 dx; + s32 dy; + s32 dist; + s32 i; + + u32 animIndex; // used as 2nd param of InitAnimationForceUpdate + u32 animIndexTmp; + + KidHeapItem* heapPtr; + KidHeapItem item; + + // Prepended heap item is initialized from player's current state. + item.FIELDS.x = gPlayerEntity.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.z.HALF_U.HI; + item.FIELDS.framestate = gPlayerState.framestate; + item.FIELDS.animationState = gPlayerEntity.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer; + + heapPtr = this->myHeap; + if (heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16) { + dx = this->x.HALF.HI - gPlayerEntity.x.HALF.HI; + dy = this->y.HALF.HI - gPlayerEntity.y.HALF.HI; + + if (dx < 0) + dx = -dx; + if (dy < 0) + dy = -dy; + + if (dx > 120 || dy > 80) { + this->field_0x68.HALF.LO = 0; + return; + } + + sub_0806252C(this); + } + + animIndex = 0; + + if (item.DWORD != heapPtr->DWORD) { + KID_HEAP_SHIFT_RIGHT; + heapPtr = KID_HEAP; + heapPtr[0] = item; + + animIndex = 0x4; + if ((s8)this->field_0x68.HALF.HI > 0) { + this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1; + } + } else { + heapPtr += KID_HEAP_COUNT - 1; + if (heapPtr->FIELDS.z < 0) { + KID_HEAP_SHIFT_RIGHT; + animIndex = 0x4; + } else { + dist = sub_080041E8(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, (u16)heapPtr->FIELDS.x, + (u16)heapPtr->FIELDS.y); + dist = ((u32)dist) >> 0x4; + if (dist > 0x18) { + + KID_HEAP_SHIFT_RIGHT; + animIndex = 0x4; + } + } + } + heapPtr = KID_HEAP; + heapPtr += +KID_HEAP_COUNT - 1; + this->x.HALF.HI = heapPtr->FIELDS.x; + this->y.HALF.HI = heapPtr->FIELDS.y; + this->z.HALF.HI = heapPtr->FIELDS.z; + this->animationState = heapPtr->FIELDS.animationState; + this->collisionLayer = heapPtr->FIELDS.collisionLayer; + + if (((s8)this->field_0x68.HALF.HI) > 0) { + this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1; + } + + animIndexTmp = animIndex; + animIndex += this->animationState >> 1; + if (this->type == OBJECT) { + animIndex += 0x10; + } + + if (!(animIndex == this->animIndex || (animIndexTmp == 0 && ((s8)this->field_0x68.HALF.HI) > 0))) { + InitAnimationForceUpdate(this, animIndex); + this->field_0x68.HALF.HI = 0x1e; + } else { + UpdateAnimationSingleFrame(this); + } + + sub_0800451C(this); + return; +} void sub_08062500(Entity* this) { this->myHeap = zMalloc(sizeof(KidHeap)); if (this->myHeap != NULL) { this->field_0x68.HALF.LO = 1; - sub_080788E0(this); + RemoveInteractableObject(this); this->hitbox = NULL; sub_0806252C(this); } } -NONMATCH("asm/non_matching/kid/sub_0806252C.inc", void sub_0806252C(Entity* this)) { +void sub_0806252C(Entity* this) { s16 sVar1; s16 sVar2; u16 uVar3; u8 uVar4; - s16 r0; s16 sVar5; s16 sVar6; u8 bVar7; - KidHeapItem* heapObj; + KidHeapItem* item; s32 loopVar; - s32 iVar10; - s32 iVar11; - - uVar4 = gPlayerState.framestate; - uVar3 = gPlayerEntity.z.HALF.HI; - sVar2 = gPlayerEntity.y.HALF.HI; - sVar1 = gPlayerEntity.x.HALF.HI; - r0 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; - sVar5 = FixedDiv(gPlayerEntity.x.HALF.HI - this->x.HALF.HI, KID_HEAP_COUNT); - sVar6 = FixedDiv(r0, KID_HEAP_COUNT); - heapObj = (KidHeapItem*)this->myHeap; - iVar10 = 0; - iVar11 = 0; - - for (loopVar = KID_HEAP_COUNT - 1; loopVar > -1; loopVar--) { - heapObj->unk_0 = sVar1 - (s16)((u32)iVar11 >> 8); - heapObj->unk_2 = sVar2 - (s16)((u32)iVar10 >> 8); - heapObj->unk_4 = uVar3; - heapObj->unk_6 = uVar4; - bVar7 = this->animationState & 0x3f; - heapObj->unk_7 = (heapObj->unk_7 & 0xc0) | bVar7; - heapObj->unk_7 = bVar7 | this->collisionLayer << 6; - heapObj = heapObj + 1; - iVar10 = iVar10 + sVar6; - iVar11 = iVar11 + sVar5; + FORCE_REGISTER(u32 r5, r5); + FORCE_REGISTER(u32 r6, r6); + FORCE_REGISTER(u32 r0, r0); + FORCE_REGISTER(u32 r1, r1); + FORCE_REGISTER(u32 r2, r2); + u32 r3; + FORCE_REGISTER(s32 r8, r8); + s32 y; + s32 r10; + FORCE_REGISTER(s32 x, r12); + + r1 = gPlayerEntity.x.HALF_U.HI; + r3 = 0xffff0000; + r0 = r3; + r0 &= r5; + r0 |= r1; + + r1 = gPlayerEntity.y.HALF_U.HI; + r1 <<= 0x10; + r2 = 0x0000ffff; + r0 &= r2; + r0 |= r1; + r5 = r0; + + r0 = gPlayerEntity.z.HALF_U.HI; + r3 &= r6; + r3 |= r0; + + r0 = gPlayerState.framestate; + r0 <<= 0x10; + r2 = 0xff00ffff; + r2 &= r3; + r2 |= r0; + + r1 = gPlayerEntity.animationState; + r0 = 0x3f; + r1 &= r0; + r1 <<= 0x18; + r0 = 0xc0ffffff; + r0 &= r2; + r0 |= r1; + + r1 = gPlayerEntity.collisionLayer; + r1 <<= 0x1e; + r2 = 0x3fffffff; + r0 &= r2; + r0 |= r1; + r6 = r0; + + r10 = r0 = gPlayerEntity.x.HALF.HI - this->x.HALF.HI; + r8 = r0 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; + + r10 = FixedDiv(r10, KID_HEAP_COUNT); + r8 = FixedDiv(r8, KID_HEAP_COUNT); + item = (KidHeapItem*)this->myHeap; + y = 0; + x = 0; + + for (loopVar = KID_HEAP_COUNT - 1; loopVar >= 0; loopVar--) { + item->FIELDS.x = r5 - (x >> 8); + item->FIELDS.y = (r5 >> 0x10) - (y >> 8); + item->FIELDS.z = r6; + item->FIELDS.framestate = r6 >> 0x10; + item->FIELDS.animationState = this->animationState & 0x3f; + item->FIELDS.collisionLayer = this->collisionLayer; + item++; + y = y + r8; + x = x + r10; } } -END_NONMATCH void sub_08062634(Entity* this) { u32 a = this->type2; @@ -554,9 +701,9 @@ void sub_08062948(Entity* this, ScriptExecutionContext* context) { } } -void sub_08062A48(Entity* this, ScriptExecutionContext* context) { - this->field_0x6a.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x6a.HALF.LO); +void Kid_MakeInteractable(Entity* this, ScriptExecutionContext* context) { + this->field_0x6a.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x6a.HALF.LO); } void Kid_Fusion(Entity* this) { diff --git a/src/npc/kingDaltus.c b/src/npc/kingDaltus.c index bc22daa4..3bdf60a2 100644 --- a/src/npc/kingDaltus.c +++ b/src/npc/kingDaltus.c @@ -39,8 +39,8 @@ void KingDaltus(Entity* this) { void sub_08066654(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); InitAnimationForceUpdate(this, 2); } @@ -72,7 +72,7 @@ void sub_080666DC(Entity* this) { void sub_080666E4(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); } @@ -86,8 +86,8 @@ void sub_08066718(Entity* this) { } } -void sub_0806672C(Entity* this) { - sub_08078784(this, this->field_0x68.HALF.LO); +void KingDaltus_MakeInteractable(Entity* this) { + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void sub_0806673C(Entity* this) { diff --git a/src/npc/librari.c b/src/npc/librari.c index 5f0b6786..e725b669 100644 --- a/src/npc/librari.c +++ b/src/npc/librari.c @@ -9,8 +9,8 @@ void Librari(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; this->animationState = this->timer; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; diff --git a/src/npc/malon.c b/src/npc/malon.c index d38be5aa..1ab967c0 100644 --- a/src/npc/malon.c +++ b/src/npc/malon.c @@ -43,8 +43,8 @@ void sub_08065888(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; this->animationState = 4; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } diff --git a/src/npc/mama.c b/src/npc/mama.c index 0cbda85b..0e2b7620 100644 --- a/src/npc/mama.c +++ b/src/npc/mama.c @@ -92,9 +92,9 @@ void sub_0806C4DC(Entity* this) { ShowNPCDialogue(this, &dialogs[gSave.global_progress]); } -void sub_0806C4F8(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Mama_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Mama_Fusion(Entity* this) { diff --git a/src/npc/mayorHagen.c b/src/npc/mayorHagen.c index 5550feb6..e5e5cad3 100644 --- a/src/npc/mayorHagen.c +++ b/src/npc/mayorHagen.c @@ -11,7 +11,7 @@ void MayorHagen(Entity* this) { case 0: this->action = 1; this->field_0x68.HALF.HI = 0; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); SetDefaultPriority(this, PRIO_MESSAGE); sub_0807DD50(this); break; @@ -37,15 +37,10 @@ void MayorHagen(Entity* this) { } } -void sub_0806CE5C(Entity* this) { - static const u8 gUnk_08113F44[] = { - 0, - 8, - 8, - 16, - }; - sub_08078784(this, sub_0801E99C(this)); - sub_08078850(this, 1, 0, gUnk_08113F44); +void MayorHagen_MakeInteractable(Entity* this) { + static const Rect gUnk_08113F44 = { 0, 8, 8, 16 }; + AddInteractableWhenBigFuser(this, GetFusionToOffer(this)); + SetInteractableObjectCollision(this, 1, 0, &gUnk_08113F44); } void sub_0806CE80(Entity* this) { diff --git a/src/npc/melari.c b/src/npc/melari.c index 7e20dbed..59760a78 100644 --- a/src/npc/melari.c +++ b/src/npc/melari.c @@ -29,7 +29,7 @@ void sub_08068708(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08111520)) { this->action = 1; InitializeAnimation(this, 0); - sub_08078778(this); + AddInteractableWhenBigObject(this); } } @@ -100,9 +100,9 @@ void sub_08068780(Entity* this) { } } -void sub_08068884(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Melari_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Melari_Head(Entity* this) { diff --git a/src/npc/ministerPotho.c b/src/npc/ministerPotho.c index 72323ed3..fe5806c1 100644 --- a/src/npc/ministerPotho.c +++ b/src/npc/ministerPotho.c @@ -27,7 +27,7 @@ void sub_080667E4(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 2); - sub_08078778(this); + AddInteractableWhenBigObject(this); } void sub_08066808(Entity* this) { @@ -60,7 +60,7 @@ void sub_08066864(Entity* this) { case 0: this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); break; case 1: @@ -81,8 +81,8 @@ void sub_08066864(Entity* this) { } } -void sub_080668F0(Entity* this) { - sub_08078784(this, sub_0801E99C(this)); +void MinisterPotho_MakeInteractable(Entity* this) { + AddInteractableWhenBigFuser(this, GetFusionToOffer(this)); } void sub_08066904(Entity* this) { diff --git a/src/npc/mountainMinish.c b/src/npc/mountainMinish.c index 647b550a..bfa0e17c 100644 --- a/src/npc/mountainMinish.c +++ b/src/npc/mountainMinish.c @@ -57,7 +57,7 @@ void MountainMinish(Entity* this) { void sub_08067E60(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08111358)) { this->action = 1; - sub_08078778(this); + AddInteractableWhenBigObject(this); InitializeAnimation(this, 2); } } @@ -179,9 +179,9 @@ void sub_08067EF0(Entity* this) { } } -void sub_08068104(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void MountainMinish_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void sub_0806811C(Entity* this) { diff --git a/src/npc/mutoh.c b/src/npc/mutoh.c index d1d5a00a..a93b7258 100644 --- a/src/npc/mutoh.c +++ b/src/npc/mutoh.c @@ -82,9 +82,9 @@ void sub_080670E4(Entity* this) { ShowNPCDialogue(this, &dialogs[gSave.global_progress]); } -void sub_08067100(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Mutoh_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Mutoh_Fusion(Entity* this) { diff --git a/src/npc/nayru.c b/src/npc/nayru.c index 262b251c..b9ea0df4 100644 --- a/src/npc/nayru.c +++ b/src/npc/nayru.c @@ -1,6 +1,7 @@ #include "global.h" #include "entity.h" #include "npc.h" +#include "kinstone.h" void Nayru(Entity* this) { switch (this->action) { @@ -29,12 +30,12 @@ void Nayru(Entity* this) { } } -void sub_08064928(Entity* this) { - u32 tmp = sub_0801E99C(this); - if ((gSave.unk141[sub_08002632(this)] != 0) && (gSave.global_progress < 7)) { - tmp = 0; +void Nayru_MakeInteractable(Entity* this) { + u32 kinstoneId = GetFusionToOffer(this); + if ((gSave.fuserProgress[GetFuserId(this)] != 0) && (gSave.global_progress < 7)) { + kinstoneId = KINSTONE_NONE; } - sub_08078784(this, tmp); + AddInteractableWhenBigFuser(this, kinstoneId); } void Nayru_Fusion(Entity* this) { diff --git a/src/npc/npc23.c b/src/npc/npc23.c index eccd933c..a07b14b1 100644 --- a/src/npc/npc23.c +++ b/src/npc/npc23.c @@ -38,7 +38,7 @@ void sub_080662F8(Entity* this) { this->parent = &gPlayerEntity; this->cutsceneBeh.HWORD = 0; sub_08066490(this, this->parent); - sub_08078778(this); + AddInteractableWhenBigObject(this); } void sub_08066358(Entity* this) { @@ -56,7 +56,7 @@ void sub_08066358(Entity* this) { this->speed = 0x80; this->cutsceneBeh.HWORD = 1; gPauseMenuOptions.disabled = 1; - sub_080788E0(this); + RemoveInteractableObject(this); } } else { sub_08066490(this, this->parent); diff --git a/src/npc/npc26.c b/src/npc/npc26.c index a9c19cf2..fddbf460 100644 --- a/src/npc/npc26.c +++ b/src/npc/npc26.c @@ -18,7 +18,7 @@ static void sub_080669B8(Entity* this) { this->action = 1; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 2); - sub_08078778(this); + AddInteractableWhenBigObject(this); } static void sub_080669DC(Entity* this) { diff --git a/src/npc/npc4E.c b/src/npc/npc4E.c index 3e4bc3c7..cdfd7abe 100644 --- a/src/npc/npc4E.c +++ b/src/npc/npc4E.c @@ -4,6 +4,7 @@ #include "game.h" #include "hitbox.h" #include "item.h" +#include "kinstone.h" #include "npc.h" #include "object.h" #include "save.h" @@ -11,15 +12,16 @@ #include "sound.h" typedef struct { - u32 unk_00; - s8 unk_04; -} gUnk_0810C89C_struct; + Rect customHitbox; + u8 interactDirections; + u8 unused[3]; +} InteractCollisionData; extern void script_MinishVillageObjectLeftStoneOpening; // Cutscene data type? extern void script_MinishVillageObjectRightStoneOpening; // Cutscene data type? const Hitbox gUnk_08114154; -const u8 gUnk_0811415C[]; +const InteractCollisionData gNpc4ECollisionData[]; const ScreenTransitionData* const gNpc4ETransitions[]; const u8 gNpc4ETransitionTypes[]; const u16 gUnk_081141F4[]; @@ -41,66 +43,61 @@ void NPC4E(Entity* this) { } } -void sub_0806DA04(Entity* this, ScriptExecutionContext* context) { - // TODO gUnk_0811415C should be a gUnk_0810C89C_struct[], but then a lot of bytes everywhere are wrong? - gUnk_0810C89C_struct* a = (gUnk_0810C89C_struct*)&( - (gUnk_0810C89C_struct*)gUnk_0811415C)[context->intVariable]; // cast necessary to no longer make it a const* ? - sub_08078850(this, 1, (u8)a->unk_04, a); +void NPC4E_ChangeInteractableHitbox(Entity* this, ScriptExecutionContext* context) { + const InteractCollisionData* data = &gNpc4ECollisionData[context->intVariable]; + SetInteractableObjectCollision(this, 1, data->interactDirections, data); } void NPC4E_DoScreenTransition(Entity* this, ScriptExecutionContext* context) { sub_0808091C(gNpc4ETransitions[context->intVariable], gNpc4ETransitionTypes[context->intVariable]); } -// Returns the kinstone id? -u8 sub_0806DA3C(Entity* this) { +u8 NPC4E_GetKinstoneId(Entity* this) { u32 result; switch (this->type) { default: - result = 0; + result = KINSTONE_NONE; break; case 1: - result = 1; + result = KINSTONE_MYSTERIOUS_CLOUD_TOP_RIGHT; break; case 2: - result = 2; + result = KINSTONE_MYSTERIOUS_CLOUD_BOTTOM_LEFT; break; case 3: - result = 3; + result = KINSTONE_MYSTERIOUS_CLOUD_TOP_LEFT; break; case 4: - result = 4; + result = KINSTONE_MYSTERIOUS_CLOUD_MIDDLE; break; case 5: - result = 5; + result = KINSTONE_MYSTERIOUS_CLOUD_BOTTOM_RIGHT; break; case 11: - result = 9; + result = KINSTONE_SOURCE_FLOW; break; case 6: case 7: case 8: case 9: case 10: - result = sub_0801E99C(this); + result = GetFusionToOffer(this); break; } return result; } -// Check whether a kinstone fusion is possible and store the result somewhere in param_2? -void sub_0806DAAC(Entity* this, ScriptExecutionContext* context) { - context->condition = CheckKinstoneFused(sub_0806DA3C(this)); +void NPC4E_IsKinstoneFused(Entity* this, ScriptExecutionContext* context) { + context->condition = CheckKinstoneFused(NPC4E_GetKinstoneId(this)); gActiveScriptInfo.flags |= 1; } -// maybe actually execute the kinstone fusion? -void sub_0806DAD0(Entity* this) { - sub_08078790(this, sub_0806DA3C(this)); +void NPC4E_MakeFuserInteractable(Entity* this) { + AddInteractableFuser(this, NPC4E_GetKinstoneId(this)); } -void sub_0806DAE8(Entity* this) { +void NPC4E_SetPinwheelFlag(Entity* this) { switch (this->type - 1) { case 0: SetLocalFlag(KUMOUE_02_AWASE_01); @@ -122,7 +119,7 @@ void sub_0806DAE8(Entity* this) { SoundReq(SFX_TASK_COMPLETE); } -void sub_0806DB44(Entity* this, ScriptExecutionContext* context) { +void NPC4E_IsEveryPinwheelActivated(Entity* this, ScriptExecutionContext* context) { context->condition = 0; if (CheckLocalFlag(KUMOUE_02_AWASE_01) && CheckLocalFlag(KUMOUE_02_AWASE_02) && @@ -148,29 +145,29 @@ void sub_0806DB84(Entity* this, ScriptExecutionContext* context) { } } -u32 sub_0806DBF4(u32 param_1) { - switch (param_1) { - case 1: - case 2: - case 3: - case 4: - case 6: - param_1 = ITEM_SMITH_SWORD; +Item NPC4E_GetItemWithSwordUpgraded(Item itemId) { + switch (itemId) { + case ITEM_SMITH_SWORD: + case ITEM_GREEN_SWORD: + case ITEM_RED_SWORD: + case ITEM_BLUE_SWORD: + case ITEM_FOURSWORD: + itemId = ITEM_SMITH_SWORD; if (GetInventoryValue(ITEM_GREEN_SWORD) != 0) { - param_1 = ITEM_GREEN_SWORD; + itemId = ITEM_GREEN_SWORD; } if (GetInventoryValue(ITEM_RED_SWORD) != 0) { - param_1 = ITEM_RED_SWORD; + itemId = ITEM_RED_SWORD; } if (GetInventoryValue(ITEM_BLUE_SWORD) != 0) { - param_1 = ITEM_BLUE_SWORD; + itemId = ITEM_BLUE_SWORD; } if (GetInventoryValue(ITEM_FOURSWORD) != 0) { - param_1 = ITEM_FOURSWORD; + itemId = ITEM_FOURSWORD; } break; } - return param_1; + return itemId; } void NPC4E_SaveEquippedItems(Entity* this) { @@ -179,8 +176,8 @@ void NPC4E_SaveEquippedItems(Entity* this) { } void NPC4E_RestoreEquippedItems(Entity* this) { - ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.LO), EQUIP_SLOT_A); - ForceEquipItem(sub_0806DBF4(this->field_0x68.HALF.HI), EQUIP_SLOT_B); + ForceEquipItem(NPC4E_GetItemWithSwordUpgraded(this->field_0x68.HALF.LO), EQUIP_SLOT_A); + ForceEquipItem(NPC4E_GetItemWithSwordUpgraded(this->field_0x68.HALF.HI), EQUIP_SLOT_B); } void sub_0806DC7C(void) { @@ -234,13 +231,12 @@ void NPC4E_Fusion(Entity* this) { const Hitbox gUnk_08114154 = { 0, -8, 0, 0, 0, 0, 24, 8 }; -const u8 gUnk_0811415C[] = { // - 0x00, 0x00, 0x08, 0x08, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x08, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x10, 0x04, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x04, 0x0e, 0x00, 0x00, 0x00, - 0x00, 0x08, 0x10, 0x04, 0x0e, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x18, 0x08, 0x0e, 0x00, 0x00, 0x00, +const InteractCollisionData gNpc4ECollisionData[] = { // + { 0, 0, 8, 8, 0x0E, 0, 0, 0 }, { 0, 0, 26, 8, 0x0E, 0, 0, 0 }, { 0, 0, 16, 4, 0x0E, 0, 0, 0 }, + { 0, 0, 10, 10, 0x00, 0, 0, 0 }, { 0, 0, 10, 10, 0x00, 0, 0, 0 }, { 0, 0, 6, 4, 0x0E, 0, 0, 0 }, + { 0, 8, 16, 4, 0x0E, 0, 0, 0 }, { 0, -8, 24, 8, 0x0E, 0, 0, 0 }, #ifndef EU - 0x00, 0x00, 0x58, 0x08, 0x0e, 0x00, 0x00, 0x00 + { 0, 0, 88, 8, 0x0E, 0, 0, 0 } #endif }; diff --git a/src/npc/npc5.c b/src/npc/npc5.c index f43e40c3..4076c54a 100644 --- a/src/npc/npc5.c +++ b/src/npc/npc5.c @@ -875,7 +875,7 @@ void sub_08061ACC(Entity* this) { this->subAction = 0xff; this->timer = 0; this->followerFlag = this->followerFlag & 0xfe; - sub_08078778(this); + AddInteractableWhenBigObject(this); sub_08061AFC(this); } diff --git a/src/npc/npc9.c b/src/npc/npc9.c index 76a69b93..a8361648 100644 --- a/src/npc/npc9.c +++ b/src/npc/npc9.c @@ -22,7 +22,7 @@ void sub_08062AF0(Entity* this) { this->action = 1; this->spriteSettings.draw = TRUE; InitializeAnimation(this, 0); - sub_08078778(this); + AddInteractableWhenBigObject(this); } void sub_08062B14(Entity* this) { diff --git a/src/npc/percy.c b/src/npc/percy.c index acb65a57..21a205f4 100644 --- a/src/npc/percy.c +++ b/src/npc/percy.c @@ -41,7 +41,7 @@ void sub_0806B3CC(Entity* this) { } this->action = 1; InitializeAnimation(this, 0); - sub_08078778(this); + AddInteractableWhenBigObject(this); } GetNextFrame(this); if (this->interactType != 0) { @@ -71,7 +71,7 @@ void sub_0806B41C(Entity* this) { this->action = 2; this->interactType = 0; InitializeAnimation(this, sub_0806F5A4(GetFacingDirection(this, &gPlayerEntity)) + 4); - idx = sub_08002632(this); + idx = GetFuserId(this); tmp = gUnk_08001A7C[idx]; if (this->field_0x68.HALF.LO == 33) tmp += 3; @@ -161,9 +161,9 @@ void sub_0806B540(Entity* this) { gActiveScriptInfo.commandSize = 0; } -void sub_0806B60C(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Percy_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Percy_Fusion(Entity* this) { diff --git a/src/npc/picolyteBottle.c b/src/npc/picolyteBottle.c index be49c2f3..80ebfc0a 100644 --- a/src/npc/picolyteBottle.c +++ b/src/npc/picolyteBottle.c @@ -26,7 +26,7 @@ void PicolyteBottle_Action1(PicolyteBottleEntity* this); void PicolyteBottle_Action2(PicolyteBottleEntity* this); void nullsub_111(PicolyteBottleEntity* this); -extern void sub_08078828(Entity*); +extern void AddInteractableChest(Entity*); void PicolyteBottle(Entity* this) { static void (*const PicolyteBottle_Actions[])(PicolyteBottleEntity*) = { @@ -97,7 +97,7 @@ void PicolyteBottle_Action2(PicolyteBottleEntity* this) { super->child = obj; CopyPosition(super, obj); } - sub_080788E0(super); + RemoveInteractableObject(super); sub_0807B7D8(0x74, this->unk76, 2); } } @@ -149,7 +149,7 @@ void sub_0806E0DC(PicolyteBottleEntity* this) { DeleteEntity(super->child); super->child = NULL; } - sub_08078828(super); + AddInteractableChest(super); sub_0807B7D8(0x73, this->unk76, 2); } else { super->action = 3; diff --git a/src/npc/pina.c b/src/npc/pina.c index 545a4097..f11cbdd9 100644 --- a/src/npc/pina.c +++ b/src/npc/pina.c @@ -32,7 +32,7 @@ void sub_08063A98(Entity* this) { this->action++; this->spriteSettings.draw = 1; InitAnimationForceUpdate(this, 4); - sub_08078778(this); + AddInteractableWhenBigObject(this); } void sub_08063AC0(Entity* this) { @@ -150,9 +150,9 @@ void sub_08063C90(Entity* this) { ShowNPCDialogue(this, &gUnk_0810CE04[gSave.global_progress]); } -void sub_08063CAC(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Pina_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Pina_Fusion(Entity* this) { diff --git a/src/npc/pita.c b/src/npc/pita.c index a55c4012..8414accc 100644 --- a/src/npc/pita.c +++ b/src/npc/pita.c @@ -41,10 +41,10 @@ void RemoveAllBakedGoods(void) { bool32 sub_08062EDC(Entity* this, ScriptExecutionContext* context) { u32 tmp; - u32 tmp2; + u32 kinstoneId; static const u8 chanceForPrize[] = { 0x20, 0x40, 0x60, 0x80, 0xFF }; - static const u8 gUnk_0810C435[] = { 0x10, 0x10, 0x10, 0x20, 0x20, 0x30, 0x30, 0x30 }; - static const u8 gUnk_0810C43D[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; + static const u8 chancesPerType[] = { 0x10, 0x10, 0x10, 0x20, 0x20, 0x30, 0x30, 0x30 }; + static const u8 kinstoneTypes[] = { 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75 }; //! @bug: tmp is uninitialized, in practice player must have an item here if (GetInventoryValue(ITEM_BRIOCHE) != 0) { @@ -67,9 +67,9 @@ bool32 sub_08062EDC(Entity* this, ScriptExecutionContext* context) { context->condition = FALSE; return FALSE; } else { - tmp = GetRandomByWeight(gUnk_0810C435); - tmp2 = gUnk_0810C43D[tmp]; - InitItemGetSequence(ITEM_KINSTONE, tmp2, 1); + tmp = GetRandomByWeight(chancesPerType); + kinstoneId = kinstoneTypes[tmp]; + InitItemGetSequence(ITEM_KINSTONE, kinstoneId, 1); MessageNoOverlap(TEXT_INDEX(TEXT_BAKERY, 0x5), this); context->condition = TRUE; return TRUE; diff --git a/src/npc/postman.c b/src/npc/postman.c index ec444469..5eb99418 100644 --- a/src/npc/postman.c +++ b/src/npc/postman.c @@ -8,7 +8,7 @@ extern void sub_08060528(Entity*); extern void sub_080604DC(Entity*); extern void sub_080606D8(Entity*); -extern void sub_080606C0(Entity*); +extern void Postman_MakeInteractable(Entity*); const Coords gUnk_0810A66C[] = { { .HALF = { 0x0, 0x0 } }, { .HALF = { 0x48, 0xa8 } }, { .HALF = { 0x0, 0xf0 } }, @@ -234,7 +234,7 @@ void sub_08060528(Entity* this) { this->field_0x68.HALF.HI = 0; this->field_0x6a.HWORD = 0; this->field_0x6c.HALF.HI = 0; - this->field_0x6c.HALF.LO = sub_0801E99C(this); + this->field_0x6c.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); break; case 1: @@ -274,7 +274,7 @@ void sub_08060528(Entity* this) { this->field_0x6a.HWORD = 0; this->zVelocity = Q_16_16(2.0); this->field_0x6c.HALF.HI = 1; - sub_080788E0(this); + RemoveInteractableObject(this); EnqueueSFX(SFX_PLY_JUMP); } else { this->field_0x6a.HWORD--; @@ -283,7 +283,7 @@ void sub_08060528(Entity* this) { GravityUpdate(this, Q_8_8(24.0)); if (((this->field_0x6c.HALF.HI != 0) && (this->zVelocity == 0)) && this->z.WORD == 0) { this->field_0x6c.HALF.HI = 0; - sub_080606C0(this); + Postman_MakeInteractable(this); } if (this->z.WORD >= 0 && ((gPlayerEntity.collisionLayer == 0 || (this->collisionLayer == gPlayerEntity.collisionLayer)))) { @@ -292,9 +292,9 @@ void sub_08060528(Entity* this) { sub_0800451C(this); } -void sub_080606C0(Entity* this) { - this->field_0x6c.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x6c.HALF.LO); +void Postman_MakeInteractable(Entity* this) { + this->field_0x6c.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x6c.HALF.LO); } void sub_080606D8(Entity* this) { @@ -336,7 +336,7 @@ void sub_0806076C(Entity* this, ScriptExecutionContext* context) { } this->field_0x68.HALF.HI++; this->collisionLayer = 1; - sub_080606C0(this); + Postman_MakeInteractable(this); pbVar10 = gUnk_0810A918[(s8)this->field_0x68.HALF.LO]; pbVar10 += (s8)this->field_0x68.HALF.HI; do { diff --git a/src/npc/rem.c b/src/npc/rem.c index c8834192..01db2ab1 100644 --- a/src/npc/rem.c +++ b/src/npc/rem.c @@ -328,10 +328,10 @@ void sub_0806A914(Entity* this) { } } -void sub_0806A93C(Entity* this) { - static const u8 gUnk_0811229C[] = { 0, 6, 10, 16 }; - sub_08078778(this); - sub_08078850(this, 0, 0, &gUnk_0811229C); +void Rem_MakeInteractable(Entity* this) { + static const Rect gUnk_0811229C = { 0, 6, 10, 16 }; + AddInteractableWhenBigObject(this); + SetInteractableObjectCollision(this, 0, 0, &gUnk_0811229C); } void sub_0806A958(Entity* this) { diff --git a/src/npc/sittingPerson.c b/src/npc/sittingPerson.c index 6fc0ec00..c5f63d07 100644 --- a/src/npc/sittingPerson.c +++ b/src/npc/sittingPerson.c @@ -235,9 +235,9 @@ void SittingPerson_Head(Entity* this) { sub_0807000C(this); } -void sub_080639D0(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void SittingPerson_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void SittingPerson_Fusion(Entity* this) { diff --git a/src/npc/smallTownMinish.c b/src/npc/smallTownMinish.c index 96e4d1b4..5bbe8040 100644 --- a/src/npc/smallTownMinish.c +++ b/src/npc/smallTownMinish.c @@ -9,12 +9,12 @@ void SmallTownMinish(Entity* this) { static const Hitbox gUnk_081142FC = { -2, 1, { 0, 0, 0, 0 }, 6, 6 }; - static const u8 gUnk_08114304[] = { -2, 1, 6, 6 }; + static const Rect gUnk_08114304 = { -2, 1, 6, 6 }; if (this->action == 0) { this->action++; this->hitbox = (Hitbox*)&gUnk_081142FC; sub_0807DD50(this); - sub_08078850(this, 1, 0, gUnk_08114304); + SetInteractableObjectCollision(this, 1, 0, &gUnk_08114304); } else { sub_0807DD94(this, NULL); } diff --git a/src/npc/smith.c b/src/npc/smith.c index e6663737..bc5df016 100644 --- a/src/npc/smith.c +++ b/src/npc/smith.c @@ -73,7 +73,7 @@ void Smith_Head(Entity* this) { void sub_080660EC(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08110354)) { this->action = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); InitAnimationForceUpdate(this, 2); } } @@ -109,7 +109,7 @@ void sub_08066178(Entity* this) { if (LoadExtraSpriteData(this, gUnk_08110354)) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); } } @@ -205,18 +205,13 @@ void sub_08066258(void) { SoundReq(hammerSounds[Random() & 7]); } -void sub_08066274(Entity* this) { - static const u8 gUnk_081103E0[] = { - 0, - 6, - 8, - 12, - }; - sub_08078850(this, 1, 0, &gUnk_081103E0); +void Smith_ChangeInteractableHitbox(Entity* this) { + static const Rect gUnk_081103E0 = { 0, 6, 8, 12 }; + SetInteractableObjectCollision(this, 1, 0, &gUnk_081103E0); } -void sub_08066288(Entity* this) { - sub_08078784(this, this->field_0x68.HALF.LO); +void Smith_MakeInteractable(Entity* this) { + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Smith_Fusion(Entity* this) { diff --git a/src/npc/stamp.c b/src/npc/stamp.c index 3c932d97..0ac805ec 100644 --- a/src/npc/stamp.c +++ b/src/npc/stamp.c @@ -35,7 +35,7 @@ void sub_08062BD4(Entity* ent) { ent->action = 1; ent->spriteSettings.draw = 1; InitializeAnimation(ent, 0); - sub_08078778(ent); + AddInteractableWhenBigObject(ent); } void sub_08062BF8(Entity* ent) { diff --git a/src/npc/stockwell.c b/src/npc/stockwell.c index d7187ee3..7230bd7a 100644 --- a/src/npc/stockwell.c +++ b/src/npc/stockwell.c @@ -9,7 +9,7 @@ #include "game.h" #ifndef EU -static const u8 gUnk_0810FDA0[] = { 0, 8, 10, 16 }; +static const Rect gUnk_0810FDA0 = { 0, 8, 10, 16 }; #endif extern u16 script_StockwellBuy[]; @@ -48,9 +48,9 @@ void sub_08065080(Entity* this) { this->spriteSettings.draw = 1; SetDefaultPriority(this, PRIO_MESSAGE); InitializeAnimation(this, 4); - sub_08078778(this); + AddInteractableWhenBigObject(this); #ifndef EU - sub_08078850(this, 0, 0, &gUnk_0810FDA0); + SetInteractableObjectCollision(this, 0, 0, &gUnk_0810FDA0); #endif context = StartCutscene(this, &script_Stockwell); *(ScriptExecutionContext**)&this->cutsceneBeh = context; diff --git a/src/npc/sturgeon.c b/src/npc/sturgeon.c index 7ee3e4bc..05416de9 100644 --- a/src/npc/sturgeon.c +++ b/src/npc/sturgeon.c @@ -28,7 +28,7 @@ extern const u16 gUnk_0810FA54[]; // }; extern u32 gUnk_0810FA5A; // TODO second parameter of sub_0806EE04 -void sub_08064CC0(Entity* this); +void Sturgeon_MakeInteractable(Entity* this); void sub_08064C9C(Entity* this); void sub_08064CD8(Entity* this); @@ -68,7 +68,7 @@ void sub_08064B44(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810FA38)) { InitializeAnimation(this, 2); sub_0806EE04(this, &gUnk_0810FA5A, 0); - sub_08064CC0(this); + Sturgeon_MakeInteractable(this); this->action = 1; this->subAction = 0; this->spriteSettings.draw = 1; @@ -140,9 +140,9 @@ void sub_08064C9C(Entity* this) { } } -void sub_08064CC0(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Sturgeon_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void sub_08064CD8(Entity* this) { diff --git a/src/npc/talon.c b/src/npc/talon.c index 8de3c789..dc86ba85 100644 --- a/src/npc/talon.c +++ b/src/npc/talon.c @@ -37,7 +37,7 @@ void Talon(Entity* this) { void sub_08065570(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810FEB0)) { InitializeAnimation(this, 0); - sub_08078778(this); + AddInteractableWhenBigObject(this); this->action = 1; this->subtimer = 1; this->animationState = 2; @@ -78,8 +78,8 @@ void sub_08065608(Entity* this) { if (LoadExtraSpriteData(this, gUnk_0810FEB0)) { this->action = 1; this->spriteSettings.draw = 1; - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); sub_0807DD50(this); } } diff --git a/src/npc/teachers.c b/src/npc/teachers.c index 4ff317ad..05e0d3f6 100644 --- a/src/npc/teachers.c +++ b/src/npc/teachers.c @@ -42,9 +42,9 @@ void Teachers(Entity* this) { } } -void sub_0806C674(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); - sub_08078784(this, this->field_0x68.HALF.LO); +void Teachers_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void Teachers_Head(Entity* this) { diff --git a/src/npc/tingleSiblings.c b/src/npc/tingleSiblings.c index 7ca9c778..1d5cfabf 100644 --- a/src/npc/tingleSiblings.c +++ b/src/npc/tingleSiblings.c @@ -68,7 +68,7 @@ void sub_08064DE4(Entity* this) { case 2: if (UpdateFuseInteraction(this)) { this->action = 1; - sub_0801E99C(this); + GetFusionToOffer(this); } break; } @@ -83,8 +83,8 @@ void sub_08064DE4(Entity* this) { } } -void sub_08064EA4(Entity* this) { - this->field_0x68.HALF.LO = sub_0801E99C(this); +void TingleSiblings_MakeInteractable(Entity* this) { + this->field_0x68.HALF.LO = GetFusionToOffer(this); switch (this->type) { case 0: if ((CheckKinstoneFused(KINSTONE_59) != 0) && (GetInventoryValue(ITEM_MAGIC_BOOMERANG) == 0)) { @@ -99,7 +99,7 @@ void sub_08064EA4(Entity* this) { default: break; } - sub_08078784(this, this->field_0x68.HALF.LO); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void sub_08064EE8(Entity* this) { @@ -134,7 +134,7 @@ void sub_08064F28(Entity* this, ScriptExecutionContext* context) { context->condition = 0; roomFlag = gUnk_0810FC50[this->type]; if (CheckRoomFlag(roomFlag) == 0) { - bVar2 = gSave.unk141[sub_08002632(this)]; + bVar2 = gSave.fuserProgress[GetFuserId(this)]; if (bVar2 >= 2) { uVar5 = 3; } else { diff --git a/src/npc/townMinish.c b/src/npc/townMinish.c index 85630b7c..a8cb574b 100644 --- a/src/npc/townMinish.c +++ b/src/npc/townMinish.c @@ -129,13 +129,13 @@ static const SpriteLoadData gUnk_08112674[][4] = { { 0x0, 0x0, 0x0 }, }, }; -static const u8 gUnk_081126D4[][4] = { - { 0x0, 0x8, 0x8, 0x10 }, - { 0xf8, 0xfe, 0x10, 0x8 }, - { 0x0, 0x8, 0x8, 0x10 }, - { 0x8, 0xfe, 0x10, 0x8 }, +static const Rect gUnk_081126D4[4] = { + { 0, 8, 8, 16 }, + { -8, -2, 16, 8 }, + { 0, 8, 8, 16 }, + { 8, -2, 16, 8 }, }; -static const u8 gUnk_081126E4[4] = { 14, 13, 11, 7 }; +static const u8 gUnk_081126E4[4] = { 0x0e, 0x0d, 0x0b, 0x07 }; void TownMinish(Entity* this) { static void (*const scriptedActionFuncs[])(Entity*) = { @@ -208,7 +208,7 @@ void sub_0806ACC4(Entity* this) { this->animationState = delay * 2; this->timer = 0; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD50(this); InitializeAnimation(this, (this->animationState / 2) + 8); break; @@ -228,7 +228,7 @@ void sub_0806ACC4(Entity* this) { } if (this->type == 1) { u8 idx = gPlayerEntity.animationState >> 1; - sub_08078850(this, 1, gUnk_081126E4[idx], gUnk_081126D4[idx]); + SetInteractableObjectCollision(this, 1, gUnk_081126E4[idx], &gUnk_081126D4[idx]); } } break; @@ -250,8 +250,8 @@ void sub_0806ACC4(Entity* this) { } } -void sub_0806ADFC(Entity* this) { - sub_08078784(this, this->field_0x68.HALF.LO); +void TownMinish_MakeInteractable(Entity* this) { + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void TownMinish_Head(Entity* this) { diff --git a/src/npc/townsperson.c b/src/npc/townsperson.c index 4def0fca..adb973cb 100644 --- a/src/npc/townsperson.c +++ b/src/npc/townsperson.c @@ -15,8 +15,8 @@ extern void sub_08062048(Entity*); extern struct_0810B680 gUnk_0810B680[]; extern SpriteLoadData* gUnk_0810B6EC[]; -extern u32 gUnk_0810B740[]; // TODO fourth parameter of sub_08078850 -extern u8 gUnk_0810B748[]; // TODO third parameter of sub_08078850 +extern u32 gUnk_0810B740[]; // TODO fourth parameter of SetInteractableObjectCollision +extern u8 gUnk_0810B748[]; // TODO third parameter of SetInteractableObjectCollision extern u16 gUnk_0810B74A[]; extern void (*const gUnk_0810B774[])(Entity*); extern void (*const gUnk_0810B77C[])(Entity*); @@ -104,7 +104,7 @@ void sub_08061CEC(Entity* this) { this->field_0x6a.HWORD = (uVar2 >> 0x10); } *(u16*)&this->field_0x6c = uVar2; - this->field_0x68.HALF.LO = sub_0801E99C(this); + this->field_0x68.HALF.LO = GetFusionToOffer(this); sub_0807DD64(this); sub_08061D64(this); } @@ -150,11 +150,11 @@ void sub_08061E50(Entity* this) { } } -void sub_08061E70(Entity* this) { +void Townsperson_MakeInteractable(Entity* this) { if (this->id == 6) { - sub_08078784(this, this->field_0x68.HALF.LO); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } else { - sub_08078778(this); + AddInteractableWhenBigObject(this); } } @@ -236,7 +236,7 @@ void sub_08061FB0(Entity* this) { void sub_08061FB8(Entity* this, ScriptExecutionContext* context) { u8* temp = gUnk_0810B748; - sub_08078850(this, 1, temp[context->intVariable], &gUnk_0810B740[context->intVariable]); + SetInteractableObjectCollision(this, 1, temp[context->intVariable], &gUnk_0810B740[context->intVariable]); } void sub_08061FD8(Entity* this) { diff --git a/src/npc/windTribespeople.c b/src/npc/windTribespeople.c index 2018581f..aa4f9b31 100644 --- a/src/npc/windTribespeople.c +++ b/src/npc/windTribespeople.c @@ -78,12 +78,12 @@ void sub_0806C85C(Entity* this) { } } -void sub_0806C870(Entity* this) { +void WindTribespeople_MakeInteractable(Entity* this) { u8 bVar1; - bVar1 = sub_0801E99C(this); + bVar1 = GetFusionToOffer(this); this->field_0x68.HALF.LO = bVar1; - sub_08078784(this, this->field_0x68.HALF.LO); + AddInteractableWhenBigFuser(this, this->field_0x68.HALF.LO); } void WindTribespeople_Head(Entity* this) { diff --git a/src/npc/zeldaFollower.c b/src/npc/zeldaFollower.c index 04153f4a..2402823d 100644 --- a/src/npc/zeldaFollower.c +++ b/src/npc/zeldaFollower.c @@ -1,7 +1,36 @@ -#include "global.h" +#include "common.h" #include "entity.h" #include "functions.h" -#include "common.h" + +extern s32 sub_080041E8(s32 x1, s32 y1, s32 x2, s32 y2); + +typedef union { + struct { + u16 x; + u16 y; + u16 z; + u8 framestate; + u8 animationState : 6; + u8 collisionLayer : 2; + } FIELDS; + u64 DWORD; +} ZeldaFollowerItem; + +#define ZELDA_FOLLOWER_HEAP_LEN 20 + +#define ZELDA_FOLLOWER_HEAP ((ZeldaFollowerItem*)this->myHeap) +#define ZELDA_FOLLOWER_HEAP_END ((ZeldaFollowerItem*)this->myHeap + (ZELDA_FOLLOWER_HEAP_LEN - 1)) + +#define ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr) \ + do { \ + int i; \ + heapPtr = ((ZeldaFollowerItem*)this->myHeap); \ + heapPtr += (ZELDA_FOLLOWER_HEAP_LEN - 2); \ + for (i = 0; i < (ZELDA_FOLLOWER_HEAP_LEN - 1); i++) { \ + heapPtr[1] = heapPtr[0]; \ + heapPtr--; \ + } \ + } while (0) void sub_08068318(Entity*); void sub_0806854C(Entity*, u32*); @@ -25,19 +54,223 @@ void ZeldaFollower(Entity* this) { } } -ASM_FUNC("asm/non_matching/zeldaFollower/sub_08068318.inc", void sub_08068318(Entity* this)) +void sub_08068318(Entity* this) { + s32 dist; + s16 z; + + u32 animIndex; + u32 animIndexTmp; + + ZeldaFollowerItem* heapPtr; + ZeldaFollowerItem item; + + item.FIELDS.x = gPlayerEntity.x.HALF_U.HI; + item.FIELDS.y = gPlayerEntity.y.HALF_U.HI; + item.FIELDS.z = gPlayerEntity.z.HALF_U.HI; + item.FIELDS.framestate = gPlayerState.framestate; + item.FIELDS.animationState = gPlayerEntity.animationState; + item.FIELDS.collisionLayer = gPlayerEntity.collisionLayer; + + heapPtr = this->myHeap; + + if ((heapPtr->FIELDS.framestate == 0xa && item.FIELDS.framestate != 0xa) || + (heapPtr->FIELDS.framestate == 0x16 && item.FIELDS.framestate != 0x16)) { + this->x.HALF.HI = gPlayerEntity.x.HALF.HI; + this->y.HALF.HI = gPlayerEntity.y.HALF.HI; + this->spriteSettings.draw = 1; + sub_08068578(this); + } + + animIndex = 0; + if (item.DWORD != heapPtr->DWORD || item.FIELDS.framestate == 0x16 || item.FIELDS.framestate == 0xa) { + ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr); + heapPtr = ZELDA_FOLLOWER_HEAP; + heapPtr[0] = item; + animIndex = 0x4; + + if ((s8)this->field_0x68.HALF.HI > 0) { + this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1; + } + } else { + heapPtr += ZELDA_FOLLOWER_HEAP_LEN - 1; + z = heapPtr->FIELDS.z; + + if (z < 0) { + ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr); + animIndex = 0x4; + } else { + dist = sub_080041E8(gPlayerEntity.x.HALF.HI, gPlayerEntity.y.HALF.HI, (u16)heapPtr->FIELDS.x, + (u16)heapPtr->FIELDS.y); + dist = ((u32)dist) >> 0x4; + if (dist > 0x18) { + ZELDA_FOLLOWER_HEAP_SHIFT_RIGHT(this, heapPtr); + animIndex = 0x4; + } + } + } + + heapPtr = ZELDA_FOLLOWER_HEAP; + heapPtr += ZELDA_FOLLOWER_HEAP_LEN - 1; + this->x.HALF.HI = heapPtr->FIELDS.x; + this->y.HALF.HI = heapPtr->FIELDS.y; + this->z.HALF.HI = heapPtr->FIELDS.z; + this->animationState = heapPtr->FIELDS.animationState; + this->collisionLayer = heapPtr->FIELDS.collisionLayer; + + if (heapPtr->FIELDS.framestate == 0x16 || heapPtr->FIELDS.framestate == 0xa) { + this->spriteSettings.draw = 0; + } + + if (((s8)this->field_0x68.HALF.HI) > 0) { + this->field_0x68.HALF.HI = this->field_0x68.HALF.HI - 1; + } + + animIndexTmp = animIndex; + animIndex += this->animationState >> 1; + + if (!(animIndex == this->animIndex || (animIndexTmp == 0 && ((s8)this->field_0x68.HALF.HI) > 0))) { + InitAnimationForceUpdate(this, animIndex); + this->field_0x68.HALF.HI = 0x1e; + } else { + UpdateAnimationSingleFrame(this); + } + + sub_0800451C(this); + if (this->z.HALF.HI < 0) { + sub_0806F854(this, 0x0, -0xc); + } +} void sub_0806854C(Entity* this, u32* none) { - this->myHeap = zMalloc(0xa0); + this->myHeap = zMalloc(sizeof(ZeldaFollowerItem[ZELDA_FOLLOWER_HEAP_LEN])); if (this->myHeap != NULL) { this->field_0x68.HALF.LO = 1; - sub_080788E0(this); + RemoveInteractableObject(this); this->hitbox = NULL; sub_08068578(this); } } -ASM_FUNC("asm/non_matching/zeldaFollower/sub_08068578.inc", void sub_08068578(Entity* this)) +void sub_08068578(Entity* this) { + ZeldaFollowerItem* item; + s32 index; +#ifdef REWRITE_CODE + u32 r0; + u32 r1; + u32 r2; + u32 r3; + u32 r5; + u32 r6; + u32 r8; + s32 y; + u32 r10; + s32 x; +#else + register u32 r5 asm("r5"); + register u32 r6 asm("r6"); + register u32 r0 asm("r0"); + register u32 r1 asm("r1"); + register u32 r2 asm("r2"); + register u32 r3 asm("r3"); + register s32 r8 asm("r8"); + register s32 y asm("r9"); + register s32 r10 asm("r10"); + register s32 x asm("r12"); +#endif + + // first u32 (r5) +#ifdef REWRITE_CODE + r0 = gPlayerEntity.x.HALF_U.HI | (r5 & 0xffff0000); + r5 = (gPlayerEntity.y.HALF_U.HI << 0x10) | (r0 & 0x0000ffff); +#else + r1 = gPlayerEntity.x.HALF_U.HI; + + r3 = 0xffff0000; + r0 = r3; + r0 &= r5; + r0 |= r1; + + r1 = gPlayerEntity.y.HALF_U.HI; + r1 <<= 0x10; + r2 = 0xffff; + r0 &= r2; + r0 |= r1; + r5 = r0; +#endif + + // second u32 (r6) +#ifdef REWRITE_CODE + r3 = gPlayerEntity.z.HALF_U.HI | (r6 & 0xffff0000); + r2 = (gPlayerState.framestate << 0x10) | (r3 & 0xff00ffff); + r0 = ((gPlayerEntity.animationState & 0x3f) << 0x18) | (r2 & 0xc0ffffff); + r6 = (gPlayerEntity.collisionLayer << 0x1e) | (r0 & 0x3fffffff); +#else + r0 = gPlayerEntity.z.HALF_U.HI; + r3 &= r6; + r3 |= r0; + + r0 = gPlayerState.framestate; + r0 <<= 0x10; + r2 = 0xff00ffff; + r2 &= r3; + r2 |= r0; + + r1 = gPlayerEntity.animationState; + r0 = 0x3f; + r1 &= r0; + r1 <<= 0x18; + r0 = 0xc0ffffff; + r0 &= r2; + r0 |= r1; + + // gPlayerEntity is now at r1 + r1 = gPlayerEntity.collisionLayer; + r1 <<= 0x1e; + r2 = 0x3fffffff; + r0 &= r2; + r0 |= r1; + r6 = r0; +#endif + +#ifdef REWRITE_CODE + r10 = gPlayerEntity.x.HALF.HI - this->x.HALF.HI; +#else + r1 = gPlayerEntity.x.HALF.HI; + r0 = this->x.HALF.HI; + r0 = r1 - r0; + r10 = r0; +#endif + +#ifdef REWRITE_CODE + r8 = gPlayerEntity.y.HALF.HI - this->y.HALF.HI; +#else + r1 = gPlayerEntity.y.HALF.HI; + r0 = this->y.HALF.HI; + r0 = r1 - r0; + r8 = r0; +#endif + + r10 = FixedDiv(r10, 0x14); + r8 = FixedDiv(r8, 0x14); + + item = this->myHeap; + y = 0; + x = 0; + + // Down here the u32 are suddendly accessed correctly as u16 and bitfields? + // How are the results of above u32 calculations used? + for (index = 0x13; index >= 0; index--) { + item->FIELDS.x = r5 - (x >> 8); + item->FIELDS.y = (r5 >> 0x10) - (y >> 8); + item->FIELDS.z = r6; + item->FIELDS.framestate = r6 >> 0x10; + item->FIELDS.animationState = this->animationState & 0x3f; + item->FIELDS.collisionLayer = this->collisionLayer; + item++; + y = y + r8; + x = x + r10; + } +} void ZeldaFollower_Hide(Entity* zelda, Entity* follower) { follower->field_0x68.HALF.LO = 0; diff --git a/src/npcUtils.c b/src/npcUtils.c index 190c9338..8702f3eb 100644 --- a/src/npcUtils.c +++ b/src/npcUtils.c @@ -327,7 +327,7 @@ void CollideFollowers(void) { } void sub_0806F118(Entity* ent) { - u32 idx = sub_08002632(ent); + u32 idx = GetFuserId(ent); NPCData* data = gUnk_08001A7C[idx]; sub_0801DFB4(ent, data->textIndex, data->_2, data->_4); gPlayerState.controlMode = CONTROL_DISABLED; @@ -352,10 +352,10 @@ u32 UpdateFuseInteraction(Entity* ent) { return ret; } -void sub_0806F188(Entity* ent) { - u32 idx = sub_08002632(ent); +void MarkFuserDone(Entity* ent) { + u32 idx = GetFuserId(ent); if (idx != 0) - gSave.unk1C1[idx] = 0xF3; + gSave.fuserOffers[idx] = KINSTONE_FUSER_DONE; } void ShowNPCDialogue(Entity* ent, const Dialog* dia) { diff --git a/src/object/bossDoor.c b/src/object/bossDoor.c index 4f9a5220..c1b3bcff 100644 --- a/src/object/bossDoor.c +++ b/src/object/bossDoor.c @@ -27,7 +27,7 @@ typedef struct { } BossDoorEntity; extern bool32 gUnk_02036BB8; -extern const u8 gUnk_0811F740[]; +extern const u8 gLockedDoorInteractDirections[]; void sub_0808C500(BossDoorEntity*); void sub_0808C4BC(BossDoorEntity*); @@ -69,8 +69,8 @@ void BossDoor_Init(BossDoorEntity* this) { super->action = 1; super->spriteSettings.draw = 1; sub_0808C500(this); - sub_08078800(super); - sub_08078850(super, 0, gUnk_0811F740[this->unk_76], 0); + AddInteractableBossDoor(super); + SetInteractableObjectCollision(super, 0, gLockedDoorInteractDirections[this->unk_76], NULL); break; case 1: super->action = 4; @@ -87,7 +87,7 @@ void BossDoor_Init(BossDoorEntity* this) { void BossDoor_Action1(BossDoorEntity* this) { if (super->interactType != 0) { super->action = 2; - sub_080788E0(super); + RemoveInteractableObject(super); SetFlag(this->unk_86); } } diff --git a/src/object/cameraTarget.c b/src/object/cameraTarget.c index 79b56190..57a5623a 100644 --- a/src/object/cameraTarget.c +++ b/src/object/cameraTarget.c @@ -53,16 +53,17 @@ void CameraTarget(Entity* this) { case 0: case 1: case 2: - if ((gMessage.doTextBox & 0x7f) != 0) { - default: - if (gUnk_03003DF0.unk_4[3] == 50) { - if (CheckKinstoneFused(KINSTONE_32) == 0) { - uVar2 = 0; - break; - } - } - uVar2 = 1; + if ((gMessage.doTextBox & 0x7f) == 0) { + break; } + default: + if (gPossibleInteraction.currentObject->kinstoneId == KINSTONE_32) { + if (CheckKinstoneFused(KINSTONE_32) == 0) { + uVar2 = 0; + break; + } + } + uVar2 = 1; break; } @@ -102,9 +103,10 @@ void CameraTarget_Action1(Entity* this) { if (this->timer) { this->timer--; } else { - if ((*(Entity**)(gUnk_03003DF0.unk_4 + 8) != NULL) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { - this->child = *(Entity**)(gUnk_03003DF0.unk_4 + 8); - this->interactType = gUnk_03003DF0.unk_3; + if ((gPossibleInteraction.currentObject->entity != NULL) && + ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) { + this->child = gPossibleInteraction.currentObject->entity; + this->interactType = gPossibleInteraction.currentIndex; sub_08083A40(this); } } @@ -118,8 +120,8 @@ void CameraTarget_Action2(Entity* this) { u32 temp2; const KinstoneWorldEvent* ptr; - if ((this->type != 1) && - (((u8)(gUnk_03003DF0.unk_4[3] - 1) >= 100 || (this->child != *(Entity**)(gUnk_03003DF0.unk_4 + 8))))) { + if ((this->type != 1) && (((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) >= 100 || + (this->child != gPossibleInteraction.currentObject->entity)))) { sub_080838DC(this); } else { this->x = this->child->x; @@ -128,12 +130,12 @@ void CameraTarget_Action2(Entity* this) { if (this->frame == 1) { this->frame = 0; if (this->type == 0) { - bVar2 = gUnk_03003DF0.unk_4[3]; + bVar2 = gPossibleInteraction.currentObject->kinstoneId; } else { bVar2 = this->type2; } ptr = gKinstoneWorldEvents + bVar2; - bVar1 = ptr->unk6; + bVar1 = ptr->bubbleIcon; bVar3 = bVar1 & 1; this->palette.b.b0 = bVar3; temp = gUnk_0811F744[bVar1] < 0; diff --git a/src/object/chestSpawner.c b/src/object/chestSpawner.c index dfe03a92..8a721a58 100644 --- a/src/object/chestSpawner.c +++ b/src/object/chestSpawner.c @@ -26,7 +26,7 @@ extern const Hitbox gUnk_0811F8A8; extern const Hitbox gUnk_0811F8B0; void sub_080842D8(ChestSpawnerEntity*); -void sub_08078828(ChestSpawnerEntity*); +void AddInteractableChest(ChestSpawnerEntity*); void sub_08083E20(ChestSpawnerEntity*); void sub_08084074(u32); void sub_080840A8(s32, s32); @@ -76,7 +76,7 @@ void sub_08083E20(ChestSpawnerEntity* this) { super->spriteSettings.draw = 1; super->spriteRendering.alphaBlend = 0; sub_080842D8(this); - sub_08078828(this); + AddInteractableChest(this); } void ChestSpawner_Type2Init(ChestSpawnerEntity* this) { super->hitbox = (Hitbox*)&gUnk_0811F8B0; @@ -153,7 +153,7 @@ void ChestSpawner_Type2Action3(ChestSpawnerEntity* this) { if (super->interactType != 0) { super->action = 4; super->subtimer = 30; - sub_080788E0(super); + RemoveInteractableObject(super); RequestPriorityDuration(super, 60); SoundReq(SFX_CHEST_OPEN); } diff --git a/src/object/crenelBeanSprout.c b/src/object/crenelBeanSprout.c index 70279d9a..8bee94eb 100644 --- a/src/object/crenelBeanSprout.c +++ b/src/object/crenelBeanSprout.c @@ -172,9 +172,9 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { this->unk_70 = ((super->x.HALF.HI + (s8)gUnk_08123184[tmp]) & -0x10) | 8; this->unk_72 = ((super->y.HALF.HI + (s8)gUnk_08123184[(tmp) + 1]) & -0x10) | 8; if (sub_080B1AB4(this->unk_70, this->unk_72, super->collisionLayer) == 0x19) { - gHUD.unk_2f = 3; + gHUD.rActionPlayerState = R_ACTION_THROW; } else { - gHUD.unk_2f = 0; + gHUD.rActionPlayerState = R_ACTION_NONE; } PositionRelative(&gPlayerEntity, super, 0, 0x10000); if (GetTileUnderEntity(super) == 0x19) { @@ -184,7 +184,7 @@ void CrenelBeanSprout_Action1(CrenelBeanSproutEntity* this) { if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_40)) == 0) { return; } - if (gHUD.unk_2f != 3) { + if (gHUD.rActionPlayerState != R_ACTION_THROW) { return; } gPlayerState.heldObject = 0; diff --git a/src/object/cuccoMinigame.c b/src/object/cuccoMinigame.c index 1d87a6d0..f6b02dd1 100644 --- a/src/object/cuccoMinigame.c +++ b/src/object/cuccoMinigame.c @@ -13,23 +13,28 @@ #include "npc.h" #include "object.h" #include "script.h" +#include "item.h" typedef struct { Entity base; - s16 unk68; - s16 unk6a; - s16 unk6c; + s16 timer; + s16 currentCuccos; + s16 targetCuccos; u16 unk6e; - u8 unk70[0x18]; + u8 returnedCuccoTypes[0x18]; } CuccoMinigameEntity; typedef Entity* CuccoMinigameHeap[10]; -u32 sub_080A1514(); +u32 CuccoMinigame_GetLevel(); -const u16 gUnk_08124C20[] = { - 25, 0x2, 25, 0x3, 30, 0x4, 45, 0x5, 50, 0x5, 45, 0x5, 50, 0x6, 60, 0x7, 55, 0x2, 55, 0x3, -}; +typedef struct { + u16 time; + u16 numCuccos; +} CuccoMinigameGoal; + +const CuccoMinigameGoal goalData[10] = { { 25, 2 }, { 25, 3 }, { 30, 4 }, { 45, 5 }, { 50, 5 }, + { 45, 5 }, { 50, 6 }, { 60, 7 }, { 55, 2 }, { 55, 3 } }; static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = { { 0x0001, 0x02E9, 0x0318, 0x0001, 0x0280, 0x0380, 0x0002, 0x0277, 0x0314, 0x0001, @@ -66,9 +71,18 @@ static const u16 pCuccoMinigame_MinigameCuccoDefs[][30] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000 } }; -static const u8 gUnk_08124EA0[] = { 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x0A, 0x01, 0x00, 0x3F, 0x14, 0x01, 0x00, 0x3F, 0x14, - 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x3F, 0x1E, 0x01, 0x00, 0x5C, 0x6E, 0x01, 0x00, - 0x5C, 0x6F, 0x01, 0x00, 0x5C, 0x70, 0x01, 0x00, 0x63, 0x00, 0x01, 0x00 }; +typedef struct { + u8 item; + u8 subtype; + u8 unk2; + u8 unk3; +} CuccoMinigamePrizeData; + +static const CuccoMinigamePrizeData prizeData[10] = { { ITEM_SHELLS, 10, 1, 0 }, { ITEM_SHELLS, 10, 1, 0 }, + { ITEM_SHELLS, 20, 1, 0 }, { ITEM_SHELLS, 20, 1, 0 }, + { ITEM_SHELLS, 30, 1, 0 }, { ITEM_SHELLS, 30, 1, 0 }, + { ITEM_KINSTONE, 0x6E, 1, 0 }, { ITEM_KINSTONE, 0x6F, 1, 0 }, + { ITEM_KINSTONE, 0x70, 1, 0 }, { ITEM_HEART_PIECE, 0, 1, 0 } }; static const u16 CuccoMinigame_Sounds[] = { SFX_VO_CUCCO5, SFX_VO_CUCCO_CALL }; @@ -78,17 +92,17 @@ void CuccoMinigame(CuccoMinigameEntity* this) { int index; u32 val; u8* puVar2; - const u16* ptr; + const CuccoMinigameGoal* ptr; if (super->action == 0) { super->action++; - ptr = gUnk_08124C20 + sub_080A1514() * 2; - this->unk68 = ptr[0] * 0x3c; - this->unk6a = 0; - this->unk6c = ptr[1]; + ptr = &goalData[CuccoMinigame_GetLevel()]; + this->timer = ptr->time * 60; + this->currentCuccos = 0; + this->targetCuccos = ptr->numCuccos; this->unk6e = 1; - for (puVar2 = this->unk70, val = 0, index = 9; index >= 0; index--) { + for (puVar2 = this->returnedCuccoTypes, val = 0, index = 9; index >= 0; index--) { *puVar2++ = val; } sub_0807DD64(super); @@ -110,7 +124,7 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi sVar6 = 0; entArray = ((Entity**)super->myHeap); - ptr = this->unk70; + ptr = this->returnedCuccoTypes; iVar1 = (gRoomControls.origin_x + 0x360); iVar4 = (gRoomControls.origin_y + 0x350); iVar1 = (iVar1 << 16) >> 16; @@ -147,9 +161,9 @@ NONMATCH("asm/non_matching/objectB9/sub_080A1270.inc", void sub_080A1270(CuccoMi } } - this->unk6a = sVar6; + this->currentCuccos = sVar6; gPlayerState.field_0x27[0] = 0xff; - if (--this->unk68 < 1) { + if (--this->timer < 1) { SoundReq(SFX_CUCCO_MINIGAME_BELL); sub_08050384(); } else { @@ -163,7 +177,7 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) { s8* pcVar2; int index; - pcVar2 = this->unk70; + pcVar2 = this->returnedCuccoTypes; puVar1 = super->myHeap; for (index = 9; index >= 0; index--, pcVar2++, puVar1++) { @@ -174,8 +188,8 @@ void CuccoMinigame_Cleanup(CuccoMinigameEntity* this) { } } -void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) { - if (this->unk6a >= this->unk6c) { +void CuccoMinigame_Results(CuccoMinigameEntity* this, ScriptExecutionContext* context) { + if (this->currentCuccos >= this->targetCuccos) { MessageFromTarget(TEXT_INDEX(TEXT_ANJU, 0xc)); context->condition = 1; } else { @@ -184,115 +198,115 @@ void sub_080A13B4(CuccoMinigameEntity* this, ScriptExecutionContext* context) { } } -void sub_080A13E8(CuccoMinigameEntity* this) { - bool32 bVar2; - const u8* ptr = &gUnk_08124EA0[sub_080A1514() * 4]; +void CuccoMinigame_WinItem(CuccoMinigameEntity* this) { + bool32 skipItem; + const CuccoMinigamePrizeData* prize = &prizeData[CuccoMinigame_GetLevel()]; - bVar2 = 0; - switch (ptr[0]) { - case 0x3f: + skipItem = 0; + switch (prize->item) { + case ITEM_SHELLS: if (gSave.stats.hasAllFigurines) { - bVar2 = 1; + skipItem = 1; } break; - case 0x5c: + case ITEM_KINSTONE: if (gSave.didAllFusions) { - bVar2 = 1; + skipItem = 1; } break; - case 0x63: + case ITEM_HEART_PIECE: if (!CheckGlobalFlag(ANJU_HEART)) { SetGlobalFlag(ANJU_HEART); break; } - bVar2 = 1; + skipItem = 1; break; } - if (!bVar2) { - InitItemGetSequence(ptr[0], ptr[1], 0); + if (!skipItem) { + InitItemGetSequence(prize->item, prize->subtype, 0); } else { this->unk6e = 2; } } -void sub_080A1460(CuccoMinigameEntity* this) { - s8* pcVar1; - int iVar2; +void CuccoMinigame_WinRupees(CuccoMinigameEntity* this) { + s8* cuccoTypes; + int index; s32 rupees; - const u8* ptr; + const u8* rupeeValues; - sub_080A1514(); - pcVar1 = this->unk70; + CuccoMinigame_GetLevel(); // Rupees previously dependent on level? + cuccoTypes = this->returnedCuccoTypes; rupees = 0; - ptr = CuccoMinigameRupees; + rupeeValues = CuccoMinigameRupees; - for (iVar2 = 9; iVar2 >= 0; iVar2--) { + for (index = 9; index >= 0; index--) { // Only first 10 count? // Weird register addition - // ptr[*pcVar1] translates to add r0,r3,r0 but should be add r0,r3 - u32 temp = *pcVar1; - temp += (int)ptr; + // rupeeValues[*cuccoTypes] translates to add r0,r3,r0 but should be add r0,r3 + u32 temp = *cuccoTypes; + temp += (int)rupeeValues; rupees += *(u8*)temp; - pcVar1++; + cuccoTypes++; } ModRupees(rupees); MessageNoOverlap(TEXT_INDEX(TEXT_ANJU, 0x7), super); gMessage.rupees = (u16)rupees; } -void sub_080A14A8(void) { - int iVar1; +void CuccoMinigame_AdvanceLevel(void) { + int level; - iVar1 = sub_080A1514(); - iVar1++; - if (iVar1 > 9) { - iVar1 = 9; + level = CuccoMinigame_GetLevel(); + level++; + if (level > 9) { + level = 9; } - if (iVar1 & 1) { + if (level & 1) { SetGlobalFlag(ANJU_LV_BIT0); } else { ClearGlobalFlag(ANJU_LV_BIT0); } - if (iVar1 & 2) { + if (level & 2) { SetGlobalFlag(ANJU_LV_BIT1); } else { ClearGlobalFlag(ANJU_LV_BIT1); } - if (iVar1 & 4) { + if (level & 4) { SetGlobalFlag(ANJU_LV_BIT2); } else { ClearGlobalFlag(ANJU_LV_BIT2); } - if (iVar1 & 8) { + if (level & 8) { SetGlobalFlag(ANJU_LV_BIT3); } else { ClearGlobalFlag(ANJU_LV_BIT3); } } -u32 sub_080A1514(void) { - u32 rv = 0; +u32 CuccoMinigame_GetLevel(void) { + u32 level = 0; if (CheckGlobalFlag(ANJU_LV_BIT0)) { - rv = 1; + level = 1; } if (CheckGlobalFlag(ANJU_LV_BIT1)) { - rv |= 2; + level |= 2; } if (CheckGlobalFlag(ANJU_LV_BIT2)) { - rv |= 4; + level |= 4; } if (CheckGlobalFlag(ANJU_LV_BIT3)) { - rv |= 8; + level |= 8; } - return rv; + return level; } void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { @@ -311,7 +325,7 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { } else { *(ScriptExecutionContext**)&((GenericEntity*)pEnt)->cutsceneBeh = (ScriptExecutionContext*)StartCutscene(pEnt, (u16*)context->intVariable); - pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[sub_080A1514()]; + pCuccoMinigameDef = pCuccoMinigame_MinigameCuccoDefs[CuccoMinigame_GetLevel()]; ppEVar5 = (Entity**)pEnt->myHeap; room = &gRoomControls; for (index = 9; index >= 0; index--, pCuccoMinigameDef += 3) { @@ -332,9 +346,9 @@ void CuccoMinigame_Init(Entity* this, ScriptExecutionContext* context) { } } -void sub_080A1608(void) { +void CuccoMinigame_TellObjective(void) { u16 messageIndex; - const u16* ptr; + const CuccoMinigameGoal* ptr; messageIndex = TEXT_INDEX(TEXT_ANJU, 0x2); if (CheckRoomFlag(1)) { @@ -343,9 +357,9 @@ void sub_080A1608(void) { MessageFromTarget(messageIndex); gMessage.textWindowPosX = 1; gMessage.textWindowPosY = 0; - ptr = &gUnk_08124C20[sub_080A1514() * 2]; - gMessage.rupees = ptr[0]; - gMessage.field_0x14 = ptr[1]; + ptr = &goalData[CuccoMinigame_GetLevel()]; + gMessage.rupees = ptr->time; + gMessage.field_0x14 = ptr->numCuccos; } void sub_080A1648(void) { diff --git a/src/object/cutsceneMiscObject.c b/src/object/cutsceneMiscObject.c index e5643dab..08b3e868 100644 --- a/src/object/cutsceneMiscObject.c +++ b/src/object/cutsceneMiscObject.c @@ -22,7 +22,7 @@ extern u16 gUnk_08122B1E[]; extern Coords8 gUnk_08122B2E[]; // TODO struct xy typedef struct { Hitbox hit; - u8 _8[4]; // TODO fourth param of sub_08078850 + u8 _8[4]; // TODO fourth param of SetInteractableObjectCollision u8 _c; } HitboxCfg; extern HitboxCfg gUnk_08122B3C[]; @@ -395,13 +395,13 @@ void sub_08094FA8(CutsceneMiscObjectEntity* this) { super->action = 1; super->frameIndex = 0; super->spritePriority.b0 = 7; - sub_080787B4(super); + AddInteractableCheckableObject(super); break; case 1: if (super->interactType != 0) { super->interactType = 0; super->action = 2; - sub_080788E0(super); + RemoveInteractableObject(super); gPlayerState.queued_action = PLAYER_EMPTYBOTTLE; gPlayerState.field_0x38 = 54; #ifndef EU @@ -449,13 +449,13 @@ void sub_08095088(CutsceneMiscObjectEntity* this) { DeleteThisEntity(); super->action = 1; super->spritePriority.b0 = 7; - sub_080787B4(super); + AddInteractableCheckableObject(super); break; case 1: if (super->interactType != 0) { super->interactType = 0; super->action = 2; - sub_080788E0(super); + RemoveInteractableObject(super); CreateEzloHint(TEXT_INDEX(TEXT_BELARI, 0x1F), 0); } break; @@ -1322,6 +1322,6 @@ void sub_080962E8(CutsceneMiscObjectEntity* this) { void sub_080962F8(CutsceneMiscObjectEntity* this, ScriptExecutionContext* ctx) { HitboxCfg* cfg = &gUnk_08122B3C[ctx->intVariable]; - sub_08078850(super, 1, cfg->_c, cfg->_8); + SetInteractableObjectCollision(super, 1, cfg->_c, cfg->_8); super->hitbox = &cfg->hit; } diff --git a/src/object/figurineDevice.c b/src/object/figurineDevice.c index d52ac049..bf406be3 100644 --- a/src/object/figurineDevice.c +++ b/src/object/figurineDevice.c @@ -79,7 +79,7 @@ void FigurineDevice_Init(FigurineDeviceEntity* this) { case 0: if (CheckLocalFlag(SHOP07_TANA)) { this->unk_7a = 1; - sub_080787B4(super); + AddInteractableCheckableObject(super); } else { this->unk_7a = 0; } @@ -123,7 +123,7 @@ void FigurineDevice_Action1(FigurineDeviceEntity* this) { switch (this->unk_7a) { case 0: this->unk_7a = 1; - sub_080787B4(super); + AddInteractableCheckableObject(super); break; case 1: if (super->interactType != 0) { @@ -142,7 +142,7 @@ void FigurineDevice_Action1(FigurineDeviceEntity* this) { default: if (CheckRoomFlag(2) == 0) { this->unk_7a = 1; - sub_080787B4(super); + AddInteractableCheckableObject(super); } break; } diff --git a/src/object/frozenOctorok.c b/src/object/frozenOctorok.c index 682e0ae0..9bde8f4a 100644 --- a/src/object/frozenOctorok.c +++ b/src/object/frozenOctorok.c @@ -421,10 +421,17 @@ void sub_0809CB70(FrozenOctorokEntity* this, s32 angle, s32 radius) { super->z.WORD = super->parent->z.WORD; } -NONMATCH("asm/non_matching/frozenOctorok/sub_0809CBE4.inc", void sub_0809CBE4(FrozenOctorokEntity* this)) { - this->unk_79 += super->subtimer; +void sub_0809CBE4(FrozenOctorokEntity* this) { + u16 tmp1; + FORCE_REGISTER(u8 tmp4, r4); + u8* tmp3 = &this->unk_79; + tmp1 = super->subtimer; + tmp4 = *tmp3; + tmp1 += tmp4; + this->unk_79 = tmp1; if ((s8)super->subtimer < 0) { - if (super->timer < -this->unk_79) { + u8 tmp_r0 = super->timer; + if (tmp1 << 0x18 < -tmp_r0 << 0x18) { super->subtimer = -super->subtimer; SoundReq(SFX_19E); } @@ -433,7 +440,6 @@ NONMATCH("asm/non_matching/frozenOctorok/sub_0809CBE4.inc", void sub_0809CBE4(Fr SoundReq(SFX_19E); } } -END_NONMATCH void FrozenOctorok_ChangeObjPaletteOfChildren(FrozenOctorokEntity* this, u32 palette) { u32 index; diff --git a/src/object/itemForSale.c b/src/object/itemForSale.c index dfef44de..d9615ea4 100644 --- a/src/object/itemForSale.c +++ b/src/object/itemForSale.c @@ -27,14 +27,14 @@ typedef struct { // not match. } ModifiedParentEntity; -extern u32 sub_080787D8(Entity*); +extern u32 AddInteractableShopItem(Entity*); extern void* sub_080784E4(void); void ItemForSale_Init(ItemForSaleEntity*); void ItemForSale_Action1(ItemForSaleEntity*); void ItemForSale_Action2(ItemForSaleEntity*); void ItemForSale_Action3(ItemForSaleEntity*); -void sub_08081A5C(ItemForSaleEntity*); +void ItemForSale_MakeInteractable(ItemForSaleEntity*); void sub_080819B4(ItemForSaleEntity*); void sub_08081AB0(void); @@ -71,7 +71,7 @@ void ItemForSale_Init(ItemForSaleEntity* this) { SetDefaultPriority(super, 6); #endif super->child = super; - sub_08081A5C(this); + ItemForSale_MakeInteractable(this); switch (super->timer) { case 0: super->hitbox = (Hitbox*)&gUnk_080FD328; @@ -85,7 +85,7 @@ void ItemForSale_Init(ItemForSaleEntity* this) { void ItemForSale_Action1(ItemForSaleEntity* this) { if (super->subAction != 0) { super->action = 2; - gHUD.unk_2f = 2; + gHUD.rActionPlayerState = 2; } else { if (super->type == 0x36) { if (super->interactType != 0) { @@ -102,7 +102,7 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { ResetActiveItems(); gPlayerState.heldObject = 4; gNewPlayerEntity.unk_74 = super; - gHUD.unk_2f = 2; + gHUD.rActionPlayerState = R_ACTION_DROP; MessageClose(); } } @@ -112,15 +112,15 @@ void ItemForSale_Action1(ItemForSaleEntity* this) { void ItemForSale_Action2(ItemForSaleEntity* this) { void* ptr; - gHUD.unk_2f = 2; + gHUD.rActionPlayerState = R_ACTION_DROP; super->spriteSettings.draw = gPlayerEntity.spriteSettings.draw; if ((gPlayerState.heldObject == 0) || (super != gNewPlayerEntity.unk_74)) { sub_080819B4(this); } else { ptr = sub_080784E4(); - if (((*(int*)(ptr + 8) == 0) || - ((*(u8*)(ptr + 1) != 1 || (gHUD.unk_2f = 7, (gPlayerState.playerInput.newInput & - (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) && + if (((*(int*)(ptr + 8) == 0) || ((*(u8*)(ptr + 1) != 1 || (gHUD.rActionPlayerState = R_ACTION_SPEAK, + (gPlayerState.playerInput.newInput & + (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0)))) && ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_10 | PLAYER_INPUT_8)) != 0)) { sub_080819B4(this); } @@ -142,8 +142,8 @@ void sub_080819B4(ItemForSaleEntity* this) { gNewPlayerEntity.unk_74 = 0; ptr = &gHUD; gRoomVars.shopItemType = 0; - ptr->unk_2c = 0; - ptr->unk_2f = 0; + ptr->rActionInteractObject = R_ACTION_NONE; + ptr->rActionPlayerState = R_ACTION_NONE; gRoomVars.shopItemType2 = 0; super->x.HALF.HI = this->unk_80 + gRoomControls.origin_x; super->y.HALF.HI = this->unk_82 + gRoomControls.origin_y; @@ -154,13 +154,13 @@ void sub_080819B4(ItemForSaleEntity* this) { super->collisionLayer = 1; super->spritePriority.b0 = 4; UpdateSpriteForCollisionLayer(super); - sub_08081A5C(this); + ItemForSale_MakeInteractable(this); } -void sub_08081A5C(ItemForSaleEntity* this) { - u32 tmp = sub_080787D8(super); +void ItemForSale_MakeInteractable(ItemForSaleEntity* this) { + u32 tmp = AddInteractableShopItem(super); if (super->timer == 1) { - gUnk_03003DF0.array[tmp].unk_2 = 0; + gPossibleInteraction.candidates[tmp].interactDirections = 0; } } diff --git a/src/object/lilypadLarge.c b/src/object/lilypadLarge.c index 88cf601a..84b11274 100644 --- a/src/object/lilypadLarge.c +++ b/src/object/lilypadLarge.c @@ -117,7 +117,7 @@ void sub_080855E8(LilypadLargeEntity* this) { super->flags |= 0x20; if (sub_0806FC80(super, &gPlayerEntity, 0x18) != 0) { - gPlayerState.flags |= 2; + gPlayerState.flags |= PL_FLAGS2; if (gPlayerEntity.z.WORD == 0) { if (gPlayerState.swim_state != 0) { gPlayerEntity.collisionFlags &= 0xfb; @@ -258,7 +258,7 @@ void sub_080855E8(LilypadLargeEntity* this) { this->unk_85 = 0; } - if ((gPlayerState.flags & 2) != 0) { + if ((gPlayerState.flags & PL_FLAGS2) != 0) { sub_08085F1C(this); } diff --git a/src/object/lockedDoor.c b/src/object/lockedDoor.c index 1b704f50..6cc6c1a6 100644 --- a/src/object/lockedDoor.c +++ b/src/object/lockedDoor.c @@ -81,7 +81,7 @@ const struct_0811F730 gUnk_0811F730[] = { { { 8, 8 }, { 8, -8 } }, }; -const u8 gUnk_0811F740[] = { +const u8 gLockedDoorInteractDirections[] = { 0xBE, 0x7D, 0xEB, @@ -133,8 +133,9 @@ void LockedDoor_Init(Entity* this) { this->action = 5; } else { this->action = 8; - sub_080787CC(this); - sub_08078850(this, 0, gUnk_0811F740[this->field_0x7c.BYTES.byte2], 0); + AddInteractableSmallKeyLock(this); + SetInteractableObjectCollision(this, 0, gLockedDoorInteractDirections[this->field_0x7c.BYTES.byte2], + NULL); } } else { DeleteThisEntity(); diff --git a/src/object/object37.c b/src/object/object37.c index 11f54176..800f0fa0 100644 --- a/src/object/object37.c +++ b/src/object/object37.c @@ -44,14 +44,14 @@ void Object37_Init(Object37Entity* this) { void Object37_Action1(Object37Entity* this) { Entity* item; - if ((gSave.unk24E[0] != 0) && (this->unk70 != *this->unk78)) { + if ((gSave.fusionUnmarked[0] != 0) && (this->unk70 != *this->unk78)) { item = CreateGroundItem(super, ITEM_RUPEE100, 0); if (item != 0) { item->direction = gPlayerEntity.animationState << 2; item->speed = 0x80; item->zVelocity = Q_16_16(2.0); } - gSave.unk24E[0] = 1; + gSave.fusionUnmarked[0] = 1; DeleteThisEntity(); } } diff --git a/src/object/objectA.c b/src/object/objectA.c index f9db55e0..77622f1f 100644 --- a/src/object/objectA.c +++ b/src/object/objectA.c @@ -34,7 +34,7 @@ void ObjectA(Entity* this) { } DeleteThisEntity(); } else { - sub_080787CC(this); + AddInteractableSmallKeyLock(this); } } else if (this->interactType != 0) { SetTileType(*(u16*)&this->field_0x70.HALF.LO, COORD_TO_TILE(this), this->collisionLayer); diff --git a/src/object/pushableStatue.c b/src/object/pushableStatue.c index efca1ea6..b29ca269 100644 --- a/src/object/pushableStatue.c +++ b/src/object/pushableStatue.c @@ -132,7 +132,7 @@ void PushableStatue_SubAction0(PushableStatueEntity* this) { if (sub_080896B0()) { gPlayerState.queued_action = PLAYER_PULL; gPlayerState.field_0x38 = 0x20; - gPlayerState.flags |= 1; + gPlayerState.flags |= PL_BUSY; gPlayerEntity.x.HALF.LO = 0; gPlayerEntity.y.HALF.LO = 0; super->direction = (gPlayerEntity.animationState ^ 4) << 2; diff --git a/src/object/specialChest.c b/src/object/specialChest.c index 2d0264be..8d8fd2f1 100644 --- a/src/object/specialChest.c +++ b/src/object/specialChest.c @@ -9,7 +9,7 @@ #include "flags.h" #include "room.h" -extern void sub_08078828(Entity*); +extern void AddInteractableChest(Entity*); extern void OpenSmallChest(u32 pos, u32 layer); void SpecialChest(Entity* this) { @@ -19,7 +19,7 @@ void SpecialChest(Entity* this) { } this->action = 1; this->collisionLayer = 1; - sub_08078828(this); + AddInteractableChest(this); } if (this->interactType != 0) { OpenSmallChest(COORD_TO_TILE(this), 2); diff --git a/src/object/swordsmanNewsletter.c b/src/object/swordsmanNewsletter.c index f296de5a..15f8eef5 100644 --- a/src/object/swordsmanNewsletter.c +++ b/src/object/swordsmanNewsletter.c @@ -8,7 +8,7 @@ #include "global.h" #include "message.h" -extern void sub_080787B4(Entity*); +extern void AddInteractableCheckableObject(Entity*); void SwordsmanNewsletter_Init(Entity*); void SwordsmanNewsletter_Action1(Entity*); @@ -27,7 +27,7 @@ void SwordsmanNewsletter_Init(Entity* this) { this->frameIndex = this->type; UpdateSpriteForCollisionLayer(this); this->hitbox = (Hitbox*)&gUnk_081228A8; - sub_080787B4(this); + AddInteractableCheckableObject(this); } void SwordsmanNewsletter_Action1(Entity* this) { diff --git a/src/object/windcrest.c b/src/object/windcrest.c index 56bc6459..815a0f4a 100644 --- a/src/object/windcrest.c +++ b/src/object/windcrest.c @@ -22,9 +22,9 @@ void Windcrest(Entity* this) { HandleEntity0x82Actions(this); } -void sub_080A2124(Entity* this) { - static const u8 gUnk_08125010[] = { 0, 0, 12, 12 }; - sub_08078850(this, 1, 0xe, gUnk_08125010); +void Windcrest_ChangeInteractableHitbox(Entity* this) { + static const Rect gUnk_08125010 = { 0, 0, 12, 12 }; + SetInteractableObjectCollision(this, 1, 0xe, &gUnk_08125010); } void Windcrest_Unlock(Entity* this) { diff --git a/src/player.c b/src/player.c index cd32e8c9..9c3b725f 100644 --- a/src/player.c +++ b/src/player.c @@ -1830,7 +1830,7 @@ static void PlayerPull(Entity* this) { gPlayerState.framestate = PL_STATE_PULL; sPlayerPullStates[this->subAction](this); - gHUD.unk_2e = 8; + gHUD.rActionGrabbing = R_ACTION_GRAB; } static void sub_08072214(Entity* this) { @@ -2756,7 +2756,7 @@ static void sub_08073584(Entity* this) { return; } - gHUD.unk_2f = 1; + gHUD.rActionPlayerState = R_ACTION_CANCEL; if (sub_0807A2F8(0)) { this->subAction++; this->direction = 4 * (this->animationState & 6); diff --git a/src/playerItem/playerItemSword.c b/src/playerItem/playerItemSword.c index e1fbacb9..43471e77 100644 --- a/src/playerItem/playerItemSword.c +++ b/src/playerItem/playerItemSword.c @@ -182,7 +182,7 @@ void sub_080A76CC(PlayerItemSwordEntity* this) { } } else { - if ((gPlayerState.flags & 0x8000000) != 0) { + if ((gPlayerState.flags & PL_SWORD_THRUST) != 0) { if (this->unk_68 == 6) { super->hurtType = 0xc; } else { diff --git a/src/playerUtils.c b/src/playerUtils.c index ffacff28..941934a0 100644 --- a/src/playerUtils.c +++ b/src/playerUtils.c @@ -74,7 +74,7 @@ bool32 sub_0807BF88(u32, u32, RoomResInfo*); void sub_0807BFD0(void); void ForceSetPlayerState(u32 framestate); -struct_03003DF8* sub_080784E4(void); +InteractableObject* sub_080784E4(void); u32 sub_08079778(void); u32 GetPlayerTilePos(void); @@ -208,7 +208,7 @@ bool32 IsPreventedFromUsingItem(void) { } return FALSE; default: - if ((((gHUD.unk_2c == 0xc) && (gPlayerState.field_0x1c == 0)) && + if ((((gHUD.rActionInteractObject == R_ACTION_ROLL) && (gPlayerState.field_0x1c == 0)) && (gPlayerState.floor_type != SURFACE_SWAMP)) && ((((gPlayerState.playerInput.heldInput & PLAYER_INPUT_ANY_DIRECTION) != 0 && ((gPlayerState.flags & (PL_BURNING | PL_ROLLING)) == 0)) && @@ -655,14 +655,17 @@ bool32 (*const gPlayerChargeActions[])(ChargeState*) = { sub_08078008, sub_08078124, sub_08078140, sub_08078070, sub_080780E0, sub_08078108, }; -const u8 gUnk_0811C000[] = { - 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +const InteractableObject gNoInteraction = { + 0, INTERACTION_NULL, 0, 0, NULL, NULL, }; -const u8 gUnk_0811C00C[] = { - 0, 238, 14, 255, 0, 10, 241, 255, + +// for shifting the hitbox in which entities can be interacted with in Link's facing direction +// from left to right: north, east, south and west in x, y pairs +const s8 gPlayerInteractHitboxOffsetNormal[] = { + 0, -18, 14, -1, 0, 10, -15, -1, }; -const u8 gUnk_0811C014[] = { - 0, 242, 10, 255, 0, 6, 245, 255, +const s8 gPlayerInteractHitboxOffsetMinish[] = { + 0, -14, 10, -1, 0, 6, -11, -1, }; const u8 gUnk_0811C01C[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 3, 3, 4, 3, 0, 1, 2, 0, 3, 3, 4, 3, 10, 15, 0, 0, 0, @@ -965,50 +968,49 @@ void ForceSetPlayerState(u32 framestate) { sub_08078B48(); } -void sub_08078180(void) { - u8 uVar1; - u8 uVar3; - struct_03003DF8* ptr; +void DetermineRButtonInteraction(void) { + u8 rAction; + InteractableObject* interaction; - if (gHUD.unk_2f != 0) + if (gHUD.rActionPlayerState != R_ACTION_NONE) return; - uVar1 = 0; + rAction = R_ACTION_NONE; if ((gPlayerState.jump_status == 0) && ((gPlayerState.flags & (PL_IN_HOLE | PL_FROZEN | PL_BURNING | PL_DISABLE_ITEMS | PL_DRUGGED)) == 0)) { if ((u8)(gPlayerState.heldObject - 1) < 4) { - if (gHUD.unk_2e != 0) { - uVar1 = gHUD.unk_2e; + if (gHUD.rActionGrabbing != R_ACTION_NONE) { + rAction = gHUD.rActionGrabbing; } else { - uVar1 = 3; + rAction = R_ACTION_THROW; } } else { - if (gHUD.unk_2d != 0) { - uVar1 = gHUD.unk_2d; + if (gHUD.rActionInteractTile != R_ACTION_NONE) { + rAction = gHUD.rActionInteractTile; } else { - ptr = sub_080784E4(); - if (ptr->entity->interactType == 0) { + interaction = sub_080784E4(); + if (interaction->entity->interactType == 0) { - switch (ptr->unk_1) { - case 1: - case 7: - uVar1 = 7; + switch (interaction->type) { + case INTERACTION_TALK: + case INTERACTION_TALK_MINISH: + rAction = R_ACTION_SPEAK; break; - case 8: + case INTERACTION_LIFT_SHOP_ITEM: if (gRoomVars.shopItemType == ITEM_NONE) { - uVar1 = 9; + rAction = R_ACTION_LIFT; } break; - case 3: - case 5: - case 6: - uVar1 = 6; + case INTERACTION_OPEN_CHEST: + case INTERACTION_USE_SMALL_KEY: + case INTERACTION_USE_BIG_KEY: + rAction = R_ACTION_OPEN; break; - case 9: - uVar1 = 5; + case INTERACTION_CHECK: + rAction = R_ACTION_CHECK; break; - case 10: - uVar1 = 2; + case INTERACTION_DROP_PEDESTAL: + rAction = R_ACTION_DROP; break; } } else { @@ -1016,25 +1018,25 @@ void sub_08078180(void) { if (((gPlayerState.framestate != PL_STATE_USEPORTAL))) { if ((gCarriedEntity.unk_1 == 2) && ((gCarriedEntity.unk_8)->carryFlags == 1)) { - uVar1 = 8; + rAction = R_ACTION_GRAB; } else { - uVar1 = 9; + rAction = R_ACTION_LIFT; } } else { return; } } else { if ((gPlayerState.framestate == PL_STATE_WALK) && (gPlayerState.mobility == 0)) { - uVar1 = 0xc; + rAction = R_ACTION_ROLL; } else { - uVar1 = 0; + rAction = R_ACTION_NONE; } } } } } } - gHUD.unk_2c = uVar1; + gHUD.rActionInteractObject = rAction; } bool32 sub_080782C0(void) { @@ -1085,11 +1087,12 @@ bool32 sub_080782C0(void) { return FALSE; } } - if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && ((u8)(gUnk_03003DF0.unk_4[3] - 1) < 100)) { - sub_0801E738(0); - if (gSave.unk12B[0] != 0) { - gUnk_03003DF0.unk_2 = gUnk_03003DF0.unk_4[3]; - *(u8*)(*(int*)(gUnk_03003DF0.unk_4 + 8) + 0x39) = 2; + if (((gPlayerState.playerInput.newInput & PLAYER_INPUT_1000) != 0) && + ((u8)(gPossibleInteraction.currentObject->kinstoneId - 1) < 100)) { + AddKinstoneToBag(KINSTONE_NONE); + if (gSave.kinstoneAmounts[0] != 0) { + gPossibleInteraction.kinstoneId = gPossibleInteraction.currentObject->kinstoneId; + gPossibleInteraction.currentObject->entity->interactType = 2; gPlayerState.queued_action = PLAYER_08070E9C; } else { CreateEzloHint(TEXT_INDEX(TEXT_EZLO, 0x65), 0); @@ -1100,23 +1103,23 @@ bool32 sub_080782C0(void) { if ((gPlayerState.playerInput.newInput & (PLAYER_INPUT_80 | PLAYER_INPUT_8)) == 0) { return FALSE; } - switch (gUnk_03003DF0.unk_4[1]) { + switch (gPossibleInteraction.currentObject->type) { default: - case 0: + case INTERACTION_NONE: return TRUE; - case 1: - case 6: - case 9: - case 0xa: + case INTERACTION_TALK: + case INTERACTION_USE_BIG_KEY: + case INTERACTION_CHECK: + case INTERACTION_DROP_PEDESTAL: gPlayerState.queued_action = PLAYER_08070E9C; ForceSetPlayerState(PL_STATE_TALKEZLO); - case 3: - case 5: - case 7: + case INTERACTION_OPEN_CHEST: + case INTERACTION_USE_SMALL_KEY: + case INTERACTION_TALK_MINISH: entity->interactType = 1; - gUnk_03003DF0.unk_2 = 0; + gPossibleInteraction.kinstoneId = KINSTONE_NONE; return TRUE; - case 8: + case INTERACTION_LIFT_SHOP_ITEM: if (gRoomVars.shopItemType == 0) { entity->interactType = 1; gRoomVars.shopItemType = entity->type; @@ -1128,99 +1131,102 @@ bool32 sub_080782C0(void) { return TRUE; } -void sub_080784C8(void) { - MemClear(&gUnk_03003DF0, sizeof(gUnk_03003DF0)); - gUnk_03003DF0.unk_4 = (u8*)gUnk_0811C000; +void ResetPossibleInteraction(void) { + MemClear(&gPossibleInteraction, sizeof(gPossibleInteraction)); + gPossibleInteraction.currentObject = (InteractableObject*)&gNoInteraction; } -ASM_FUNC("asm/non_matching/playerUtils/sub_080784E4.inc", struct_03003DF8* sub_080784E4(void)) +// determines which (if any) object the player is currently able to interact with +ASM_FUNC("asm/non_matching/playerUtils/sub_080784E4.inc", InteractableObject* sub_080784E4(void)) -void sub_08078778(Entity* ent) { - sub_0807887C(ent, 1, 0); +void AddInteractableWhenBigObject(Entity* ent) { + AddInteractableObject(ent, 1, 0); } -void sub_08078784(Entity* ent, u32 arg1) { - sub_0807887C(ent, 1, arg1); +void AddInteractableWhenBigFuser(Entity* ent, KinstoneId kinstoneId) { + AddInteractableObject(ent, 1, kinstoneId); } -void sub_08078790(Entity* ent, u32 arg1) { - sub_0807887C(ent, 2, arg1); +void AddInteractableFuser(Entity* ent, KinstoneId kinstoneId) { + AddInteractableObject(ent, 2, kinstoneId); } -void sub_0807879C(Entity* ent) { - sub_0807887C(ent, 7, 0); +void AddInteractableAsMinishObject(Entity* ent) { + AddInteractableObject(ent, 7, 0); } -void sub_080787A8(Entity* ent, u32 arg1) { - sub_0807887C(ent, 7, arg1); +void AddInteractableAsMinishFuser(Entity* ent, KinstoneId kinstoneId) { + AddInteractableObject(ent, 7, kinstoneId); } -void sub_080787B4(Entity* ent) { - sub_0807887C(ent, 9, 0); +void AddInteractableCheckableObject(Entity* ent) { + AddInteractableObject(ent, 9, 0); } -void sub_080787C0(Entity* ent) { - sub_0807887C(ent, 10, 0); +void AddInteractablePedestal(Entity* ent) { + AddInteractableObject(ent, 10, 0); } -void sub_080787CC(Entity* ent) { - sub_0807887C(ent, 5, 0); +void AddInteractableSmallKeyLock(Entity* ent) { + AddInteractableObject(ent, 5, 0); } -s32 sub_080787D8(Entity* ent) { +s32 AddInteractableShopItem(Entity* ent) { s32 iVar1; - iVar1 = sub_0807887C(ent, 8, 0); + iVar1 = AddInteractableObject(ent, 8, 0); if (iVar1 >= 0) { - gUnk_03003DF0.array[iVar1].unk_2 = 0xbe; + gPossibleInteraction.candidates[iVar1].interactDirections = 0xbe; } return iVar1; } -s32 sub_08078800(Entity* ent) { +s32 AddInteractableBossDoor(Entity* ent) { s32 iVar1; - iVar1 = sub_0807887C(ent, 6, 0); + iVar1 = AddInteractableObject(ent, 6, 0); if (iVar1 >= 0) { - gUnk_03003DF0.array[iVar1].unk_2 = 0xbe; + // weird, this line assumes it's a north door, and is unnecessary + // anyway because this is overwritten right after returning + gPossibleInteraction.candidates[iVar1].interactDirections = 0xbe; } return iVar1; } -s32 sub_08078828(Entity* ent) { +s32 AddInteractableChest(Entity* ent) { s32 iVar1; - iVar1 = sub_0807887C(ent, 3, 0); + iVar1 = AddInteractableObject(ent, 3, 0); if (iVar1 >= 0) { - gUnk_03003DF0.array[iVar1].unk_2 = 0xbe; + gPossibleInteraction.candidates[iVar1].interactDirections = 0xbe; } return iVar1; } -void sub_08078850(Entity* arg0, u32 arg1, u32 arg2, const void* arg3) { +void SetInteractableObjectCollision(Entity* arg0, u32 ignoreLayer, u32 interactDirections, const void* customHitbox) { s32 iVar1; - iVar1 = sub_08078904(arg0); + iVar1 = GetInteractableObjectIndex(arg0); if (iVar1 >= 0) { - gUnk_03003DF0.array[iVar1].unk_0 = arg1; - gUnk_03003DF0.array[iVar1].unk_2 = arg2; - gUnk_03003DF0.array[iVar1].unk_4 = arg3; + gPossibleInteraction.candidates[iVar1].ignoreLayer = ignoreLayer; + gPossibleInteraction.candidates[iVar1].interactDirections = interactDirections; + gPossibleInteraction.candidates[iVar1].customHitbox = customHitbox; } } -s32 sub_0807887C(Entity* entity, u32 param_2, u32 param_3) { +s32 AddInteractableObject(Entity* entity, InteractionType type, KinstoneId kinstoneId) { s32 index; entity->interactType = 0; - index = sub_08078904(entity); + index = GetInteractableObjectIndex(entity); if (index < 0) { - index = sub_08078904(0); + index = GetInteractableObjectIndex(0); } if (index >= 0) { - gUnk_03003DF0.array[index].entity = entity; - gUnk_03003DF0.array[index].unk_1 = param_2; - gUnk_03003DF0.array[index].unk_3 = param_3; + gPossibleInteraction.candidates[index].entity = entity; + gPossibleInteraction.candidates[index].type = type; + gPossibleInteraction.candidates[index].kinstoneId = kinstoneId; } - if (param_3 != 0) { + if (kinstoneId != KINSTONE_NONE) { Entity* entity = FindEntityByID(OBJECT, CAMERA_TARGET, 6); if (entity == NULL) { CreateObject(CAMERA_TARGET, 0, 0); @@ -1230,18 +1236,18 @@ s32 sub_0807887C(Entity* entity, u32 param_2, u32 param_3) { } /** Clear entry for Entity. */ -void sub_080788E0(Entity* entity) { - s32 index = sub_08078904(entity); +void RemoveInteractableObject(Entity* entity) { + s32 index = GetInteractableObjectIndex(entity); if (index > -1) { - MemClear(&gUnk_03003DF0.array[index], 0xc); + MemClear(&gPossibleInteraction.candidates[index], sizeof(InteractableObject)); } } /** Find entry for Entity. */ -s32 sub_08078904(Entity* entity) { +s32 GetInteractableObjectIndex(Entity* entity) { u32 index; for (index = 0; index < 0x20; index++) { - if (entity == gUnk_03003DF0.array[index].entity) { + if (entity == gPossibleInteraction.candidates[index].entity) { return index; } } @@ -1373,7 +1379,7 @@ void ClearPlayerState(void) { gPlayerState.spriteOffsetY = 0; gPlayerState.field_0x3c = 0; MemFill32(0xffffffff, gPlayerState.path_memory, 0x40); - MemClear(&gUnk_03003DF0, sizeof(gUnk_03003DF0)); + MemClear(&gPossibleInteraction, sizeof(gPossibleInteraction)); } void UpdateCarriedObject(void) { @@ -1518,10 +1524,10 @@ void sub_08078FB0(Entity* this) { gPlayerState.field_0x35 = 0xff; } sub_08079064(this); - if ((gPlayerState.flags & 8) != 0) { + if ((gPlayerState.flags & PL_NO_CAP) != 0) { animIndex = 0x58; } else { - if ((gPlayerState.flags & 0x80) != 0) { + if ((gPlayerState.flags & PL_MINISH) != 0) { animIndex = 0x18; } else { if (gPlayerState.animation >> 8 == 7) { @@ -1714,8 +1720,8 @@ void RespawnPlayer(void) { player->zVelocity = 0; player->knockbackDuration = 0; ResetPlayerPosition(); - if ((gPlayerState.flags & 0x20000) == 0) { - if ((gPlayerState.flags & 0x10000) != 0) { + if ((gPlayerState.flags & PL_GYORG_FIGHT) == 0) { + if ((gPlayerState.flags & PL_FLAGS10000) != 0) { player->x.HALF.HI = gPlayerState.lilypad->x.HALF.HI; player->y.HALF.HI = gPlayerState.lilypad->y.HALF.HI; } else { @@ -1760,7 +1766,54 @@ u32 sub_0807953C(void) { return gPlayerState.playerInput.newInput & tmp; } -ASM_FUNC("asm/non_matching/playerUtils/sub_08079550.inc", u32 sub_08079550(void)) +bool32 sub_08079550(void) { + const s8* ptr; + u32 uVar3; + u32 tilePos2; + u32 tilePos1; + + if (gDiggingCaveEntranceTransition.isDiggingCave == 0) { + if ((gPlayerState.dash_state == 0 || (gPlayerState.flags & PL_BURNING)) && + (gPlayerState.swim_state != 0 || (gPlayerState.sword_state & 0x40) || + gPlayerEntity.direction != gPlayerState.direction || (gPlayerEntity.direction & 0x80))) { + gPlayerEntity.subtimer = 0; + return FALSE; + } + if (sub_08079778()) { + ptr = &gUnk_0811C100[gPlayerEntity.animationState & 6]; + if ((gPlayerEntity.animationState & 2) != 0) { + tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], -(gPlayerEntity.hitbox)->unk2[1]); + tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -ptr[0], +(gPlayerEntity.hitbox)->unk2[1]); + } else { + + tilePos1 = COORD_TO_TILE_OFFSET(&gPlayerEntity, -(gPlayerEntity.hitbox)->unk2[2], -ptr[1]); + tilePos2 = COORD_TO_TILE_OFFSET(&gPlayerEntity, (gPlayerEntity.hitbox)->unk2[2], -ptr[1]); + } + + uVar3 = sub_080B1AE0(tilePos1, gPlayerEntity.collisionLayer); + uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.animationState >> 1]); + if (uVar3 != 0) { + uVar3 = sub_080B1AE0(tilePos2, gPlayerEntity.collisionLayer); + uVar3 = sub_08007DD6(uVar3, gUnk_0811C1E8[gPlayerEntity.animationState >> 1]); + if (uVar3 != 0) { + gPlayerState.pushedObject |= 0x80; + if (gPlayerState.dash_state == 0 && (++gPlayerEntity.subtimer <= 5)) { + return FALSE; + } + + gPlayerEntity.animationState = uVar3 - 1; + gPlayerEntity.action = 4; + gPlayerEntity.subAction = 0; + COLLISION_OFF(&gPlayerEntity); + gPlayerState.jump_status = 0x81; + DoPlayerAction(&gPlayerEntity); + return TRUE; + } + } + } + } + return FALSE; +} void sub_08079708(Entity* this) { gPlayerState.framestate = PL_STATE_DIE; diff --git a/src/projectile/gyorgTail.c b/src/projectile/gyorgTail.c index c3657692..1f191f7a 100644 --- a/src/projectile/gyorgTail.c +++ b/src/projectile/gyorgTail.c @@ -169,70 +169,76 @@ void sub_080AC560(Entity* this) { this->y.WORD = entity->y.WORD - gSineTable[entity->direction + 0x40] * factor; } -NONMATCH("asm/non_matching/gyorgTail/sub_080AC5E4.inc", bool32 sub_080AC5E4(Entity* this)) { +bool32 sub_080AC5E4(Entity* this) { // TODO regalloc Entity* entity; + Entity* new_var2; Entity* entity2; Entity* entity3; Entity* entity4; - u8 uVar3; if (this->type == 0) { - if (0x43 < gEntCount) { + if (gEntCount > 0x43) { return FALSE; } this->field_0x78.HALF.HI = 0x11; - entity = CreateProjectile(0x22); + entity = CreateProjectile(GYORG_TAIL); entity->type = this->type; entity->type2 = 1; entity->parent = this->parent; entity->field_0x78.HALF.HI = 0x12; this->child = entity; - entity2 = CreateProjectile(0x22); + + entity2 = CreateProjectile(GYORG_TAIL); entity2->type = this->type; entity2->type2 = 2; entity2->parent = this->parent; entity2->field_0x78.HALF.HI = 0x14; - uVar3 = entity2->field_0x78.HALF.HI; - entity2->field_0x78.HALF.HI = uVar3; entity->child = entity2; - entity3 = CreateProjectile(0x22); + + entity3 = CreateProjectile(GYORG_TAIL); entity3->type = this->type; entity3->type2 = 3; entity3->parent = this->parent; entity3->child = NULL; entity3->field_0x78.HALF.HI = 0; entity2->child = entity3; + + entity = CreateProjectile(GYORG_TAIL); + entity->type = this->type; + entity->type2 = 4; + entity->parent = this->parent; + entity->child = this; + entity->field_0x78.HALF.HI = 0x14; } else { - if (0x44 < gEntCount) { + if (gEntCount > 0x44) { return FALSE; } this->field_0x78.HALF.HI = 0xf; - entity = CreateProjectile(0x22); + entity = CreateProjectile(GYORG_TAIL); entity->type = this->type; entity->type2 = 1; entity->parent = this->parent; entity->field_0x78.HALF.HI = 0x10; - uVar3 = entity->field_0x78.HALF.HI; - entity->field_0x78.HALF.HI = uVar3; this->child = entity; - entity2 = CreateProjectile(0x22); + + entity2 = CreateProjectile(GYORG_TAIL); entity2->type = this->type; entity2->type2 = 2; entity2->parent = this->parent; entity2->child = NULL; entity2->field_0x78.HALF.HI = 0x20; entity->child = entity2; + + entity = CreateProjectile(GYORG_TAIL); + entity->type = this->type; + entity->type2 = 4; + entity->parent = this->parent; + entity->child = this; + entity->field_0x78.HALF.HI = 0x10; } - entity = CreateProjectile(0x22); - entity->type = this->type; - entity->type2 = 4; - entity->parent = this->parent; - entity->child = this; - entity->field_0x78.HALF.HI = uVar3; return TRUE; } -END_NONMATCH void sub_080AC6F0(Entity* this) { static const u8 gUnk_0812A9C0[] = { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, diff --git a/src/script.c b/src/script.c index 29cee3df..e18a0359 100644 --- a/src/script.c +++ b/src/script.c @@ -94,12 +94,12 @@ void ScriptCommand_SetVariableToFrame(Entity* entity, ScriptExecutionContext* co void ScriptCommand_SetAnimation(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_TriggerInteract(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E974(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807E9D4(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807E9DC(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807E9E4(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_AddInteractableWhenBigObject(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_RemoveInteractableObject(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_AddInteractableWhenBigFuser(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807E9F0(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_0807EA4C(Entity* entity, ScriptExecutionContext* context); -void ScriptCommand_0807EA88(Entity* entity, ScriptExecutionContext* context); +void ScriptCommand_AddInteractableFuser(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_WaitUntilTextboxCloses(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_MessageFromTarget(Entity* entity, ScriptExecutionContext* context); void ScriptCommand_MessageNoOverlap(Entity* entity, ScriptExecutionContext* context); @@ -543,12 +543,12 @@ void ExecuteScript(Entity* entity, ScriptExecutionContext* context) { ScriptCommand_SetAnimation, ScriptCommand_TriggerInteract, ScriptCommand_0807E974, - ScriptCommand_0807E9D4, - ScriptCommand_0807E9DC, - ScriptCommand_0807E9E4, + ScriptCommand_AddInteractableWhenBigObject, + ScriptCommand_RemoveInteractableObject, + ScriptCommand_AddInteractableWhenBigFuser, ScriptCommand_0807E9F0, ScriptCommand_0807EA4C, - ScriptCommand_0807EA88, + ScriptCommand_AddInteractableFuser, ScriptCommand_WaitUntilTextboxCloses, ScriptCommand_MessageFromTarget, ScriptCommand_MessageNoOverlap, @@ -721,17 +721,17 @@ void ScriptCommand_CheckInventory1(Entity* entity, ScriptExecutionContext* conte u32 tmp; u32 tmp2 = GetNextScriptCommandHalfwordAfterCommandMetadata(context->scriptInstructionPointer); switch (tmp2) { - case 0x53: - tmp = HasDungeonMap(); - break; - case 0x52: - tmp = HasDungeonCompass(); + case ITEM_SMALL_KEY: + tmp = HasDungeonSmallKey(); break; - case 0x51: + case ITEM_BIG_KEY: tmp = HasDungeonBigKey(); break; - case 0x50: - tmp = HasDungeonSmallKey(); + case ITEM_COMPASS: + tmp = HasDungeonCompass(); + break; + case ITEM_DUNGEON_MAP: + tmp = HasDungeonMap(); break; default: tmp = GetInventoryValue(tmp2); @@ -1136,16 +1136,16 @@ void ScriptCommand_0807E974(Entity* entity, ScriptExecutionContext* context) { gActiveScriptInfo.commandSize = 0; } -void ScriptCommand_0807E9D4(Entity* entity, ScriptExecutionContext* context) { - sub_08078778(entity); +void ScriptCommand_AddInteractableWhenBigObject(Entity* entity, ScriptExecutionContext* context) { + AddInteractableWhenBigObject(entity); } -void ScriptCommand_0807E9DC(Entity* entity, ScriptExecutionContext* context) { - sub_080788E0(entity); +void ScriptCommand_RemoveInteractableObject(Entity* entity, ScriptExecutionContext* context) { + RemoveInteractableObject(entity); } -void ScriptCommand_0807E9E4(Entity* entity, ScriptExecutionContext* context) { - sub_08078784(entity, context->scriptInstructionPointer[1]); +void ScriptCommand_AddInteractableWhenBigFuser(Entity* entity, ScriptExecutionContext* context) { + AddInteractableWhenBigFuser(entity, context->scriptInstructionPointer[1]); } void ScriptCommand_0807E9F0(Entity* entity, ScriptExecutionContext* context) { @@ -1184,8 +1184,8 @@ void ScriptCommand_0807EA4C(Entity* entity, ScriptExecutionContext* context) { } } -void ScriptCommand_0807EA88(Entity* entity, ScriptExecutionContext* context) { - sub_08078790(entity, context->scriptInstructionPointer[1]); +void ScriptCommand_AddInteractableFuser(Entity* entity, ScriptExecutionContext* context) { + AddInteractableFuser(entity, context->scriptInstructionPointer[1]); } void ScriptCommand_WaitUntilTextboxCloses(Entity* entity, ScriptExecutionContext* context) { @@ -1825,7 +1825,7 @@ void sub_0807F634(Entity* entity, ScriptExecutionContext* context) { } void sub_0807F650(Entity* entity, ScriptExecutionContext* context) { - u32 p = sub_08002632(entity); + u32 p = GetFuserId(entity); sub_0801DFB4(entity, gUnk_08001A7C[p][0], gUnk_08001A7C[p][1], gUnk_08001A7C[p][2]); gPlayerState.controlMode = CONTROL_DISABLED; } @@ -1969,16 +1969,16 @@ void PutItemAnySlot(Entity* entity, ScriptExecutionContext* context) { PutItemOnSlot(context->intVariable); } -void sub_0807F924(Entity* entity, ScriptExecutionContext* context) { - sub_0807879C(entity); +void MakeInteractableAsMinish(Entity* entity, ScriptExecutionContext* context) { + AddInteractableAsMinishObject(entity); } -void sub_0807F92C(Entity* entity, ScriptExecutionContext* context) { - sub_080787C0(entity); +void MakePedestalInteractable(Entity* entity, ScriptExecutionContext* context) { + AddInteractablePedestal(entity); } -void sub_0807F934(Entity* entity, ScriptExecutionContext* context) { - sub_080787B4(entity); +void MakeCheckableObjectInteractable(Entity* entity, ScriptExecutionContext* context) { + AddInteractableCheckableObject(entity); } void sub_0807F93C(Entity* entity, ScriptExecutionContext* context) { diff --git a/src/scroll.c b/src/scroll.c index 9ff97e39..19e52f9e 100644 --- a/src/scroll.c +++ b/src/scroll.c @@ -28,7 +28,7 @@ extern void sub_0805E248(); extern u8 gUpdateVisibleTiles; extern u16 gUnk_0200B640; extern u32** gUnk_08109194[]; -extern u8 gUnk_02022830[]; +extern u32 gUnk_02022830[]; extern u16 gUnk_020246B0[]; extern u8 gUnk_080B7910[]; @@ -418,7 +418,68 @@ void sub_080801BC(RoomControls* controls) { } } -ASM_FUNC("asm/non_matching/scroll/sub_08080278.inc", u32 sub_08080278()) +u32 sub_08080278(void) { + u32 width; + u32 height; + u32 tilePos; + u16* bottomMapDataPtr; + u16* topMapDataPtr; + u32 result; + u16* bottomMapDataClonePtr; + u16* topMapDataClonePtr; + u32 indexX; + FORCE_REGISTER(u32 indexY, r10); + int iVar10; + u16* ptr1; + u32 tmp; + + ptr1 = (u16*)gUnk_02022830; + width = gRoomControls.width >> 4; + height = (gRoomControls.height >> 4) << 6; + result = 0; + indexY = 0; + if (result < height) { + iVar10 = 0; + do { + indexX = 0; + if (indexX < width) { + topMapDataPtr = (u16*)((int)gMapTop.mapData + iVar10); + topMapDataClonePtr = (u16*)((int)gMapTop.mapDataClone + iVar10); + bottomMapDataPtr = (u16*)((int)gMapBottom.mapData + iVar10); + bottomMapDataClonePtr = (u16*)((int)gMapBottom.mapDataClone + iVar10); + while (indexX < width) { + tilePos = indexY + indexX; + if ((bottomMapDataClonePtr[0] != bottomMapDataPtr[0]) && (bottomMapDataPtr[0] < 0x4000)) { + ptr1[0] = tilePos | 0x4000; + ptr1[1] = bottomMapDataPtr[0]; + ptr1 += 2; + result++; + if (result >= 0x600) { + return result; + } + } + if ((topMapDataClonePtr[0] != topMapDataPtr[0]) && (topMapDataPtr[0] < 0x4000)) { + ptr1[0] = tilePos | 0x8000; + ptr1[1] = topMapDataPtr[0]; + ptr1 += 2; + result++; + if (result >= 0x800) { + return result; + } + } + topMapDataPtr++; + topMapDataClonePtr++; + bottomMapDataPtr++; + bottomMapDataClonePtr++; + indexX++; + } + } + iVar10 += 0x80; + indexY += 0x40; + } while (indexY < height); + } + return result; +} void sub_08080368(void) { u32 tmp; diff --git a/src/subtask.c b/src/subtask.c index 3cae246b..67096dc2 100644 --- a/src/subtask.c +++ b/src/subtask.c @@ -14,7 +14,6 @@ #include "subtask.h" #include "ui.h" -extern u8 gUnk_020350F0[]; extern Screen gUnk_03001020; extern u8 gPaletteBufferBackup[]; extern u8 gUnk_03000420[]; @@ -53,7 +52,7 @@ void sub_080A6F6C(u32 textIndexOrPtr) { extern Font gUnk_08128FA8; if (gGenericMenu.unk2e.HWORD != textIndexOrPtr) { gGenericMenu.unk2e.HWORD = textIndexOrPtr; - MemClear(gUnk_020350F0, 0x100); + MemClear(&gBG0Buffer[0x220], 0x100); if ((textIndexOrPtr & 0xff) != 0) { ShowTextBox(textIndexOrPtr, &gUnk_08128FA8); } @@ -92,7 +91,7 @@ void ShowAreaName(u32 id, u32 type) { if (gGenericMenu.unk2e.HWORD != textIndexOrPtr) { gGenericMenu.unk2e.HWORD = textIndexOrPtr; - MemClear(&gUnk_020350F0, 0x100); + MemClear(&gBG0Buffer[0x220], 0x100); if ((textIndexOrPtr & 0xff) != 0) { ShowTextBox(textIndexOrPtr, font); } @@ -103,11 +102,10 @@ void ShowAreaName(u32 id, u32 type) { void sub_080A7040(u32 param_1) { extern Font gUnk_08129004; - extern u8 gUnk_02022130[]; if (gGenericMenu.unk2e.HWORD != param_1) { gGenericMenu.unk2e.HWORD = param_1; - MemClear(gUnk_02022130, 0x300); - MemCopy(gUnk_02022130 - 0x200, (void*)0x600e000, 0x800); + MemClear(&gBG1Buffer[0x100], 0x300); + MemCopy(gBG1Buffer, (void*)0x600e000, 0x800); if (GetInventoryValue(gUnk_08128D70[param_1].item) != 0) { ShowTextBox(gUnk_08128D70[param_1].textIndex, &gUnk_08129004); } @@ -122,13 +120,13 @@ void sub_080A70AC(const KeyButtonLayout* layout) { gHUD.unk_14 = 0x7f; gHUD.buttonX[0] = layout->aButtonX; gHUD.buttonY[0] = (s8)layout->aButtonY; - gHUD.unk_30[0] = layout->aButtonText; + gHUD.buttonText[0] = layout->aButtonText; gHUD.buttonX[1] = layout->bButtonX; gHUD.buttonY[1] = (s8)layout->bButtonY; - gHUD.unk_30[1] = layout->bButtonText; + gHUD.buttonText[1] = layout->bButtonText; gHUD.buttonX[2] = layout->rButtonX; gHUD.buttonY[2] = (s8)layout->rButtonY; - gHUD.unk_32 = layout->rButtonText; + gHUD.buttonText[2] = layout->rButtonText; layout++; do { CreateUIElement(layout->aButtonX, layout->aButtonY); diff --git a/src/subtask/subtaskLocalMapHint.c b/src/subtask/subtaskLocalMapHint.c index 22758da4..357e3f7e 100644 --- a/src/subtask/subtaskLocalMapHint.c +++ b/src/subtask/subtaskLocalMapHint.c @@ -38,7 +38,7 @@ void sub_080A6B04(void) { sub_080A4DB8(6); ptr = &gKinstoneWorldEvents[gFuseInfo.kinstoneId]; ptr2 = &gWorldEvents[ptr->worldEventId]; - bVar1 = ptr->unk7; + bVar1 = ptr->mapMarkerIcon; uVar3 = ptr2->_c; uVar4 = ptr2->_e; uVar2 = GetOverworldLocation(uVar3, uVar4)->windcrestId; diff --git a/src/subtask/subtaskWorldEvent.c b/src/subtask/subtaskWorldEvent.c index bae3e921..0c7c5b5b 100644 --- a/src/subtask/subtaskWorldEvent.c +++ b/src/subtask/subtaskWorldEvent.c @@ -58,7 +58,7 @@ void Subtask_WorldEvent_Update(void) { void Subtask_WorldEvent_End(void) { MessageInitialize(); sub_0806F38C(); - if (gKinstoneWorldEvents[gFuseInfo.kinstoneId].unk7 != 0) { + if (gKinstoneWorldEvents[gFuseInfo.kinstoneId].mapMarkerIcon != 0) { // Show the map hint. MenuFadeIn(SUBTASK_LOCALMAPHINT, gUI.field_0x3); } else { @@ -11,57 +11,8 @@ #include "structures.h" extern void sub_0805ECEC(u32, u32, u32, u32); -extern bool32 ItemIsBottle(u32); extern u32 sub_08000E44(u32); -typedef struct { - u16 unk_0; - u16 unk_2; - u16 unk_4; - u16 unk_6; - u16 unk_8; -} substruct_160; - -typedef struct { - substruct_160 unk_0; - u8 unk_9[50]; - substruct_160 unk_40; -} struct_02035160; -extern struct_02035160 gUnk_02035160; - -typedef struct { - u32 unk_0; - u32 unk_4; - u32 unk_8; - u32 unk_c; - u32 unk_10; - u32 unk_14; - u8 unk_18[40]; -} struct_02034CF0; - -extern struct_02034CF0 gUnk_02034CF0[]; - -typedef struct { - struct_02034CF0 unk_0; - struct_02034CF0 unk_40; -} struct_02034D30; - -extern struct_02034D30 gUnk_02034D30; - -typedef struct { - u16 unk_0; - u16 unk_2; - u16 unk_4; - u16 unk_6; - u8 pad[56]; -} substruct_0E2; - -typedef struct { - substruct_0E2 unk_0[2]; -} struct_020350E2; - -extern struct_020350E2 gUnk_020350E2; - extern const u16 gUnk_080C8F2C[]; extern u32 gUnk_085C4620[]; extern Frame* gSpriteAnimations_322[]; @@ -94,13 +45,13 @@ void DrawChargeBar(void); void DrawRupees(void); void DrawKeys(void); void CreateUIElement(u32, u32); -void DrawDigits(u32, u32, u32, u32); +void RenderDigits(u32, u32, u32, u32); void sub_0801CAFC(UIElement*, u32); void sub_0801CB20(UIElement*, UIElementDefinition*); UIElement* FindUIElement(u32); void sub_0801CAD0(UIElement*); void sub_0801CAB8(UIElement*, Frame*); -void sub_0801C824(void); +void EraseChargeBar(void); void UpdateUIElements(void) { u32 index; @@ -119,7 +70,7 @@ void DrawUIElements(void) { u32 index; UIElement* element; UIElementDefinition* definition; - index = 0; + for (index = 0; index < MAX_UI_ELEMENTS; index++) { element = &gHUD.elements[index]; if (element->used == 1 && element->unk_0_1 == 1) { @@ -135,7 +86,6 @@ void DrawUIElements(void) { } void sub_0801C25C(void) { - u32 uVar1; s32 index; u8 tmp; UIElement* element; @@ -165,7 +115,6 @@ void sub_0801C25C(void) { void sub_0801C2F0(u32 param_1, u32 param_2) { u32 uVar1; register u32 rem asm("r1"); - vu32* ptr; param_1 = param_1 * 0x20 + 0x6010000; uVar1 = Div(param_2, 10); @@ -250,46 +199,42 @@ void DrawRupees(void) { u32 cVar1; u32 temp; u32 temp2; - substruct_160* ptr; - substruct_160* ptr2; - const u16* ptr3; - struct_02035160* ptr4; + u16* row1; + u16* row2; if (gHUD.hideFlags & HUD_HIDE_RUPEES) { if (gHUD.unk_a != 0) { gHUD.unk_a = 0; - ptr4 = &gUnk_02035160; - ptr = &ptr4->unk_0; - ptr->unk_0 = 0; - ptr->unk_2 = 0; - ptr->unk_4 = 0; - ptr->unk_6 = 0; - ptr->unk_8 = 0; - ptr2 = &ptr4->unk_40; - ptr2->unk_0 = 0; - ptr2->unk_2 = 0; - ptr2->unk_4 = 0; - ptr2->unk_6 = 0; - ptr2->unk_8 = 0; + row1 = &gBG0Buffer[0x258]; + row1[0] = 0; + row1[1] = 0; + row1[2] = 0; + row1[3] = 0; + row1[4] = 0; + row2 = &gBG0Buffer[0x278]; + row2[0] = 0; + row2[1] = 0; + row2[2] = 0; + row2[3] = 0; + row2[4] = 0; gScreen.bg0.updated = 1; } } else { if (gHUD.unk_a == 0) { gHUD.unk_a = 2; - ptr4 = &gUnk_02035160; - ptr2 = &ptr4->unk_40; - ptr3 = gWalletSizes; - ptr4->unk_0.unk_0 = temp2 = *(ptr3 + (u32)gSave.stats.walletType * 2 + 1); - ptr4->unk_0.unk_2 = temp2 + 1; - ptr2->unk_0 = temp2 + 2; - ptr2->unk_2 = temp2 + 3; + row1 = &gBG0Buffer[0x258]; + row2 = &gBG0Buffer[0x278]; + row1[0] = temp2 = gWalletSizes[gSave.stats.walletType].iconStartTile; + row1[1] = temp2 + 1; + row2[0] = temp2 + 2; + row2[1] = temp2 + 3; temp2 = 0xf070; - ptr4->unk_0.unk_4 = temp2; - ptr2->unk_4 = temp2 + 1; - ptr4->unk_0.unk_6 = temp2 + 2; - ptr2->unk_6 = temp2 + 3; - ptr4->unk_0.unk_8 = temp2 + 4; - ptr2->unk_8 = temp2 + 5; + row1[2] = temp2; + row2[2] = temp2 + 1; + row1[3] = temp2 + 2; + row2[3] = temp2 + 3; + row1[4] = temp2 + 4; + row2[4] = temp2 + 5; gScreen.bg0.updated = 1; cVar1 = 1; } else { @@ -312,8 +257,8 @@ void DrawRupees(void) { SoundReq(SFX_RUPEE_GET); } case 1: - DrawDigits(0x70, gHUD.rupees, - (u16)gWalletSizes[(u32)gSave.stats.walletType * 2] <= gHUD.rupees, 3); + RenderDigits(0x70, gHUD.rupees, + gWalletSizes[(u32)gSave.stats.walletType].size <= gHUD.rupees, 3); cVar1 = gHUD.unk_c + 1; default: gHUD.unk_c = cVar1; @@ -324,8 +269,8 @@ void DrawRupees(void) { /** * Draw icon with text for rupees or keys -*/ -void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { + */ +void RenderDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { int iVar2; int iVar3; u8* puVar4; @@ -345,7 +290,7 @@ void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { digit = Div(count, 100); count = r1; DmaCopy32(3, puVar4 + digit * 0x40, iVar2, 0x10 * 4); - iVar2 = iVar3 + 0x600c040; + iVar2 += 0x40; case 2: digit = Div(count, 10); count = r1; @@ -356,26 +301,26 @@ void DrawDigits(u32 iconVramIndex, u32 count, u32 isTextYellow, u32 digits) { DmaCopy32(3, puVar4 + count * 0x40, iVar2, 0x10 * 4); } -void sub_0801C66C(void) { - struct_02034CF0* ptr; +void EraseHearts(void) { + u32* ptr; s32 index; if (gHUD.unk_2 != 0) { gHUD.unk_2 = 0; - if (gHUD.maxHealth > 0x28) { + if (gHUD.maxHealth > 10 * 4) { index = 2; } else { index = 1; } - ptr = gUnk_02034CF0; + ptr = (u32*)&gBG0Buffer[0x20]; do { - ptr->unk_0 = 0; - ptr->unk_4 = 0; - ptr->unk_8 = 0; - ptr->unk_c = 0; - ptr->unk_10 = 0; - ptr->unk_14 = 0; - ptr++; + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + ptr[3] = 0; + ptr[4] = 0; + ptr[5] = 0; + ptr += 0x10; index--; } while (index > 0); gScreen.bg0.updated = 1; @@ -386,23 +331,21 @@ void DrawHearts(void) { s32 health; s32 uVar1; s32 uVar2; - s32 uVar4; u32 uVar6; s32 maxHealth; - const u16* ptr; s32 tmp1; - u16* ptr2; + u16* ptr; if (gHUD.hideFlags & HUD_HIDE_HEARTS) { - sub_0801C824(); - sub_0801C66C(); + EraseChargeBar(); + EraseHearts(); return; } maxHealth = gSave.stats.maxHealth / 2; if (maxHealth != gHUD.maxHealth) { gHUD.maxHealth = maxHealth; - sub_0801C824(); - sub_0801C66C(); + EraseChargeBar(); + EraseHearts(); } if (gSave.stats.health != 1) { health = gSave.stats.health / 2; @@ -457,42 +400,42 @@ void DrawHearts(void) { } if (uVar1 - 10 > 0) { - ptr2 = (u16*)&gUnk_02034D30; - *ptr2 = 0xf010; - DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr2 + 1, (uVar1 - 10) | 0x80000000); + ptr = &gBG0Buffer[0x40]; + *ptr = 0xf010; + DmaSet(3, gUnk_080C8F2C + (10 - uVar6), ptr + 1, (uVar1 - 10) | 0x80000000); } - ptr2 = (u16*)&gUnk_02034CF0[0].unk_0; - *ptr2 = 0xf010; + ptr = &gBG0Buffer[0x20]; + *ptr = 0xf010; - DmaSet(3, gUnk_080C8F2C + (10 - tmp1), ptr2 + 1, maxHealth | 0x80000000); + DmaSet(3, gUnk_080C8F2C + (10 - tmp1), ptr + 1, maxHealth | 0x80000000); if ((gHUD.health & 3) != 0) { if (9 < uVar2) { uVar2 -= 10; - ptr2 += 0x20; + ptr += 0x20; } - ptr2[uVar2 + 1] = ((gHUD.health & 3) + 0x11) | 0xf000; + ptr[uVar2 + 1] = ((gHUD.health & 3) + 0x11) | 0xf000; } gScreen.bg0.updated = 1; } } -void sub_0801C824(void) { - struct_02034CF0* ptr; +void EraseChargeBar(void) { + u32* ptr; if (gHUD.unk_6 != 0) { gHUD.unk_6 = 0; - if (gHUD.maxHealth > 4 * 10) { - ptr = &gUnk_02034D30.unk_40; // Show second row of hearts + if (gHUD.maxHealth > 10 * 4) { + ptr = (u32*)&gBG0Buffer[0x60]; } else { - ptr = &gUnk_02034D30.unk_0; + ptr = (u32*)&gBG0Buffer[0x40]; } - ptr->unk_0 = 0; - ptr->unk_4 = 0; - ptr->unk_8 = 0; - ptr->unk_c = 0; - ptr->unk_10 = 0; - ptr->unk_14 = 0; + ptr[0] = 0; + ptr[1] = 0; + ptr[2] = 0; + ptr[3] = 0; + ptr[4] = 0; + ptr[5] = 0; gScreen.bg0.updated = 1; } } @@ -511,9 +454,13 @@ void DrawChargeBar(void) { } if (!tmp1) - return sub_0801C824(); + return EraseChargeBar(); - ptr1 = (gHUD.maxHealth > 0x28) ? (u16*)((u8*)(&gUnk_02034D30) + 0x40) : (u16*)&gUnk_02034D30.unk_0; + if (gHUD.maxHealth > 10 * 4) { + ptr1 = &gBG0Buffer[0x60]; + } else { + ptr1 = &gBG0Buffer[0x40]; + } tmp2 = Div(gPlayerState.chargeState.chargeTimer + 19, 20); if (tmp2 > 40) { @@ -552,52 +499,50 @@ void DrawChargeBar(void) { } void DrawKeys(void) { - s32 iVar1; - substruct_0E2* ptr1; - substruct_0E2* ptr2; + u16* row1; + u16* row2; u32 temp; - if (!(((gHUD.hideFlags & HUD_HIDE_KEYS) == 0) && (AreaHasKeys()))) { + if (!(((gHUD.hideFlags & HUD_HIDE_KEYS) == 0)&& (AreaHasKeys()))) { if (gHUD.unk_10 != 0) { gHUD.unk_10 = 0; - ptr1 = &gUnk_020350E2.unk_0[0]; - ptr1->unk_0 = 0; - ptr1->unk_2 = 0; - ptr1->unk_4 = 0; - ptr1->unk_6 = 0; - gUnk_020350E2.unk_0[1].unk_0 = 0; - gUnk_020350E2.unk_0[1].unk_2 = 0; - gUnk_020350E2.unk_0[1].unk_4 = 0; - gUnk_020350E2.unk_0[1].unk_6 = 0; + row1 = &gBG0Buffer[0x219]; + row1[0] = 0; + row1[1] = 0; + row1[2] = 0; + row1[3] = 0; + row1[0x20] = 0; + row1[0x21] = 0; + row1[0x22] = 0; + row1[0x23] = 0; gScreen.bg0.updated = 1; } } else { if (gHUD.unk_10 == 0) { - ptr1 = &gUnk_020350E2.unk_0[0]; - ptr2 = &gUnk_020350E2.unk_0[1]; + row1 = &gBG0Buffer[0x219]; + row2 = &gBG0Buffer[0x239]; temp = 0xf01c; - ptr1->unk_0 = temp; - ptr1->unk_2 = temp + 1; - ptr2->unk_0 = temp + 2; - ptr2->unk_2 = temp + 3; + row1[0] = temp; + row1[1] = temp + 1; + row2[0] = temp + 2; + row2[1] = temp + 3; temp = 0xf076; - ptr1->unk_4 = temp; - ptr2->unk_4 = temp + 1; - ptr1->unk_6 = temp + 2; - ptr2->unk_6 = temp + 3; + row1[2] = temp; + row2[2] = temp + 1; + row1[3] = temp + 2; + row2[3] = temp + 3; gScreen.bg0.updated = 1; } if ((gHUD.dungeonKeys != gSave.dungeonKeys[gArea.dungeon_idx]) || (gHUD.unk_10 == 0)) { gHUD.unk_10 = 2; gHUD.dungeonKeys = gSave.dungeonKeys[gArea.dungeon_idx]; - DrawDigits(0x76, gHUD.dungeonKeys, 0, 2); + RenderDigits(0x76, gHUD.dungeonKeys, 0, 2); } } } void CreateUIElement(u32 type, u32 type2) { u32 index; - UIElement* new_var; UIElement* element; for (index = 0; index < MAX_UI_ELEMENTS; index++) { @@ -731,7 +676,6 @@ u32 sub_0801CC80(UIElement* element) { void ItemUIElement(UIElement* element) { u32 itemMaxNumber; u32 itemId; - u8* puVar3; UIElement* element2; u32 uVar5; u32 playerItemCount; @@ -799,33 +743,30 @@ void ItemUIElement(UIElement* element) { void TextUIElement(UIElement* element) { UIElement* buttonUIElement; - u32 tmp; - extern HUD* ptr; - u32 tmp1; - UIElement* ptr2; + u32 frameIndex; if (element->type2 == 9) { - tmp = gHUD.unk_2f; - if (tmp == 0) { + frameIndex = gHUD.rActionPlayerState; + if (frameIndex == R_ACTION_NONE) { switch (gArea.portal_mode) { case 2: - tmp = 0xb; + frameIndex = R_ACTION_SHRINK; break; case 3: - tmp = 0xa; + frameIndex = R_ACTION_GROW; break; default: - tmp = gHUD.unk_2c; + frameIndex = gHUD.rActionInteractObject; break; } } - gHUD.unk_32 = tmp; + gHUD.buttonText[2] = frameIndex; } - tmp = gHUD.unk_30[element->buttonElementId]; + frameIndex = gHUD.buttonText[element->buttonElementId]; element->unk_0_1 = 0; - if (tmp != 0) { - tmp += gUnk_080C9044[((SaveHeader*)0x2000000)->language]; - sub_0801CAFC(element, tmp); + if (frameIndex != 0) { + frameIndex += gUnk_080C9044[((SaveHeader*)0x2000000)->language]; + sub_0801CAFC(element, frameIndex); buttonUIElement = FindUIElement(element->buttonElementId); if (buttonUIElement != NULL) { element->x = buttonUIElement->x; |
