1 /* $Id: titles.c,v 1.27 2003-11-07 06:30:06 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Routines to display title screens...
20 * Revision 1.13 1995/11/03 12:52:23 allender
23 * Revision 1.12 1995/10/31 10:17:56 allender
26 * Revision 1.11 1995/10/24 18:12:02 allender
27 * don't do special processing on do_appl_quit anymore
29 * Revision 1.10 1995/10/21 22:25:02 allender
30 * added bald guy cheat
32 * Revision 1.9 1995/10/17 13:14:30 allender
33 * mouse will now move through title stuff
35 * Revision 1.8 1995/10/15 23:00:34 allender
36 * made mouse move through screens and do event processing
39 * Revision 1.7 1995/10/10 11:52:10 allender
40 * use appropriate end01 file for registered
42 * Revision 1.6 1995/09/24 10:53:09 allender
43 * added cmd-q to quit during titles screens and briefing screens
45 * Revision 1.5 1995/08/25 15:39:37 allender
46 * save and resotre interpolation method during briefing screens
48 * Revision 1.4 1995/08/24 16:10:57 allender
49 * endgame screen changes, and fixups to other stuff
51 * Revision 1.3 1995/08/14 14:40:37 allender
52 * fixed up briefing screens to look correct.
53 * made robot canvas smaller for now for speec
55 * Revision 1.2 1995/06/13 13:07:05 allender
56 * do a bitblt during tight loops to get spinning robots and cursor flashing
58 * Revision 1.1 1995/05/16 15:31:52 allender
61 * Revision 2.10 1995/06/15 12:14:16 john
62 * Made end game, win game and title sequences all go
63 * on after 5 minutes automatically.
65 * Revision 2.9 1995/06/14 17:25:48 john
66 * Fixed bug with VFX palette not getting loaded for credits, titles.
68 * Revision 2.8 1995/05/26 16:16:30 john
69 * Split SATURN into define's for requiring cd, using cd, etc.
70 * Also started adding all the Rockwell stuff.
72 * Revision 2.7 1995/03/24 13:11:36 john
73 * Added save game during briefing screens.
75 * Revision 2.6 1995/03/21 14:41:17 john
76 * Ifdef'd out the NETWORK code.
78 * Revision 2.5 1995/03/15 14:33:45 john
79 * Added code to force the Descent CD-rom in the drive.
81 * Revision 2.4 1995/03/14 18:24:50 john
82 * Force Destination Saturn to use CD-ROM drive.
84 * Revision 2.3 1995/03/10 13:05:52 john
85 * Added code so that palette is correct for VFX1 helmets.
87 * Revision 2.2 1995/03/07 14:19:28 mike
88 * More destination saturn stuff.
90 * Revision 2.1 1995/03/06 15:24:16 john
91 * New screen techniques.
93 * Revision 2.0 1995/02/27 11:32:50 john
94 * New version 2.0, which has no anonymous unions, builds with
95 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
97 * Revision 1.95 1995/02/12 04:07:19 matt
98 * After freeing Robot_canv, set ptr to NULL
100 * Revision 1.94 1995/02/11 12:41:57 john
101 * Added new song method, with FM bank switching..
103 * Revision 1.93 1995/02/11 09:51:59 john
104 * Stripped out all SVGA references.
106 * Revision 1.92 1995/02/07 09:56:10 john
107 * Fixed bug with wrong title screen drawing during save btwn lvls.
109 * Revision 1.91 1995/02/04 13:53:16 john
110 * Added code to display the correct titles between levels
111 * that have robot maps..
113 * Revision 1.90 1995/02/02 16:36:33 adam
114 * *** empty log message ***
116 * Revision 1.89 1995/02/02 12:23:30 john
117 * Made between level saves have picture.
119 * Revision 1.88 1995/02/02 01:50:16 adam
120 * rearranged robot briefings.
122 * Revision 1.87 1995/02/01 22:28:54 mike
123 * *** empty log message ***
125 * Revision 1.86 1995/02/01 17:12:21 mike
126 * Make score come after endgame screens.
128 * Revision 1.85 1995/02/01 14:04:17 adam
129 * mucked with screens
131 * Revision 1.84 1995/01/28 16:59:30 adam
132 * added hook for special first briefing music
134 * Revision 1.83 1995/01/21 17:04:35 mike
135 * fix endgame text bogosity.
137 * Revision 1.82 1995/01/21 16:26:29 matt
138 * Made endlevel briefing work with missions
140 * Revision 1.81 1995/01/21 13:15:20 adam
141 * added new robot briefings.
143 * Revision 1.80 1995/01/20 22:47:33 matt
144 * Mission system implemented, though imcompletely
146 * Revision 1.79 1995/01/20 14:57:52 mike
147 * support arbitrary number of screens/level.
149 * Revision 1.78 1995/01/15 14:29:12 john
150 * Made the exit door page in.
152 * Revision 1.77 1995/01/15 14:27:09 adam
153 * messed with endgame stuff
155 * Revision 1.76 1995/01/14 15:42:49 mike
156 * Make endgame for registered support 3 screens.
158 * Revision 1.75 1995/01/14 14:00:59 adam
159 * *** empty log message ***
161 * Revision 1.74 1995/01/09 11:28:53 mike
162 * Support new $O thingy for bitmaps which cycle and are not the exit door.
164 * Revision 1.73 1995/01/02 12:39:13 mike
165 * fix secret level sequencing.
167 * Revision 1.72 1994/12/12 19:44:14 rob
168 * Added kill matrix to end of game sequence.
170 * Revision 1.71 1994/12/09 22:32:57 adam
171 * messed with text positioning
173 * Revision 1.70 1994/12/09 14:08:37 mike
174 * make briefing text work with hog files.
176 * Revision 1.69 1994/12/09 00:41:47 mike
177 * fix hang in automap print screen.
179 * Revision 1.68 1994/12/08 20:56:36 john
182 * Revision 1.67 1994/12/08 17:19:11 yuan
185 * Revision 1.66 1994/12/07 11:28:00 matt
186 * Did a localization suppport
188 * Revision 1.65 1994/12/06 17:10:23 yuan
191 * Revision 1.64 1994/12/06 17:00:45 rob
192 * Fixed problem with finishing the game in modem/serial mode.
194 * Revision 1.63 1994/12/06 16:58:37 matt
197 * Revision 1.62 1994/12/06 15:54:28 mike
218 #include "pa_enabl.h" //$$POLY_ACC
229 #include "gamefont.h"
233 #include "textures.h"
248 #if defined(POLY_ACC)
249 #include "poly_acc.h"
253 void DoBriefingColorStuff ();
254 int get_new_message_num(char **message);
255 int DefineBriefingBox (char **buf);
257 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
260 int New_pal_254_bash;
262 char CurBriefScreenName[15]="brief03.pcx";
263 char * Briefing_text;
266 //Begin D1X modification
267 #define MAX_BRIEFING_COLORS 7
268 //End D1X modification
270 // Descent 1 briefings
271 char Ending_text_filename[13] = "endreg.txt";
272 char Briefing_text_filename[13] = "briefing.txt";
274 #define SHAREWARE_ENDING_FILENAME "ending.tex"
276 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
277 int Skip_briefing_screens=0;
278 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
279 int Current_color = 0;
282 extern int check_button_press();
285 extern void macintosh_quit(void);
288 // added by Jan Bobrowski for variable-size menu screen
289 static int rescale_x(int x)
291 return x * GWIDTH / 320;
294 static int rescale_y(int y)
296 return y * GHEIGHT / 200;
300 int local_key_inkey(void)
307 DoMessageStuff(&msg);
312 if (rval == KEY_PRINT_SCREEN) {
315 gr_palette_read(gr_palette);
316 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
320 return 0; //say no key pressed
323 if (check_button_press()) //joystick or mouse button pressed?
327 if ( rval == KEY_Q+KEY_COMMAND )
334 int local_key_inkey(void)
339 if (!GetOSEvent(everyEvent, &event))
342 if (event.what != keyDown)
345 rval = (int)((event.message & keyCodeMask) >> 8);
347 if (rval == KEY_PRINT_SCREEN) {
349 return 0; //say no key pressed
352 if (check_button_press()) //joystick or mouse button pressed?
356 if ( rval == KEY_Q+KEY_COMMAND )
364 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
369 ubyte palette_save[768];
370 char new_filename[FILENAME_LEN+1] = "";
374 strcpy(new_filename,"\x01"); //only read from hog file
377 strcat(new_filename,filename);
378 filename = new_filename;
380 title_bm.bm_data=NULL;
381 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
382 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
383 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));
384 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
387 memcpy(palette_save,gr_palette,sizeof(palette_save));
389 #if defined(POLY_ACC)
391 pa_update_clut(New_pal, 0, 256, 0);
394 //vfx_set_palette_sub( New_pal );
396 gr_palette_load( New_pal );
402 dd_gr_set_current_canvas(NULL),
403 gr_set_current_canvas( NULL )
405 WIN(DDGRLOCK(dd_grd_curcanv));
406 show_fullscr(&title_bm);
407 WIN(DDGRUNLOCK(dd_grd_curcanv));
411 #if defined(POLY_ACC)
415 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
417 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
419 gr_palette_load( New_pal );
420 timer = timer_get_fixed_seconds() + i2f(3);
422 if ( local_key_inkey() && allow_keys ) break;
423 if ( timer_get_fixed_seconds() > timer ) break;
425 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
427 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
428 d_free(title_bm.bm_data);
433 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
436 short text_ulx, text_uly; // upper left x,y of text window
437 short text_width, text_height; // width and height of text window
440 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
441 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
443 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
444 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
447 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
449 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
452 #define MAX_BRIEFING_SCREENS 60
455 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
456 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
458 briefing_screen Briefing_screens[] = {
459 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
460 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
461 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
462 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
464 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
465 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
466 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
468 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
469 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
471 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
472 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
473 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
476 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
477 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
478 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
479 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
480 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
482 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
483 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
484 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
485 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
486 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
488 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
489 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
490 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
491 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
492 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
494 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
495 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
496 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
497 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
499 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
500 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
501 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
503 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
504 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
505 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
507 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
508 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
509 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
512 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
514 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
515 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
516 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
523 int Briefing_text_x, Briefing_text_y;
525 void init_char_pos(int x, int y)
529 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
532 grs_canvas *Robot_canv = NULL;
533 vms_angvec Robot_angles;
535 char Bitmap_name[32] = "";
536 #define EXIT_DOOR_MAX 14
537 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
538 #define DOOR_DIV_INIT 6
539 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
541 //-----------------------------------------------------------------------------
542 void show_bitmap_frame(void)
545 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
547 grs_canvas *curcanv_save, *bitmap_canv=0;
550 grs_bitmap *bitmap_ptr;
552 // Only plot every nth frame.
553 if (Door_div_count) {
558 Door_div_count = DOOR_DIV_INIT;
560 if (Bitmap_name[0] != 0) {
564 // Set supertransparency color to black
565 if (!New_pal_254_bash) {
566 New_pal_254_bash = 1;
568 New_pal[254*3+1] = 0;
569 New_pal[254*3+2] = 0;
570 gr_palette_load( New_pal );
573 switch (Animating_bitmap_type) {
575 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
576 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
580 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
581 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
584 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
586 Int3(); // Impossible, illegal value for Animating_bitmap_type
590 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
591 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
594 pound_signp = strchr(Bitmap_name, '#');
595 Assert(pound_signp != NULL);
597 dig1 = *(pound_signp+1);
598 dig2 = *(pound_signp+2);
602 num = (dig1-'0')*10 + (dig2-'0');
604 switch (Animating_bitmap_type) {
607 if (num > EXIT_DOOR_MAX) {
610 } else if (num < 0) {
617 if (num > OTHER_THING_MAX)
624 *(pound_signp+1) = (num / 10) + '0';
625 *(pound_signp+2) = (num % 10) + '0';
626 *(pound_signp+3) = 0;
628 *(pound_signp+1) = (num % 10) + '0';
629 *(pound_signp+2) = 0;
634 bi = piggy_find_bitmap(Bitmap_name);
635 bitmap_ptr = &GameBitmaps[bi.index];
639 WIN(DDGRLOCK(dd_grd_curcanv));
640 gr_bitmapm(0, 0, bitmap_ptr);
641 WIN(DDGRUNLOCK(dd_grd_curcanv));
644 dd_grd_curcanv = curcanv_save,
645 grd_curcanv = curcanv_save
649 switch (Animating_bitmap_type) {
651 if (num == EXIT_DOOR_MAX) {
654 } else if (num == 0) {
666 //-----------------------------------------------------------------------------
667 void show_briefing_bitmap(grs_bitmap *bmp)
670 dd_grs_canvas *bitmap_canv, *curcanv_save;
672 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
673 curcanv_save = dd_grd_curcanv;
674 dd_gr_set_current_canvas(bitmap_canv);
675 DDGRLOCK(dd_grd_curcanv);
677 DDGRUNLOCK(dd_grd_curcanv);
678 dd_gr_set_current_canvas(curcanv_save);
680 grs_canvas *curcanv_save, *bitmap_canv;
682 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
683 curcanv_save = grd_curcanv;
684 gr_set_current_canvas(bitmap_canv);
685 gr_bitmapm(0, 0, bmp);
686 gr_set_current_canvas(curcanv_save);
693 //-----------------------------------------------------------------------------
694 void show_spinning_robot_frame(int robot_num)
696 grs_canvas *curcanv_save;
698 if (robot_num != -1) {
699 Robot_angles.h += 150;
701 curcanv_save = grd_curcanv;
702 grd_curcanv = Robot_canv;
703 Assert(Robot_info[robot_num].model_num != -1);
704 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
705 grd_curcanv = curcanv_save;
710 //-----------------------------------------------------------------------------
711 void init_spinning_robot(void) //(int x,int y,int w,int h)
713 //Robot_angles.p += 0;
714 //Robot_angles.b += 0;
715 //Robot_angles.h += 0;
717 int x = rescale_x(138);
718 int y = rescale_y(55);
719 int w = rescale_x(166);
720 int h = rescale_y(138);
722 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
727 //---------------------------------------------------------------------------
728 // Returns char width.
729 // If show_robot_flag set, then show a frame of the spinning robot.
730 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
734 static fix start_time=0;
736 message[0] = the_char;
739 if (start_time==0 && timer_get_fixed_seconds()<0)
740 start_time=timer_get_fixed_seconds();
742 gr_get_string_size(message, &w, &h, &aw );
744 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
746 // Draw cursor if there is some delay and caller says to draw cursor
747 if (cursor_flag && delay) {
748 WIN(DDGRLOCK(dd_grd_curcanv));
749 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
750 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
751 WIN(DDGRUNLOCK(dd_grd_curcanv));
756 delay=fixdiv (F1_0,i2f(15));
758 if ((Bitmap_name[0] != 0) && (delay != 0))
761 if (RobotPlaying && (delay != 0))
764 while (timer_get_fixed_seconds() < (start_time + delay)) {
765 if (RobotPlaying && delay != 0)
769 show_spinning_robot_frame(robot_num);
771 start_time = timer_get_fixed_seconds();
773 WIN(DDGRLOCK(dd_grd_curcanv));
775 if (cursor_flag && delay) {
776 gr_set_fontcolor(Erase_color, -1);
777 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
780 // Draw the character
781 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
782 gr_printf(Briefing_text_x, Briefing_text_y, message );
784 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
785 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
786 WIN(DDGRUNLOCK(dd_grd_curcanv));
788 if (delay) gr_update();
790 // if (the_char != ' ')
791 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
792 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
797 //-----------------------------------------------------------------------------
798 int load_briefing_screen( int screen_num )
803 if (Mission_list[Current_mission_num].descent_version == 1)
804 fname = Briefing_screens[screen_num].bs_name;
806 fname = CurBriefScreenName;
808 WIN(DDGRLOCK(dd_grd_curcanv));
809 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
810 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
811 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);
812 WIN(DDGRUNLOCK(dd_grd_curcanv));
813 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
815 WIN(DDGRUNLOCK(dd_grd_curcanv));
822 int load_new_briefing_screen( char *fname )
826 mprintf ((0,"Loading new briefing <%s>\n",fname));
827 strcpy (CurBriefScreenName,fname);
829 //WIN(DEFINE_SCREEN(CurBriefScreenName));
831 if (gr_palette_fade_out( New_pal, 32, 0 ))
834 WIN(DDGRLOCK(dd_grd_curcanv));
835 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
836 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
837 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);
838 WIN(DDGRUNLOCK(dd_grd_curcanv));
839 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
841 WIN(DDGRUNLOCK(dd_grd_curcanv));
845 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
847 if (gr_palette_fade_in( New_pal, 32, 0 ))
849 DoBriefingColorStuff();
856 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
858 //-----------------------------------------------------------------------------
859 int get_message_num(char **message)
863 while (**message == ' ')
866 while ((**message >= '0') && (**message <= '9')) {
867 num = 10*num + **message-'0';
871 while (*(*message)++ != 10) // Get and drop eoln
877 //-----------------------------------------------------------------------------
878 void get_message_name(char **message, char *result)
880 while (**message == ' ')
883 while ((**message != ' ') && (**message != 10)) {
884 if (**message != '\n')
885 *result++ = **message;
890 while (*(*message)++ != 10) // Get and drop eoln
896 //-----------------------------------------------------------------------------
897 void flash_cursor(int cursor_flag)
899 if (cursor_flag == 0)
902 WIN(DDGRLOCK(dd_grd_curcanv));
903 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
904 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
906 gr_set_fontcolor(Erase_color, -1);
908 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
909 WIN(DDGRUNLOCK(dd_grd_curcanv));
913 extern int InitMovieBriefing();
916 //-----------------------------------------------------------------------------
917 // Return true if message got aborted by user (pressed ESC), else return false.
918 int show_briefing_message(int screen_num, char *message)
922 briefing_screen *bsp;
923 int delay_count = KEY_DELAY_DEFAULT;
927 static int tab_stop=0;
928 int flashing_cursor=0;
929 int new_page=0,GotZ=0;
930 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
934 int hum_channel=-1,printing_channel=-1;
935 int LineAdjustment=1;
936 WIN(int wpage_done=0);
945 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
948 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
949 gr_set_curfont( GAME_FONT );
951 if (Mission_list[Current_mission_num].descent_version == 1) {
953 MALLOC(bsp, briefing_screen, 1);
954 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
955 bsp->text_ulx = rescale_x(bsp->text_ulx);
956 bsp->text_uly = rescale_y(bsp->text_uly);
957 bsp->text_width = rescale_x(bsp->text_width);
958 bsp->text_height = rescale_y(bsp->text_height);
959 init_char_pos(bsp->text_ulx, bsp->text_uly);
961 bsp=&Briefing_screens[0];
962 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
970 screen_num=DefineBriefingBox (&message);
971 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
973 bsp = &Briefing_screens[screen_num];
974 init_char_pos(bsp->text_ulx, bsp->text_uly);
976 prev_ch = 10; // read to eoln
977 } else if (ch=='U') {
978 screen_num=get_message_num(&message);
979 bsp = &Briefing_screens[screen_num];
980 init_char_pos(bsp->text_ulx, bsp->text_uly);
981 prev_ch = 10; // read to eoln
982 } else if (ch == 'C') {
983 Current_color = get_message_num(&message)-1;
984 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
986 } else if (ch == 'F') { // toggle flashing cursor
987 flashing_cursor = !flashing_cursor;
989 while (*message++ != 10)
991 } else if (ch == 'T') {
992 tab_stop = get_message_num(&message);
993 tab_stop*=(1+MenuHires);
994 prev_ch = 10; // read to eoln
995 } else if (ch == 'R') {
996 if (Robot_canv != NULL) {
1005 if (Mission_list[Current_mission_num].descent_version == 1) {
1006 init_spinning_robot();
1007 robot_num = get_message_num(&message);
1008 while (*message++ != 10)
1012 spinRobotName[2]=kludge; // ugly but proud
1014 RobotPlaying=InitRobotMovie(spinRobotName);
1016 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
1020 DoBriefingColorStuff ();
1021 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
1024 prev_ch = 10; // read to eoln
1025 } else if (ch == 'N') {
1026 //--grs_bitmap *bitmap_ptr;
1027 if (Robot_canv != NULL) {
1032 get_message_name(&message, Bitmap_name);
1033 strcat(Bitmap_name, "#0");
1034 Animating_bitmap_type = 0;
1036 } else if (ch == 'O') {
1037 if (Robot_canv != NULL) {
1042 get_message_name(&message, Bitmap_name);
1043 strcat(Bitmap_name, "#0");
1044 Animating_bitmap_type = 1;
1046 } else if (ch=='A') {
1047 LineAdjustment=1-LineAdjustment;
1048 } else if (ch=='Z') {
1049 //mprintf ((0,"Got a Z!\n"));
1051 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
1054 if (LineAdjustment==1)
1061 while ((fname[i]=*message) != '\n') {
1067 while (*message++ != 10) // Get and drop eoln
1074 while (fname[i]!='.') {
1075 fname2[i] = fname[i];
1085 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
1086 load_new_briefing_screen (fname2);
1088 load_new_briefing_screen (fname);
1091 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1093 } else if (ch == 'B') {
1094 char bitmap_name[32];
1095 grs_bitmap guy_bitmap;
1096 ubyte temp_palette[768];
1099 if (Robot_canv != NULL) {
1104 get_message_name(&message, bitmap_name);
1105 strcat(bitmap_name, ".bbm");
1106 guy_bitmap.bm_data = NULL;
1107 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
1108 Assert(iff_error == IFF_NO_ERROR);
1109 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
1111 show_briefing_bitmap(&guy_bitmap);
1112 d_free(guy_bitmap.bm_data);
1114 // } else if (ch==EOF) {
1116 // } else if (ch == 'B') {
1117 // if (Robot_canv != NULL) {
1118 // d_free(Robot_canv);
1122 // bitmap_num = get_message_num(&message);
1123 // if (bitmap_num != -1)
1124 // show_briefing_bitmap(Textures[bitmap_num]);
1125 // prev_ch = 10; // read to eoln
1126 } else if (ch == 'S') {
1131 if (printing_channel>-1)
1132 digi_stop_sound( printing_channel );
1133 printing_channel=-1;
1144 start_time = timer_get_fixed_seconds();
1145 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1147 if (_RedrawScreen) {
1148 _RedrawScreen = FALSE;
1149 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1155 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1157 flash_cursor(flashing_cursor);
1161 if (robot_num != -1)
1162 show_spinning_robot_frame(robot_num);
1164 if (Bitmap_name[0] != 0)
1165 show_bitmap_frame();
1166 start_time += KEY_DELAY_DEFAULT/2;
1170 if (keypress == KEY_BACKSP)
1173 if (keypress == KEY_ESC)
1176 flashing_cursor = 0;
1178 WIN(wpage_done = 0);
1179 } else if (ch == 'P') { // New page.
1181 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1182 // printing to it! You know, $Z !!!
1183 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1187 while (*message != 10) {
1188 message++; // drop carriage return after special escape sequence
1194 } else if (ch == '\t') { // Tab
1195 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1196 Briefing_text_x = bsp->text_ulx + tab_stop;
1197 } else if ((ch == ';') && (prev_ch == 10)) {
1198 while (*message++ != 10)
1201 } else if (ch == '\\') {
1203 } else if (ch == 10) {
1204 if (prev_ch != '\\') {
1207 Briefing_text_y += (8*(MenuHires+1));
1210 Briefing_text_x = bsp->text_ulx;
1211 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1212 load_briefing_screen(screen_num);
1213 Briefing_text_x = bsp->text_ulx;
1214 Briefing_text_y = bsp->text_uly;
1217 if (ch == 13) //Can this happen? Above says ch==10
1224 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1225 // printing to it! You know, $Z !!!
1226 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1232 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1236 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1238 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1242 // Check for Esc -> abort.
1244 key_check=local_key_inkey();
1249 if (_RedrawScreen) {
1250 _RedrawScreen = FALSE;
1251 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1252 key_check = KEY_ESC;
1255 if ( key_check == KEY_ESC ) {
1260 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1263 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1264 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1265 (key_check == KEY_ALTED+KEY_PADENTER))
1266 gr_toggle_fullscreen();
1269 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1270 Briefing_text_x = bsp->text_ulx;
1271 Briefing_text_y += bsp->text_uly;
1274 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1280 if (printing_channel>-1)
1281 digi_stop_sound( printing_channel );
1282 printing_channel=-1;
1293 start_time = timer_get_fixed_seconds();
1294 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1296 if (_RedrawScreen) {
1297 _RedrawScreen = FALSE;
1298 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1304 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1306 flash_cursor(flashing_cursor);
1309 if (robot_num != -1)
1310 show_spinning_robot_frame(robot_num);
1311 if (Bitmap_name[0] != 0)
1312 show_bitmap_frame();
1313 start_time += KEY_DELAY_DEFAULT/2;
1322 if (keypress == KEY_BACKSP)
1325 if (keypress == KEY_ESC) {
1330 load_briefing_screen(screen_num);
1331 Briefing_text_x = bsp->text_ulx;
1332 Briefing_text_y = bsp->text_uly;
1333 delay_count = KEY_DELAY_DEFAULT;
1335 WIN(wpage_done = 0);
1344 if (Robot_canv != NULL)
1345 {d_free(Robot_canv); Robot_canv=NULL;}
1348 digi_stop_sound( hum_channel );
1349 if (printing_channel>-1)
1350 digi_stop_sound( printing_channel );
1352 if (Mission_list[Current_mission_num].descent_version == 1)
1358 //-----------------------------------------------------------------------------
1359 // Return a pointer to the start of text for screen #screen_num.
1360 char * get_briefing_message(int screen_num)
1362 char *tptr = Briefing_text;
1366 Assert(screen_num >= 0);
1368 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1373 cur_screen = get_message_num(&tptr);
1377 if (screen_num!=cur_screen)
1383 //-----------------------------------------------------------------------------
1384 // Load Descent briefing text.
1385 int load_screen_text(char *filename, char **buf)
1390 int have_binary = 0;
1392 if ((tfile = cfopen(filename,"rb")) == NULL) {
1393 char nfilename[30], *ptr;
1395 strcpy(nfilename, filename);
1396 if ((ptr = strrchr(nfilename, '.')))
1398 strcat(nfilename, ".txb");
1399 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1400 mprintf ((0,"can't open %s!\n",nfilename));
1402 //Error("Cannot open file %s or %s", filename, nfilename);
1405 mprintf ((0,"reading...\n"));
1408 len = cfilelength(ifile);
1409 MALLOC(*buf, char, len+500);
1410 mprintf ((0,"len=%d\n",len));
1411 for (x=0, i=0; i < len; i++, x++) {
1412 cfread (*buf+x,1,1,ifile);
1413 // mprintf ((0,"%c",*(*buf+x)));
1420 len = cfilelength(tfile);
1421 MALLOC(*buf, char, len+500);
1422 for (x=0, i=0; i < len; i++, x++) {
1423 cfread (*buf+x,1,1,tfile);
1424 // mprintf ((0,"%c",*(*buf+x)));
1430 //cfread(*buf, 1, len, tfile);
1437 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1439 encode_rotate_left(ptr);
1440 *ptr = *ptr ^ BITMAP_TBL_XOR;
1441 encode_rotate_left(ptr);
1449 //-----------------------------------------------------------------------------
1450 // Return true if message got aborted, else return false.
1451 int show_briefing_text(int screen_num)
1455 if (Mission_list[Current_mission_num].descent_version == 1)
1456 message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num);
1458 message_ptr = get_briefing_message(screen_num);
1459 if (message_ptr==NULL)
1462 DoBriefingColorStuff();
1464 return show_briefing_message(screen_num, message_ptr);
1467 void DoBriefingColorStuff ()
1469 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1470 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1472 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1473 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1475 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1476 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1478 if (Mission_list[Current_mission_num].descent_version == 1) {
1480 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1481 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1483 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1484 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1486 //Begin D1X addition
1488 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1489 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1492 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1493 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1495 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1496 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1498 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1499 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1501 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1502 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1505 Erase_color = gr_find_closest_color_current(0, 0, 0);
1508 //-----------------------------------------------------------------------------
1509 // Return true if screen got aborted by user, else return false.
1510 int show_briefing_screen( int screen_num, int allow_keys)
1513 //ubyte palette_save[768];
1515 New_pal_254_bash = 0;
1517 if (Skip_briefing_screens) {
1518 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1522 if (Mission_list[Current_mission_num].descent_version == 1) {
1525 grs_bitmap briefing_bm;
1527 gr_init_bitmap_data(&briefing_bm);
1528 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1530 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1532 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1533 mprintf((0, "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));
1539 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1540 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1542 //vfx_set_palette_sub( New_pal );
1544 gr_palette_load(New_pal);
1548 gr_set_current_canvas( NULL );
1549 show_fullscr(&briefing_bm);
1552 //added on 9/13/98 by adb to make arch's requiring updates work
1554 //end changes by adb
1557 gr_free_bitmap_data (&briefing_bm);
1560 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1563 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1568 key_close(); // kill the keyboard handler during briefing screens for movies
1570 rval = show_briefing_text(screen_num);
1575 #if defined (MACINTOSH) || defined(WINDOWS)
1576 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1581 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1584 DEFINE_SCREEN(NULL);
1585 WIN(DDGRLOCK(dd_grd_curcanv));
1586 gr_clear_canvas (0);
1587 WIN(DDGRUNLOCK(dd_grd_curcanv));
1588 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1592 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1594 //d_free(briefing_bm.bm_data);
1600 //-----------------------------------------------------------------------------
1601 void do_briefing_screens(char *filename,int level_num)
1603 int abort_briefing_screens = 0;
1604 int cur_briefing_screen = 0;
1606 if (Skip_briefing_screens) {
1607 mprintf((0, "Skipping all briefing screens.\n"));
1612 return; // no briefing screens at all for demo
1616 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1621 if (!load_screen_text(filename, &Briefing_text))
1625 songs_play_song( SONG_BRIEFING, 1 );
1630 set_screen_mode( SCREEN_MENU );
1633 dd_gr_set_current_canvas(NULL),
1634 gr_set_current_canvas(NULL)
1637 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1641 if (Mission_list[Current_mission_num].descent_version == 1) {
1642 if (level_num == 1) {
1643 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1644 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1645 cur_briefing_screen++;
1649 if (!abort_briefing_screens) {
1650 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1651 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1652 if (show_briefing_screen(cur_briefing_screen, 0))
1657 show_briefing_screen(level_num,0);
1659 d_free (Briefing_text);
1666 int DefineBriefingBox (char **buf)
1671 n=get_new_message_num (buf);
1673 Assert(n < MAX_BRIEFING_SCREENS);
1675 while (**buf!=' ') {
1680 name[i]='\0'; // slap a delimiter on this guy
1682 strcpy (Briefing_screens[n].bs_name,name);
1683 Briefing_screens[n].level_num=get_new_message_num (buf);
1684 Briefing_screens[n].message_num=get_new_message_num (buf);
1685 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1686 Briefing_screens[n].text_uly=get_new_message_num (buf);
1687 Briefing_screens[n].text_width=get_new_message_num (buf);
1688 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1690 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1691 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1692 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1693 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1698 int get_new_message_num(char **message)
1702 while (**message == ' ')
1705 while ((**message >= '0') && (**message <= '9')) {
1706 num = 10*num + **message-'0';