+1








f3e61a31aa
* buffers: refresh 15 and revert to base decomp * behavior script * color helper functions * extended bounds * egeo_layout * fixed model ids * camera conf improved * message panel ucode small * graph node * level script * mathutil updates * mathutil updates (allow unused funcs) * behaviors a - beta_fish * Add librtc and fix some data declarations * Move GRUCODE define to proper location in makefile * Refresh 15 * extra * Make ROM name smaller and change messages printed on build a bit * Fix console (lol) * Update UNF to latest master * Make ucode load from .o's (and also fix Super3D) * Fix crash with rumble + custom mario model * graph node and mathutil * removed behaviors * Ldtob documentation * _Putfld labeling * area * behavior actions * camera * debug updates * bubbles * envfx snow * farcall helpers * game init * geo misc * hud * only check if VC on render init * ingame menu * revert goddard to base decomp * insn disasm * interaction documentation * level geo * level update defines * macro special objects formatting changes * main.h documentation * map parser documentation & formatting * airborne documentation * mario actions automatic documentation * mario actions cutscene documentation * mario actions moving documentation and options * mario actions object documentation and options * mario stationary documentation * mario submerged documentation * mario misc documentation * mario step: ledge grab fixes and documentation * mario documentation * memory.h documentation * moving textures * object behaviors * object collision * fix flamethrower bug * object helpers * object list processor documentation * paintings * platform displacement * print / printf * puppycam absf * puppyprint updates and formatting changes * rendering graph node performance optimizations * rumble opt and doc * hqvm back to ultrasm64 * save file documentation and unlock defines * s2d engine * reset various files to ultrasm64 * file select * intro geo documentation * screen transition documentation * segment2.h * shadow overhaul * skybox refactor * sound init: clean up define usage + documentation * spawn object optimizations and documentation * spawn sound cleanup * sram to ultrasm64 * star select cleanup * title screen cleanup * dialogs / text * rename stomp smoke * stomp smoke -> small water splash * updated README * compilation flags * optimized file positions + support function/data sections * surface collision performance improvements * surface load optimizations * camera conf documentation * Allow easier command for opening puppyprint debug * Rearranged framebuffers & fixed puppyprint console printing * Fix shadow scaling and shifting * Fix SILHOUETTE, OBJECTS_REJ, and ucode loading, also clean up render phase system a bit. * Fixed build with BETTER_HANGING off * Clean up OBJECTS_REJ ifdefs * Fix duplicate comment & graph render layers/flags bitmask * Fixed build with BETTER_HANGING off * Fix Fast64 importing by reverting sSegmentTable change * Readded missing functions that caused build errors with Mario head enabled * Fixed clang compilation issues * Add INTER mode for geo_update_layer_transparency * Fix build warnings * bugfix: miscalculation in obj_turn_toward_object * Some puppytech fixes * Further Puppycamera fixes * Fix BUGFIX_DIALOG_TIME_STOP Fixes #136 * Fix sliding platform bparams * Add LEGACY_SHADOW_IDS define for Fast64 compatibility * Apply suggested changes * Better find_in_bounds_yaw_wdw_bob_thi ifdef * Fix build warnings for unused functions * Fixed stale reference bug from obj_mark_for_deletion change * Fixed incorrect digit for 100s #145 * Change groundpound-fix define and functionality to just disable bonking * Fixed puppyroll #134 * Adjust height value for terrain angle to kick in * fixed hi score flashing * Remove menudata backup (#131) Not considered important enough to keep * Fix fread() build warning * Add COURSE_NUM_TO_INDEX to save_file_get_star_flags check in bhv_unagi_init * Fix approach_s16 return value * Use boolean defines for oCapDoScaleVertically * Make the door lock a part of the key door model to eliminate z-fighting, also reduce z fighting on numbered doors with AUTO_LOD enabled. * Move flames to LAYER_TRANSPARENT_INTER * Resolved some compiler warnings and added FALL_THROUGH define (#168) * Address some more compiler warnings with different define toggles * Remove unnecessary fallthrough attribute * fixed geo_process_billboard floating point exception * Allow water to face any direction * Initialize focOffset so that BBH doesn't crash * Removed superfluous RDP commands when switching microcodes which would override scissor * Set OBJ_FLAG_DONT_CALC_COLL_DIST on bhvUkikiCage * Fix rumble build * Fixed UNLOCK_FPS strobing * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update src/game/object_helpers.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Fix LEGACY_SHADOW_IDS id conflict * Use the vanilla default value for rotating fire bars if bparam2 is 0 * START_LEVEL safeguard * Fix some drawing distance issues caused by AUTO_COLLISION_DISTANCE * Fix rumble build * Fixed spline poll code using the wrong values for keyframes * Update readme with better credits Better credits for individual contributors * add arthur * added falco and moose * add fazana * le funny typo * added S2DEX engine to credits * silhouette + axo + ratio * remove specific callouts + add auto col distance * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Update data/behavior_data.c Co-authored-by: thecozies <79979276+thecozies@users.noreply.github.com> * Revert formatting changes to match vanilla decomp * Re-implement Y buffer for find_ceil * Re-implement POWER_STARS_HEAL for normal Power Stars * Start level comment & exit course comment/collapse * utilize reonucam technique for FAST_VERTICAL_CAMERA_MOVEMENT * Fix "MAX_REFERENCED_WALLS" typo * Allow stop_and_set_height_to_floor to work at any height if Mario is teleporting (#213) * Revert stop_and_set_height_to_floor to vanilla Fixes #208 * Fixed sAudioEnabled so that it disables audio CPU processing as well * Fixed puppyprint debug RDP us calculations * Renamed sAudioEnabled to gAudioEnabled * Replaced mtxf_to_mtx_asm with an equivalent implementation that supports WORLD_SCALE * Moved extended bounds and world scale configuration to a new config_world.h file * Default all objects to non-rej (#227) Fixes #221 (Default all objects to non-rej) * Fix #221 * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled (#211) * Fix VISUAL_DEBUG breaking/crashing when OBJECTS_REJ is disabled * Change vtl decrement in visual_surface_display from 6 to 3 Fixes #207 * Make area in SL igloo wider to prevent a softlock (#233) Fixes #210 * Fix coin formation coins being deleted if they spawn in the middle of a floor, also fix TTM slide coin position (#232) Fixes #201 * Make UNLOCK_ALL apply to more things * Fix wrong ifdef/ifndef in bhv_invisible_objects_under_bridge_init * Change chain chomp load/unload distances depending on number of segments (#237) Fixes #192 * added WATER_PLUNGE_UPWARP define * Add reonucam patch (#239) * added reonucam patch Fixes #218 * Fix how shadows handle water/transparency/height (#228) * Fix how shadows handle water/transparency/height * Change shadow check for flying carpets from a level specific check to a oPlatformOnTrackType check Fixes #179 * added reonucam credit * delete unnecesary patches * Apply suggested changes * murdered more patches * UNLOCK_ALL unlocks the cap boxes * UNLOCK_ALL unlocks cap boxes (slightly more epic edition) * revert ceil buffer * Renamed HD_INTRO_TEXTURES define, separated intro floombas * prevent double definition of floombas * actually prevent floomba redefinition * Develop/refactor default defines (#242) * Changed default config options * Added build dir to includePaths for pngs * disable NO_SLEEP by default * Disable puppyprint by default Sorry fazana 😔 * fix typos * add comment about BETTER_REVERB console perf * disable blue coin switch retry by default * Update config_audio.h Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com> * revert air step line to vanilla to fix bitfs scaling platform issue (#247) Fixes #200 * Fix stuttering on thin slopes (#248) * Fix stuttering on thin slopes * Revert vec3f_find_ceil calls to vanilla * Rename vec3f_find_ceil to find_mario_ceil * Update src/engine/surface_collision.h Fixes #249 * Swap static and dynamic surface checks back to vanilla order (#253) * Swap static and dynamic surface checks back to vanilla order * re-enable DISABLE_ALL config Fixes #251 #252 * Fixed save and quitting while in widescreen (#257) * Fixed save and quitting while in widescreen * use define for the level * all my homies hate ifdefs * skip wall offsets < 0 (#255) Fixes #255 * #264: Document non-stop stars' issues (#267) * #264: Document non-stop stars' issues * Update include/config/config_game.h * nonstop vanilla comment * derive margin_radius from radius after capping at 200 (#266) Fixes #259 * Config cleanup/refactor (#269) * Moved puppyprint define to graphics / rearranged some debug defines for ease of access * Moved compatibility safeguards to config_safeguards.h * spacing and comment formatting * #272 Move GFX_POOL_SIZE to config_graphics.h * disable EASIER_DIALOG_TRIGGER by default * prevent redefining warnings * small ifdef typo * changed ifndef to undefs Fixes #262 Fixes #272 * Improved movement config documentation related to turning around (#271) Fixes #270 * rename CUSTOM_DEBUG, add comments (#275) * Update README.md (#277) * v2.0.0 Co-authored-by: CrashOveride95 <crashoveride953@gmail.com> Co-authored-by: Arceveti <73617174+Arceveti@users.noreply.github.com> Co-authored-by: n64 <n64> Co-authored-by: Fazana <52551480+FazanaJ@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <mrwiseguyromhacking@gmail.com> Co-authored-by: aglab2 <aglab3@gmail.com> Co-authored-by: gheskett <gheskett@gmail.com> Co-authored-by: Reonu <danileon95@gmail.com> Co-authored-by: Axollyon <20480418+Axollyon@users.noreply.github.com> Co-authored-by: Mr-Wiseguy <68165316+Mr-Wiseguy@users.noreply.github.com>
616 lines
21 KiB
C
616 lines
21 KiB
C
#include <PR/ultratypes.h>
|
|
|
|
#include "sm64.h"
|
|
#include "actors/common1.h"
|
|
#include "gfx_dimensions.h"
|
|
#include "game_init.h"
|
|
#include "level_update.h"
|
|
#include "camera.h"
|
|
#include "print.h"
|
|
#include "ingame_menu.h"
|
|
#include "hud.h"
|
|
#include "segment2.h"
|
|
#include "area.h"
|
|
#include "save_file.h"
|
|
#include "print.h"
|
|
#include "engine/surface_load.h"
|
|
#include "engine/math_util.h"
|
|
#include "puppycam2.h"
|
|
#include "puppyprint.h"
|
|
|
|
#include "config.h"
|
|
|
|
/* @file hud.c
|
|
* This file implements HUD rendering and power meter animations.
|
|
* That includes stars, lives, coins, camera status, power meter, timer
|
|
* cannon reticle, and the unused keys.
|
|
**/
|
|
|
|
#define HUD_POWER_METER_X 140
|
|
#define HUD_POWER_METER_EMPHASIZED_Y 166
|
|
#define HUD_POWER_METER_Y 200
|
|
#define HUD_POWER_METER_HIDDEN_Y 300
|
|
|
|
#ifdef BREATH_METER
|
|
// #ifdef DISABLE_LIVES
|
|
// #define HUD_BREATH_METER_X 64
|
|
// #define HUD_BREATH_METER_Y 200
|
|
// #define HUD_BREATH_METER_HIDDEN_Y 300
|
|
// #else
|
|
#define HUD_BREATH_METER_X 40
|
|
#define HUD_BREATH_METER_Y 32
|
|
#define HUD_BREATH_METER_HIDDEN_Y -20
|
|
// #endif
|
|
#endif
|
|
|
|
// ------------- FPS COUNTER ---------------
|
|
// To use it, call print_fps(x,y); every frame.
|
|
#define FRAMETIME_COUNT 30
|
|
|
|
OSTime frameTimes[FRAMETIME_COUNT];
|
|
u8 curFrameTimeIndex = 0;
|
|
|
|
#include "PR/os_convert.h"
|
|
|
|
// Call once per frame
|
|
f32 calculate_and_update_fps() {
|
|
OSTime newTime = osGetTime();
|
|
OSTime oldTime = frameTimes[curFrameTimeIndex];
|
|
frameTimes[curFrameTimeIndex] = newTime;
|
|
|
|
curFrameTimeIndex++;
|
|
if (curFrameTimeIndex >= FRAMETIME_COUNT) {
|
|
curFrameTimeIndex = 0;
|
|
}
|
|
return ((f32)FRAMETIME_COUNT * 1000000.0f) / (s32)OS_CYCLES_TO_USEC(newTime - oldTime);
|
|
}
|
|
|
|
void print_fps(s32 x, s32 y) {
|
|
f32 fps = calculate_and_update_fps();
|
|
char text[14];
|
|
|
|
sprintf(text, "FPS %2.2f", fps);
|
|
#ifdef PUPPYPRINT
|
|
print_small_text(x, y, text, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
|
|
#else
|
|
print_text(x, y, text);
|
|
#endif
|
|
|
|
}
|
|
|
|
// ------------ END OF FPS COUNER -----------------
|
|
|
|
struct PowerMeterHUD {
|
|
s8 animation;
|
|
s16 x;
|
|
s16 y;
|
|
};
|
|
|
|
struct CameraHUD {
|
|
s16 status;
|
|
};
|
|
|
|
// Stores health segmented value defined by numHealthWedges
|
|
// When the HUD is rendered this value is 8, full health.
|
|
static s16 sPowerMeterStoredHealth;
|
|
|
|
static struct PowerMeterHUD sPowerMeterHUD = {
|
|
POWER_METER_HIDDEN,
|
|
HUD_POWER_METER_X,
|
|
HUD_POWER_METER_HIDDEN_Y,
|
|
};
|
|
|
|
// Power Meter timer that keeps counting when it's visible.
|
|
// Gets reset when the health is filled and stops counting
|
|
// when the power meter is hidden.
|
|
s32 sPowerMeterVisibleTimer = 0;
|
|
|
|
#ifdef BREATH_METER
|
|
static s16 sBreathMeterStoredValue;
|
|
static struct PowerMeterHUD sBreathMeterHUD = {
|
|
BREATH_METER_HIDDEN,
|
|
HUD_BREATH_METER_X,
|
|
HUD_BREATH_METER_HIDDEN_Y,
|
|
};
|
|
s32 sBreathMeterVisibleTimer = 0;
|
|
#endif
|
|
|
|
static struct CameraHUD sCameraHUD = { CAM_STATUS_NONE };
|
|
|
|
/**
|
|
* Renders a rgba16 16x16 glyph texture from a table list.
|
|
*/
|
|
void render_hud_tex_lut(s32 x, s32 y, Texture *texture) {
|
|
gDPPipeSync(gDisplayListHead++);
|
|
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, texture);
|
|
gSPDisplayList(gDisplayListHead++, &dl_hud_img_load_tex_block);
|
|
gSPTextureRectangle(gDisplayListHead++, x << 2, y << 2, (x + 15) << 2, (y + 15) << 2,
|
|
G_TX_RENDERTILE, 0, 0, 4 << 10, 1 << 10);
|
|
}
|
|
|
|
/**
|
|
* Renders a rgba16 8x8 glyph texture from a table list.
|
|
*/
|
|
void render_hud_small_tex_lut(s32 x, s32 y, Texture *texture) {
|
|
gDPSetTile(gDisplayListHead++, 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);
|
|
gDPTileSync(gDisplayListHead++);
|
|
gDPSetTile(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 2, 0, G_TX_RENDERTILE, 0,
|
|
G_TX_CLAMP, 3, G_TX_NOLOD, G_TX_CLAMP, 3, G_TX_NOLOD);
|
|
gDPSetTileSize(gDisplayListHead++, G_TX_RENDERTILE, 0, 0, (8 - 1) << G_TEXTURE_IMAGE_FRAC, (8 - 1) << G_TEXTURE_IMAGE_FRAC);
|
|
gDPPipeSync(gDisplayListHead++);
|
|
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, texture);
|
|
gDPLoadSync(gDisplayListHead++);
|
|
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 8 * 8 - 1, CALC_DXT(8, G_IM_SIZ_16b_BYTES));
|
|
gSPTextureRectangle(gDisplayListHead++, x << 2, y << 2, (x + 7) << 2, (y + 7) << 2, G_TX_RENDERTILE,
|
|
0, 0, 4 << 10, 1 << 10);
|
|
}
|
|
|
|
/**
|
|
* Renders power meter health segment texture using a table list.
|
|
*/
|
|
void render_power_meter_health_segment(s16 numHealthWedges) {
|
|
Texture *(*healthLUT)[] = segmented_to_virtual(&power_meter_health_segments_lut);
|
|
|
|
gDPPipeSync(gDisplayListHead++);
|
|
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1,
|
|
(*healthLUT)[numHealthWedges - 1]);
|
|
gDPLoadSync(gDisplayListHead++);
|
|
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES));
|
|
gSP1Triangle(gDisplayListHead++, 0, 1, 2, 0);
|
|
gSP1Triangle(gDisplayListHead++, 0, 2, 3, 0);
|
|
}
|
|
|
|
/**
|
|
* Renders power meter display lists.
|
|
* That includes the "POWER" base and the colored health segment textures.
|
|
*/
|
|
void render_dl_power_meter(s16 numHealthWedges) {
|
|
Mtx *mtx = alloc_display_list(sizeof(Mtx));
|
|
|
|
if (mtx == NULL) {
|
|
return;
|
|
}
|
|
|
|
guTranslate(mtx, (f32) sPowerMeterHUD.x, (f32) sPowerMeterHUD.y, 0);
|
|
|
|
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx++),
|
|
G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH);
|
|
gSPDisplayList(gDisplayListHead++, &dl_power_meter_base);
|
|
|
|
if (numHealthWedges != 0) {
|
|
gSPDisplayList(gDisplayListHead++, &dl_power_meter_health_segments_begin);
|
|
render_power_meter_health_segment(numHealthWedges);
|
|
gSPDisplayList(gDisplayListHead++, &dl_power_meter_health_segments_end);
|
|
}
|
|
|
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
|
}
|
|
|
|
/**
|
|
* Power meter animation called when there's less than 8 health segments
|
|
* Checks its timer to later change into deemphasizing mode.
|
|
*/
|
|
void animate_power_meter_emphasized(void) {
|
|
s16 hudDisplayFlags = gHudDisplay.flags;
|
|
|
|
if (!(hudDisplayFlags & HUD_DISPLAY_FLAG_EMPHASIZE_POWER)) {
|
|
if (sPowerMeterVisibleTimer == 45.0f) {
|
|
sPowerMeterHUD.animation = POWER_METER_DEEMPHASIZING;
|
|
}
|
|
} else {
|
|
sPowerMeterVisibleTimer = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Power meter animation called after emphasized mode.
|
|
* Moves power meter y pos speed until it's at 200 to be visible.
|
|
*/
|
|
static void animate_power_meter_deemphasizing(void) {
|
|
s16 speed = 5;
|
|
|
|
if (sPowerMeterHUD.y > HUD_POWER_METER_Y - 20) speed = 3;
|
|
if (sPowerMeterHUD.y > HUD_POWER_METER_Y - 10) speed = 2;
|
|
if (sPowerMeterHUD.y > HUD_POWER_METER_Y - 5) speed = 1;
|
|
|
|
sPowerMeterHUD.y += speed;
|
|
|
|
if (sPowerMeterHUD.y > HUD_POWER_METER_Y) {
|
|
sPowerMeterHUD.y = HUD_POWER_METER_Y;
|
|
sPowerMeterHUD.animation = POWER_METER_VISIBLE;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Power meter animation called when there's 8 health segments.
|
|
* Moves power meter y pos quickly until it's at 301 to be hidden.
|
|
*/
|
|
static void animate_power_meter_hiding(void) {
|
|
sPowerMeterHUD.y += 20;
|
|
if (sPowerMeterHUD.y > HUD_POWER_METER_HIDDEN_Y) {
|
|
sPowerMeterHUD.animation = POWER_METER_HIDDEN;
|
|
sPowerMeterVisibleTimer = 0;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles power meter actions depending of the health segments values.
|
|
*/
|
|
void handle_power_meter_actions(s16 numHealthWedges) {
|
|
// Show power meter if health is not full, less than 8
|
|
if (numHealthWedges < 8 && sPowerMeterStoredHealth == 8
|
|
&& sPowerMeterHUD.animation == POWER_METER_HIDDEN) {
|
|
sPowerMeterHUD.animation = POWER_METER_EMPHASIZED;
|
|
sPowerMeterHUD.y = HUD_POWER_METER_EMPHASIZED_Y;
|
|
}
|
|
|
|
// Show power meter if health is full, has 8
|
|
if (numHealthWedges == 8 && sPowerMeterStoredHealth == 7) {
|
|
sPowerMeterVisibleTimer = 0;
|
|
}
|
|
|
|
// After health is full, hide power meter
|
|
if (numHealthWedges == 8 && sPowerMeterVisibleTimer > 45.0f) {
|
|
sPowerMeterHUD.animation = POWER_METER_HIDING;
|
|
}
|
|
|
|
// Update to match health value
|
|
sPowerMeterStoredHealth = numHealthWedges;
|
|
|
|
#ifndef BREATH_METER
|
|
// If Mario is swimming, keep power meter visible
|
|
if (gPlayerCameraState->action & ACT_FLAG_SWIMMING) {
|
|
if (sPowerMeterHUD.animation == POWER_METER_HIDDEN
|
|
|| sPowerMeterHUD.animation == POWER_METER_EMPHASIZED) {
|
|
sPowerMeterHUD.animation = POWER_METER_DEEMPHASIZING;
|
|
sPowerMeterHUD.y = HUD_POWER_METER_EMPHASIZED_Y;
|
|
}
|
|
sPowerMeterVisibleTimer = 0;
|
|
}
|
|
#endif
|
|
}
|
|
|
|
/**
|
|
* Renders the power meter that shows when Mario is in underwater
|
|
* or has taken damage and has less than 8 health segments.
|
|
* And calls a power meter animation function depending of the value defined.
|
|
*/
|
|
void render_hud_power_meter(void) {
|
|
s16 shownHealthWedges = gHudDisplay.wedges;
|
|
if (sPowerMeterHUD.animation != POWER_METER_HIDING) handle_power_meter_actions(shownHealthWedges);
|
|
if (sPowerMeterHUD.animation == POWER_METER_HIDDEN) return;
|
|
switch (sPowerMeterHUD.animation) {
|
|
case POWER_METER_EMPHASIZED: animate_power_meter_emphasized(); break;
|
|
case POWER_METER_DEEMPHASIZING: animate_power_meter_deemphasizing(); break;
|
|
case POWER_METER_HIDING: animate_power_meter_hiding(); break;
|
|
default: break;
|
|
}
|
|
render_dl_power_meter(shownHealthWedges);
|
|
sPowerMeterVisibleTimer++;
|
|
}
|
|
|
|
#ifdef BREATH_METER
|
|
/**
|
|
* Renders breath meter health segment texture using a table list.
|
|
*/
|
|
void render_breath_meter_segment(s16 numBreathWedges) {
|
|
Texture *(*breathLUT)[];
|
|
breathLUT = segmented_to_virtual(&breath_meter_segments_lut);
|
|
gDPPipeSync(gDisplayListHead++);
|
|
gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, (*breathLUT)[numBreathWedges - 1]);
|
|
gDPLoadSync(gDisplayListHead++);
|
|
gDPLoadBlock(gDisplayListHead++, G_TX_LOADTILE, 0, 0, 32 * 32 - 1, CALC_DXT(32, G_IM_SIZ_16b_BYTES));
|
|
gSP1Triangle(gDisplayListHead++, 0, 1, 2, 0);
|
|
gSP1Triangle(gDisplayListHead++, 0, 2, 3, 0);
|
|
}
|
|
|
|
/**
|
|
* Renders breath meter display lists.
|
|
* That includes the base and the colored segment textures.
|
|
*/
|
|
void render_dl_breath_meter(s16 numBreathWedges) {
|
|
Mtx *mtx = alloc_display_list(sizeof(Mtx));
|
|
|
|
if (mtx == NULL) {
|
|
return;
|
|
}
|
|
|
|
guTranslate(mtx, (f32) sBreathMeterHUD.x, (f32) sBreathMeterHUD.y, 0);
|
|
gSPMatrix( gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx++),
|
|
G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_PUSH);
|
|
gSPDisplayList( gDisplayListHead++, &dl_breath_meter_base);
|
|
if (numBreathWedges != 0) {
|
|
gSPDisplayList(gDisplayListHead++, &dl_breath_meter_health_segments_begin);
|
|
render_breath_meter_segment(numBreathWedges);
|
|
gSPDisplayList(gDisplayListHead++, &dl_breath_meter_health_segments_end);
|
|
}
|
|
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
|
|
}
|
|
|
|
/**
|
|
* Breath meter animation called after emphasized mode.
|
|
* Moves breath meter y pos speed until it's visible.
|
|
*/
|
|
static void animate_breath_meter_sliding_in(void) {
|
|
approach_s16_symmetric_bool(&sBreathMeterHUD.y, HUD_BREATH_METER_Y, 5);
|
|
if (sBreathMeterHUD.y == HUD_BREATH_METER_Y) {
|
|
sBreathMeterHUD.animation = BREATH_METER_VISIBLE;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Breath meter animation called when there's 8 health segments.
|
|
* Moves breath meter y pos quickly until it's hidden.
|
|
*/
|
|
static void animate_breath_meter_sliding_out(void) {
|
|
approach_s16_symmetric_bool(&sBreathMeterHUD.y, HUD_BREATH_METER_HIDDEN_Y, 20);
|
|
if (sBreathMeterHUD.y == HUD_BREATH_METER_HIDDEN_Y) {
|
|
sBreathMeterHUD.animation = BREATH_METER_HIDDEN;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handles breath meter actions depending of the health segments values.
|
|
*/
|
|
void handle_breath_meter_actions(s16 numBreathWedges) {
|
|
// Show breath meter if health is not full, less than 8
|
|
if ((numBreathWedges < 8) && (sBreathMeterStoredValue == 8) && sBreathMeterHUD.animation == BREATH_METER_HIDDEN) {
|
|
sBreathMeterHUD.animation = BREATH_METER_SHOWING;
|
|
// sBreathMeterHUD.y = HUD_BREATH_METER_Y;
|
|
}
|
|
// Show breath meter if breath is full, has 8
|
|
if ((numBreathWedges == 8) && (sBreathMeterStoredValue == 7)) sBreathMeterVisibleTimer = 0;
|
|
// After breath is full, hide breath meter
|
|
if ((numBreathWedges == 8) && (sBreathMeterVisibleTimer > 45)) sBreathMeterHUD.animation = BREATH_METER_HIDING;
|
|
// Update to match breath value
|
|
sBreathMeterStoredValue = numBreathWedges;
|
|
// If Mario is swimming, keep breath meter visible
|
|
if (gPlayerCameraState->action & ACT_FLAG_SWIMMING) {
|
|
if (sBreathMeterHUD.animation == BREATH_METER_HIDDEN) {
|
|
sBreathMeterHUD.animation = BREATH_METER_SHOWING;
|
|
}
|
|
sBreathMeterVisibleTimer = 0;
|
|
}
|
|
}
|
|
|
|
void render_hud_breath_meter(void) {
|
|
s16 shownBreathAmount = gHudDisplay.breath;
|
|
if (sBreathMeterHUD.animation != BREATH_METER_HIDING) handle_breath_meter_actions(shownBreathAmount);
|
|
if (sBreathMeterHUD.animation == BREATH_METER_HIDDEN) return;
|
|
switch (sBreathMeterHUD.animation) {
|
|
case BREATH_METER_SHOWING: animate_breath_meter_sliding_in(); break;
|
|
case BREATH_METER_HIDING: animate_breath_meter_sliding_out(); break;
|
|
default: break;
|
|
}
|
|
render_dl_breath_meter(shownBreathAmount);
|
|
sBreathMeterVisibleTimer++;
|
|
}
|
|
#endif
|
|
|
|
#define HUD_TOP_Y 209
|
|
|
|
/**
|
|
* Renders the amount of lives Mario has.
|
|
*/
|
|
void render_hud_mario_lives(void) {
|
|
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(22), HUD_TOP_Y, ","); // 'Mario Head' glyph
|
|
print_text(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(38), HUD_TOP_Y, "*"); // 'X' glyph
|
|
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_LEFT_EDGE(54), HUD_TOP_Y, "%d", gHudDisplay.lives);
|
|
}
|
|
|
|
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
|
|
void render_debug_mode(void) {
|
|
print_text(180, 40, "DEBUG MODE");
|
|
print_text_fmt_int(5, 20, "Z %d", gMarioState->pos[2]);
|
|
print_text_fmt_int(5, 40, "Y %d", gMarioState->pos[1]);
|
|
print_text_fmt_int(5, 60, "X %d", gMarioState->pos[0]);
|
|
print_text_fmt_int(10, 100, "SPD %d", (s32) gMarioState->forwardVel);
|
|
print_text_fmt_int(10, 120, "ANG 0*%04x", (u16) gMarioState->faceAngle[1]);
|
|
print_fps(10,80);
|
|
}
|
|
#endif
|
|
|
|
/**
|
|
* Renders the amount of coins collected.
|
|
*/
|
|
void render_hud_coins(void) {
|
|
print_text(168, HUD_TOP_Y, "$"); // 'Coin' glyph
|
|
print_text(184, HUD_TOP_Y, "*"); // 'X' glyph
|
|
print_text_fmt_int(198, HUD_TOP_Y, "%d", gHudDisplay.coins);
|
|
}
|
|
|
|
#define HUD_STARS_X 78
|
|
|
|
/**
|
|
* Renders the amount of stars collected.
|
|
* Disables "X" glyph when Mario has 100 stars or more.
|
|
*/
|
|
void render_hud_stars(void) {
|
|
if (gHudFlash == HUD_FLASH_STARS && gGlobalTimer & 0x8) return;
|
|
s8 showX = (gHudDisplay.stars < 100);
|
|
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(HUD_STARS_X), HUD_TOP_Y, "^"); // 'Star' glyph
|
|
if (showX) print_text((GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(HUD_STARS_X) + 16), HUD_TOP_Y, "*"); // 'X' glyph
|
|
print_text_fmt_int((showX * 14) + GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(HUD_STARS_X - 16),
|
|
HUD_TOP_Y, "%d", gHudDisplay.stars);
|
|
}
|
|
|
|
/**
|
|
* Unused function that renders the amount of keys collected.
|
|
* Leftover function from the beta version of the game.
|
|
*/
|
|
void render_hud_keys(void) {
|
|
s16 i;
|
|
|
|
for (i = 0; i < gHudDisplay.keys; i++) {
|
|
print_text((i * 16) + 220, 142, "|"); // unused glyph - beta key
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Renders the timer when Mario start sliding in PSS.
|
|
*/
|
|
void render_hud_timer(void) {
|
|
Texture *(*hudLUT)[58] = segmented_to_virtual(&main_hud_lut);
|
|
u16 timerValFrames = gHudDisplay.timer;
|
|
u16 timerMins = timerValFrames / (30 * 60);
|
|
u16 timerSecs = (timerValFrames - (timerMins * 1800)) / 30;
|
|
u16 timerFracSecs = ((timerValFrames - (timerMins * 1800) - (timerSecs * 30)) & 0xFFFF) / 3;
|
|
|
|
#if MULTILANG
|
|
switch (eu_get_language()) {
|
|
case LANGUAGE_ENGLISH: print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "TIME"); break;
|
|
case LANGUAGE_FRENCH: print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(155), 185, "TEMPS"); break;
|
|
case LANGUAGE_GERMAN: print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "ZEIT"); break;
|
|
}
|
|
#else
|
|
print_text(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(150), 185, "TIME");
|
|
#endif
|
|
|
|
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(91), 185, "%0d", timerMins);
|
|
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(71), 185, "%02d", timerSecs);
|
|
print_text_fmt_int(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(37), 185, "%d", timerFracSecs);
|
|
|
|
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
|
|
render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(81), 32, (*hudLUT)[GLYPH_APOSTROPHE]);
|
|
render_hud_tex_lut(GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(46), 32, (*hudLUT)[GLYPH_DOUBLE_QUOTE]);
|
|
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
|
|
}
|
|
|
|
/**
|
|
* Sets HUD status camera value depending of the actions
|
|
* defined in update_camera_status.
|
|
*/
|
|
void set_hud_camera_status(s16 status) {
|
|
sCameraHUD.status = status;
|
|
}
|
|
|
|
/**
|
|
* Renders camera HUD glyphs using a table list, depending of
|
|
* the camera status called, a defined glyph is rendered.
|
|
*/
|
|
void render_hud_camera_status(void) {
|
|
Texture *(*cameraLUT)[6] = segmented_to_virtual(&main_hud_camera_lut);
|
|
s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54);
|
|
s32 y = 205;
|
|
|
|
if (sCameraHUD.status == CAM_STATUS_NONE) {
|
|
return;
|
|
}
|
|
|
|
gSPDisplayList(gDisplayListHead++, dl_hud_img_begin);
|
|
render_hud_tex_lut(x, y, (*cameraLUT)[GLYPH_CAM_CAMERA]);
|
|
|
|
switch (sCameraHUD.status & CAM_STATUS_MODE_GROUP) {
|
|
case CAM_STATUS_MARIO:
|
|
render_hud_tex_lut(x + 16, y, (*cameraLUT)[GLYPH_CAM_MARIO_HEAD]);
|
|
break;
|
|
case CAM_STATUS_LAKITU:
|
|
render_hud_tex_lut(x + 16, y, (*cameraLUT)[GLYPH_CAM_LAKITU_HEAD]);
|
|
break;
|
|
case CAM_STATUS_FIXED:
|
|
render_hud_tex_lut(x + 16, y, (*cameraLUT)[GLYPH_CAM_FIXED]);
|
|
break;
|
|
}
|
|
|
|
switch (sCameraHUD.status & CAM_STATUS_C_MODE_GROUP) {
|
|
case CAM_STATUS_C_DOWN:
|
|
render_hud_small_tex_lut(x + 4, y + 16, (*cameraLUT)[GLYPH_CAM_ARROW_DOWN]);
|
|
break;
|
|
case CAM_STATUS_C_UP:
|
|
render_hud_small_tex_lut(x + 4, y - 8, (*cameraLUT)[GLYPH_CAM_ARROW_UP]);
|
|
break;
|
|
}
|
|
|
|
gSPDisplayList(gDisplayListHead++, dl_hud_img_end);
|
|
}
|
|
|
|
/**
|
|
* Render HUD strings using hudDisplayFlags with it's render functions,
|
|
* excluding the cannon reticle which detects a camera preset for it.
|
|
*/
|
|
void render_hud(void) {
|
|
s16 hudDisplayFlags = gHudDisplay.flags;
|
|
|
|
if (hudDisplayFlags == HUD_DISPLAY_NONE) {
|
|
sPowerMeterHUD.animation = POWER_METER_HIDDEN;
|
|
sPowerMeterStoredHealth = 8;
|
|
sPowerMeterVisibleTimer = 0;
|
|
#ifdef BREATH_METER
|
|
sBreathMeterHUD.animation = BREATH_METER_HIDDEN;
|
|
sBreathMeterStoredValue = 8;
|
|
sBreathMeterVisibleTimer = 0;
|
|
#endif
|
|
} else {
|
|
#ifdef VERSION_EU
|
|
// basically create_dl_ortho_matrix but guOrtho screen width is different
|
|
Mtx *mtx = alloc_display_list(sizeof(*mtx));
|
|
|
|
if (mtx == NULL) {
|
|
return;
|
|
}
|
|
|
|
create_dl_identity_matrix();
|
|
guOrtho(mtx, -16.0f, SCREEN_WIDTH + 16, 0, SCREEN_HEIGHT, -10.0f, 10.0f, 1.0f);
|
|
gSPPerspNormalize(gDisplayListHead++, 0xFFFF);
|
|
gSPMatrix(gDisplayListHead++, VIRTUAL_TO_PHYSICAL(mtx),
|
|
G_MTX_PROJECTION | G_MTX_MUL | G_MTX_NOPUSH);
|
|
#else
|
|
create_dl_ortho_matrix();
|
|
#endif
|
|
|
|
if (gCurrentArea != NULL && gCurrentArea->camera->mode == CAMERA_MODE_INSIDE_CANNON) {
|
|
render_hud_cannon_reticle();
|
|
}
|
|
|
|
#ifndef DISABLE_LIVES
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_LIVES) {
|
|
render_hud_mario_lives();
|
|
}
|
|
#endif
|
|
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_COIN_COUNT) {
|
|
render_hud_coins();
|
|
}
|
|
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_STAR_COUNT) {
|
|
render_hud_stars();
|
|
}
|
|
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_KEYS) {
|
|
render_hud_keys();
|
|
}
|
|
|
|
#ifdef BREATH_METER
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_BREATH_METER) render_hud_breath_meter();
|
|
#endif
|
|
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_CAMERA_AND_POWER) {
|
|
render_hud_power_meter();
|
|
#ifdef PUPPYCAM
|
|
if (!gPuppyCam.enabled) {
|
|
#endif
|
|
render_hud_camera_status();
|
|
#ifdef PUPPYCAM
|
|
}
|
|
#endif
|
|
}
|
|
|
|
if (hudDisplayFlags & HUD_DISPLAY_FLAG_TIMER) {
|
|
render_hud_timer();
|
|
}
|
|
|
|
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_SURFACES) print_text(10, 40, "SURFACE POOL FULL");
|
|
if (gSurfacePoolError & NOT_ENOUGH_ROOM_FOR_NODES) print_text(10, 60, "SURFACE NODE POOL FULL");
|
|
|
|
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
|
|
if (gCustomDebugMode) {
|
|
render_debug_mode();
|
|
}
|
|
#endif
|
|
#ifdef PUPPYPRINT
|
|
print_set_envcolour(255, 255, 255, 255);
|
|
#endif
|
|
}
|
|
}
|