Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Functions
spawn_object.c File Reference
#include <ultra64.h>
#include "sm64.h"
#include "engine/math_util.h"
#include "area.h"
#include "engine/geo_layout.h"
#include "engine/graph_node.h"
#include "object_helpers.h"
#include "engine/behavior_script.h"
#include "engine/surface_collision.h"
#include "audio/external.h"
#include "level_update.h"
#include "spawn_object.h"
#include "object_list_processor.h"

Data Structures

struct  LinkedList
 An unused linked list struct that seems to have been replaced by ObjectNode. More...
 

Functions

static void unused_init_free_list (struct LinkedList *usedList, struct LinkedList **pFreeList, struct LinkedList *pool, s32 itemSize, s32 poolLength)
 Clear the doubly linked usedList. More...
 
static struct LinkedListunused_try_allocate (struct LinkedList *destList, struct LinkedList *freeList)
 Attempt to allocate a node from freeList (singly linked) and append it to the end of destList (doubly linked). More...
 
static struct Objecttry_allocate_object (struct ObjectNode *destList, struct ObjectNode *freeList)
 Attempt to allocate an object from freeList (singly linked) and append it to the end of destList (doubly linked). More...
 
static void unused_deallocate (struct LinkedList *freeList, struct LinkedList *node)
 Remove the node from the doubly linked list it's in, and place it in the singly linked freeList. More...
 
static void deallocate_object (struct ObjectNode *freeList, struct ObjectNode *obj)
 Remove the given object from the object list that it's currently in, and insert it at the beginning of the free list (singly linked). More...
 
void init_free_object_list (void)
 Add every object in the pool to the free object list. More...
 
void clear_object_lists (struct ObjectNode *objLists)
 Clear each object list, without adding the objects back to the free list. More...
 
static void unused_delete_leaf_nodes (struct Object *obj)
 This function looks broken, but it appears to attempt to delete the leaf graph nodes under obj and obj's siblings. More...
 
void unload_object (struct Object *obj)
 Free the given object. More...
 
static struct Objectallocate_object (struct ObjectNode *objList)
 Attempt to allocate a new object slot into the given object list, freeing an unimportant object if necessary. More...
 
static void snap_object_to_floor (struct Object *obj)
 If the object is close to being on the floor, move it to be exactly on the floor. More...
 
struct Objectcreate_object (u32 *behScript)
 Spawn an object at the origin with the behavior script at virtual address behScript. More...
 
void mark_obj_for_deletion (struct Object *obj)
 Mark an object to be unloaded at the end of the frame. More...
 

Function Documentation

◆ allocate_object()

static struct Object* allocate_object ( struct ObjectNode objList)
static

Attempt to allocate a new object slot into the given object list, freeing an unimportant object if necessary.

If this is not possible, hang using an infinite loop.

Uh oh, the unimportant object was in the middle of

◆ clear_object_lists()

void clear_object_lists ( struct ObjectNode objLists)

Clear each object list, without adding the objects back to the free list.

◆ create_object()

struct Object* create_object ( u32 behScript)

Spawn an object at the origin with the behavior script at virtual address behScript.

They intended to snap certain objects to the floor when they spawn.

◆ deallocate_object()

static void deallocate_object ( struct ObjectNode freeList,
struct ObjectNode obj 
)
static

Remove the given object from the object list that it's currently in, and insert it at the beginning of the free list (singly linked).

◆ init_free_object_list()

void init_free_object_list ( void  )

Add every object in the pool to the free object list.

◆ mark_obj_for_deletion()

void mark_obj_for_deletion ( struct Object obj)

Mark an object to be unloaded at the end of the frame.

Same issue as mark_object_for_deletion

◆ snap_object_to_floor()

static void snap_object_to_floor ( struct Object obj)
static

If the object is close to being on the floor, move it to be exactly on the floor.

◆ try_allocate_object()

static struct Object* try_allocate_object ( struct ObjectNode destList,
struct ObjectNode freeList 
)
static

Attempt to allocate an object from freeList (singly linked) and append it to the end of destList (doubly linked).

Return the object, or NULL if freeList is empty.

◆ unload_object()

void unload_object ( struct Object obj)

Free the given object.

◆ unused_deallocate()

static void unused_deallocate ( struct LinkedList freeList,
struct LinkedList node 
)
static

Remove the node from the doubly linked list it's in, and place it in the singly linked freeList.

This function seems to have been replaced by deallocate_object.

◆ unused_delete_leaf_nodes()

static void unused_delete_leaf_nodes ( struct Object obj)
static

This function looks broken, but it appears to attempt to delete the leaf graph nodes under obj and obj's siblings.

◆ unused_init_free_list()

static void unused_init_free_list ( struct LinkedList usedList,
struct LinkedList **  pFreeList,
struct LinkedList pool,
s32  itemSize,
s32  poolLength 
)
static

Clear the doubly linked usedList.

Singly link each item in the pool into a list, and return this list in pFreeList. Appears to have been replaced by init_free_object_list.

◆ unused_try_allocate()

static struct LinkedList* unused_try_allocate ( struct LinkedList destList,
struct LinkedList freeList 
)
static

Attempt to allocate a node from freeList (singly linked) and append it to the end of destList (doubly linked).

Return the object, or NULL if freeList is empty. Appears to have been replaced by try_allocate_object.