Debian Codegraph @

Descent3/TelComEffects.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (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, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/TelComEffects.cpp $
21 * $Revision: 33 $
22 * $Date: 5/13/99 3:42p $
23 * $Author: Ardussi $
24 *
25 * TelCom Effect class defines
26 *
27 * $Log: /DescentIII/Main/TelComEffects.cpp $
28 *
29 * 33 5/13/99 3:42p Ardussi
30 * changes for compiling on the Mac
31 *
32 * 32 4/14/99 3:57a Jeff
33 * fixed case mismatch in #includes
34 *
35 * 31 2/17/99 6:55p Jeff
36 * added jump button type. Added no early render flag for bitmaps. Fixed
37 * color bug for type text
38 *
39 * 30 2/16/99 11:54a Jeff
40 * fixed bug with 0 length strings
41 *
42 * 29 2/05/99 7:04p Jeff
43 * table file parsing macros put in
44 *
45 * 28 2/03/99 1:23p Jeff
46 * more updates to single player ship selection...all thats left is stats
47 *
48 * 27 2/03/99 12:14a Jeff
49 * updated single player ship selection to full functional...needs effects
50 * added in. Had to add flag to buttons for gain focus to register as a
51 * click
52 *
53 * 26 2/02/99 7:32p Jeff
54 * begining of single player ship selection
55 *
56 * 25 11/01/98 1:57a Jeff
57 * converted the vsprintf calls to use the Pvsprintf, which is a safe
58 * vsprintf, no buffer overflows allowed
59 *
60 * 24 10/12/98 11:39p Jeff
61 * finished up new focus system of telcom
62 *
63 * 23 10/12/98 8:32p Jeff
64 * changed the way focus is handled
65 *
66 * 22 10/08/98 4:23p Kevin
67 * Changed code to comply with memory library usage. Always use mem_malloc
68 * , mem_free and mem_strdup
69 *
70 * 21 9/17/98 2:29p Jeff
71 * added focus filenames to button effect
72 *
73 * 20 8/27/98 2:51p Jeff
74 * New TelCom finally checked in
75 *
76 * 19 8/19/98 1:38p Jeff
77 * removed update2dsound
78 *
79 * 18 6/15/98 4:00p Jason
80 * replaced monochromatic polymodel lighting with rgb lighting
81 *
82 * 17 5/19/98 3:40p Jeff
83 * poly models functional
84 *
85 * 16 5/15/98 5:16p Jeff
86 * use regular draw chunk bitmap
87 *
88 * 15 5/11/98 6:21p Jeff
89 * fixed setting glitch offsets
90 *
91 * 14 5/07/98 3:31p Jeff
92 * various optimizations, removed Copy and similar functions
93 *
94 * 13 5/05/98 6:50p Jeff
95 * Telcom doesn't use rend_DrawLFBitmap anymore...more speed!
96 *
97 * 12 5/04/98 6:22p Jeff
98 * fixed possible sound bugs
99 *
100 * 11 5/04/98 5:29p Jeff
101 * Added sounds to TelCom events
102 *
103 * 10 5/04/98 1:35p Jeff
104 * Changes made for mouse handling
105 *
106 * 9 5/04/98 11:01a Jeff
107 * added scroll parameter to text
108 *
109 * 8 5/03/98 7:57p Jeff
110 * Got scrolling textboxes working
111 *
112 * 7 5/01/98 2:17p Jeff
113 * Added sound effect support
114 *
115 * 6 4/30/98 7:18p Jeff
116 * fixed poly model rotation
117 *
118 * 5 4/29/98 4:36p Jeff
119 * fixed text going beyond bottom of text box
120 *
121 * 4 4/28/98 6:58p Jeff
122 * Added new poly model effect driver
123 *
124 * 3 4/26/98 7:20p Jeff
125 * Added the rest of the effect drivers except for scrolling text. Added
126 * invert bitmaps and stretch bitmaps
127 *
128 * 2 4/26/98 2:54a Jeff
129 * Initial Creation
130 *
131 * 1 4/25/98 4:23p Jeff
132 *
133 * $NoKeywords: $
134 */
135
136 #include <cstdarg>
137 #include <cstdio>
138
139 #include "TelComEffects.h"
140 #include "mem.h"
141 #include "vecmat.h"
142 #include <string.h>
143 #include "textaux.h"
144 #include "hlsoundlib.h"
145 #include "soundload.h"
146
147 tceffect TCEffects[MAX_TCEFFECTS];
148 int Screen_roots[MAX_TELCOM_SCREENS];
149 static bool Screen_has_effect_with_focus[MAX_TELCOM_SCREENS];
150
151 // Initializes the effects
152 void EfxInit(void) {
153 int i;
154
155 for (i = 0; i < MAX_TCEFFECTS; i++) {
156 tceffect *tce = &TCEffects[i];
157 tce->type = EFX_NONE;
158 tce->monitor = -1;
159 tce->screen = -1;
160 tce->id = INVALID_EFFECT_ID;
161 tce->prev = -1;
162 tce->next = -1;
163 tce->text_buffer = NULL;
164 tce->tab_stop = false;
165 tce->has_focus = false;
166 for (int j = 0; j < MAX_EFFECT_EVENTS; j++)
167 tce->event_queue[j].id = -1;
168 }
169
170 for (i = 0; i < MAX_TELCOM_SCREENS; i++) {
171 Screen_has_effect_with_focus[i] = false;
172 Screen_roots[i] = -1;
173 }
174 }
175
176 // Shutdown of effects
177 void EfxClose(void) {
178 for (int i = 0; i < MAX_TCEFFECTS; i++) {
179 if (TCEffects[i].type != EFX_NONE) {
180 tceffect *tce = &TCEffects[i];
181 EfxFreeEffect(tce);
182 }
183 }
184 }
185
186 // Destroys all the screens
187 void EfxDestroyAllScreens(void) {
188 for (int i = 0; i < MAX_TCEFFECTS; i++) {
189 if (TCEffects[i].type != EFX_NONE) {
190 tceffect *tce = &TCEffects[i];
191 EfxFreeEffect(tce);
192 }
193 }
194 EfxInit();
195 }
196
197 // Destroys the screens within a monitor
198 void EfxDestroyScreen(int screen) {
199 ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS);
200 int node = Screen_roots[screen];
201 tceffect *tce;
202 while (node != -1) {
203 tce = &TCEffects[node];
204 node = TCEffects[node].next;
205
206 EfxFreeEffect(tce);
207 tce->type = EFX_NONE;
208 tce->monitor = -1;
209 tce->screen = -1;
210 tce->prev = tce->next = -1;
211 tce->id = INVALID_EFFECT_ID;
212 tce->text_buffer = NULL;
213 for (int j = 0; j < MAX_EFFECT_EVENTS; j++)
214 tce->event_queue[j].id = -1;
215 }
216 Screen_roots[screen] = -1;
217 Screen_has_effect_with_focus[screen] = false;
218 }
219
220 // Creates an instance of an Effect
221 int EfxCreate(int type, int monitor, int screen, int id, bool is_tab_stop) {
222 ASSERT(type != EFX_NONE);
223 ASSERT(monitor >= 0 && monitor < MAX_MONITOR);
224 ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS);
225
226 bool make_focus = false;
227
228 // find an available index
229 for (int i = 0; i < MAX_TCEFFECTS; i++) {
230 if (TCEffects[i].type == EFX_NONE) {
231 // we found a slot
232 TCEffects[i].type = type;
233 TCEffects[i].monitor = monitor;
234 TCEffects[i].screen = screen;
235 TCEffects[i].id = id;
236
237 if (is_tab_stop && !Screen_has_effect_with_focus[screen]) {
238 // this effect should get focus
239 make_focus = true;
240 }
241
242 EfxInit(&TCEffects[i], is_tab_stop, make_focus);
243 return i;
244 }
245 }
246 return INVALID_EFFECT_HANDLE;
247 }
248
249 // Frees up any memory allocated for effect, sets type to EFX_NONE
250 void EfxFreeEffect(tceffect *tce) {
251 ASSERT(tce);
252
253 // unlink it out of the list
254 int prev, next;
255 prev = tce->prev;
256 next = tce->next;
257
258 if (prev == -1) {
259 // removing a root
260 if (next != -1) {
261 Screen_roots[tce->screen] = next;
262 } else {
263 Screen_roots[tce->screen] = -1;
264 }
265 } else {
266 // removing a middle node
267 TCEffects[prev].next = next;
268 if (next != -1)
269 TCEffects[next].prev = prev;
270 }
271 tce->prev = tce->next = -1;
272
273 if (tce->text_buffer) {
274 mem_free(tce->text_buffer);
275 tce->text_buffer = NULL;
276 }
277
278 if (tce->has_focus) {
279 // disable the tab stop
280 tce->tab_stop = false;
281
282 // uh oh, we're removing the item on the screen that has focus
283 Screen_has_effect_with_focus[tce->screen] = false;
284
285 // see if we can find another item and give it focus
286 int node = Screen_roots[tce->screen];
287 while (node != -1) {
288 if (TCEffects[node].tab_stop) {
289 // ok we found some one with a tab stop, give em focus
290 TCEffects[node].has_focus = true;
291 Screen_has_effect_with_focus[tce->screen] = true;
292 break;
293 }
294 node = TCEffects[node].next;
295 }
296 }
297
298 int i;
299
300 switch (tce->type) {
301 case EFX_TEXT_TYPE:
302 TelcomStopSound(TCSND_TYPING);
303 break;
304 case EFX_TEXT_STATIC:
305 case EFX_TEXT_FADE:
306 break;
307 case EFX_BMP_STATIC:
308 case EFX_BMP_BLUR:
309 case EFX_BMP_SCANLINE:
310 case EFX_BMP_INVERT:
311 case EFX_BMP_STRETCH:
312 if (tce->bmpinfo.bm_handle > BAD_BITMAP_HANDLE)
313 bm_FreeBitmap(tce->bmpinfo.bm_handle);
314 tce->bmpinfo.bm_handle = -1;
315
316 if (tce->bmpinfo.temp_bmhandle > BAD_BITMAP_HANDLE)
317 bm_FreeBitmap(tce->bmpinfo.temp_bmhandle);
318 tce->bmpinfo.temp_bmhandle = -1;
319
320 if (tce->bmpinfo.bitmaps) {
321 for (i = 0; i < tce->bmpinfo.bm_count; i++) {
322 if (tce->bmpinfo.bitmaps[i] > BAD_BITMAP_HANDLE)
323 bm_FreeBitmap(tce->bmpinfo.bitmaps[i]);
324 }
325 mem_free(tce->bmpinfo.bitmaps);
326 tce->bmpinfo.bitmaps = NULL;
327 }
328
329 if (tce->bmpinfo.chunk_bmp.pw != 0 || tce->bmpinfo.chunk_bmp.ph != 0) {
330 bm_DestroyChunkedBitmap(&tce->bmpinfo.chunk_bmp);
331 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
332 }
333 break;
334 case EFX_BACKGROUND:
335 break;
336 case EFX_MOVIE:
337 if (tce->movieinfo.handle) {
338 EndMovie(tce->movieinfo.handle);
339 tce->movieinfo.handle = NULL;
340 }
341
342 if (tce->movieinfo.filename) {
343 mem_free(tce->movieinfo.filename);
344 tce->movieinfo.filename = NULL;
345 }
346 break;
347 case EFX_POLYMODEL:
348 break;
349 case EFX_SOUND:
350 break;
351 case EFX_BUTTON:
352 if (tce->buttoninfo.bm_handle > BAD_BITMAP_HANDLE)
353 bm_FreeBitmap(tce->buttoninfo.bm_handle);
354 tce->buttoninfo.bm_handle = -1;
355
356 if (tce->buttoninfo.bmfocus_handle > BAD_BITMAP_HANDLE)
357 bm_FreeBitmap(tce->buttoninfo.bmfocus_handle);
358 tce->buttoninfo.bmfocus_handle = -1;
359
360 if (tce->buttoninfo.chunk_bmp.pw != 0 || tce->buttoninfo.chunk_bmp.ph != 0) {
361 bm_DestroyChunkedBitmap(&tce->buttoninfo.chunk_bmp);
362 tce->buttoninfo.chunk_bmp.pw = tce->buttoninfo.chunk_bmp.ph = 0;
363 }
364
365 if (tce->buttoninfo.chunkfocus_bmp.pw != 0 || tce->buttoninfo.chunkfocus_bmp.ph != 0) {
366 bm_DestroyChunkedBitmap(&tce->buttoninfo.chunkfocus_bmp);
367 tce->buttoninfo.chunkfocus_bmp.pw = tce->buttoninfo.chunkfocus_bmp.ph = 0;
368 }
369
370 if (tce->buttoninfo.flash_handle > BAD_BITMAP_HANDLE)
371 bm_FreeBitmap(tce->buttoninfo.flash_handle);
372 tce->buttoninfo.flash_handle = -1;
373
374 if (tce->buttoninfo.flashfocus_handle > BAD_BITMAP_HANDLE)
375 bm_FreeBitmap(tce->buttoninfo.flashfocus_handle);
376 tce->buttoninfo.flashfocus_handle = -1;
377
378 if (tce->buttoninfo.flash_chunk.pw != 0 || tce->buttoninfo.flash_chunk.ph != 0) {
379 bm_DestroyChunkedBitmap(&tce->buttoninfo.flash_chunk);
380 tce->buttoninfo.flash_chunk.pw = tce->buttoninfo.flash_chunk.ph = 0;
381 }
382
383 if (tce->buttoninfo.flashfocus_chunk.pw != 0 || tce->buttoninfo.flashfocus_chunk.ph != 0) {
384 bm_DestroyChunkedBitmap(&tce->buttoninfo.flashfocus_chunk);
385 tce->buttoninfo.flashfocus_chunk.pw = tce->buttoninfo.flashfocus_chunk.ph = 0;
386 }
387
388 break;
389 default:
390 Int3(); // invalid type
391 break;
392 }
393 tce->type = EFX_NONE;
394 tce->monitor = -1;
395 }
396
397 // Initializes an effect based on it's type
398 void EfxInit(tceffect *tce, bool tab_stop, bool gets_focus) {
399
400 ASSERT(tce);
401 ASSERT(tce->type != EFX_NONE);
402 ASSERT(tce->monitor >= 0 && tce->monitor < MAX_MONITOR);
403 ASSERT(tce->screen >= 0 && tce->screen < MAX_TELCOM_SCREENS);
404 ASSERT(tce >= TCEffects);
405
406 // Link effect in
407 int root = Screen_roots[tce->screen];
408 int effect_num = (tce - TCEffects);
409 tce->tab_stop = tab_stop;
410 tce->has_focus = (tab_stop) ? gets_focus : false;
411 if (tce->has_focus) {
412 // the screen has a definite focus, so set the global
413 Screen_has_effect_with_focus[tce->screen] = true;
414 }
415
416 if (root == -1) {
417 // no roots for this monitor, add it
418 Screen_roots[tce->screen] = effect_num;
419 tce->prev = -1;
420 tce->next = -1;
421 } else {
422 // traverse until we get to the end, then add it
423 int curr, next = -1;
424 bool done = false;
425
426 curr = root;
427
428 if (tce->type == EFX_BUTTON) {
429 // go to the end of the list
430 while (!done) {
431 if (TCEffects[curr].next == -1) {
432 done = true;
433 } else {
434 curr = TCEffects[curr].next;
435 }
436 }
437 TCEffects[curr].next = effect_num;
438 TCEffects[effect_num].prev = curr;
439 TCEffects[effect_num].next = -1;
440 } else {
441 // go to where the buttons start
442 if (TCEffects[root].type == EFX_BUTTON) {
443 // replace the root
444 Screen_roots[tce->screen] = effect_num;
445 TCEffects[effect_num].prev = -1;
446 TCEffects[effect_num].next = root;
447 TCEffects[root].prev = effect_num;
448 } else {
449 while (!done) {
450 if (TCEffects[curr].next == -1 || TCEffects[TCEffects[curr].next].type == EFX_BUTTON) {
451 next = TCEffects[curr].next;
452 done = true;
453 } else {
454 curr = TCEffects[curr].next;
455 }
456 }
457 TCEffects[curr].next = effect_num;
458 TCEffects[effect_num].prev = curr;
459 TCEffects[effect_num].next = next;
460 }
461 } // end else
462 } // end else
463
464 tce->pos_x = tce->pos_y = 0;
465 tce->text_buffer = NULL;
466 tce->age = 0;
467 tce->flags = 0;
468 tce->color = GR_GREEN;
469 tce->w = tce->h = 0;
470 tce->speed = 1.0f;
471 tce->start_time = 0;
472
473 // clear the event queue
474 for (int j = 0; j < MAX_EFFECT_EVENTS; j++)
475 tce->event_queue[j].id = -1;
476
477 switch (tce->type) {
478 case EFX_TEXT_STATIC:
479 case EFX_TEXT_TYPE:
480 case EFX_TEXT_FADE:
481 tce->textinfo.last_letter = 0;
482 tce->textinfo.sound_index = -1;
483 tce->textinfo.font_index = BRIEF_FONT_INDEX;
484 ;
485 tce->textinfo.line_index = 0;
486 tce->textinfo.scroll_u = tce->textinfo.scroll_d = false;
487 tce->textinfo.scroll = false;
488 break;
489 case EFX_BMP_STATIC:
490 case EFX_BMP_BLUR:
491 case EFX_BMP_SCANLINE:
492 case EFX_BMP_INVERT:
493 case EFX_BMP_STRETCH:
494 tce->bmpinfo.temp_bmhandle = -1;
495 tce->bmpinfo.stage = 0;
496 tce->bmpinfo.bitmaps = NULL;
497 tce->bmpinfo.bm_count = 0;
498 tce->bmpinfo.bm_handle = -1;
499 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
500 break;
501 case EFX_BACKGROUND:
502 break;
503 case EFX_MOVIE:
504 tce->movieinfo.handle = NULL;
505 tce->movieinfo.filename = NULL;
506 tce->movieinfo.fps = 20.0f;
507 break;
508 case EFX_POLYMODEL:
509 vm_MakeZero(&tce->polyinfo.m_Rot);
510 vm_MakeZero(&tce->polyinfo.m_Pos);
511 vm_MakeZero(&tce->polyinfo.m_Ori);
512 vm_MakeIdentity(&tce->polyinfo.m_mOrient);
513 tce->polyinfo.handle = -1;
514 break;
515 case EFX_SOUND:
516 tce->soundinfo.started = false;
517 tce->soundinfo.handle = -1;
518 break;
519 case EFX_BUTTON:
520 tce->buttoninfo.click_type = CLICKTYPE_CLICKUP;
521 tce->buttoninfo.button_type = BUTT_NEXTPAGE;
522 tce->buttoninfo.sibling = -1;
523 tce->buttoninfo.parent = -1;
524 tce->buttoninfo.internal = NULL;
525 tce->buttoninfo.jump_page = 0;
526 break;
527 default:
528 Int3(); // Invalid Effect
529 }
530 }
531
532 // Renders a Monitor
533 void RenderScreen(int screen, tTelComInfo *tsys, float Frametime) {
534 ASSERT(screen >= -1 && screen < MAX_TELCOM_SCREENS);
535
536 int node = Screen_roots[screen];
537 tceffect *tce;
538
539 int count = 0;
540 int x, y;
541
542 while (node != -1) {
543 tce = &TCEffects[node];
544 x = tsys->Monitor_coords[tce->monitor].left;
545 y = tsys->Monitor_coords[tce->monitor].top;
546
547 if (tce->start_time <= 0) {
548 RenderEffect(tce, Frametime, x, y, true);
549 count++;
550 } else {
551 RenderEffect(tce, Frametime, x, y, false);
552 tce->start_time -= Frametime;
553 }
554
555 node = TCEffects[node].next;
556 }
557 // mprintf(0,"Effect Count: %d effects\n",count);
558 }
559
560 // Renders an effect
561 void RenderEffect(tceffect *tce, float frametime, int xoff, int yoff, bool ok_to_render) {
562 ASSERT(tce->type != EFX_NONE);
563
564 switch (tce->type) {
565 case EFX_TEXT_STATIC:
566 RenderTextStatic(tce, frametime, xoff, yoff, ok_to_render);
567 break;
568 case EFX_TEXT_TYPE:
569 RenderTextType(tce, frametime, xoff, yoff, ok_to_render);
570 break;
571 case EFX_TEXT_FADE:
572 RenderTextFade(tce, frametime, xoff, yoff, ok_to_render);
573 break;
574 case EFX_BMP_STATIC:
575 RenderBmpStatic(tce, frametime, xoff, yoff, ok_to_render);
576 break;
577 case EFX_BMP_BLUR:
578 RenderBmpBlur(tce, frametime, xoff, yoff, ok_to_render);
579 break;
580 case EFX_BMP_SCANLINE:
581 RenderBmpScanline(tce, frametime, xoff, yoff, ok_to_render);
582 break;
583 case EFX_BMP_INVERT:
584 RenderBmpInvert(tce, frametime, xoff, yoff, ok_to_render);
585 break;
586 case EFX_BMP_STRETCH:
587 RenderBmpStretch(tce, frametime, xoff, yoff, ok_to_render);
588 break;
589 case EFX_BACKGROUND:
590 RenderBackground(tce, frametime, xoff, yoff, ok_to_render);
591 break;
592 case EFX_MOVIE:
593 RenderMovie(tce, frametime, xoff, yoff, ok_to_render);
594 break;
595 case EFX_POLYMODEL:
596 RenderPolyModel(tce, frametime, xoff, yoff, ok_to_render);
597 break;
598 case EFX_SOUND:
599 RenderSound(tce, frametime, xoff, yoff, ok_to_render);
600 break;
601 case EFX_BUTTON:
602 RenderButton(tce, frametime, xoff, yoff, ok_to_render);
603 break;
604 default:
605 Int3();
606 };
607 }
608
609 // Sends an event to an effect
610 void SendEventToEffect(int effect, int event, int parm1, int parm2) {
611 ASSERT(effect >= 0 && effect < MAX_TCEFFECTS);
612 ASSERT(event >= 0);
613
614 tceffect *tce = &TCEffects[effect];
615
616 for (int j = 0; j < MAX_EFFECT_EVENTS; j++) {
617 if (tce->event_queue[j].id == -1) {
618 tce->event_queue[j].id = event;
619 tce->event_queue[j].parms[0] = parm1;
620 tce->event_queue[j].parms[1] = parm2;
621 return;
622 }
623 }
624
625 // if we got here than the event queue is filled up
626 mprintf(0, "Warning: Event queue filled up for effect %d\n", effect);
627 }
628
629 // Pops off an event for processesing, returns -1 if no event available
630 bool PopEvent(tceffect *tce, tTCEvent *evt) {
631 ASSERT(tce);
632 int ret = tce->event_queue[0].id;
633
634 if (ret == -1)
635 return false;
636
637 memcpy(evt, &tce->event_queue[0], sizeof(tTCEvent));
638
639 // slide everything up (if it isn't -1)
640 for (int j = 1; j < MAX_EFFECT_EVENTS; j++) {
641 memcpy(&tce->event_queue[j - 1], &tce->event_queue[j], sizeof(tTCEvent));
642 }
643 tce->event_queue[MAX_EFFECT_EVENTS - 1].id = -1;
644 return true;
645 }
646
647 // Returns the efxnum given an id & screen, -1 if not found
648 int GetEfxNumFromID(int id, int screen) {
649 ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS);
650
651 int node = Screen_roots[screen];
652
653 while (node != -1) {
654 if (TCEffects[node].id == id) {
655 return node;
656 }
657
658 node = TCEffects[node].next;
659 }
660 return -1;
661 }
662
663 // returns the efxnum of the button that contains the X,Y on the given monitor/screen, -1 if none
664 int FindButtonEffectByXY(int x, int y, int screen) {
665 ASSERT(screen >= 0 && screen < MAX_TELCOM_SCREENS);
666 tceffect *tce;
667 int node = Screen_roots[screen];
668
669 while (node != -1) {
670 if (TCEffects[node].type == EFX_BUTTON) {
671 tce = &TCEffects[node];
672 if ((tce->pos_x + glitch_dx <= x) && (x <= tce->pos_x + tce->w + glitch_dx) && (tce->pos_y + glitch_dy <= y) &&
673 (y <= tce->pos_y + tce->h + glitch_dy)) {
674 // we got a winner
675 return node;
676 }
677 }
678 node = TCEffects[node].next;
679 }
680 return -1;
681 }
682
683 /////////////////////////////////////////////////////////////////////////
684 char *format(const char *fmt, ...) {
685 static char tempbuffer[8192];
686
687 std::va_list ap;
688 va_start(ap, fmt);
689 std::vsnprintf(tempbuffer, sizeof(tempbuffer), fmt, ap);
690 va_end(ap);
691 return tempbuffer;
692 }
693
694 bool CreateTextEffect(TCTEXTDESC* desc, const char *text, int monitor, int screen, int id) {
695 ASSERT(desc);
696 ASSERT(text);
697
698 int efxtype = -1;
699 switch (desc->type) {
700 case TC_TEXT_STATIC:
701 efxtype = EFX_TEXT_STATIC;
702 break;
703 case TC_TEXT_FADE:
704 efxtype = EFX_TEXT_FADE;
705 break;
706 case TC_TEXT_FLASH:
707 efxtype = EFX_TEXT_TYPE;
708 break;
709 default:
710 Int3(); // not supported
711 }
712 if (efxtype == -1)
713 return false;
714
715 // Creates an instance of the Effect
716 int efxnum = EfxCreate(efxtype, monitor, screen, id, (desc->caps & TCTD_TABSTOP) ? true : false);
717 if (efxnum == -1)
718 return false;
719 tceffect *tce = &TCEffects[efxnum];
720
721 if (desc->caps & TCTD_FONT)
722 tce->textinfo.font_index = desc->font;
723 if (desc->caps & TCTD_COLOR)
724 tce->color = desc->color;
725 if (desc->caps & TCTD_SPEED)
726 tce->speed = desc->speed;
727 else
728 tce->speed = 1.0f;
729 if (desc->caps & TCTD_TEXTBOX) {
730 tce->pos_x = desc->textbox.left;
731 tce->pos_y = desc->textbox.top;
732 tce->w = desc->textbox.right - desc->textbox.left;
733 tce->h = desc->textbox.bottom - desc->textbox.top;
734 } else
735 Int3(); // need a text box
736
737 if (desc->caps & TCTD_SCROLL)
738 tce->textinfo.scroll = true;
739
740 tce->flags = desc->flags;
741 if (desc->caps & TCTD_WAITTIME)
742 tce->start_time = desc->waittime;
743 else
744 tce->start_time = 0;
745 if (desc->caps & TCTD_TABSTOP)
746 tce->tab_stop = true;
747 else
748 tce->tab_stop = false;
749
750 tce->id = id;
751
752 switch (tce->type) {
753 case EFX_TEXT_STATIC:
754 return CreateTextStatic(tce, text);
755 case EFX_TEXT_FADE:
756 return CreateTextFade(tce, text);
757 case EFX_TEXT_TYPE:
758 return CreateTextType(tce, text);
759 }
760 return false;
761 }
762
763 bool CreateBitmapEffect(TCBMPDESC* desc, int monitor, int screen, int id) {
764 ASSERT(desc);
765 int efxtype = -1;
766 switch (desc->type) {
767 case TC_BMP_STATIC:
768 efxtype = EFX_BMP_STATIC;
769 break;
770 case TC_BMP_BLUR:
771 efxtype = EFX_BMP_BLUR;
772 break;
773 case TC_BMP_SCANLINE:
774 efxtype = EFX_BMP_SCANLINE;
775 break;
776 case TC_BMP_INVERT:
777 efxtype = EFX_BMP_INVERT;
778 break;
779 case TC_BMP_STRETCH:
780 efxtype = EFX_BMP_STRETCH;
781 break;
782 default:
783 Int3();
784 }
785 if (efxtype == -1)
786 return false;
787
788 // Creates an instance of the Effect
789 int efxnum = EfxCreate(efxtype, monitor, screen, id);
790 if (efxnum == -1)
791 return false;
792 tceffect *tce = &TCEffects[efxnum];
793
794 if (desc->caps & TCBD_XY) {
795 tce->pos_x = desc->x;
796 tce->pos_y = desc->y;
797 } else {
798 tce->pos_x = tce->pos_y = 0;
799 }
800 if (desc->caps & TCBD_WAITTIME)
801 tce->start_time = desc->waittime;
802 else
803 tce->start_time = 0;
804 if (desc->caps & TCBD_SPEED)
805 tce->speed = desc->speed;
806 else
807 tce->speed = 1;
808 tce->flags = desc->flags;
809
810 switch (tce->type) {
811 case EFX_BMP_STATIC:
812 return CreateBmpStatic(tce, desc->filename);
813 case EFX_BMP_BLUR:
814 return CreateBmpBlur(tce, desc->filename);
815 case EFX_BMP_SCANLINE:
816 return CreateBmpScanline(tce, desc->filename);
817 case EFX_BMP_INVERT:
818 return CreateBmpInvert(tce, desc->filename);
819 case EFX_BMP_STRETCH:
820 return CreateBmpStretch(tce, desc->filename);
821 }
822 return false;
823 }
824
825 bool CreateMovieEffect(TCMOVIEDESC* desc, int monitor, int screen, int id) {
826 ASSERT(desc);
827 int efxtype = -1;
828 switch (desc->type) {
829 case TC_MOVIE_STATIC:
830 efxtype = EFX_MOVIE;
831 break;
832 default:
833 Int3();
834 }
835 if (efxtype == -1)
836 return false;
837 // Creates an instance of the Effect
838 int efxnum = EfxCreate(efxtype, monitor, screen, id);
839 if (efxnum == -1)
840 return false;
841 tceffect *tce = &TCEffects[efxnum];
842
843 if (desc->caps & TCMD_XY)
844 tce->movieinfo.fps = desc->fps;
845 else
846 tce->movieinfo.fps = 20.0f;
847 if (desc->caps & TCMD_WAITTIME)
848 tce->start_time = desc->waittime;
849 else
850 tce->start_time = 0;
851 if (desc->caps & TCMD_XY) {
852 tce->pos_x = desc->x;
853 tce->pos_y = desc->y;
854 } else {
855 tce->pos_x = tce->pos_y = 0;
856 }
857
858 switch (tce->type) {
859 case EFX_MOVIE:
860 return CreateMovie(tce, desc->filename);
861 }
862
863 return false;
864 }
865
866 extern tTelComInfo Telcom_system;
867 bool CreateBackgroundEffect(TCBKGDESC* desc, int monitor, int screen, int id) {
868 ASSERT(desc);
869 int efxtype = -1;
870 switch (desc->type) {
871 case TC_BACK_STATIC:
872 efxtype = EFX_BACKGROUND;
873 break;
874 default:
875 Int3();
876 }
877 if (efxtype == -1)
878 return false;
879 // Creates an instance of the Effect
880 int efxnum = EfxCreate(efxtype, monitor, screen, id);
881 if (efxnum == -1)
882 return false;
883 tceffect *tce = &TCEffects[efxnum];
884
885 if (desc->caps & TCBGD_COLOR)
886 tce->color = desc->color;
887 else
888 tce->color = GR_BLUE;
889 if (desc->caps & TCBGD_WAITTIME)
890 tce->start_time = desc->waittime;
891 else
892 tce->start_time = 0;
893
894 tce->pos_x = 0;
895 tce->pos_y = 0;
896 tce->w = Telcom_system.Monitor_coords[monitor].right - Telcom_system.Monitor_coords[monitor].left;
897 tce->h = Telcom_system.Monitor_coords[monitor].bottom - Telcom_system.Monitor_coords[monitor].top;
898
899 switch (tce->type) {
900 case EFX_BACKGROUND:
901 return CreateBackground(tce);
902 }
903 return false;
904 }
905
906 bool CreatePolyModelEffect(TCPOLYDESC* desc, int monitor, int screen, int id) {
907 ASSERT(desc);
908 int efxtype = -1;
909 switch (desc->type) {
910 case TC_POLY_STATIC:
911 efxtype = EFX_POLYMODEL;
912 break;
913 default:
914 Int3();
915 }
916 Int3(); // polymodel not supported yet
917 return false;
918 }
919
920 bool CreateSoundEffect(TCSNDDESC* desc, int monitor, int screen, int id) {
921 ASSERT(desc);
922 int efxtype = -1;
923 switch (desc->type) {
924 case TC_SND_STATIC:
925 efxtype = EFX_SOUND;
926 break;
927 default:
928 Int3();
929 }
930 if (efxtype == -1)
931 return false;
932 // Creates an instance of the Effect
933 int efxnum = EfxCreate(efxtype, monitor, screen, id);
934 if (efxnum == -1)
935 return false;
936 tceffect *tce = &TCEffects[efxnum];
937 if (desc->caps & TCSD_WAITTIME)
938 tce->start_time = desc->waittime;
939 else
940 tce->start_time = 0;
941
942 switch (tce->type) {
943 case EFX_SOUND:
944 return CreateSound(tce, desc->filename);
945 }
946 return false;
947 }
948
949 int CreateButtonEffect(TCBUTTONDESC* desc, int monitor, int screen, int id) {
950 ASSERT(desc);
951 ASSERT(monitor == MONITOR_MAIN);
952
953 // Creates an instance of the Effect
954 int efxnum = EfxCreate(EFX_BUTTON, monitor, screen, id, desc->tab_stop);
955 if (efxnum == -1)
956 return -1;
957 tceffect *tce = &TCEffects[efxnum];
958
959 // Load in regular bitmap
960 tce->buttoninfo.chunk_bmp.pw = tce->buttoninfo.chunk_bmp.ph = 0;
961 tce->buttoninfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->filename), 0);
962 if (tce->buttoninfo.bm_handle == -1) {
963 desc->w = desc->h = 0;
964 tce->buttoninfo.bm_handle = BAD_BITMAP_HANDLE;
965 mprintf(0, "Unable to load bmp '%s'\n", desc->filename);
966 } else {
967 desc->w = bm_w(tce->buttoninfo.bm_handle, 0);
968 desc->h = bm_h(tce->buttoninfo.bm_handle, 0);
969 bm_CreateChunkedBitmap(tce->buttoninfo.bm_handle, &tce->buttoninfo.chunk_bmp);
970 }
971
972 tce->buttoninfo.chunkfocus_bmp.pw = tce->buttoninfo.chunkfocus_bmp.ph = 0;
973 tce->buttoninfo.bmfocus_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->filename_focus), 0);
974 if (tce->buttoninfo.bmfocus_handle == -1) {
975 tce->buttoninfo.bmfocus_handle = BAD_BITMAP_HANDLE;
976 mprintf(0, "Unable to load bmp '%s'\n", desc->filename_focus);
977 } else {
978 bm_CreateChunkedBitmap(tce->buttoninfo.bmfocus_handle, &tce->buttoninfo.chunkfocus_bmp);
979 }
980
981 // Load in flash/glow bitmap
982 tce->buttoninfo.flash_chunk.pw = tce->buttoninfo.flash_chunk.ph = 0;
983 if (desc->flasher) {
984 tce->buttoninfo.flash_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->flash_filename), 0);
985 if (tce->buttoninfo.flash_handle == -1) {
986 mprintf(0, "Unable to load bmp '%s'\n", desc->flash_filename);
987 } else {
988 bm_CreateChunkedBitmap(tce->buttoninfo.flash_handle, &tce->buttoninfo.flash_chunk);
989 }
990 } else {
991 tce->buttoninfo.flash_handle = -1;
992 }
993
994 tce->buttoninfo.flashfocus_chunk.pw = tce->buttoninfo.flashfocus_chunk.ph = 0;
995 if (desc->flasher) {
996 tce->buttoninfo.flashfocus_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(desc->flash_filename_focus), 0);
997 if (tce->buttoninfo.flashfocus_handle == -1) {
998 mprintf(0, "Unable to load bmp '%s'\n", desc->flash_filename_focus);
999 } else {
1000 bm_CreateChunkedBitmap(tce->buttoninfo.flashfocus_handle, &tce->buttoninfo.flashfocus_chunk);
1001 }
1002 } else {
1003 tce->buttoninfo.flashfocus_handle = -1;
1004 }
1005
1006 if (desc->button_type == BUTT_INTERNAL) {
1007 tce->buttoninfo.internal = desc->internal;
1008 } else {
1009 tce->buttoninfo.internal = NULL;
1010 }
1011
1012 tce->buttoninfo.sibling = desc->sibling_id;
1013 tce->buttoninfo.parent = desc->parent_id;
1014 tce->buttoninfo.button_type = desc->button_type;
1015 tce->buttoninfo.click_type = desc->click_type;
1016 tce->buttoninfo.flash_time = desc->flash_time;
1017 tce->w = desc->w;
1018 tce->h = desc->h;
1019 tce->pos_x = desc->x;
1020 tce->pos_y = desc->y;
1021 tce->flags = desc->osflags;
1022 tce->buttoninfo.jump_page = desc->jump_page;
1023
1024 return efxnum;
1025 }
1026
1027 ////////////////////////////////////////////////////////////////////
1028 bool CreateTextStatic(tceffect *tce, const char *text) {
1029 ASSERT(text);
1030 if (!text)
1031 return false;
1032
1033 tce->text_buffer = (char *)mem_malloc(strlen(text) + 10);
1034 if (!tce->text_buffer)
1035 return false;
1036
1037 tce->alpha = 255;
1038
1039 char *tempbuffer = (char *)mem_malloc(strlen(text) + 10);
1040 if (!tempbuffer)
1041 return false;
1042 strcpy(tempbuffer, text);
1043
1044 // apply the word wrap
1045 textaux_WordWrap(tempbuffer, tce->text_buffer, tce->w, Game_fonts[tce->textinfo.font_index]);
1046
1047 mem_free(tempbuffer);
1048
1049 return true;
1050 }
1051
1052 bool CreateTextFade(tceffect *tce, const char *text) {
1053 ASSERT(text);
1054 if (!text || text[0] == '\0')
1055 return false;
1056 tce->text_buffer = (char *)mem_malloc(strlen(text) + 10);
1057 if (!tce->text_buffer)
1058 return false;
1059
1060 char *tempbuffer = (char *)mem_malloc(strlen(text) + 10);
1061 if (!tempbuffer)
1062 return false;
1063 strcpy(tempbuffer, text);
1064
1065 // apply the word wrap
1066 textaux_WordWrap(tempbuffer, tce->text_buffer, tce->w, Game_fonts[tce->textinfo.font_index]);
1067
1068 mem_free(tempbuffer);
1069
1070 switch (tce->flags) {
1071 case TC_TEXTF_OUT:
1072 tce->alpha = 255.0f;
1073 break;
1074 case TC_TEXTF_IN:
1075 case TC_TEXTF_PINGPONG:
1076 default:
1077 tce->alpha = 0.01f;
1078 break;
1079 }
1080 return true;
1081 }
1082
1083 bool CreateTextType(tceffect *tce, const char *text) {
1084 ASSERT(text);
1085 if (!text || text[0] == '\0')
1086 return false;
1087 tce->text_buffer = (char *)mem_malloc(strlen(text) + 10);
1088 if (!tce->text_buffer)
1089 return false;
1090
1091 char *tempbuffer = (char *)mem_malloc(strlen(text) + 10);
1092 if (!tempbuffer)
1093 return false;
1094 strcpy(tempbuffer, text);
1095
1096 // apply the word wrap
1097 textaux_WordWrap(tempbuffer, tce->text_buffer, tce->w, Game_fonts[tce->textinfo.font_index]);
1098
1099 mem_free(tempbuffer);
1100
1101 tce->textinfo.last_letter = 0;
1102 return true;
1103 }
1104
1105 bool CreateBmpStatic(tceffect *tce, const char *filename) {
1106 ASSERT(filename);
1107
1108 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
1109 tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
1110 if (tce->bmpinfo.bm_handle == -1) {
1111 tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE;
1112 mprintf(0, "Unable to load bmp '%s'\n", filename);
1113 } else
1114 bm_CreateChunkedBitmap(tce->bmpinfo.bm_handle, &tce->bmpinfo.chunk_bmp);
1115 return true;
1116 }
1117
1118 bool CreateBmpBlur(tceffect *tce, const char *filename) {
1119 ASSERT(filename);
1120
1121 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
1122 tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
1123 if (tce->bmpinfo.bm_handle == -1) {
1124 tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE;
1125 mprintf(0, "Unable to load bmp '%s'\n", filename);
1126 } else {
1127 tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0);
1128 if (tce->bmpinfo.temp_bmhandle == -1)
1129 tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE;
1130
1131 if (tce->flags == TC_BMPF_OUT)
1132 tce->bmpinfo.stage = BLUR_STAGES;
1133 else
1134 tce->bmpinfo.stage = 0;
1135
1136 // create the chunk bitmap for use
1137 bm_CreateChunkedBitmap(tce->bmpinfo.bm_handle, &tce->bmpinfo.chunk_bmp);
1138 }
1139 return true;
1140 }
1141
1142 bool CreateBmpScanline(tceffect *tce, const char *filename) {
1143 ASSERT(filename);
1144
1145 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
1146 tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
1147 tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE;
1148 if (tce->bmpinfo.bm_handle == -1) {
1149 tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE;
1150 mprintf(0, "Unable to load bmp '%s'\n", filename);
1151 } else {
1152 tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0);
1153 if (tce->bmpinfo.temp_bmhandle == -1)
1154 tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE;
1155
1156 // create the chunk bitmap for use
1157 bm_CreateChunkedBitmap(tce->bmpinfo.bm_handle, &tce->bmpinfo.chunk_bmp);
1158 }
1159 return true;
1160 }
1161
1162 bool CreateBmpInvert(tceffect *tce, const char *filename) {
1163 ASSERT(filename);
1164
1165 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
1166 tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
1167 tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE;
1168 if (tce->bmpinfo.bm_handle == -1) {
1169 tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE;
1170 mprintf(0, "Unable to load bmp '%s'\n", filename);
1171 } else {
1172 tce->bmpinfo.temp_bmhandle = bm_AllocBitmap(bm_w(tce->bmpinfo.bm_handle, 0), bm_h(tce->bmpinfo.bm_handle, 0), 0);
1173 if (tce->bmpinfo.temp_bmhandle == -1)
1174 tce->bmpinfo.temp_bmhandle = BAD_BITMAP_HANDLE;
1175
1176 // create the chunk bitmap for use
1177 bm_CreateChunkedBitmap(tce->bmpinfo.bm_handle, &tce->bmpinfo.chunk_bmp);
1178 }
1179 return true;
1180 }
1181
1182 bool CreateBmpStretch(tceffect *tce, const char *filename) {
1183 ASSERT(filename);
1184
1185 tce->bmpinfo.chunk_bmp.pw = tce->bmpinfo.chunk_bmp.ph = 0;
1186 tce->bmpinfo.bm_handle = bm_AllocLoadFileBitmap(IGNORE_TABLE(filename), 0);
1187 tce->bmpinfo.bitmaps = NULL;
1188 tce->bmpinfo.bm_count = 0;
1189 if (tce->bmpinfo.bm_handle == -1) {
1190 tce->bmpinfo.bm_handle = BAD_BITMAP_HANDLE;
1191 mprintf(0, "Unable to load bmp '%s'\n", filename);
1192 } else {
1193 // determine how many wide we need
1194 int src_w = bm_w(tce->bmpinfo.bm_handle, 0);
1195 int w_count = 0;
1196 w_count = ((src_w + 63) / 64);
1197 // determine how many tall we need
1198 int src_h = bm_h(tce->bmpinfo.bm_handle, 0);
1199 int h_count = 0;
1200 h_count = ((src_h + 63) / 64);
1201
1202 int total = w_count * h_count;
1203 int index;
1204 tce->bmpinfo.bm_count = total;
1205 tce->bmpinfo.bitmaps = (int *)mem_malloc(sizeof(int) * total);
1206 if (!tce->bmpinfo.bitmaps)
1207 return false;
1208
1209 for (index = 0; index < total; index++) {
1210 tce->bmpinfo.bitmaps[index] = bm_AllocBitmap(64, 64, 0);
1211 if (tce->bmpinfo.bitmaps[index] == -1)
1212 tce->bmpinfo.bitmaps[index] = BAD_BITMAP_HANDLE;
1213 }
1214
1215 // now fill in the bitmaps
1216 int realx, realy;
1217 realx = 0;
1218 realy = 0;
1219
1220 int wi, hi;
1221 uint16_t *srcdata = bm_data(tce->bmpinfo.bm_handle, 0);
1222 uint16_t *destdata;
1223
1224 realx = 0;
1225 realy = 0;
1226 index = 0;
1227 for (hi = 0, realy = 0; hi < h_count; hi++, realy += 64)
1228 for (wi = 0, realx = 0; wi < w_count; wi++, realx += 64) {
1229 int x, y;
1230 int ix, iy;
1231
1232 destdata = bm_data(tce->bmpinfo.bitmaps[index], 0);
1233
1234 for (y = realy, iy = 0; y < realy + 64; iy++, y++)
1235 for (x = realx, ix = 0; x < realx + 64; ix++, x++) {
1236 if ((x < src_w) && (y < src_h)) {
1237 destdata[(iy * 64) + ix] = srcdata[(y * src_w) + x];
1238 } else {
1239 destdata[(iy * 64) + ix] = NEW_TRANSPARENT_COLOR;
1240 }
1241 }
1242 index++;
1243 }
1244 }
1245 return true;
1246 }
1247
1248 bool CreateMovie(tceffect *tce, const char *filename) {
1249 ASSERT(filename);
1250
1251 tce->movieinfo.handle = NULL;
1252 tce->movieinfo.filename = NULL;
1253 tce->w = tce->h = 100;
1254
1255 tce->movieinfo.filename = (char *)mem_malloc(strlen(filename) + 1);
1256 if (!tce->movieinfo.filename)
1257 return false;
1258 strcpy(tce->movieinfo.filename, filename);
1259 tce->movieinfo.handle = StartMovie(filename);
1260 if (!tce->movieinfo.handle)
1261 return false;
1262 return true;
1263 }
1264
1265 bool CreateBackground(tceffect *tce) { return true; }
1266
1267 bool CreateSound(tceffect *tce, const char *filename) {
1268 tce->soundinfo.handle = FindSoundName(IGNORE_TABLE(filename));
1269 if (tce->soundinfo.handle == -1) {
1270 mprintf(0, "Unable to find sound '%s'\n", filename);
1271 }
1272 return true;
1273 }
1274
1275 void BltBmpToScreen(int dx, int dy, chunked_bitmap *src_bmp) {
1276 BltBmpToScreen(dx, dy, src_bmp, 0, 0, src_bmp->pw, src_bmp->ph);
1277 }
1278 void BltBmpToScreen(int dx, int dy, chunked_bitmap *src_bmp, int sx, int sy, int sw, int sh) {
1279 rend_DrawChunkedBitmap(src_bmp, dx, dy, 255);
1280 }
1281 // forces a chunk bitmap to be uploaded
1282 void UploadChunk(chunked_bitmap *bmp) {
1283 ASSERT(bmp);
1284
1285 int count = bmp->w * bmp->h;
1286
1287 for (int index = 0; index < count; index++) {
1288 int bm = bmp->bm_array[index];
1289 GameBitmaps[bm].flags |= BF_CHANGED;
1290 }
1291 }