diff --git a/spec b/spec index 750790ae40..a10aa74eb1 100644 --- a/spec +++ b/spec @@ -2642,8 +2642,7 @@ beginseg name "ovl_Obj_Skateblock" compress include "build/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.data.o" - include "build/data/ovl_Obj_Skateblock/ovl_Obj_Skateblock.reloc.o" + include "build/src/overlays/actors/ovl_Obj_Skateblock/ovl_Obj_Skateblock_reloc.o" endseg beginseg diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c index 8219bc581d..a953cd304f 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.c @@ -5,6 +5,7 @@ */ #include "z_obj_skateblock.h" +#include "objects/gameplay_dangeon_keep/gameplay_dangeon_keep.h" #define FLAGS (ACTOR_FLAG_10) @@ -15,7 +16,17 @@ void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx); void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx); -#if 0 +void func_80A22308(ObjSkateblock* this); +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A2244C(ObjSkateblock* this); +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22628(ObjSkateblock* this); +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A22728(ObjSkateblock* this); +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx); +void func_80A227A4(ObjSkateblock* this); +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx); + const ActorInit Obj_Skateblock_InitVars = { ACTOR_OBJ_SKATEBLOCK, ACTORCAT_BG, @@ -28,76 +39,658 @@ const ActorInit Obj_Skateblock_InitVars = { (ActorFunc)ObjSkateblock_Draw, }; -// static InitChainEntry sInitChain[] = { -static InitChainEntry D_80A22AE0[] = { - ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), - ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), - ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), - ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +s32 D_80A22A10 = 0; + +s32 D_80A22A14 = 0; + +AnimatedMaterial* D_80A22A18 = NULL; + +Vec2f D_80A22A1C[] = { + { -300.0f, 300.0f }, { 300.0f, 300.0f }, { -300.0f, -300.0f }, { 300.0f, -300.0f }, { 0.0f, 0.0f }, }; -#endif +Vec2f D_80A22A44[] = { + { 0.5f, -0.5f }, { -0.5f, -0.5f }, { 0.5f, 0.5f }, { -0.5f, 0.5f }, { 0.0f, 0.0f }, +}; -extern InitChainEntry D_80A22AE0[]; +Vec2f D_80A22A6C[] = { + { -300.0f, 0.0f }, { 300.0f, 0.0f }, { -300.0f, 600.0f }, { 300.0f, 600.0f }, { 0.0f, 300.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21150.s") +Vec2f D_80A22A94[] = { + { 1.0f, 1.0f }, { -1.0f, 1.0f }, { 1.0f, -1.0f }, { -1.0f, -1.0f }, { 0.0f, 0.0f }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A211F4.s") +f32 D_80A22ABC[] = { -300.0f, 300.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A212F0.s") +f32 D_80A22AC4[] = { 1.0f, -1.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21370.s") +Vec3f D_80A22ACC = { 0.0f, 0.3f, 0.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21548.s") +Color_RGBA8 D_80A22AD8 = { 250, 250, 250, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A216D4.s") +Color_RGBA8 D_80A22ADC = { 180, 180, 180, 255 }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21934.s") +static InitChainEntry sInitChain[] = { + ICHAIN_F32_DIV1000(gravity, -1700, ICHAIN_CONTINUE), ICHAIN_F32_DIV1000(terminalVelocity, -20000, ICHAIN_CONTINUE), + ICHAIN_VEC3F_DIV1000(scale, 100, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneForward, 4000, ICHAIN_CONTINUE), + ICHAIN_F32(uncullZoneScale, 150, ICHAIN_CONTINUE), ICHAIN_F32(uncullZoneDownward, 200, ICHAIN_STOP), +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21990.s") +f32 D_80A22AF8[] = { 14.0f, -14.0f, 14.0f, -14.0f }; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C30.s") +Color_RGB8 D_80A22B08[] = { + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, + { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, { 255, 255, 255 }, +}; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21C88.s") +s32 func_80A21150(ObjSkateblock* this) { + s32 temp_v0; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CB4.s") + if (fabsf(this->dyna.pushForce) > 0.1f) { + if (this->dyna.pushForce > 0.0f) { + temp_v0 = BINANG_ADD(this->dyna.yRotation, 0x2000); + } else { + temp_v0 = BINANG_SUB(this->dyna.yRotation, 0x6000); + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21CD8.s") + if (temp_v0 < -0x4000) { + return 3; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21D1C.s") + if (temp_v0 < 0) { + return 1; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21E9C.s") + if (temp_v0 < 0x4000) { + return 2; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F68.s") + return 0; + } + return -1; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A21F74.s") +void func_80A211F4(ObjSkateblock* this, s32 arg1) { + s32 i; + s32 phi_v0 = false; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Init.s") + if (this->dyna.pushForce > 0.0f) { + phi_v0 = true; + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Destroy.s") + for (i = 0; i < ARRAY_COUNT(this->unk_172); i++) { + if ((arg1 == i) && phi_v0) { + this->unk_172[i]++; + } else if (this->unk_172[i] > 0) { + this->unk_172[i]--; + } + } +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22308.s") +void func_80A212F0(Vec3f* arg0, Vec3f* arg1, s16 arg2) { + f32 sp1C = Math_SinS(arg2); + f32 temp_f0 = Math_CosS(arg2); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22334.s") + arg0->x = (arg1->z * sp1C) + (arg1->x * temp_f0); + arg0->y = arg1->y; + arg0->z = (arg1->z * temp_f0) - (arg1->x * sp1C); +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2244C.s") +s32 func_80A21370(ObjSkateblock* this, GlobalContext* globalCtx) { + ObjSkateblockFloor* floor; + s32 i; + s32 pad; + s32 sp98; + Vec3f sp8C; + s32 sp88; + f32 phi_f20 = BGCHECK_Y_MIN; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A224A4.s") + sp88 = false; + sp8C.y = this->dyna.actor.world.pos.y + 40.0f; + sp98 = -1; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22628.s") + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2264C.s") + floor->poly = NULL; + floor->height = BGCHECK_Y_MIN; + floor->bgId = BG_ACTOR_MAX; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A22728.s") + sp8C.x = this->dyna.actor.world.pos.x + ((D_80A22A1C[i].x * this->dyna.actor.scale.x) + D_80A22A44[i].x); + sp8C.z = this->dyna.actor.world.pos.z + ((D_80A22A1C[i].y * this->dyna.actor.scale.z) + D_80A22A44[i].y); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A2273C.s") + floor->height = + BgCheck_EntityRaycastFloor6(&globalCtx->colCtx, &floor->poly, &floor->bgId, &this->dyna.actor, &sp8C, 0.0f); -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227A4.s") + if (floor->height > BGCHECK_Y_MIN + 1.0f) { + sp88 = true; + if (phi_f20 < floor->height) { + phi_f20 = floor->height; + sp98 = i; + } + } + } -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/func_80A227C0.s") + if (sp98 >= 0) { + this->dyna.actor.floorPoly = this->unk_184[sp98].poly; + this->dyna.actor.floorHeight = this->unk_184[sp98].height; + this->dyna.actor.floorBgId = this->unk_184[sp98].bgId; + } + return sp88; +} -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Update.s") +s32 func_80A21548(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 i; + ObjSkateblockFloor* floor; -#pragma GLOBAL_ASM("asm/non_matchings/overlays/ovl_Obj_Skateblock/ObjSkateblock_Draw.s") + this->unk_1C1 &= ~4; + + if (func_80A21370(this, globalCtx)) { + f32 maxHeight = BGCHECK_Y_MIN; + s32 phi_v1 = false; + f32 temp_f12 = this->dyna.actor.world.pos.y - 10.0f; + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + floor = &this->unk_184[i]; + if ((temp_f12 < floor->height) && (floor->height > maxHeight)) { + maxHeight = floor->height; + phi_v1 = true; + } + } + + if (phi_v1) { + this->dyna.actor.world.pos.y = maxHeight; + this->unk_1C1 |= 4; + this->dyna.actor.velocity.y = 0.0f; + } + return phi_v1; + } + return false; +} + +s32 func_80A216D4(ObjSkateblock* this, GlobalContext* globalCtx, f32 arg2, Vec3f* arg3) { + s32 pad; + f32 spE8; + f32 spE4; + s32 i; + Vec3f spD4; + Vec3f spC8; + Vec3f spBC; + Vec3f spB0; + f32 temp_f20; + f32 temp_f24; + s32 spA4; + CollisionPoly* spA0; + s32 ret; + f32 temp_f26; + s16 sp96 = this->dyna.yRotation; + f32 temp_f2; + + if (this->dyna.pushForce < 0.0f) { + sp96 -= 0x8000; + } + spE8 = Math_SinS(sp96); + spE4 = Math_CosS(sp96); + + temp_f2 = Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos) + + (300.0f * this->dyna.actor.scale.z) + arg2; + temp_f24 = temp_f2 * spE8; + temp_f26 = temp_f2 * spE4; + + ret = false; + temp_f20 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22A6C); i++) { + spBC.x = (D_80A22A6C[i].x * this->dyna.actor.scale.x) + D_80A22A94[i].x; + spBC.y = (D_80A22A6C[i].y * this->dyna.actor.scale.y) + D_80A22A94[i].y; + spBC.z = 0.0f; + + func_80A212F0(&spD4, &spBC, sp96); + + spD4.x += this->dyna.actor.prevPos.x; + spD4.y += this->dyna.actor.prevPos.y; + spD4.z += this->dyna.actor.prevPos.z; + + spC8.x = temp_f24 + spD4.x; + spC8.y = spD4.y; + spC8.z = temp_f26 + spD4.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spD4, &spC8, &spB0, &spA0, true, false, false, true, &spA4, + &this->dyna.actor, 0.0f)) { + temp_f2 = Math3D_Vec3fDistSq(&spD4, &spB0); + if (temp_f2 < temp_f20) { + temp_f20 = temp_f2; + ret = true; + Math_Vec3f_Diff(&spB0, &spC8, arg3); + } + } + } + return ret; +} + +s32 func_80A21934(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A216D4(this, globalCtx, 0.0f, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + return false; +} + +s32 func_80A21990(ObjSkateblock* this, GlobalContext* globalCtx, Vec3f* arg2) { + s32 i; + f32 sp100; + s16 phi_s6 = this->dyna.yRotation; + f32 phi_f22; + Vec3f spEC; + Vec3f spE0; + Vec3f spD4; + Vec3f spC8; + f32 temp_f0; + f32 temp_f12; + s32 spBC; + CollisionPoly* spB8; + s32 ret; + f32 temp_f26; + f32 temp_f28; + f32 temp_f30; + + if (this->dyna.pushForce < 0.0f) { + phi_s6 -= 0x8000; + } + + sp100 = Math_SinS(phi_s6); + temp_f26 = Math_CosS(phi_s6); + + temp_f12 = + (300.0f * this->dyna.actor.scale.z + Math3D_Distance(&this->dyna.actor.world.pos, &this->dyna.actor.prevPos)) + + 2.0f; + temp_f28 = -temp_f12 * sp100; + temp_f30 = -temp_f12 * temp_f26; + + ret = false; + phi_f22 = FLT_MAX; + + for (i = 0; i < ARRAY_COUNT(D_80A22ABC); i++) { + spD4.x = (D_80A22ABC[i] * this->dyna.actor.scale.x) + D_80A22AC4[i]; + spD4.y = -10.0f; + spD4.z = 0.0f; + + func_80A212F0(&spEC, &spD4, phi_s6); + + spEC.x += this->dyna.actor.world.pos.x; + spEC.y += this->dyna.actor.world.pos.y; + spEC.z += this->dyna.actor.world.pos.z; + + spE0.x = temp_f28 + spEC.x; + spE0.y = spEC.y; + spE0.z = temp_f30 + spEC.z; + + if (BgCheck_EntityLineTest3(&globalCtx->colCtx, &spEC, &spE0, &spC8, &spB8, true, false, false, true, &spBC, + &this->dyna.actor, 0.0f)) { + temp_f0 = Math3D_Vec3fDistSq(&spEC, &spC8); + if (temp_f0 < phi_f22) { + ret = true; + arg2->x = (spC8.x - spEC.x) + (300.0f * this->dyna.actor.scale.z * sp100); + arg2->y = 0.0f; + arg2->z = (spC8.z - spEC.z) + (300.0f * this->dyna.actor.scale.z * temp_f26); + phi_f22 = temp_f0; + } + } + } + return ret; +} + +s32 func_80A21C30(ObjSkateblock* this, GlobalContext* globalCtx) { + Vec3f sp1C; + + if (func_80A21990(this, globalCtx, &sp1C)) { + this->dyna.actor.world.pos.x += sp1C.x; + this->dyna.actor.world.pos.z += sp1C.z; + return true; + } + + return false; +} + +void func_80A21C88(ObjSkateblock* this, s32 arg1) { + if ((arg1 == 0) || (arg1 == 1)) { + this->unk_16C = &this->dyna.actor.world.pos.x; + } else { + this->unk_16C = &this->dyna.actor.world.pos.z; + } + this->unk_170 = arg1; +} + +void func_80A21CB4(ObjSkateblock* this, GlobalContext* globalCtx) { + Player* player = GET_PLAYER(globalCtx); + + player->stateFlags2 &= ~0x10; + this->dyna.pushForce = 0.0f; +} + +void func_80A21CD8(ObjSkateblock* this) { + this->dyna.actor.velocity.y += this->dyna.actor.gravity; + if (this->dyna.actor.velocity.y < this->dyna.actor.terminalVelocity) { + this->dyna.actor.velocity.y = this->dyna.actor.terminalVelocity; + } + this->dyna.actor.world.pos.y += this->dyna.actor.velocity.y; +} + +void func_80A21D1C(ObjSkateblock* this) { + f32 sp4; + f32 temp_f14; + f32 temp_f16; + f32 temp_f6; + f32 phi_f2; + + temp_f14 = this->dyna.actor.world.pos.x - this->dyna.actor.home.pos.x; + phi_f2 = ((temp_f14 >= 0.0f) ? 0.5f : -0.5f); + sp4 = ((s32)(phi_f2 + temp_f14) / 30) * 30; + temp_f14 -= sp4; + + if (fabsf(temp_f14) < 3.0f) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x + sp4; + } + + temp_f16 = this->dyna.actor.world.pos.z - this->dyna.actor.home.pos.z; + phi_f2 = ((temp_f16 >= 0.0f) ? 0.5f : -0.5f); + temp_f6 = ((s32)(phi_f2 + temp_f16) / 30) * 30; + temp_f16 -= temp_f6; + + if (fabsf(temp_f16) < 3.0f) { + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z + temp_f6; + } +} + +void func_80A21E9C(ObjSkateblock* this, GlobalContext* globalCtx) { + DynaPolyActor* temp_v0; + s32 i; + ObjSkateblockFloor* ptr; + + if (!(this->unk_1C1 & 4)) { + return; + } + + for (i = 0; i < ARRAY_COUNT(this->unk_184); i++) { + ptr = &this->unk_184[i]; + + temp_v0 = DynaPoly_GetActor(&globalCtx->colCtx, ptr->bgId); + if ((temp_v0 != NULL) && (temp_v0->actor.id == ACTOR_OBJ_SKATEBLOCK)) { + ObjSkateblock* skateBlock = (ObjSkateblock*)temp_v0; + f32 height = this->dyna.actor.world.pos.y - ptr->height; + + if (fabsf(height) < 0.1f) { + skateBlock->unk_1C1 |= 2; + } + } + } +} + +void func_80A21F68(ObjSkateblock* this) { + this->unk_17C = 0; +} + +void func_80A21F74(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + Vec3f spA8; + Vec3f sp9C; + f32 phi_f22; + s32 i; + f32 temp; + s32 pad2; + s16 sp8A = this->dyna.yRotation; + + if (this->dyna.pushForce < 0.0f) { + sp8A -= 0x8000; + } + + this->unk_17C++; + + if (this->dyna.actor.flags & ACTOR_FLAG_40) { + if (this->unk_17C >= 46) { + phi_f22 = 1.0f; + } else { + phi_f22 = (this->unk_17C * 0.017777778f) + 0.2f; + } + sp9C.y = 12.0f; + + for (i = 0; i < 2; i++) { + if (phi_f22 < (Rand_ZeroOne() * 1.2f)) { + continue; + } + this->unk_180 += Rand_ZeroOne(); + + if (this->unk_180 > 1.0f) { + this->unk_180 -= 1.0f; + } + + sp9C.x = (this->unk_180 - 0.5f) * 600.0f * this->dyna.actor.scale.x; + sp9C.z = (this->dyna.actor.scale.z * -300.0f) + 4.0f; + + func_80A212F0(&spA8, &sp9C, sp8A); + + spA8.x += this->dyna.actor.world.pos.x; + spA8.y += this->dyna.actor.world.pos.y; + spA8.z += this->dyna.actor.world.pos.z; + + temp = ((Rand_ZeroOne() * 800.0f) + (1600.0f * this->dyna.actor.scale.x)) * phi_f22; + func_800B0E48(globalCtx, &spA8, &gZeroVec3f, &D_80A22ACC, &D_80A22AD8, &D_80A22ADC, temp, + (Rand_ZeroOne() * 20.0f) + 30.0f); + } + } +} + +void ObjSkateblock_Init(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + Actor_ProcessInitChain(&this->dyna.actor, sInitChain); + DynaPolyActor_Init(&this->dyna, 1); + DynaPolyActor_LoadMesh(globalCtx, &this->dyna, &gameplay_dangeon_keep_Colheader_007498); + if (D_80A22A18 == NULL) { + D_80A22A18 = Lib_SegmentedToVirtual(gameplay_dangeon_keep_Matanimheader_01B370); + } + func_80A22308(this); + this->unk_1C0 = D_80A22A14; + D_80A22A14++; + D_80A22A14 &= 0x1F; +} + +void ObjSkateblock_Destroy(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + DynaPoly_DeleteBgActor(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); +} + +void func_80A22308(ObjSkateblock* this) { + this->actionFunc = func_80A22334; + this->unk_172[1] = 0; + this->unk_172[2] = 0; + this->unk_172[3] = 0; + this->unk_172[0] = 0; + this->dyna.actor.velocity.y = 0.0f; +} + +void func_80A22334(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp30; + s32 sp2C; + Vec3f sp20; + + func_80A21CD8(this); + func_80A21548(this, globalCtx); + sp2C = func_80A21150(this); + func_80A211F4(this, sp2C); + + sp30 = true; + + if (sp2C == -1) { + sp30 = false; + } else if (!(this->unk_1C1 & 2) && (this->unk_172[sp2C] > 10) && (D_80A22A10 == 0) && + !func_80A216D4(this, globalCtx, 2.0f, &sp20) && !Player_InCsMode(&globalCtx->state)) { + func_80A21C88(this, sp2C); + func_80A2244C(this); + sp30 = false; + func_800B7298(globalCtx, &this->dyna.actor, 7); + this->unk_1C1 |= 1; + } + + if (sp30) { + func_80A21CB4(this, globalCtx); + } +} + +void func_80A2244C(ObjSkateblock* this) { + this->actionFunc = func_80A224A4; + this->unk_168 = D_80A22AF8[this->unk_170]; + this->unk_164 = 0.0f; + this->unk_17A = 15; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; + func_80A21F68(this); +} + +void func_80A224A4(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp28 = false; + s32 sp24 = false; + + Math_StepToF(&this->unk_164, this->unk_168, 0.75f); + + *this->unk_16C += this->unk_164; + + if (func_80A21934(this, globalCtx)) { + Actor_PlaySfxAtPos(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); + func_80A21D1C(this); + sp28 = true; + } else { + func_800B9010(&this->dyna.actor, NA_SE_PL_SLIP_ICE_LEVEL - SFX_FLAG); + } + + func_80A21CD8(this); + + if (!func_80A21548(this, globalCtx)) { + func_80A21C30(this, globalCtx); + func_80A21D1C(this); + func_80A22628(this); + sp24 = true; + } else if (sp28) { + func_80A22308(this); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + } + + if (sp24 || sp28 || (this->unk_17A == 1)) { + func_80A21CB4(this, globalCtx); + } + + if ((this->unk_1C1 & 1) && (sp24 || sp28 || (this->dyna.actor.xzDistToPlayer > 400.0f))) { + this->unk_1C1 &= ~1; + func_800B7298(globalCtx, &this->dyna.actor, 6); + } + + func_80A21F74(this, globalCtx); +} + +void func_80A22628(ObjSkateblock* this) { + this->actionFunc = func_80A2264C; + this->unk_160 = this->dyna.actor.world.pos.y; + this->dyna.actor.velocity.y = this->dyna.actor.gravity; +} + +void func_80A2264C(ObjSkateblock* this, GlobalContext* globalCtx) { + s32 pad; + s32 sp20; + + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + func_80A21CD8(this); + + sp20 = func_80A21548(this, globalCtx); + if (sp20 || ((this->unk_160 - this->dyna.actor.world.pos.y) > 300.0f)) { + if (func_800C9B40(&globalCtx->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) == 12) { + func_800C62BC(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = NULL; + func_80A22728(this); + return; + } + } + + if (sp20) { + func_80A22308(this); + } +} + +void func_80A22728(ObjSkateblock* this) { + this->actionFunc = func_80A2273C; +} + +void func_80A2273C(ObjSkateblock* this, GlobalContext* globalCtx) { + if (!DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + this->dyna.actor.world.pos.x = this->dyna.actor.home.pos.x; + this->dyna.actor.world.pos.y = (this->dyna.actor.home.pos.y - (600.0f * this->dyna.actor.scale.y)) - 10.0f; + this->dyna.actor.world.pos.z = this->dyna.actor.home.pos.z; + + func_80A227A4(this); + } +} + +void func_80A227A4(ObjSkateblock* this) { + this->actionFunc = func_80A227C0; + this->unk_17A = 40; +} + +void func_80A227C0(ObjSkateblock* this, GlobalContext* globalCtx) { + if (func_80A21150(this) != -1) { + func_80A21CB4(this, globalCtx); + } + + if (this->unk_17A > 0) { + this->unk_17A--; + return; + } + + func_800C6314(globalCtx, &globalCtx->colCtx.dyna, this->dyna.bgId); + this->dyna.actor.draw = ObjSkateblock_Draw; + + if (Math_StepToF(&this->dyna.actor.world.pos.y, this->dyna.actor.home.pos.y, 1.0f)) { + func_80A22308(this); + } + + if (DynaPolyActor_IsInRidingMovingState(&this->dyna)) { + D_80A22A10 |= 1 << this->unk_1C0; + } +} + +void ObjSkateblock_Update(Actor* thisx, GlobalContext* globalCtx) { + ObjSkateblock* this = THIS; + + D_80A22A10 &= ~(1 << this->unk_1C0); + this->actionFunc(this, globalCtx); + this->unk_1C1 &= ~2; +} + +void ObjSkateblock_Draw(Actor* thisx, GlobalContext* globalCtx) { + s32 pad; + ObjSkateblock* this = THIS; + Color_RGB8* sp2C = &D_80A22B08[OBJSKAEBLOCK_GET_F(&this->dyna.actor)]; + + OPEN_DISPS(globalCtx->state.gfxCtx); + + func_8012C28C(globalCtx->state.gfxCtx); + AnimatedMat_DrawStep(globalCtx, D_80A22A18, 0); + + gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + gDPSetPrimColor(POLY_OPA_DISP++, 0xFF, 0xFF, sp2C->r, sp2C->g, sp2C->b, 255); + gSPDisplayList(POLY_OPA_DISP++, gameplay_dangeon_keep_DL_0182A8); + + func_80A21E9C(this, globalCtx); + + CLOSE_DISPS(globalCtx->state.gfxCtx); +} diff --git a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h index 00f3a0f1b1..c26a93844b 100644 --- a/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h +++ b/src/overlays/actors/ovl_Obj_Skateblock/z_obj_skateblock.h @@ -7,11 +7,29 @@ struct ObjSkateblock; typedef void (*ObjSkateblockActionFunc)(struct ObjSkateblock*, GlobalContext*); +#define OBJSKAEBLOCK_GET_F(thisx) ((thisx)->params & 0xF) + +typedef struct { + /* 0x00 */ CollisionPoly* poly; + /* 0x04 */ f32 height; + /* 0x08 */ s32 bgId; +} ObjSkateblockFloor; // size = 0xC + typedef struct ObjSkateblock { - /* 0x0000 */ Actor actor; - /* 0x0144 */ char unk_144[0x18]; + /* 0x0000 */ DynaPolyActor dyna; /* 0x015C */ ObjSkateblockActionFunc actionFunc; - /* 0x0160 */ char unk_160[0x64]; + /* 0x0160 */ f32 unk_160; + /* 0x0164 */ f32 unk_164; + /* 0x0168 */ f32 unk_168; + /* 0x016C */ f32* unk_16C; + /* 0x0170 */ s16 unk_170; + /* 0x0172 */ s16 unk_172[4]; + /* 0x017A */ s16 unk_17A; + /* 0x017C */ s16 unk_17C; + /* 0x0180 */ f32 unk_180; + /* 0x0184 */ ObjSkateblockFloor unk_184[5]; + /* 0x01C0 */ u8 unk_1C0; + /* 0x01C1 */ u8 unk_1C1; } ObjSkateblock; // size = 0x1C4 extern const ActorInit Obj_Skateblock_InitVars;