![]() |
Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
|
#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 ObjectNode * | gObjectLists |
A pointer to gObjectListArray. More... | |
struct ObjectNode | gFreeObjectList |
A singly linked list of available slots in the object pool. More... | |
struct Object * | gMarioObject |
The object representing mario. More... | |
struct Object * | gLuigiObject |
An object variable that may have been used to represent the planned second player. More... | |
struct Object * | gCurrentObject |
The object whose behavior script is currently being updated. More... | |
u32 * | gBehCommand |
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 MemoryPool * | gObjectMemoryPool |
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... | |
Clear objects, dynamic surfaces, and some miscellaneous level data used by objects.
Copy position, velocity, and angle variables from MarioState to the mario object.
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 given a list of SpawnInfos.
Called when loading an area.
(Spawning Displacement) On the Japanese version, mario's platform object
Spawn a particle at gCurrentObject's location.
void stub_8029CA50 | ( | ) |
s32 unload_deactivated_objects_in_list | ( | struct ObjectNode * | objList | ) |
Unload any objects in the list that have been deactivated.
Unload all objects whose activeAreaIndex is areaIndex.
Unused profiling function.
Update all other object lists besides spawner and surface objects, using the order specified by sObjectListUpdateOrder.
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,
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)
s32 update_objects_in_list | ( | struct ObjectNode * | objList | ) |
Update every object in the given list.
Return the total number of objects in the list.
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.
u32* gBehCommand |
The next object behavior command to be executed.
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".
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).
s32 gDebugInfoFlags |
Flags controlling what debug info is displayed.
s16 gDebugInfoOverwrite[16][8] |
struct ObjectNode gFreeObjectList |
A singly linked list of available slots in the object pool.
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.
A special object whose purpose is to act as a parent for macro objects.
struct NumTimesCalled gNumCalls |
The number of times find_floor, find_ceil, and find_wall_collisions have been called respectively.
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.
s32 gNumStaticSurfaceNodes |
The number of nodes that have been created for surfaces.
s32 gNumStaticSurfaces |
The number of surfaces in the pool.
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.
struct ObjectNode gObjectListArray[16] |
Nodes used to represent the doubly linked object lists.
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.
struct MemoryPool* gObjectMemoryPool |
A pool used by chain chomp and wiggler to allocate their body parts.
struct Object gObjectPool[OBJECT_POOL_CAPACITY] |
The pool that objects are allocated from.
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.
s32 gSurfaceNodesAllocated |
The total number of surface nodes allocated (a node is allocated for each spatial partition cell that a surface intersects).
s32 gSurfacesAllocated |
The total number of surfaces allocated.
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.
s32 gUnknownWallCount |
An unused debug counter with the label "WALL".
s8 sObjectListUpdateOrder[] |
The order that object lists are processed in a frame.
struct ParticleProperties sParticleTypes[] |
A table mapping particle flags to various properties use when spawning a particle.