This commit was manufactured by cvs2svn to create tag 'd2x-0_1_2'.
[btb/d2x.git] / main / titles.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14 #ifdef HAVE_CONFIG_H
15 #include <conf.h>
16 #endif
17
18 #define ROBOT_MOVIES
19
20 #ifdef WINDOWS
21 #include "desw.h"
22 #endif
23
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <string.h>
27
28 #ifdef MACINTOSH
29 #include <Events.h>
30 #endif
31
32 #include "pa_enabl.h"                   //$$POLY_ACC
33 #include "pstypes.h"
34 #include "timer.h"
35 #include "key.h"
36 #include "gr.h"
37 #include "palette.h"
38 #include "iff.h"
39 #include "pcx.h"
40 #include "u_mem.h"
41 #include "joy.h"
42 #include "mono.h"
43 #include "gamefont.h"
44 #include "cfile.h"
45 #include "error.h"
46 #include "polyobj.h"
47 #include "textures.h"
48 #include "screens.h"
49 #include "multi.h"
50 #include "player.h"
51 #include "digi.h"
52 #include "compbit.h"
53 #include "text.h"
54 #include "kmatrix.h"
55 #include "piggy.h"
56 #include "songs.h"
57 #include "newmenu.h"
58 #include "state.h"
59 #ifdef ROBOT_MOVIES
60 #include "movie.h"
61 #endif
62 #include "menu.h"
63
64 #if defined(POLY_ACC)
65 #include "poly_acc.h"
66 #endif
67
68 #ifdef ROBOT_MOVIES
69 extern void RotateRobot();
70 #endif
71
72 void DoBriefingColorStuff ();
73 int get_new_message_num(char **message);
74 int DefineBriefingBox (char **buf);
75
76 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
77
78 extern int MVEPaletteCalls;
79
80 ubyte New_pal[768];
81 int     New_pal_254_bash;
82
83 char CurBriefScreenName[15]="brief03.pcx";
84 char    * Briefing_text;
85 #ifdef ROBOT_MOVIES
86 char RobotPlaying=0;
87 #endif
88
89 #define MAX_BRIEFING_COLORS     3
90
91 #define SHAREWARE_ENDING_FILENAME       "ending.tex"
92
93 //      Can be set by -noscreens command line option.  Causes bypassing of all briefing screens.
94 int     Skip_briefing_screens=0;
95 int     Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
96 int     Current_color = 0;
97 int     Erase_color;
98
99 extern int check_button_press();
100
101 #ifdef MACINTOSH
102 extern void macintosh_quit(void);
103 #endif
104
105 #ifndef ROBOT_MOVIES
106 static int rescale_x(int x)
107 {
108         return x * GWIDTH / 320;
109 }
110
111 static int rescale_y(int y)
112 {
113         return y * GHEIGHT / 200;
114 }
115 #endif
116
117 #ifndef MACINTOSH
118 int local_key_inkey(void)
119 {
120         int     rval;
121
122 #ifdef WINDOWS
123         MSG msg;
124         
125         DoMessageStuff(&msg);
126 #endif
127
128         rval = key_inkey();
129
130         if (rval == KEY_PRINT_SCREEN) {
131                 #ifdef POLY_ACC
132 #ifdef ROBOT_MOVIES
133                 if (RobotPlaying) {
134                         gr_palette_read(gr_palette);
135                         gr_copy_palette(gr_palette,gr_palette,0);       //reset color lookup cache
136                 }
137 #endif
138                 #endif
139                 save_screen_shot(0);
140                 return 0;                               //say no key pressed
141         }
142
143         if (check_button_press())               //joystick or mouse button pressed?
144                 rval = KEY_SPACEBAR;
145
146         #ifdef MACINTOSH
147         if ( rval == KEY_Q+KEY_COMMAND )
148                 macintosh_quit();
149         #endif
150
151         return rval;
152 }
153 #else
154 int local_key_inkey(void)
155 {
156         EventRecord event;
157         int     rval;
158
159         if (!GetOSEvent(everyEvent, &event))
160                 return 0;
161
162         if (event.what != keyDown)
163                 return 0;
164                 
165         rval = (int)((event.message & keyCodeMask) >> 8);
166
167         if (rval == KEY_PRINT_SCREEN) {
168                 save_screen_shot(0);
169                 return 0;                               //say no key pressed
170         }
171
172         if (check_button_press())               //joystick or mouse button pressed?
173                 rval = KEY_SPACEBAR;
174
175         #ifdef MACINTOSH
176         if ( rval == KEY_Q+KEY_COMMAND )
177                 macintosh_quit();
178         #endif
179
180         return rval;
181 }
182 #endif
183
184 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
185 {
186         fix timer;
187         int pcx_error;
188         grs_bitmap title_bm;
189         ubyte   palette_save[768];
190         char new_filename[FILENAME_LEN+1] = "";
191
192         #ifdef RELEASE
193         if (from_hog_only)
194                 strcpy(new_filename,"\x01");    //only read from hog file
195         #endif
196
197         strcat(new_filename,filename);
198         filename = new_filename;
199
200         title_bm.bm_data=NULL;
201         if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE)     {
202                 printf( "File '%s', PCX load error: %s (%i)\n  (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
203                 mprintf((0, "File '%s', PCX load error: %s (%i)\n  (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error));
204                 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
205         }
206
207         memcpy(palette_save,gr_palette,sizeof(palette_save));
208
209 #if defined(POLY_ACC)
210     pa_save_clut();
211     pa_update_clut(New_pal, 0, 256, 0);
212 #endif
213
214         //vfx_set_palette_sub( New_pal );
215 #ifdef OGL
216         gr_palette_load( New_pal );
217 #else
218         gr_palette_clear();     
219 #endif
220
221         WINDOS( 
222                 dd_gr_set_current_canvas(NULL),
223                 gr_set_current_canvas( NULL )
224         );
225         WIN(DDGRLOCK(dd_grd_curcanv));
226                 gr_bitmap( 0, 0, &title_bm );
227         WIN(DDGRUNLOCK(dd_grd_curcanv));
228
229         WIN(DDGRRESTORE);
230
231 #if defined(POLY_ACC)
232     pa_restore_clut();
233 #endif
234
235         if (gr_palette_fade_in( New_pal, 32, allow_keys ))      
236                 return 1;
237         gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
238
239         gr_palette_load( New_pal );
240         timer   = timer_get_fixed_seconds() + i2f(3);
241         while (1)       {
242                 if ( local_key_inkey() && allow_keys ) break;
243                 if ( timer_get_fixed_seconds() > timer ) break;
244         }                       
245         if (gr_palette_fade_out( New_pal, 32, allow_keys ))
246                 return 1;
247         gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
248         d_free(title_bm.bm_data);
249         return 0;
250 }
251
252 typedef struct {
253         char    bs_name[14];                                            //      filename, eg merc01.  Assumes .lbm suffix.
254         byte    level_num;
255         byte    message_num;
256         short   text_ulx, text_uly;                     //      upper left x,y of text window
257         short   text_width, text_height;        //      width and height of text window
258 } briefing_screen;
259
260 #define BRIEFING_SECRET_NUM     31                      //      This must correspond to the first secret level which must come at the end of the list.
261 #define BRIEFING_OFFSET_NUM     4                       // This must correspond to the first level screen (ie, past the bald guy briefing screens)
262
263 #define SHAREWARE_ENDING_LEVEL_NUM              0x7f
264 #define REGISTERED_ENDING_LEVEL_NUM     0x7e
265
266 #ifdef SHAREWARE
267 #define ENDING_LEVEL_NUM        SHAREWARE_ENDING_LEVEL_NUM
268 #else
269 #define ENDING_LEVEL_NUM        REGISTERED_ENDING_LEVEL_NUM
270 #endif
271
272 #define MAX_BRIEFING_SCREENS 60
273
274 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
275  {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
276
277 int     Briefing_text_x, Briefing_text_y;
278
279 void init_char_pos(int x, int y)
280 {
281         Briefing_text_x = x;
282         Briefing_text_y = y;
283    mprintf ((0,"Setting init x=%d y=%d\n",x,y));
284 }
285
286 grs_canvas      *Robot_canv = NULL;
287 vms_angvec      Robot_angles;
288
289 char    Bitmap_name[32] = "";
290 #define EXIT_DOOR_MAX   14
291 #define OTHER_THING_MAX 10              //      Adam: This is the number of frames in your new animating thing.
292 #define DOOR_DIV_INIT   6
293 byte    Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
294
295 //      -----------------------------------------------------------------------------
296 void show_bitmap_frame(void)
297 {
298 #ifdef WINDOWS
299         dd_grs_canvas *curcanv_save, *bitmap_canv=0;
300 #else
301         grs_canvas      *curcanv_save, *bitmap_canv=0;
302 #endif
303
304         grs_bitmap      *bitmap_ptr;
305
306         //      Only plot every nth frame.
307         if (Door_div_count) {
308                 Door_div_count--;
309                 return;
310         }
311
312         Door_div_count = DOOR_DIV_INIT;
313
314         if (Bitmap_name[0] != 0) {
315                 char            *pound_signp;
316                 int             num, dig1, dig2;
317
318                 //      Set supertransparency color to black
319                 if (!New_pal_254_bash) {
320                         New_pal_254_bash = 1;
321                         New_pal[254*3] = 0;
322                         New_pal[254*3+1] = 0;
323                         New_pal[254*3+2] = 0;
324                         gr_palette_load( New_pal );
325                 }
326
327                 switch (Animating_bitmap_type) {
328                         case 0:
329                         WINDOS( 
330                                 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
331                                 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64);       break
332                         );
333                         case 1: 
334                         WINDOS(
335                                 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
336                                 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94);       break
337                         );      
338                         
339                         //      Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
340                         default:        Int3(); //      Impossible, illegal value for Animating_bitmap_type
341                 }
342
343                 WINDOS(
344                         curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
345                         curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
346                 );
347
348                 pound_signp = strchr(Bitmap_name, '#');
349                 Assert(pound_signp != NULL);
350
351                 dig1 = *(pound_signp+1);
352                 dig2 = *(pound_signp+2);
353                 if (dig2 == 0)
354                         num = dig1-'0';
355                 else
356                         num = (dig1-'0')*10 + (dig2-'0');
357
358                 switch (Animating_bitmap_type) {
359                         case 0:
360                                 num += Door_dir;
361                                 if (num > EXIT_DOOR_MAX) {
362                                         num = EXIT_DOOR_MAX;
363                                         Door_dir = -1;
364                                 } else if (num < 0) {
365                                         num = 0;
366                                         Door_dir = 1;
367                                 }
368                                 break;
369                         case 1:
370                                 num++;
371                                 if (num > OTHER_THING_MAX)
372                                         num = 0;
373                                 break;
374                 }
375
376                 Assert(num < 100);
377                 if (num >= 10) {
378                         *(pound_signp+1) = (num / 10) + '0';
379                         *(pound_signp+2) = (num % 10) + '0';
380                         *(pound_signp+3) = 0;
381                 } else {
382                         *(pound_signp+1) = (num % 10) + '0';
383                         *(pound_signp+2) = 0;
384                 }
385
386                 {
387                         bitmap_index bi;
388                         bi = piggy_find_bitmap(Bitmap_name);
389                         bitmap_ptr = &GameBitmaps[bi.index];
390                         PIGGY_PAGE_IN( bi );
391                 }
392
393                 WIN(DDGRLOCK(dd_grd_curcanv));
394                         gr_bitmapm(0, 0, bitmap_ptr);
395                 WIN(DDGRUNLOCK(dd_grd_curcanv));
396
397                 WINDOS(
398                         dd_grd_curcanv = curcanv_save,
399                         grd_curcanv = curcanv_save
400                 );
401                 d_free(bitmap_canv);
402
403                 switch (Animating_bitmap_type) {
404                         case 0:
405                                 if (num == EXIT_DOOR_MAX) {
406                                         Door_dir = -1;
407                                         Door_div_count = 64;
408                                 } else if (num == 0) {
409                                         Door_dir = 1;
410                                         Door_div_count = 64;
411                                 }
412                                 break;
413                         case 1:
414                                 break;
415                 }
416         }
417
418 }
419
420 //      -----------------------------------------------------------------------------
421 void show_briefing_bitmap(grs_bitmap *bmp)
422 {
423 #ifdef WINDOWS
424         dd_grs_canvas *bitmap_canv, *curcanv_save;
425   
426         bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h); 
427         curcanv_save = dd_grd_curcanv;
428         dd_gr_set_current_canvas(bitmap_canv);
429         DDGRLOCK(dd_grd_curcanv);
430         gr_bitmapm(0,0,bmp);
431         DDGRUNLOCK(dd_grd_curcanv);
432         dd_gr_set_current_canvas(curcanv_save);
433 #else
434         grs_canvas      *curcanv_save, *bitmap_canv;
435
436         bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
437         curcanv_save = grd_curcanv;
438         gr_set_current_canvas(bitmap_canv);
439         gr_bitmapm(0, 0, bmp);
440         gr_set_current_canvas(curcanv_save);
441 #endif
442
443         d_free(bitmap_canv);
444 }
445
446 #ifndef ROBOT_MOVIES //WINDOWS
447 //      -----------------------------------------------------------------------------
448 void show_spinning_robot_frame(int robot_num)
449 {
450         grs_canvas      *curcanv_save;
451
452         if (robot_num != -1) {
453                 Robot_angles.h += 150;
454
455                 curcanv_save = grd_curcanv;
456                 grd_curcanv = Robot_canv;
457                 Assert(Robot_info[robot_num].model_num != -1);
458                 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
459                 grd_curcanv = curcanv_save;
460         }
461
462 }
463
464 //  -----------------------------------------------------------------------------
465 void init_spinning_robot(void) //(int x,int y,int w,int h)
466  {
467 #if 0
468         Robot_angles.p += 0;
469         Robot_angles.b += 0;
470         Robot_angles.h += 0;
471
472 #else
473         int x = rescale_x(138);
474         int y = rescale_y(55);
475         int w = rescale_x(166);
476         int h = rescale_y(138);
477 #endif
478
479         Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
480         // 138, 55, 166, 138
481  }
482 #endif
483
484 //      -----------------------------------------------------------------------------
485 //      Returns char width.
486 //      If show_robot_flag set, then show a frame of the spinning robot.
487 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
488 {
489         int     w, h, aw;
490         char    message[2];
491         static fix      start_time=0;
492
493    robot_num=0;
494         message[0] = the_char;
495         message[1] = 0;
496
497    if (start_time==0 && timer_get_fixed_seconds()<0)
498     start_time=timer_get_fixed_seconds(); 
499  
500         gr_get_string_size(message, &w, &h, &aw );
501
502         Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
503
504         //      Draw cursor if there is some delay and caller says to draw cursor
505         if (cursor_flag && delay) {
506         WIN(DDGRLOCK(dd_grd_curcanv));
507                 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
508                 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
509         WIN(DDGRUNLOCK(dd_grd_curcanv));
510         }
511
512                 if (delay)
513                  delay=fixdiv (F1_0,i2f(15));
514
515                 if (delay != 0)
516                         show_bitmap_frame();
517
518 #ifdef ROBOT_MOVIES
519                 if (RobotPlaying && (delay != 0))
520                         RotateRobot();
521       
522       
523                 while (timer_get_fixed_seconds() < (start_time + delay)) {
524                         if (RobotPlaying && delay != 0)
525                                 RotateRobot();
526                 }
527 #else
528                 if (robot_num != -1)
529                         show_spinning_robot_frame(robot_num);
530 #endif
531                 start_time = timer_get_fixed_seconds();
532
533 WIN(DDGRLOCK(dd_grd_curcanv));
534         //      Erase cursor
535         if (cursor_flag && delay) {
536                 gr_set_fontcolor(Erase_color, -1);
537                 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
538         }
539
540         //      Draw the character
541         gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
542         gr_printf(Briefing_text_x, Briefing_text_y, message );
543
544         gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
545         gr_printf(Briefing_text_x+1, Briefing_text_y, message );
546 WIN(DDGRUNLOCK(dd_grd_curcanv));
547
548 //      if (the_char != ' ')
549 //              if (!digi_is_sound_playing(SOUND_MARKER_HIT))
550 //                      digi_play_sample( SOUND_MARKER_HIT, F1_0 );
551
552         return w;
553 }
554
555 //      -----------------------------------------------------------------------------
556 int load_briefing_screen( int screen_num )
557 {
558         int     pcx_error;
559
560         WIN(DDGRLOCK(dd_grd_curcanv));
561       if ((pcx_error=pcx_read_bitmap( CurBriefScreenName, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE)     {
562                 printf( "File '%s', PCX load error: %s\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error));
563                 printf( "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error);
564                 WIN(DDGRUNLOCK(dd_grd_curcanv));
565                 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
566         }
567         WIN(DDGRUNLOCK(dd_grd_curcanv));
568
569         WIN(DDGRRESTORE);
570
571         return 0;
572 }
573
574 int load_new_briefing_screen( char *fname )
575 {
576         int     pcx_error;
577
578    mprintf ((0,"Loading new briefing %s!\n",fname));
579    strcpy (CurBriefScreenName,fname);
580
581 // WIN(DEFINE_SCREEN(CurBriefScreenName));
582
583         if (gr_palette_fade_out( New_pal, 32, 0 ))      
584                 return 0;
585
586 WIN(DDGRLOCK(dd_grd_curcanv));
587    if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE)     {
588                 printf( "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n",fname, pcx_errormsg(pcx_error), pcx_error);
589                         WIN(DDGRUNLOCK(dd_grd_curcanv));
590                 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
591         }
592 WIN(DDGRUNLOCK(dd_grd_curcanv));
593
594 WIN(DDGRRESTORE);
595
596         gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
597
598         if (gr_palette_fade_in( New_pal, 32, 0 ))       
599                 return 0;
600    DoBriefingColorStuff();
601
602         return 1;
603 }
604
605
606
607 #define KEY_DELAY_DEFAULT       ((F1_0*20)/1000)
608
609 //      -----------------------------------------------------------------------------
610 int get_message_num(char **message)
611 {
612         int     num=0;
613
614         while (**message == ' ')
615                 (*message)++;
616
617         while ((**message >= '0') && (**message <= '9')) {
618                 num = 10*num + **message-'0';
619                 (*message)++;
620         }
621
622         while (*(*message)++ != 10)             //      Get and drop eoln
623                 ;
624
625         return num;
626 }
627
628 //      -----------------------------------------------------------------------------
629 void get_message_name(char **message, char *result)
630 {
631         while (**message == ' ')
632                 (*message)++;
633
634         while ((**message != ' ') && (**message != 10)) {
635                 if (**message != '\n')
636                         *result++ = **message;
637                 (*message)++;
638         }
639
640         if (**message != 10)
641                 while (*(*message)++ != 10)             //      Get and drop eoln
642                         ;
643
644         *result = 0;
645 }
646
647 //      -----------------------------------------------------------------------------
648 void flash_cursor(int cursor_flag)
649 {
650         if (cursor_flag == 0)
651                 return;
652
653 WIN(DDGRLOCK(dd_grd_curcanv));
654         if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
655                 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
656         else
657                 gr_set_fontcolor(Erase_color, -1);
658
659         gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
660 WIN(DDGRUNLOCK(dd_grd_curcanv));
661 }
662
663 extern int InitMovieBriefing();
664
665 //      -----------------------------------------------------------------------------
666 //      Return true if message got aborted by user (pressed ESC), else return false.
667 int show_briefing_message(int screen_num, char *message)
668 {
669         int     prev_ch=-1;
670         int     ch, done=0,i;
671         briefing_screen *bsp = &Briefing_screens[screen_num];
672         int     delay_count = KEY_DELAY_DEFAULT;
673         int     key_check;
674         int     robot_num=-1;
675         int     rval=0;
676         static int tab_stop=0;
677         int     flashing_cursor=0;
678         int     new_page=0,GotZ=0;
679 #ifdef ROBOT_MOVIES
680         char *spinRobotName="rba.mve",kludge;  // matt don't change this!  
681 #endif
682         char fname[15];
683    char DumbAdjust=0;
684         char chattering=0;
685         int hum_channel=-1,printing_channel=-1;
686         int LineAdjustment=0;   
687         WIN(int wpage_done=0);
688
689         Bitmap_name[0] = 0;
690         Current_color = 0;
691 #ifdef ROBOT_MOVIES
692         RobotPlaying=0;
693
694         InitMovieBriefing();
695 #endif
696
697         #ifndef SHAREWARE
698         hum_channel  = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
699         #endif
700  
701         // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
702         gr_set_curfont( GAME_FONT );
703
704    bsp=&Briefing_screens[0];
705    init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
706
707         while (!done) {
708                 ch = *message++;
709                 if (ch == '$') {
710                         ch = *message++;
711               if (ch=='D')
712                {
713                       screen_num=DefineBriefingBox (&message);
714                         //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
715                                 
716            bsp = &Briefing_screens[screen_num];
717             init_char_pos(bsp->text_ulx, bsp->text_uly);
718                                 LineAdjustment=0;
719             prev_ch = 10;                                     //      read to eoln
720           }
721          else if (ch=='U')
722           {
723                 screen_num=get_message_num(&message);
724            bsp = &Briefing_screens[screen_num];
725            init_char_pos(bsp->text_ulx, bsp->text_uly);
726            prev_ch = 10;                                                   //      read to eoln
727           }
728                        
729          else if (ch == 'C') {
730                                 Current_color = get_message_num(&message)-1;
731                                 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
732                                 prev_ch = 10;
733                         } else if (ch == 'F') {         //      toggle flashing cursor
734                                 flashing_cursor = !flashing_cursor;
735                                 prev_ch = 10;
736                                 while (*message++ != 10)
737                                         ;
738                         } else if (ch == 'T') {
739                                 tab_stop = get_message_num(&message);
740                                 tab_stop*=(1+MenuHires);
741                                 prev_ch = 10;                                                   //      read to eoln
742                         } else if (ch == 'R') {
743                                 if (Robot_canv != NULL) {
744                                         d_free(Robot_canv); 
745                                         Robot_canv=NULL;
746                                 }
747 #ifdef ROBOT_MOVIES
748                                 if (RobotPlaying) {
749                                         DeInitRobotMovie();
750                                         RobotPlaying=0;
751                                 }
752                                 
753                                 kludge=*message++;
754                                 spinRobotName[2]=kludge; // ugly but proud
755
756                                 RobotPlaying=InitRobotMovie(spinRobotName);
757
758                                 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
759
760                                 if (RobotPlaying) {                     
761                                         DoBriefingColorStuff ();
762                                         mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
763                                 }
764 #else
765                                 init_spinning_robot();
766                                 robot_num = get_message_num(&message);
767 #endif
768             prev_ch = 10;                                                       //      read to eoln
769                         } else if (ch == 'N') {
770                                 //--grs_bitmap  *bitmap_ptr;
771                                 if (Robot_canv != NULL)
772                                         {d_free(Robot_canv); Robot_canv=NULL;}
773
774                                 get_message_name(&message, Bitmap_name);
775                                 strcat(Bitmap_name, "#0");
776                                 Animating_bitmap_type = 0;
777                                 prev_ch = 10;
778                         } else if (ch == 'O') {
779                                 if (Robot_canv != NULL)
780                                         {d_free(Robot_canv); Robot_canv=NULL;}
781
782                                 get_message_name(&message, Bitmap_name);
783                                 strcat(Bitmap_name, "#0");
784                                 Animating_bitmap_type = 1;
785                                 prev_ch = 10;
786                         } else if (ch=='A') {
787                                 LineAdjustment=1-LineAdjustment;
788                         } else if (ch=='Z') {
789                                 mprintf ((0,"Got a Z!\n"));
790                                 GotZ=1;
791                                 #if defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
792                                         DumbAdjust=1;
793                                 #else
794                                         if (LineAdjustment==1)
795                                                 DumbAdjust=1;
796                                         else
797                                                 DumbAdjust=2;
798                                 #endif
799         
800                                 i=0;
801                                 while ((fname[i]=*message) != '\n') {
802                                         i++;
803                                         message++;
804                                 }
805                                 fname[i]=0;
806   
807                                 if (MenuHires)
808                                  {
809                                    i=0; 
810                                    while (fname[i]!='.')
811                                         i++;
812 #ifndef SHAREWARE
813                                    fname[i++]='b';
814 #endif
815                                    fname[i++]='.';      
816                                    fname[i++]='p';      
817                                    fname[i++]='c';      
818                                    fname[i++]='x';      
819                                    fname[i++]=0;        
820
821                                    load_new_briefing_screen (fname);
822                                  }
823                                 else
824                                    load_new_briefing_screen (fname);
825
826                                 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");        
827
828                         } else if (ch == 'B') {
829                                 char                    bitmap_name[32];
830                                 grs_bitmap      guy_bitmap;
831                                 ubyte                   temp_palette[768];
832                                 int                     iff_error;
833
834                                 if (Robot_canv != NULL)
835                                         {d_free(Robot_canv); Robot_canv=NULL;}
836
837                                 get_message_name(&message, bitmap_name);
838                                 strcat(bitmap_name, ".bbm");
839                                 guy_bitmap.bm_data = NULL;
840                                 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
841                                 Assert(iff_error == IFF_NO_ERROR);
842                                 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
843
844                                 show_briefing_bitmap(&guy_bitmap);
845                                 d_free(guy_bitmap.bm_data);
846                                 prev_ch = 10;
847 //                 } else if (ch==EOF) {
848 //                              done=1;
849 //                      } else if (ch == 'B') {
850 //                              if (Robot_canv != NULL)
851 //                                      {d_free(Robot_canv); Robot_canv=NULL;}
852 //
853 //                              bitmap_num = get_message_num(&message);
854 //                              if (bitmap_num != -1)
855 //                                      show_briefing_bitmap(Textures[bitmap_num]);
856 //                              prev_ch = 10;                                                   //      read to eoln
857                         } else if (ch == 'S') {
858                                 int     keypress;
859                                 fix     start_time;
860                         
861                                 chattering=0;
862                                 if (printing_channel>-1)
863                                    digi_stop_sound( printing_channel );
864                                 printing_channel=-1;
865
866                         #ifdef WINDOWS
867                                 if (!wpage_done) {
868                                         DDGRRESTORE;
869                                         wpage_done =1;
870                                 }
871                         #endif
872
873                                 start_time = timer_get_fixed_seconds();
874                                 while ( (keypress = local_key_inkey()) == 0 ) {         //      Wait for a key
875                                 #ifdef WINDOWS
876                                         if (_RedrawScreen) {
877                                                 _RedrawScreen = FALSE;
878                                                 hum_channel  = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
879                                                 keypress = KEY_ESC;
880                                                 break;
881                                         }
882                                 #endif
883
884                                         while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
885                                                 ;
886                                         flash_cursor(flashing_cursor);
887
888 #ifdef ROBOT_MOVIES
889                                         if (RobotPlaying)       RotateRobot ();
890 #else
891                                         show_spinning_robot_frame(robot_num);
892 #endif
893
894                                         show_bitmap_frame();
895                                         start_time += KEY_DELAY_DEFAULT/2;
896                                 }
897
898 #ifndef NDEBUG
899                                 if (keypress == KEY_BACKSP)
900                                         Int3();
901 #endif
902                                 if (keypress == KEY_ESC)
903                                         rval = 1;
904
905                                 flashing_cursor = 0;
906                                 done = 1;
907                                 WIN(wpage_done = 0);
908                         } else if (ch == 'P') {         //      New page.
909                                 if (!GotZ)
910                                  {
911                                          Int3(); // Hey ryan!!!! You gotta load a screen before you start 
912                                                                 // printing to it! You know, $Z !!!
913                                     load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
914                                  }
915                                                                         
916                 
917                                 new_page = 1;
918                                 while (*message != 10) {
919                                         message++;      //      drop carriage return after special escape sequence
920                                 }
921                                 message++;
922                                 prev_ch = 10;
923                         }
924                 } else if (ch == '\t') {                //      Tab
925                         if (Briefing_text_x - bsp->text_ulx < tab_stop)
926                                 Briefing_text_x = bsp->text_ulx + tab_stop;
927                 } else if ((ch == ';') && (prev_ch == 10)) {
928                         while (*message++ != 10)
929                                 ;
930                         prev_ch = 10;
931                 } else if (ch == '\\') {
932                         prev_ch = ch;
933                 } else if (ch == 10) {
934                         if (prev_ch != '\\') {
935                                 prev_ch = ch;
936                                 if (DumbAdjust==0)
937                                         Briefing_text_y += (8*(MenuHires+1));
938                                 else
939                                         DumbAdjust--;
940                                 Briefing_text_x = bsp->text_ulx;
941                                 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
942                                         load_briefing_screen(screen_num);
943                                         Briefing_text_x = bsp->text_ulx;
944                                         Briefing_text_y = bsp->text_uly;
945                                 }
946                         } else {
947                                 if (ch == 13)           //Can this happen? Above says ch==10
948                                         Int3();
949                                 prev_ch = ch;
950                         }
951
952                 } else {
953                         if (!GotZ)
954                          {
955                                  Int3(); // Hey ryan!!!! You gotta load a screen before you start 
956                                                         // printing to it! You know, $Z !!!
957                                  load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
958                          }
959                                  
960                         prev_ch = ch;
961
962          if (!chattering)
963                          {
964                                 printing_channel  = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
965                            chattering=1;
966                          }
967                 
968                         WIN(if (GRMODEINFO(emul)) delay_count = 0);
969
970                         Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
971
972                 }
973
974                 //      Check for Esc -> abort.
975                 key_check = local_key_inkey();
976
977         #ifdef WINDOWS
978                 if (_RedrawScreen) {
979                         _RedrawScreen = FALSE;
980                         hum_channel  = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
981                         key_check = KEY_ESC;
982                 }
983         #endif
984                 if ( key_check == KEY_ESC ) {
985                         rval = 1;
986                         done = 1;
987                 }
988
989                 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
990                         delay_count = 0;
991
992                 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
993                         Briefing_text_x = bsp->text_ulx;
994                         Briefing_text_y += bsp->text_uly;
995                 }
996
997                 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
998                         fix     start_time = 0;
999                         int     keypress;
1000
1001                         new_page = 0;
1002
1003                         if (printing_channel>-1)
1004                            digi_stop_sound( printing_channel );
1005                         printing_channel=-1;
1006                         
1007                         chattering=0;
1008
1009                         #ifdef WINDOWS
1010                                 if (!wpage_done) {
1011                                         DDGRRESTORE;
1012                                         wpage_done =1;
1013                                 }
1014                         #endif
1015
1016                         start_time = timer_get_fixed_seconds();
1017                         while ( (keypress = local_key_inkey()) == 0 ) {         //      Wait for a key
1018                         #ifdef WINDOWS
1019                                 if (_RedrawScreen) {
1020                                         _RedrawScreen = FALSE;
1021                                         hum_channel  = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1022                                         keypress = KEY_ESC;
1023                                         break;
1024                                 }
1025                         #endif
1026
1027                                 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1028                                         ;
1029                                 flash_cursor(flashing_cursor);
1030 #ifdef ROBOT_MOVIES
1031                                 if (RobotPlaying) RotateRobot();
1032 #else
1033                                 show_spinning_robot_frame(robot_num);
1034 #endif
1035                                 show_bitmap_frame();
1036                                 start_time += KEY_DELAY_DEFAULT/2;
1037                         }
1038
1039 #ifdef ROBOT_MOVIES
1040                         if (RobotPlaying) DeInitRobotMovie();
1041                         RobotPlaying=0;
1042 #endif
1043                         robot_num = -1;
1044
1045 #ifndef NDEBUG
1046                         if (keypress == KEY_BACKSP)
1047                                 Int3();
1048 #endif
1049                         if (keypress == KEY_ESC) {
1050                                 rval = 1;
1051                                 done = 1;
1052                         }
1053
1054                         load_briefing_screen(screen_num);
1055                         Briefing_text_x = bsp->text_ulx;
1056                         Briefing_text_y = bsp->text_uly;
1057          delay_count = KEY_DELAY_DEFAULT;
1058
1059                         WIN(wpage_done = 0);
1060                 }
1061         }
1062
1063 #ifdef ROBOT_MOVIES
1064         if (RobotPlaying) {
1065                 DeInitRobotMovie();
1066                 RobotPlaying=0;
1067         }
1068 #endif
1069
1070         if (Robot_canv != NULL)
1071                 {d_free(Robot_canv); Robot_canv=NULL;}
1072
1073         if (hum_channel>-1)
1074                 digi_stop_sound( hum_channel );
1075         if (printing_channel>-1)
1076            digi_stop_sound( printing_channel );
1077
1078         return rval;
1079 }
1080
1081 //      -----------------------------------------------------------------------------
1082 //      Return a pointer to the start of text for screen #screen_num.
1083 char * get_briefing_message(int screen_num)
1084 {
1085         char    *tptr = Briefing_text;
1086         int     cur_screen=0;
1087         int     ch;
1088
1089         Assert(screen_num >= 0);
1090
1091         while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1092                 ch = *tptr++;
1093                 if (ch == '$') {
1094                         ch = *tptr++;
1095                         if (ch == 'S')
1096                                 cur_screen = get_message_num(&tptr);
1097                 }
1098         }
1099
1100    if (screen_num!=cur_screen)
1101          return (NULL);
1102   
1103         return tptr;
1104 }
1105
1106 // -----------------------------------------------------------------------------
1107 //      Load Descent briefing text.
1108 int load_screen_text(char *filename, char **buf)
1109 {
1110         CFILE   *tfile;
1111         CFILE *ifile;
1112         int     len, i,x;
1113         int     have_binary = 0;
1114
1115         if ((tfile = cfopen(filename,"rb")) == NULL) {
1116                 char nfilename[30], *ptr;
1117
1118                 strcpy(nfilename, filename);
1119                 ptr = strrchr(nfilename, '.');
1120                 *ptr = '\0';
1121                 strcat(nfilename, ".txb");
1122                 if ((ifile = cfopen(nfilename, "rb")) == NULL)
1123                 { 
1124                         mprintf ((0,"can't open %s!\n",nfilename));
1125                         return (0); 
1126                         //Error("Cannot open file %s or %s", filename, nfilename); 
1127                 }       
1128    
1129                 mprintf ((0,"reading...\n"));
1130                 have_binary = 1;
1131
1132                 len = cfilelength(ifile);
1133                 MALLOC(*buf, char, len+500); 
1134       mprintf ((0,"len=%d\n",len));
1135                 for (x=0,i=0;i<len;i++,x++)
1136                  {
1137              cfread (*buf+x,1,1,ifile);
1138                 //  mprintf ((0,"%c",*(*buf+x)));
1139                   if (*(*buf+x)==13)
1140                         x--;
1141        }
1142       
1143                 cfclose(ifile);
1144         } else {
1145                 len = cfilelength(tfile);
1146                 MALLOC(*buf, char, len+500); 
1147                 for (x=0,i=0;i<len;i++,x++)
1148                  {
1149              cfread (*buf+x,1,1,tfile);
1150                  // mprintf ((0,"%c",*(*buf+x)));
1151                   if (*(*buf+x)==13)
1152                         x--;
1153        }
1154           
1155       
1156                 //cfread(*buf, 1, len, tfile);
1157                 cfclose(tfile);
1158         }
1159
1160         if (have_binary) {
1161                 char *ptr;
1162
1163                 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1164                         if (*ptr != '\n') {
1165                                 encode_rotate_left(ptr);
1166                                 *ptr = *ptr ^ BITMAP_TBL_XOR;
1167                                 encode_rotate_left(ptr);
1168                         }
1169                 }
1170         }
1171
1172  return (1);
1173 }
1174
1175 //      -----------------------------------------------------------------------------
1176 //      Return true if message got aborted, else return false.
1177 int show_briefing_text(int screen_num)
1178 {
1179         char    *message_ptr;
1180
1181    message_ptr = get_briefing_message(screen_num);
1182    if (message_ptr==NULL)
1183          return (0);
1184     
1185    DoBriefingColorStuff();
1186
1187         return show_briefing_message(screen_num, message_ptr);
1188 }
1189 void DoBriefingColorStuff ()
1190  {
1191    Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1192    Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1193
1194    Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1195    Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1196
1197    Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1198    Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1199
1200    Erase_color = gr_find_closest_color_current(0, 0, 0);
1201  } 
1202
1203 //      -----------------------------------------------------------------------------
1204 //      Return true if screen got aborted by user, else return false.
1205 int show_briefing_screen( int screen_num, int allow_keys)
1206 {
1207         int     rval=0;
1208         ubyte   palette_save[768];
1209
1210         New_pal_254_bash = 0;
1211
1212         if (Skip_briefing_screens) {
1213         mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1214                 return 0;
1215         }
1216
1217 //      briefing_bm.bm_data=NULL;       
1218 //   if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE)     {
1219 //        mprintf((0, "File '%s', PCX load error: %s (%i)\n  (It's a briefing screen.  Does this cause you pain?)\n","Brief03.pcx", pcx_errormsg(pcx_error), pcx_error));
1220 //              Int3();
1221 //              return 0;
1222 //      }
1223
1224         memcpy(palette_save,gr_palette,sizeof(palette_save));
1225         memcpy(New_pal,gr_palette,sizeof(gr_palette));
1226    
1227
1228 //      vfx_set_palette_sub( New_pal );
1229 //      gr_palette_clear();
1230 //      gr_bitmap( 0, 0, &briefing_bm );
1231 #ifdef OGL
1232         gr_palette_load(New_pal);
1233 #endif
1234
1235 //      if (gr_palette_fade_in( New_pal, 32, allow_keys ))      
1236 //              return 1;
1237 //      memcpy(gr_palette,New_pal,sizeof(gr_palette));
1238
1239         #ifdef MACINTOSH
1240         key_close();            // kill the keyboard handler during briefing screens for movies
1241         #endif
1242         rval = show_briefing_text(screen_num);
1243         #ifdef MACINTOSH
1244         key_init();
1245         #endif
1246         
1247         #if defined (MACINTOSH) || defined(WINDOWS)
1248         memcpy(New_pal,gr_palette,sizeof(gr_palette));          // attempt to get fades after briefing screens done correctly.
1249         #endif
1250
1251
1252         #ifndef WINDOWS 
1253         if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1254                 return 1;
1255    #else
1256                 DEFINE_SCREEN(NULL);
1257                 WIN(DDGRLOCK(dd_grd_curcanv));
1258                 gr_clear_canvas (0);
1259                 WIN(DDGRUNLOCK(dd_grd_curcanv));
1260                 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1261                         return 1;
1262         #endif
1263
1264         gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1265
1266 //      d_free(briefing_bm.bm_data);
1267
1268         return rval;
1269 }
1270
1271
1272 //      -----------------------------------------------------------------------------
1273 void do_briefing_screens(char *filename,int level_num)
1274 {
1275
1276    MVEPaletteCalls=0;
1277
1278         if (Skip_briefing_screens) {
1279                 mprintf((0, "Skipping all briefing screens.\n"));
1280                 return;
1281         }
1282         
1283         #ifdef APPLE_DEMO
1284         return;                 // no briefing screens at all for demo
1285         #endif
1286
1287         mprintf ((0,"Trying briefing screen! %s\n",filename));
1288
1289         if (!filename)
1290                 return;
1291
1292         if (!load_screen_text(filename, &Briefing_text))
1293          return;
1294
1295         #ifdef SHAREWARE
1296         songs_play_song( SONG_BRIEFING, 1 );
1297         #else
1298         songs_stop_all();
1299         #endif
1300
1301         set_screen_mode( SCREEN_MENU );
1302         
1303         WINDOS(
1304                 dd_gr_set_current_canvas(NULL),
1305                 gr_set_current_canvas(NULL)
1306         );
1307
1308         mprintf ((0,"Playing briefing screen! %s %d\n",filename,level_num));
1309
1310         key_flush();
1311         
1312         show_briefing_screen(level_num,0);
1313
1314         d_free (Briefing_text);
1315         key_flush();
1316
1317         return;
1318
1319 }
1320
1321 int DefineBriefingBox (char **buf)
1322  {
1323   int n,i=0;
1324   char name[20];
1325
1326   n=get_new_message_num (buf);
1327
1328         Assert(n < MAX_BRIEFING_SCREENS);
1329
1330   while (**buf!=' ')
1331    {
1332     name[i++]=**buf;
1333     (*buf)++;
1334    }
1335
1336   name[i]='\0';   // slap a delimiter on this guy
1337
1338   strcpy (Briefing_screens[n].bs_name,name);
1339   Briefing_screens[n].level_num=get_new_message_num (buf);
1340   Briefing_screens[n].message_num=get_new_message_num (buf);
1341   Briefing_screens[n].text_ulx=get_new_message_num (buf);
1342   Briefing_screens[n].text_uly=get_new_message_num (buf);
1343   Briefing_screens[n].text_width=get_new_message_num (buf);
1344   Briefing_screens[n].text_height=get_message_num (buf);  // NOTICE!!!
1345
1346   if (MenuHires)
1347         {
1348          Briefing_screens[n].text_ulx*=2;
1349          Briefing_screens[n].text_uly*=2.4;
1350          Briefing_screens[n].text_width*=2;
1351          Briefing_screens[n].text_height*=2.4;
1352         }
1353  
1354   return (n);
1355  }
1356
1357 int get_new_message_num(char **message)
1358 {
1359         int     num=0;
1360
1361         while (**message == ' ')
1362                 (*message)++;
1363
1364         while ((**message >= '0') && (**message <= '9')) {
1365                 num = 10*num + **message-'0';
1366                 (*message)++;
1367         }
1368
1369        (*message)++;
1370
1371         return num;
1372 }
1373