diff --git a/include/functions.h b/include/functions.h index e7c5bb585b..d0d3e8e3a7 100644 --- a/include/functions.h +++ b/include/functions.h @@ -634,28 +634,28 @@ u16 BgCheck_GetBgCamSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 b u16 BgCheck_GetBgCamCount(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); Vec3s* BgCheck_GetBgCamFuncDataImpl(CollisionContext* colCtx, s32 bgCamIndex, s32 bgId); Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetFloorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041DB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041DE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041E18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041EA4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041EC8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_GetWallFlags(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag1(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +s32 SurfaceType_CheckWallFlag2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetFloorProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_IsSoft(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 func_80041F10(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetSfxType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u16 SurfaceType_GetSfxId(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_GetLightSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 SurfaceType_CanHookshot(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByEntities(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsIgnoredByProjectiles(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); -u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); +u32 func_80042108(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId); s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, WaterBox** outWaterBox); s32 WaterBox_GetSurface2(PlayState* play, CollisionContext* colCtx, Vec3f* pos, f32 surfaceChkDist, diff --git a/include/z64bgcheck.h b/include/z64bgcheck.h index 892ab925d9..2b9169f094 100644 --- a/include/z64bgcheck.h +++ b/include/z64bgcheck.h @@ -87,11 +87,94 @@ typedef struct { // 0x0000_00FF = BgCam Index } WaterBox; // size = 0x10 +typedef enum { + /* 0 */ FLOOR_TYPE_0, + /* 1 */ FLOOR_TYPE_1, + /* 2 */ FLOOR_TYPE_2, + /* 3 */ FLOOR_TYPE_3, + /* 4 */ FLOOR_TYPE_4, + /* 5 */ FLOOR_TYPE_5, + /* 6 */ FLOOR_TYPE_6, + /* 7 */ FLOOR_TYPE_7, + /* 8 */ FLOOR_TYPE_8, + /* 9 */ FLOOR_TYPE_9, + /* 10 */ FLOOR_TYPE_10, + /* 11 */ FLOOR_TYPE_11, + /* 12 */ FLOOR_TYPE_12 +} FloorType; + +typedef enum { + /* 0 */ WALL_TYPE_0, + /* 1 */ WALL_TYPE_1, + /* 2 */ WALL_TYPE_2, + /* 3 */ WALL_TYPE_3, + /* 4 */ WALL_TYPE_4, + /* 5 */ WALL_TYPE_5, + /* 6 */ WALL_TYPE_6, + /* 7 */ WALL_TYPE_7, + /* 8 */ WALL_TYPE_8, + /* 9 */ WALL_TYPE_9, + /* 10 */ WALL_TYPE_10, + /* 11 */ WALL_TYPE_11, + /* 12 */ WALL_TYPE_12, + /* 32 */ WALL_TYPE_MAX = 32 +} WallType; + +#define WALL_FLAG_0 (1 << 0) +#define WALL_FLAG_1 (1 << 1) +#define WALL_FLAG_2 (1 << 2) +#define WALL_FLAG_3 (1 << 3) +#define WALL_FLAG_4 (1 << 4) +#define WALL_FLAG_5 (1 << 5) +#define WALL_FLAG_6 (1 << 6) + +typedef enum { + /* 0 */ FLOOR_PROPERTY_0, + /* 5 */ FLOOR_PROPERTY_5 = 5, + /* 6 */ FLOOR_PROPERTY_6, + /* 7 */ FLOOR_PROPERTY_7, + /* 8 */ FLOOR_PROPERTY_8, + /* 9 */ FLOOR_PROPERTY_9, + /* 11 */ FLOOR_PROPERTY_11 = 11, + /* 12 */ FLOOR_PROPERTY_12 +} FloorProperty; + +typedef enum { + /* 0 */ SURFACE_SFX_TYPE_0, + /* 1 */ SURFACE_SFX_TYPE_1, + /* 2 */ SURFACE_SFX_TYPE_2, + /* 3 */ SURFACE_SFX_TYPE_3, + /* 4 */ SURFACE_SFX_TYPE_4, + /* 5 */ SURFACE_SFX_TYPE_5, + /* 6 */ SURFACE_SFX_TYPE_6, + /* 7 */ SURFACE_SFX_TYPE_7, + /* 8 */ SURFACE_SFX_TYPE_8, + /* 9 */ SURFACE_SFX_TYPE_9, + /* 10 */ SURFACE_SFX_TYPE_10, + /* 11 */ SURFACE_SFX_TYPE_11, + /* 12 */ SURFACE_SFX_TYPE_12, + /* 13 */ SURFACE_SFX_TYPE_13, + /* 14 */ SURFACE_SFX_TYPE_MAX +} SurfaceSfxType; + +typedef enum { + /* 0 */ FLOOR_EFFECT_0, + /* 1 */ FLOOR_EFFECT_1, + /* 2 */ FLOOR_EFFECT_2 +} FloorEffect; + +typedef enum { + /* 0 */ CONVEYOR_SPEED_DISABLED, + /* 1 */ CONVEYOR_SPEED_SLOW, + /* 2 */ CONVEYOR_SPEED_MEDIUM, + /* 3 */ CONVEYOR_SPEED_FAST, + /* 4 */ CONVEYOR_SPEED_MAX +} ConveyorSpeed; + +#define CONVEYOR_DIRECTION_TO_BINANG(conveyorDirection) ((conveyorDirection) * (0x10000 / 64)) + typedef struct { u32 data[2]; - - // Type 1 - // 0x0800_0000 = wall damage } SurfaceType; typedef struct { diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 091f6fc022..75409861f5 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -1705,7 +1705,7 @@ void func_8002F850(PlayState* play, Actor* actor) { sfxId = NA_SE_PL_WALK_WATER1 - SFX_FLAG; } } else { - sfxId = SurfaceType_GetSfx(&play->colCtx, actor->floorPoly, actor->floorBgId); + sfxId = SurfaceType_GetSfxId(&play->colCtx, actor->floorPoly, actor->floorBgId); } func_80078914(&actor->projectedPos, NA_SE_EV_BOMB_BOUND); @@ -1749,7 +1749,7 @@ void func_8002F994(Actor* actor, s32 arg1) { // Tests if something hit Jabu Jabu surface, displaying hit splash and playing sfx if true s32 func_8002F9EC(PlayState* play, Actor* actor, CollisionPoly* poly, s32 bgId, Vec3f* pos) { - if (func_80041D4C(&play->colCtx, poly, bgId) == 8) { + if (SurfaceType_GetFloorType(&play->colCtx, poly, bgId) == FLOOR_TYPE_8) { play->roomCtx.unk_74[0] = 1; CollisionCheck_BlueBlood(play, NULL, pos); Audio_PlayActorSfx2(actor, NA_SE_IT_WALL_HIT_BUYO); diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 55ee74b8aa..ff11a33ac2 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -24,18 +24,32 @@ #define COLPOLY_IGNORE_ENTITY (1 << 1) #define COLPOLY_IGNORE_PROJECTILES (1 << 2) -// func_80041DB8, SurfaceType wall properties -s32 D_80119D90[32] = { - 0, 1, 3, 5, 8, 16, 32, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +s32 D_80119D90[WALL_TYPE_MAX] = { + 0, // WALL_TYPE_0 + WALL_FLAG_0, // WALL_TYPE_1 + WALL_FLAG_0 | WALL_FLAG_1, // WALL_TYPE_2 + WALL_FLAG_0 | WALL_FLAG_2, // WALL_TYPE_3 + WALL_FLAG_3, // WALL_TYPE_4 + WALL_FLAG_4, // WALL_TYPE_5 + WALL_FLAG_5, // WALL_TYPE_6 + WALL_FLAG_6, // WALL_TYPE_7 }; -// SurfaceType_GetSfx -u16 D_80119E10[14] = { - NA_SE_PL_WALK_GROUND - SFX_FLAG, NA_SE_PL_WALK_SAND - SFX_FLAG, NA_SE_PL_WALK_CONCRETE - SFX_FLAG, - NA_SE_PL_WALK_DIRT - SFX_FLAG, NA_SE_PL_WALK_WATER0 - SFX_FLAG, NA_SE_PL_WALK_WATER1 - SFX_FLAG, - NA_SE_PL_WALK_WATER2 - SFX_FLAG, NA_SE_PL_WALK_MAGMA - SFX_FLAG, NA_SE_PL_WALK_GRASS - SFX_FLAG, - NA_SE_PL_WALK_GLASS - SFX_FLAG, NA_SE_PL_WALK_LADDER - SFX_FLAG, NA_SE_PL_WALK_GROUND - SFX_FLAG, - NA_SE_PL_WALK_ICE - SFX_FLAG, NA_SE_PL_WALK_IRON - SFX_FLAG, +u16 D_80119E10[SURFACE_SFX_TYPE_MAX] = { + NA_SE_PL_WALK_GROUND - SFX_FLAG, // SURFACE_SFX_TYPE_0 + NA_SE_PL_WALK_SAND - SFX_FLAG, // SURFACE_SFX_TYPE_1 + NA_SE_PL_WALK_CONCRETE - SFX_FLAG, // SURFACE_SFX_TYPE_2 + NA_SE_PL_WALK_DIRT - SFX_FLAG, // SURFACE_SFX_TYPE_3 + NA_SE_PL_WALK_WATER0 - SFX_FLAG, // SURFACE_SFX_TYPE_4 + NA_SE_PL_WALK_WATER1 - SFX_FLAG, // SURFACE_SFX_TYPE_5 + NA_SE_PL_WALK_WATER2 - SFX_FLAG, // SURFACE_SFX_TYPE_6 + NA_SE_PL_WALK_MAGMA - SFX_FLAG, // SURFACE_SFX_TYPE_7 + NA_SE_PL_WALK_GRASS - SFX_FLAG, // SURFACE_SFX_TYPE_8 + NA_SE_PL_WALK_GLASS - SFX_FLAG, // SURFACE_SFX_TYPE_9 + NA_SE_PL_WALK_LADDER - SFX_FLAG, // SURFACE_SFX_TYPE_10 + NA_SE_PL_WALK_GROUND - SFX_FLAG, // SURFACE_SFX_TYPE_11 + NA_SE_PL_WALK_ICE - SFX_FLAG, // SURFACE_SFX_TYPE_12 + NA_SE_PL_WALK_IRON - SFX_FLAG, // SURFACE_SFX_TYPE_13 }; /** @@ -602,7 +616,7 @@ f32 BgCheck_RaycastFloorStatic(StaticLookup* lookup, CollisionContext* colCtx, u /** * Compute wall displacement on `posX` and `posZ` - * sets `wallPolyPtr` to `poly` if `wallPolyPtr` is NULL or not a damage wall + * sets `wallPolyPtr` to `poly` if `wallPolyPtr` is NULL or doesn't have `surfaceData[0] & 0x08000000` set * returns true if `wallPolyPtr` was changed * `invXZlength` is 1 / sqrt( sq(poly.normal.x) + sq(poly.normal.z) ) */ @@ -610,7 +624,7 @@ s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* pol f32 nz, f32 invXZlength, f32 planeDist, f32 radius, CollisionPoly** wallPolyPtr) { CollisionPoly* wallPoly; u32 surfaceData; - u32 wallDamage; + u32 hasFlag27; f32 displacement = (radius - planeDist) * invXZlength; *posX += displacement * nx; @@ -623,9 +637,9 @@ s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* pol } surfaceData = colCtx->colHeader->surfaceTypeList[wallPoly->type].data[1]; - wallDamage = surfaceData & 0x08000000 ? 1 : 0; + hasFlag27 = surfaceData & 0x08000000 ? 1 : 0; - if (!wallDamage) { + if (!hasFlag27) { *wallPolyPtr = poly; return true; } @@ -1707,7 +1721,7 @@ f32 BgCheck_RaycastFloorImpl(PlayState* play, CollisionContext* colCtx, u16 xpFl yIntersect = yIntersectDyna; } - if (yIntersect != BGCHECK_Y_MIN && func_80041EC8(colCtx, *outPoly, *outBgId)) { + if (yIntersect != BGCHECK_Y_MIN && SurfaceType_IsSoft(colCtx, *outPoly, *outBgId)) { yIntersect -= 1.0f; } return yIntersect; @@ -3832,9 +3846,6 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId, return surfaceTypes[poly->type].data[dataIdx]; } -/** - * SurfaceType get index of bgCam - */ u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) & 0xFF; } @@ -3971,17 +3982,11 @@ Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s return BgCheck_GetBgCamFuncDataImpl(colCtx, SurfaceType_GetBgCamIndex(colCtx, poly, bgId), bgId); } -/** - * SurfaceType Get Scene Exit Index - */ -u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 8 & 0x1F; } -/** - * SurfaceType Get ? Property (& 0x0003 E000) - */ -u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetFloorType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 13 & 0x1F; } @@ -3992,110 +3997,68 @@ u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 18 & 7; } -/** - * SurfaceType Get Wall Property (Internal) - */ -u32 func_80041D94(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetWallType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 21 & 0x1F; } -/** - * SurfaceType Get Wall Flags - */ -s32 func_80041DB8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return D_80119D90[func_80041D94(colCtx, poly, bgId)]; +s32 SurfaceType_GetWallFlags(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return D_80119D90[SurfaceType_GetWallType(colCtx, poly, bgId)]; } -/** - * SurfaceType Is Wall Flag (1 << 0) Set - */ -s32 func_80041DE4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_80041DB8(colCtx, poly, bgId) & 1) ? true : false; +s32 SurfaceType_CheckWallFlag0(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_0) ? true : false; } -/** - * SurfaceType Is Wall Flag (1 << 1) Set - */ -s32 func_80041E18(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_80041DB8(colCtx, poly, bgId) & 2) ? true : false; +s32 SurfaceType_CheckWallFlag1(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_1) ? true : false; } -/** - * SurfaceType Is Wall Flag (1 << 2) Set - */ -s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (func_80041DB8(colCtx, poly, bgId) & 4) ? true : false; +s32 SurfaceType_CheckWallFlag2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetWallFlags(colCtx, poly, bgId) & WALL_FLAG_2) ? true : false; } -/** - * unused - */ -u32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetFloorProperty2(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } -/** - * SurfaceType Get Floor Property - */ -u32 func_80041EA4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetFloorProperty(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF; } -/** - * SurfaceType Is Floor Minus 1 - */ -u32 func_80041EC8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_IsSoft(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 30 & 1; } -/** - * SurfaceType Is Horse Blocked - */ u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 31 & 1; } -u32 func_80041F10(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetSfxType(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) & 0xF; } -/** - * SurfaceType Get Poly Sfx - */ -u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - s32 id = func_80041F10(colCtx, poly, bgId); +u16 SurfaceType_GetSfxId(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + s32 sfxType = SurfaceType_GetSfxType(colCtx, poly, bgId); - if (id < 0 || id > 13) { + if (sfxType < 0 || sfxType >= ARRAY_COUNT(D_80119E10)) { return NA_SE_PL_WALK_GROUND - SFX_FLAG; } - return D_80119E10[id]; + return D_80119E10[sfxType]; } -/** - * SurfaceType get terrain slope surface - */ -u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetFloorEffect(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 4 & 3; } -/** - * SurfaceType get surface lighting setting - */ -u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_GetLightSetting(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 6 & 0x1F; } -/** - * SurfaceType get echo - */ u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 11 & 0x3F; } -/** - * SurfaceType Is Hookshot Surface - */ -u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { +u32 SurfaceType_CanHookshot(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1; } @@ -4146,26 +4109,19 @@ s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s return !!flags; } -/** - * SurfaceType Get Conveyor Surface Speed - */ u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 18 & 7; } /** - * SurfaceType Get Conveyor Direction * returns a value between 0-63, representing 360 / 64 degrees of rotation */ u32 SurfaceType_GetConveyorDirection(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 21 & 0x3F; } -/** - * SurfaceType is Wall Damage - */ -u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { - return (SurfaceType_GetData(colCtx, poly, bgId, 1) & 0x8000000) ? 1 : 0; +u32 func_80042108(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) { + return (SurfaceType_GetData(colCtx, poly, bgId, 1) & 0x08000000) ? 1 : 0; } /** diff --git a/src/code/z_camera.c b/src/code/z_camera.c index 2bf859ece7..8b7dac2601 100644 --- a/src/code/z_camera.c +++ b/src/code/z_camera.c @@ -427,7 +427,7 @@ f32 Camera_GetFloorYLayer(Camera* camera, Vec3f* norm, Vec3f* pos, s32* bgId) { norm->z = 0.0f; floorY = BGCHECK_Y_MIN; break; - } else if (func_80041D4C(colCtx, floorPoly, *bgId) == 1) { + } else if (SurfaceType_GetFloorType(colCtx, floorPoly, *bgId) == FLOOR_TYPE_1) { // floor is not solid, check below that floor. pos->y = floorY - 10.0f; continue; diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 5217f1283d..928fe3333f 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1037,9 +1037,9 @@ void func_8008F87C(PlayState* play, Player* this, SkelAnime* skelAnime, Vec3f* p skelAnime->jointTable[shinLimbIndex].z = skelAnime->jointTable[shinLimbIndex].z + temp1; skelAnime->jointTable[footLimbIndex].z = skelAnime->jointTable[footLimbIndex].z + temp2 - temp1; - temp3 = func_80041D4C(&play->colCtx, sp88, sp84); + temp3 = SurfaceType_GetFloorType(&play->colCtx, sp88, sp84); - if ((temp3 >= 2) && (temp3 < 4) && !SurfaceType_IsWallDamage(&play->colCtx, sp88, sp84)) { + if ((temp3 >= FLOOR_TYPE_2) && (temp3 <= FLOOR_TYPE_3) && !func_80042108(&play->colCtx, sp88, sp84)) { footprintPos.y = sp80; EffectSsGFire_Spawn(play, &footprintPos); } diff --git a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c index 7430971d4d..2cef55d6e2 100644 --- a/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c +++ b/src/overlays/actors/ovl_Arms_Hook/z_arms_hook.c @@ -266,7 +266,7 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { this->actor.world.pos.x += 10.0f * polyNormalX; this->actor.world.pos.z += 10.0f * polyNormalZ; this->timer = 0; - if (SurfaceType_IsHookshotSurface(&play->colCtx, poly, bgId)) { + if (SurfaceType_CanHookshot(&play->colCtx, poly, bgId)) { if (bgId != BGCHECK_SCENE) { dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); if (dynaPolyActor != NULL) { diff --git a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c index 360345ec37..be72c84868 100644 --- a/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c +++ b/src/overlays/actors/ovl_Bg_Hidan_Rock/z_bg_hidan_rock.c @@ -251,9 +251,9 @@ void func_8088B79C(BgHidanRock* this, PlayState* play) { } Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Audio_PlayActorSfx2(&this->dyna.actor, - SurfaceType_GetSfx(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + - SFX_FLAG); + Audio_PlayActorSfx2( + &this->dyna.actor, + SurfaceType_GetSfxId(&play->colCtx, this->dyna.actor.floorPoly, this->dyna.actor.floorBgId) + SFX_FLAG); } this->unk_16C -= 0.5f; diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c index 59dfea7ab9..2fc91ab891 100644 --- a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c @@ -719,7 +719,7 @@ void func_80986570(DemoIm* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 7.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { u32 sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); Audio_PlaySfxGeneral(sfxId, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); } diff --git a/src/overlays/actors/ovl_En_Bb/z_en_bb.c b/src/overlays/actors/ovl_En_Bb/z_en_bb.c index 04919ca125..b8f535cb90 100644 --- a/src/overlays/actors/ovl_En_Bb/z_en_bb.c +++ b/src/overlays/actors/ovl_En_Bb/z_en_bb.c @@ -693,9 +693,9 @@ void EnBb_Down(EnBb* this, PlayState* play) { } if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { if (this->actor.params == ENBB_RED) { - s32 floorType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + s32 floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + if ((floorType == FLOOR_TYPE_2) || (floorType == FLOOR_TYPE_3) || (floorType == FLOOR_TYPE_9)) { this->moveMode = BBMOVE_HIDDEN; this->timer = 10; this->actionState++; @@ -812,8 +812,8 @@ void EnBb_Red(EnBb* this, PlayState* play) { this->actor.bgCheckFlags &= ~BGCHECKFLAG_WALL; } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - floorType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorType == 2) || (floorType == 3) || (floorType == 9)) { + floorType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((floorType == FLOOR_TYPE_2) || (floorType == FLOOR_TYPE_3) || (floorType == FLOOR_TYPE_9)) { this->moveMode = BBMOVE_HIDDEN; this->timer = 10; this->actionState++; diff --git a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c index 70a11b868e..bc1517c45a 100644 --- a/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c +++ b/src/overlays/actors/ovl_En_Bom_Chu/z_en_bom_chu.c @@ -275,7 +275,8 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posUpDown, &polyUpDown, true, true, true, true, &bgIdUpDown) && - !(func_80041DB8(&play->colCtx, polyUpDown, bgIdUpDown) & 0x30) && // && not crawl space? + !(SurfaceType_GetWallFlags(&play->colCtx, polyUpDown, bgIdUpDown) & + (WALL_FLAG_4 | WALL_FLAG_5)) && // && not crawl space? !SurfaceType_IsIgnoredByProjectiles(&play->colCtx, polyUpDown, bgIdUpDown)) { // forwards posB.x = (this->axisForwards.x * lineLength) + posA.x; @@ -284,7 +285,7 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, &bgIdSide) && - !(func_80041DB8(&play->colCtx, polySide, bgIdSide) & 0x30) && + !(SurfaceType_GetWallFlags(&play->colCtx, polySide, bgIdSide) & (WALL_FLAG_4 | WALL_FLAG_5)) && !SurfaceType_IsIgnoredByProjectiles(&play->colCtx, polySide, bgIdSide)) { EnBomChu_UpdateFloorPoly(this, polySide, play); this->actor.world.pos = posSide; @@ -323,7 +324,7 @@ void EnBomChu_Move(EnBomChu* this, PlayState* play) { if (BgCheck_EntityLineTest1(&play->colCtx, &posA, &posB, &posSide, &polySide, true, true, true, true, &bgIdSide) && - !(func_80041DB8(&play->colCtx, polySide, bgIdSide) & 0x30) && + !(SurfaceType_GetWallFlags(&play->colCtx, polySide, bgIdSide) & (WALL_FLAG_4 | WALL_FLAG_5)) && !SurfaceType_IsIgnoredByProjectiles(&play->colCtx, polySide, bgIdSide)) { EnBomChu_UpdateFloorPoly(this, polySide, play); this->actor.world.pos = posSide; diff --git a/src/overlays/actors/ovl_En_Bw/z_en_bw.c b/src/overlays/actors/ovl_En_Bw/z_en_bw.c index 454cd26a5d..dd40911c48 100644 --- a/src/overlays/actors/ovl_En_Bw/z_en_bw.c +++ b/src/overlays/actors/ovl_En_Bw/z_en_bw.c @@ -455,8 +455,8 @@ void func_809CF984(EnBw* this, PlayState* play) { } SkelAnime_Update(&this->skelAnime); if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) { - floorPolyType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorPolyType == 2) || (floorPolyType == 3) || (floorPolyType == 9)) { + floorPolyType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + if ((floorPolyType == FLOOR_TYPE_2) || (floorPolyType == FLOOR_TYPE_3) || (floorPolyType == FLOOR_TYPE_9)) { Actor_Kill(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c index 015779aa84..96bd56c04b 100644 --- a/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c +++ b/src/overlays/actors/ovl_En_Encount1/z_en_encount1.c @@ -107,8 +107,8 @@ void EnEncount1_SpawnLeevers(EnEncount1* this, PlayState* play) { if ((this->timer == 0) && (play->csCtx.state == CS_STATE_IDLE) && (this->curNumSpawn <= this->maxCurSpawns) && (this->curNumSpawn < 5)) { - floorType = func_80041D4C(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId); - if ((floorType != 4) && (floorType != 7) && (floorType != 12)) { + floorType = SurfaceType_GetFloorType(&play->colCtx, player->actor.floorPoly, player->actor.floorBgId); + if ((floorType != FLOOR_TYPE_4) && (floorType != FLOOR_TYPE_7) && (floorType != FLOOR_TYPE_12)) { this->numLeeverSpawns = 0; } else if (!(this->reduceLeevers && (this->actor.xzDistToPlayer > 1300.0f))) { spawnLimit = 5; @@ -241,7 +241,7 @@ void EnEncount1_SpawnStalchildOrWolfos(EnEncount1* this, PlayState* play) { if ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) { while ((this->curNumSpawn < this->maxCurSpawns) && (this->totalNumSpawn < this->maxTotalSpawns)) { if (play->sceneNum == SCENE_SPOT00) { - if ((player->unk_89E == 0) || (player->actor.floorBgId != BGCHECK_SCENE) || + if ((player->unk_89E == SURFACE_SFX_TYPE_0) || (player->actor.floorBgId != BGCHECK_SCENE) || !(player->actor.bgCheckFlags & BGCHECKFLAG_GROUND) || (player->stateFlags1 & PLAYER_STATE1_27)) { this->fieldSpawnTimer = 60; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 384fde934d..55035b2f74 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -2854,7 +2854,7 @@ s32 EnHorse_CalcFloorHeight(EnHorse* this, PlayState* play, Vec3f* pos, Collisio if ((*floorPoly)->normal.y * COLPOLY_NORMAL_FRAC < 0.81915206f || // cos(35 degrees) SurfaceType_IsHorseBlocked(&play->colCtx, *floorPoly, bgId) || - func_80041D4C(&play->colCtx, *floorPoly, bgId) == 7) { + SurfaceType_GetFloorType(&play->colCtx, *floorPoly, bgId) == FLOOR_TYPE_7) { return 3; // Horse blocked surface } return 0; @@ -2983,7 +2983,7 @@ void EnHorse_CheckFloors(EnHorse* this, PlayState* play) { if (ny < 0.81915206f || // cos(35 degrees) SurfaceType_IsHorseBlocked(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) || - func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 7) { + SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == FLOOR_TYPE_7) { if (this->actor.speedXZ >= 0.0f) { EnHorse_ObstructMovement(this, play, 4, galloping); } else { @@ -3252,7 +3252,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; if (ny < 0.81915206f || // cos(35 degrees) (SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) != 0) || - (func_80041D4C(&play->colCtx, obstacleFloor, bgId) == 7)) { + (SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7)) { if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); @@ -3289,7 +3289,7 @@ void EnHorse_UpdateBgCheckInfo(EnHorse* this, PlayState* play) { ny = obstacleFloor->normal.y * COLPOLY_NORMAL_FRAC; if (ny < 0.81915206f || // cos(35 degrees) SurfaceType_IsHorseBlocked(&play->colCtx, obstacleFloor, bgId) || - func_80041D4C(&play->colCtx, obstacleFloor, bgId) == 7) { + SurfaceType_GetFloorType(&play->colCtx, obstacleFloor, bgId) == FLOOR_TYPE_7) { if (movingFast == true && this->action != ENHORSE_ACT_STOPPING) { this->stateFlags |= ENHORSE_FORCE_REVERSING; EnHorse_StartBraking(this, play); @@ -3460,7 +3460,7 @@ s32 EnHorse_UpdateConveyors(EnHorse* this, PlayState* play) { return 0; } conveyorDir = SurfaceType_GetConveyorDirection(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - conveyorDir = (conveyorDir * (0x10000 / 64)) - this->actor.world.rot.y; + conveyorDir = CONVEYOR_DIRECTION_TO_BINANG(conveyorDir) - this->actor.world.rot.y; if (conveyorDir > 800.0f) { this->actor.world.rot.y += 800.0f; } else if (conveyorDir < -800.0f) { diff --git a/src/overlays/actors/ovl_En_Js/z_en_js.c b/src/overlays/actors/ovl_En_Js/z_en_js.c index f67805f08e..b91758f7af 100644 --- a/src/overlays/actors/ovl_En_Js/z_en_js.c +++ b/src/overlays/actors/ovl_En_Js/z_en_js.c @@ -174,7 +174,7 @@ void EnJs_Update(Actor* thisx, PlayState* play) { Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_2); if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == + if (SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == (NA_SE_PL_WALK_SAND - SFX_FLAG)) { Math_ApproachF(&this->actor.shape.yOffset, sREG(80) + -2000.0f, 1.0f, (sREG(81) / 10.0f) + 50.0f); } diff --git a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c index f420cc1176..9d62e41642 100644 --- a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c +++ b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c @@ -133,9 +133,9 @@ void EnReeba_Init(Actor* thisx, PlayState* play) { UPDBGCHECKINFO_FLAG_0 | UPDBGCHECKINFO_FLAG_2 | UPDBGCHECKINFO_FLAG_3 | UPDBGCHECKINFO_FLAG_4); - surfaceType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + surfaceType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((surfaceType != 4) && (surfaceType != 7)) { + if ((surfaceType != FLOOR_TYPE_4) && (surfaceType != FLOOR_TYPE_7)) { Actor_Kill(&this->actor); return; } @@ -251,9 +251,9 @@ void func_80AE5270(EnReeba* this, PlayState* play) { Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); } - surfaceType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + surfaceType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((surfaceType != 4) && (surfaceType != 7)) { + if ((surfaceType != FLOOR_TYPE_4) && (surfaceType != FLOOR_TYPE_7)) { this->actor.speedXZ = 0.0f; this->actionfunc = func_80AE5688; } else if ((this->unk_272 == 0) || (this->actor.xzDistToPlayer < 30.0f) || (this->actor.xzDistToPlayer > 400.0f) || @@ -282,9 +282,9 @@ void func_80AE53AC(EnReeba* this, PlayState* play) { Math_ApproachF(&this->actor.shape.shadowScale, 12.0f, 3.0f, 1.0f); } - surfaceType = func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + surfaceType = SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if (((surfaceType != 4) && (surfaceType != 7)) || (this->actor.xzDistToPlayer > 400.0f) || + if (((surfaceType != FLOOR_TYPE_4) && (surfaceType != FLOOR_TYPE_7)) || (this->actor.xzDistToPlayer > 400.0f) || (this->actor.bgCheckFlags & BGCHECKFLAG_WALL)) { this->actionfunc = func_80AE5688; } else { diff --git a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c index 6224cd7e91..c7733b843a 100644 --- a/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c +++ b/src/overlays/actors/ovl_En_River_Sound/z_en_river_sound.c @@ -208,10 +208,10 @@ void EnRiverSound_Update(Actor* thisx, PlayState* play) { // Get the river sfx frequency based on the speed of the river current under the actor this->sfxFreqIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, thisx->floorPoly, bgId); } else { - this->sfxFreqIndex = 0; + this->sfxFreqIndex = CONVEYOR_SPEED_DISABLED; } - if (this->sfxFreqIndex == 0) { + if (this->sfxFreqIndex == CONVEYOR_SPEED_DISABLED) { if (thisx->params == RS_RIVER_DEFAULT_MEDIUM_FREQ) { this->sfxFreqIndex = 0; } else if (thisx->params == RS_RIVER_DEFAULT_LOW_FREQ) { @@ -222,7 +222,7 @@ void EnRiverSound_Update(Actor* thisx, PlayState* play) { } } else { this->sfxFreqIndex--; - this->sfxFreqIndex = CLAMP_MAX(this->sfxFreqIndex, 2); + this->sfxFreqIndex = CLAMP_MAX(this->sfxFreqIndex, CONVEYOR_SPEED_MAX - 2); } } } else if ((thisx->params == RS_GORON_CITY_SARIAS_SONG) || (thisx->params == RS_GREAT_FAIRY)) { @@ -257,10 +257,14 @@ void EnRiverSound_Draw(Actor* thisx, PlayState* play) { NA_SE_EV_TORCH - SFX_FLAG, NA_SE_EV_COW_CRY_LV - SFX_FLAG, }; - static f32 sfxFreqs[] = { 0.7f, 1.0f, 1.4f }; + static f32 sfxFreqs[CONVEYOR_SPEED_MAX - 1] = { + 0.7f, // CONVEYOR_SPEED_SLOW + 1.0f, // CONVEYOR_SPEED_MEDIUM + 1.4f, // CONVEYOR_SPEED_FAST + }; EnRiverSound* this = (EnRiverSound*)thisx; - if (!(this->playSfx)) { + if (!this->playSfx) { this->playSfx = true; } else if ((this->actor.params == RS_RIVER_DEFAULT_LOW_FREQ) || (this->actor.params == RS_RIVER_DEFAULT_MEDIUM_FREQ) || diff --git a/src/overlays/actors/ovl_En_Sw/z_en_sw.c b/src/overlays/actors/ovl_En_Sw/z_en_sw.c index 786b2e5d37..c95f4f4d62 100644 --- a/src/overlays/actors/ovl_En_Sw/z_en_sw.c +++ b/src/overlays/actors/ovl_En_Sw/z_en_sw.c @@ -122,7 +122,7 @@ CollisionPoly* func_80B0C020(PlayState* play, Vec3f* arg1, Vec3f* arg2, Vec3f* a return NULL; } - if (func_80041DB8(&play->colCtx, sp3C, *arg4) & 0x30) { + if (SurfaceType_GetWallFlags(&play->colCtx, sp3C, *arg4) & (WALL_FLAG_4 | WALL_FLAG_5)) { return NULL; } diff --git a/src/overlays/actors/ovl_En_Test/z_en_test.c b/src/overlays/actors/ovl_En_Test/z_en_test.c index 012b0ad927..e78a0cefee 100644 --- a/src/overlays/actors/ovl_En_Test/z_en_test.c +++ b/src/overlays/actors/ovl_En_Test/z_en_test.c @@ -1723,10 +1723,10 @@ void EnTest_Update(Actor* thisx, PlayState* play) { this->actor.floorHeight = this->actor.home.pos.y; } } else if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) { - floorProperty = func_80041EA4(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + floorProperty = SurfaceType_GetFloorProperty(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); - if ((floorProperty == 5) || (floorProperty == 0xC) || - func_80041D4C(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == 9) { + if ((floorProperty == FLOOR_PROPERTY_5) || (floorProperty == FLOOR_PROPERTY_12) || + SurfaceType_GetFloorType(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) == FLOOR_TYPE_9) { Actor_Kill(&this->actor); return; } diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 3d45721f24..c3445fb7d4 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -372,7 +372,7 @@ void EnXc_SetWalkingSFX(EnXc* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 11.0f) || Animation_OnFrame(&this->skelAnime, 23.0f)) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); func_80078914(&this->actor.projectedPos, sfxId); } } @@ -386,7 +386,7 @@ void EnXc_SetNutThrowSFX(EnXc* this, PlayState* play) { if (Animation_OnFrame(&this->skelAnime, 7.0f)) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); func_80078914(&this->actor.projectedPos, sfxId); } } @@ -402,7 +402,7 @@ void EnXc_SetLandingSFX(EnXc* this, PlayState* play) { if ((gSaveContext.sceneLayer != 4) || (sceneNum != SCENE_SPOT11)) { if (Animation_OnFrame(&this->skelAnime, 11.0f)) { sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); func_80078914(&this->actor.projectedPos, sfxId); } } diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index e5ad763cfc..3559f15998 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -1437,7 +1437,7 @@ void func_80B51D24(EnZl2* this, PlayState* play) { if (Animation_OnFrame(skelAnime, 6.0f) || Animation_OnFrame(skelAnime, 0.0f)) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { sfxId = SFX_FLAG; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); func_80078914(&this->actor.projectedPos, sfxId); } } diff --git a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c index 91fffe50cb..eae543d6a9 100644 --- a/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c +++ b/src/overlays/actors/ovl_En_Zl3/z_en_zl3.c @@ -1558,7 +1558,7 @@ void func_80B56E38(EnZl3* this, PlayState* play) { if ((Animation_OnFrame(sp20, 6.0f) || Animation_OnFrame(sp20, 0.0f)) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { sfxId = 0x800; - sfxId += SurfaceType_GetSfx(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); + sfxId += SurfaceType_GetSfxId(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId); func_80078914(&this->actor.projectedPos, sfxId); } } diff --git a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c index 33ec90fa3a..a8f37d88f8 100644 --- a/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c +++ b/src/overlays/actors/ovl_Obj_Oshihiki/z_obj_oshihiki.c @@ -604,8 +604,8 @@ void ObjOshihiki_Fall(ObjOshihiki* this, PlayState* play) { ObjOshihiki_SetupOnActor(this, play); } Audio_PlayActorSfx2(&this->dyna.actor, NA_SE_EV_BLOCK_BOUND); - Audio_PlayActorSfx2(&this->dyna.actor, SurfaceType_GetSfx(&play->colCtx, this->floorPolys[this->highestFloor], - this->floorBgIds[this->highestFloor]) + + Audio_PlayActorSfx2(&this->dyna.actor, SurfaceType_GetSfxId(&play->colCtx, this->floorPolys[this->highestFloor], + this->floorBgIds[this->highestFloor]) + SFX_FLAG); } } diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 327f08e26c..022033ddd2 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -467,15 +467,15 @@ static f32 D_808535D4 = 0.0f; static s16 D_808535D8 = 0; static s16 D_808535DC = 0; static s32 D_808535E0 = 0; -static s32 D_808535E4 = 0; +static s32 D_808535E4 = FLOOR_TYPE_0; static f32 D_808535E8 = 1.0f; static f32 D_808535EC = 1.0f; static u32 D_808535F0 = 0; -static u32 sConveyorSpeedIndex = 0; +static u32 sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; static s16 sIsFloorConveyor = false; static s16 sConveyorYaw = 0; static f32 D_80853600 = 0.0f; -static s32 D_80853604 = 0; +static s32 D_80853604 = FLOOR_PROPERTY_0; static s32 D_80853608 = 0; static s32 D_8085360C = 0; static s16 D_80853610 = 0; @@ -3713,9 +3713,9 @@ void func_80837C0C(PlayState* play, Player* this, s32 arg2, f32 arg3, f32 arg4, } s32 func_80838144(s32 arg0) { - s32 temp = arg0 - 2; + s32 temp = arg0 - FLOOR_TYPE_2; - if ((temp >= 0) && (temp < 2)) { + if ((temp >= 0) && (temp <= (FLOOR_TYPE_3 - FLOOR_TYPE_2))) { return temp; } else { return -1; @@ -3723,7 +3723,7 @@ s32 func_80838144(s32 arg0) { } s32 func_8083816C(s32 arg0) { - return (arg0 == 4) || (arg0 == 7) || (arg0 == 12); + return (arg0 == FLOOR_TYPE_4) || (arg0 == FLOOR_TYPE_7) || (arg0 == FLOOR_TYPE_12); } void func_8083819C(Player* this, PlayState* play) { @@ -3771,7 +3771,7 @@ s32 func_808382DC(Player* this, PlayState* play) { } else { sp68 = ((Player_GetHeight(this) - 8.0f) < (this->unk_6C4 * this->actor.scale.y)); - if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (D_808535E4 == 9) || + if (sp68 || (this->actor.bgCheckFlags & BGCHECKFLAG_CRUSHED) || (D_808535E4 == FLOOR_TYPE_9) || (this->stateFlags2 & PLAYER_STATE2_31)) { func_80832698(this, NA_SE_VO_LI_DAMAGE_S); @@ -3898,9 +3898,8 @@ s32 func_808382DC(Player* this, PlayState* play) { s32 sp48 = func_80838144(D_808535E4); if (((this->actor.wallPoly != NULL) && - SurfaceType_IsWallDamage(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || - ((sp48 >= 0) && - SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) && + func_80042108(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) || + ((sp48 >= 0) && func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) && (this->unk_A79 >= D_808544F4[sp48])) || ((sp48 >= 0) && ((this->currentTunic != PLAYER_TUNIC_GORON) || (this->unk_A79 >= D_808544F4[sp48])))) { @@ -3964,7 +3963,7 @@ s32 func_80838A14(Player* this, PlayState* play) { return 0; } - if ((this->actor.wallBgId != BGCHECK_SCENE) && (D_808535F0 & 0x40)) { + if ((this->actor.wallBgId != BGCHECK_SCENE) && (D_808535F0 & WALL_FLAG_6)) { if (this->unk_88D >= 6) { this->stateFlags2 |= PLAYER_STATE2_2; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A)) { @@ -4136,9 +4135,8 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (!(this->stateFlags1 & PLAYER_STATE1_7) && (play->transitionTrigger == TRANS_TRIGGER_OFF) && (this->csMode == 0) && !(this->stateFlags1 & PLAYER_STATE1_0) && - (((poly != NULL) && - (exitIndex = SurfaceType_GetSceneExitIndex(&play->colCtx, poly, bgId), exitIndex != 0)) || - (func_8083816C(D_808535E4) && (this->unk_A7A == 12)))) { + (((poly != NULL) && (exitIndex = SurfaceType_GetExitIndex(&play->colCtx, poly, bgId), exitIndex != 0)) || + (func_8083816C(D_808535E4) && (this->unk_A7A == FLOOR_PROPERTY_12)))) { sp34 = this->unk_A84 - (s32)this->actor.world.pos.y; @@ -4165,7 +4163,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) play->curSpawn]; Scene_SetTransitionForNextEntrance(play); } else { - if (SurfaceType_GetSlope(&play->colCtx, poly, bgId) == 2) { + if (SurfaceType_GetFloorEffect(&play->colCtx, poly, bgId) == FLOOR_EFFECT_2) { gSaveContext.respawn[RESPAWN_MODE_DOWN].entranceIndex = play->nextEntranceIndex; Play_TriggerVoidOut(play); gSaveContext.respawnFlag = -2; @@ -4180,10 +4178,10 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (!(this->stateFlags1 & (PLAYER_STATE1_23 | PLAYER_STATE1_29)) && !(this->stateFlags2 & PLAYER_STATE2_18) && !func_808332B8(this) && - (temp = func_80041D4C(&play->colCtx, poly, bgId), (temp != 10)) && + (temp = SurfaceType_GetFloorType(&play->colCtx, poly, bgId), (temp != FLOOR_TYPE_10)) && ((sp34 < 100) || (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { - if (temp == 11) { + if (temp == FLOOR_TYPE_11) { func_800788CC(NA_SE_OC_SECRET_HOLE_OUT); func_800F6964(5); gSaveContext.seqId = (u8)NA_BGM_DISABLED; @@ -4202,7 +4200,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) gSaveContext.entranceSpeed = linearVel; } - if (sConveyorSpeedIndex != 0) { + if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { yaw = sConveyorYaw; } else { yaw = this->actor.world.rot.y; @@ -4224,13 +4222,13 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) if (play->transitionTrigger == TRANS_TRIGGER_OFF) { if ((this->actor.world.pos.y < -4000.0f) || - (((this->unk_A7A == 5) || (this->unk_A7A == 12)) && + (((this->unk_A7A == FLOOR_PROPERTY_5) || (this->unk_A7A == FLOOR_PROPERTY_12)) && ((D_80853600 < 100.0f) || (this->fallDistance > 400.0f) || ((play->sceneNum != SCENE_HAKADAN) && (this->fallDistance > 200.0f)))) || ((play->sceneNum == SCENE_GANON_FINAL) && (this->fallDistance > 320.0f))) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - if (this->unk_A7A == 5) { + if (this->unk_A7A == FLOOR_PROPERTY_5) { Play_TriggerRespawn(play); } else { Play_TriggerVoidOut(play); @@ -4240,7 +4238,7 @@ s32 func_80839034(PlayState* play, Player* this, CollisionPoly* poly, u32 bgId) } else { func_80838F5C(play, this); this->unk_850 = 9999; - if (this->unk_A7A == 5) { + if (this->unk_A7A == FLOOR_PROPERTY_5) { this->unk_84F = -1; } else { this->unk_84F = 1; @@ -4700,8 +4698,8 @@ s32 func_8083A6AC(Player* this, PlayState* play) { sp54 = Math3D_UDistPlaneToPos(nx, ny, nz, sp84->dist, &this->actor.world.pos); - sp50 = D_80853604 == 6; - if (!sp50 && (func_80041DB8(&play->colCtx, sp84, sp80) & 8)) { + sp50 = D_80853604 == FLOOR_PROPERTY_6; + if (!sp50 && (SurfaceType_GetWallFlags(&play->colCtx, sp84, sp80) & WALL_FLAG_3)) { sp50 = 1; } @@ -4753,7 +4751,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (!(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) { if (!func_80838FB8(play, this)) { - if (D_80853604 == 8) { + if (D_80853604 == FLOOR_PROPERTY_8) { this->actor.world.pos.x = this->actor.prevPos.x; this->actor.world.pos.z = this->actor.prevPos.z; return; @@ -4762,7 +4760,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (!(this->stateFlags3 & PLAYER_STATE3_1) && !(this->skelAnime.moveFlags & 0x80) && (func_8084411C != this->func_674) && (func_80844A44 != this->func_674)) { - if ((D_80853604 == 7) || (this->meleeWeaponState != 0)) { + if ((D_80853604 == FLOOR_PROPERTY_7) || (this->meleeWeaponState != 0)) { Math_Vec3f_Copy(&this->actor.world.pos, &this->actor.prevPos); func_80832210(this); return; @@ -4770,7 +4768,7 @@ void func_8083AA10(Player* this, PlayState* play) { if (this->hoverBootsTimer != 0) { this->actor.velocity.y = 1.0f; - D_80853604 = 9; + D_80853604 = FLOOR_PROPERTY_9; return; } @@ -4782,10 +4780,10 @@ void func_8083AA10(Player* this, PlayState* play) { this->unk_89E = this->unk_A82; if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND_LEAVE) && !(this->stateFlags1 & PLAYER_STATE1_27) && - (D_80853604 != 6) && (D_80853604 != 9) && (D_80853600 > 20.0f) && (this->meleeWeaponState == 0) && - (ABS(sp5C) < 0x2000) && (this->linearVelocity > 3.0f)) { + (D_80853604 != FLOOR_PROPERTY_6) && (D_80853604 != FLOOR_PROPERTY_9) && (D_80853600 > 20.0f) && + (this->meleeWeaponState == 0) && (ABS(sp5C) < 0x2000) && (this->linearVelocity > 3.0f)) { - if ((D_80853604 == 11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { + if ((D_80853604 == FLOOR_PROPERTY_11) && !(this->stateFlags1 & PLAYER_STATE1_11)) { sp40 = func_808396F4(play, this, &D_8085451C, &sp44, &sp58, &sp54); sp3C = this->actor.world.pos.y; @@ -4802,7 +4800,8 @@ void func_8083AA10(Player* this, PlayState* play) { return; } - if ((D_80853604 == 9) || (D_80853600 <= this->ageProperties->unk_34) || !func_8083A6AC(this, play)) { + if ((D_80853604 == FLOOR_PROPERTY_9) || (D_80853600 <= this->ageProperties->unk_34) || + !func_8083A6AC(this, play)) { func_80832284(play, this, &gPlayerAnim_003040); return; } @@ -5180,7 +5179,7 @@ s32 func_8083BB20(Player* this) { } s32 func_8083BBA0(Player* this, PlayState* play) { - if (func_8083BB20(this) && (D_808535E4 != 7)) { + if (func_8083BB20(this) && (D_808535E4 != FLOOR_TYPE_7)) { func_8083BA90(play, this, PLAYER_MWA_JUMPSLASH_START, 3.0f, 4.5f); return 1; } @@ -5195,7 +5194,7 @@ void func_8083BC04(Player* this, PlayState* play) { } s32 func_8083BC7C(Player* this, PlayState* play) { - if ((this->unk_84B[this->unk_846] == 0) && (D_808535E4 != 7)) { + if ((this->unk_84B[this->unk_846] == 0) && (D_808535E4 != FLOOR_TYPE_7)) { func_8083BC04(this, play); return 1; } @@ -5223,8 +5222,8 @@ s32 func_8083BDBC(Player* this, PlayState* play) { s32 sp2C; if (CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && - (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (D_808535E4 != 7) && - (SurfaceType_GetSlope(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) != 1)) { + (play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && (D_808535E4 != FLOOR_TYPE_7) && + (SurfaceType_GetFloorEffect(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1)) { sp2C = this->unk_84B[this->unk_846]; if (sp2C <= 0) { @@ -5795,7 +5794,7 @@ void func_8083D6EC(PlayState* play, Player* this) { temp1 = fabsf(this->linearVelocity) * 20.0f; temp3 = 0.0f; - if (D_808535E4 == 4) { + if (D_808535E4 == FLOOR_TYPE_4) { if (this->unk_6C4 > 1300.0f) { temp2 = this->unk_6C4; } else { @@ -5810,7 +5809,7 @@ void func_8083D6EC(PlayState* play, Player* this) { temp2 = 20000.0f; if (this->currentBoots != PLAYER_BOOTS_HOVER) { temp1 += temp1; - } else if ((D_808535E4 == 7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { + } else if ((D_808535E4 == FLOOR_TYPE_7) || (this->currentBoots == PLAYER_BOOTS_IRON)) { temp1 = 0; } } @@ -5912,7 +5911,7 @@ void func_8083DC54(Player* this, PlayState* play) { return; } - if (D_808535E4 == 11) { + if (D_808535E4 == FLOOR_TYPE_11) { Math_SmoothStepToS(&this->actor.focus.rot.x, -20000, 10, 4000, 800); } else { sp46 = 0; @@ -6042,7 +6041,7 @@ s32 func_8083E318(PlayState* play, Player* this, CollisionPoly* floorPoly) { s16 velYawToDownwardSlope; if (!Player_InBlockingCsMode(play, this) && (func_8084F390 != this->func_674) && - (SurfaceType_GetSlope(&play->colCtx, floorPoly, this->actor.floorBgId) == 1)) { + (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) == FLOOR_EFFECT_1)) { // Get direction of movement relative to the downward direction of the slope playerVelYaw = Math_Atan2S(this->actor.velocity.z, this->actor.velocity.x); @@ -6245,9 +6244,10 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 arg2) { if (this->wallHeight >= 79.0f) { if (!(this->stateFlags1 & PLAYER_STATE1_27) || (this->currentBoots == PLAYER_BOOTS_IRON) || (this->actor.yDistToWater < this->ageProperties->unk_2C)) { - s32 sp8C = (arg2 & 8) ? 2 : 0; + s32 sp8C = (arg2 & WALL_FLAG_3) ? 2 : 0; - if ((sp8C != 0) || (arg2 & 2) || func_80041E4C(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { + if ((sp8C != 0) || (arg2 & WALL_FLAG_1) || + SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId)) { f32 phi_f20; CollisionPoly* wallPoly = this->actor.wallPoly; f32 sp80; @@ -6312,7 +6312,7 @@ s32 func_8083EC18(Player* this, PlayState* play, u32 arg2) { this->stateFlags1 |= PLAYER_STATE1_21; this->stateFlags1 &= ~PLAYER_STATE1_27; - if ((sp8C != 0) || (arg2 & 2)) { + if ((sp8C != 0) || (arg2 & WALL_FLAG_1)) { if ((this->unk_84F = sp8C) != 0) { if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { sp30 = &gPlayerAnim_002D80; @@ -6363,7 +6363,7 @@ s32 func_8083F0C8(Player* this, PlayState* play, u32 arg2) { f32 phi_f12; s32 i; - if (!LINK_IS_ADULT && !(this->stateFlags1 & PLAYER_STATE1_27) && (arg2 & 0x30)) { + if (!LINK_IS_ADULT && !(this->stateFlags1 & PLAYER_STATE1_27) && (arg2 & (WALL_FLAG_4 | WALL_FLAG_5))) { wallPoly = this->actor.wallPoly; CollisionPoly_GetVerticesByBgId(wallPoly, this->actor.wallBgId, &play->colCtx, sp50); @@ -6443,7 +6443,7 @@ s32 func_8083F360(PlayState* play, Player* this, f32 arg1, f32 arg2, f32 arg3, f this->actor.bgCheckFlags |= BGCHECKFLAG_PLAYER_WALL_INTERACT; this->actor.wallBgId = sp78; - D_808535F0 = func_80041DB8(&play->colCtx, wallPoly, sp78); + D_808535F0 = SurfaceType_GetWallFlags(&play->colCtx, wallPoly, sp78); wallPolyNormalX = COLPOLY_GET_NORMAL(wallPoly->normal.x); wallPolyNormalZ = COLPOLY_GET_NORMAL(wallPoly->normal.z); @@ -6469,7 +6469,8 @@ s32 func_8083F524(PlayState* play, Player* this) { s32 func_8083F570(Player* this, PlayState* play) { s16 temp; - if ((this->linearVelocity != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && (D_808535F0 & 0x30)) { + if ((this->linearVelocity != 0.0f) && (this->actor.bgCheckFlags & BGCHECKFLAG_WALL) && + (D_808535F0 & (WALL_FLAG_4 | WALL_FLAG_5))) { temp = this->actor.shape.rot.y - this->actor.wallYaw; if (this->linearVelocity < 0.0f) { @@ -6525,7 +6526,8 @@ s32 func_8083F7BC(Player* this, PlayState* play) { } if (!func_808332B8(this) && ((this->linearVelocity == 0.0f) || !(this->stateFlags2 & PLAYER_STATE2_2)) && - (D_808535F0 & 0x40) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (this->wallHeight >= 39.0f)) { + (D_808535F0 & WALL_FLAG_6) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && + (this->wallHeight >= 39.0f)) { this->stateFlags2 |= PLAYER_STATE2_0; @@ -6609,8 +6611,8 @@ void func_8083FB7C(Player* this, PlayState* play) { s32 func_8083FBC0(Player* this, PlayState* play) { if (!CHECK_BTN_ALL(sControlInput->press.button, BTN_A) && (this->actor.bgCheckFlags & BGCHECKFLAG_PLAYER_WALL_INTERACT) && - ((D_808535F0 & 8) || (D_808535F0 & 2) || - func_80041E4C(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId))) { + ((D_808535F0 & WALL_FLAG_3) || (D_808535F0 & WALL_FLAG_1) || + SurfaceType_CheckWallFlag2(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId))) { return 0; } @@ -7591,7 +7593,7 @@ static Vec3f D_808545C0 = { 0.0f, 0.0f, 0.0f }; s32 func_8084269C(PlayState* play, Player* this) { Vec3f sp2C; - if ((this->unk_89E == 0) || (this->unk_89E == 1)) { + if ((this->unk_89E == SURFACE_SFX_TYPE_0) || (this->unk_89E == SURFACE_SFX_TYPE_1)) { func_8084260C(&this->actor.shape.feetPos[FOOT_LEFT], &sp2C, this->actor.floorHeight - this->actor.shape.feetPos[FOOT_LEFT].y, 7.0f, 5.0f); func_800286CC(play, &sp2C, &D_808545B4, &D_808545C0, 50, 30); @@ -7758,7 +7760,7 @@ s32 func_80842DF4(PlayState* play, Player* this) { if (BgCheck_EntityLineTest1(&play->colCtx, &sp68, &this->meleeWeaponInfo[0].tip, &sp5C, &sp78, true, false, false, true, &sp74) && !SurfaceType_IsIgnoredByEntities(&play->colCtx, sp78, sp74) && - (func_80041D4C(&play->colCtx, sp78, sp74) != 6) && + (SurfaceType_GetFloorType(&play->colCtx, sp78, sp74) != FLOOR_TYPE_6) && (func_8002F9EC(play, &this->actor, sp78, sp74, &sp5C) == 0)) { if (this->heldItemActionParam == PLAYER_AP_HAMMER) { @@ -7769,13 +7771,13 @@ s32 func_80842DF4(PlayState* play, Player* this) { } if (this->linearVelocity >= 0.0f) { - sp48 = func_80041F10(&play->colCtx, sp78, sp74); + sp48 = SurfaceType_GetSfxType(&play->colCtx, sp78, sp74); - if (sp48 == 0xA) { + if (sp48 == SURFACE_SFX_TYPE_10) { CollisionCheck_SpawnShieldParticlesWood(play, &sp5C, &this->actor.projectedPos); } else { CollisionCheck_SpawnShieldParticles(play, &sp5C); - if (sp48 == 0xB) { + if (sp48 == SURFACE_SFX_TYPE_11) { func_8002F7DC(&this->actor, NA_SE_IT_WALL_HIT_SOFT); } else { func_8002F7DC(&this->actor, NA_SE_IT_WALL_HIT_HARD); @@ -8090,9 +8092,9 @@ static struct_80832924 D_808545F0[] = { void func_80843CEC(Player* this, PlayState* play) { if (this->currentTunic != PLAYER_TUNIC_GORON) { - if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (D_808535E4 == 9) || + if ((play->roomCtx.curRoom.behaviorType2 == ROOM_BEHAVIOR_TYPE2_3) || (D_808535E4 == FLOOR_TYPE_9) || ((func_80838144(D_808535E4) >= 0) && - !SurfaceType_IsWallDamage(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { + !func_80042108(&play->colCtx, this->actor.floorPoly, this->actor.floorBgId))) { func_8083821C(this); } } @@ -8131,7 +8133,7 @@ static FallImpactInfo D_80854600[] = { s32 func_80843E64(PlayState* play, Player* this) { s32 sp34; - if ((D_808535E4 == 6) || (D_808535E4 == 9)) { + if ((D_808535E4 == FLOOR_TYPE_6) || (D_808535E4 == FLOOR_TYPE_9)) { sp34 = 0; } else { sp34 = this->fallDistance; @@ -8175,7 +8177,7 @@ s32 func_80843E64(PlayState* play, Player* this) { func_8083264C(this, (u8)sp34, (u8)(sp34 * 0.1f), (u8)sp34, 0); - if (D_808535E4 == 6) { + if (D_808535E4 == FLOOR_TYPE_6) { func_80832698(this, NA_SE_VO_LI_CLIMB_END); } } @@ -8853,7 +8855,7 @@ void func_80845CA4(Player* this, PlayState* play) { if (this->stateFlags1 & PLAYER_STATE1_0) { sp34 = gSaveContext.entranceSpeed; - if (sConveyorSpeedIndex != 0) { + if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { this->unk_450.x = (Math_SinS(sConveyorYaw) * 400.0f) + this->actor.world.pos.x; this->unk_450.z = (Math_CosS(sConveyorYaw) * 400.0f) + this->actor.world.pos.z; } @@ -9538,7 +9540,7 @@ void func_808473D4(PlayState* play, Player* this) { !Player_IsChildWithHylianShield(this))) { if ((!(this->stateFlags1 & PLAYER_STATE1_14) && (sp20 <= 0) && (func_8008E9C4(this) || - ((D_808535E4 != 7) && + ((D_808535E4 != FLOOR_TYPE_7) && (func_80833B2C(this) || ((play->roomCtx.curRoom.behaviorType1 != ROOM_BEHAVIOR_TYPE1_2) && !(this->stateFlags1 & PLAYER_STATE1_22) && (sp20 == 0))))))) { doAction = DO_ACTION_ATTACK; @@ -9599,7 +9601,7 @@ s32 func_80847A78(Player* this) { return false; } - D_808535E4 = 0; + D_808535E4 = FLOOR_TYPE_0; this->unk_898 = this->unk_89A = D_80853610 = 0; return true; @@ -9663,25 +9665,26 @@ void func_80847BA0(PlayState* play, Player* this) { } D_80853600 = this->actor.world.pos.y - this->actor.floorHeight; - sConveyorSpeedIndex = 0; + sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; floorPoly = this->actor.floorPoly; if (floorPoly != NULL) { - this->unk_A7A = func_80041EA4(&play->colCtx, floorPoly, this->actor.floorBgId); + this->unk_A7A = SurfaceType_GetFloorProperty(&play->colCtx, floorPoly, this->actor.floorBgId); this->unk_A82 = this->unk_89E; if (this->actor.bgCheckFlags & BGCHECKFLAG_WATER) { if (this->actor.yDistToWater < 20.0f) { - this->unk_89E = 4; + this->unk_89E = SURFACE_SFX_TYPE_4; } else { - this->unk_89E = 5; + this->unk_89E = SURFACE_SFX_TYPE_5; } } else { if (this->stateFlags2 & PLAYER_STATE2_9) { - this->unk_89E = 1; + this->unk_89E = SURFACE_SFX_TYPE_1; } else { - this->unk_89E = SurfaceType_GetSfx(&play->colCtx, floorPoly, this->actor.floorBgId); + // unk_89E is a sfxType, but SurfaceType_GetSfxId returns a sfxId? + this->unk_89E = SurfaceType_GetSfxId(&play->colCtx, floorPoly, this->actor.floorBgId); } } @@ -9690,7 +9693,7 @@ void func_80847BA0(PlayState* play, Player* this) { if (this->actor.floorBgId == BGCHECK_SCENE) { Environment_ChangeLightSetting( - play, SurfaceType_GetLightSettingIndex(&play->colCtx, floorPoly, this->actor.floorBgId)); + play, SurfaceType_GetLightSetting(&play->colCtx, floorPoly, this->actor.floorBgId)); } else { DynaPoly_SetPlayerAbove(&play->colCtx, this->actor.floorBgId); } @@ -9698,15 +9701,15 @@ void func_80847BA0(PlayState* play, Player* this) { // This block extracts the conveyor properties from the floor poly sConveyorSpeedIndex = SurfaceType_GetConveyorSpeed(&play->colCtx, floorPoly, this->actor.floorBgId); - if (sConveyorSpeedIndex != 0) { + if (sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) { sIsFloorConveyor = SurfaceType_IsFloorConveyor(&play->colCtx, floorPoly, this->actor.floorBgId); if ((!sIsFloorConveyor && (this->actor.yDistToWater > 20.0f) && (this->currentBoots != PLAYER_BOOTS_IRON)) || (sIsFloorConveyor && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND))) { - sConveyorYaw = - SurfaceType_GetConveyorDirection(&play->colCtx, floorPoly, this->actor.floorBgId) * (0x10000 / 64); + sConveyorYaw = CONVEYOR_DIRECTION_TO_BINANG( + SurfaceType_GetConveyorDirection(&play->colCtx, floorPoly, this->actor.floorBgId)); } else { - sConveyorSpeedIndex = 0; + sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; } } } @@ -9736,7 +9739,7 @@ void func_80847BA0(PlayState* play, Player* this) { sp9A = this->actor.shape.rot.y - (s16)(this->actor.wallYaw + 0x8000); - D_808535F0 = func_80041DB8(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); + D_808535F0 = SurfaceType_GetWallFlags(&play->colCtx, this->actor.wallPoly, this->actor.wallBgId); D_80853608 = ABS(sp9A); @@ -9793,9 +9796,9 @@ void func_80847BA0(PlayState* play, Player* this) { if (func_80839768(play, this, &D_80854798, &sp78, &sp74, &D_80858AA8) && (temp3 = this->actor.wallYaw - Math_Atan2S(sp78->normal.z, sp78->normal.x), ABS(temp3) < 0x4000) && - !func_80041E18(&play->colCtx, sp78, sp74)) { + !SurfaceType_CheckWallFlag1(&play->colCtx, sp78, sp74)) { this->wallHeight = 399.96002f; - } else if (func_80041DE4(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { + } else if (SurfaceType_CheckWallFlag0(&play->colCtx, wallPoly, this->actor.wallBgId) == 0) { if (this->ageProperties->unk_1C <= this->wallHeight) { if (ABS(sp7C->normal.y) > 28000) { if (this->ageProperties->unk_14 <= this->wallHeight) { @@ -9829,7 +9832,7 @@ void func_80847BA0(PlayState* play, Player* this) { } if (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) { - D_808535E4 = func_80041D4C(&play->colCtx, floorPoly, this->actor.floorBgId); + D_808535E4 = SurfaceType_GetFloorType(&play->colCtx, floorPoly, this->actor.floorBgId); if (!func_80847A78(this)) { f32 floorPolyNormalX; @@ -10112,8 +10115,16 @@ static s8 D_808547C4[] = { static Vec3f D_80854814 = { 0.0f, 0.0f, 200.0f }; -static f32 sWaterConveyorSpeeds[] = { 2.0f, 4.0f, 7.0f }; -static f32 sFloorConveyorSpeeds[] = { 0.5f, 1.0f, 3.0f }; +static f32 sWaterConveyorSpeeds[CONVEYOR_SPEED_MAX - 1] = { + 2.0f, // CONVEYOR_SPEED_SLOW + 4.0f, // CONVEYOR_SPEED_MEDIUM + 7.0f, // CONVEYOR_SPEED_FAST +}; +static f32 sFloorConveyorSpeeds[CONVEYOR_SPEED_MAX - 1] = { + 0.5f, // CONVEYOR_SPEED_SLOW + 1.0f, // CONVEYOR_SPEED_MEDIUM + 3.0f, // CONVEYOR_SPEED_FAST +}; void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { s32 pad; @@ -10238,7 +10249,7 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } if (!(this->skelAnime.moveFlags & 0x80)) { - if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (D_808535E4 == 5) && + if (((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) && (D_808535E4 == FLOOR_TYPE_5) && (this->currentBoots != PLAYER_BOOTS_IRON)) || ((this->currentBoots == PLAYER_BOOTS_HOVER) && !(this->stateFlags1 & (PLAYER_STATE1_27 | PLAYER_STATE1_29)))) { @@ -10285,8 +10296,8 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { func_8002D7EC(&this->actor); func_80847BA0(play, this); } else { - D_808535E4 = 0; - this->unk_A7A = 0; + D_808535E4 = FLOOR_TYPE_0; + this->unk_A7A = FLOOR_PROPERTY_0; if (!(this->stateFlags1 & PLAYER_STATE1_0) && (this->stateFlags1 & PLAYER_STATE1_23)) { EnHorse* rideActor = (EnHorse*)this->rideActor; @@ -10310,12 +10321,12 @@ void Player_UpdateCommon(Player* this, PlayState* play, Input* input) { } } - sConveyorSpeedIndex = 0; + sConveyorSpeedIndex = CONVEYOR_SPEED_DISABLED; this->pushedSpeed = 0.0f; } // This block applies the bg conveyor to pushedSpeed - if ((sConveyorSpeedIndex != 0) && (this->currentBoots != PLAYER_BOOTS_IRON)) { + if ((sConveyorSpeedIndex != CONVEYOR_SPEED_DISABLED) && (this->currentBoots != PLAYER_BOOTS_IRON)) { f32 conveyorSpeed; // converts 1-index to 0-index @@ -11406,7 +11417,7 @@ void func_8084C5F8(Player* this, PlayState* play) { sp24.y = this->actor.world.pos.y + 20.0f; sp24.z = this->actor.world.pos.z; if (BgCheck_EntityRaycastFloor3(&play->colCtx, &sp34, &sp30, &sp24) != 0.0f) { - this->unk_89E = func_80041F10(&play->colCtx, sp34, sp30); + this->unk_89E = SurfaceType_GetSfxType(&play->colCtx, sp34, sp30); func_808328A0(this); } } @@ -12617,7 +12628,7 @@ void func_8084F390(Player* this, PlayState* play) { sp4C = (sp50 * sp50) * 0.015f; sp48 = slopeNormal.y * 0.01f; - if (SurfaceType_GetSlope(&play->colCtx, floorPoly, this->actor.floorBgId) != 1) { + if (SurfaceType_GetFloorEffect(&play->colCtx, floorPoly, this->actor.floorBgId) != FLOOR_EFFECT_1) { sp50 = 0; sp48 = slopeNormal.y * 10.0f; }