Super Mario 64 Source
A Super Mario 64 decompilation, brought to you by a bunch of clever folks.
Data Structures | Functions | Variables
print.c File Reference
#include <ultra64.h>
#include "sm64.h"
#include "game.h"
#include "mario.h"
#include "memory.h"
#include "save_file.h"
#include "main.h"
#include "engine/surface_collision.h"
#include "geo_misc.h"
#include "segment2.h"
#include "print.h"

Data Structures

struct  TextLabel
 This file handles printing and formatting the colorful text that appears when printing things such as "PRESS START". More...
 

Functions

s32 int_pow (s32 n, s32 exponent)
 Returns n to the exponent power, only for non-negative powers. More...
 
void format_integer (s32 n, s32 base, char *dest, s32 *totalLength, u8 width, s8 zeroPad)
 Formats an integer n for print by fitting it to width, prefixing with a negative, and converting the base. More...
 
void parse_width_field (const char *str, s32 *srcIndex, u8 *width, s8 *zeroPad)
 Determines the width of the number for printing, writing to 'width'. More...
 
void print_text_fmt_int (s32 x, s32 y, const char *str, s32 n)
 Takes a number, finds the intended base, formats the number, and prints it at the given X & Y coordinates. More...
 
void print_text (s32 x, s32 y, const char *str)
 Prints text in the colorful lettering at given X, Y coordinates. More...
 
void print_text_centered (s32 x, s32 y, const char *str)
 Prints text in the colorful lettering centered at given X, Y coordinates. More...
 
s8 char_to_glyph_index (char c)
 Converts a char into the proper colorful glyph for the char. More...
 
void add_glyph_texture (s8 glyphIndex)
 Adds an individual glyph to be rendered. More...
 
void clip_to_bounds (s32 *x, s32 *y)
 Clips textrect into the boundaries defined. More...
 
void render_textrect (s32 x, s32 y, s32 pos)
 Renders the glyph that's set at the given position. More...
 
void render_text_labels (void)
 Renders the text in sTextLabels on screen at the proper locations by iterating a for loop. More...
 

Variables

struct TextLabelsTextLabels [52]
 Stores the text to be rendered on screen and how they are to be rendered. More...
 
s16 sTextLabelsCount = 0
 

Function Documentation

◆ add_glyph_texture()

void add_glyph_texture ( s8  glyphIndex)

Adds an individual glyph to be rendered.

◆ char_to_glyph_index()

s8 char_to_glyph_index ( char  c)

Converts a char into the proper colorful glyph for the char.

◆ clip_to_bounds()

void clip_to_bounds ( s32 x,
s32 y 
)

Clips textrect into the boundaries defined.

◆ format_integer()

void format_integer ( s32  n,
s32  base,
char dest,
s32 totalLength,
u8  width,
s8  zeroPad 
)

Formats an integer n for print by fitting it to width, prefixing with a negative, and converting the base.

◆ int_pow()

s32 int_pow ( s32  n,
s32  exponent 
)

Returns n to the exponent power, only for non-negative powers.

◆ parse_width_field()

void parse_width_field ( const char str,
s32 srcIndex,
u8 width,
s8 zeroPad 
)

Determines the width of the number for printing, writing to 'width'.

Additionally, this determines if a number should be zero-padded, writing to 'zeroPad'.

◆ print_text()

void print_text ( s32  x,
s32  y,
const char str 
)

Prints text in the colorful lettering at given X, Y coordinates.

◆ print_text_centered()

void print_text_centered ( s32  x,
s32  y,
const char str 
)

Prints text in the colorful lettering centered at given X, Y coordinates.

◆ print_text_fmt_int()

void print_text_fmt_int ( s32  x,
s32  y,
const char str,
s32  n 
)

Takes a number, finds the intended base, formats the number, and prints it at the given X & Y coordinates.

Warning: this fails on too large numbers, because format_integer has bugs related to overflow. For romhacks, prefer sprintf + print_text.

◆ render_text_labels()

void render_text_labels ( void  )

Renders the text in sTextLabels on screen at the proper locations by iterating a for loop.

◆ render_textrect()

void render_textrect ( s32  x,
s32  y,
s32  pos 
)

Renders the glyph that's set at the given position.

Variable Documentation

◆ sTextLabels

struct TextLabel* sTextLabels[52]

Stores the text to be rendered on screen and how they are to be rendered.

◆ sTextLabelsCount

s16 sTextLabelsCount = 0