| 1 | /* |
| 2 | * OpenTyrian: A modern cross-platform port of Tyrian |
| 3 | * Copyright (C) 2007-2009 The OpenTyrian Development Team |
| 4 | * |
| 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. |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 18 | */ |
| 19 | #include "fonthand.h"cxx . . $ `<file>/src/fonthand.h`/ |
| 20 | |
| 21 | #include "network.h"cxx . . $ `<file>/src/network.h`/ |
| 22 | #include "nortsong.h"cxx . . $ `<file>/src/nortsong.h`/ |
| 23 | #include "nortvars.h"cxx . . $ `<file>/src/nortvars.h`/ |
| 24 | #include "opentyr.h"cxx . . $ `<file>/src/opentyr.h`/ |
| 25 | #include "params.h"cxx . . $ `<file>/src/params.h`/ |
| 26 | #include "sprite.h"cxx . . $ `<file>/src/sprite.h`/ |
| 27 | #include "vga256d.h"cxx . . $ `<file>/src/vga256d.h`/ |
| 28 | #include "video.h"cxx . . $ `<file>/src/video.h`/ |
| 29 | |
| 30 | const int font_asciicxx . . $ font_ascii.[256] = |
| 31 | { |
| 32 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 33 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 34 | -1, 26, 33, 60, 61, 62, -1, 32, 64, 65, 63, 84, 29, 83, 28, 80, // !"#$%&'()*+,-./ |
| 35 | 79, 70, 71, 72, 73, 74, 75, 76, 77, 78, 31, 30, -1, 85, -1, 27, // 0123456789:;<=>? |
| 36 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // @ABCDEFGHIJKLMNO |
| 37 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 68, 82, 69, -1, -1, // PQRSTUVWXYZ[\]^_ |
| 38 | -1, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // `abcdefghijklmno |
| 39 | 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 66, 81, 67, -1, -1, // pqrstuvwxyz{|}~⌂ |
| 40 | |
| 41 | 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, // ÇüéâäàåçêëèïîìÄÅ |
| 42 | 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, // ÉæÆôöòûùÿÖÜ¢£¥₧ƒ |
| 43 | 118, 119, 120, 121, 122, 123, 124, 125, 126, -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, |
| 48 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
| 49 | }; |
| 50 | |
| 51 | /* shape constants included in newshape.h */ |
| 52 | |
| 53 | JE_bytecxx . . $ JE_byte# textGlowFontcxx . . $ textGlowFont., textGlowBrightnesscxx . . $ textGlowBrightness. = 6; |
| 54 | |
| 55 | JE_booleancxx . . $ JE_boolean# levelWarningDisplaycxx . . $ levelWarningDisplay.; |
| 56 | JE_bytecxx . . $ JE_byte# levelWarningLinescxx . . $ levelWarningLines.; |
| 57 | char levelWarningTextcxx . . $ levelWarningText.[10][61]; /* [1..10] of string [60] */ |
| 58 | JE_booleancxx . . $ JE_boolean# warningRedcxx . . $ warningRed.; |
| 59 | |
| 60 | JE_bytecxx . . $ JE_byte# warningSoundDelaycxx . . $ warningSoundDelay.; |
| 61 | JE_wordcxx . . $ JE_word# armorShipDelaycxx . . $ armorShipDelay.; |
| 62 | JE_bytecxx . . $ JE_byte# warningColcxx . . $ warningCol.; |
| 63 | JE_shortintcxx . . $ JE_shortint# warningColChangecxx . . $ warningColChange.; |
| 64 | |
| 65 | void JE_dStringcxx . . $ JE_dString(19e4cd32eb7ad4fc).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int font) |
| 66 | { |
| 67 | const int defaultBrightness = -3; |
| 68 | |
| 69 | int bright = 0; |
| 70 | |
| 71 | for (int i = 0; s[i] != '\0'; ++i) |
| 72 | { |
| 73 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 74 | |
| 75 | switch (s[i]) |
| 76 | { |
| 77 | case ' ': |
| 78 | x += 6; |
| 79 | break; |
| 80 | |
| 81 | case '~': |
| 82 | bright = (bright == 0) ? 2 : 0; |
| 83 | break; |
| 84 | |
| 85 | default: |
| 86 | if (sprite_id != -1) |
| 87 | { |
| 88 | blit_sprite_darkcxx . . $ blit_sprite_dark(34bc9a7b28a4eeec).(screen, x + 2, y + 2, font, sprite_id, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 89 | blit_sprite_hv_unsafecxx . . $ blit_sprite_hv_unsafe(62f96868ab2f1929).(screen, x, y, font, sprite_id, 0xf, defaultBrightness + bright); |
| 90 | |
| 91 | x += spritecxx . . $ sprite(d067a90ab23634af).(font, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 92 | } |
| 93 | break; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | int JE_fontCentercxx . . $ JE_fontCenter(1df18506ef0a631b).(const char *s, unsigned int font) |
| 99 | { |
| 100 | return 160 - (JE_textWidthcxx . . $ JE_textWidth(1df18506ef0a631b).(s, font) / 2); |
| 101 | } |
| 102 | |
| 103 | int JE_textWidthcxx . . $ JE_textWidth(1df18506ef0a631b).(const char *s, unsigned int font) |
| 104 | { |
| 105 | int x = 0; |
| 106 | |
| 107 | for (int i = 0; s[i] != '\0'; ++i) |
| 108 | { |
| 109 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 110 | |
| 111 | if (s[i] == ' ') |
| 112 | x += 6; |
| 113 | else if (sprite_id != -1) |
| 114 | x += spritecxx . . $ sprite(d067a90ab23634af).(font, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 115 | } |
| 116 | |
| 117 | return x; |
| 118 | } |
| 119 | |
| 120 | void JE_textShadecxx . . $ JE_textShade(bb6cf87f29d3df77).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int colorbank, int brightness, unsigned int shadetype) |
| 121 | { |
| 122 | switch (shadetype) |
| 123 | { |
| 124 | case PART_SHADEcxx . . $ `src/fonthand.h:26:9`!: |
| 125 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x+1, y+1, s, 0, -1); |
| 126 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x, y, s, colorbank, brightness); |
| 127 | break; |
| 128 | case FULL_SHADEcxx . . $ `src/fonthand.h:27:9`!: |
| 129 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x-1, y, s, 0, -1); |
| 130 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x+1, y, s, 0, -1); |
| 131 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x, y-1, s, 0, -1); |
| 132 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x, y+1, s, 0, -1); |
| 133 | JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(screen, x, y, s, colorbank, brightness); |
| 134 | break; |
| 135 | case DARKENcxx . . $ `src/fonthand.h:28:9`!: |
| 136 | JE_outTextAndDarkencxx . . $ JE_outTextAndDarken(6303b30c6464185e).(screen, x+1, y+1, s, colorbank, brightness, TINY_FONTcxx . . $ `src/sprite.h:31:9`!); |
| 137 | break; |
| 138 | case TRICKcxx . . $ `src/fonthand.h:29:9`!: |
| 139 | JE_outTextModifycxx . . $ JE_outTextModify(6303b30c6464185e).(screen, x, y, s, colorbank, brightness, TINY_FONTcxx . . $ `src/sprite.h:31:9`!); |
| 140 | break; |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | void JE_outTextcxx . . $ JE_outText(894c69c4be246b6e).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int colorbank, int brightness) |
| 145 | { |
| 146 | int bright = 0; |
| 147 | |
| 148 | for (int i = 0; s[i] != '\0'; ++i) |
| 149 | { |
| 150 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 151 | |
| 152 | switch (s[i]) |
| 153 | { |
| 154 | case ' ': |
| 155 | x += 6; |
| 156 | break; |
| 157 | |
| 158 | case '~': |
| 159 | bright = (bright == 0) ? 4 : 0; |
| 160 | break; |
| 161 | |
| 162 | default: |
| 163 | if (sprite_id != -1 && sprite_existscxx . . $ sprite_exists(8e1b545ea3aecce3).(TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id)) |
| 164 | { |
| 165 | if (brightness >= 0) |
| 166 | blit_sprite_hv_unsafecxx . . $ blit_sprite_hv_unsafe(62f96868ab2f1929).(screen, x, y, TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id, colorbank, brightness + bright); |
| 167 | else |
| 168 | blit_sprite_darkcxx . . $ blit_sprite_dark(34bc9a7b28a4eeec).(screen, x, y, TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id, truecxx . . $ `<external>/14268322491693841775/stdbool.h:37:9`!); |
| 169 | |
| 170 | x += spritecxx . . $ sprite(d067a90ab23634af).(TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 171 | } |
| 172 | break; |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | void JE_outTextModifycxx . . $ JE_outTextModify(6303b30c6464185e).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int filter, unsigned int brightness, unsigned int font) |
| 178 | { |
| 179 | for (int i = 0; s[i] != '\0'; ++i) |
| 180 | { |
| 181 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 182 | |
| 183 | if (s[i] == ' ') |
| 184 | { |
| 185 | x += 6; |
| 186 | } |
| 187 | else if (sprite_id != -1) |
| 188 | { |
| 189 | blit_sprite_hv_blendcxx . . $ blit_sprite_hv_blend(62f96868ab2f1929).(screen, x, y, font, sprite_id, filter, brightness); |
| 190 | |
| 191 | x += spritecxx . . $ sprite(d067a90ab23634af).(font, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | void JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int filter, int brightness, unsigned int font, JE_booleancxx . . $ JE_boolean# shadow) |
| 197 | { |
| 198 | int bright = 0; |
| 199 | |
| 200 | for (int i = 0; s[i] != '\0'; ++i) |
| 201 | { |
| 202 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 203 | |
| 204 | switch (s[i]) |
| 205 | { |
| 206 | case ' ': |
| 207 | x += 6; |
| 208 | break; |
| 209 | |
| 210 | case '~': |
| 211 | bright = (bright == 0) ? 4 : 0; |
| 212 | break; |
| 213 | |
| 214 | default: |
| 215 | if (sprite_id != -1 && sprite_existscxx . . $ sprite_exists(8e1b545ea3aecce3).(TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id)) |
| 216 | { |
| 217 | if (shadow) |
| 218 | blit_sprite_darkcxx . . $ blit_sprite_dark(34bc9a7b28a4eeec).(screen, x + 2, y + 2, font, sprite_id, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 219 | blit_sprite_hvcxx . . $ blit_sprite_hv(62f96868ab2f1929).(screen, x, y, font, sprite_id, filter, brightness + bright); |
| 220 | |
| 221 | x += spritecxx . . $ sprite(d067a90ab23634af).(font, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 222 | } |
| 223 | break; |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void JE_outTextAndDarkencxx . . $ JE_outTextAndDarken(6303b30c6464185e).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s, unsigned int colorbank, unsigned int brightness, unsigned int font) |
| 229 | { |
| 230 | int bright = 0; |
| 231 | |
| 232 | for (int i = 0; s[i] != '\0'; ++i) |
| 233 | { |
| 234 | int sprite_id = font_asciicxx . . $ font_ascii.[(unsigned char)s[i]]; |
| 235 | |
| 236 | switch (s[i]) |
| 237 | { |
| 238 | case ' ': |
| 239 | x += 6; |
| 240 | break; |
| 241 | |
| 242 | case '~': |
| 243 | bright = (bright == 0) ? 4 : 0; |
| 244 | break; |
| 245 | |
| 246 | default: |
| 247 | if (sprite_id != -1 && sprite_existscxx . . $ sprite_exists(8e1b545ea3aecce3).(TINY_FONTcxx . . $ `src/sprite.h:31:9`!, sprite_id)) |
| 248 | { |
| 249 | blit_sprite_darkcxx . . $ blit_sprite_dark(34bc9a7b28a4eeec).(screen, x + 1, y + 1, font, sprite_id, falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 250 | blit_sprite_hv_unsafecxx . . $ blit_sprite_hv_unsafe(62f96868ab2f1929).(screen, x, y, font, sprite_id, colorbank, brightness + bright); |
| 251 | |
| 252 | x += spritecxx . . $ sprite(d067a90ab23634af).(font, sprite_id)->widthcxx . . $ $anonymous_type_297934740aeafb7d_0#width. + 1; |
| 253 | } |
| 254 | break; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | void JE_updateWarningcxx . . $ JE_updateWarning(60a0b30a00b4fc6d).(SDL_Surfacecxx . . $ SDL_Surface# * screen) |
| 260 | { |
| 261 | if (getDelayTicks2cxx . . $ getDelayTicks2(db52760e79bf9054).() == 0) |
| 262 | { /*Update Color Bars*/ |
| 263 | |
| 264 | warningColcxx . . $ warningCol. += warningColChangecxx . . $ warningColChange.; |
| 265 | if (warningColcxx . . $ warningCol. > 14 * 16 + 10 || warningColcxx . . $ warningCol. < 14 * 16 + 4) |
| 266 | { |
| 267 | warningColChangecxx . . $ warningColChange. = -warningColChangecxx . . $ warningColChange.; |
| 268 | } |
| 269 | fill_rectangle_xycxx . . $ fill_rectangle_xy(da1d960d0d6e485d).(screen, 0, 0, 319, 5, warningColcxx . . $ warningCol.); |
| 270 | fill_rectangle_xycxx . . $ fill_rectangle_xy(da1d960d0d6e485d).(screen, 0, 194, 319, 199, warningColcxx . . $ warningCol.); |
| 271 | JE_showVGAcxx . . $ JE_showVGA(49f6e7a06ebc5aa8).(); |
| 272 | |
| 273 | setDelay2cxx . . $ setDelay2(d4f767463ce0a6b3).(6); |
| 274 | |
| 275 | if (warningSoundDelaycxx . . $ warningSoundDelay. > 0) |
| 276 | { |
| 277 | warningSoundDelaycxx . . $ warningSoundDelay.--; |
| 278 | } |
| 279 | else |
| 280 | { |
| 281 | warningSoundDelaycxx . . $ warningSoundDelay. = 14; |
| 282 | JE_playSampleNumcxx . . $ JE_playSampleNum(ac50b47256ae7414).(S_WARNINGcxx . . $ S_WARNING.); |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | void JE_outTextGlowcxx . . $ JE_outTextGlow(472f2eee5aa9d4c0).(SDL_Surfacecxx . . $ SDL_Surface# * screen, int x, int y, const char *s) |
| 288 | { |
| 289 | JE_integercxx . . $ JE_integer# z; |
| 290 | JE_bytecxx . . $ JE_byte# c = 15; |
| 291 | |
| 292 | if (warningRedcxx . . $ warningRed.) |
| 293 | { |
| 294 | c = 7; |
| 295 | } |
| 296 | |
| 297 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x - 1, y, s, 0, -12, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 298 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x, y - 1, s, 0, -12, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 299 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x + 1, y, s, 0, -12, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 300 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x, y + 1, s, 0, -12, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 301 | if (frameCountMaxcxx . . $ frameCountMax. > 0) |
| 302 | for (z = 1; z <= 12; z++) |
| 303 | { |
| 304 | setDelaycxx . . $ setDelay(d4f767463ce0a6b3).(frameCountMaxcxx . . $ frameCountMax.); |
| 305 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x, y, s, c, z - 10, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 306 | if (JE_anyButtoncxx . . $ JE_anyButton(c9857a73d68e59ba).()) |
| 307 | { |
| 308 | frameCountMaxcxx . . $ frameCountMax. = 0; |
| 309 | } |
| 310 | |
| 311 | NETWORK_KEEP_ALIVEcxx . . $ `src/network.h:88:9`!(); |
| 312 | |
| 313 | JE_showVGAcxx . . $ JE_showVGA(49f6e7a06ebc5aa8).(); |
| 314 | |
| 315 | wait_delaycxx . . $ wait_delay(49f6e7a06ebc5aa8).(); |
| 316 | } |
| 317 | for (z = (frameCountMaxcxx . . $ frameCountMax. == 0) ? 6 : 12; z >= textGlowBrightnesscxx . . $ textGlowBrightness.; z--) |
| 318 | { |
| 319 | setDelaycxx . . $ setDelay(d4f767463ce0a6b3).(frameCountMaxcxx . . $ frameCountMax.); |
| 320 | JE_outTextAdjustcxx . . $ JE_outTextAdjust(f31fd28f47a6d6f4).(screen, x, y, s, c, z - 10, textGlowFontcxx . . $ textGlowFont., falsecxx . . $ `<external>/14268322491693841775/stdbool.h:38:9`!); |
| 321 | if (JE_anyButtoncxx . . $ JE_anyButton(c9857a73d68e59ba).()) |
| 322 | { |
| 323 | frameCountMaxcxx . . $ frameCountMax. = 0; |
| 324 | } |
| 325 | |
| 326 | NETWORK_KEEP_ALIVEcxx . . $ `src/network.h:88:9`!(); |
| 327 | |
| 328 | JE_showVGAcxx . . $ JE_showVGA(49f6e7a06ebc5aa8).(); |
| 329 | |
| 330 | wait_delaycxx . . $ wait_delay(49f6e7a06ebc5aa8).(); |
| 331 | } |
| 332 | textGlowBrightnesscxx . . $ textGlowBrightness. = 6; |
| 333 | } |