Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Functions | Variables
envfx_bubbles.c File Reference
#include <ultra64.h>
#include "sm64.h"
#include "display.h"
#include "memory.h"
#include "ingame_menu.h"
#include "envfx_snow.h"
#include "envfx_bubbles.h"
#include "engine/surface_collision.h"
#include "engine/math_util.h"
#include "engine/behavior_script.h"
#include "audio/external.h"
#include "obj_behaviors.h"

Functions

s32 particle_is_laterally_close (s32 index, s32 x, s32 z, s32 distance)
 Check whether the particle with the given index is laterally within distance of point (x, z). More...
 
s32 random_flower_offset ()
 Generate a uniform random number in range [-2000, -1000[ or [1000, 2000[ Used to position flower particles. More...
 
void envfx_update_flower (Vec3s centerPos)
 Update flower particles. More...
 
void envfx_set_lava_bubble_position (s32 index, Vec3s centerPos)
 Update the position of a lava bubble to be somewhere around centerPos Uses find_floor to find the height of lava, if no floor or a non-lava floor is found the bubble y is set to -10000, which is why you can see occasional lava bubbles far below the course in Lethal Lava Land. More...
 
void envfx_update_lava (Vec3s centerPos)
 Update lava bubble animation and give the bubble a new position if the animation is over. More...
 
void envfx_rotate_around_whirlpool (s32 *x, s32 *y, s32 *z)
 Rotate the input x, y and z around the rotation origin of the whirlpool according to the pitch and yaw of the whirlpool. More...
 
s32 envfx_is_whirlpool_bubble_alive (s32 index)
 Check whether a whirlpool bubble is alive. More...
 
void envfx_update_whirlpool (void)
 Update whirlpool particles. More...
 
s32 envfx_is_jestream_bubble_alive (s32 index)
 Check whether a jetstream bubble should respawn. More...
 
void envfx_update_jetstream (void)
 Update the positions of jestream bubble particles. More...
 
s32 envfx_init_bubble (s32 mode)
 Initialize bubble (or flower) effect by allocating a buffer to store the state of each particle and setting the initial and max count. More...
 
void envfx_bubbles_update_switch (s32 mode, Vec3s camTo, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3)
 Update particles depending on mode. More...
 
void append_bubble_vertex_buffer (Gfx *gfx, s32 index, Vec3s vertex1, Vec3s vertex2, Vec3s vertex3, Vtx *template)
 Append 15 vertices to 'gfx', which is enough for 5 bubbles starting at 'index'. More...
 
void envfx_set_bubble_texture (s32 mode, s16 index)
 Appends to the enfvx display list a command setting the appropriate texture for a specific particle. More...
 
Gfxenvfx_update_bubble_particles (s32 mode, UNUSED Vec3s marioPos, Vec3s camFrom, Vec3s camTo)
 Updates the bubble particle positions, then generates and returns a display list drawing them. More...
 
void envfx_set_max_bubble_particles (s32 mode)
 Set the maximum particle count from the gEnvFxBubbleConfig variable, which is set by the whirlpool or jetstream behavior. More...
 
Gfxenvfx_update_bubbles (s32 mode, Vec3s marioPos, Vec3s camTo, Vec3s camFrom)
 Update bubble-like environment effects. More...
 

Variables

s16 gEnvFxBubbleConfig [10]
 This file implements environment effects that are not snow: Flowers (unused), lava bubbles and jetsream/whirlpool bubbles. More...
 
static GfxsGfxCursor
 
static s32 sBubbleParticleCount
 
static s32 sBubbleParticleMaxCount
 
UNUSED s32 D_80330690 = 0
 
UNUSED s32 D_80330694 = 0
 
Vtx_t gBubbleTempVtx [3]
 Template for a bubble particle triangle. More...
 
voidflower_bubbles_textures_ptr_0B002008
 
voidlava_bubble_ptr_0B006020
 
voidbubble_ptr_0B006848
 
voidtiny_bubble_dl_0B006AB0
 
voidtiny_bubble_dl_0B006D38
 
voidtiny_bubble_dl_0B006D68
 

Function Documentation

◆ append_bubble_vertex_buffer()

void append_bubble_vertex_buffer ( Gfx gfx,
s32  index,
Vec3s  vertex1,
Vec3s  vertex2,
Vec3s  vertex3,
Vtx template 
)

Append 15 vertices to 'gfx', which is enough for 5 bubbles starting at 'index'.

The 3 input vertices represent the roated triangle around (0,0,0) that will be translated to bubble positions to draw the bubble image

◆ envfx_bubbles_update_switch()

void envfx_bubbles_update_switch ( s32  mode,
Vec3s  camTo,
Vec3s  vertex1,
Vec3s  vertex2,
Vec3s  vertex3 
)

Update particles depending on mode.

Also sets the given vertices to the correct shape for each mode, though they are not being rotated yet.

◆ envfx_init_bubble()

s32 envfx_init_bubble ( s32  mode)

Initialize bubble (or flower) effect by allocating a buffer to store the state of each particle and setting the initial and max count.

Analogous to init_snow_particles, but for bubbles.

Dead code

◆ envfx_is_jestream_bubble_alive()

s32 envfx_is_jestream_bubble_alive ( s32  index)

Check whether a jetstream bubble should respawn.

Happens if it is laterally 1000 units away from the source or 1500 units above it.

◆ envfx_is_whirlpool_bubble_alive()

s32 envfx_is_whirlpool_bubble_alive ( s32  index)

Check whether a whirlpool bubble is alive.

A bubble respawns when it is too low or close to the center.

◆ envfx_rotate_around_whirlpool()

void envfx_rotate_around_whirlpool ( s32 x,
s32 y,
s32 z 
)

Rotate the input x, y and z around the rotation origin of the whirlpool according to the pitch and yaw of the whirlpool.

◆ envfx_set_bubble_texture()

void envfx_set_bubble_texture ( s32  mode,
s16  index 
)

Appends to the enfvx display list a command setting the appropriate texture for a specific particle.

The display list is not passed as parameter but uses the global sGfxCursor instead.

◆ envfx_set_lava_bubble_position()

void envfx_set_lava_bubble_position ( s32  index,
Vec3s  centerPos 
)

Update the position of a lava bubble to be somewhere around centerPos Uses find_floor to find the height of lava, if no floor or a non-lava floor is found the bubble y is set to -10000, which is why you can see occasional lava bubbles far below the course in Lethal Lava Land.

In the second Bowser fight arena, the visual lava is above the lava floor so lava-bubbles are not normally visible, only if you bring the camera below the lava plane.

◆ envfx_set_max_bubble_particles()

void envfx_set_max_bubble_particles ( s32  mode)

Set the maximum particle count from the gEnvFxBubbleConfig variable, which is set by the whirlpool or jetstream behavior.

◆ envfx_update_bubble_particles()

Gfx* envfx_update_bubble_particles ( s32  mode,
UNUSED Vec3s  marioPos,
Vec3s  camFrom,
Vec3s  camTo 
)

Updates the bubble particle positions, then generates and returns a display list drawing them.

◆ envfx_update_bubbles()

Gfx* envfx_update_bubbles ( s32  mode,
Vec3s  marioPos,
Vec3s  camTo,
Vec3s  camFrom 
)

Update bubble-like environment effects.

Assumes the mode is larger than 10, lower modes are snow effects which are updated in a different function. Returns a display list drawing the particles.

◆ envfx_update_flower()

void envfx_update_flower ( Vec3s  centerPos)

Update flower particles.

Flowers are scattered randomly in front of the camera, and can land on any ground

◆ envfx_update_jetstream()

void envfx_update_jetstream ( void  )

Update the positions of jestream bubble particles.

They move up and outwards.

◆ envfx_update_lava()

void envfx_update_lava ( Vec3s  centerPos)

Update lava bubble animation and give the bubble a new position if the animation is over.

◆ envfx_update_whirlpool()

void envfx_update_whirlpool ( void  )

Update whirlpool particles.

Whirlpool particles start high and far from the center and get sucked into the sink in a spiraling motion.

◆ particle_is_laterally_close()

s32 particle_is_laterally_close ( s32  index,
s32  x,
s32  z,
s32  distance 
)

Check whether the particle with the given index is laterally within distance of point (x, z).

Used to kill flower and bubble particles.

◆ random_flower_offset()

s32 random_flower_offset ( )

Generate a uniform random number in range [-2000, -1000[ or [1000, 2000[ Used to position flower particles.

Variable Documentation

◆ bubble_ptr_0B006848

void* bubble_ptr_0B006848

◆ D_80330690

UNUSED s32 D_80330690 = 0

◆ D_80330694

UNUSED s32 D_80330694 = 0

◆ flower_bubbles_textures_ptr_0B002008

void* flower_bubbles_textures_ptr_0B002008

◆ gBubbleTempVtx

Vtx_t gBubbleTempVtx[3]
Initial value:
= {
{ { 0, 0, 0 }, 0, { 1544, 964 }, { 0xFF, 0xFF, 0xFF, 0xFF } },
{ { 0, 0, 0 }, 0, { 522, -568 }, { 0xFF, 0xFF, 0xFF, 0xFF } },
{ { 0, 0, 0 }, 0, { -498, 964 }, { 0xFF, 0xFF, 0xFF, 0xFF } },
}

Template for a bubble particle triangle.

◆ gEnvFxBubbleConfig

s16 gEnvFxBubbleConfig[10]

This file implements environment effects that are not snow: Flowers (unused), lava bubbles and jetsream/whirlpool bubbles.

Refer to 'envfx_snow.c' for more info about environment effects. Note that the term 'bubbles' is used as a collective name for effects in this file even though flowers aren't bubbles. For the sake of concise naming, flowers fall under bubbles.

◆ lava_bubble_ptr_0B006020

void* lava_bubble_ptr_0B006020

◆ sBubbleParticleCount

s32 sBubbleParticleCount
static

◆ sBubbleParticleMaxCount

s32 sBubbleParticleMaxCount
static

◆ sGfxCursor

Gfx* sGfxCursor
static

◆ tiny_bubble_dl_0B006AB0

void* tiny_bubble_dl_0B006AB0

◆ tiny_bubble_dl_0B006D38

void* tiny_bubble_dl_0B006D38

◆ tiny_bubble_dl_0B006D68

void* tiny_bubble_dl_0B006D68