Add breath meter
1
.gitignore
vendored
@@ -71,6 +71,7 @@ build/*
|
||||
!/assets/**/*custom*.bin
|
||||
!/assets/**/*custom*/**/*.bin
|
||||
!/textures/crash_custom/*.png
|
||||
!/actors/breath_meter/breath_meter_*.png
|
||||
# libultra
|
||||
|
||||
!/lib/*.a
|
||||
|
||||
@@ -66,7 +66,7 @@ KING_BOBOMB_DIRS := king_bobomb water_bubble
|
||||
BOO_DIRS := bookend book chair small_key mad_piano boo haunted_cage
|
||||
MR_I_DIRS := mr_i_eyeball mr_i_iris swoop snufit dorrie scuttlebug
|
||||
HOOT_DIRS := yellow_sphere_small hoot yoshi_egg thwomp bullet_bill heave_ho
|
||||
COINS_DIRS := mist explosion butterfly coin warp_pipe door bowser_key flame blue_fish pebble leaves warp_collision mario_cap power_meter mushroom_1up star sand dirt transparent_star white_particle wooden_signpost tree
|
||||
COINS_DIRS := mist explosion butterfly coin warp_pipe door bowser_key flame blue_fish pebble leaves warp_collision mario_cap breath_meter power_meter mushroom_1up star sand dirt transparent_star white_particle wooden_signpost tree
|
||||
BUBBA_DIRS := bubba wiggler wiggler_body_part lakitu_enemy spiny_egg spiny
|
||||
SKEETER_DIRS := skeeter seaweed water_mine cyan_fish bub water_ring treasure_chest
|
||||
KLEPTO_DIRS := klepto eyerok pokey tornado
|
||||
|
||||
BIN
actors/breath_meter/breath_meter_five_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
actors/breath_meter/breath_meter_four_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
actors/breath_meter/breath_meter_full.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
actors/breath_meter/breath_meter_left_side.rgba16.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
actors/breath_meter/breath_meter_one_segment.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.2 KiB |
BIN
actors/breath_meter/breath_meter_right_side.rgba16.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
actors/breath_meter/breath_meter_seven_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
BIN
actors/breath_meter/breath_meter_six_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
actors/breath_meter/breath_meter_three_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.4 KiB |
BIN
actors/breath_meter/breath_meter_two_segments.rgba16.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
130
actors/breath_meter/model.inc.c
Normal file
@@ -0,0 +1,130 @@
|
||||
#ifdef BREATH_METER
|
||||
// Breath Meter HUD
|
||||
|
||||
// 0x030233E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_left_side[] = {
|
||||
#include "actors/breath_meter/breath_meter_left_side.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030243E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_right_side[] = {
|
||||
#include "actors/breath_meter/breath_meter_right_side.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030253E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_full[] = {
|
||||
#include "actors/breath_meter/breath_meter_full.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x03025BE0
|
||||
ALIGNED8 static const Texture texture_breath_meter_seven_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_seven_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030263E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_six_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_six_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x03026BE0
|
||||
ALIGNED8 static const Texture texture_breath_meter_five_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_five_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030273E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_four_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_four_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x03027BE0
|
||||
ALIGNED8 static const Texture texture_breath_meter_three_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_three_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030283E0
|
||||
ALIGNED8 static const Texture texture_breath_meter_two_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_two_segments.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x03028BE0
|
||||
ALIGNED8 static const Texture texture_breath_meter_one_segments[] = {
|
||||
#include "actors/breath_meter/breath_meter_one_segment.rgba16.inc.c"
|
||||
};
|
||||
|
||||
// 0x030293E0
|
||||
const Texture *const breath_meter_segments_lut[] = {
|
||||
texture_breath_meter_one_segments,
|
||||
texture_breath_meter_two_segments,
|
||||
texture_breath_meter_three_segments,
|
||||
texture_breath_meter_four_segments,
|
||||
texture_breath_meter_five_segments,
|
||||
texture_breath_meter_six_segments,
|
||||
texture_breath_meter_seven_segments,
|
||||
texture_breath_meter_full,
|
||||
};
|
||||
|
||||
// 0x03029400
|
||||
static const Vtx vertex_breath_meter_base[] = {
|
||||
{{{ -32, -32, 0}, 0, { 0, 2016}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 0, -32, 0}, 0, { 992, 2016}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 0, 32, 0}, 0, { 992, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ -32, 32, 0}, 0, { 0, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 0, -32, 0}, 0, { 1, 2016}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 32, -32, 0}, 0, { 1024, 2016}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 32, 32, 0}, 0, { 1024, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 0, 32, 0}, 0, { 1, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
};
|
||||
|
||||
// 0x03029480 - 0x03029530
|
||||
const Gfx dl_breath_meter_base[] = {
|
||||
gsDPPipeSync(),
|
||||
gsSPClearGeometryMode(G_LIGHTING),
|
||||
gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA),
|
||||
gsDPSetRenderMode(G_RM_TEX_EDGE, G_RM_TEX_EDGE2),
|
||||
gsDPSetTextureFilter(G_TF_POINT),
|
||||
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON),
|
||||
gsSPVertex(vertex_breath_meter_base, 8, 0),
|
||||
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD, (G_TX_WRAP | G_TX_NOMIRROR), G_TX_NOMASK, G_TX_NOLOD),
|
||||
gsDPTileSync(),
|
||||
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 6, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
|
||||
gsDPSetTileSize(0, 0, 0, ((32 - 1) << G_TEXTURE_IMAGE_FRAC), ((64 - 1) << G_TEXTURE_IMAGE_FRAC)),
|
||||
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, texture_breath_meter_left_side),
|
||||
gsDPLoadSync(),
|
||||
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
|
||||
gsSP2Triangles( 0, 1, 2, 0x0, 0, 2, 3, 0x0),
|
||||
gsDPSetTextureImage(G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, texture_breath_meter_right_side),
|
||||
gsDPLoadSync(),
|
||||
gsDPLoadBlock(G_TX_LOADTILE, 0, 0, 32 * 64 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES)),
|
||||
gsSP2Triangles( 4, 5, 6, 0x0, 4, 6, 7, 0x0),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
// 0x03029530
|
||||
static const Vtx vertex_breath_meter_health_segments[] = {
|
||||
{{{ -16, -16, 0}, 0, { 0, 992}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 16, -16, 0}, 0, { 992, 992}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ 16, 16, 0}, 0, { 992, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
{{{ -16, 16, 0}, 0, { 0, 0}, {0xff, 0xff, 0xff, 0xff}}},
|
||||
};
|
||||
|
||||
// 0x03029570 - 0x030295A0
|
||||
const Gfx dl_breath_meter_health_segments_begin[] = {
|
||||
gsDPPipeSync(),
|
||||
gsSPVertex(vertex_breath_meter_health_segments, 4, 0),
|
||||
gsDPTileSync(),
|
||||
gsDPSetTile(G_IM_FMT_RGBA, G_IM_SIZ_16b, 8, 0, G_TX_RENDERTILE, 0, G_TX_CLAMP, 5, G_TX_NOLOD, G_TX_CLAMP, 5, G_TX_NOLOD),
|
||||
gsDPSetTileSize(0, 0, 0, ((32 - 1) << G_TEXTURE_IMAGE_FRAC), ((32 - 1) << G_TEXTURE_IMAGE_FRAC)),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
|
||||
// 0x030295A0 - 0x030295D8
|
||||
const Gfx dl_breath_meter_health_segments_end[] = {
|
||||
gsDPPipeSync(),
|
||||
gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF),
|
||||
gsSPSetGeometryMode(G_LIGHTING),
|
||||
gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2),
|
||||
gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE),
|
||||
gsDPSetTextureFilter(G_TF_BILERP),
|
||||
gsSPEndDisplayList(),
|
||||
};
|
||||
#endif
|
||||
@@ -56,6 +56,9 @@ UNUSED static const u64 binid_11 = 11;
|
||||
UNUSED static const u64 binid_12 = 12;
|
||||
|
||||
#include "power_meter/model.inc.c"
|
||||
#ifdef BREATH_METER
|
||||
#include "breath_meter/model.inc.c"
|
||||
#endif
|
||||
UNUSED static const u64 binid_13 = 13;
|
||||
|
||||
UNUSED static const u64 binid_14 = 14;
|
||||
|
||||
@@ -195,6 +195,14 @@ extern const Gfx dl_power_meter_base[];
|
||||
extern const Gfx dl_power_meter_health_segments_begin[];
|
||||
extern const Gfx dl_power_meter_health_segments_end[];
|
||||
|
||||
#ifdef BREATH_METER
|
||||
// breath_meter
|
||||
extern const Texture *const breath_meter_segments_lut[];
|
||||
extern const Gfx dl_breath_meter_base[];
|
||||
extern const Gfx dl_breath_meter_health_segments_begin[];
|
||||
extern const Gfx dl_breath_meter_health_segments_end[];
|
||||
#endif
|
||||
|
||||
// sand
|
||||
extern const Gfx sand_seg3_dl_0302BCD0[];
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
// -- GAME SETTINGS --
|
||||
// Disable lives and hide the lives counter
|
||||
#define DISABLE_LIVES
|
||||
// Air/Breath meter is separate from health meter when underwater
|
||||
//#define BREATH_METER
|
||||
// Number of coins to spawn the "100 coin" star. If you remove the define altogether, then there won't be a 100 coin star at all.
|
||||
#define X_COIN_STAR 100
|
||||
// Stars don't kick you out of the level
|
||||
|
||||
@@ -377,6 +377,10 @@ struct MarioState
|
||||
/*0xBC*/ f32 peakHeight;
|
||||
/*0xC0*/ f32 quicksandDepth;
|
||||
/*0xC4*/ f32 windGravity;
|
||||
#ifdef BREATH_METER
|
||||
s16 breath;
|
||||
u8 breathCounter;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // TYPES_H
|
||||
|
||||
@@ -554,7 +554,6 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *
|
||||
register f32 x = to[0] - from[0];
|
||||
register f32 y = to[1] - from[1];
|
||||
register f32 z = to[2] - from[2];
|
||||
|
||||
*dist = sqrtf(sqr(x) + sqr(y) + sqr(z));
|
||||
*pitch = atan2s(sqrtf(sqr(x) + sqr(z)), y);
|
||||
*yaw = atan2s(z, x);
|
||||
@@ -570,6 +569,21 @@ void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s32 pitch, s32 yaw
|
||||
to[2] = from[2] + dist * coss(pitch) * coss(yaw);
|
||||
}
|
||||
|
||||
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec) {
|
||||
s16 dist = (target - current);
|
||||
if (dist >= 0) { // target >= current
|
||||
current = ((dist > inc) ? (current + inc) : target);
|
||||
} else { // target < current
|
||||
current = ((dist < -dec) ? (current - dec) : target);
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec) {
|
||||
*current = approach_s16(*current, target, inc, dec);
|
||||
return !(*current == target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value 'current' after it tries to approach target, going up at
|
||||
* most 'inc' and going down at most 'dec'.
|
||||
@@ -584,6 +598,11 @@ s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec) {
|
||||
return current;
|
||||
}
|
||||
|
||||
Bool32 approach_s32_bool(s32 *current, s32 target, s32 inc, s32 dec) {
|
||||
*current = approach_s32(*current, target, inc, dec);
|
||||
return !(*current == target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the value 'current' after it tries to approach target, going up at
|
||||
* most 'inc' and going down at most 'dec'.
|
||||
@@ -598,6 +617,28 @@ f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
|
||||
return current;
|
||||
}
|
||||
|
||||
Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec) {
|
||||
*current = approach_f32(*current, target, inc, dec);
|
||||
return !(*current == target);
|
||||
}
|
||||
|
||||
s32 approach_f32_signed(f32 *current, f32 target, f32 inc) {
|
||||
s32 reachedTarget = FALSE;
|
||||
*current += inc;
|
||||
if (inc >= 0.0f) {
|
||||
if (*current > target) {
|
||||
*current = target;
|
||||
reachedTarget = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (*current < target) {
|
||||
*current = target;
|
||||
reachedTarget = TRUE;
|
||||
}
|
||||
}
|
||||
return reachedTarget;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to approach_s32, but converts to s16 and allows for overflow between 32767 and -32768
|
||||
*/
|
||||
|
||||
@@ -374,8 +374,19 @@ void mtxf_rotate_xy(Mtx *mtx, s32 angle);
|
||||
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
|
||||
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);
|
||||
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s32 pitch, s32 yaw);
|
||||
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec);
|
||||
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
|
||||
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
|
||||
Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec);
|
||||
Bool32 approach_s32_bool(s32 *current, s32 target, s32 inc, s32 dec);
|
||||
Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec);
|
||||
#define approach_s16_symmetric(current, target, inc) approach_s16((current), (target), (inc), (inc))
|
||||
#define approach_s32_symmetric(current, target, inc) approach_s32((current), (target), (inc), (inc))
|
||||
#define approach_f32_symmetric(current, target, inc) approach_f32((current), (target), (inc), (inc))
|
||||
#define approach_s16_symmetric_bool(current, target, inc) approach_s16_bool((current), (target), (inc), (inc))
|
||||
#define approach_s32_symmetric_bool(current, target, inc) approach_s32_bool((current), (target), (inc), (inc))
|
||||
#define approach_f32_symmetric_bool(current, target, inc) approach_f32_bool((current), (target), (inc), (inc))
|
||||
s32 approach_f32_signed(f32 *current, f32 target, f32 inc);
|
||||
s32 approach_angle(s32 current, s32 target, s32 inc);
|
||||
s16 atan2s(f32 y, f32 x);
|
||||
f32 atan2f(f32 a, f32 b);
|
||||
|
||||
@@ -30,7 +30,10 @@ void bhv_recovery_heart_loop(void) {
|
||||
}
|
||||
|
||||
if ((o->oSpinningHeartTotalSpin += o->oAngleVelYaw) >= 0x10000) {
|
||||
gMarioStates[0].healCounter += 4;
|
||||
gMarioState->healCounter += 4;
|
||||
#ifdef BREATH_METER
|
||||
gMarioState->breathCounter += 4;
|
||||
#endif
|
||||
o->oSpinningHeartTotalSpin -= 0x10000;
|
||||
}
|
||||
|
||||
|
||||