1 /* $Id: titles.c,v 1.20 2003-02-23 06:10:59 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 defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
1051 if (LineAdjustment==1)
1058 while ((fname[i]=*message) != '\n') {
1068 while (fname[i]!='.') {
1069 fname2[i] = fname[i];
1081 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
1082 load_new_briefing_screen (fname2);
1084 load_new_briefing_screen (fname);
1087 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1089 } else if (ch == 'B') {
1090 char bitmap_name[32];
1091 grs_bitmap guy_bitmap;
1092 ubyte temp_palette[768];
1095 if (Robot_canv != NULL) {
1100 get_message_name(&message, bitmap_name);
1101 strcat(bitmap_name, ".bbm");
1102 guy_bitmap.bm_data = NULL;
1103 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
1104 Assert(iff_error == IFF_NO_ERROR);
1105 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
1107 show_briefing_bitmap(&guy_bitmap);
1108 d_free(guy_bitmap.bm_data);
1110 // } else if (ch==EOF) {
1112 // } else if (ch == 'B') {
1113 // if (Robot_canv != NULL) {
1114 // d_free(Robot_canv);
1118 // bitmap_num = get_message_num(&message);
1119 // if (bitmap_num != -1)
1120 // show_briefing_bitmap(Textures[bitmap_num]);
1121 // prev_ch = 10; // read to eoln
1122 } else if (ch == 'S') {
1127 if (printing_channel>-1)
1128 digi_stop_sound( printing_channel );
1129 printing_channel=-1;
1138 start_time = timer_get_fixed_seconds();
1139 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1141 if (_RedrawScreen) {
1142 _RedrawScreen = FALSE;
1143 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1149 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1151 flash_cursor(flashing_cursor);
1157 show_spinning_robot_frame(robot_num);
1160 show_bitmap_frame();
1161 start_time += KEY_DELAY_DEFAULT/2;
1165 if (keypress == KEY_BACKSP)
1168 if (keypress == KEY_ESC)
1171 flashing_cursor = 0;
1173 WIN(wpage_done = 0);
1174 } else if (ch == 'P') { // New page.
1176 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1177 // printing to it! You know, $Z !!!
1178 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1182 while (*message != 10) {
1183 message++; // drop carriage return after special escape sequence
1189 } else if (ch == '\t') { // Tab
1190 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1191 Briefing_text_x = bsp->text_ulx + tab_stop;
1192 } else if ((ch == ';') && (prev_ch == 10)) {
1193 while (*message++ != 10)
1196 } else if (ch == '\\') {
1198 } else if (ch == 10) {
1199 if (prev_ch != '\\') {
1201 if (1) //DumbAdjust==0)
1202 Briefing_text_y += (8*(MenuHires+1));
1205 Briefing_text_x = bsp->text_ulx;
1206 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1207 load_briefing_screen(screen_num);
1208 Briefing_text_x = bsp->text_ulx;
1209 Briefing_text_y = bsp->text_uly;
1212 if (ch == 13) //Can this happen? Above says ch==10
1219 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1220 // printing to it! You know, $Z !!!
1221 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1227 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1231 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1233 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1237 // Check for Esc -> abort.
1239 key_check=local_key_inkey();
1244 if (_RedrawScreen) {
1245 _RedrawScreen = FALSE;
1246 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1247 key_check = KEY_ESC;
1250 if ( key_check == KEY_ESC ) {
1255 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1258 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1259 if ((key_check == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) ||
1260 (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) ||
1261 (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER))
1262 gr_toggle_fullscreen();
1265 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1266 Briefing_text_x = bsp->text_ulx;
1267 Briefing_text_y += bsp->text_uly;
1270 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1276 if (printing_channel>-1)
1277 digi_stop_sound( printing_channel );
1278 printing_channel=-1;
1289 start_time = timer_get_fixed_seconds();
1290 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1292 if (_RedrawScreen) {
1293 _RedrawScreen = FALSE;
1294 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1300 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1302 flash_cursor(flashing_cursor);
1307 show_spinning_robot_frame(robot_num);
1309 show_bitmap_frame();
1310 start_time += KEY_DELAY_DEFAULT/2;
1321 if (keypress == KEY_BACKSP)
1324 if (keypress == KEY_ESC) {
1329 load_briefing_screen(screen_num);
1330 Briefing_text_x = bsp->text_ulx;
1331 Briefing_text_y = bsp->text_uly;
1332 delay_count = KEY_DELAY_DEFAULT;
1334 WIN(wpage_done = 0);
1345 if (Robot_canv != NULL)
1346 {d_free(Robot_canv); Robot_canv=NULL;}
1349 digi_stop_sound( hum_channel );
1350 if (printing_channel>-1)
1351 digi_stop_sound( printing_channel );
1356 //-----------------------------------------------------------------------------
1357 // Return a pointer to the start of text for screen #screen_num.
1358 char * get_briefing_message(int screen_num)
1360 char *tptr = Briefing_text;
1364 Assert(screen_num >= 0);
1366 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1371 cur_screen = get_message_num(&tptr);
1375 if (screen_num!=cur_screen)
1381 //-----------------------------------------------------------------------------
1382 // Load Descent briefing text.
1383 int load_screen_text(char *filename, char **buf)
1388 int have_binary = 0;
1390 if ((tfile = cfopen(filename,"rb")) == NULL) {
1391 char nfilename[30], *ptr;
1393 strcpy(nfilename, filename);
1394 ptr = strrchr(nfilename, '.');
1396 strcat(nfilename, ".txb");
1397 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1398 mprintf ((0,"can't open %s!\n",nfilename));
1400 //Error("Cannot open file %s or %s", filename, nfilename);
1403 mprintf ((0,"reading...\n"));
1406 len = cfilelength(ifile);
1407 MALLOC(*buf, char, len+500);
1408 mprintf ((0,"len=%d\n",len));
1409 for (x=0, i=0; i < len; i++, x++) {
1410 cfread (*buf+x,1,1,ifile);
1411 // mprintf ((0,"%c",*(*buf+x)));
1418 len = cfilelength(tfile);
1419 MALLOC(*buf, char, len+500);
1420 for (x=0, i=0; i < len; i++, x++) {
1421 cfread (*buf+x,1,1,tfile);
1422 // mprintf ((0,"%c",*(*buf+x)));
1428 //cfread(*buf, 1, len, tfile);
1435 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1437 encode_rotate_left(ptr);
1438 *ptr = *ptr ^ BITMAP_TBL_XOR;
1439 encode_rotate_left(ptr);
1447 //-----------------------------------------------------------------------------
1448 // Return true if message got aborted, else return false.
1449 int show_briefing_text(int screen_num)
1453 message_ptr = get_briefing_message(screen_num);
1454 if (message_ptr==NULL)
1457 DoBriefingColorStuff();
1459 if (Mission_list[Current_mission_num].descent_version == 1)
1460 return show_d1_briefing_message(screen_num, message_ptr);
1462 return show_briefing_message(screen_num, message_ptr);
1465 void DoBriefingColorStuff ()
1467 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1468 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1470 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1471 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1473 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1474 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1476 Erase_color = gr_find_closest_color_current(0, 0, 0);
1479 //-----------------------------------------------------------------------------
1480 // Return true if screen got aborted by user, else return false.
1481 int show_briefing_screen( int screen_num, int allow_keys)
1484 ubyte palette_save[768];
1486 New_pal_254_bash = 0;
1488 if (Skip_briefing_screens) {
1489 mprintf((0, "Skipping briefing screen [brief03.pcx]\n"));
1493 // briefing_bm.bm_data=NULL;
1494 // if ((pcx_error=pcx_read_bitmap( "brief03.pcx", &briefing_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
1495 // 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));
1500 memcpy(palette_save,gr_palette,sizeof(palette_save));
1501 memcpy(New_pal,gr_palette,sizeof(gr_palette));
1504 // vfx_set_palette_sub( New_pal );
1505 // gr_palette_clear();
1506 // gr_bitmap( 0, 0, &briefing_bm );
1508 gr_palette_load(New_pal);
1511 // if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1513 // memcpy(gr_palette,New_pal,sizeof(gr_palette));
1516 key_close(); // kill the keyboard handler during briefing screens for movies
1518 rval = show_briefing_text(screen_num);
1523 #if defined (MACINTOSH) || defined(WINDOWS)
1524 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1529 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1532 DEFINE_SCREEN(NULL);
1533 WIN(DDGRLOCK(dd_grd_curcanv));
1534 gr_clear_canvas (0);
1535 WIN(DDGRUNLOCK(dd_grd_curcanv));
1536 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1540 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1542 // d_free(briefing_bm.bm_data);
1548 //-----------------------------------------------------------------------------
1549 void do_briefing_screens(char *filename,int level_num)
1551 int abort_briefing_screens = 0;
1552 int cur_briefing_screen = 0;
1554 if (Skip_briefing_screens) {
1555 mprintf((0, "Skipping all briefing screens.\n"));
1560 return; // no briefing screens at all for demo
1564 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1569 if (!load_screen_text(filename, &Briefing_text))
1573 songs_play_song( SONG_BRIEFING, 1 );
1578 set_screen_mode( SCREEN_MENU );
1581 dd_gr_set_current_canvas(NULL),
1582 gr_set_current_canvas(NULL)
1585 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1589 if (Mission_list[Current_mission_num].descent_version == 1) {
1590 if (level_num == 1) {
1591 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1592 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1593 cur_briefing_screen++;
1597 if (!abort_briefing_screens) {
1598 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1599 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1600 if (show_briefing_screen(cur_briefing_screen, 0))
1605 show_briefing_screen(level_num,0);
1607 d_free (Briefing_text);
1614 int DefineBriefingBox (char **buf)
1619 n=get_new_message_num (buf);
1621 Assert(n < MAX_BRIEFING_SCREENS);
1623 while (**buf!=' ') {
1628 name[i]='\0'; // slap a delimiter on this guy
1630 strcpy (Briefing_screens[n].bs_name,name);
1631 Briefing_screens[n].level_num=get_new_message_num (buf);
1632 Briefing_screens[n].message_num=get_new_message_num (buf);
1633 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1634 Briefing_screens[n].text_uly=get_new_message_num (buf);
1635 Briefing_screens[n].text_width=get_new_message_num (buf);
1636 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1639 Briefing_screens[n].text_ulx*=2;
1640 Briefing_screens[n].text_uly*=2.4;
1641 Briefing_screens[n].text_width*=2;
1642 Briefing_screens[n].text_height*=2.4;
1648 int get_new_message_num(char **message)
1652 while (**message == ' ')
1655 while ((**message >= '0') && (**message <= '9')) {
1656 num = 10*num + **message-'0';