Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Functions | Variables
object_list_processor.c File Reference
#include <ultra64.h>
#include "sm64.h"
#include "behavior_data.h"
#include "engine/behavior_script.h"
#include "area.h"
#include "camera.h"
#include "engine/graph_node.h"
#include "interaction.h"
#include "debug.h"
#include "profiler.h"
#include "spawn_object.h"
#include "engine/surface_collision.h"
#include "memory.h"
#include "level_update.h"
#include "object_collision.h"
#include "object_helpers.h"
#include "platform_displacement.h"
#include "engine/surface_load.h"
#include "room.h"
#include "object_list_processor.h"
#include "mario.h"

Data Structures

struct  ParticleProperties
 Info needed to spawn particles and keep track of which have been spawned for an object. More...
 

Functions

void copy_mario_state_to_object (void)
 Copy position, velocity, and angle variables from MarioState to the mario object. More...
 
void spawn_particle (u32 activeParticleFlag, s16 model, void *behavior)
 Spawn a particle at gCurrentObject's location. More...
 
void bhv_mario_update (void)
 Mario's primary behavior update function. More...
 
s32 update_objects_starting_at (struct ObjectNode *objList, struct ObjectNode *firstObj)
 Update every object that occurs after firstObj in the given object list, including firstObj itself. More...
 
s32 update_objects_during_time_stop (struct ObjectNode *objList, struct ObjectNode *firstObj)
 Update objects in objList starting with firstObj while time stop is active. More...
 
s32 update_objects_in_list (struct ObjectNode *objList)
 Update every object in the given list. More...
 
s32 unload_deactivated_objects_in_list (struct ObjectNode *objList)
 Unload any objects in the list that have been deactivated. More...
 
void set_object_respawn_info_bits (struct Object *obj, u8 bits)
 OR the object's respawn info with bits << 8. More...
 
void unload_objects_from_area (UNUSED s32 unused, s32 areaIndex)
 Unload all objects whose activeAreaIndex is areaIndex. More...
 
void spawn_objects_from_info (UNUSED s32 unused, struct SpawnInfo *spawnInfo)
 Spawn objects given a list of SpawnInfos. More...
 
void stub_8029CA50 ()
 
void clear_objects (void)
 Clear objects, dynamic surfaces, and some miscellaneous level data used by objects. More...
 
void update_terrain_objects (void)
 Update spawner and surface objects. More...
 
void update_non_terrain_objects (void)
 Update all other object lists besides spawner and surface objects, using the order specified by sObjectListUpdateOrder. More...
 
void unload_deactivated_objects (void)
 Unload deactivated objects in any object list. More...
 
static u16 unused_get_elapsed_time (u64 *cycleCounts, s32 index)
 Unused profiling function. More...
 
void update_objects (UNUSED s32 unused)
 Update all objects. More...
 

Variables

struct ObjectNode gObjectListArray [16]
 Nodes used to represent the doubly linked object lists. More...
 
s32 gDebugInfoFlags
 Flags controlling what debug info is displayed. More...
 
s32 gNumFindFloorMisses
 The number of times per frame find_floor found no floor beneath an object, and therefore either returned a dynamic floor or NULL. More...
 
UNUSED s32 unused_8033BEF8
 
s32 gUnknownWallCount
 An unused debug counter with the label "WALL". More...
 
u32 gObjectCounter
 Roughly the number of objects that have been processed this frame so far. More...
 
struct NumTimesCalled gNumCalls
 The number of times find_floor, find_ceil, and find_wall_collisions have been called respectively. More...
 
s16 gDebugInfo [16][8]
 An array of debug controls that could be used to tweak in-game parameters. More...
 
s16 gDebugInfoOverwrite [16][8]
 
u32 gTimeStopState
 A set of flags to control which objects are updated on a given frame. More...
 
struct Object gObjectPool [OBJECT_POOL_CAPACITY]
 The pool that objects are allocated from. More...
 
struct Object gMacroObjectDefaultParent
 A special object whose purpose is to act as a parent for macro objects. More...
 
struct ObjectNodegObjectLists
 A pointer to gObjectListArray. More...
 
struct ObjectNode gFreeObjectList
 A singly linked list of available slots in the object pool. More...
 
struct ObjectgMarioObject
 The object representing mario. More...
 
struct ObjectgLuigiObject
 An object variable that may have been used to represent the planned second player. More...
 
struct ObjectgCurrentObject
 The object whose behavior script is currently being updated. More...
 
u32gBehCommand
 The next object behavior command to be executed. More...
 
s16 gPrevFrameObjectCount
 The number of objects that were processed last frame, which may miss some objects that were spawned last frame and all objects that were spawned this frame. More...
 
s32 gSurfaceNodesAllocated
 The total number of surface nodes allocated (a node is allocated for each spatial partition cell that a surface intersects). More...
 
s32 gSurfacesAllocated
 The total number of surfaces allocated. More...
 
s32 gNumStaticSurfaceNodes
 The number of nodes that have been created for surfaces. More...
 
s32 gNumStaticSurfaces
 The number of surfaces in the pool. More...
 
struct MemoryPoolgObjectMemoryPool
 A pool used by chain chomp and wiggler to allocate their body parts. More...
 
s8 sObjectListUpdateOrder []
 The order that object lists are processed in a frame. More...
 
struct ParticleProperties sParticleTypes []
 A table mapping particle flags to various properties use when spawning a particle. More...
 

Function Documentation

◆ bhv_mario_update()

void bhv_mario_update ( void  )

Mario's primary behavior update function.

◆ clear_objects()

void clear_objects ( void  )

Clear objects, dynamic surfaces, and some miscellaneous level data used by objects.

◆ copy_mario_state_to_object()

void copy_mario_state_to_object ( void  )

Copy position, velocity, and angle variables from MarioState to the mario object.

◆ set_object_respawn_info_bits()

void set_object_respawn_info_bits ( struct Object obj,
u8  bits 
)

OR the object's respawn info with bits << 8.

If bits = 0xFF, this prevents the object from respawning after leaving and re-entering the area. For macro objects, respawnInfo points to the 16 bit entry in the macro object list. For other objects, it points to the 32 bit behaviorArg in the SpawnInfo.

◆ spawn_objects_from_info()

void spawn_objects_from_info ( UNUSED s32  unused,
struct SpawnInfo spawnInfo 
)

Spawn objects given a list of SpawnInfos.

Called when loading an area.

(Spawning Displacement) On the Japanese version, mario's platform object

◆ spawn_particle()

void spawn_particle ( u32  activeParticleFlag,
s16  model,
void behavior 
)

Spawn a particle at gCurrentObject's location.

◆ stub_8029CA50()

void stub_8029CA50 ( )

◆ unload_deactivated_objects()

void unload_deactivated_objects ( void  )

Unload deactivated objects in any object list.

◆ unload_deactivated_objects_in_list()

s32 unload_deactivated_objects_in_list ( struct ObjectNode objList)

Unload any objects in the list that have been deactivated.

◆ unload_objects_from_area()

void unload_objects_from_area ( UNUSED s32  unused,
s32  areaIndex 
)

Unload all objects whose activeAreaIndex is areaIndex.

◆ unused_get_elapsed_time()

static u16 unused_get_elapsed_time ( u64 cycleCounts,
s32  index 
)
static

Unused profiling function.

◆ update_non_terrain_objects()

void update_non_terrain_objects ( void  )

Update all other object lists besides spawner and surface objects, using the order specified by sObjectListUpdateOrder.

◆ update_objects()

void update_objects ( UNUSED s32  unused)

Update all objects.

This includes script execution, object collision detection, and object surface management.

If the platform object unloaded and a different object took its place,

◆ update_objects_during_time_stop()

s32 update_objects_during_time_stop ( struct ObjectNode objList,
struct ObjectNode firstObj 
)

Update objects in objList starting with firstObj while time stop is active.

This means that only certain select objects will be updated, such as mario, doors, unimportant objects, and the object that initiated time stop. The exact set of objects that are updated depends on which flags are set in gTimeStopState. Return the total number of objects in the list (including those that weren't updated)

◆ update_objects_in_list()

s32 update_objects_in_list ( struct ObjectNode objList)

Update every object in the given list.

Return the total number of objects in the list.

◆ update_objects_starting_at()

s32 update_objects_starting_at ( struct ObjectNode objList,
struct ObjectNode firstObj 
)

Update every object that occurs after firstObj in the given object list, including firstObj itself.

Return the number of objects that were updated.

◆ update_terrain_objects()

void update_terrain_objects ( void  )

Update spawner and surface objects.

This was meant to be +=

Variable Documentation

◆ gBehCommand

u32* gBehCommand

The next object behavior command to be executed.

◆ gCurrentObject

struct Object* gCurrentObject

The object whose behavior script is currently being updated.

This object is used frequently in object behavior code, and so is often aliased as "o".

◆ gDebugInfo

s16 gDebugInfo[16][8]

An array of debug controls that could be used to tweak in-game parameters.

The only used rows are [4] and [5] (effectinfo and enemyinfo).

◆ gDebugInfoFlags

s32 gDebugInfoFlags

Flags controlling what debug info is displayed.

◆ gDebugInfoOverwrite

s16 gDebugInfoOverwrite[16][8]

◆ gFreeObjectList

struct ObjectNode gFreeObjectList

A singly linked list of available slots in the object pool.

◆ gLuigiObject

struct Object* gLuigiObject

An object variable that may have been used to represent the planned second player.

This is speculation, based on its position and its usage in shadow.c.

◆ gMacroObjectDefaultParent

struct Object gMacroObjectDefaultParent

A special object whose purpose is to act as a parent for macro objects.

◆ gMarioObject

struct Object* gMarioObject

The object representing mario.

◆ gNumCalls

The number of times find_floor, find_ceil, and find_wall_collisions have been called respectively.

◆ gNumFindFloorMisses

s32 gNumFindFloorMisses

The number of times per frame find_floor found no floor beneath an object, and therefore either returned a dynamic floor or NULL.

◆ gNumStaticSurfaceNodes

s32 gNumStaticSurfaceNodes

The number of nodes that have been created for surfaces.

◆ gNumStaticSurfaces

s32 gNumStaticSurfaces

The number of surfaces in the pool.

◆ gObjectCounter

u32 gObjectCounter

Roughly the number of objects that have been processed this frame so far.

A bug in update_terrain_objects makes this count inaccurate.

◆ gObjectListArray

struct ObjectNode gObjectListArray[16]

Nodes used to represent the doubly linked object lists.

◆ gObjectLists

struct ObjectNode* gObjectLists

A pointer to gObjectListArray.

Given an object list index idx, gObjectLists[idx] is the head of a doubly linked list of all currently spawned objects in the list.

◆ gObjectMemoryPool

struct MemoryPool* gObjectMemoryPool

A pool used by chain chomp and wiggler to allocate their body parts.

◆ gObjectPool

The pool that objects are allocated from.

◆ gPrevFrameObjectCount

s16 gPrevFrameObjectCount

The number of objects that were processed last frame, which may miss some objects that were spawned last frame and all objects that were spawned this frame.

It also includes objects that were unloaded last frame. Besides this, a bug in update_terrain_objects makes this count inaccurate.

◆ gSurfaceNodesAllocated

s32 gSurfaceNodesAllocated

The total number of surface nodes allocated (a node is allocated for each spatial partition cell that a surface intersects).

◆ gSurfacesAllocated

s32 gSurfacesAllocated

The total number of surfaces allocated.

◆ gTimeStopState

u32 gTimeStopState

A set of flags to control which objects are updated on a given frame.

This is used during dialog and cutscenes to freeze most objects in place.

◆ gUnknownWallCount

s32 gUnknownWallCount

An unused debug counter with the label "WALL".

◆ sObjectListUpdateOrder

s8 sObjectListUpdateOrder[]
Initial value:
-1 }
Definition: object_list_processor.h:52
Definition: object_list_processor.h:37
Definition: object_list_processor.h:48
Definition: object_list_processor.h:51
Definition: object_list_processor.h:32
Definition: object_list_processor.h:44
Definition: object_list_processor.h:39
Definition: object_list_processor.h:42
Definition: object_list_processor.h:46
Definition: object_list_processor.h:34

The order that object lists are processed in a frame.

◆ sParticleTypes

struct ParticleProperties sParticleTypes[]
Initial value:
= {
{ 0, 0, MODEL_NONE, NULL },
}
u32 bhvGroundSand[]
#define MODEL_WHITE_PARTICLE_SMALL
Definition: model_ids.h:492
#define ACTIVE_PARTICLE_12
Definition: object_constants.h:114
#define PARTICLE_11
Definition: sm64.h:102
u32 bhvSpecialTripleJumpSparkles[]
#define PARTICLE_17
Definition: sm64.h:108
u32 bhvWaterMistSpawn[]
#define ACTIVE_PARTICLE_18
Definition: object_constants.h:120
#define PARTICLE_12
Definition: sm64.h:103
#define PARTICLE_DUST
Definition: sm64.h:91
#define ACTIVE_PARTICLE_17
Definition: object_constants.h:119
#define PARTICLE_16
Definition: sm64.h:107
#define ACTIVE_PARTICLE_15
Definition: object_constants.h:117
u32 bhvMarioDustGenerator[]
#define MODEL_BUBBLE
Definition: model_ids.h:496
u32 bhvSurfaceWaves[]
#define ACTIVE_PARTICLE_14
Definition: object_constants.h:116
#define ACTIVE_PARTICLE_0
Definition: object_constants.h:104
#define PARTICLE_10
Definition: sm64.h:101
#define PARTICLE_15
Definition: sm64.h:106
#define PARTICLE_7
Definition: sm64.h:98
u32 bhvWaterWaves[]
#define PARTICLE_8
Definition: sm64.h:99
u32 bhvPunchTinyTriangleSpawn[]
#define ACTIVE_PARTICLE_5
Definition: object_constants.h:107
#define MODEL_MIST
Definition: model_ids.h:470
#define MODEL_RED_FLAME
Definition: model_ids.h:472
#define MODEL_NONE
Definition: model_ids.h:11
#define PARTICLE_4
Definition: sm64.h:95
#define PARTICLE_18
Definition: sm64.h:109
#define ACTIVE_PARTICLE_3
Definition: object_constants.h:105
u32 bhvWallTinyStarParticleSpawn[]
#define PARTICLE_9
Definition: sm64.h:100
#define MODEL_WATER_SPLASH
Definition: model_ids.h:495
u32 bhvFlameMario[]
u32 bhvPoundTinyStarParticleSpawn[]
#define ACTIVE_PARTICLE_8
Definition: object_constants.h:110
#define PARTICLE_SPARKLES
Definition: sm64.h:94
u32 bhvGroundSnow[]
#define ACTIVE_PARTICLE_19
Definition: object_constants.h:121
u32 bhvWaterSplash[]
#define PARTICLE_6
Definition: sm64.h:97
#define ACTIVE_PARTICLE_11
Definition: object_constants.h:113
u32 bhvSurfaceWaveShrinking[]
#define MODEL_WATER_WAVES
Definition: model_ids.h:491
#define PARTICLE_LEAVES
Definition: sm64.h:104
#define ACTIVE_PARTICLE_9
Definition: object_constants.h:111
#define ACTIVE_PARTICLE_7
Definition: object_constants.h:109
u32 bhvSnowLeafParticleSpawn[]
#define ACTIVE_PARTICLE_16
Definition: object_constants.h:118
#define PARTICLE_14
Definition: sm64.h:105
u32 bhvWaveTrailOnSurface[]
#define ACTIVE_PARTICLE_10
Definition: object_constants.h:112
#define PARTICLE_5
Definition: sm64.h:96
#define MODEL_SPARKLES
Definition: model_ids.h:477
u32 bhvPoundWhitePuffs[]
u32 bhvBubbleMario[]
#define PARTICLE_1
Definition: sm64.h:92
#define NULL
Definition: mbi.h:101
#define ACTIVE_PARTICLE_4
Definition: object_constants.h:106
u32 bhvWavesGenerator[]
#define ACTIVE_PARTICLE_13
Definition: object_constants.h:115
#define ACTIVE_PARTICLE_6
Definition: object_constants.h:108
#define MODEL_WATER_WAVES_SURF
Definition: model_ids.h:494

A table mapping particle flags to various properties use when spawning a particle.

◆ unused_8033BEF8

UNUSED s32 unused_8033BEF8