1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-11 03:39:59 +00:00

SURFACETYPE0/1 getter macros

This commit is contained in:
Dragorn421 2022-06-21 11:48:48 +02:00
parent 5dda2f9ffc
commit e61cccf2e6
No known key found for this signature in database
GPG key ID: 32B53D2D16FC4118
2 changed files with 103 additions and 21 deletions

View file

@ -87,11 +87,93 @@ typedef struct {
// 0x0000_00FF = BgCam Index
} WaterBox; // size = 0x10
// SurfaceType.data[0]
#define SURFACETYPE0_BGCAMINDEX_SHIFT 0
#define SURFACETYPE0_BGCAMINDEX_MASK 0x000000FF
#define SURFACETYPE0_BGCAMINDEX(data0) \
(((data0) >> SURFACETYPE0_BGCAMINDEX_SHIFT) & (SURFACETYPE0_BGCAMINDEX_MASK >> SURFACETYPE0_BGCAMINDEX_SHIFT))
#define SURFACETYPE0_SCENEEXITINDEX_SHIFT 8
#define SURFACETYPE0_SCENEEXITINDEX_MASK 0x00001F00
#define SURFACETYPE0_SCENEEXITINDEX(data0) \
(((data0) >> SURFACETYPE0_SCENEEXITINDEX_SHIFT) & \
(SURFACETYPE0_SCENEEXITINDEX_MASK >> SURFACETYPE0_SCENEEXITINDEX_SHIFT))
#define SURFACETYPE0_13_SHIFT 13
#define SURFACETYPE0_13_MASK 0x0003E000
#define SURFACETYPE0_13(data0) (((data0) >> SURFACETYPE0_13_SHIFT) & (SURFACETYPE0_13_MASK >> SURFACETYPE0_13_SHIFT))
#define SURFACETYPE0_18_SHIFT 18
#define SURFACETYPE0_18_MASK 0x001C0000
#define SURFACETYPE0_18(data0) (((data0) >> SURFACETYPE0_18_SHIFT) & (SURFACETYPE0_18_MASK >> SURFACETYPE0_18_SHIFT))
#define SURFACETYPE0_21_SHIFT 21
#define SURFACETYPE0_21_MASK 0x03E00000
#define SURFACETYPE0_21(data0) (((data0) >> SURFACETYPE0_21_SHIFT) & (SURFACETYPE0_21_MASK >> SURFACETYPE0_21_SHIFT))
#define SURFACETYPE0_FLOORPROPERTY_SHIFT 26
#define SURFACETYPE0_FLOORPROPERTY_MASK 0x3C000000
#define SURFACETYPE0_FLOORPROPERTY(data0) \
(((data0) >> SURFACETYPE0_FLOORPROPERTY_SHIFT) & \
(SURFACETYPE0_FLOORPROPERTY_MASK >> SURFACETYPE0_FLOORPROPERTY_SHIFT))
#define SURFACETYPE0_30_SHIFT 30
#define SURFACETYPE0_30_MASK 0x40000000
#define SURFACETYPE0_30(data0) (((data0) >> SURFACETYPE0_30_SHIFT) & (SURFACETYPE0_30_MASK >> SURFACETYPE0_30_SHIFT))
#define SURFACETYPE0_ISHORSEBLOCKED_SHIFT 31
#define SURFACETYPE0_ISHORSEBLOCKED_MASK 0x80000000
#define SURFACETYPE0_ISHORSEBLOCKED(data0) \
(((data0) >> SURFACETYPE0_ISHORSEBLOCKED_SHIFT) & \
(SURFACETYPE0_ISHORSEBLOCKED_MASK >> SURFACETYPE0_ISHORSEBLOCKED_SHIFT))
// SurfaceType.data[1]
#define SURFACETYPE1_0_SHIFT 0
#define SURFACETYPE1_0_MASK 0x0000000F
#define SURFACETYPE1_0(data1) (((data1) >> SURFACETYPE1_0_SHIFT) & (SURFACETYPE1_0_MASK >> SURFACETYPE1_0_SHIFT))
#define SURFACETYPE1_SLOPE_SHIFT 4
#define SURFACETYPE1_SLOPE_MASK 0x00000030
#define SURFACETYPE1_SLOPE(data1) \
(((data1) >> SURFACETYPE1_SLOPE_SHIFT) & (SURFACETYPE1_SLOPE_MASK >> SURFACETYPE1_SLOPE_SHIFT))
#define SURFACETYPE1_LIGHTSETTINGINDEX_SHIFT 6
#define SURFACETYPE1_LIGHTSETTINGINDEX_MASK 0x000007C0
#define SURFACETYPE1_LIGHTSETTINGINDEX(data1) \
(((data1) >> SURFACETYPE1_LIGHTSETTINGINDEX_SHIFT) & \
(SURFACETYPE1_LIGHTSETTINGINDEX_MASK >> SURFACETYPE1_LIGHTSETTINGINDEX_SHIFT))
#define SURFACETYPE1_ECHO_SHIFT 11
#define SURFACETYPE1_ECHO_MASK 0x0001F800
#define SURFACETYPE1_ECHO(data1) \
(((data1) >> SURFACETYPE1_ECHO_SHIFT) & (SURFACETYPE1_ECHO_MASK >> SURFACETYPE1_ECHO_SHIFT))
#define SURFACETYPE1_ISHOOKSHOTSURFACE_SHIFT 17
#define SURFACETYPE1_ISHOOKSHOTSURFACE_MASK 0x00020000
#define SURFACETYPE1_ISHOOKSHOTSURFACE(data1) \
(((data1) >> SURFACETYPE1_ISHOOKSHOTSURFACE_SHIFT) & \
(SURFACETYPE1_ISHOOKSHOTSURFACE_MASK >> SURFACETYPE1_ISHOOKSHOTSURFACE_SHIFT))
#define SURFACETYPE1_CONVEYORSPEED_SHIFT 18
#define SURFACETYPE1_CONVEYORSPEED_MASK 0x001C0000
#define SURFACETYPE1_CONVEYORSPEED(data1) \
(((data1) >> SURFACETYPE1_CONVEYORSPEED_SHIFT) & \
(SURFACETYPE1_CONVEYORSPEED_MASK >> SURFACETYPE1_CONVEYORSPEED_SHIFT))
#define SURFACETYPE1_CONVEYORDIRECTION_SHIFT 21
#define SURFACETYPE1_CONVEYORDIRECTION_MASK 0x07E00000
#define SURFACETYPE1_CONVEYORDIRECTION(data1) \
(((data1) >> SURFACETYPE1_CONVEYORDIRECTION_SHIFT) & \
(SURFACETYPE1_CONVEYORDIRECTION_MASK >> SURFACETYPE1_CONVEYORDIRECTION_SHIFT))
#define SURFACETYPE1_WALLDAMAGE_SHIFT 27
#define SURFACETYPE1_WALLDAMAGE_FLAG (1 << SURFACETYPE1_WALLDAMAGE_SHIFT)
#define SURFACETYPE1_WALLDAMAGE(data1) ((data1) & SURFACETYPE1_WALLDAMAGE_FLAG ? true : false)
typedef struct {
u32 data[2];
// Type 1
// 0x0800_0000 = wall damage
} SurfaceType;
typedef struct {

View file

@ -623,7 +623,7 @@ s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* pol
}
surfaceData = colCtx->colHeader->surfaceTypeList[wallPoly->type].data[1];
wallDamage = surfaceData & 0x08000000 ? 1 : 0;
wallDamage = SURFACETYPE1_WALLDAMAGE(surfaceData);
if (!wallDamage) {
*wallPolyPtr = poly;
@ -3836,7 +3836,7 @@ u32 SurfaceType_GetData(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId,
* SurfaceType get index of bgCam
*/
u32 SurfaceType_GetBgCamIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) & 0xFF;
return SURFACETYPE0_BGCAMINDEX(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
@ -3975,28 +3975,28 @@ Vec3s* BgCheck_GetBgCamFuncData(CollisionContext* colCtx, CollisionPoly* poly, s
* SurfaceType Get Scene Exit Index
*/
u32 SurfaceType_GetSceneExitIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 8 & 0x1F;
return SURFACETYPE0_SCENEEXITINDEX(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Get ? Property (& 0x0003 E000)
*/
u32 func_80041D4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 13 & 0x1F;
return SURFACETYPE0_13(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Get ? Property (& 0x001C 0000)
*/
u32 func_80041D70(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 18 & 7;
return SURFACETYPE0_18(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Get Wall Property (Internal)
*/
u32 func_80041D94(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 21 & 0x1F;
return SURFACETYPE0_21(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
@ -4031,32 +4031,32 @@ s32 func_80041E4C(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
* unused
*/
u32 func_80041E80(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF;
return SURFACETYPE0_FLOORPROPERTY(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Get Floor Property
*/
u32 func_80041EA4(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 26 & 0xF;
return SURFACETYPE0_FLOORPROPERTY(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Is Floor Minus 1
*/
u32 func_80041EC8(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 30 & 1;
return SURFACETYPE0_30(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
/**
* SurfaceType Is Horse Blocked
*/
u32 SurfaceType_IsHorseBlocked(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 0) >> 31 & 1;
return SURFACETYPE0_ISHORSEBLOCKED(SurfaceType_GetData(colCtx, poly, bgId, 0));
}
u32 func_80041F10(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) & 0xF;
return SURFACETYPE1_0(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
@ -4075,28 +4075,28 @@ u16 SurfaceType_GetSfx(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId)
* SurfaceType get terrain slope surface
*/
u32 SurfaceType_GetSlope(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 4 & 3;
return SURFACETYPE1_SLOPE(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
* SurfaceType get surface lighting setting
*/
u32 SurfaceType_GetLightSettingIndex(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 6 & 0x1F;
return SURFACETYPE1_LIGHTSETTINGINDEX(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
* SurfaceType get echo
*/
u32 SurfaceType_GetEcho(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 11 & 0x3F;
return SURFACETYPE1_ECHO(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
* SurfaceType Is Hookshot Surface
*/
u32 SurfaceType_IsHookshotSurface(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 17 & 1;
return SURFACETYPE1_ISHOOKSHOTSURFACE(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
@ -4150,7 +4150,7 @@ s32 SurfaceType_IsFloorConveyor(CollisionContext* colCtx, CollisionPoly* poly, s
* SurfaceType Get Conveyor Surface Speed
*/
u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return SurfaceType_GetData(colCtx, poly, bgId, 1) >> 18 & 7;
return SURFACETYPE1_CONVEYORSPEED(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
@ -4158,14 +4158,14 @@ u32 SurfaceType_GetConveyorSpeed(CollisionContext* colCtx, CollisionPoly* poly,
* 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;
return SURFACETYPE1_CONVEYORDIRECTION(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**
* SurfaceType is Wall Damage
*/
u32 SurfaceType_IsWallDamage(CollisionContext* colCtx, CollisionPoly* poly, s32 bgId) {
return (SurfaceType_GetData(colCtx, poly, bgId, 1) & 0x8000000) ? 1 : 0;
return SURFACETYPE1_WALLDAMAGE(SurfaceType_GetData(colCtx, poly, bgId, 1));
}
/**