Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
text.c
Go to the documentation of this file.
1/*
2 * Cinematic sprite-font renderer.
3 *
4 * Retail object 0x433690-0x433ACF (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8/* Function start: 0x433690 */
9void DrawCinematicFontCharacter(char character)
10{
11 ShortRect bounds;
12 short frame;
13
14 if (IsCinematicFontCharacterPrintable((short)(signed char)character) == 0) {
17 return;
18 }
19 frame = (short)((signed char)character - 0x21);
20 GetShapeFrameBounds(&bounds.left, 0, 0,
27 bounds.right - bounds.left +
29}
30
31/* Function start: 0x43374E */
33{
34 if (character < 0x21)
35 return 0;
36 return 1;
37}
38
39/* Function start: 0x433777 */
41{
42 char *lineStart;
43 char *end;
44 short terminator;
45 short usedWidth;
46 short viewportWidth;
47 short advance;
48 short ch;
49
50 lineStart = text;
51 viewportWidth = (short)(
54 while (*lineStart != 0) {
55 usedWidth = 0;
56 end = lineStart;
57 while ((ch = (signed char)*end) != 0) {
58 if (ch == '\n')
59 break;
61 usedWidth = (short)(usedWidth + advance);
62 if (viewportWidth <= usedWidth) {
63 if (isalnum(ch) != 0) {
64 while (isalpha(ch) != 0) {
65 usedWidth = (short)(usedWidth - advance);
66 end--;
67 ch = (signed char)*end;
68 advance =
70 }
71 } else {
72 usedWidth = (short)(usedWidth - advance);
73 }
74 break;
75 }
76 end++;
77 }
78 terminator = ch;
79 *end = 0;
81 case 0:
84 break;
85 case 1:
88 usedWidth + 1);
89 break;
90 case 2:
93 (viewportWidth - usedWidth) / 2);
94 break;
95 }
96 while (*lineStart != 0)
97 DrawCinematicFontCharacter(*lineStart++);
98 *lineStart = (char)terminator;
99 if (terminator == '\n') {
103 lineStart++;
104 }
105 }
106}
107
108/* Function start: 0x433A14 */
110{
111 ShortRect bounds;
112
113 if (IsCinematicFontCharacterPrintable(character) == 0)
114 return 5;
115 GetShapeFrameBounds(&bounds.left, 0, 0,
117 (short)(character - 0x21));
118 return (short)(bounds.right - bounds.left + 2);
119}
120
121/* Function start: 0x433A75 */
123{
124 ShortRect bounds;
125
126 GetShapeFrameBounds(&bounds.left, 0, 0,
128 return (short)(bounds.bottom - bounds.top + 2);
129}
130
131/* Function start: 0x433AB0 */
short MeasureCinematicFontCharacterWidth(short character)
Definition text.c:109
void DrawWrappedCinematicText(char *text)
Definition text.c:40
void InitializeCinematicTextRenderer(void)
Definition text.c:132
void DrawSpriteDefault(Viewport *viewport, short x, short y, unsigned char *shape, short frame)
Definition gr.c:682
short GetShapeFrameBounds(short *bounds, short x, short y, unsigned char *shape, short frame)
Definition eventmgr.c:228
short IsCinematicFontCharacterPrintable(short character)
Definition text.c:32
void advance(short ship)
Definition fl.c:181
short MeasureCinematicFontLineHeight(void)
Definition text.c:122
void DrawCinematicFontCharacter(char character)
Definition text.c:9
Shared Win32 declarations, types and library interfaces.
TextContext * g_29_pCurrentTextContext
Definition eventmgr.c:2563
void(*) g_3_pfnRenderSceneTextStringHandler(char *text)
Definition eventmgr.c:2560
void(*) g_36_pfnRenderSceneFontCharacterHandler(char character)
Definition eventmgr.c:2567
short top
Definition game_data.h:480
short left
Definition game_data.h:479
short right
Definition game_data.h:481
short bottom
Definition game_data.h:482
short cursorY
Definition game.h:286
unsigned char * font
Definition game.h:287
signed char alignment
Definition game.h:292
short cursorX
Definition game.h:285
Viewport * viewport
Definition game.h:284
short right
Definition game.h:154
short left
Definition game.h:152