![]() |
Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
|
Functions for parsing and processing Goddard's DynList object format. More...
#include <ultra64.h>
#include <macros.h>
#include <config.h>
#include "gd_types.h"
#include "bad_declarations.h"
#include "prevent_bss_reordering.h"
#include "gd_main.h"
#include "draw_objects.h"
#include "objects.h"
#include "particles.h"
#include "dynlist_proc.h"
#include "old_menu.h"
#include "debug_utils.h"
#include "joints.h"
#include "skin.h"
#include "gd_math.h"
#include "shape_helper.h"
#include "renderer.h"
Data Structures | |
struct | DynObjInfo |
Information about a dynamically created GdObj More... | |
Macros | |
#define | DYNOBJ_NAME_SIZE 8 |
Size of the dynamic object name buffer. More... | |
#define | DYNOBJ_LIST_SIZE 3000 |
Total number of dynamic GdObj s that can be created. More... | |
#define | VTX_BUF_SIZE 3000 |
Maximum number of verticies supported when adding vertices node to an ObjShape More... | |
DynList Accessors | |
Accessor marcos for easy interpretation of data in a | |
#define | Dyn1AsInt(dyn) ((dyn)->w1.word) |
#define | Dyn1AsPtr(dyn) ((dyn)->w1.ptr) |
#define | Dyn1AsStr(dyn) ((dyn)->w1.str) |
#define | Dyn1AsID(dyn) ((DynId)((dyn)->w1.ptr)) |
#define | Dyn2AsInt(dyn) ((dyn)->w2.word) |
#define | Dyn2AsPtr(dyn) ((dyn)->w2.ptr) |
#define | Dyn2AsStr(dyn) ((dyn)->w2.str) |
#define | Dyn2AsID(dyn) ((DynId)((dyn)->w2.ptr)) |
#define | DynVec(dyn) (&(dyn)->vec) |
#define | DynVecX(dyn) ((dyn)->vec.x) |
#define | DynVecY(dyn) ((dyn)->vec.y) |
#define | DynVecZ(dyn) ((dyn)->vec.z) |
Functions | |
void | d_add_net_with_subgroup (s32, DynId) |
void | d_end_net_subgroup (DynId id) |
End the ObjNet +ObjGroup set created by d_add_net_with_subgroup() . More... | |
void | d_attach_joint_to_net (s32, DynId) |
void | d_addto_group (DynId id) |
Add the current dynamic object to the dynamic ObjGroup id . More... | |
void | d_link_with (DynId id) |
Link the dynamic object id to the current dynamic object by wrapping d_link_with_ptr() . More... | |
void | d_link_with_ptr (void *ptr) |
Link a variable pointer to the current active dynamic object. More... | |
void | d_set_normal (f32 x, f32 y, f32 z) |
Set the normal of the current dynamic ObjVertex . More... | |
void | d_make_vertex (struct GdVec3f *pos) |
Create a new dynamic ObjVertex at point pos . More... | |
void | d_set_rotation (f32 x, f32 y, f32 z) |
Set the rotation value of the current active dynamic object. More... | |
void | d_center_of_gravity (f32 x, f32 y, f32 z) |
Set the center of gravity of the current dynamic ObjNet . More... | |
void | d_set_shape_offset (f32 x, f32 y, f32 z) |
Set the shape offset of the current dynamic ObjJoint . More... | |
void | d_clear_flags (s32 flags) |
Clear object specific flags from the current dynamic object. More... | |
void | d_attach (DynId id) |
Attach dynamic object id to the current active ObjJoint object. More... | |
void | d_attach_to (s32 flag, struct GdObj *obj) |
Attach the current dynamic GdObj into the proper subgroup of obj and set the "attach flags" of the current dynamic object to flag More... | |
void | d_attachto_dynid (s32 flag, DynId id) |
Attach the current dynamic object to dynamic object id . More... | |
void | d_set_att_offset (const struct GdVec3f *off) |
Set the offset of the attached object on the current dynamic object. More... | |
void | d_set_nodegroup (DynId id) |
Set the "node group" of the current dynamic object to dynamic object id . More... | |
void | d_set_matgroup (DynId id) |
Set the material group of the current dynamic ObjShape to id . More... | |
void | d_set_skinshape (DynId id) |
Set the current dynamic ObjNet 's skin group with the vertex group from the dynamic ObjShape with id . More... | |
void | d_set_planegroup (DynId id) |
In practice, this is used to set the faces of the current active dynamic ObjShape to the dynamic group id of ObjFace s. More... | |
void | d_set_shapeptr (DynId id) |
Set the shape pointer of the current active dynamic object to dynamic ObjShape id . More... | |
void | d_friction (f32 x, f32 y, f32 z) |
Set the friction vec of the current dynamic ObjJoint . More... | |
void | d_set_spring (f32 spring) |
Set the spring constant of the current dynamic ObjBone . More... | |
void | d_set_ambient (f32 r, f32 g, f32 b) |
Set the ambient color of the current dynamic ObjMaterial . More... | |
void | d_set_control_type (s32 ctrltype) |
Set the control type of the current dynamic ObjNet . More... | |
void | d_set_skin_weight (s32 id, f32 percentWeight) |
Create a new weight for the current dynamic ObjJoint . More... | |
void | d_set_id (s32 id) |
Set the specific object ID field for the current dynamic object. More... | |
void | d_set_material (void *, s32) |
void | d_map_materials (DynId id) |
Map the material ids for the ObjFace s in the current dynamic ObjGroup to pointer to ObjMaterial s in the ObjGroup id . More... | |
void | d_map_vertices (DynId id) |
Map the vertex ids for the ObjFace s in the current dynamic ObjGroup to pointer to ObjVertex in the ObjGroup id . More... | |
void | d_set_texture_st (f32, f32) |
void | d_use_texture (void *texture) |
Set the texture pointer of the current dynamic ObjMaterial . More... | |
void | d_make_netfromshapeid (DynId id) |
Create a new ObjNet linked with the dynamic ObjShape id . More... | |
void | d_make_netfromshape_ptrptr (struct ObjShape **shapePtr) |
Create a new ObjNet linked with the doubly indirected ObjShape . More... | |
void | add_to_dynobj_list (struct GdObj *newobj, DynId id) |
Add newobj identified by id to the dynamic GdObj list. More... | |
void | push_dynobj_stash (void) |
Store the active dynamic GdObj into a one object stash. More... | |
void | pop_dynobj_stash (void) |
Set the stashed GdObj as the active dynamic GdObj . More... | |
void | reset_dynlist (void) |
Reset dynlist related variables to a starting state. More... | |
struct GdObj * | proc_dynlist (struct DynList *dylist) |
Parse a DynList array into active GdObj s. More... | |
void | d_copystr_to_idbuf (char *str) |
Copy input str into a buffer that will be concatenated to a dynamic GdObj 's name string when creating a new dynamic object. More... | |
void | d_catstr_to_idbuf (char *str) |
Concatenate input str into a buffer that will be concatenated to a dynamic GdObj 's name string when creating a new dynamic object. More... | |
void | cpy_idbuf_to_backbuf (void) |
Stash the current string that is appended to a created dynamic GdObj name. More... | |
void | cpy_backbuf_to_idbuf (void) |
Pop the stash for the string that is appended to a created dynamic GdObj name. More... | |
struct DynObjInfo * | get_dynobj_info (DynId id) |
Get the DynObjInfo struct for object id More... | |
void | reset_dynamic_objs (void) |
Reset the number of created dynamic objects and free the dynamic object information list (sGdDynObjList ). More... | |
void | d_add_net_with_subgroup (UNUSED s32 a0, DynId id) |
Create an ObjNet and an associated node ObjGroup . More... | |
void | d_attach_joint_to_net (UNUSED s32 arg0, DynId id) |
Create an ObjJoint and add that to the ObjNet created by d_add_net_with_subgroup() . More... | |
char * | print_int_dynid (DynId id) |
Format id into string, if DynId s are currently being interpreted as numbers. More... | |
struct GdObj * | d_makeobj (enum DObjTypes type, DynId id) |
Create a new GdObj of type and add that object to the dynamic object list with id . More... | |
void | copy_bytes (u8 *src, u8 *dst, s32 num) |
Helper function to copy bytes. More... | |
void | alloc_animdata (struct ObjAnimator *animator) |
Allocate the animation data for animator onto the goddard heap. More... | |
void | chk_shapegen (struct ObjShape *shape) |
Generate or create the various ObjVertex , ObjFace , and/or ObjMaterial when groups of those structures are attached to shape . More... | |
void | d_set_texture_st (UNUSED f32 s, UNUSED f32 t) |
At one time in the past, this set the s and t value of the current dynamic ObjVertex . More... | |
void | d_set_shapeptrptr (struct ObjShape **shpPtrptr) |
Set the shape pointer of the current active dynamic object to the pointer pointed to by shpPtrptr . More... | |
struct GdObj * | d_use_obj (DynId id) |
Set the current active dynamic object to object id . More... | |
void | set_cur_dynobj (struct GdObj *obj) |
Set the current active dynamic object to obj . More... | |
void | d_start_group (DynId id) |
Start a dynamic ObjGroup identified with id . More... | |
void | d_end_group (DynId id) |
Add all dynamic objects created between the start of dynamic ObjGroup id and this call. More... | |
void | dynid_is_int (s32 isIntBool) |
Set if DynId should be treated as integer values, or as char * string pointers. More... | |
void | d_set_init_pos (f32 x, f32 y, f32 z) |
Set the initial position of the current dynamic object to (x, y, z) . More... | |
void | d_set_velocity (const struct GdVec3f *vel) |
Set the velocity of the current active dynamic object. More... | |
void | d_get_velocity (struct GdVec3f *dst) |
Read the velocity value of the current dynamic object into dst More... | |
void | d_set_torque (const struct GdVec3f *src) |
Set the torque vectore for the current dynamic object. More... | |
void | d_get_init_pos (struct GdVec3f *dst) |
Get the initial position of the current dynamic object and store in dst . More... | |
void | d_get_init_rot (struct GdVec3f *dst) |
Get the initial rotation of the current dynamic object and store in dst . More... | |
void | d_set_rel_pos (f32 x, f32 y, f32 z) |
Set the position of the current dynamic object. More... | |
void | d_addto_rel_pos (struct GdVec3f *src) |
Offset the current position of the current dynamic object. More... | |
void | d_get_rel_pos (struct GdVec3f *dst) |
Store the current dynamic object's position into dst . More... | |
struct ObjGroup * | d_get_att_objgroup (void) |
Return a pointer to the attached object group of the current dynamic object. More... | |
struct GdObj * | d_get_att_to_obj (void) |
Return a pointer to the attached object of the current dynamic object. More... | |
void | d_get_scale (struct GdVec3f *dst) |
Store the current dynamic object's scale into dst . More... | |
void | d_set_att_to_offset (UNUSED u32 a) |
An incorrectly-coded recursive function that was presumably supposed to set the offset of an attached object. More... | |
void | d_get_att_offset (struct GdVec3f *dst) |
Store the offset of the attached object into dst . More... | |
s32 | d_get_att_flags (void) |
Get the attached object flags for the current dynamic object. More... | |
void | d_set_world_pos (f32 x, f32 y, f32 z) |
Set the world position of the current dynamic object. More... | |
struct GdVec3f * | d_get_world_pos_ptr (void) |
Get a pointer to the world position vector of the active dynamic object. More... | |
void | d_get_world_pos (struct GdVec3f *dst) |
Copy the world position of the current dynamic object into dst . More... | |
void | d_set_scale (f32 x, f32 y, f32 z) |
Scale the current dynamic object by factor (x, y, z) . More... | |
void | d_add_valptr (DynId objId, u32 vflags, s32 type, u32 offset) |
Create a new ObjValPtr to dynamic object objId and attach that valptr to the current dynamic object. More... | |
void | d_add_valproc (valptrproc_t proc) |
Add a value processing function (valptrproc_t ) to the current dynamic ObjLabel . More... | |
void | d_set_flags (s32 flags) |
Set the object specific flags of the current dynamic object. More... | |
void | d_set_parm_f (enum DParmF param, f32 val) |
Set variable float parameters on the current dynamic object. More... | |
void | d_set_parm_ptr (enum DParmPtr param, void *ptr) |
Set various pointer parameters for the current dynamic object. More... | |
void | d_set_obj_draw_flag (enum ObjDrawingFlags flag) |
Set the generic drawing flags for the current dynamic object. More... | |
void | d_set_type (s32 type) |
Set an object specific type field for the current dynamic object. More... | |
void | d_set_colour_num (s32 colornum) |
Set the colour of the current dynamic object. More... | |
void | d_set_material (UNUSED void *a0, s32 mtlId) |
Set the material ID of the current dynamic ObjFace . More... | |
void | d_set_diffuse (f32 r, f32 g, f32 b) |
Set the diffuse color of the current dynamic ObjMaterial or ObjLight . More... | |
struct GdPlaneF * | d_get_plane (void) |
Get a pointer to a GdPlaneF in the current dynamic object. More... | |
void | d_get_matrix (Mat4f *dst) |
Copy the matrix from the current dynamic object into dst . More... | |
void | d_set_matrix (Mat4f *src) |
Set the matrix of the current dynamic object by copying src into the object. More... | |
void | d_set_rot_mtx (Mat4f *src) |
Set the rotation matrix of the current dynamic object by copying the input matrix src . More... | |
Mat4f * | d_get_rot_mtx_ptr (void) |
Get a pointer to the current dynamic object's rotation matrix. More... | |
void | d_set_idn_mtx (Mat4f *src) |
Copy src into the identity matrix of the current dynamic object. More... | |
Mat4f * | d_get_matrix_ptr (void) |
Get a pointer to the current dynamic object's matrix. More... | |
Mat4f * | d_get_idn_mtx_ptr (void) |
Get a pointer to the current dynamic object's identity matrix. More... | |
f32 | d_calc_world_dist_btwn (struct GdObj *obj1, struct GdObj *obj2) |
Use the dynamic object system to calculate the distance between two GdObj s. More... | |
Variables | |
static struct DynObjInfo * | sGdDynObjList = NULL |
static struct GdObj * | sDynListCurObj = NULL |
static struct GdPlaneF | sGdNullPlaneF |
static s32 | sGdDynObjIdIsInt = FALSE |
static char | sIntDynIdBuffer [DYNOBJ_NAME_SIZE] |
buffer for returning formated string from print_int_dynid() More... | |
static struct DynObjInfo | sNullDynObjInfo |
static char | sDynIdBuf [DYNOBJ_NAME_SIZE] |
static s32 | sUnnamedObjCount |
static s32 | sLoadedDynObjs |
static struct DynObjInfo * | sDynListCurInfo |
static struct DynObjInfo * | sParentNetInfo |
Information for ObjNet made by d_add_net_with_subgroup() More... | |
static struct DynObjInfo * | sStashedDynObjInfo |
static struct GdObj * | sStashedDynObj |
static s32 | sDynNetCount |
static char | sDynNetIdBuf [0x20] |
static char | sBackBuf [0x100] |
Functions for parsing and processing Goddard's DynList object format.
It also has utility functions for abstracting at runtime over the various flavors of GdObj
s.
#define Dyn1AsID | ( | dyn | ) | ((DynId)((dyn)->w1.ptr)) |
#define Dyn1AsInt | ( | dyn | ) | ((dyn)->w1.word) |
#define Dyn1AsPtr | ( | dyn | ) | ((dyn)->w1.ptr) |
#define Dyn1AsStr | ( | dyn | ) | ((dyn)->w1.str) |
#define Dyn2AsID | ( | dyn | ) | ((DynId)((dyn)->w2.ptr)) |
#define Dyn2AsInt | ( | dyn | ) | ((dyn)->w2.word) |
#define Dyn2AsPtr | ( | dyn | ) | ((dyn)->w2.ptr) |
#define Dyn2AsStr | ( | dyn | ) | ((dyn)->w2.str) |
#define DYNOBJ_LIST_SIZE 3000 |
Total number of dynamic GdObj
s that can be created.
#define DYNOBJ_NAME_SIZE 8 |
Size of the dynamic object name buffer.
#define DynVec | ( | dyn | ) | (&(dyn)->vec) |
#define DynVecX | ( | dyn | ) | ((dyn)->vec.x) |
#define DynVecY | ( | dyn | ) | ((dyn)->vec.y) |
#define DynVecZ | ( | dyn | ) | ((dyn)->vec.z) |
#define VTX_BUF_SIZE 3000 |
Maximum number of verticies supported when adding vertices node to an ObjShape
void alloc_animdata | ( | struct ObjAnimator * | animator | ) |
Allocate the animation data for animator
onto the goddard heap.
Animation data of type GD_ANIM_9H
is converted to a AnimMtxVec
struct, rather than solely byted copied like the other types.
Generate or create the various ObjVertex
, ObjFace
, and/or ObjMaterial
when groups of those structures are attached to shape
.
This function is called when d_set_nodegroup()
, d_set_planegroup()
, or d_set_matgroup()
are called when an ObjShape
is the active dynamic object.
make_face_with_colour()
compiles incorrectly due to Goddard only declaring the functions, not prototyping the functions Helper function to copy bytes.
Where's memcpy when you need it?
Pop the stash for the string that is appended to a created dynamic GdObj
name.
Stash the current string that is appended to a created dynamic GdObj
name.
void d_add_valproc | ( | valptrproc_t | proc | ) |
Add a value processing function (valptrproc_t
) to the current dynamic ObjLabel
.
Create a new ObjValPtr
to dynamic object objId
and attach that valptr to the current dynamic object.
type | ValPtrType |
Offset the current position of the current dynamic object.
Attach dynamic object id
to the current active ObjJoint
object.
Create an ObjJoint
and add that to the ObjNet
created by d_add_net_with_subgroup()
.
arg0 | Not used |
id | Id for created ObjJoint |
Attach the current dynamic GdObj
into the proper subgroup of obj
and set the "attach flags" of the current dynamic object to flag
Attach the current dynamic object to dynamic object id
.
This function is a wrapper around d_attach_to()
Use the dynamic object system to calculate the distance between two GdObj
s.
The objects don't have to be dynamic objects.
Concatenate input str
into a buffer that will be concatenated to a dynamic GdObj
's name string when creating a new dynamic object.
If input is NULL
, then a generic string is created based on the number of unnamed objects.
Set the center of gravity of the current dynamic ObjNet
.
Copy input str
into a buffer that will be concatenated to a dynamic GdObj
's name string when creating a new dynamic object.
If input is NULL
, then a generic string is created based on the number of unnamed objects.
Add all dynamic objects created between the start of dynamic ObjGroup
id
and this call.
End the ObjNet
+ObjGroup
set created by d_add_net_with_subgroup()
.
Return a pointer to the attached object group of the current dynamic object.
Store the offset of the attached object into dst
.
Return a pointer to the attached object of the current dynamic object.
Get the initial position of the current dynamic object and store in dst
.
Get the initial rotation of the current dynamic object and store in dst
.
Get a pointer to a GdPlaneF
in the current dynamic object.
If the current object does not have a plane, a pointer to a global plane at (0,0) is returned.
Read the velocity value of the current dynamic object into dst
[out] | dst | values are copied to this GdVec3f |
Copy the world position of the current dynamic object into dst
.
Get a pointer to the world position vector of the active dynamic object.
This is a pointer inside the actual object.
Link the dynamic object id
to the current dynamic object by wrapping d_link_with_ptr()
.
Link a variable pointer to the current active dynamic object.
In the final game, this is used to link arrays of raw vertex, face, or animation data to ObjGroup
s, or to link joints to ObjAnimator
s.
Create a new dynamic ObjVertex
at point pos
.
[in] | pos | values are copied to set vertex position |
Create a new GdObj
of type
and add that object to the dynamic object list with id
.
Created objects have default parameters, which are usually 0 or NULL.
D_DATA_GRP
object D_LABEL
, the call to make_label()
compiles incorrectly due to Goddard only declaring the functions, not prototyping the functions Map the material ids for the ObjFace
s in the current dynamic ObjGroup
to pointer to ObjMaterial
s in the ObjGroup
id
.
See map_face_materials()
for more info.
Map the vertex ids for the ObjFace
s in the current dynamic ObjGroup
to pointer to ObjVertex
in the ObjGroup
id
.
See map_vertices()
for more info.
Set the ambient color of the current dynamic ObjMaterial
.
Set the offset of the attached object on the current dynamic object.
An incorrectly-coded recursive function that was presumably supposed to set the offset of an attached object.
Now, it will only call itself until it encounters a NULL pointer, which will trigger a fatal_printf()
call.
Set the colour of the current dynamic object.
The input color is an index for gd_get_colour()
Set the diffuse color of the current dynamic ObjMaterial
or ObjLight
.
Set the initial position of the current dynamic object to (x, y, z)
.
Set the material ID of the current dynamic ObjFace
.
Set the "node group" of the current dynamic object to dynamic object id
.
The node group depends on the type of the current dynamic object:
ObjShape
ObjNet
ObjAnimator
ObjGadget
Set the normal of the current dynamic ObjVertex
.
The input x, y, z
values are normalized into a unit vector before setting the vertex normal.
void d_set_obj_draw_flag | ( | enum ObjDrawingFlags | flag | ) |
Set the generic drawing flags for the current dynamic object.
Set variable float parameters on the current dynamic object.
These are mainly used for ObjGadget
s to set the drawing size range.
Set various pointer parameters for the current dynamic object.
Normally, this is used to set char *
pointer for various objects, but it can also set the vertices for an ObjFace
.
Set the position of the current dynamic object.
ObjCamera
. Set the rotation matrix of the current dynamic object by copying the input matrix src
.
Set the rotation value of the current active dynamic object.
Scale the current dynamic object by factor (x, y, z)
.
ObjView
Set the shape offset of the current dynamic ObjJoint
.
Set the shape pointer of the current active dynamic object to dynamic ObjShape
id
.
Set the shape pointer of the current active dynamic object to the pointer pointed to by shpPtrptr
.
Create a new weight for the current dynamic ObjJoint
.
The input weight value is out of 100.
Set the torque vectore for the current dynamic object.
Values from input GdVec3f
are copied into the object.
Set the velocity of the current active dynamic object.
The values of the input GdVec3f
are copied into the object.
Set the world position of the current dynamic object.
ObjView
Set the texture pointer of the current dynamic ObjMaterial
.
Set if DynId
should be treated as integer values, or as char *
string pointers.
isIntBool | TRUE to interpret ids as integers |
struct DynObjInfo* get_dynobj_info | ( | DynId | id | ) |
Get the DynObjInfo
struct for object id
id | Either a string or integer id for a dynamic GdObj |
Format id
into string, if DynId
s are currently being interpreted as numbers.
NULL | if id is NULL or if DynId s are interpreted as strings |
Reset the number of created dynamic objects and free the dynamic object information list (sGdDynObjList
).
The objects themselves still exist, though.
Set the current active dynamic object to obj
.
This object can any type of GdObj
, not just an object created through the dynmaic object system.
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
buffer for returning formated string from print_int_dynid()
|
static |
|
static |
|
static |
Information for ObjNet
made by d_add_net_with_subgroup()
|
static |
|
static |