Every interactive entity in SM64 is aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/n64decomp/sm64/llms.txt
Use this file to discover all available pages before exploring further.
struct Object. The bulk of that struct — bytes 0x088 through 0x1C7 — is a union called rawData that holds 0x50 (80) slots of object-specific data. Behavior scripts and C code access these slots through named #define constants declared in include/object_fields.h. Understanding how these field names map to the underlying union is the key to reading any behavior file in the repository.
The rawData union
struct Object is defined in include/types.h. Its variant data section is:
0x50 * 4 = 320 bytes (0x088–0x1C7). Each slot is four bytes wide and may be read as u32, s32, two s16 sub-slots, f32, or a pointer.
On 64-bit host builds (PC ports), pointer-type fields are moved into a separate
ptrData union so that the 32-bit rawData slots retain their original sizes. The accessor macros handle this transparently.Accessor macros
include/object_fields.h defines a family of macros that expand differently depending on whether the code is being compiled for indexing (OBJECT_FIELDS_INDEX_DIRECTLY) or for the actual struct:
Field naming convention
All shared object field names begin with a lowercaseo prefix (for “object”), followed by a descriptive CamelCase name:
oFlags,oTimer,oAction— general stateoPosX,oPosY,oPosZ— positionoVelX,oVelY,oVelZ— velocityoMoveAngleYaw,oFaceAngleYaw— angles
o prefix but include the object type: oBooBaseScale, oGoombaWalkTimer, oChainChompSegments, and so on.
Common fields reference
The fields below are present in (or meaningful for) nearly every active object. Slot indices in comments are the raw hex indices intorawData.
Behaviour and state
Bitmask controlling the object update system’s per-frame operations. Common bits:
| Constant | Value | Effect |
|---|---|---|
OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE | 0x00000001 | Sync graphic node position/angle each frame |
OBJ_FLAG_MOVE_XZ_USING_FVEL | 0x00000002 | Apply oForwardVel in the XZ plane |
OBJ_FLAG_MOVE_Y_WITH_TERMINAL_VEL | 0x00000004 | Apply gravity with terminal velocity cap |
OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW | 0x00000008 | Copy move yaw to face yaw |
OBJ_FLAG_COMPUTE_DIST_TO_MARIO | 0x00000040 | Update oDistanceToMario each frame |
OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO | 0x00002000 | Update oAngleToMario each frame |
OBJ_FLAG_HOLDABLE | 0x00000400 | Mario can pick this object up |
General-purpose timer incremented by 1 every frame the object is active. Behavior scripts reset this with
SET_INT(oTimer, 0) when entering a new action.Current action state. Behavior scripts switch on this to implement state machines.
Previous action; written automatically when
oAction changes via SET_INT.Secondary action state for objects with two-level state machines (e.g., an enemy that is both
ACT_CHASE and ACT_CHASE_TURN).The full 32-bit behavior parameter word, typically set by the object placement macro or level script. The upper byte is the most common parameter byte read in behaviors.
The second byte of
oBhvParams, extracted and sign-extended to s32 for convenience. Used so frequently it has its own name.Position and velocity
World-space position. These are read by the graphics engine each frame to position the model (when
OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE is set). O_POS_INDEX = 0x06 is the base slot; the three fields occupy consecutive slots.World-space velocity components, applied directly to the position each frame by the physics engine.
Speed along the object’s current move-angle yaw direction. The flag
OBJ_FLAG_MOVE_XZ_USING_FVEL converts this into oVelX / oVelZ each frame. Also aliased as oForwardVelS32 (same slot, s32 view).Lateral (strafing) velocity component.
Vertical velocity component used by some objects instead of
oVelY.Spawn / home position. Many enemies return to these coordinates when idle.
Angles
All angles are stored ass32 (sign-extended from s16 BAM units).
The direction in which the object moves.
oForwardVel is applied along oMoveAngleYaw. Base index O_MOVE_ANGLE_INDEX = 0x0F.The direction the object’s model faces visually. Base index
O_FACE_ANGLE_INDEX = 0x12. The flag OBJ_FLAG_SET_FACE_YAW_TO_MOVE_YAW keeps move and face yaw in sync automatically.Per-frame rotation speed added to the corresponding face angle by the spinning/tumbling physics.
Yaw angle (in BAM units) from this object toward Mario. Updated automatically when
OBJ_FLAG_COMPUTE_ANGLE_TO_MARIO is set.Yaw angle from this object toward its home position.
Physics
Per-frame downward acceleration applied to
oVelY. Negative values pull the object down.Y coordinate of the floor directly beneath the object, updated by the collision system.
Bitmask of movement state flags updated every frame:
| Constant | Value | Meaning |
|---|---|---|
OBJ_MOVE_LANDED | 0x0001 | Just hit the ground this frame |
OBJ_MOVE_ON_GROUND | 0x0002 | Resting on the floor |
OBJ_MOVE_LEFT_GROUND | 0x0004 | Left the floor this frame |
OBJ_MOVE_ENTERED_WATER | 0x0008 | Entered a water body |
OBJ_MOVE_AT_WATER_SURFACE | 0x0010 | At the water surface |
OBJ_MOVE_UNDERWATER_ON_GROUND | 0x0040 | On the floor underwater |
OBJ_MOVE_IN_AIR | 0x0080 | Airborne |
OBJ_MOVE_HIT_WALL | 0x0200 | Collided with a wall |
OBJ_MOVE_ABOVE_LAVA | 0x0800 | Over a lava surface |
Pointer to the
Surface triangle beneath the object. Filled in by the collision system.Surface type constant of the floor triangle below (e.g.,
SURFACE_BURNING). Extracted from oFloor->type by the physics system for convenience.Room index of the floor triangle below.
Yaw angle of the last wall the object collided with.
Coefficient applied to
oVelY on a floor bounce. 1.0 = perfectly elastic.Horizontal speed multiplier applied per frame on the ground (typically
< 1.0 to decelerate).Upward force applied while the object is underwater.
Air/water drag:
forwardVel is multiplied by (1 - oDragStrength) each frame.Interaction and hitbox
Bitmask describing what kind of interaction this object presents to Mario (e.g., coin, enemy, hold-able object). See
INTERACT_* constants in object_constants.h.Set by the interaction system to indicate what happened (e.g.,
INT_STATUS_HIT_MARIO). Cleared after the behavior processes it.Additional flags qualifying the interaction (e.g., which cap this pickup awards).
When this object damages Mario: the amount of health to subtract. When it is a coin: the coin value. Also referred to via the
ObjectHitbox struct’s damageOrCoinValue field.Number of coins spawned when this object is defeated.
The object’s hit points. Decremented by
INT_PUNCH / INT_KICK interactions.Visibility and rendering
Vertical rendering offset added to
oPosY for the graphic node, without affecting collision. Useful for bobbing effects.Alpha value in the range 0–255. Passed to the RSP to blend the object’s model.
Objects whose distance to the camera exceeds this value are culled.
The radius at which the object’s collision sphere is checked against Mario.
Radius used for wall-collision checks against other objects.
Room and distance tracking
Room index the object currently occupies (from
RoomData). The object is culled when Mario is in a different room and ACTIVE_FLAG_IN_DIFFERENT_ROOM is set.Euclidean distance from this object to Mario. Updated each frame when
OBJ_FLAG_COMPUTE_DIST_TO_MARIO is set.Misc
Selects which animation variant to play (maps to an index in the object’s animation list).
Pointer to the object’s animation list (array of
struct Animation *).Whether Mario is holding this object. Values:
HELD_FREE (0), HELD_HELD (1), HELD_THROWN (2), HELD_DROPPED (3).Sound effect ID to play when this object is defeated.
When non-zero, the object cannot be interacted with. Decremented each frame.
Accessing object fields
rawData and ptrData automatically.
Object-specific fields
The region0x0F4–0x110 (slots 0x1B–0x22) and 0x1AC–0x1B4 (slots 0x49–0x4A) are not part of the common field set. Each object type uses them for its own purpose. For example:
include/object_fields.h for the complete list, organized by object type.
The first slot (0x00 / 0x088)
Slot0x00 at offset 0x088 is reserved for object-type-specific use and is not part of the common fields. Some objects use it for a primary state value: