1 /* $Id: titles.c,v 1.23 2003-02-26 11:09:19 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 static int rescale_x(int x)
103 return x * GWIDTH / 320;
106 static int rescale_y(int y)
108 return y * GHEIGHT / 200;
112 int local_key_inkey(void)
119 DoMessageStuff(&msg);
124 if (rval == KEY_PRINT_SCREEN) {
127 gr_palette_read(gr_palette);
128 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
132 return 0; //say no key pressed
135 if (check_button_press()) //joystick or mouse button pressed?
139 if ( rval == KEY_Q+KEY_COMMAND )
146 int local_key_inkey(void)
151 if (!GetOSEvent(everyEvent, &event))
154 if (event.what != keyDown)
157 rval = (int)((event.message & keyCodeMask) >> 8);
159 if (rval == KEY_PRINT_SCREEN) {
161 return 0; //say no key pressed
164 if (check_button_press()) //joystick or mouse button pressed?
168 if ( rval == KEY_Q+KEY_COMMAND )
176 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
181 ubyte palette_save[768];
182 char new_filename[FILENAME_LEN+1] = "";
186 strcpy(new_filename,"\x01"); //only read from hog file
189 strcat(new_filename,filename);
190 filename = new_filename;
192 title_bm.bm_data=NULL;
193 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
194 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
195 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));
196 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
199 memcpy(palette_save,gr_palette,sizeof(palette_save));
201 #if defined(POLY_ACC)
203 pa_update_clut(New_pal, 0, 256, 0);
206 //vfx_set_palette_sub( New_pal );
208 gr_palette_load( New_pal );
214 dd_gr_set_current_canvas(NULL),
215 gr_set_current_canvas( NULL )
217 WIN(DDGRLOCK(dd_grd_curcanv));
218 show_fullscr(&title_bm);
219 WIN(DDGRUNLOCK(dd_grd_curcanv));
223 #if defined(POLY_ACC)
227 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
229 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
231 gr_palette_load( New_pal );
232 timer = timer_get_fixed_seconds() + i2f(3);
234 if ( local_key_inkey() && allow_keys ) break;
235 if ( timer_get_fixed_seconds() > timer ) break;
237 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
239 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
240 d_free(title_bm.bm_data);
245 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
248 short text_ulx, text_uly; // upper left x,y of text window
249 short text_width, text_height; // width and height of text window
252 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
253 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
255 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
256 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
259 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
261 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
264 #define MAX_BRIEFING_SCREENS 60
267 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
268 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
270 briefing_screen Briefing_screens[] = {
271 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
272 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
273 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
274 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
276 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
277 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
278 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
280 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
281 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
283 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
284 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
285 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
288 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
289 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
290 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
291 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
292 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
294 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
295 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
296 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
297 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
298 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
300 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
301 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
302 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
303 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
304 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
306 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
307 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
308 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
309 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
311 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
312 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
313 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
315 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
316 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
317 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
319 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
320 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
321 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
324 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
326 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
327 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
328 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
335 int Briefing_text_x, Briefing_text_y;
337 void init_char_pos(int x, int y)
341 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
344 grs_canvas *Robot_canv = NULL;
345 vms_angvec Robot_angles;
347 char Bitmap_name[32] = "";
348 #define EXIT_DOOR_MAX 14
349 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
350 #define DOOR_DIV_INIT 6
351 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
353 //-----------------------------------------------------------------------------
354 void show_bitmap_frame(void)
357 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
359 grs_canvas *curcanv_save, *bitmap_canv=0;
362 grs_bitmap *bitmap_ptr;
364 // Only plot every nth frame.
365 if (Door_div_count) {
370 Door_div_count = DOOR_DIV_INIT;
372 if (Bitmap_name[0] != 0) {
376 // Set supertransparency color to black
377 if (!New_pal_254_bash) {
378 New_pal_254_bash = 1;
380 New_pal[254*3+1] = 0;
381 New_pal[254*3+2] = 0;
382 gr_palette_load( New_pal );
385 switch (Animating_bitmap_type) {
388 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
389 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
393 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
394 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 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)
532 int x = rescale_x(138);
533 int y = rescale_y(55);
534 int w = rescale_x(166);
535 int h = rescale_y(138);
538 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
543 //---------------------------------------------------------------------------
544 // Returns char width.
545 // If show_robot_flag set, then show a frame of the spinning robot.
546 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
550 static fix start_time=0;
552 message[0] = the_char;
555 if (start_time==0 && timer_get_fixed_seconds()<0)
556 start_time=timer_get_fixed_seconds();
558 gr_get_string_size(message, &w, &h, &aw );
560 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
562 // Draw cursor if there is some delay and caller says to draw cursor
563 if (cursor_flag && delay) {
564 WIN(DDGRLOCK(dd_grd_curcanv));
565 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
566 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
567 WIN(DDGRUNLOCK(dd_grd_curcanv));
571 delay=fixdiv (F1_0,i2f(15));
576 if (RobotPlaying && (delay != 0))
579 while (timer_get_fixed_seconds() < (start_time + delay)) {
580 if (RobotPlaying && delay != 0)
584 show_spinning_robot_frame(robot_num);
586 start_time = timer_get_fixed_seconds();
588 WIN(DDGRLOCK(dd_grd_curcanv));
590 if (cursor_flag && delay) {
591 gr_set_fontcolor(Erase_color, -1);
592 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
595 // Draw the character
596 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
597 gr_printf(Briefing_text_x, Briefing_text_y, message );
599 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
600 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
601 WIN(DDGRUNLOCK(dd_grd_curcanv));
603 if (delay) gr_update();
605 // if (the_char != ' ')
606 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
607 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
612 //-----------------------------------------------------------------------------
613 int load_briefing_screen( int screen_num )
618 if (Mission_list[Current_mission_num].descent_version == 1)
619 fname = Briefing_screens[screen_num].bs_name;
621 fname = CurBriefScreenName;
623 WIN(DDGRLOCK(dd_grd_curcanv));
624 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
625 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
626 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);
627 WIN(DDGRUNLOCK(dd_grd_curcanv));
628 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
630 WIN(DDGRUNLOCK(dd_grd_curcanv));
637 int load_new_briefing_screen( char *fname )
641 mprintf ((0,"Loading new briefing <%s>\n",fname));
642 strcpy (CurBriefScreenName,fname);
644 //WIN(DEFINE_SCREEN(CurBriefScreenName));
646 if (gr_palette_fade_out( New_pal, 32, 0 ))
649 WIN(DDGRLOCK(dd_grd_curcanv));
650 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
651 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
652 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);
653 WIN(DDGRUNLOCK(dd_grd_curcanv));
654 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
656 WIN(DDGRUNLOCK(dd_grd_curcanv));
660 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
662 if (gr_palette_fade_in( New_pal, 32, 0 ))
664 DoBriefingColorStuff();
671 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
673 //-----------------------------------------------------------------------------
674 int get_message_num(char **message)
678 while (**message == ' ')
681 while ((**message >= '0') && (**message <= '9')) {
682 num = 10*num + **message-'0';
686 while (*(*message)++ != 10) // Get and drop eoln
692 //-----------------------------------------------------------------------------
693 void get_message_name(char **message, char *result)
695 while (**message == ' ')
698 while ((**message != ' ') && (**message != 10)) {
699 if (**message != '\n')
700 *result++ = **message;
705 while (*(*message)++ != 10) // Get and drop eoln
711 //-----------------------------------------------------------------------------
712 void flash_cursor(int cursor_flag)
714 if (cursor_flag == 0)
717 WIN(DDGRLOCK(dd_grd_curcanv));
718 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
719 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
721 gr_set_fontcolor(Erase_color, -1);
723 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
724 WIN(DDGRUNLOCK(dd_grd_curcanv));
727 extern int InitMovieBriefing();
730 //-----------------------------------------------------------------------------
731 // Return true if message got aborted by user (pressed ESC), else return false.
732 int show_briefing_message(int screen_num, char *message)
736 briefing_screen *bsp = &Briefing_screens[screen_num];
737 int delay_count = KEY_DELAY_DEFAULT;
741 static int tab_stop=0;
742 int flashing_cursor=0;
743 int new_page=0,GotZ=0;
744 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
748 int hum_channel=-1,printing_channel=-1;
749 int LineAdjustment=1;
750 WIN(int wpage_done=0);
759 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
762 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
763 gr_set_curfont( GAME_FONT );
765 if (Mission_list[Current_mission_num].descent_version == 1) {
767 bsp=&Briefing_screens[screen_num];
768 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*MenuHires));
770 bsp=&Briefing_screens[0];
771 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
779 screen_num=DefineBriefingBox (&message);
780 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
782 bsp = &Briefing_screens[screen_num];
783 init_char_pos(bsp->text_ulx, bsp->text_uly);
785 prev_ch = 10; // read to eoln
786 } else if (ch=='U') {
787 screen_num=get_message_num(&message);
788 bsp = &Briefing_screens[screen_num];
789 init_char_pos(bsp->text_ulx, bsp->text_uly);
790 prev_ch = 10; // read to eoln
791 } else if (ch == 'C') {
792 Current_color = get_message_num(&message)-1;
793 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
795 } else if (ch == 'F') { // toggle flashing cursor
796 flashing_cursor = !flashing_cursor;
798 while (*message++ != 10)
800 } else if (ch == 'T') {
801 tab_stop = get_message_num(&message);
802 tab_stop*=(1+MenuHires);
803 prev_ch = 10; // read to eoln
804 } else if (ch == 'R') {
805 if (Robot_canv != NULL) {
814 if (Mission_list[Current_mission_num].descent_version == 1) {
816 init_spinning_robot();
817 robot_num = get_message_num(&message);
821 spinRobotName[2]=kludge; // ugly but proud
823 RobotPlaying=InitRobotMovie(spinRobotName);
825 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
829 DoBriefingColorStuff ();
830 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
833 prev_ch = 10; // read to eoln
834 while (*message++ != 10)
836 } else if (ch == 'N') {
837 //--grs_bitmap *bitmap_ptr;
838 if (Robot_canv != NULL) {
843 get_message_name(&message, Bitmap_name);
844 strcat(Bitmap_name, "#0");
845 Animating_bitmap_type = 0;
847 } else if (ch == 'O') {
848 if (Robot_canv != NULL) {
853 get_message_name(&message, Bitmap_name);
854 strcat(Bitmap_name, "#0");
855 Animating_bitmap_type = 1;
857 } else if (ch=='A') {
858 LineAdjustment=1-LineAdjustment;
859 } else if (ch=='Z') {
860 //mprintf ((0,"Got a Z!\n"));
862 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
865 if (LineAdjustment==1)
872 while ((fname[i]=*message) != '\n') {
878 while (*message++ != 10) // Get and drop eoln
885 while (fname[i]!='.') {
886 fname2[i] = fname[i];
896 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
897 load_new_briefing_screen (fname2);
899 load_new_briefing_screen (fname);
902 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
904 } else if (ch == 'B') {
905 char bitmap_name[32];
906 grs_bitmap guy_bitmap;
907 ubyte temp_palette[768];
910 if (Robot_canv != NULL) {
915 get_message_name(&message, bitmap_name);
916 strcat(bitmap_name, ".bbm");
917 guy_bitmap.bm_data = NULL;
918 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
919 Assert(iff_error == IFF_NO_ERROR);
920 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
922 show_briefing_bitmap(&guy_bitmap);
923 d_free(guy_bitmap.bm_data);
925 // } else if (ch==EOF) {
927 // } else if (ch == 'B') {
928 // if (Robot_canv != NULL) {
929 // d_free(Robot_canv);
933 // bitmap_num = get_message_num(&message);
934 // if (bitmap_num != -1)
935 // show_briefing_bitmap(Textures[bitmap_num]);
936 // prev_ch = 10; // read to eoln
937 } else if (ch == 'S') {
942 if (printing_channel>-1)
943 digi_stop_sound( printing_channel );
955 start_time = timer_get_fixed_seconds();
956 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
959 _RedrawScreen = FALSE;
960 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
966 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
968 flash_cursor(flashing_cursor);
973 show_spinning_robot_frame(robot_num);
976 start_time += KEY_DELAY_DEFAULT/2;
980 if (keypress == KEY_BACKSP)
983 if (keypress == KEY_ESC)
989 } else if (ch == 'P') { // New page.
991 Int3(); // Hey ryan!!!! You gotta load a screen before you start
992 // printing to it! You know, $Z !!!
993 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
997 while (*message != 10) {
998 message++; // drop carriage return after special escape sequence
1004 } else if (ch == '\t') { // Tab
1005 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1006 Briefing_text_x = bsp->text_ulx + tab_stop;
1007 } else if ((ch == ';') && (prev_ch == 10)) {
1008 while (*message++ != 10)
1011 } else if (ch == '\\') {
1013 } else if (ch == 10) {
1014 if (prev_ch != '\\') {
1017 Briefing_text_y += (8*(MenuHires+1));
1020 Briefing_text_x = bsp->text_ulx;
1021 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1022 load_briefing_screen(screen_num);
1023 Briefing_text_x = bsp->text_ulx;
1024 Briefing_text_y = bsp->text_uly;
1027 if (ch == 13) //Can this happen? Above says ch==10
1034 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1035 // printing to it! You know, $Z !!!
1036 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1042 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1046 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1048 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1052 // Check for Esc -> abort.
1054 key_check=local_key_inkey();
1059 if (_RedrawScreen) {
1060 _RedrawScreen = FALSE;
1061 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1062 key_check = KEY_ESC;
1065 if ( key_check == KEY_ESC ) {
1070 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1073 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1074 if ((key_check == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) ||
1075 (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) ||
1076 (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER))
1077 gr_toggle_fullscreen();
1080 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1081 Briefing_text_x = bsp->text_ulx;
1082 Briefing_text_y += bsp->text_uly;
1085 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1091 if (printing_channel>-1)
1092 digi_stop_sound( printing_channel );
1093 printing_channel=-1;
1104 start_time = timer_get_fixed_seconds();
1105 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1107 if (_RedrawScreen) {
1108 _RedrawScreen = FALSE;
1109 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1115 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1117 flash_cursor(flashing_cursor);
1120 if (robot_num != -1)
1121 show_spinning_robot_frame(robot_num);
1122 show_bitmap_frame();
1123 start_time += KEY_DELAY_DEFAULT/2;
1132 if (keypress == KEY_BACKSP)
1135 if (keypress == KEY_ESC) {
1140 load_briefing_screen(screen_num);
1141 Briefing_text_x = bsp->text_ulx;
1142 Briefing_text_y = bsp->text_uly;
1143 delay_count = KEY_DELAY_DEFAULT;
1145 WIN(wpage_done = 0);
1154 if (Robot_canv != NULL)
1155 {d_free(Robot_canv); Robot_canv=NULL;}
1158 digi_stop_sound( hum_channel );
1159 if (printing_channel>-1)
1160 digi_stop_sound( printing_channel );
1165 //-----------------------------------------------------------------------------
1166 // Return a pointer to the start of text for screen #screen_num.
1167 char * get_briefing_message(int screen_num)
1169 char *tptr = Briefing_text;
1173 Assert(screen_num >= 0);
1175 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1180 cur_screen = get_message_num(&tptr);
1184 if (screen_num!=cur_screen)
1190 //-----------------------------------------------------------------------------
1191 // Load Descent briefing text.
1192 int load_screen_text(char *filename, char **buf)
1197 int have_binary = 0;
1199 if ((tfile = cfopen(filename,"rb")) == NULL) {
1200 char nfilename[30], *ptr;
1202 strcpy(nfilename, filename);
1203 ptr = strrchr(nfilename, '.');
1205 strcat(nfilename, ".txb");
1206 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1207 mprintf ((0,"can't open %s!\n",nfilename));
1209 //Error("Cannot open file %s or %s", filename, nfilename);
1212 mprintf ((0,"reading...\n"));
1215 len = cfilelength(ifile);
1216 MALLOC(*buf, char, len+500);
1217 mprintf ((0,"len=%d\n",len));
1218 for (x=0, i=0; i < len; i++, x++) {
1219 cfread (*buf+x,1,1,ifile);
1220 // mprintf ((0,"%c",*(*buf+x)));
1227 len = cfilelength(tfile);
1228 MALLOC(*buf, char, len+500);
1229 for (x=0, i=0; i < len; i++, x++) {
1230 cfread (*buf+x,1,1,tfile);
1231 // mprintf ((0,"%c",*(*buf+x)));
1237 //cfread(*buf, 1, len, tfile);
1244 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1246 encode_rotate_left(ptr);
1247 *ptr = *ptr ^ BITMAP_TBL_XOR;
1248 encode_rotate_left(ptr);
1256 //-----------------------------------------------------------------------------
1257 // Return true if message got aborted, else return false.
1258 int show_briefing_text(int screen_num)
1262 if (Mission_list[Current_mission_num].descent_version == 1)
1263 message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num);
1265 message_ptr = get_briefing_message(screen_num);
1266 if (message_ptr==NULL)
1269 DoBriefingColorStuff();
1271 return show_briefing_message(screen_num, message_ptr);
1274 void DoBriefingColorStuff ()
1276 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1277 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1279 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1280 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1282 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1283 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1285 if (Mission_list[Current_mission_num].descent_version == 1) {
1287 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1288 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1290 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1291 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1293 //Begin D1X addition
1295 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1296 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1299 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1300 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1302 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1303 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1305 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1306 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1308 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1309 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1312 Erase_color = gr_find_closest_color_current(0, 0, 0);
1315 //-----------------------------------------------------------------------------
1316 // Return true if screen got aborted by user, else return false.
1317 int show_briefing_screen( int screen_num, int allow_keys)
1320 //ubyte palette_save[768];
1322 New_pal_254_bash = 0;
1324 if (Skip_briefing_screens) {
1325 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1329 if (Mission_list[Current_mission_num].descent_version == 1) {
1332 grs_bitmap briefing_bm;
1334 gr_init_bitmap_data(&briefing_bm);
1335 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1337 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1339 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1340 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));
1346 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1347 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1349 //vfx_set_palette_sub( New_pal );
1351 gr_palette_load(New_pal);
1355 gr_set_current_canvas( NULL );
1356 show_fullscr(&briefing_bm);
1359 //added on 9/13/98 by adb to make arch's requiring updates work
1361 //end changes by adb
1364 gr_free_bitmap_data (&briefing_bm);
1367 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1370 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1375 key_close(); // kill the keyboard handler during briefing screens for movies
1377 rval = show_briefing_text(screen_num);
1382 #if defined (MACINTOSH) || defined(WINDOWS)
1383 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1388 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1391 DEFINE_SCREEN(NULL);
1392 WIN(DDGRLOCK(dd_grd_curcanv));
1393 gr_clear_canvas (0);
1394 WIN(DDGRUNLOCK(dd_grd_curcanv));
1395 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1399 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1401 //d_free(briefing_bm.bm_data);
1407 //-----------------------------------------------------------------------------
1408 void do_briefing_screens(char *filename,int level_num)
1410 int abort_briefing_screens = 0;
1411 int cur_briefing_screen = 0;
1413 if (Skip_briefing_screens) {
1414 mprintf((0, "Skipping all briefing screens.\n"));
1419 return; // no briefing screens at all for demo
1423 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1428 if (!load_screen_text(filename, &Briefing_text))
1432 songs_play_song( SONG_BRIEFING, 1 );
1437 set_screen_mode( SCREEN_MENU );
1440 dd_gr_set_current_canvas(NULL),
1441 gr_set_current_canvas(NULL)
1444 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1448 if (Mission_list[Current_mission_num].descent_version == 1) {
1449 if (level_num == 1) {
1450 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1451 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1452 cur_briefing_screen++;
1456 if (!abort_briefing_screens) {
1457 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1458 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1459 if (show_briefing_screen(cur_briefing_screen, 0))
1464 show_briefing_screen(level_num,0);
1466 d_free (Briefing_text);
1473 int DefineBriefingBox (char **buf)
1478 n=get_new_message_num (buf);
1480 Assert(n < MAX_BRIEFING_SCREENS);
1482 while (**buf!=' ') {
1487 name[i]='\0'; // slap a delimiter on this guy
1489 strcpy (Briefing_screens[n].bs_name,name);
1490 Briefing_screens[n].level_num=get_new_message_num (buf);
1491 Briefing_screens[n].message_num=get_new_message_num (buf);
1492 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1493 Briefing_screens[n].text_uly=get_new_message_num (buf);
1494 Briefing_screens[n].text_width=get_new_message_num (buf);
1495 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1498 Briefing_screens[n].text_ulx*=2;
1499 Briefing_screens[n].text_uly*=2.4;
1500 Briefing_screens[n].text_width*=2;
1501 Briefing_screens[n].text_height*=2.4;
1507 int get_new_message_num(char **message)
1511 while (**message == ' ')
1514 while ((**message >= '0') && (**message <= '9')) {
1515 num = 10*num + **message-'0';