1 /* $Id: titles.c,v 1.22 2003-02-25 04:45:31 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 //Begin D1X modification
86 #define MAX_BRIEFING_COLORS 7
87 //End D1X modification
89 // Descent 1 briefings
90 char Ending_text_filename[13] = "endreg.txt";
91 char Briefing_text_filename[13] = "briefing.txt";
93 #define SHAREWARE_ENDING_FILENAME "ending.tex"
95 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
96 int Skip_briefing_screens=0;
97 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
98 int Current_color = 0;
101 extern int check_button_press();
104 extern void macintosh_quit(void);
107 static int rescale_x(int x)
109 return x * GWIDTH / 320;
112 static int rescale_y(int y)
114 return y * GHEIGHT / 200;
118 int local_key_inkey(void)
125 DoMessageStuff(&msg);
130 if (rval == KEY_PRINT_SCREEN) {
134 gr_palette_read(gr_palette);
135 gr_copy_palette(gr_palette,gr_palette,0); //reset color lookup cache
140 return 0; //say no key pressed
143 if (check_button_press()) //joystick or mouse button pressed?
147 if ( rval == KEY_Q+KEY_COMMAND )
154 int local_key_inkey(void)
159 if (!GetOSEvent(everyEvent, &event))
162 if (event.what != keyDown)
165 rval = (int)((event.message & keyCodeMask) >> 8);
167 if (rval == KEY_PRINT_SCREEN) {
169 return 0; //say no key pressed
172 if (check_button_press()) //joystick or mouse button pressed?
176 if ( rval == KEY_Q+KEY_COMMAND )
184 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
189 ubyte palette_save[768];
190 char new_filename[FILENAME_LEN+1] = "";
194 strcpy(new_filename,"\x01"); //only read from hog file
197 strcat(new_filename,filename);
198 filename = new_filename;
200 title_bm.bm_data=NULL;
201 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
202 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
203 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));
204 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
207 memcpy(palette_save,gr_palette,sizeof(palette_save));
209 #if defined(POLY_ACC)
211 pa_update_clut(New_pal, 0, 256, 0);
214 //vfx_set_palette_sub( New_pal );
216 gr_palette_load( New_pal );
222 dd_gr_set_current_canvas(NULL),
223 gr_set_current_canvas( NULL )
225 WIN(DDGRLOCK(dd_grd_curcanv));
226 show_fullscr(&title_bm);
227 WIN(DDGRUNLOCK(dd_grd_curcanv));
231 #if defined(POLY_ACC)
235 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
237 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
239 gr_palette_load( New_pal );
240 timer = timer_get_fixed_seconds() + i2f(3);
242 if ( local_key_inkey() && allow_keys ) break;
243 if ( timer_get_fixed_seconds() > timer ) break;
245 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
247 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
248 d_free(title_bm.bm_data);
253 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
256 short text_ulx, text_uly; // upper left x,y of text window
257 short text_width, text_height; // width and height of text window
260 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
261 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
263 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
264 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
267 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
269 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
272 #define MAX_BRIEFING_SCREENS 60
275 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
276 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
278 briefing_screen Briefing_screens[] = {
279 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
280 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
281 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
282 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
284 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
285 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
286 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
288 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
289 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
291 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
292 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
293 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
296 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
297 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
298 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
299 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
300 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
302 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
303 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
304 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
305 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
306 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
308 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
309 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
310 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
311 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
312 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
314 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
315 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
316 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
317 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
319 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
320 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
321 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
323 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
324 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
325 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
327 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
328 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
329 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
332 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
334 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
335 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
336 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
343 int Briefing_text_x, Briefing_text_y;
345 void init_char_pos(int x, int y)
349 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
352 grs_canvas *Robot_canv = NULL;
353 vms_angvec Robot_angles;
355 char Bitmap_name[32] = "";
356 #define EXIT_DOOR_MAX 14
357 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
358 #define DOOR_DIV_INIT 6
359 byte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
361 //-----------------------------------------------------------------------------
362 void show_bitmap_frame(void)
365 dd_grs_canvas *curcanv_save, *bitmap_canv=0;
367 grs_canvas *curcanv_save, *bitmap_canv=0;
370 grs_bitmap *bitmap_ptr;
372 // Only plot every nth frame.
373 if (Door_div_count) {
378 Door_div_count = DOOR_DIV_INIT;
380 if (Bitmap_name[0] != 0) {
384 // Set supertransparency color to black
385 if (!New_pal_254_bash) {
386 New_pal_254_bash = 1;
388 New_pal[254*3+1] = 0;
389 New_pal[254*3+2] = 0;
390 gr_palette_load( New_pal );
393 switch (Animating_bitmap_type) {
396 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 64, 64); break,
397 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 64, 64); break
401 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, 94, 94); break,
402 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, 94, 94); break
405 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
407 Int3(); // Impossible, illegal value for Animating_bitmap_type
411 curcanv_save = dd_grd_curcanv; dd_grd_curcanv = bitmap_canv,
412 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv
415 pound_signp = strchr(Bitmap_name, '#');
416 Assert(pound_signp != NULL);
418 dig1 = *(pound_signp+1);
419 dig2 = *(pound_signp+2);
423 num = (dig1-'0')*10 + (dig2-'0');
425 switch (Animating_bitmap_type) {
428 if (num > EXIT_DOOR_MAX) {
431 } else if (num < 0) {
438 if (num > OTHER_THING_MAX)
445 *(pound_signp+1) = (num / 10) + '0';
446 *(pound_signp+2) = (num % 10) + '0';
447 *(pound_signp+3) = 0;
449 *(pound_signp+1) = (num % 10) + '0';
450 *(pound_signp+2) = 0;
455 bi = piggy_find_bitmap(Bitmap_name);
456 bitmap_ptr = &GameBitmaps[bi.index];
460 WIN(DDGRLOCK(dd_grd_curcanv));
461 gr_bitmapm(0, 0, bitmap_ptr);
462 WIN(DDGRUNLOCK(dd_grd_curcanv));
465 dd_grd_curcanv = curcanv_save,
466 grd_curcanv = curcanv_save
470 switch (Animating_bitmap_type) {
472 if (num == EXIT_DOOR_MAX) {
475 } else if (num == 0) {
487 //-----------------------------------------------------------------------------
488 void show_briefing_bitmap(grs_bitmap *bmp)
491 dd_grs_canvas *bitmap_canv, *curcanv_save;
493 bitmap_canv = dd_gr_create_sub_canvas(dd_grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
494 curcanv_save = dd_grd_curcanv;
495 dd_gr_set_current_canvas(bitmap_canv);
496 DDGRLOCK(dd_grd_curcanv);
498 DDGRUNLOCK(dd_grd_curcanv);
499 dd_gr_set_current_canvas(curcanv_save);
501 grs_canvas *curcanv_save, *bitmap_canv;
503 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
504 curcanv_save = grd_curcanv;
505 gr_set_current_canvas(bitmap_canv);
506 gr_bitmapm(0, 0, bmp);
507 gr_set_current_canvas(curcanv_save);
514 //-----------------------------------------------------------------------------
515 void show_spinning_robot_frame(int robot_num)
517 grs_canvas *curcanv_save;
519 if (robot_num != -1) {
520 Robot_angles.h += 150;
522 curcanv_save = grd_curcanv;
523 grd_curcanv = Robot_canv;
524 Assert(Robot_info[robot_num].model_num != -1);
525 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
526 grd_curcanv = curcanv_save;
531 //-----------------------------------------------------------------------------
532 void init_spinning_robot(void) //(int x,int y,int w,int h)
540 int x = rescale_x(138);
541 int y = rescale_y(55);
542 int w = rescale_x(166);
543 int h = rescale_y(138);
546 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
551 //---------------------------------------------------------------------------
552 // Returns char width.
553 // If show_robot_flag set, then show a frame of the spinning robot.
554 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
558 static fix start_time=0;
561 message[0] = the_char;
564 if (start_time==0 && timer_get_fixed_seconds()<0)
565 start_time=timer_get_fixed_seconds();
567 gr_get_string_size(message, &w, &h, &aw );
569 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
571 // Draw cursor if there is some delay and caller says to draw cursor
572 if (cursor_flag && delay) {
573 WIN(DDGRLOCK(dd_grd_curcanv));
574 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
575 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
576 WIN(DDGRUNLOCK(dd_grd_curcanv));
580 delay=fixdiv (F1_0,i2f(15));
586 if (RobotPlaying && (delay != 0))
589 while (timer_get_fixed_seconds() < (start_time + delay)) {
590 if (RobotPlaying && delay != 0)
595 show_spinning_robot_frame(robot_num);
598 start_time = timer_get_fixed_seconds();
600 WIN(DDGRLOCK(dd_grd_curcanv));
602 if (cursor_flag && delay) {
603 gr_set_fontcolor(Erase_color, -1);
604 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
607 // Draw the character
608 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
609 gr_printf(Briefing_text_x, Briefing_text_y, message );
611 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
612 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
613 WIN(DDGRUNLOCK(dd_grd_curcanv));
615 if (delay) gr_update();
617 // if (the_char != ' ')
618 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
619 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
624 //-----------------------------------------------------------------------------
625 int load_briefing_screen( int screen_num )
630 if (Mission_list[Current_mission_num].descent_version == 1)
631 fname = Briefing_screens[screen_num].bs_name;
633 fname = CurBriefScreenName;
635 WIN(DDGRLOCK(dd_grd_curcanv));
636 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
637 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
638 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);
639 WIN(DDGRUNLOCK(dd_grd_curcanv));
640 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
642 WIN(DDGRUNLOCK(dd_grd_curcanv));
649 int load_new_briefing_screen( char *fname )
653 mprintf ((0,"Loading new briefing <%s>\n",fname));
654 strcpy (CurBriefScreenName,fname);
656 //WIN(DEFINE_SCREEN(CurBriefScreenName));
658 if (gr_palette_fade_out( New_pal, 32, 0 ))
661 WIN(DDGRLOCK(dd_grd_curcanv));
662 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
663 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
664 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);
665 WIN(DDGRUNLOCK(dd_grd_curcanv));
666 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
668 WIN(DDGRUNLOCK(dd_grd_curcanv));
672 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
674 if (gr_palette_fade_in( New_pal, 32, 0 ))
676 DoBriefingColorStuff();
683 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
685 //-----------------------------------------------------------------------------
686 int get_message_num(char **message)
690 while (**message == ' ')
693 while ((**message >= '0') && (**message <= '9')) {
694 num = 10*num + **message-'0';
698 while (*(*message)++ != 10) // Get and drop eoln
704 //-----------------------------------------------------------------------------
705 void get_message_name(char **message, char *result)
707 while (**message == ' ')
710 while ((**message != ' ') && (**message != 10)) {
711 if (**message != '\n')
712 *result++ = **message;
717 while (*(*message)++ != 10) // Get and drop eoln
723 //-----------------------------------------------------------------------------
724 void flash_cursor(int cursor_flag)
726 if (cursor_flag == 0)
729 WIN(DDGRLOCK(dd_grd_curcanv));
730 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
731 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
733 gr_set_fontcolor(Erase_color, -1);
735 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
736 WIN(DDGRUNLOCK(dd_grd_curcanv));
739 extern int InitMovieBriefing();
742 //-----------------------------------------------------------------------------
743 // Return true if message got aborted by user (pressed ESC), else return false.
744 int show_briefing_message(int screen_num, char *message)
748 briefing_screen *bsp = &Briefing_screens[screen_num];
749 int delay_count = KEY_DELAY_DEFAULT;
753 static int tab_stop=0;
754 int flashing_cursor=0;
755 int new_page=0,GotZ=0;
757 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
762 int hum_channel=-1,printing_channel=-1;
763 int LineAdjustment=1;
764 WIN(int wpage_done=0);
775 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
778 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
779 gr_set_curfont( GAME_FONT );
781 if (Mission_list[Current_mission_num].descent_version == 1) {
783 bsp=&Briefing_screens[screen_num];
784 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*MenuHires));
786 bsp=&Briefing_screens[0];
787 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
795 screen_num=DefineBriefingBox (&message);
796 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
798 bsp = &Briefing_screens[screen_num];
799 init_char_pos(bsp->text_ulx, bsp->text_uly);
801 prev_ch = 10; // read to eoln
802 } else if (ch=='U') {
803 screen_num=get_message_num(&message);
804 bsp = &Briefing_screens[screen_num];
805 init_char_pos(bsp->text_ulx, bsp->text_uly);
806 prev_ch = 10; // read to eoln
807 } else if (ch == 'C') {
808 Current_color = get_message_num(&message)-1;
809 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
811 } else if (ch == 'F') { // toggle flashing cursor
812 flashing_cursor = !flashing_cursor;
814 while (*message++ != 10)
816 } else if (ch == 'T') {
817 tab_stop = get_message_num(&message);
818 tab_stop*=(1+MenuHires);
819 prev_ch = 10; // read to eoln
820 } else if (ch == 'R') {
821 if (Robot_canv != NULL) {
832 spinRobotName[2]=kludge; // ugly but proud
834 RobotPlaying=InitRobotMovie(spinRobotName);
836 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
840 DoBriefingColorStuff ();
841 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
844 init_spinning_robot();
845 robot_num = get_message_num(&message);
847 prev_ch = 10; // read to eoln
848 while (*message++ != 10)
850 } else if (ch == 'N') {
851 //--grs_bitmap *bitmap_ptr;
852 if (Robot_canv != NULL) {
857 get_message_name(&message, Bitmap_name);
858 strcat(Bitmap_name, "#0");
859 Animating_bitmap_type = 0;
861 } else if (ch == 'O') {
862 if (Robot_canv != NULL) {
867 get_message_name(&message, Bitmap_name);
868 strcat(Bitmap_name, "#0");
869 Animating_bitmap_type = 1;
871 } else if (ch=='A') {
872 LineAdjustment=1-LineAdjustment;
873 } else if (ch=='Z') {
874 //mprintf ((0,"Got a Z!\n"));
876 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
879 if (LineAdjustment==1)
886 while ((fname[i]=*message) != '\n') {
892 while (*message++ != 10) // Get and drop eoln
899 while (fname[i]!='.') {
900 fname2[i] = fname[i];
910 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
911 load_new_briefing_screen (fname2);
913 load_new_briefing_screen (fname);
916 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
918 } else if (ch == 'B') {
919 char bitmap_name[32];
920 grs_bitmap guy_bitmap;
921 ubyte temp_palette[768];
924 if (Robot_canv != NULL) {
929 get_message_name(&message, bitmap_name);
930 strcat(bitmap_name, ".bbm");
931 guy_bitmap.bm_data = NULL;
932 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
933 Assert(iff_error == IFF_NO_ERROR);
934 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
936 show_briefing_bitmap(&guy_bitmap);
937 d_free(guy_bitmap.bm_data);
939 // } else if (ch==EOF) {
941 // } else if (ch == 'B') {
942 // if (Robot_canv != NULL) {
943 // d_free(Robot_canv);
947 // bitmap_num = get_message_num(&message);
948 // if (bitmap_num != -1)
949 // show_briefing_bitmap(Textures[bitmap_num]);
950 // prev_ch = 10; // read to eoln
951 } else if (ch == 'S') {
956 if (printing_channel>-1)
957 digi_stop_sound( printing_channel );
969 start_time = timer_get_fixed_seconds();
970 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
973 _RedrawScreen = FALSE;
974 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
980 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
982 flash_cursor(flashing_cursor);
988 show_spinning_robot_frame(robot_num);
992 start_time += KEY_DELAY_DEFAULT/2;
996 if (keypress == KEY_BACKSP)
999 if (keypress == KEY_ESC)
1002 flashing_cursor = 0;
1004 WIN(wpage_done = 0);
1005 } else if (ch == 'P') { // New page.
1007 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1008 // printing to it! You know, $Z !!!
1009 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1013 while (*message != 10) {
1014 message++; // drop carriage return after special escape sequence
1020 } else if (ch == '\t') { // Tab
1021 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1022 Briefing_text_x = bsp->text_ulx + tab_stop;
1023 } else if ((ch == ';') && (prev_ch == 10)) {
1024 while (*message++ != 10)
1027 } else if (ch == '\\') {
1029 } else if (ch == 10) {
1030 if (prev_ch != '\\') {
1033 Briefing_text_y += (8*(MenuHires+1));
1036 Briefing_text_x = bsp->text_ulx;
1037 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1038 load_briefing_screen(screen_num);
1039 Briefing_text_x = bsp->text_ulx;
1040 Briefing_text_y = bsp->text_uly;
1043 if (ch == 13) //Can this happen? Above says ch==10
1050 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1051 // printing to it! You know, $Z !!!
1052 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1058 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1062 WIN(if (GRMODEINFO(emul)) delay_count = 0);
1064 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1068 // Check for Esc -> abort.
1070 key_check=local_key_inkey();
1075 if (_RedrawScreen) {
1076 _RedrawScreen = FALSE;
1077 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1078 key_check = KEY_ESC;
1081 if ( key_check == KEY_ESC ) {
1086 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1089 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1090 if ((key_check == KEY_CTRLED+KEY_SHIFTED+KEY_PADENTER) ||
1091 (key_check == KEY_ALTED+KEY_CTRLED+KEY_PADENTER) ||
1092 (key_check == KEY_ALTED+KEY_SHIFTED+KEY_PADENTER))
1093 gr_toggle_fullscreen();
1096 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1097 Briefing_text_x = bsp->text_ulx;
1098 Briefing_text_y += bsp->text_uly;
1101 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1107 if (printing_channel>-1)
1108 digi_stop_sound( printing_channel );
1109 printing_channel=-1;
1120 start_time = timer_get_fixed_seconds();
1121 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1123 if (_RedrawScreen) {
1124 _RedrawScreen = FALSE;
1125 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1131 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1133 flash_cursor(flashing_cursor);
1138 show_spinning_robot_frame(robot_num);
1140 show_bitmap_frame();
1141 start_time += KEY_DELAY_DEFAULT/2;
1152 if (keypress == KEY_BACKSP)
1155 if (keypress == KEY_ESC) {
1160 load_briefing_screen(screen_num);
1161 Briefing_text_x = bsp->text_ulx;
1162 Briefing_text_y = bsp->text_uly;
1163 delay_count = KEY_DELAY_DEFAULT;
1165 WIN(wpage_done = 0);
1176 if (Robot_canv != NULL)
1177 {d_free(Robot_canv); Robot_canv=NULL;}
1180 digi_stop_sound( hum_channel );
1181 if (printing_channel>-1)
1182 digi_stop_sound( printing_channel );
1187 //-----------------------------------------------------------------------------
1188 // Return a pointer to the start of text for screen #screen_num.
1189 char * get_briefing_message(int screen_num)
1191 char *tptr = Briefing_text;
1195 Assert(screen_num >= 0);
1197 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1202 cur_screen = get_message_num(&tptr);
1206 if (screen_num!=cur_screen)
1212 //-----------------------------------------------------------------------------
1213 // Load Descent briefing text.
1214 int load_screen_text(char *filename, char **buf)
1219 int have_binary = 0;
1221 if ((tfile = cfopen(filename,"rb")) == NULL) {
1222 char nfilename[30], *ptr;
1224 strcpy(nfilename, filename);
1225 ptr = strrchr(nfilename, '.');
1227 strcat(nfilename, ".txb");
1228 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1229 mprintf ((0,"can't open %s!\n",nfilename));
1231 //Error("Cannot open file %s or %s", filename, nfilename);
1234 mprintf ((0,"reading...\n"));
1237 len = cfilelength(ifile);
1238 MALLOC(*buf, char, len+500);
1239 mprintf ((0,"len=%d\n",len));
1240 for (x=0, i=0; i < len; i++, x++) {
1241 cfread (*buf+x,1,1,ifile);
1242 // mprintf ((0,"%c",*(*buf+x)));
1249 len = cfilelength(tfile);
1250 MALLOC(*buf, char, len+500);
1251 for (x=0, i=0; i < len; i++, x++) {
1252 cfread (*buf+x,1,1,tfile);
1253 // mprintf ((0,"%c",*(*buf+x)));
1259 //cfread(*buf, 1, len, tfile);
1266 for (i = 0, ptr = *buf; i < len; i++, ptr++) {
1268 encode_rotate_left(ptr);
1269 *ptr = *ptr ^ BITMAP_TBL_XOR;
1270 encode_rotate_left(ptr);
1278 //-----------------------------------------------------------------------------
1279 // Return true if message got aborted, else return false.
1280 int show_briefing_text(int screen_num)
1284 if (Mission_list[Current_mission_num].descent_version == 1) {
1286 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1287 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1289 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1290 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1291 //Begin D1X addition
1293 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1294 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1296 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1297 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1299 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1300 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1302 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1303 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1305 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1306 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1309 Erase_color = gr_find_closest_color_current(0, 0, 0);
1311 message_ptr = get_briefing_message(Briefing_screens[screen_num].message_num);
1313 message_ptr = get_briefing_message(screen_num);
1314 if (message_ptr==NULL)
1317 DoBriefingColorStuff();
1320 return show_briefing_message(screen_num, message_ptr);
1323 void DoBriefingColorStuff ()
1325 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1326 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1328 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1329 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1331 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1332 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1334 Erase_color = gr_find_closest_color_current(0, 0, 0);
1337 //-----------------------------------------------------------------------------
1338 // Return true if screen got aborted by user, else return false.
1339 int show_briefing_screen( int screen_num, int allow_keys)
1342 //ubyte palette_save[768];
1344 New_pal_254_bash = 0;
1346 if (Skip_briefing_screens) {
1347 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1351 if (Mission_list[Current_mission_num].descent_version == 1) {
1354 grs_bitmap briefing_bm;
1356 gr_init_bitmap_data(&briefing_bm);
1357 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1359 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1361 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1362 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));
1368 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1369 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1371 //vfx_set_palette_sub( New_pal );
1373 gr_palette_load(New_pal);
1377 gr_set_current_canvas( NULL );
1378 show_fullscr(&briefing_bm);
1381 //added on 9/13/98 by adb to make arch's requiring updates work
1383 //end changes by adb
1386 gr_free_bitmap_data (&briefing_bm);
1389 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1392 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1397 key_close(); // kill the keyboard handler during briefing screens for movies
1399 rval = show_briefing_text(screen_num);
1404 #if defined (MACINTOSH) || defined(WINDOWS)
1405 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1410 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1413 DEFINE_SCREEN(NULL);
1414 WIN(DDGRLOCK(dd_grd_curcanv));
1415 gr_clear_canvas (0);
1416 WIN(DDGRUNLOCK(dd_grd_curcanv));
1417 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1421 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1423 //d_free(briefing_bm.bm_data);
1429 //-----------------------------------------------------------------------------
1430 void do_briefing_screens(char *filename,int level_num)
1432 int abort_briefing_screens = 0;
1433 int cur_briefing_screen = 0;
1435 if (Skip_briefing_screens) {
1436 mprintf((0, "Skipping all briefing screens.\n"));
1441 return; // no briefing screens at all for demo
1445 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1450 if (!load_screen_text(filename, &Briefing_text))
1454 songs_play_song( SONG_BRIEFING, 1 );
1459 set_screen_mode( SCREEN_MENU );
1462 dd_gr_set_current_canvas(NULL),
1463 gr_set_current_canvas(NULL)
1466 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1470 if (Mission_list[Current_mission_num].descent_version == 1) {
1471 if (level_num == 1) {
1472 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1473 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1474 cur_briefing_screen++;
1478 if (!abort_briefing_screens) {
1479 for (cur_briefing_screen = 0; cur_briefing_screen < MAX_BRIEFING_SCREENS; cur_briefing_screen++)
1480 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1481 if (show_briefing_screen(cur_briefing_screen, 0))
1486 show_briefing_screen(level_num,0);
1488 d_free (Briefing_text);
1495 int DefineBriefingBox (char **buf)
1500 n=get_new_message_num (buf);
1502 Assert(n < MAX_BRIEFING_SCREENS);
1504 while (**buf!=' ') {
1509 name[i]='\0'; // slap a delimiter on this guy
1511 strcpy (Briefing_screens[n].bs_name,name);
1512 Briefing_screens[n].level_num=get_new_message_num (buf);
1513 Briefing_screens[n].message_num=get_new_message_num (buf);
1514 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1515 Briefing_screens[n].text_uly=get_new_message_num (buf);
1516 Briefing_screens[n].text_width=get_new_message_num (buf);
1517 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1520 Briefing_screens[n].text_ulx*=2;
1521 Briefing_screens[n].text_uly*=2.4;
1522 Briefing_screens[n].text_width*=2;
1523 Briefing_screens[n].text_height*=2.4;
1529 int get_new_message_num(char **message)
1533 while (**message == ' ')
1536 while ((**message >= '0') && (**message <= '9')) {
1537 num = 10*num + **message-'0';