How sm64dx’s Object struct, rawData union, ObjectHitbox, and BehaviorScript arrays give every enemy, platform, and pickup its own per-frame scripted logic.
Use this file to discover all available pages before exploring further.
Every interactive entity in sm64dx—enemies, platforms, coins, NPCs, environmental effects—is an instance of struct Object. Each object carries a BehaviorScript pointer that points to a compact byte-code array interpreted every frame by the behavior script engine. The same Object struct is reused for every type of game entity; per-type data lives in a large rawData union accessed through named macros, keeping the struct a fixed size regardless of how many fields a given object type actually uses.
Object is defined in include/types.h. It begins with an ObjectNode header that embeds a GraphNodeObject (the scene-graph node), then provides the rawData union for per-type fields, and finally a block of fixed fields for hitbox geometry and the behavior interpreter state.
On 64-bit host builds (PC ports), pointer-sized fields move into a separate ptrData union at 0x1C8 and the fixed fields shift accordingly, but the layout of rawData scalars is unchanged.
ObjectHitbox is a convenience struct for initialising an object’s collision dimensions and interaction type in one call. The real hitbox values live as individual f32 fields on Object; obj_set_hitbox() copies from this struct into those fields.
struct ObjectHitbox { /*0x00*/ u32 interactType; // INTERACT_* constant (what happens on contact) /*0x04*/ u8 downOffset; // downward hitbox offset from object origin /*0x05*/ s8 damageOrCoinValue; // damage dealt to Mario, or coin value if pickup /*0x06*/ s8 health; // initial health points /*0x07*/ s8 numLootCoins; // coins spawned on defeat /*0x08*/ s16 radius; // hitbox radius (cylinder) /*0x0A*/ s16 height; // hitbox height /*0x0C*/ s16 hurtboxRadius; // inner hurtbox radius (where Mario takes damage) /*0x0E*/ s16 hurtboxHeight; // inner hurtbox height};
INTERACT_BOUNCE_TOP means Mario bounces when jumping on this object. The hurtbox (42 × 40) is smaller than the hitbox (72 × 50), so a walking hit damages Mario while a precise top-bounce kills the Goomba.
The rawData union occupies 80 (0x50) slots, each 4 bytes wide. Every object type claims a subset of these slots for its own purposes. Named macros in include/object_fields.h map human-readable names to slot indices:
A BehaviorScript is an array of uintptr_t words terminated by a BEGIN/END pair. The behavior script engine (in src/engine/behavior_script.c) processes one or more commands per frame until it hits a command that yields (BREAK, DELAY, LOOP) or ends the script.
typedef uintptr_t BehaviorScript;// From Object:const BehaviorScript *curBhvCommand; // current "program counter"u32 bhvStackIndex; // depth of the call stackuintptr_t bhvStack[8]; // return addresses for CALL/RETURNs16 bhvDelayTimer; // countdown for DELAY commandsconst BehaviorScript *behavior; // start of the behavior (for reset)
Macro commands in include/behavior_data.h assemble the word-level bytecode:
// Conceptual behavior structure (macro-assembled):const BehaviorScript bhvGoomba[] = { BEGIN(/*object list*/ OBJ_LIST_GENACTOR), OR_INT(oFlags, OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE), BEGIN_REPEAT(4), CALL_NATIVE(bhv_goomba_init), // runs once on spawn END_REPEAT(), BEGIN_LOOP(), CALL_NATIVE(bhv_goomba_loop), // runs every frame END_LOOP(),};
CALL_NATIVE stores a C function pointer in the behavior word; the interpreter casts it and calls it directly. This is how the .inc.c files in src/game/behaviors/ connect to the byte-code.
The src/game/behaviors/ directory contains 226 .inc.c files. They fall into the following broad categories:
Enemies
goomba.inc.c, bowser.inc.c, koopa.inc.c, boo.inc.c, bully.inc.c, whomp.inc.c, thwomp.inc.c, piranha_plant.inc.c, fly_guy.inc.c, amp.inc.c, and many more. Each defines init/loop functions and a static ObjectHitbox.
Platforms and environmental
rotating_platform.inc.c, seesaw_platform.inc.c, tilting_inverted_pyramid.inc.c, elevator.inc.c, donut_platform.inc.c, checkerboard_platform.inc.c, and level-specific platforms like ttc_treadmill.inc.c and lll_sinking_rock_block.inc.c.
king_bobomb.inc.c, mips.inc.c, yoshi.inc.c, hoot.inc.c, dorrie.inc.c, racing_penguin.inc.c, tuxie.inc.c, and warp/dialog objects like warp.inc.c, door.inc.c, and cannon.inc.c.
All .inc.c files are #included into data/behavior_data.c, which is the single translation unit compiled into the behavior segment. This is why they use the .inc.c extension rather than .c—they are not compiled independently.