diff options
| author | mzxrules <mzxrules@gmail.com> | 2021-01-08 06:12:58 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-08 06:12:58 -0500 |
| commit | 3cef03f5ff9c0341544afec9636bd0581f87d0cc (patch) | |
| tree | 91ff5c72cadc5c647b52c285f9432f9f40e327dd /src/code/z_actor.c | |
| parent | 209f0d21b87fa01c033a943fd8c862cb46b31315 (diff) | |
z_bgcheck.c, 800430A0.c, 80043480.c (#256)
* beginning of migrating changes
* got matching
* changed order a bit
* clean up bgcheck
* fix conflict
* fix conflict again
* first stab at identifying types, some oks
* Clean up most bad structs/pointer math, move relevant structs to z64bgcheck.h, get some OKs
* more OKs, z_bgcheck.bss migration, update some sys_math3d.c args
* couple more OKs
* pushing some OKs
* fix compilation issues
* code_800430A0.c OK, more files decomp'd
* 8003A3E0 big OK :)
* Decomp most of func_8003C614, decomp helper funcs
* Decomp SurfaceType, CamData, and WaterBox property related functions
* more OKs, big OK in 8003C078
* more OKs, more progress, move a function definition in z_collision_check to functions.h
* more clean-ups, more OKs, dyn_vtx is now defined as u8*
* 8003A5B8, 8003A7D8, 8003C614, 8003DD6C OK, document function args better
* data migrated, more OKs
* 80041240 OK, func_8003B3C8 and func_8003BB18 disassembled
* func_80040284, 800409A8 non_matching, add IS_ZERO macro
* All asm files have C representations, some big OKs, lots of minor tweaks
* More OKs, non-matching code cleanup
* 8003FBF4 and 80040BE4 OK, improve codegen for most functions
* format z_bgcheck.c
* fix warnings, compile errors on NON_MATCHING
* func_8003EE80 is now NON_MATCHING
* begin documenting some functions
* formatting
* more documentation, func_8003A95C OK
* fix PHYSICAL_TO_VIRTUAL changes
* fix var rename
* More documentation, functions 80040E40, 80041648 OK, change types to not be compatible with ZAP
* func_8004239C ok, more NON_MATCHING improvements, more documentation
* Implement most suggested changes
* Convert comments to slower comments
* /**
* Implement ZAP2 changes
* my anti-virus ate my format.sh results
* Rename a couple hundred functions, fix minor stuff
* rename var so that clang formats correctly
* run format.sh
* implement Petrie's matches/suggestions
* format
* matches
* and the asm
* slight error
* Add SSList
* two more matches
* stuff
* implement code changes
* clean up Petrie's matchings
Co-authored-by: Arthur <arthurtilly413@gmail.com>
Co-authored-by: fig02 <fig02srl@gmail.com>
Co-authored-by: petrie911 <pmontag@DESKTOP-LG8A167.localdomain>
Diffstat (limited to 'src/code/z_actor.c')
| -rw-r--r-- | src/code/z_actor.c | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 973f903c2..c5d2f3d4a 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -821,7 +821,7 @@ void Actor_Init(Actor* actor, GlobalContext* globalCtx) { actor->uncullZoneScale = 350.0f; actor->uncullZoneDownward = 700.0f; func_80061E48(&actor->colChkInfo); - actor->floorPolySource = 0x32; + actor->floorPolySource = BGCHECK_SCENE; ActorShape_Init(&actor->shape, 0.0f, NULL, 0.0f); if (Object_IsLoaded(&globalCtx->objectCtx, actor->objBankIndex)) { Actor_SetObjectDependency(globalCtx, actor); @@ -1142,30 +1142,30 @@ s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) { return 1; } -UNK_TYPE D_8015BBA0; -u32 D_8015BBA4; +CollisionPoly* D_8015BBA0; +s32 D_8015BBA4; s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3) { f32 sp34; - s32 sp30; + s32 bgId; arg2->y += 50.0f; - actor->groundY = func_8003CA0C(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &sp30, actor, arg2); + actor->groundY = BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &bgId, actor, arg2); actor->bgCheckFlags &= ~0x0086; - if (actor->groundY <= -32000.0f) { - return func_8002E234(actor, -32000.0f, arg3); + if (actor->groundY <= BGCHECK_Y_MIN) { + return func_8002E234(actor, BGCHECK_Y_MIN, arg3); } sp34 = actor->groundY - actor->posRot.pos.y; - actor->floorPolySource = sp30; + actor->floorPolySource = bgId; if (sp34 >= 0.0f) { actor->bgCheckFlags |= 0x80; if (actor->bgCheckFlags & 0x10) { - if (sp30 != D_8015BBA4) { + if (bgId != D_8015BBA4) { if (sp34 > 15.0f) { actor->bgCheckFlags |= 0x100; } @@ -1204,29 +1204,29 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f f32 sp74; s32 pad; Vec3f sp64; - u32 sp60; + s32 bgId; CollisionPoly* sp5C; f32 sp58; - WaterBox* sp54; + WaterBox* waterBox; f32 sp50; Vec3f ripplePos; sp74 = actor->posRot.pos.y - actor->pos4.y; - if ((actor->floorPolySource != 0x32) && (actor->bgCheckFlags & 1)) { + if ((actor->floorPolySource != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) { func_800433A4(&globalCtx->colCtx, actor->floorPolySource, actor); } if (arg5 & 1) { - if ((!(arg5 & 0x80) && func_8003D52C(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, arg3, - &actor->wallPoly, &sp60, actor, arg2)) || - ((arg5 & 0x80) && func_8003D594(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, arg3, - &actor->wallPoly, &sp60, actor, arg2))) { + if ((!(arg5 & 0x80) && BgCheck_EntitySphVsWall3(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, + arg3, &actor->wallPoly, &bgId, actor, arg2)) || + ((arg5 & 0x80) && BgCheck_EntitySphVsWall4(&globalCtx->colCtx, &sp64, &actor->posRot.pos, &actor->pos4, + arg3, &actor->wallPoly, &bgId, actor, arg2))) { sp5C = actor->wallPoly; Math_Vec3f_Copy(&actor->posRot.pos, &sp64); - actor->wallPolyRot = Math_Atan2S(sp5C->norm.z, sp5C->norm.x); + actor->wallPolyRot = Math_Atan2S(sp5C->normal.z, sp5C->normal.x); actor->bgCheckFlags |= 8; - actor->wallPolySource = sp60; + actor->wallPolySource = bgId; } else { actor->bgCheckFlags &= ~8; } @@ -1237,7 +1237,8 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f if (arg5 & 2) { sp64.y = actor->pos4.y + 10.0f; - if (func_8003D7A0(&globalCtx->colCtx, &sp58, &sp64, (arg4 + sp74) - 10.0f, &D_8015BBA0, &D_8015BBA4, actor)) { + if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp58, &sp64, (arg4 + sp74) - 10.0f, &D_8015BBA0, + &D_8015BBA4, actor)) { actor->bgCheckFlags |= 0x10; actor->posRot.pos.y = (sp58 + sp74) - 10.0f; } else { @@ -1249,7 +1250,8 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f sp64.y = actor->pos4.y; func_8002E2AC(globalCtx, actor, &sp64, arg5); sp50 = actor->posRot.pos.y; - if (func_8004213C(globalCtx, &globalCtx->colCtx, actor->posRot.pos.x, actor->posRot.pos.z, &sp50, &sp54)) { + if (WaterBox_GetSurface1(globalCtx, &globalCtx->colCtx, actor->posRot.pos.x, actor->posRot.pos.z, &sp50, + &waterBox)) { actor->yDistToWater = sp50 - actor->posRot.pos.y; if (actor->yDistToWater < 0.0f) { actor->bgCheckFlags &= ~0x60; @@ -1269,7 +1271,7 @@ void func_8002E4B4(GlobalContext* globalCtx, Actor* actor, f32 arg2, f32 arg3, f } } else { actor->bgCheckFlags &= ~0x60; - actor->yDistToWater = -32000.0f; + actor->yDistToWater = BGCHECK_Y_MIN; } } } @@ -1674,7 +1676,7 @@ void func_8002F850(GlobalContext* globalCtx, Actor* actor) { sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; } } else { - sfxId = func_80041F34(&globalCtx->colCtx, actor->floorPoly, actor->floorPolySource); + sfxId = SurfaceType_GetSfx(&globalCtx->colCtx, actor->floorPoly, actor->floorPolySource); } func_80078914(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); @@ -1716,15 +1718,16 @@ void func_8002F994(Actor* actor, s32 arg1) { } } -s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* arg2, u32 arg3, Vec3f* arg4) { - if (func_80041D4C(&globalCtx->colCtx, arg2, arg3) == 8) { +// Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true +s32 func_8002F9EC(GlobalContext* globalCtx, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { + if (func_80041D4C(&globalCtx->colCtx, poly, bgId) == 8) { globalCtx->unk_11D30[0] = 1; - func_8005DFAC(globalCtx, 0, arg4); + func_8005DFAC(globalCtx, NULL, pos); Audio_PlayActorSound2(actor, NA_SE_IT_WALL_HIT_BUYO); - return 1; + return true; } - return 0; + return false; } // Local data used for Farore's Wind light (stored in BSS, possibly a struct?) @@ -2104,7 +2107,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { } if (i == ACTORTYPE_BG) { - func_8003F984(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_Setup(globalCtx, &globalCtx->colCtx.dyna); } } @@ -2125,7 +2128,7 @@ void Actor_UpdateAll(GlobalContext* globalCtx, ActorContext* actorCtx) { func_8002C7BC(&actorCtx->targetCtx, player, actor, globalCtx); TitleCard_Update(globalCtx, &actorCtx->titleCtx); - func_8003FB64(globalCtx, &globalCtx->colCtx.dyna); + DynaPoly_UpdateBgActorTransforms(globalCtx, &globalCtx->colCtx.dyna); } void Actor_FaultPrint(Actor* actor, char* command) { @@ -2927,9 +2930,9 @@ void func_800328D4(GlobalContext* globalCtx, ActorContext* actorCtx, Player* pla if (actor != sp84) { var = func_8002EFC0(actor, player, D_8015BBFC); if ((var < D_8015BBF0) && func_8002F090(actor, var) && func_80032880(globalCtx, actor) && - (!func_8003DD6C(&globalCtx->colCtx, &player->actor.posRot2.pos, &actor->posRot2.pos, &sp70, &sp80, - 1, 1, 1, 1, &sp7C) || - func_80042048(&globalCtx->colCtx, sp80, sp7C))) { + (!BgCheck_CameraLineTest1(&globalCtx->colCtx, &player->actor.posRot2.pos, &actor->posRot2.pos, + &sp70, &sp80, 1, 1, 1, 1, &sp7C) || + SurfaceType_IsIgnoredByProjectiles(&globalCtx->colCtx, sp80, sp7C))) { if (actor->unk_10D != 0) { if (actor->unk_10D < D_8015BBF8) { D_8015BBEC = actor; @@ -3433,7 +3436,7 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, GlobalContext* globalCtx) sp50.y = arg0->y + 1.0f; sp50.z = arg0->z; - var = func_8003C8EC(globalCtx, &globalCtx->colCtx, &sp4C, &sp50); + var = BgCheck_EntityRaycastFloor2(globalCtx, &globalCtx->colCtx, &sp4C, &sp50); if (sp4C != NULL) { func_80038A28(sp4C, arg0->x, var, arg0->z, &sp60); @@ -4113,9 +4116,9 @@ void func_800359B8(Actor* actor, s16 arg1, Vec3s* arg2) { if (actor->floorPoly != NULL) { floorPoly = actor->floorPoly; - sp44 = floorPoly->norm.x * (1.0f / 32767); - sp40 = floorPoly->norm.y * (1.0f / 32767); - sp3C = floorPoly->norm.z * (1.0f / 32767); + sp44 = COLPOLY_GET_NORMAL(floorPoly->normal.x); + sp40 = COLPOLY_GET_NORMAL(floorPoly->normal.y); + sp3C = COLPOLY_GET_NORMAL(floorPoly->normal.z); sp38 = Math_SinS(arg1); sp34 = Math_CosS(arg1); |
