diff options
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/code_800CB000.c | 3 | ||||
| -rw-r--r-- | src/code/z_actor.c | 4 | ||||
| -rw-r--r-- | src/code/z_bg_collect.c | 12 | ||||
| -rw-r--r-- | src/code/z_bg_item.c | 146 |
4 files changed, 102 insertions, 63 deletions
diff --git a/src/code/code_800CB000.c b/src/code/code_800CB000.c deleted file mode 100644 index 7642d35c4..000000000 --- a/src/code/code_800CB000.c +++ /dev/null @@ -1,3 +0,0 @@ -#include "global.h" - -#pragma GLOBAL_ASM("asm/non_matchings/code/code_800CB000/func_800CB000.s") diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 03a362fc6..42f67987a 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -509,8 +509,8 @@ f32 Actor_YDistance(Actor* actor1, Actor* actor2) { #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/func_800B72E0.s") void func_800B72F8(DynaPolyActor* dpactor, f32 a1, s16 a2) { - dpactor->unk150 = a2; - dpactor->unk148 += a1; + dpactor->yRotation = a2; + dpactor->pushForce += a1; } #pragma GLOBAL_ASM("asm/non_matchings/code/z_actor/Actor_IsLinkFacingActor.s") diff --git a/src/code/z_bg_collect.c b/src/code/z_bg_collect.c index 29c4cf7da..706c4b80a 100644 --- a/src/code/z_bg_collect.c +++ b/src/code/z_bg_collect.c @@ -61,13 +61,13 @@ void BgCheck2_AttachToMesh(CollisionContext* colCtx, Actor* actor, s32 index) { meshActor = BgCheck_GetActorOfMesh(colCtx, index); if (meshActor != NULL) { - func_800CAE88(meshActor); + DynaPolyActor_SetRidingFallingState(meshActor); if ((actor->flags & 0x4000000) == 0x4000000) { - func_800CAF24(meshActor); + DynaPolyActor_SetSwitchPressedState(meshActor); } if ((actor->flags & 0x20000) == 0x20000) { - func_800CAF38(meshActor); + DynaPolyActor_SetHeavySwitchPressedState(meshActor); } } } @@ -80,7 +80,7 @@ u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Acto return 0; } - if (((colCtx->dyna.bgActorFlags[index] & 2) != 0) || ((colCtx->dyna.bgActorFlags[index] & 1) == 0)) { + if (colCtx->dyna.bgActorFlags[index] & 2 || !(colCtx->dyna.bgActorFlags[index] & 1)) { return 0; } @@ -90,12 +90,12 @@ u32 BgCheck2_UpdateActorAttachedToMesh(CollisionContext* colCtx, s32 index, Acto return 0; } - if ((meshActor->unk154 & 1) != 0) { + if (meshActor->flags & 1) { BgCheck2_UpdateActorPosition(colCtx, index, actor); wasUpdated = 1; } - if ((meshActor->unk154 & 2) != 0) { + if (meshActor->flags & 2) { BgCheck2_UpdateActorYRotation(colCtx, index, actor); wasUpdated = 1; } diff --git a/src/code/z_bg_item.c b/src/code/z_bg_item.c index 77cc014b4..92a300e43 100644 --- a/src/code/z_bg_item.c +++ b/src/code/z_bg_item.c @@ -1,99 +1,141 @@ #include "global.h" -void BcCheck3_BgActorInit(DynaPolyActor* actor, UNK_TYPE4 param_2) { - actor->bgId = -1; - actor->unk148 = 0; - actor->unk14C = 0; - actor->unk154 = param_2; - actor->unk_158 = 0; +#define DYNAPOLY_STATE_NONE 0 +#define DYNAPOLY_STATE_RIDING_FALLING (1 << 0) +#define DYNAPOLY_STATE_RIDING_MOVING (1 << 1) +#define DYNAPOLY_STATE_RIDING_ROTATING (1 << 2) +#define DYNAPOLY_STATE_SWITCH_PRESSED (1 << 3) +#define DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED (1 << 4) + +void DynaPolyActor_Init(DynaPolyActor* dynaActor, s32 flags) { + dynaActor->bgId = -1; + dynaActor->pushForce = 0.0f; + dynaActor->unk14C = 0.0f; + dynaActor->flags = flags; + dynaActor->stateFlags = DYNAPOLY_STATE_NONE; } -void BgCheck3_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* actor, CollisionHeader* meshHeader) { - CollisionHeader* header; +void DynaPolyActor_LoadMesh(GlobalContext* globalCtx, DynaPolyActor* dynaActor, CollisionHeader* meshHeader) { + CollisionHeader* header = NULL; - header = NULL; BgCheck_RelocateMeshHeader(meshHeader, &header); - actor->bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, actor, header); + dynaActor->bgId = BgCheck_AddActorMesh(globalCtx, &globalCtx->colCtx.dyna, dynaActor, header); } -void BgCheck3_ResetFlags(DynaPolyActor* actor) { - actor->unk_158 = 0; +void DynaPolyActor_ResetState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags = DYNAPOLY_STATE_NONE; } -void func_800CAE88(DynaPolyActor* actor) { - actor->unk_158 |= 1; +void DynaPolyActor_SetRidingFallingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_FALLING; } -void func_800CAE9C(DynaPolyActor* actor) { - actor->unk_158 |= 2; +void DynaPolyActor_SetRidingMovingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_MOVING; } -void func_800CAEB0(CollisionContext* colCtx, s32 index) { - DynaPolyActor* actor; +void DynaPolyActor_SetRidingMovingStateByIndex(CollisionContext* colCtx, s32 index) { + DynaPolyActor* dynaActor = BgCheck_GetActorOfMesh(colCtx, index); - actor = BgCheck_GetActorOfMesh(colCtx, index); - if (actor != (DynaPolyActor*)0x0) { - func_800CAE9C(actor); + if (dynaActor != NULL) { + DynaPolyActor_SetRidingMovingState(dynaActor); } } -void func_800CAEE0(DynaPolyActor* actor) { - actor->unk_158 |= 4; +void DynaPolyActor_SetRidingRotatingState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_RIDING_ROTATING; } -void func_800CAEF4(CollisionContext* colCtx, s32 index) { - DynaPolyActor* actor; +void DynaPolyActor_SetRidingRotatingStateByIndex(CollisionContext* colCtx, s32 index) { + DynaPolyActor* dynaActor = BgCheck_GetActorOfMesh(colCtx, index); - actor = BgCheck_GetActorOfMesh(colCtx, index); - if (actor != (DynaPolyActor*)0x0) { - func_800CAEE0(actor); + if (dynaActor != NULL) { + DynaPolyActor_SetRidingRotatingState(dynaActor); } } -void func_800CAF24(DynaPolyActor* actor) { - actor->unk_158 |= 8; +void DynaPolyActor_SetSwitchPressedState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_SWITCH_PRESSED; } -void func_800CAF38(DynaPolyActor* actor) { - actor->unk_158 |= 0x10; +void DynaPolyActor_SetHeavySwitchPressedState(DynaPolyActor* dynaActor) { + dynaActor->stateFlags |= DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED; } -s32 func_800CAF4C(DynaPolyActor* actor) { - if (actor->unk_158 & 1) { - return 1; +s32 DynaPolyActor_IsInRidingFallingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_FALLING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAF70(DynaPolyActor* actor) { - if (actor->unk_158 & 2) { - return 1; +s32 DynaPolyActor_IsInRidingMovingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_MOVING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAF94(DynaPolyActor* actor) { - if (actor->unk_158 & 4) { - return 1; +s32 DynaPolyActor_IsInRidingRotatingState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_RIDING_ROTATING) { + return true; } else { - return 0; + return false; } } -s32 func_800CAFB8(DynaPolyActor* actor) { - if (actor->unk_158 & 8) { - return 1; +s32 DynaPolyActor_IsInSwitchPressedState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_SWITCH_PRESSED) { + return true; } else { - return 0; + return false; } } -s32 func_800CAFDC(DynaPolyActor* actor) { - if (actor->unk_158 & 0x10) { - return 1; +s32 DynaPolyActor_IsInHeavySwitchPressedState(DynaPolyActor* dynaActor) { + if (dynaActor->stateFlags & DYNAPOLY_STATE_HEAVY_SWITCH_PRESSED) { + return true; } else { - return 0; + return false; } } + +s32 DynaPolyActor_ValidateMove(GlobalContext* globalCtx, DynaPolyActor* dynaActor, s16 startRadius, s16 endRadius, + s16 startHeight) { + Vec3f startPos; + Vec3f endPos; + Vec3f intersectionPos; + f32 sin = Math_SinS(dynaActor->yRotation); + f32 cos = Math_CosS(dynaActor->yRotation); + s32 bgId; + CollisionPoly* poly; + f32 adjustedStartRadius; + f32 adjustedEndRadius; + f32 sign = (0.0f <= dynaActor->pushForce) ? 1.0f : -1.0f; + + adjustedStartRadius = (f32)startRadius - 0.1f; + startPos.x = dynaActor->actor.world.pos.x + (adjustedStartRadius * cos); + startPos.y = dynaActor->actor.world.pos.y + startHeight; + startPos.z = dynaActor->actor.world.pos.z - (adjustedStartRadius * sin); + + adjustedEndRadius = (f32)endRadius - 0.1f; + endPos.x = sign * adjustedEndRadius * sin + startPos.x; + endPos.y = startPos.y; + endPos.z = sign * adjustedEndRadius * cos + startPos.z; + + if (func_800C56E0(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true, &bgId, + &dynaActor->actor, 0.0f)) { + return false; + } + startPos.x = (dynaActor->actor.world.pos.x * 2.0f) - startPos.x; + startPos.z = (dynaActor->actor.world.pos.z * 2.0f) - startPos.z; + endPos.x = sign * adjustedEndRadius * sin + startPos.x; + endPos.z = sign * adjustedEndRadius * cos + startPos.z; + if (func_800C56E0(&globalCtx->colCtx, &startPos, &endPos, &intersectionPos, &poly, true, false, false, true, &bgId, + &dynaActor->actor, 0.0f)) { + return false; + } + return true; +} |
