1 /* $Id: titles.c,v 1.21 2003-02-24 12:03:16 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.
33 #include "pa_enabl.h" //$$POLY_ACC
70 void DoBriefingColorStuff ();
71 int get_new_message_num(char **message);
72 int DefineBriefingBox (char **buf);
74 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
79 char CurBriefScreenName[15]="brief03.pcx";
85 #define MAX_BRIEFING_COLORS 3
87 // Descent 1 briefings
88 char Ending_text_filename[13] = "\0";
89 char Briefing_text_filename[13] = "\0";
91 #define SHAREWARE_ENDING_FILENAME "ending.tex"
93 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
94 int Skip_briefing_screens=0;
95 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
96 int Current_color = 0;
99 extern int check_button_press();
102 extern void macintosh_quit(void);
105 static int rescale_x(int x)
107 return x * GWIDTH / 320;
110 static int rescale_y(int y)
112 return y * GHEIGHT / 200;
116 int local_key_inkey(void)
123 DoMessageStuff(&msg);
128 if (rval == KEY_PRINT_SCREEN) {
132 gr_palette_read(gr_palette);
133 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
138 return 0; //say no key pressed
141 if (check_button_press()) //joystick or mouse button pressed?
145 if ( rval == KEY_Q+KEY_COMMAND )
152 int local_key_inkey(void)
157 if (!GetOSEvent(everyEvent, &event))
160 if (event.what != keyDown)
163 rval = (int)((event.message & keyCodeMask) >> 8);
165 if (rval == KEY_PRINT_SCREEN) {
167 return 0; //say no key pressed
170 if (check_button_press()) //joystick or mouse button pressed?
174 if ( rval == KEY_Q+KEY_COMMAND )
182 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
187 ubyte palette_save[768];
188 char new_filename[FILENAME_LEN+1] = "";
192 strcpy(new_filename,"\x01"); //only read from hog file
195 strcat(new_filename,filename);
196 filename = new_filename;
198 title_bm.bm_data=NULL;
199 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
200 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
201 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));
202 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
205 memcpy(palette_save,gr_palette,sizeof(palette_save));
207 #if defined(POLY_ACC)
209 pa_update_clut(New_pal, 0, 256, 0);
212 //vfx_set_palette_sub( New_pal );
214 gr_palette_load( New_pal );
220 dd_gr_set_current_canvas(NULL),
221 gr_set_current_canvas( NULL )
223 WIN(DDGRLOCK(dd_grd_curcanv));
224 show_fullscr(&title_bm);
225 WIN(DDGRUNLOCK(dd_grd_curcanv));
229 #if defined(POLY_ACC)
233 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
235 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
237 gr_palette_load( New_pal );
238 timer = timer_get_fixed_seconds() + i2f(3);
240 if ( local_key_inkey() && allow_keys ) break;
241 if ( timer_get_fixed_seconds() > timer ) break;
243 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
245 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
246 d_free(title_bm.bm_data);
251 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
254 short text_ulx, text_uly; // upper left x,y of text window
255 short text_width, text_height; // width and height of text window
258 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
259 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
261 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
262 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
265 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
267 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
270 #define MAX_BRIEFING_SCREENS 60
272 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
273 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
275 int Briefing_text_x, Briefing_text_y;
277 void init_char_pos(int x, int y)
281 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
284 grs_canvas *Robot_canv = NULL;
285 vms_angvec Robot_angles;
287 char Bitmap_name[32] = "";
288 #define EXIT_DOOR_MAX 14
289 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
290 #define DOOR_DIV_INIT 6
291 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
293 //-----------------------------------------------------------------------------
294 void show_bitmap_frame(void)
297 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
299 grs_canvas *curcanv_save, *bitmap_canv=0;
302 grs_bitmap *bitmap_ptr;
304 // Only plot every nth frame.
305 if (Door_div_count) {
310 Door_div_count = DOOR_DIV_INIT;
312 if (Bitmap_name[0] != 0) {
316 // Set supertransparency color to black
317 if (!New_pal_254_bash) {
318 New_pal_254_bash = 1;
320 New_pal[254*3+1] = 0;
321 New_pal[254*3+2] = 0;
322 gr_palette_load( New_pal );
325 switch (Animating_bitmap_type) {
328 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
329 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
333 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
334 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
337 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
339 Int3(); // Impossible, illegal value for Animating_bitmap_type
343 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
344 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
347 pound_signp = strchr(Bitmap_name, '#');
348 Assert(pound_signp != NULL);
350 dig1 = *(pound_signp+1);
351 dig2 = *(pound_signp+2);
355 num = (dig1-'0')*10 + (dig2-'0');
357 switch (Animating_bitmap_type) {
360 if (num > EXIT_DOOR_MAX) {
363 } else if (num < 0) {
370 if (num > OTHER_THING_MAX)
377 *(pound_signp+1) = (num / 10) + '0';
378 *(pound_signp+2) = (num % 10) + '0';
379 *(pound_signp+3) = 0;
381 *(pound_signp+1) = (num % 10) + '0';
382 *(pound_signp+2) = 0;
387 bi = piggy_find_bitmap(Bitmap_name);
388 bitmap_ptr = &GameBitmaps[bi.index];
392 WIN(DDGRLOCK(dd_grd_curcanv));
393 gr_bitmapm(0, 0, bitmap_ptr);
394 WIN(DDGRUNLOCK(dd_grd_curcanv));
397 dd_grd_curcanv = curcanv_save,
398 grd_curcanv = curcanv_save
402 switch (Animating_bitmap_type) {
404 if (num == EXIT_DOOR_MAX) {
407 } else if (num == 0) {
419 //-----------------------------------------------------------------------------
420 void show_briefing_bitmap(grs_bitmap *bmp)
423 dd_grs_canvas *bitmap_canv, *curcanv_save;
425 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
426 curcanv_save = dd_grd_curcanv;
427 dd_gr_set_current_canvas(bitmap_canv);
428 DDGRLOCK(dd_grd_curcanv);
430 DDGRUNLOCK(dd_grd_curcanv);
431 dd_gr_set_current_canvas(curcanv_save);
433 grs_canvas *curcanv_save, *bitmap_canv;
435 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
436 curcanv_save = grd_curcanv;
437 gr_set_current_canvas(bitmap_canv);
438 gr_bitmapm(0, 0, bmp);
439 gr_set_current_canvas(curcanv_save);
446 //-----------------------------------------------------------------------------
447 void show_spinning_robot_frame(int robot_num)
449 grs_canvas *curcanv_save;
451 if (robot_num != -1) {
452 Robot_angles.h += 150;
454 curcanv_save = grd_curcanv;
455 grd_curcanv = Robot_canv;
456 Assert(Robot_info[robot_num].model_num != -1);
457 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
458 grd_curcanv = curcanv_save;
463 //-----------------------------------------------------------------------------
464 void init_spinning_robot(void) //(int x,int y,int w,int h)
472 int x = rescale_x(138);
473 int y = rescale_y(55);
474 int w = rescale_x(166);
475 int h = rescale_y(138);
478 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
483 //---------------------------------------------------------------------------
484 // Returns char width.
485 // If show_robot_flag set, then show a frame of the spinning robot.
486 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
490 static fix start_time=0;
493 message[0] = the_char;
496 if (start_time==0 && timer_get_fixed_seconds()<0)
497 start_time=timer_get_fixed_seconds();
499 gr_get_string_size(message, &w, &h, &aw );
501 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
503 // Draw cursor if there is some delay and caller says to draw cursor
504 if (cursor_flag && delay) {
505 WIN(DDGRLOCK(dd_grd_curcanv));
506 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
507 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
508 WIN(DDGRUNLOCK(dd_grd_curcanv));
512 delay=fixdiv (F1_0,i2f(15));
518 if (RobotPlaying && (delay != 0))
521 while (timer_get_fixed_seconds() < (start_time + delay)) {
522 if (RobotPlaying && delay != 0)
527 show_spinning_robot_frame(robot_num);
530 start_time = timer_get_fixed_seconds();
532 WIN(DDGRLOCK(dd_grd_curcanv));
534 if (cursor_flag && delay) {
535 gr_set_fontcolor(Erase_color, -1);
536 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
539 // Draw the character
540 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
541 gr_printf(Briefing_text_x, Briefing_text_y, message );
543 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
544 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
545 WIN(DDGRUNLOCK(dd_grd_curcanv));
547 if (delay) gr_update();
549 // if (the_char != ' ')
550 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
551 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
556 //-----------------------------------------------------------------------------
557 int load_briefing_screen( int screen_num )
561 WIN(DDGRLOCK(dd_grd_curcanv));
562 if ((pcx_error=pcx_read_fullscr( CurBriefScreenName, New_pal ))!=PCX_ERROR_NONE) {
563 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error));
564 printf( "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n",Briefing_screens[screen_num].bs_name, pcx_errormsg(pcx_error), pcx_error);
565 WIN(DDGRUNLOCK(dd_grd_curcanv));
566 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",CurBriefScreenName, pcx_errormsg(pcx_error), pcx_error);
568 WIN(DDGRUNLOCK(dd_grd_curcanv));
575 int load_new_briefing_screen( char *fname )
579 mprintf ((0,"Loading new briefing <%s>\n",fname));
580 strcpy (CurBriefScreenName,fname);
582 //WIN(DEFINE_SCREEN(CurBriefScreenName));
584 if (gr_palette_fade_out( New_pal, 32, 0 ))
587 WIN(DDGRLOCK(dd_grd_curcanv));
588 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
589 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
590 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);
591 WIN(DDGRUNLOCK(dd_grd_curcanv));
592 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
594 WIN(DDGRUNLOCK(dd_grd_curcanv));
598 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
600 if (gr_palette_fade_in( New_pal, 32, 0 ))
602 DoBriefingColorStuff();
609 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
611 //-----------------------------------------------------------------------------
612 int get_message_num(char **message)
616 while (**message == ' ')
619 while ((**message >= '0') && (**message <= '9')) {
620 num = 10*num + **message-'0';
624 while (*(*message)++ != 10) // Get and drop eoln
630 //-----------------------------------------------------------------------------
631 void get_message_name(char **message, char *result)
633 while (**message == ' ')
636 while ((**message != ' ') && (**message != 10)) {
637 if (**message != '\n')
638 *result++ = **message;
643 while (*(*message)++ != 10) // Get and drop eoln
649 //-----------------------------------------------------------------------------
650 void flash_cursor(int cursor_flag)
652 if (cursor_flag == 0)
655 WIN(DDGRLOCK(dd_grd_curcanv));
656 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
657 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
659 gr_set_fontcolor(Erase_color, -1);
661 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
662 WIN(DDGRUNLOCK(dd_grd_curcanv));
665 extern int InitMovieBriefing();
667 //-----------------------------------------------------------------------------
668 // Return true if message got aborted by user (pressed ESC), else return false.
669 int show_d1_briefing_message(int screen_num, char *message)
673 briefing_screen *bsp = &Briefing_screens[screen_num];
674 int delay_count = KEY_DELAY_DEFAULT;
679 int flashing_cursor=0;
681 int text_ulx = rescale_x(bsp->text_ulx);
682 int text_uly = rescale_y(bsp->text_uly);
688 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
689 gr_set_curfont( GAME_FONT );
691 init_char_pos(text_ulx, text_uly);
698 Current_color = get_message_num(&message)-1;
699 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
701 } else if (ch == 'F') { // toggle flashing cursor
702 flashing_cursor = !flashing_cursor;
704 while (*message++ != 10)
706 } else if (ch == 'T') {
707 tab_stop = get_message_num(&message);
708 prev_ch = 10; // read to eoln
709 } else if (ch == 'R') {
710 if (Robot_canv != NULL)
711 {free(Robot_canv); Robot_canv=NULL;}
713 init_spinning_robot();
714 robot_num = get_message_num(&message);
715 prev_ch = 10; // read to eoln
716 } else if (ch == 'N') {
717 //--grs_bitmap *bitmap_ptr;
718 if (Robot_canv != NULL)
719 {free(Robot_canv); Robot_canv=NULL;}
721 get_message_name(&message, Bitmap_name);
722 strcat(Bitmap_name, "#0");
723 Animating_bitmap_type = 0;
725 } else if (ch == 'O') {
726 if (Robot_canv != NULL)
727 {free(Robot_canv); Robot_canv=NULL;}
729 get_message_name(&message, Bitmap_name);
730 strcat(Bitmap_name, "#0");
731 Animating_bitmap_type = 1;
733 } else if (ch == 'B') {
734 char bitmap_name[32];
735 grs_bitmap guy_bitmap;
736 ubyte temp_palette[768];
739 if (Robot_canv != NULL)
740 {free(Robot_canv); Robot_canv=NULL;}
742 get_message_name(&message, bitmap_name);
743 strcat(bitmap_name, ".bbm");
744 gr_init_bitmap_data (&guy_bitmap);
745 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
746 Assert(iff_error == IFF_NO_ERROR);
748 show_briefing_bitmap(&guy_bitmap);
749 gr_free_bitmap_data (&guy_bitmap);
751 // } else if (ch == 'B') {
752 // if (Robot_canv != NULL)
753 // {free(Robot_canv); Robot_canv=NULL;}
755 // bitmap_num = get_message_num(&message);
756 // if (bitmap_num != -1)
757 // show_briefing_bitmap(Textures[bitmap_num]);
758 // prev_ch = 10; // read to eoln
759 } else if (ch == 'S') {
764 start_time = timer_get_fixed_seconds();
765 start_time = timer_get_approx_seconds();
766 time_out_value = start_time + i2f(60*5); // Wait 1 minute...
768 //added on 9/13/98 by adb to make arch's requiring updates work
772 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
773 if ( timer_get_approx_seconds() > time_out_value ) {
775 break; // Time out after 1 minute..
777 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
779 flash_cursor(flashing_cursor);
780 show_spinning_robot_frame(robot_num);
783 //added on 9/13/98 by adb to make arch's requiring updates work
787 start_time += KEY_DELAY_DEFAULT/2;
791 if (keypress == KEY_BACKSP)
794 if (keypress == KEY_ESC)
799 } else if (ch == 'P') { // New page.
801 while (*message != 10) {
802 message++; // drop carriage return after special escape sequence
807 } else if (ch == '$' || ch == ';') { // Print a $/;
809 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
813 } else if (ch == '\t') { // Tab
814 if (Briefing_text_x - text_ulx < tab_stop)
815 Briefing_text_x = text_ulx + tab_stop;
816 } else if ((ch == ';') && (prev_ch == 10)) {
817 while (*message++ != 10)
820 } else if (ch == '\\') {
822 } else if (ch == 10) {
823 if (prev_ch != '\\') {
825 Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5;
826 Briefing_text_x = text_ulx;
827 if (Briefing_text_y > text_uly + rescale_y(bsp->text_height)) {
828 load_briefing_screen(screen_num);
829 Briefing_text_x = text_ulx;
830 Briefing_text_y = text_uly;
839 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
842 //added/changed on 9/13/98 by adb to speed up briefings after pressing a key with SDL
843 // Check for Esc -> abort.
845 key_check=local_key_inkey();
849 if ( key_check == KEY_ESC ) {
855 if ( key_check == KEY_ALTED+KEY_F2 )
859 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
862 if (Briefing_text_x > text_ulx + rescale_x(bsp->text_width)) {
863 Briefing_text_x = text_ulx;
864 Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5;
867 if ((new_page) || (Briefing_text_y > text_uly + rescale_y(bsp->text_height))) {
869 fix time_out_value = 0;
873 start_time = timer_get_approx_seconds();
874 time_out_value = start_time + i2f(60*5); // Wait 1 minute...
876 //added on 9/13/98 by adb to make arch's requiring updates work
880 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
881 if ( timer_get_approx_seconds() > time_out_value ) {
883 break; // Time out after 1 minute..
885 while (timer_get_approx_seconds() < start_time + KEY_DELAY_DEFAULT/2)
887 flash_cursor(flashing_cursor);
888 show_spinning_robot_frame(robot_num);
891 //added on 9/13/98 by adb to make arch's requiring updates work
895 start_time += KEY_DELAY_DEFAULT/2;
901 if (keypress == KEY_BACKSP)
904 if (keypress == KEY_ESC) {
909 load_briefing_screen(screen_num);
910 Briefing_text_x = text_ulx;
911 Briefing_text_y = text_uly;
912 delay_count = KEY_DELAY_DEFAULT;
916 if (Robot_canv != NULL)
917 {free(Robot_canv); Robot_canv=NULL;}
922 //-----------------------------------------------------------------------------
923 // Return true if message got aborted by user (pressed ESC), else return false.
924 int show_briefing_message(int screen_num, char *message)
928 briefing_screen *bsp = &Briefing_screens[screen_num];
929 int delay_count = KEY_DELAY_DEFAULT;
933 static int tab_stop=0;
934 int flashing_cursor=0;
935 int new_page=0,GotZ=0;
937 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
942 int hum_channel=-1,printing_channel=-1;
943 int LineAdjustment=1;
944 WIN(int wpage_done=0);
955 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
958 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
959 gr_set_curfont( GAME_FONT );
961 bsp=&Briefing_screens[0];
962 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
969 screen_num=DefineBriefingBox (&message);
970 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
972 bsp = &Briefing_screens[screen_num];
973 init_char_pos(bsp->text_ulx, bsp->text_uly);
975 prev_ch = 10; // read to eoln
976 } else if (ch=='U') {
977 screen_num=get_message_num(&message);
978 bsp = &Briefing_screens[screen_num];
979 init_char_pos(bsp->text_ulx, bsp->text_uly);
980 prev_ch = 10; // read to eoln
981 } else if (ch == 'C') {
982 Current_color = get_message_num(&message)-1;
983 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
985 } else if (ch == 'F') { // toggle flashing cursor
986 flashing_cursor = !flashing_cursor;
988 while (*message++ != 10)
990 } else if (ch == 'T') {
991 tab_stop = get_message_num(&message);
992 tab_stop*=(1+MenuHires);
993 prev_ch = 10; // read to eoln
994 } else if (ch == 'R') {
995 if (Robot_canv != NULL) {
1006 spinRobotName[2]=kludge; // ugly but proud
1008 RobotPlaying=InitRobotMovie(spinRobotName);
1010 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
1014 DoBriefingColorStuff ();
1015 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
1018 init_spinning_robot();
1019 robot_num = get_message_num(&message);
1021 prev_ch = 10; // read to eoln
1022 } else if (ch == 'N') {
1023 //--grs_bitmap *bitmap_ptr;
1024 if (Robot_canv != NULL) {
1029 get_message_name(&message, Bitmap_name);
1030 strcat(Bitmap_name, "#0");
1031 Animating_bitmap_type = 0;
1033 } else if (ch == 'O') {
1034 if (Robot_canv != NULL) {
1039 get_message_name(&message, Bitmap_name);
1040 strcat(Bitmap_name, "#0");
1041 Animating_bitmap_type = 1;
1043 } else if (ch=='A') {
1044 LineAdjustment=1-LineAdjustment;
1045 } else if (ch=='Z') {
1046 //mprintf ((0,"Got a Z!\n"));
1048 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
1051 if (LineAdjustment==1)
1058 while ((fname[i]=*message) != '\n') {
1064 while (*message++ != 10) // Get and drop eoln
1071 while (fname[i]!='.') {
1072 fname2[i] = fname[i];
1084 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
1085 load_new_briefing_screen (fname2);
1087 load_new_briefing_screen (fname);
1090 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1092 } else if (ch == 'B') {
1093 char bitmap_name[32];
1094 grs_bitmap guy_bitmap;
1095 ubyte temp_palette[768];
1098 if (Robot_canv != NULL) {
1103 get_message_name(&message, bitmap_name);
1104 strcat(bitmap_name, ".bbm");
1105 guy_bitmap.bm_data = NULL;
1106 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
1107 Assert(iff_error == IFF_NO_ERROR);
1108 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
1110 show_briefing_bitmap(&guy_bitmap);
1111 d_free(guy_bitmap.bm_data);
1113 // } else if (ch==EOF) {
1115 // } else if (ch == 'B') {
1116 // if (Robot_canv != NULL) {
1117 // d_free(Robot_canv);
1121 // bitmap_num = get_message_num(&message);
1122 // if (bitmap_num != -1)
1123 // show_briefing_bitmap(Textures[bitmap_num]);
1124 // prev_ch = 10; // read to eoln
1125 } else if (ch == 'S') {
1130 if (printing_channel>-1)
1131 digi_stop_sound( printing_channel );
1132 printing_channel=-1;
1143 start_time = timer_get_fixed_seconds();
1144 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1146 if (_RedrawScreen) {
1147 _RedrawScreen = FALSE;
1148 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1154 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1156 flash_cursor(flashing_cursor);
1162 show_spinning_robot_frame(robot_num);
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_CTRLED+KEY_SHIFTED+KEY_PADENTER) ||
1265 (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) ||
1266 (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER))
1267 gr_toggle_fullscreen();
1270 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1271 Briefing_text_x = bsp->text_ulx;
1272 Briefing_text_y += bsp->text_uly;
1275 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1281 if (printing_channel>-1)
1282 digi_stop_sound( printing_channel );
1283 printing_channel=-1;
1294 start_time = timer_get_fixed_seconds();
1295 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1297 if (_RedrawScreen) {
1298 _RedrawScreen = FALSE;
1299 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1305 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1307 flash_cursor(flashing_cursor);
1312 show_spinning_robot_frame(robot_num);
1314 show_bitmap_frame();
1315 start_time += KEY_DELAY_DEFAULT/2;
1326 if (keypress == KEY_BACKSP)
1329 if (keypress == KEY_ESC) {
1334 load_briefing_screen(screen_num);
1335 Briefing_text_x = bsp->text_ulx;
1336 Briefing_text_y = bsp->text_uly;
1337 delay_count = KEY_DELAY_DEFAULT;
1339 WIN(wpage_done = 0);
1350 if (Robot_canv != NULL)
1351 {d_free(Robot_canv); Robot_canv=NULL;}
1354 digi_stop_sound( hum_channel );
1355 if (printing_channel>-1)
1356 digi_stop_sound( printing_channel );
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 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 message_ptr = get_briefing_message(screen_num);
1459 if (message_ptr==NULL)
1462 DoBriefingColorStuff();
1464 if (Mission_list[Current_mission_num].descent_version == 1)
1465 return show_d1_briefing_message(screen_num, message_ptr);
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 Erase_color = gr_find_closest_color_current(0, 0, 0);
1484 //-----------------------------------------------------------------------------
1485 // Return true if screen got aborted by user, else return false.
1486 int show_briefing_screen( int screen_num, int allow_keys)
1489 ubyte palette_save[768];
1491 New_pal_254_bash = 0;
1493 if (Skip_briefing_screens) {
1494 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1498 // briefing_bm.bm_data=NULL;
1499 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1500 // mprintf((0, "File '%s', PCX load error: %s (%i)\n (It's a briefing screen. Does this cause you pain?)\n","Brief03.pcx", pcx_errormsg(pcx_error), pcx_error));
1505 memcpy(palette_save,gr_palette,sizeof(palette_save));
1506 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1509 // vfx_set_palette_sub( New_pal );
1510 // gr_palette_clear();
1511 // gr_bitmap( 0, 0, &briefing_bm );
1513 gr_palette_load(New_pal);
1516 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1518 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1521 key_close(); // kill the keyboard handler during briefing screens for movies
1523 rval = show_briefing_text(screen_num);
1528 #if defined (MACINTOSH) || defined(WINDOWS)
1529 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1534 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1537 DEFINE_SCREEN(NULL);
1538 WIN(DDGRLOCK(dd_grd_curcanv));
1539 gr_clear_canvas (0);
1540 WIN(DDGRUNLOCK(dd_grd_curcanv));
1541 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1545 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1547 // d_free(briefing_bm.bm_data);
1553 //-----------------------------------------------------------------------------
1554 void do_briefing_screens(char *filename,int level_num)
1556 int abort_briefing_screens = 0;
1557 int cur_briefing_screen = 0;
1559 if (Skip_briefing_screens) {
1560 mprintf((0, "Skipping all briefing screens.\n"));
1565 return; // no briefing screens at all for demo
1569 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1574 if (!load_screen_text(filename, &Briefing_text))
1578 songs_play_song( SONG_BRIEFING, 1 );
1583 set_screen_mode( SCREEN_MENU );
1586 dd_gr_set_current_canvas(NULL),
1587 gr_set_current_canvas(NULL)
1590 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1594 if (Mission_list[Current_mission_num].descent_version == 1) {
1595 if (level_num == 1) {
1596 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1597 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1598 cur_briefing_screen++;
1602 if (!abort_briefing_screens) {
1603 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1604 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1605 if (show_briefing_screen(cur_briefing_screen, 0))
1610 show_briefing_screen(level_num,0);
1612 d_free (Briefing_text);
1619 int DefineBriefingBox (char **buf)
1624 n=get_new_message_num (buf);
1626 Assert(n < MAX_BRIEFING_SCREENS);
1628 while (**buf!=' ') {
1633 name[i]='\0'; // slap a delimiter on this guy
1635 strcpy (Briefing_screens[n].bs_name,name);
1636 Briefing_screens[n].level_num=get_new_message_num (buf);
1637 Briefing_screens[n].message_num=get_new_message_num (buf);
1638 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1639 Briefing_screens[n].text_uly=get_new_message_num (buf);
1640 Briefing_screens[n].text_width=get_new_message_num (buf);
1641 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1644 Briefing_screens[n].text_ulx*=2;
1645 Briefing_screens[n].text_uly*=2.4;
1646 Briefing_screens[n].text_width*=2;
1647 Briefing_screens[n].text_height*=2.4;
1653 int get_new_message_num(char **message)
1657 while (**message == ' ')
1660 while ((**message >= '0') && (**message <= '9')) {
1661 num = 10*num + **message-'0';