coastline 0.0.4
Loading...
Searching...
No Matches
text.h
Go to the documentation of this file.
1#ifndef COASTLINE_TEXT_H
2#define COASTLINE_TEXT_H
3
12
13#include "common/types.h"
14
15#if TGR_BOSS_RALLY && defined(DrawText)
16#undef DrawText
17#endif
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
29
40extern u8 g_bTextStyleBold;
41
52extern u8 g_nTextAlignment;
53
65
77
89
101
113
125
137
149
161
173
185
197
206extern u8 g_aLargeFontTexture[];
207
216extern u8 g_aSmallFontTexture[];
217
229
239
249
260extern s32 g_nTextDrawX;
261
272extern s32 g_nTextDrawY;
273
284extern s32 g_nFontSize;
285
286#if TGR_REGION == TGR_REGION_JP
288#define FIRST_WEATHER_GLYPH 0x29
289
291#define GLYPH_CACHE_CHARACTERS 256
292
294#define GLYPH_CACHE_SLOT_SIZE 0x5A0
295
297#define GLYPH_ROM_OFFSETS 209
298
307
314
321
327extern u8 g_abGlyphSlotChar[];
328
335
342
348extern u8 *g_pGlyphCacheBuffer;
349
356
363
370extern u8 g_abGlyphCacheMemory[];
371
373extern u8 _cachedGlyphsSegmentRomStart[];
374
382
391
400#endif /* TGR_REGION == TGR_REGION_JP */
401
413void RenderTextToDisplayList(const char *text);
414
424
436
448
460
472
484
496
513void SetTextCustomColors(s32 red, s32 green, s32 blue, s32 red2, s32 green2, s32 blue2);
514
525void SetTextGradientColorsFromBytes(const u8 *color, const u8 *color2);
526
538void SetTextSize(s32 size);
539
553void DrawText(const char *text, s32 x, s32 y);
554
555#if TGR_PLATFORM == TGR_PLATFORM_SDL
561extern void (*g_pfnTextSink)(const char *text, s32 x, s32 y);
562#endif
563
577void DrawHudLabelAtFraction(const char *text, f32 x, f32 y, s32 unused);
578
592s32 MeasureTextWidth(const char *text, s32 size);
593
594#ifdef __cplusplus
595}
596#endif
597
598#endif /* COASTLINE_TEXT_H */
u8 * GetCachedGlyphTexture(s32 character)
Give a character a slot of the glyph cache if it has none.
void DrawText(const char *text, s32 x, s32 y)
Draw text at a position, aligned as the last alignment set.
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.
u8 g_abHudFontCharToGlyph[]
The glyph of each character from ! on.
u8 g_abGlyphRleBuffer[GLYPH_CACHE_SLOT_SIZE]
The compressed glyph LoadCachedGlyphTextures() reads before it expands the glyph into its slot.
s32 g_bGlyphOffsetTableLoaded
Whether g_aGlyphRomOffsets has been read from the cartridge.
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.
void SetTextSize(s32 size)
Set the size of the font.
void LoadCachedGlyphTextures(void)
Read the glyph of each character given a slot into the slot, unless the glyph is already there,...
#define GLYPH_CACHE_CHARACTERS
The characters the glyph cache maps, one for each byte value.
Definition text.h:291
s32 g_bTextCustomColorsEnabled
Whether text draws in the colors of SetTextCustomColors() rather than the style.
void DisableTextShadow(void)
Draw glyphs with the plain gradient.
s32 g_dwTextCustomColor2B
The blue of the bottom of custom text.
s32 g_nTextDrawY
The baseline of the next text RenderTextToDisplayList() draws.
u8 g_abSmallFontShadowGradient[]
The gradient of small glyphs with a shadow.
void ResetGlyphCache(void)
Forget the glyph of every character and size the glyph cache to the memory after the BSS.
s32 g_nFontSize
The height of text in pixels of the low-resolution screen.
#define GLYPH_ROM_OFFSETS
The entries of the table of glyph offsets, one more than the glyphs it covers.
Definition text.h:297
s32 g_nGlyphCacheSlotLimit
The number of slots that fit in the memory of the glyph cache.
void EnableTextShadow(void)
Draw glyphs with the shadow gradient.
void SetTextStyleNormal(void)
Draw text in the normal style.
u8 g_bTextShadowEnabled
Whether glyphs draw with the shadow gradient.
u8 g_bTextStyleBold
Whether text draws in the bold colors.
s32 g_dwTextCustomColor2R
The red of the bottom of custom 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.
u8 g_aLargeFontTexture[]
The large font, two rows of glyphs in 8-bit intensity and alpha.
s32 g_adwLargeFontGlyphOffsets[]
The first column of each glyph of the large font, and one past the last glyph.
#define GLYPH_CACHE_SLOT_SIZE
The bytes of the texture of a cached glyph.
Definition text.h:294
u8 g_abLargeFontGradient[]
The gradient of large glyphs.
s32 g_dwTextCustomColor2G
The green of the bottom of custom text.
u8 g_abGlyphCacheMemory[]
The memory after the BSS where the glyph cache starts, once aligned to 8 bytes.
void SetTextAlignLeft(void)
Start text at its position.
TextAlignment
Where DrawText() places text against its position.
Definition text.h:24
@ TEXT_ALIGN_LEFT
Definition text.h:25
@ TEXT_ALIGN_CENTER
Definition text.h:27
@ TEXT_ALIGN_RIGHT
Definition text.h:26
s32 g_dwTextCustomColorR
The red of the top of custom text.
u8 g_abGlyphCharToSlot[GLYPH_CACHE_CHARACTERS]
The slot of the glyph cache of each character used since ResetGlyphCache(), or 0 for none.
u8 g_nTextAlignment
The alignment of DrawText(), one of the TextAlignment values.
s32 g_dwTextCustomColorB
The blue of the top of custom text.
s32 g_nTextDrawX
The left of the next text RenderTextToDisplayList() draws.
void SetTextAlignCenter(void)
Center text on its position.
u8 g_abLargeFontShadowGradient[]
The gradient of large glyphs with a shadow.
void RenderTextToDisplayList(const char *text)
Draw text at g_nTextDrawX and g_nTextDrawY.
u8 * g_pGlyphCacheBufferEnd
The end of the slots of the glyph cache.
u8 g_aSmallFontTexture[]
The small font, two rows of glyphs in 8-bit intensity and alpha.
s32 MeasureTextWidth(const char *text, s32 size)
The width in pixels of text drawn at a size.
s32 g_aGlyphRomOffsets[GLYPH_ROM_OFFSETS]
The offset of each glyph from the start of the glyphs on the cartridge, from the character 0x20,...
s32 g_nGlyphCacheNextSlot
The next free slot of the glyph cache, from 1.
void SetTextStyleBold(void)
Draw text in the bold colors.
s32 g_adwSmallFontGlyphOffsets[]
The first column of each glyph of the small font, and one past the last glyph.
u8 g_abGlyphSlotChar[]
The character whose glyph is in each slot of the glyph cache, or 0 for none.
s32 g_dwTextCustomColorG
The green of the top of custom text.
u8 * g_pGlyphCacheBuffer
The texture of slot 0 of the glyph cache, a slot before its memory.
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,...
u8 g_abSmallFontGradient[]
The gradient of small glyphs.
The integer and floating-point types of the console, for headers shared with Windows.
float f32
Definition ultratypes.h:38
int s32
Definition ultratypes.h:25
unsigned char u8
Definition ultratypes.h:18