![]() |
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 "mario.h"#include "area.h"#include "audio/external.h"#include "behavior_actions.h"#include "behavior_data.h"#include "camera.h"#include "mario_misc.h"#include "display.h"#include "game.h"#include "engine/graph_node.h"#include "interaction.h"#include "level_update.h"#include "memory.h"#include "main.h"#include "mario_actions_object.h"#include "mario_actions_automatic.h"#include "mario_actions_cutscene.h"#include "mario_actions_submerged.h"#include "mario_actions_airborne.h"#include "mario_actions_moving.h"#include "mario_actions_stationary.h"#include "mario_step.h"#include "engine/math_util.h"#include "object_fields.h"#include "object_helpers.h"#include "print.h"#include "save_file.h"#include "sound_init.h"#include "engine/surface_collision.h"Functions | |
| s32 | is_anim_at_end (struct MarioState *m) |
| Checks if Mario's animation has reached its end point. More... | |
| s32 | is_anim_past_end (struct MarioState *m) |
| Checks if Mario's animation has surpassed 2 frames before its end point. More... | |
| s16 | set_mario_animation (struct MarioState *m, s32 targetAnimID) |
| Sets Mario's animation without any acceleration, running at its default rate. More... | |
| s16 | set_mario_anim_with_accel (struct MarioState *m, s32 targetAnimID, s32 accel) |
| Sets Mario's animation where the animation is sped up or slowed down via acceleration. More... | |
| void | set_anim_to_frame (struct MarioState *m, s16 animFrame) |
| Sets the animation to a specific "next" frame from the frame given. More... | |
| s32 | is_anim_past_frame (struct MarioState *m, s16 animFrame) |
| s16 | find_mario_anim_flags_and_translation (struct Object *obj, s32 yaw, Vec3s translation) |
| Rotates the animation's translation into the global coordinate system and returns the animation's flags. More... | |
| void | update_mario_pos_for_anim (struct MarioState *m) |
| Updates Mario's position from his animation's translation. More... | |
| s16 | return_mario_anim_y_translation (struct MarioState *m) |
| Finds the vertical translation from Mario's animation. More... | |
| void | play_sound_if_no_flag (struct MarioState *m, u32 soundBits, u32 flags) |
| Plays a sound if if Mario doesn't have the flag being checked. More... | |
| void | play_mario_action_sound (struct MarioState *m) |
| Plays an action sound if one has not been played since the last action change. More... | |
| void | adjust_sound_for_speed (struct MarioState *m) |
| Adjusts the volume/pitch of sounds from Mario's speed. More... | |
| void | play_sound_and_spawn_particles (struct MarioState *m, u32 soundBits, u32 waveParticleType) |
| Spawns particles if the step sound says to, then either plays a step sound or relevant other sound. More... | |
| void | play_mario_environment_sound (struct MarioState *m, u32 soundBits, u32 waveParticleType) |
| Plays an environmental sound if one has not been played since the last action change. More... | |
| void | play_mario_step_sound (struct MarioState *m, u32 soundBits) |
| Plays a step sound, accounting for metal cap. More... | |
| void | play_mario_landing_sound (struct MarioState *m, u32 soundBits) |
| Plays a landing sound, accounting for metal cap. More... | |
| void | play_mario_heavy_landing_sound (struct MarioState *m, u32 soundBits) |
| Plays a heavy landing (ground pound, etc.) sound, accounting for metal cap. More... | |
| void | play_mario_knockback_sound (struct MarioState *m, u32 soundBits) |
| Plays a knockback sound, accounting for metal cap. More... | |
| void | play_mario_sound (struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits) |
| Plays an environment and action noise relevant to what was passed into the function. More... | |
| void | mario_set_forward_vel (struct MarioState *m, f32 forwardVel) |
| Sets Mario's other velocities from his forward speed. More... | |
| s32 | mario_get_floor_class (struct MarioState *m) |
| Returns the slipperines class of Mario's floor. More... | |
| u32 | mario_get_step_noise (struct MarioState *m) |
| Finds and returns Mario's step noise/type. More... | |
| struct Surface * | resolve_and_return_wall_collisions (Vec3f pos, f32 offset, f32 radius) |
| Collides with walls and returns the most recent wall. More... | |
| f32 | vec3f_find_ceil (Vec3f pos, f32 height, struct Surface **ceil) |
| Finds the ceiling from a vec3f horizontally and a height (with 80 vertical buffer). More... | |
| s32 | mario_facing_downhill (struct MarioState *m, s32 turnYaw) |
| Determines if Mario is facing "downhill.". More... | |
| u32 | mario_floor_is_slippery (struct MarioState *m) |
| Determines if a surface is slippery based on the surface class. More... | |
| s32 | mario_floor_is_slope (struct MarioState *m) |
| Determines if a surface is a slope based on the surface class. More... | |
| s32 | mario_floor_is_steep (struct MarioState *m) |
| Determines if a surface is steep based on the surface class. More... | |
| f32 | find_floor_height_relative_polar (struct MarioState *m, s16 angleFromMario, f32 distFromMario) |
| Finds the floor height relative from Mario given polar displacement. More... | |
| s16 | find_floor_slope (struct MarioState *m, s16 yawOffset) |
| Returns the slope of the floor based off points around Mario. More... | |
| void | update_mario_sound_and_camera (struct MarioState *m) |
| Adjusts Mario's camera and sound based on his action status. More... | |
| void | set_steep_jump_action (struct MarioState *m) |
| Transitions Mario to a steep jump action. More... | |
| static void | set_mario_y_vel_based_on_fspeed (struct MarioState *m, f32 initialVelY, f32 multiplier) |
| Set's Marios vertical speed from his forward speed. More... | |
| static u32 | set_mario_action_airborne (struct MarioState *m, u32 action, u32 actionArg) |
| Transitions for a variety of airborne actions. More... | |
| static u32 | set_mario_action_moving (struct MarioState *m, u32 action, UNUSED u32 actionArg) |
| Transitions for a variety of moving actions. More... | |
| static u32 | set_mario_action_submerged (struct MarioState *m, u32 action, UNUSED u32 actionArg) |
| Transition for certain submerged actions, which is actually just the metal jump actions. More... | |
| static u32 | set_mario_action_cutscene (struct MarioState *m, u32 action, UNUSED u32 actionArg) |
| Transitions for a variety of cutscene actions. More... | |
| u32 | set_mario_action (struct MarioState *m, u32 action, u32 actionArg) |
| Puts Mario into a given action, putting Mario through the appropriate specific function if needed. More... | |
| s32 | set_jump_from_landing (struct MarioState *m) |
| Puts Mario into a specific jumping action from a landing action. More... | |
| s32 | set_jumping_action (struct MarioState *m, u32 action, u32 actionArg) |
| Puts Mario in a given action, as long as it is not overruled by either a quicksand or steep jump. More... | |
| s32 | drop_and_set_mario_action (struct MarioState *m, u32 action, u32 actionArg) |
| Drop anything Mario is holding and set a new action. More... | |
| s32 | hurt_and_set_mario_action (struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter) |
| Increment Mario's hurt counter and set a new action. More... | |
| s32 | check_common_action_exits (struct MarioState *m) |
| Checks a variety of inputs for common transitions between many different actions. More... | |
| s32 | check_common_hold_action_exits (struct MarioState *m) |
| Checks a variety of inputs for common transitions between many different object holding actions. More... | |
| s32 | transition_submerged_to_walking (struct MarioState *m) |
| Transitions Mario from a submerged action to a walking action. More... | |
| s32 | set_water_plunge_action (struct MarioState *m) |
| This is the transition function typically for entering a submerged action for a non-submerged action. More... | |
| void | squish_mario_model (struct MarioState *m) |
| Applies the squish to Mario's model via scaling. More... | |
| void | debug_print_speed_action_normal (struct MarioState *m) |
| Debug function that prints floor normal, velocity, and action information. More... | |
| void | update_mario_button_inputs (struct MarioState *m) |
| Update the button inputs for Mario. More... | |
| void | update_mario_joystick_inputs (struct MarioState *m) |
| Updates the joystick intended magnitude. More... | |
| void | update_mario_geometry_inputs (struct MarioState *m) |
| Resolves wall collisions, and updates a variety of inputs. More... | |
| void | update_mario_inputs (struct MarioState *m) |
| Handles Mario's input flags as well as a couple timers. More... | |
| void | set_submerged_cam_preset_and_spawn_bubbles (struct MarioState *m) |
| Set's the camera preset for submerged action behaviors. More... | |
| void | update_mario_health (struct MarioState *m) |
| Both increments and decrements Mario's HP. More... | |
| void | update_mario_info_for_cam (struct MarioState *m) |
| Updates some basic info for camera usage. More... | |
| void | mario_reset_bodystate (struct MarioState *m) |
| Resets Mario's model, done every time an action is executed. More... | |
| void | sink_mario_in_quicksand (struct MarioState *m) |
| Adjusts Mario's graphical height for quicksand. More... | |
| u32 | update_and_return_cap_flags (struct MarioState *m) |
| Updates the cap flags mainly based on the cap timer. More... | |
| void | mario_update_hitbox_and_cap_model (struct MarioState *m) |
| Updates the Mario's cap, rendering, and hitbox. More... | |
| static void | debug_update_mario_cap (u16 button, s32 flags, u16 capTimer, u16 capMusic) |
| An unused and possibly a debug function. More... | |
| s32 | execute_mario_action (UNUSED struct Object *o) |
| Main function for executing Mario's behavior. More... | |
| void | init_mario (void) |
| void | init_mario_from_save_file (void) |
Variables | |
| u32 | unused80339F10 |
| s8 | filler80339F1C [20] |
| s8 | sTerrainStepNoises [7][6] |
| The step noises organized by terrain types by surface classes. More... | |
| u8 | sSquishScaleOverTime [16] |
| These are the scaling values for the x and z axis for Mario when he is close to unsquishing. More... | |
| u64 | sCapFlickerFrames = 0x4444449249255555 |
| Is a binary representation of the frames to flicker Mario's cap when the timer is running out. More... | |
| void adjust_sound_for_speed | ( | struct MarioState * | m | ) |
Adjusts the volume/pitch of sounds from Mario's speed.
| s32 check_common_action_exits | ( | struct MarioState * | m | ) |
Checks a variety of inputs for common transitions between many different actions.
A common variant of the below function.
| s32 check_common_hold_action_exits | ( | struct MarioState * | m | ) |
Checks a variety of inputs for common transitions between many different object holding actions.
A holding variant of the above function.
| void debug_print_speed_action_normal | ( | struct MarioState * | m | ) |
Debug function that prints floor normal, velocity, and action information.
An unused and possibly a debug function.
Z + another button input sets Mario with a different cap.
| s32 drop_and_set_mario_action | ( | struct MarioState * | m, |
| u32 | action, | ||
| u32 | actionArg | ||
| ) |
Drop anything Mario is holding and set a new action.
| f32 find_floor_height_relative_polar | ( | struct MarioState * | m, |
| s16 | angleFromMario, | ||
| f32 | distFromMario | ||
| ) |
Finds the floor height relative from Mario given polar displacement.
| s16 find_floor_slope | ( | struct MarioState * | m, |
| s16 | yawOffset | ||
| ) |
Returns the slope of the floor based off points around Mario.
If Mario is near OOB, these floorY's can sometimes be -11000.
Rotates the animation's translation into the global coordinate system and returns the animation's flags.
Increment Mario's hurt counter and set a new action.
| s32 is_anim_at_end | ( | struct MarioState * | m | ) |
Checks if Mario's animation has reached its end point.
| s32 is_anim_past_end | ( | struct MarioState * | m | ) |
Checks if Mario's animation has surpassed 2 frames before its end point.
| s32 is_anim_past_frame | ( | struct MarioState * | m, |
| s16 | animFrame | ||
| ) |
| s32 mario_facing_downhill | ( | struct MarioState * | m, |
| s32 | turnYaw | ||
| ) |
Determines if Mario is facing "downhill.".
| u32 mario_floor_is_slippery | ( | struct MarioState * | m | ) |
Determines if a surface is slippery based on the surface class.
| s32 mario_floor_is_slope | ( | struct MarioState * | m | ) |
Determines if a surface is a slope based on the surface class.
| s32 mario_floor_is_steep | ( | struct MarioState * | m | ) |
Determines if a surface is steep based on the surface class.
| s32 mario_get_floor_class | ( | struct MarioState * | m | ) |
Returns the slipperines class of Mario's floor.
| u32 mario_get_step_noise | ( | struct MarioState * | m | ) |
Finds and returns Mario's step noise/type.
Depends on surfaces and terrain.
| void mario_reset_bodystate | ( | struct MarioState * | m | ) |
Resets Mario's model, done every time an action is executed.
| void mario_set_forward_vel | ( | struct MarioState * | m, |
| f32 | forwardVel | ||
| ) |
Sets Mario's other velocities from his forward speed.
| void mario_update_hitbox_and_cap_model | ( | struct MarioState * | m | ) |
Updates the Mario's cap, rendering, and hitbox.
(Pause buffered hitstun) Since the global timer increments while paused,
| void play_mario_action_sound | ( | struct MarioState * | m | ) |
Plays an action sound if one has not been played since the last action change.
| void play_mario_environment_sound | ( | struct MarioState * | m, |
| u32 | soundBits, | ||
| u32 | waveParticleType | ||
| ) |
Plays an environmental sound if one has not been played since the last action change.
| void play_mario_heavy_landing_sound | ( | struct MarioState * | m, |
| u32 | soundBits | ||
| ) |
Plays a heavy landing (ground pound, etc.) sound, accounting for metal cap.
| void play_mario_knockback_sound | ( | struct MarioState * | m, |
| u32 | soundBits | ||
| ) |
Plays a knockback sound, accounting for metal cap.
| void play_mario_landing_sound | ( | struct MarioState * | m, |
| u32 | soundBits | ||
| ) |
Plays a landing sound, accounting for metal cap.
| void play_mario_sound | ( | struct MarioState * | m, |
| s32 | primarySoundBits, | ||
| s32 | scondarySoundBits | ||
| ) |
Plays an environment and action noise relevant to what was passed into the function.
| void play_mario_step_sound | ( | struct MarioState * | m, |
| u32 | soundBits | ||
| ) |
Plays a step sound, accounting for metal cap.
| void play_sound_and_spawn_particles | ( | struct MarioState * | m, |
| u32 | soundBits, | ||
| u32 | waveParticleType | ||
| ) |
Spawns particles if the step sound says to, then either plays a step sound or relevant other sound.
| void play_sound_if_no_flag | ( | struct MarioState * | m, |
| u32 | soundBits, | ||
| u32 | flags | ||
| ) |
Plays a sound if if Mario doesn't have the flag being checked.
Collides with walls and returns the most recent wall.
| s16 return_mario_anim_y_translation | ( | struct MarioState * | m | ) |
Finds the vertical translation from Mario's animation.
| void set_anim_to_frame | ( | struct MarioState * | m, |
| s16 | animFrame | ||
| ) |
Sets the animation to a specific "next" frame from the frame given.
| s32 set_jump_from_landing | ( | struct MarioState * | m | ) |
Puts Mario into a specific jumping action from a landing action.
| s32 set_jumping_action | ( | struct MarioState * | m, |
| u32 | action, | ||
| u32 | actionArg | ||
| ) |
Puts Mario in a given action, as long as it is not overruled by either a quicksand or steep jump.
| u32 set_mario_action | ( | struct MarioState * | m, |
| u32 | action, | ||
| u32 | actionArg | ||
| ) |
Puts Mario into a given action, putting Mario through the appropriate specific function if needed.
Transitions for a variety of airborne actions.
(BLJ's) This properly handles long jumps from getting forward speed with
|
static |
Transitions for a variety of cutscene actions.
|
static |
Transitions for a variety of moving actions.
|
static |
Transition for certain submerged actions, which is actually just the metal jump actions.
| s16 set_mario_anim_with_accel | ( | struct MarioState * | m, |
| s32 | targetAnimID, | ||
| s32 | accel | ||
| ) |
Sets Mario's animation where the animation is sped up or slowed down via acceleration.
| s16 set_mario_animation | ( | struct MarioState * | m, |
| s32 | targetAnimID | ||
| ) |
Sets Mario's animation without any acceleration, running at its default rate.
|
static |
Set's Marios vertical speed from his forward speed.
| void set_steep_jump_action | ( | struct MarioState * | m | ) |
Transitions Mario to a steep jump action.
((s16)0x8000) has undefined behavior. Therefore, this downcast has
| void set_submerged_cam_preset_and_spawn_bubbles | ( | struct MarioState * | m | ) |
Set's the camera preset for submerged action behaviors.
| s32 set_water_plunge_action | ( | struct MarioState * | m | ) |
This is the transition function typically for entering a submerged action for a non-submerged action.
This also applies the water surface camera preset.
| void sink_mario_in_quicksand | ( | struct MarioState * | m | ) |
Adjusts Mario's graphical height for quicksand.
| void squish_mario_model | ( | struct MarioState * | m | ) |
Applies the squish to Mario's model via scaling.
| s32 transition_submerged_to_walking | ( | struct MarioState * | m | ) |
Transitions Mario from a submerged action to a walking action.
| u32 update_and_return_cap_flags | ( | struct MarioState * | m | ) |
Updates the cap flags mainly based on the cap timer.
| void update_mario_button_inputs | ( | struct MarioState * | m | ) |
Update the button inputs for Mario.
| void update_mario_geometry_inputs | ( | struct MarioState * | m | ) |
Resolves wall collisions, and updates a variety of inputs.
| void update_mario_health | ( | struct MarioState * | m | ) |
Both increments and decrements Mario's HP.
| void update_mario_info_for_cam | ( | struct MarioState * | m | ) |
Updates some basic info for camera usage.
| void update_mario_inputs | ( | struct MarioState * | m | ) |
Handles Mario's input flags as well as a couple timers.
| void update_mario_joystick_inputs | ( | struct MarioState * | m | ) |
Updates the joystick intended magnitude.
| void update_mario_pos_for_anim | ( | struct MarioState * | m | ) |
Updates Mario's position from his animation's translation.
| void update_mario_sound_and_camera | ( | struct MarioState * | m | ) |
Adjusts Mario's camera and sound based on his action status.
Finds the ceiling from a vec3f horizontally and a height (with 80 vertical buffer).
| s8 filler80339F1C[20] |
| u64 sCapFlickerFrames = 0x4444449249255555 |
Is a binary representation of the frames to flicker Mario's cap when the timer is running out.
Equals [1000]^5 . [100]^8 . [10]^9 . [1] in binary, which is 100010001000100010001001001001001001001001001010101010101010101.
| u8 sSquishScaleOverTime[16] |
These are the scaling values for the x and z axis for Mario when he is close to unsquishing.
| s8 sTerrainStepNoises[7][6] |
The step noises organized by terrain types by surface classes.
See audio_defines.h for more information.
| u32 unused80339F10 |
1.8.13