1 /* $Id: titles.c,v 1.24 2003-03-01 12:50:45 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.
31 #include "pa_enabl.h" //$$POLY_ACC
66 void DoBriefingColorStuff ();
67 int get_new_message_num(char **message);
68 int DefineBriefingBox (char **buf);
70 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
75 char CurBriefScreenName[15]="brief03.pcx";
79 //Begin D1X modification
80 #define MAX_BRIEFING_COLORS 7
81 //End D1X modification
83 // Descent 1 briefings
84 char Ending_text_filename[13] = "endreg.txt";
85 char Briefing_text_filename[13] = "briefing.txt";
87 #define SHAREWARE_ENDING_FILENAME "ending.tex"
89 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
90 int Skip_briefing_screens=0;
91 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
92 int Current_color = 0;
95 extern int check_button_press();
98 extern void macintosh_quit(void);
101 // added by Jan Bobrowski for variable-size menu screen
102 static int rescale_x(int x)
104 return x * GWIDTH / 320;
107 static int rescale_y(int y)
109 return y * GHEIGHT / 200;
113 int local_key_inkey(void)
120 DoMessageStuff(&msg);
125 if (rval == KEY_PRINT_SCREEN) {
128 gr_palette_read(gr_palette);
129 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
133 return 0; //say no key pressed
136 if (check_button_press()) //joystick or mouse button pressed?
140 if ( rval == KEY_Q+KEY_COMMAND )
147 int local_key_inkey(void)
152 if (!GetOSEvent(everyEvent, &event))
155 if (event.what != keyDown)
158 rval = (int)((event.message & keyCodeMask) >> 8);
160 if (rval == KEY_PRINT_SCREEN) {
162 return 0; //say no key pressed
165 if (check_button_press()) //joystick or mouse button pressed?
169 if ( rval == KEY_Q+KEY_COMMAND )
177 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
182 ubyte palette_save[768];
183 char new_filename[FILENAME_LEN+1] = "";
187 strcpy(new_filename,"\x01"); //only read from hog file
190 strcat(new_filename,filename);
191 filename = new_filename;
193 title_bm.bm_data=NULL;
194 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
195 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
196 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));
197 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
200 memcpy(palette_save,gr_palette,sizeof(palette_save));
202 #if defined(POLY_ACC)
204 pa_update_clut(New_pal, 0, 256, 0);
207 //vfx_set_palette_sub( New_pal );
209 gr_palette_load( New_pal );
215 dd_gr_set_current_canvas(NULL),
216 gr_set_current_canvas( NULL )
218 WIN(DDGRLOCK(dd_grd_curcanv));
219 show_fullscr(&title_bm);
220 WIN(DDGRUNLOCK(dd_grd_curcanv));
224 #if defined(POLY_ACC)
228 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
230 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
232 gr_palette_load( New_pal );
233 timer = timer_get_fixed_seconds() + i2f(3);
235 if ( local_key_inkey() && allow_keys ) break;
236 if ( timer_get_fixed_seconds() > timer ) break;
238 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
240 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
241 d_free(title_bm.bm_data);
246 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
249 short text_ulx, text_uly; // upper left x,y of text window
250 short text_width, text_height; // width and height of text window
253 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
254 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
256 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
257 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
260 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
262 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
265 #define MAX_BRIEFING_SCREENS 60
268 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
269 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
271 briefing_screen Briefing_screens[] = {
272 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
273 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
274 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
275 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
277 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
278 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
279 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
281 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
282 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
284 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
285 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
286 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
289 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
290 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
291 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
292 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
293 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
295 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
296 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
297 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
298 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
299 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
301 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
302 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
303 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
304 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
305 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
307 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
308 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
309 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
310 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
312 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
313 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
314 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
316 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
317 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
318 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
320 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
321 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
322 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
325 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
327 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
328 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
329 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
336 int Briefing_text_x, Briefing_text_y;
338 void init_char_pos(int x, int y)
342 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
345 grs_canvas *Robot_canv = NULL;
346 vms_angvec Robot_angles;
348 char Bitmap_name[32] = "";
349 #define EXIT_DOOR_MAX 14
350 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
351 #define DOOR_DIV_INIT 6
352 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
354 //-----------------------------------------------------------------------------
355 void show_bitmap_frame(void)
358 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
360 grs_canvas *curcanv_save, *bitmap_canv=0;
363 grs_bitmap *bitmap_ptr;
365 // Only plot every nth frame.
366 if (Door_div_count) {
371 Door_div_count = DOOR_DIV_INIT;
373 if (Bitmap_name[0] != 0) {
377 // Set supertransparency color to black
378 if (!New_pal_254_bash) {
379 New_pal_254_bash = 1;
381 New_pal[254*3+1] = 0;
382 New_pal[254*3+2] = 0;
383 gr_palette_load( New_pal );
386 switch (Animating_bitmap_type) {
388 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break,
389 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64); break
393 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break,
394 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94); break
397 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
399 Int3(); // Impossible, illegal value for Animating_bitmap_type
403 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
404 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
407 pound_signp = strchr(Bitmap_name, '#');
408 Assert(pound_signp != NULL);
410 dig1 = *(pound_signp+1);
411 dig2 = *(pound_signp+2);
415 num = (dig1-'0')*10 + (dig2-'0');
417 switch (Animating_bitmap_type) {
420 if (num > EXIT_DOOR_MAX) {
423 } else if (num < 0) {
430 if (num > OTHER_THING_MAX)
437 *(pound_signp+1) = (num / 10) + '0';
438 *(pound_signp+2) = (num % 10) + '0';
439 *(pound_signp+3) = 0;
441 *(pound_signp+1) = (num % 10) + '0';
442 *(pound_signp+2) = 0;
447 bi = piggy_find_bitmap(Bitmap_name);
448 bitmap_ptr = &GameBitmaps[bi.index];
452 WIN(DDGRLOCK(dd_grd_curcanv));
453 gr_bitmapm(0, 0, bitmap_ptr);
454 WIN(DDGRUNLOCK(dd_grd_curcanv));
457 dd_grd_curcanv = curcanv_save,
458 grd_curcanv = curcanv_save
462 switch (Animating_bitmap_type) {
464 if (num == EXIT_DOOR_MAX) {
467 } else if (num == 0) {
479 //-----------------------------------------------------------------------------
480 void show_briefing_bitmap(grs_bitmap *bmp)
483 dd_grs_canvas *bitmap_canv, *curcanv_save;
485 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
486 curcanv_save = dd_grd_curcanv;
487 dd_gr_set_current_canvas(bitmap_canv);
488 DDGRLOCK(dd_grd_curcanv);
490 DDGRUNLOCK(dd_grd_curcanv);
491 dd_gr_set_current_canvas(curcanv_save);
493 grs_canvas *curcanv_save, *bitmap_canv;
495 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
496 curcanv_save = grd_curcanv;
497 gr_set_current_canvas(bitmap_canv);
498 gr_bitmapm(0, 0, bmp);
499 gr_set_current_canvas(curcanv_save);
506 //-----------------------------------------------------------------------------
507 void show_spinning_robot_frame(int robot_num)
509 grs_canvas *curcanv_save;
511 if (robot_num != -1) {
512 Robot_angles.h += 150;
514 curcanv_save = grd_curcanv;
515 grd_curcanv = Robot_canv;
516 Assert(Robot_info[robot_num].model_num != -1);
517 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
518 grd_curcanv = curcanv_save;
523 //-----------------------------------------------------------------------------
524 void init_spinning_robot(void) //(int x,int y,int w,int h)
526 //Robot_angles.p += 0;
527 //Robot_angles.b += 0;
528 //Robot_angles.h += 0;
530 int x = rescale_x(138);
531 int y = rescale_y(55);
532 int w = rescale_x(166);
533 int h = rescale_y(138);
535 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
540 //---------------------------------------------------------------------------
541 // Returns char width.
542 // If show_robot_flag set, then show a frame of the spinning robot.
543 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
547 static fix start_time=0;
549 message[0] = the_char;
552 if (start_time==0 && timer_get_fixed_seconds()<0)
553 start_time=timer_get_fixed_seconds();
555 gr_get_string_size(message, &w, &h, &aw );
557 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
559 // Draw cursor if there is some delay and caller says to draw cursor
560 if (cursor_flag && delay) {
561 WIN(DDGRLOCK(dd_grd_curcanv));
562 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
563 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
564 WIN(DDGRUNLOCK(dd_grd_curcanv));
569 delay=fixdiv (F1_0,i2f(15));
571 if ((Bitmap_name[0] != 0) && (delay != 0))
574 if (RobotPlaying && (delay != 0))
577 while (timer_get_fixed_seconds() < (start_time + delay)) {
578 if (RobotPlaying && delay != 0)
582 show_spinning_robot_frame(robot_num);
584 start_time = timer_get_fixed_seconds();
586 WIN(DDGRLOCK(dd_grd_curcanv));
588 if (cursor_flag && delay) {
589 gr_set_fontcolor(Erase_color, -1);
590 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
593 // Draw the character
594 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
595 gr_printf(Briefing_text_x, Briefing_text_y, message );
597 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
598 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
599 WIN(DDGRUNLOCK(dd_grd_curcanv));
601 if (delay) gr_update();
603 // if (the_char != ' ')
604 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
605 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
610 //-----------------------------------------------------------------------------
611 int load_briefing_screen( int screen_num )
616 if (Mission_list[Current_mission_num].descent_version == 1)
617 fname = Briefing_screens[screen_num].bs_name;
619 fname = CurBriefScreenName;
621 WIN(DDGRLOCK(dd_grd_curcanv));
622 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
623 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
624 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);
625 WIN(DDGRUNLOCK(dd_grd_curcanv));
626 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
628 WIN(DDGRUNLOCK(dd_grd_curcanv));
635 int load_new_briefing_screen( char *fname )
639 mprintf ((0,"Loading new briefing <%s>\n",fname));
640 strcpy (CurBriefScreenName,fname);
642 //WIN(DEFINE_SCREEN(CurBriefScreenName));
644 if (gr_palette_fade_out( New_pal, 32, 0 ))
647 WIN(DDGRLOCK(dd_grd_curcanv));
648 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
649 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
650 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);
651 WIN(DDGRUNLOCK(dd_grd_curcanv));
652 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
654 WIN(DDGRUNLOCK(dd_grd_curcanv));
658 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
660 if (gr_palette_fade_in( New_pal, 32, 0 ))
662 DoBriefingColorStuff();
669 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
671 //-----------------------------------------------------------------------------
672 int get_message_num(char **message)
676 while (**message == ' ')
679 while ((**message >= '0') && (**message <= '9')) {
680 num = 10*num + **message-'0';
684 while (*(*message)++ != 10) // Get and drop eoln
690 //-----------------------------------------------------------------------------
691 void get_message_name(char **message, char *result)
693 while (**message == ' ')
696 while ((**message != ' ') && (**message != 10)) {
697 if (**message != '\n')
698 *result++ = **message;
703 while (*(*message)++ != 10) // Get and drop eoln
709 //-----------------------------------------------------------------------------
710 void flash_cursor(int cursor_flag)
712 if (cursor_flag == 0)
715 WIN(DDGRLOCK(dd_grd_curcanv));
716 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
717 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
719 gr_set_fontcolor(Erase_color, -1);
721 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
722 WIN(DDGRUNLOCK(dd_grd_curcanv));
726 extern int InitMovieBriefing();
729 //-----------------------------------------------------------------------------
730 // Return true if message got aborted by user (pressed ESC), else return false.
731 int show_briefing_message(int screen_num, char *message)
735 briefing_screen *bsp;
736 int delay_count = KEY_DELAY_DEFAULT;
740 static int tab_stop=0;
741 int flashing_cursor=0;
742 int new_page=0,GotZ=0;
743 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
747 int hum_channel=-1,printing_channel=-1;
748 int LineAdjustment=1;
749 WIN(int wpage_done=0);
758 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
761 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
762 gr_set_curfont( GAME_FONT );
764 if (Mission_list[Current_mission_num].descent_version == 1) {
766 MALLOC(bsp, briefing_screen, 1);
767 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
768 bsp->text_ulx = rescale_x(bsp->text_ulx);
769 bsp->text_uly = rescale_y(bsp->text_uly);
770 bsp->text_width = rescale_x(bsp->text_width);
771 bsp->text_height = rescale_y(bsp->text_height);
772 init_char_pos(bsp->text_ulx, bsp->text_uly);
774 bsp=&Briefing_screens[0];
775 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
783 screen_num=DefineBriefingBox (&message);
784 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
786 bsp = &Briefing_screens[screen_num];
787 init_char_pos(bsp->text_ulx, bsp->text_uly);
789 prev_ch = 10; // read to eoln
790 } else if (ch=='U') {
791 screen_num=get_message_num(&message);
792 bsp = &Briefing_screens[screen_num];
793 init_char_pos(bsp->text_ulx, bsp->text_uly);
794 prev_ch = 10; // read to eoln
795 } else if (ch == 'C') {
796 Current_color = get_message_num(&message)-1;
797 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
799 } else if (ch == 'F') { // toggle flashing cursor
800 flashing_cursor = !flashing_cursor;
802 while (*message++ != 10)
804 } else if (ch == 'T') {
805 tab_stop = get_message_num(&message);
806 tab_stop*=(1+MenuHires);
807 prev_ch = 10; // read to eoln
808 } else if (ch == 'R') {
809 if (Robot_canv != NULL) {
818 if (Mission_list[Current_mission_num].descent_version == 1) {
819 init_spinning_robot();
820 robot_num = get_message_num(&message);
821 while (*message++ != 10)
825 spinRobotName[2]=kludge; // ugly but proud
827 RobotPlaying=InitRobotMovie(spinRobotName);
829 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
833 DoBriefingColorStuff ();
834 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
837 prev_ch = 10; // read to eoln
838 } else if (ch == 'N') {
839 //--grs_bitmap *bitmap_ptr;
840 if (Robot_canv != NULL) {
845 get_message_name(&message, Bitmap_name);
846 strcat(Bitmap_name, "#0");
847 Animating_bitmap_type = 0;
849 } else if (ch == 'O') {
850 if (Robot_canv != NULL) {
855 get_message_name(&message, Bitmap_name);
856 strcat(Bitmap_name, "#0");
857 Animating_bitmap_type = 1;
859 } else if (ch=='A') {
860 LineAdjustment=1-LineAdjustment;
861 } else if (ch=='Z') {
862 //mprintf ((0,"Got a Z!\n"));
864 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
867 if (LineAdjustment==1)
874 while ((fname[i]=*message) != '\n') {
880 while (*message++ != 10) // Get and drop eoln
887 while (fname[i]!='.') {
888 fname2[i] = fname[i];
898 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
899 load_new_briefing_screen (fname2);
901 load_new_briefing_screen (fname);
904 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
906 } else if (ch == 'B') {
907 char bitmap_name[32];
908 grs_bitmap guy_bitmap;
909 ubyte temp_palette[768];
912 if (Robot_canv != NULL) {
917 get_message_name(&message, bitmap_name);
918 strcat(bitmap_name, ".bbm");
919 guy_bitmap.bm_data = NULL;
920 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
921 Assert(iff_error == IFF_NO_ERROR);
922 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
924 show_briefing_bitmap(&guy_bitmap);
925 d_free(guy_bitmap.bm_data);
927 // } else if (ch==EOF) {
929 // } else if (ch == 'B') {
930 // if (Robot_canv != NULL) {
931 // d_free(Robot_canv);
935 // bitmap_num = get_message_num(&message);
936 // if (bitmap_num != -1)
937 // show_briefing_bitmap(Textures[bitmap_num]);
938 // prev_ch = 10; // read to eoln
939 } else if (ch == 'S') {
944 if (printing_channel>-1)
945 digi_stop_sound( printing_channel );
957 start_time = timer_get_fixed_seconds();
958 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
961 _RedrawScreen = FALSE;
962 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
968 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
970 flash_cursor(flashing_cursor);
975 show_spinning_robot_frame(robot_num);
977 if (Bitmap_name[0] != 0)
979 start_time += KEY_DELAY_DEFAULT/2;
983 if (keypress == KEY_BACKSP)
986 if (keypress == KEY_ESC)
992 } else if (ch == 'P') { // New page.
994 Int3(); // Hey ryan!!!! You gotta load a screen before you start
995 // printing to it! You know, $Z !!!
996 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1000 while (*message != 10) {
1001 message++; // drop carriage return after special escape sequence
1007 } else if (ch == '\t') { // Tab
1008 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1009 Briefing_text_x = bsp->text_ulx + tab_stop;
1010 } else if ((ch == ';') && (prev_ch == 10)) {
1011 while (*message++ != 10)
1014 } else if (ch == '\\') {
1016 } else if (ch == 10) {
1017 if (prev_ch != '\\') {
1020 Briefing_text_y += (8*(MenuHires+1));
1023 Briefing_text_x = bsp->text_ulx;
1024 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1025 load_briefing_screen(screen_num);
1026 Briefing_text_x = bsp->text_ulx;
1027 Briefing_text_y = bsp->text_uly;
1030 if (ch == 13) //Can this happen? Above says ch==10
1037 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1038 // printing to it! You know, $Z !!!
1039 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1045 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1049 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1051 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1055 // Check for Esc -> abort.
1057 key_check=local_key_inkey();
1062 if (_RedrawScreen) {
1063 _RedrawScreen = FALSE;
1064 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1065 key_check = KEY_ESC;
1068 if ( key_check == KEY_ESC ) {
1073 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1076 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1077 if ((key_check == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) ||
1078 (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) ||
1079 (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER))
1080 gr_toggle_fullscreen();
1083 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1084 Briefing_text_x = bsp->text_ulx;
1085 Briefing_text_y += bsp->text_uly;
1088 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1094 if (printing_channel>-1)
1095 digi_stop_sound( printing_channel );
1096 printing_channel=-1;
1107 start_time = timer_get_fixed_seconds();
1108 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1110 if (_RedrawScreen) {
1111 _RedrawScreen = FALSE;
1112 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1118 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1120 flash_cursor(flashing_cursor);
1123 if (robot_num != -1)
1124 show_spinning_robot_frame(robot_num);
1125 if (Bitmap_name[0] != 0)
1126 show_bitmap_frame();
1127 start_time += KEY_DELAY_DEFAULT/2;
1136 if (keypress == KEY_BACKSP)
1139 if (keypress == KEY_ESC) {
1144 load_briefing_screen(screen_num);
1145 Briefing_text_x = bsp->text_ulx;
1146 Briefing_text_y = bsp->text_uly;
1147 delay_count = KEY_DELAY_DEFAULT;
1149 WIN(wpage_done = 0);
1158 if (Robot_canv != NULL)
1159 {d_free(Robot_canv); Robot_canv=NULL;}
1162 digi_stop_sound( hum_channel );
1163 if (printing_channel>-1)
1164 digi_stop_sound( printing_channel );
1166 if (Mission_list[Current_mission_num].descent_version == 1)
1172 //-----------------------------------------------------------------------------
1173 // Return a pointer to the start of text for screen #screen_num.
1174 char * get_briefing_message(int screen_num)
1176 char *tptr = Briefing_text;
1180 Assert(screen_num >= 0);
1182 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1187 cur_screen = get_message_num(&tptr);
1191 if (screen_num!=cur_screen)
1197 //-----------------------------------------------------------------------------
1198 // Load Descent briefing text.
1199 int load_screen_text(char *filename, char **buf)
1204 int have_binary = 0;
1206 if ((tfile = cfopen(filename,"rb")) == NULL) {
1207 char nfilename[30], *ptr;
1209 strcpy(nfilename, filename);
1210 ptr = strrchr(nfilename, '.');
1212 strcat(nfilename, ".txb");
1213 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1214 mprintf ((0,"can't open %s!\n",nfilename));
1216 //Error("Cannot open file %s or %s", filename, nfilename);
1219 mprintf ((0,"reading...\n"));
1222 len = cfilelength(ifile);
1223 MALLOC(*buf, char, len+500);
1224 mprintf ((0,"len=%d\n",len));
1225 for (x=0, i=0; i < len; i++, x++) {
1226 cfread (*buf+x,1,1,ifile);
1227 // mprintf ((0,"%c",*(*buf+x)));
1234 len = cfilelength(tfile);
1235 MALLOC(*buf, char, len+500);
1236 for (x=0, i=0; i < len; i++, x++) {
1237 cfread (*buf+x,1,1,tfile);
1238 // mprintf ((0,"%c",*(*buf+x)));
1244 //cfread(*buf, 1, len, tfile);
1251 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1253 encode_rotate_left(ptr);
1254 *ptr = *ptr ^ BITMAP_TBL_XOR;
1255 encode_rotate_left(ptr);
1263 //-----------------------------------------------------------------------------
1264 // Return true if message got aborted, else return false.
1265 int show_briefing_text(int screen_num)
1269 if (Mission_list[Current_mission_num].descent_version == 1)
1270 message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num);
1272 message_ptr = get_briefing_message(screen_num);
1273 if (message_ptr==NULL)
1276 DoBriefingColorStuff();
1278 return show_briefing_message(screen_num, message_ptr);
1281 void DoBriefingColorStuff ()
1283 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1284 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1286 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1287 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1289 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1290 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1292 if (Mission_list[Current_mission_num].descent_version == 1) {
1294 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1295 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1297 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1298 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1300 //Begin D1X addition
1302 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1303 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1306 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1307 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1309 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1310 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1312 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1313 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1315 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1316 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1319 Erase_color = gr_find_closest_color_current(0, 0, 0);
1322 //-----------------------------------------------------------------------------
1323 // Return true if screen got aborted by user, else return false.
1324 int show_briefing_screen( int screen_num, int allow_keys)
1327 //ubyte palette_save[768];
1329 New_pal_254_bash = 0;
1331 if (Skip_briefing_screens) {
1332 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1336 if (Mission_list[Current_mission_num].descent_version == 1) {
1339 grs_bitmap briefing_bm;
1341 gr_init_bitmap_data(&briefing_bm);
1342 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1344 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1346 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1347 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));
1353 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1354 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1356 //vfx_set_palette_sub( New_pal );
1358 gr_palette_load(New_pal);
1362 gr_set_current_canvas( NULL );
1363 show_fullscr(&briefing_bm);
1366 //added on 9/13/98 by adb to make arch's requiring updates work
1368 //end changes by adb
1371 gr_free_bitmap_data (&briefing_bm);
1374 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1377 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1382 key_close(); // kill the keyboard handler during briefing screens for movies
1384 rval = show_briefing_text(screen_num);
1389 #if defined (MACINTOSH) || defined(WINDOWS)
1390 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1395 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1398 DEFINE_SCREEN(NULL);
1399 WIN(DDGRLOCK(dd_grd_curcanv));
1400 gr_clear_canvas (0);
1401 WIN(DDGRUNLOCK(dd_grd_curcanv));
1402 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1406 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1408 //d_free(briefing_bm.bm_data);
1414 //-----------------------------------------------------------------------------
1415 void do_briefing_screens(char *filename,int level_num)
1417 int abort_briefing_screens = 0;
1418 int cur_briefing_screen = 0;
1420 if (Skip_briefing_screens) {
1421 mprintf((0, "Skipping all briefing screens.\n"));
1426 return; // no briefing screens at all for demo
1430 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1435 if (!load_screen_text(filename, &Briefing_text))
1439 songs_play_song( SONG_BRIEFING, 1 );
1444 set_screen_mode( SCREEN_MENU );
1447 dd_gr_set_current_canvas(NULL),
1448 gr_set_current_canvas(NULL)
1451 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1455 if (Mission_list[Current_mission_num].descent_version == 1) {
1456 if (level_num == 1) {
1457 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1458 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1459 cur_briefing_screen++;
1463 if (!abort_briefing_screens) {
1464 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1465 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1466 if (show_briefing_screen(cur_briefing_screen, 0))
1471 show_briefing_screen(level_num,0);
1473 d_free (Briefing_text);
1480 int DefineBriefingBox (char **buf)
1485 n=get_new_message_num (buf);
1487 Assert(n < MAX_BRIEFING_SCREENS);
1489 while (**buf!=' ') {
1494 name[i]='\0'; // slap a delimiter on this guy
1496 strcpy (Briefing_screens[n].bs_name,name);
1497 Briefing_screens[n].level_num=get_new_message_num (buf);
1498 Briefing_screens[n].message_num=get_new_message_num (buf);
1499 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1500 Briefing_screens[n].text_uly=get_new_message_num (buf);
1501 Briefing_screens[n].text_width=get_new_message_num (buf);
1502 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1504 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1505 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1506 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1507 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1512 int get_new_message_num(char **message)
1516 while (**message == ' ')
1519 while ((**message >= '0') && (**message <= '9')) {
1520 num = 10*num + **message-'0';