|
coastline 0.0.4
|
The drawing of text with the game's two bitmap fonts. More...
#include "common/types.h"
Go to the source code of this file.
Macros | |
| #define | FIRST_WEATHER_GLYPH 0x29 |
| The glyph of the first weather, the sun. | |
| #define | GLYPH_CACHE_CHARACTERS 256 |
| The characters the glyph cache maps, one for each byte value. | |
| #define | GLYPH_CACHE_SLOT_SIZE 0x5A0 |
| The bytes of the texture of a cached glyph. | |
| #define | GLYPH_ROM_OFFSETS 209 |
| The entries of the table of glyph offsets, one more than the glyphs it covers. | |
Enumerations | |
| enum | TextAlignment { TEXT_ALIGN_LEFT = 0 , TEXT_ALIGN_RIGHT = 1 , TEXT_ALIGN_CENTER = 2 } |
| Where DrawText() places text against its position. More... | |
Functions | |
| void | ResetGlyphCache (void) |
| Forget the glyph of every character and size the glyph cache to the memory after the BSS. | |
| u8 * | GetCachedGlyphTexture (s32 character) |
| Give a character a slot of the glyph cache if it has none. | |
| void | LoadCachedGlyphTextures (void) |
| Read the glyph of each character given a slot into the slot, unless the glyph is already there, and forget the characters of the slots not given out. | |
| void | RenderTextToDisplayList (const char *text) |
| Draw text at g_nTextDrawX and g_nTextDrawY. | |
| void | SetTextStyleBold (void) |
| Draw text in the bold colors. | |
| void | EnableTextShadow (void) |
| Draw glyphs with the shadow gradient. | |
| void | DisableTextShadow (void) |
| Draw glyphs with the plain gradient. | |
| void | SetTextStyleNormal (void) |
| Draw text in the normal style. | |
| void | SetTextAlignCenter (void) |
| Center text on its position. | |
| void | SetTextAlignLeft (void) |
| Start text at its position. | |
| void | SetTextAlignRight (void) |
| End text at its position. | |
| void | SetTextCustomColors (s32 red, s32 green, s32 blue, s32 red2, s32 green2, s32 blue2) |
| Set the colors of the top and the bottom of text. | |
| void | SetTextGradientColorsFromBytes (const u8 *color, const u8 *color2) |
| Set the colors of the top and the bottom of text from two red, green and blue triplets. | |
| void | SetTextSize (s32 size) |
| Set the size of the font. | |
| void | DrawText (const char *text, s32 x, s32 y) |
| Draw text at a position, aligned as the last alignment set. | |
| void | DrawHudLabelAtFraction (const char *text, f32 x, f32 y, s32 unused) |
| Draw text at a position in fractions of the screen, measured from the bottom left. | |
| s32 | MeasureTextWidth (const char *text, s32 size) |
| The width in pixels of text drawn at a size. | |
Variables | |
| u8 | g_bTextStyleBold |
| Whether text draws in the bold colors. | |
| u8 | g_nTextAlignment |
| The alignment of DrawText(), one of the TextAlignment values. | |
| u8 | g_bTextShadowEnabled |
| Whether glyphs draw with the shadow gradient. | |
| s32 | g_bTextCustomColorsEnabled |
| Whether text draws in the colors of SetTextCustomColors() rather than the style. | |
| s32 | g_dwTextCustomColorR |
| The red of the top of custom text. | |
| s32 | g_dwTextCustomColorG |
| The green of the top of custom text. | |
| s32 | g_dwTextCustomColorB |
| The blue of the top of custom text. | |
| s32 | g_dwTextCustomColor2R |
| The red of the bottom of custom text. | |
| s32 | g_dwTextCustomColor2G |
| The green of the bottom of custom text. | |
| s32 | g_dwTextCustomColor2B |
| The blue of the bottom of custom text. | |
| u8 | g_abLargeFontGradient [] |
| The gradient of large glyphs. | |
| u8 | g_abLargeFontShadowGradient [] |
| The gradient of large glyphs with a shadow. | |
| u8 | g_abSmallFontGradient [] |
| The gradient of small glyphs. | |
| u8 | g_abSmallFontShadowGradient [] |
| The gradient of small glyphs with a shadow. | |
| u8 | g_aLargeFontTexture [] |
| The large font, two rows of glyphs in 8-bit intensity and alpha. | |
| u8 | g_aSmallFontTexture [] |
| The small font, two rows of glyphs in 8-bit intensity and alpha. | |
| u8 | g_abHudFontCharToGlyph [] |
| The glyph of each character from ! on. | |
| s32 | g_adwLargeFontGlyphOffsets [] |
| The first column of each glyph of the large font, and one past the last glyph. | |
| s32 | g_adwSmallFontGlyphOffsets [] |
| The first column of each glyph of the small font, and one past the last glyph. | |
| s32 | g_nTextDrawX |
| The left of the next text RenderTextToDisplayList() draws. | |
| s32 | g_nTextDrawY |
| The baseline of the next text RenderTextToDisplayList() draws. | |
| s32 | g_nFontSize |
| The height of text in pixels of the low-resolution screen. | |
| s32 | g_aGlyphRomOffsets [GLYPH_ROM_OFFSETS] |
| The offset of each glyph from the start of the glyphs on the cartridge, from the character 0x20, then one past the last. | |
| s32 | g_bGlyphOffsetTableLoaded |
| Whether g_aGlyphRomOffsets has been read from the cartridge. | |
| u8 | g_abGlyphCharToSlot [GLYPH_CACHE_CHARACTERS] |
| The slot of the glyph cache of each character used since ResetGlyphCache(), or 0 for none. | |
| u8 | g_abGlyphSlotChar [] |
| The character whose glyph is in each slot of the glyph cache, or 0 for none. | |
| u8 | g_abGlyphRleBuffer [GLYPH_CACHE_SLOT_SIZE] |
| The compressed glyph LoadCachedGlyphTextures() reads before it expands the glyph into its slot. | |
| s32 | g_nGlyphCacheNextSlot |
| The next free slot of the glyph cache, from 1. | |
| u8 * | g_pGlyphCacheBuffer |
| The texture of slot 0 of the glyph cache, a slot before its memory. | |
| u8 * | g_pGlyphCacheBufferEnd |
| The end of the slots of the glyph cache. | |
| s32 | g_nGlyphCacheSlotLimit |
| The number of slots that fit in the memory of the glyph cache. | |
| u8 | g_abGlyphCacheMemory [] |
| The memory after the BSS where the glyph cache starts, once aligned to 8 bytes. | |
| void(* | g_pfnTextSink )(const char *text, s32 x, s32 y) |
| The routine DrawText() hands its text to in place of the display list while it is set, with the size, the alignment, and the colours of the text in the globals of the text. | |
The drawing of text with the game's two bitmap fonts.
A glyph is an intensity and alpha cutout of a font texture. The second texture of the combiner is a vertical gradient that blends the environment color at the top of a glyph into the primitive color at its bottom. A string may change both colors with a % code of two letters.
| #define FIRST_WEATHER_GLYPH 0x29 |
The glyph of the first weather, the sun.
The others follow it in the order of the weathers.
| #define GLYPH_CACHE_CHARACTERS 256 |
The characters the glyph cache maps, one for each byte value.
| #define GLYPH_CACHE_SLOT_SIZE 0x5A0 |
The bytes of the texture of a cached glyph.
| #define GLYPH_ROM_OFFSETS 209 |
The entries of the table of glyph offsets, one more than the glyphs it covers.
| enum TextAlignment |
Where DrawText() places text against its position.
| Enumerator | |
|---|---|
| TEXT_ALIGN_LEFT | The text starts at its position. |
| TEXT_ALIGN_RIGHT | The text ends at its position. |
| TEXT_ALIGN_CENTER | The text is centred on its position. |
| void ResetGlyphCache | ( | void | ) |
Forget the glyph of every character and size the glyph cache to the memory after the BSS.
The start of each display list calls it.
Give a character a slot of the glyph cache if it has none.
| character | The character. |
| void LoadCachedGlyphTextures | ( | void | ) |
Read the glyph of each character given a slot into the slot, unless the glyph is already there, and forget the characters of the slots not given out.
The table of offsets is read the first time.
| void RenderTextToDisplayList | ( | const char * | text | ) |
Draw text at g_nTextDrawX and g_nTextDrawY.
| text | The text to draw. |
| void SetTextStyleBold | ( | void | ) |
Draw text in the bold colors.
| void EnableTextShadow | ( | void | ) |
Draw glyphs with the shadow gradient.
| void DisableTextShadow | ( | void | ) |
Draw glyphs with the plain gradient.
| void SetTextStyleNormal | ( | void | ) |
Draw text in the normal style.
| void SetTextAlignCenter | ( | void | ) |
Center text on its position.
| void SetTextAlignLeft | ( | void | ) |
Start text at its position.
| void SetTextAlignRight | ( | void | ) |
End text at its position.
Set the colors of the top and the bottom of text.
| red | The red component of the top, from 0 to 255. |
| green | The green component of the top, from 0 to 255. |
| blue | The blue component of the top, from 0 to 255. |
| red2 | The red component of the bottom, from 0 to 255. |
| green2 | The green component of the bottom, from 0 to 255. |
| blue2 | The blue component of the bottom, from 0 to 255. |
Set the colors of the top and the bottom of text from two red, green and blue triplets.
| color | The red, green, and blue of the top. |
| color2 | The red, green, and blue of the bottom. |
| void SetTextSize | ( | s32 | size | ) |
Set the size of the font.
| size | The height of text in pixels of the low-resolution screen. |
Draw text at a position, aligned as the last alignment set.
| text | The text to draw. |
| x | The horizontal position the alignment applies to, in pixels. |
| y | The baseline, in pixels. |
Draw text at a position in fractions of the screen, measured from the bottom left.
A unit is a little under a thousandth of the screen.
| text | The text to draw. |
| x | The distance from the left edge, in units of the width. |
| y | The distance from the bottom edge, in units of the height. |
| unused | An argument that is not read. |
The width in pixels of text drawn at a size.
| text | The text to measure. |
| size | The height of text in pixels of the low-resolution screen. |
|
extern |
Whether text draws in the bold colors.
|
extern |
The alignment of DrawText(), one of the TextAlignment values.
|
extern |
Whether glyphs draw with the shadow gradient.
|
extern |
Whether text draws in the colors of SetTextCustomColors() rather than the style.
|
extern |
The red of the top of custom text.
|
extern |
The green of the top of custom text.
|
extern |
The blue of the top of custom text.
|
extern |
The red of the bottom of custom text.
|
extern |
The green of the bottom of custom text.
|
extern |
The blue of the bottom of custom text.
|
extern |
The gradient of large glyphs.
|
extern |
The gradient of large glyphs with a shadow.
|
extern |
The gradient of small glyphs.
|
extern |
The gradient of small glyphs with a shadow.
|
extern |
The large font, two rows of glyphs in 8-bit intensity and alpha.
|
extern |
The small font, two rows of glyphs in 8-bit intensity and alpha.
|
extern |
The glyph of each character from ! on.
|
extern |
The first column of each glyph of the large font, and one past the last glyph.
|
extern |
The first column of each glyph of the small font, and one past the last glyph.
|
extern |
The left of the next text RenderTextToDisplayList() draws.
|
extern |
The baseline of the next text RenderTextToDisplayList() draws.
|
extern |
The height of text in pixels of the low-resolution screen.
|
extern |
The offset of each glyph from the start of the glyphs on the cartridge, from the character 0x20, then one past the last.
A negative offset marks a glyph stored without compression, and the size of a glyph is the distance to the absolute offset of the next.
|
extern |
Whether g_aGlyphRomOffsets has been read from the cartridge.
|
extern |
The slot of the glyph cache of each character used since ResetGlyphCache(), or 0 for none.
|
extern |
The character whose glyph is in each slot of the glyph cache, or 0 for none.
|
extern |
The compressed glyph LoadCachedGlyphTextures() reads before it expands the glyph into its slot.
|
extern |
The next free slot of the glyph cache, from 1.
|
extern |
The texture of slot 0 of the glyph cache, a slot before its memory.
|
extern |
The end of the slots of the glyph cache.
|
extern |
The number of slots that fit in the memory of the glyph cache.
|
extern |
The memory after the BSS where the glyph cache starts, once aligned to 8 bytes.
The link script places it.
The routine DrawText() hands its text to in place of the display list while it is set, with the size, the alignment, and the colours of the text in the globals of the text.
The SDL game draws the HUD of a race through it.