1 /* $Id: titles.c,v 1.29 2003-11-27 09:16:58 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"
249 #if defined(POLY_ACC)
250 #include "poly_acc.h"
254 void DoBriefingColorStuff ();
255 int get_new_message_num(char **message);
256 int DefineBriefingBox (char **buf);
258 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
261 int New_pal_254_bash;
263 char CurBriefScreenName[15]="brief03.pcx";
264 char * Briefing_text;
267 //Begin D1X modification
268 #define MAX_BRIEFING_COLORS 7
269 //End D1X modification
271 // Descent 1 briefings
272 char Ending_text_filename[13] = "endreg.txt";
273 char Briefing_text_filename[13] = "briefing.txt";
275 #define SHAREWARE_ENDING_FILENAME "ending.tex"
277 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
278 int Skip_briefing_screens=0;
279 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
280 int Current_color = 0;
283 extern int check_button_press();
286 extern void macintosh_quit(void);
289 // added by Jan Bobrowski for variable-size menu screen
290 static int rescale_x(int x)
292 return x * GWIDTH / 320;
295 static int rescale_y(int y)
297 return y * GHEIGHT / 200;
301 int local_key_inkey(void)
308 DoMessageStuff(&msg);
313 if (rval == KEY_PRINT_SCREEN) {
316 gr_palette_read(gr_palette);
317 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
321 return 0; //say no key pressed
324 if (check_button_press()) //joystick or mouse button pressed?
326 else if (mouse_button_state(0))
330 if ( rval == KEY_Q+KEY_COMMAND )
337 int local_key_inkey(void)
342 if (!GetOSEvent(everyEvent, &event))
345 if (event.what != keyDown)
348 rval = (int)((event.message & keyCodeMask) >> 8);
350 if (rval == KEY_PRINT_SCREEN) {
352 return 0; //say no key pressed
355 if (check_button_press()) //joystick or mouse button pressed?
359 if ( rval == KEY_Q+KEY_COMMAND )
367 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
372 ubyte palette_save[768];
373 char new_filename[FILENAME_LEN+1] = "";
377 strcpy(new_filename,"\x01"); //only read from hog file
380 strcat(new_filename,filename);
381 filename = new_filename;
383 title_bm.bm_data=NULL;
384 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
385 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
386 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));
387 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
390 memcpy(palette_save,gr_palette,sizeof(palette_save));
392 #if defined(POLY_ACC)
394 pa_update_clut(New_pal, 0, 256, 0);
397 //vfx_set_palette_sub( New_pal );
399 gr_palette_load( New_pal );
405 dd_gr_set_current_canvas(NULL),
406 gr_set_current_canvas( NULL )
408 WIN(DDGRLOCK(dd_grd_curcanv));
409 show_fullscr(&title_bm);
410 WIN(DDGRUNLOCK(dd_grd_curcanv));
414 #if defined(POLY_ACC)
418 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
420 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
422 gr_palette_load( New_pal );
423 timer = timer_get_fixed_seconds() + i2f(3);
425 if ( local_key_inkey() && allow_keys ) break;
426 if ( timer_get_fixed_seconds() > timer ) break;
428 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
430 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
431 d_free(title_bm.bm_data);
436 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
439 short text_ulx, text_uly; // upper left x,y of text window
440 short text_width, text_height; // width and height of text window
443 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
444 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
446 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
447 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
450 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
452 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
455 #define MAX_BRIEFING_SCREENS 60
458 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
459 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
461 briefing_screen Briefing_screens[] = {
462 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
463 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
464 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
465 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
467 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
468 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
469 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
471 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
472 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
474 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
475 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
476 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
479 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
480 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
481 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
482 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
483 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
485 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
486 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
487 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
488 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
489 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
491 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
492 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
493 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
494 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
495 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
497 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
498 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
499 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
500 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
502 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
503 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
504 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
506 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
507 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
508 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
510 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
511 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
512 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
515 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
517 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
518 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
519 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
526 int Briefing_text_x, Briefing_text_y;
528 void init_char_pos(int x, int y)
532 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
535 grs_canvas *Robot_canv = NULL;
536 vms_angvec Robot_angles;
538 char Bitmap_name[32] = "";
539 #define EXIT_DOOR_MAX 14
540 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
541 #define DOOR_DIV_INIT 6
542 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
544 //-----------------------------------------------------------------------------
545 void show_bitmap_frame(void)
548 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
550 grs_canvas *curcanv_save, *bitmap_canv=0;
553 grs_bitmap *bitmap_ptr;
555 // Only plot every nth frame.
556 if (Door_div_count) {
561 Door_div_count = DOOR_DIV_INIT;
563 if (Bitmap_name[0] != 0) {
567 // Set supertransparency color to black
568 if (!New_pal_254_bash) {
569 New_pal_254_bash = 1;
571 New_pal[254*3+1] = 0;
572 New_pal[254*3+2] = 0;
573 gr_palette_load( New_pal );
576 switch (Animating_bitmap_type) {
578 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
579 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
583 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
584 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
587 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
589 Int3(); // Impossible, illegal value for Animating_bitmap_type
593 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
594 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
597 pound_signp = strchr(Bitmap_name, '#');
598 Assert(pound_signp != NULL);
600 dig1 = *(pound_signp+1);
601 dig2 = *(pound_signp+2);
605 num = (dig1-'0')*10 + (dig2-'0');
607 switch (Animating_bitmap_type) {
610 if (num > EXIT_DOOR_MAX) {
613 } else if (num < 0) {
620 if (num > OTHER_THING_MAX)
627 *(pound_signp+1) = (num / 10) + '0';
628 *(pound_signp+2) = (num % 10) + '0';
629 *(pound_signp+3) = 0;
631 *(pound_signp+1) = (num % 10) + '0';
632 *(pound_signp+2) = 0;
637 bi = piggy_find_bitmap(Bitmap_name);
638 bitmap_ptr = &GameBitmaps[bi.index];
642 WIN(DDGRLOCK(dd_grd_curcanv));
643 gr_bitmapm(0, 0, bitmap_ptr);
644 WIN(DDGRUNLOCK(dd_grd_curcanv));
647 dd_grd_curcanv = curcanv_save,
648 grd_curcanv = curcanv_save
652 switch (Animating_bitmap_type) {
654 if (num == EXIT_DOOR_MAX) {
657 } else if (num == 0) {
669 //-----------------------------------------------------------------------------
670 void show_briefing_bitmap(grs_bitmap *bmp)
673 dd_grs_canvas *bitmap_canv, *curcanv_save;
675 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
676 curcanv_save = dd_grd_curcanv;
677 dd_gr_set_current_canvas(bitmap_canv);
678 DDGRLOCK(dd_grd_curcanv);
680 DDGRUNLOCK(dd_grd_curcanv);
681 dd_gr_set_current_canvas(curcanv_save);
683 grs_canvas *curcanv_save, *bitmap_canv;
685 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
686 curcanv_save = grd_curcanv;
687 gr_set_current_canvas(bitmap_canv);
688 gr_bitmapm(0, 0, bmp);
689 gr_set_current_canvas(curcanv_save);
696 //-----------------------------------------------------------------------------
697 void show_spinning_robot_frame(int robot_num)
699 grs_canvas *curcanv_save;
701 if (robot_num != -1) {
702 Robot_angles.h += 150;
704 curcanv_save = grd_curcanv;
705 grd_curcanv = Robot_canv;
706 Assert(Robot_info[robot_num].model_num != -1);
707 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
708 grd_curcanv = curcanv_save;
713 //-----------------------------------------------------------------------------
714 void init_spinning_robot(void) //(int x,int y,int w,int h)
716 //Robot_angles.p += 0;
717 //Robot_angles.b += 0;
718 //Robot_angles.h += 0;
720 int x = rescale_x(138);
721 int y = rescale_y(55);
722 int w = rescale_x(166);
723 int h = rescale_y(138);
725 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
730 //---------------------------------------------------------------------------
731 // Returns char width.
732 // If show_robot_flag set, then show a frame of the spinning robot.
733 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
737 static fix start_time=0;
739 message[0] = the_char;
742 if (start_time==0 && timer_get_fixed_seconds()<0)
743 start_time=timer_get_fixed_seconds();
745 gr_get_string_size(message, &w, &h, &aw );
747 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
749 // Draw cursor if there is some delay and caller says to draw cursor
750 if (cursor_flag && delay) {
751 WIN(DDGRLOCK(dd_grd_curcanv));
752 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
753 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
754 WIN(DDGRUNLOCK(dd_grd_curcanv));
759 delay=fixdiv (F1_0,i2f(15));
761 if ((Bitmap_name[0] != 0) && (delay != 0))
764 if (RobotPlaying && (delay != 0))
767 while (timer_get_fixed_seconds() < (start_time + delay)) {
768 if (RobotPlaying && delay != 0)
772 show_spinning_robot_frame(robot_num);
774 start_time = timer_get_fixed_seconds();
776 WIN(DDGRLOCK(dd_grd_curcanv));
778 if (cursor_flag && delay) {
779 gr_set_fontcolor(Erase_color, -1);
780 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
783 // Draw the character
784 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
785 gr_printf(Briefing_text_x, Briefing_text_y, message );
787 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
788 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
789 WIN(DDGRUNLOCK(dd_grd_curcanv));
791 if (delay) gr_update();
793 // if (the_char != ' ')
794 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
795 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
800 //-----------------------------------------------------------------------------
801 int load_briefing_screen( int screen_num )
806 if (Mission_list[Current_mission_num].descent_version == 1)
807 fname = Briefing_screens[screen_num].bs_name;
809 fname = CurBriefScreenName;
811 WIN(DDGRLOCK(dd_grd_curcanv));
812 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
813 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
814 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);
815 WIN(DDGRUNLOCK(dd_grd_curcanv));
816 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
818 WIN(DDGRUNLOCK(dd_grd_curcanv));
825 int load_new_briefing_screen( char *fname )
829 mprintf ((0,"Loading new briefing <%s>\n",fname));
830 strcpy (CurBriefScreenName,fname);
832 //WIN(DEFINE_SCREEN(CurBriefScreenName));
834 if (gr_palette_fade_out( New_pal, 32, 0 ))
837 WIN(DDGRLOCK(dd_grd_curcanv));
838 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
839 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
840 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);
841 WIN(DDGRUNLOCK(dd_grd_curcanv));
842 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
844 WIN(DDGRUNLOCK(dd_grd_curcanv));
848 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
850 if (gr_palette_fade_in( New_pal, 32, 0 ))
852 DoBriefingColorStuff();
859 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
861 //-----------------------------------------------------------------------------
862 int get_message_num(char **message)
866 while (**message == ' ')
869 while ((**message >= '0') && (**message <= '9')) {
870 num = 10*num + **message-'0';
874 while (*(*message)++ != 10) // Get and drop eoln
880 //-----------------------------------------------------------------------------
881 void get_message_name(char **message, char *result)
883 while (**message == ' ')
886 while ((**message != ' ') && (**message != 10)) {
887 if (**message != '\n')
888 *result++ = **message;
893 while (*(*message)++ != 10) // Get and drop eoln
899 //-----------------------------------------------------------------------------
900 void flash_cursor(int cursor_flag)
902 if (cursor_flag == 0)
905 WIN(DDGRLOCK(dd_grd_curcanv));
906 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
907 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
909 gr_set_fontcolor(Erase_color, -1);
911 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
912 WIN(DDGRUNLOCK(dd_grd_curcanv));
916 extern int InitMovieBriefing();
919 //-----------------------------------------------------------------------------
920 // Return true if message got aborted by user (pressed ESC), else return false.
921 int show_briefing_message(int screen_num, char *message)
925 briefing_screen *bsp;
926 int delay_count = KEY_DELAY_DEFAULT;
930 static int tab_stop=0;
931 int flashing_cursor=0;
932 int new_page=0,GotZ=0;
933 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
937 int hum_channel=-1,printing_channel=-1;
938 int LineAdjustment=1;
939 WIN(int wpage_done=0);
948 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
951 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
952 gr_set_curfont( GAME_FONT );
954 if (Mission_list[Current_mission_num].descent_version == 1) {
956 MALLOC(bsp, briefing_screen, 1);
957 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
958 bsp->text_ulx = rescale_x(bsp->text_ulx);
959 bsp->text_uly = rescale_y(bsp->text_uly);
960 bsp->text_width = rescale_x(bsp->text_width);
961 bsp->text_height = rescale_y(bsp->text_height);
962 init_char_pos(bsp->text_ulx, bsp->text_uly);
964 bsp=&Briefing_screens[0];
965 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
973 screen_num=DefineBriefingBox (&message);
974 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
976 bsp = &Briefing_screens[screen_num];
977 init_char_pos(bsp->text_ulx, bsp->text_uly);
979 prev_ch = 10; // read to eoln
980 } else if (ch=='U') {
981 screen_num=get_message_num(&message);
982 bsp = &Briefing_screens[screen_num];
983 init_char_pos(bsp->text_ulx, bsp->text_uly);
984 prev_ch = 10; // read to eoln
985 } else if (ch == 'C') {
986 Current_color = get_message_num(&message)-1;
987 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
989 } else if (ch == 'F') { // toggle flashing cursor
990 flashing_cursor = !flashing_cursor;
992 while (*message++ != 10)
994 } else if (ch == 'T') {
995 tab_stop = get_message_num(&message);
996 tab_stop*=(1+MenuHires);
997 prev_ch = 10; // read to eoln
998 } else if (ch == 'R') {
999 if (Robot_canv != NULL) {
1008 if (Mission_list[Current_mission_num].descent_version == 1) {
1009 init_spinning_robot();
1010 robot_num = get_message_num(&message);
1011 while (*message++ != 10)
1015 spinRobotName[2]=kludge; // ugly but proud
1017 RobotPlaying=InitRobotMovie(spinRobotName);
1019 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
1023 DoBriefingColorStuff ();
1024 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
1027 prev_ch = 10; // read to eoln
1028 } else if (ch == 'N') {
1029 //--grs_bitmap *bitmap_ptr;
1030 if (Robot_canv != NULL) {
1035 get_message_name(&message, Bitmap_name);
1036 strcat(Bitmap_name, "#0");
1037 Animating_bitmap_type = 0;
1039 } else if (ch == 'O') {
1040 if (Robot_canv != NULL) {
1045 get_message_name(&message, Bitmap_name);
1046 strcat(Bitmap_name, "#0");
1047 Animating_bitmap_type = 1;
1049 } else if (ch=='A') {
1050 LineAdjustment=1-LineAdjustment;
1051 } else if (ch=='Z') {
1052 //mprintf ((0,"Got a Z!\n"));
1054 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
1057 if (LineAdjustment==1)
1064 while ((fname[i]=*message) != '\n') {
1070 while (*message++ != 10) // Get and drop eoln
1077 while (fname[i]!='.') {
1078 fname2[i] = fname[i];
1088 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
1089 load_new_briefing_screen (fname2);
1091 load_new_briefing_screen (fname);
1094 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1096 } else if (ch == 'B') {
1097 char bitmap_name[32];
1098 grs_bitmap guy_bitmap;
1099 ubyte temp_palette[768];
1102 if (Robot_canv != NULL) {
1107 get_message_name(&message, bitmap_name);
1108 strcat(bitmap_name, ".bbm");
1109 guy_bitmap.bm_data = NULL;
1110 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
1111 Assert(iff_error == IFF_NO_ERROR);
1112 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
1114 show_briefing_bitmap(&guy_bitmap);
1115 d_free(guy_bitmap.bm_data);
1117 // } else if (ch==EOF) {
1119 // } else if (ch == 'B') {
1120 // if (Robot_canv != NULL) {
1121 // d_free(Robot_canv);
1125 // bitmap_num = get_message_num(&message);
1126 // if (bitmap_num != -1)
1127 // show_briefing_bitmap(Textures[bitmap_num]);
1128 // prev_ch = 10; // read to eoln
1129 } else if (ch == 'S') {
1134 if (printing_channel>-1)
1135 digi_stop_sound( printing_channel );
1136 printing_channel=-1;
1147 start_time = timer_get_fixed_seconds();
1148 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1150 if (_RedrawScreen) {
1151 _RedrawScreen = FALSE;
1152 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1158 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1160 flash_cursor(flashing_cursor);
1164 if (robot_num != -1)
1165 show_spinning_robot_frame(robot_num);
1167 if (Bitmap_name[0] != 0)
1168 show_bitmap_frame();
1169 start_time += KEY_DELAY_DEFAULT/2;
1173 if (keypress == KEY_BACKSP)
1176 if (keypress == KEY_ESC)
1179 flashing_cursor = 0;
1181 WIN(wpage_done = 0);
1182 } else if (ch == 'P') { // New page.
1184 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1185 // printing to it! You know, $Z !!!
1186 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1190 while (*message != 10) {
1191 message++; // drop carriage return after special escape sequence
1197 } else if (ch == '\t') { // Tab
1198 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1199 Briefing_text_x = bsp->text_ulx + tab_stop;
1200 } else if ((ch == ';') && (prev_ch == 10)) {
1201 while (*message++ != 10)
1204 } else if (ch == '\\') {
1206 } else if (ch == 10) {
1207 if (prev_ch != '\\') {
1210 Briefing_text_y += (8*(MenuHires+1));
1213 Briefing_text_x = bsp->text_ulx;
1214 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1215 load_briefing_screen(screen_num);
1216 Briefing_text_x = bsp->text_ulx;
1217 Briefing_text_y = bsp->text_uly;
1220 if (ch == 13) //Can this happen? Above says ch==10
1227 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1228 // printing to it! You know, $Z !!!
1229 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1235 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1239 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1241 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1245 // Check for Esc -> abort.
1247 key_check=local_key_inkey();
1252 if (_RedrawScreen) {
1253 _RedrawScreen = FALSE;
1254 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1255 key_check = KEY_ESC;
1258 if ( key_check == KEY_ESC ) {
1263 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1266 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1267 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1268 (key_check == KEY_ALTED+KEY_PADENTER))
1269 gr_toggle_fullscreen();
1272 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1273 Briefing_text_x = bsp->text_ulx;
1274 Briefing_text_y += bsp->text_uly;
1277 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1283 if (printing_channel>-1)
1284 digi_stop_sound( printing_channel );
1285 printing_channel=-1;
1296 start_time = timer_get_fixed_seconds();
1297 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1299 if (_RedrawScreen) {
1300 _RedrawScreen = FALSE;
1301 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1307 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1309 flash_cursor(flashing_cursor);
1312 if (robot_num != -1)
1313 show_spinning_robot_frame(robot_num);
1314 if (Bitmap_name[0] != 0)
1315 show_bitmap_frame();
1316 start_time += KEY_DELAY_DEFAULT/2;
1325 if (keypress == KEY_BACKSP)
1328 if (keypress == KEY_ESC) {
1333 load_briefing_screen(screen_num);
1334 Briefing_text_x = bsp->text_ulx;
1335 Briefing_text_y = bsp->text_uly;
1336 delay_count = KEY_DELAY_DEFAULT;
1338 WIN(wpage_done = 0);
1347 if (Robot_canv != NULL)
1348 {d_free(Robot_canv); Robot_canv=NULL;}
1351 digi_stop_sound( hum_channel );
1352 if (printing_channel>-1)
1353 digi_stop_sound( printing_channel );
1355 if (Mission_list[Current_mission_num].descent_version == 1)
1361 //-----------------------------------------------------------------------------
1362 // Return a pointer to the start of text for screen #screen_num.
1363 char * get_briefing_message(int screen_num)
1365 char *tptr = Briefing_text;
1369 Assert(screen_num >= 0);
1371 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1376 cur_screen = get_message_num(&tptr);
1380 if (screen_num!=cur_screen)
1386 //-----------------------------------------------------------------------------
1387 // Load Descent briefing text.
1388 int load_screen_text(char *filename, char **buf)
1393 int have_binary = 0;
1395 if ((tfile = cfopen(filename,"rb")) == NULL) {
1396 char nfilename[30], *ptr;
1398 strcpy(nfilename, filename);
1399 if ((ptr = strrchr(nfilename, '.')))
1401 strcat(nfilename, ".txb");
1402 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1403 mprintf ((0,"can't open %s!\n",nfilename));
1405 //Error("Cannot open file %s or %s", filename, nfilename);
1408 mprintf ((0,"reading...\n"));
1411 len = cfilelength(ifile);
1412 MALLOC(*buf, char, len+500);
1413 mprintf ((0,"len=%d\n",len));
1414 for (x=0, i=0; i < len; i++, x++) {
1415 cfread (*buf+x,1,1,ifile);
1416 // mprintf ((0,"%c",*(*buf+x)));
1423 len = cfilelength(tfile);
1424 MALLOC(*buf, char, len+500);
1425 for (x=0, i=0; i < len; i++, x++) {
1426 cfread (*buf+x,1,1,tfile);
1427 // mprintf ((0,"%c",*(*buf+x)));
1433 //cfread(*buf, 1, len, tfile);
1440 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1442 encode_rotate_left(ptr);
1443 *ptr = *ptr ^ BITMAP_TBL_XOR;
1444 encode_rotate_left(ptr);
1452 //-----------------------------------------------------------------------------
1453 // Return true if message got aborted, else return false.
1454 int show_briefing_text(int screen_num)
1458 if (Mission_list[Current_mission_num].descent_version == 1)
1459 message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num);
1461 message_ptr = get_briefing_message(screen_num);
1462 if (message_ptr==NULL)
1465 DoBriefingColorStuff();
1467 return show_briefing_message(screen_num, message_ptr);
1470 void DoBriefingColorStuff ()
1472 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1473 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1475 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1476 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1478 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1479 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1481 if (Mission_list[Current_mission_num].descent_version == 1) {
1483 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1484 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1486 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1487 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1489 //Begin D1X addition
1491 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1492 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1495 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1496 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1498 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1499 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1501 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1502 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1504 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1505 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1508 Erase_color = gr_find_closest_color_current(0, 0, 0);
1511 //-----------------------------------------------------------------------------
1512 // Return true if screen got aborted by user, else return false.
1513 int show_briefing_screen( int screen_num, int allow_keys)
1516 //ubyte palette_save[768];
1518 New_pal_254_bash = 0;
1520 if (Skip_briefing_screens) {
1521 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1525 if (Mission_list[Current_mission_num].descent_version == 1) {
1528 grs_bitmap briefing_bm;
1530 gr_init_bitmap_data(&briefing_bm);
1531 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1533 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1535 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1536 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));
1542 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1543 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1545 //vfx_set_palette_sub( New_pal );
1547 gr_palette_load(New_pal);
1551 gr_set_current_canvas( NULL );
1552 show_fullscr(&briefing_bm);
1555 //added on 9/13/98 by adb to make arch's requiring updates work
1557 //end changes by adb
1560 gr_free_bitmap_data (&briefing_bm);
1563 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1566 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1571 key_close(); // kill the keyboard handler during briefing screens for movies
1573 rval = show_briefing_text(screen_num);
1578 #if defined (MACINTOSH) || defined(WINDOWS)
1579 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1584 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1587 DEFINE_SCREEN(NULL);
1588 WIN(DDGRLOCK(dd_grd_curcanv));
1589 gr_clear_canvas (0);
1590 WIN(DDGRUNLOCK(dd_grd_curcanv));
1591 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1595 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1597 //d_free(briefing_bm.bm_data);
1603 //-----------------------------------------------------------------------------
1604 void do_briefing_screens(char *filename,int level_num)
1606 int abort_briefing_screens = 0;
1607 int cur_briefing_screen = 0;
1609 if (Skip_briefing_screens) {
1610 mprintf((0, "Skipping all briefing screens.\n"));
1615 return; // no briefing screens at all for demo
1619 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1624 if (!load_screen_text(filename, &Briefing_text))
1628 songs_play_song( SONG_BRIEFING, 1 );
1633 set_screen_mode( SCREEN_MENU );
1636 dd_gr_set_current_canvas(NULL),
1637 gr_set_current_canvas(NULL)
1640 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1644 if (Mission_list[Current_mission_num].descent_version == 1) {
1645 if (level_num == 1) {
1646 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1647 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1648 cur_briefing_screen++;
1652 if (!abort_briefing_screens) {
1653 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1654 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1655 if (show_briefing_screen(cur_briefing_screen, 0))
1660 show_briefing_screen(level_num,0);
1662 d_free (Briefing_text);
1669 int DefineBriefingBox (char **buf)
1674 n=get_new_message_num (buf);
1676 Assert(n < MAX_BRIEFING_SCREENS);
1678 while (**buf!=' ') {
1683 name[i]='\0'; // slap a delimiter on this guy
1685 strcpy (Briefing_screens[n].bs_name,name);
1686 Briefing_screens[n].level_num=get_new_message_num (buf);
1687 Briefing_screens[n].message_num=get_new_message_num (buf);
1688 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1689 Briefing_screens[n].text_uly=get_new_message_num (buf);
1690 Briefing_screens[n].text_width=get_new_message_num (buf);
1691 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1693 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1694 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1695 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1696 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1701 int get_new_message_num(char **message)
1705 while (**message == ' ')
1708 while ((**message >= '0') && (**message <= '9')) {
1709 num = 10*num + **message-'0';