2
* OpenTyrian: A modern cross-platform port of Tyrian
3
* Copyright (C) 2007-2009 The OpenTyrian Development Team
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
const int font_ascii[256] =
31
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
32
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
33
-1, 26, 33, 60, 61, 62, -1, 32, 64, 65, 63, 84, 29, 83, 28, 80, // !"#$%&'()*+,-./
34
79, 70, 71, 72, 73, 74, 75, 76, 77, 78, 31, 30, -1, 85, -1, 27, // 0123456789:;<=>?
35
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // @ABCDEFGHIJKLMNO
36
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 68, 82, 69, -1, -1, // PQRSTUVWXYZ[\]^_
37
-1, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // `abcdefghijklmno
38
49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 66, 81, 67, -1, -1, // pqrstuvwxyz{|}~⌂
40
86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, // ÇüéâäàåçêëèïîìÄÅ
41
102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, // ÉæÆôöòûùÿÖÜ¢£¥₧ƒ
42
118, 119, 120, 121, 122, 123, 124, 125, 126, -1, -1, -1, -1, -1, -1, -1, // áíóúñѪº¿
43
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
44
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
45
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
46
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
47
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
50
/* shape constants included in newshape.h */
52
JE_integer defaultBrightness = -3;
53
JE_byte textGlowFont, textGlowBrightness = 6;
55
JE_boolean levelWarningDisplay;
56
JE_byte levelWarningLines;
57
char levelWarningText[10][61]; /* [1..10] of string [60] */
58
JE_boolean warningRed;
60
JE_byte warningSoundDelay;
61
JE_word armorShipDelay;
63
JE_shortint warningColChange;
65
void JE_dString( SDL_Surface * screen, int x, int y, const char *s, unsigned int font )
69
for (int i = 0; s[i] != '\0'; ++i)
71
int sprite_id = font_ascii[(unsigned char)s[i]];
80
bright = (bright == 0) ? 2 : 0;
86
blit_sprite_dark(screen, x + 2, y + 2, font, sprite_id, false);
87
blit_sprite_hv_unsafe(screen, x, y, font, sprite_id, 0xf, defaultBrightness + bright);
89
x += sprite(font, sprite_id)->width + 1;
96
int JE_fontCenter( const char *s, unsigned int font )
98
return 160 - (JE_textWidth(s, font) / 2);
101
int JE_textWidth( const char *s, unsigned int font )
105
for (int i = 0; s[i] != '\0'; ++i)
107
int sprite_id = font_ascii[(unsigned char)s[i]];
111
else if (sprite_id != -1)
112
x += sprite(font, sprite_id)->width + 1;
118
void JE_textShade( SDL_Surface * screen, int x, int y, const char *s, unsigned int colorbank, int brightness, unsigned int shadetype )
123
JE_outText(screen, x+1, y+1, s, 0, -1);
124
JE_outText(screen, x, y, s, colorbank, brightness);
127
JE_outText(screen, x-1, y, s, 0, -1);
128
JE_outText(screen, x+1, y, s, 0, -1);
129
JE_outText(screen, x, y-1, s, 0, -1);
130
JE_outText(screen, x, y+1, s, 0, -1);
131
JE_outText(screen, x, y, s, colorbank, brightness);
134
JE_outTextAndDarken(screen, x+1, y+1, s, colorbank, brightness, TINY_FONT);
137
JE_outTextModify(screen, x, y, s, colorbank, brightness, TINY_FONT);
142
void JE_outText( SDL_Surface * screen, int x, int y, const char *s, unsigned int colorbank, int brightness )
146
for (int i = 0; s[i] != '\0'; ++i)
148
int sprite_id = font_ascii[(unsigned char)s[i]];
157
bright = (bright == 0) ? 4 : 0;
161
if (sprite_id != -1 && sprite_exists(TINY_FONT, sprite_id))
164
blit_sprite_hv_unsafe(screen, x, y, TINY_FONT, sprite_id, colorbank, brightness + bright);
166
blit_sprite_dark(screen, x, y, TINY_FONT, sprite_id, true);
168
x += sprite(TINY_FONT, sprite_id)->width + 1;
175
void JE_outTextModify( SDL_Surface * screen, int x, int y, const char *s, unsigned int filter, unsigned int brightness, unsigned int font )
177
for (int i = 0; s[i] != '\0'; ++i)
179
int sprite_id = font_ascii[(unsigned char)s[i]];
185
else if (sprite_id != -1)
187
blit_sprite_hv_blend(screen, x, y, font, sprite_id, filter, brightness);
189
x += sprite(font, sprite_id)->width + 1;
194
void JE_outTextAdjust( SDL_Surface * screen, int x, int y, const char *s, unsigned int filter, int brightness, unsigned int font, JE_boolean shadow )
198
for (int i = 0; s[i] != '\0'; ++i)
200
int sprite_id = font_ascii[(unsigned char)s[i]];
209
bright = (bright == 0) ? 4 : 0;
213
if (sprite_id != -1 && sprite_exists(TINY_FONT, sprite_id))
216
blit_sprite_dark(screen, x + 2, y + 2, font, sprite_id, false);
217
blit_sprite_hv(screen, x, y, font, sprite_id, filter, brightness + bright);
219
x += sprite(font, sprite_id)->width + 1;
226
void JE_outTextAndDarken( SDL_Surface * screen, int x, int y, const char *s, unsigned int colorbank, unsigned int brightness, unsigned int font )
230
for (int i = 0; s[i] != '\0'; ++i)
232
int sprite_id = font_ascii[(unsigned char)s[i]];
241
bright = (bright == 0) ? 4 : 0;
245
if (sprite_id != -1 && sprite_exists(TINY_FONT, sprite_id))
247
blit_sprite_dark(screen, x + 1, y + 1, font, sprite_id, false);
248
blit_sprite_hv_unsafe(screen, x, y, font, sprite_id, colorbank, brightness + bright);
250
x += sprite(font, sprite_id)->width + 1;
257
void JE_updateWarning( SDL_Surface * screen )
259
if (delaycount2() == 0)
260
{ /*Update Color Bars*/
262
warningCol += warningColChange;
263
if (warningCol > 14 * 16 + 10 || warningCol < 14 * 16 + 4)
265
warningColChange = -warningColChange;
267
fill_rectangle_xy(screen, 0, 0, 319, 5, warningCol);
268
fill_rectangle_xy(screen, 0, 194, 319, 199, warningCol);
273
if (warningSoundDelay > 0)
279
warningSoundDelay = 14;
280
JE_playSampleNum(17);
285
void JE_outTextGlow( SDL_Surface * screen, int x, int y, const char *s )
295
JE_outTextAdjust(screen, x - 1, y, s, 0, -12, textGlowFont, false);
296
JE_outTextAdjust(screen, x, y - 1, s, 0, -12, textGlowFont, false);
297
JE_outTextAdjust(screen, x + 1, y, s, 0, -12, textGlowFont, false);
298
JE_outTextAdjust(screen, x, y + 1, s, 0, -12, textGlowFont, false);
299
if (frameCountMax > 0)
300
for (z = 1; z <= 12; z++)
302
setjasondelay(frameCountMax);
303
JE_outTextAdjust(screen, x, y, s, c, z - 10, textGlowFont, false);
309
NETWORK_KEEP_ALIVE();
315
for (z = (frameCountMax == 0) ? 6 : 12; z >= textGlowBrightness; z--)
317
setjasondelay(frameCountMax);
318
JE_outTextAdjust(screen, x, y, s, c, z - 10, textGlowFont, false);
324
NETWORK_KEEP_ALIVE();
330
textGlowBrightness = 6;