1 /* $Id: titles.c,v 1.40 2006-07-29 03:49:00 chris 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.
17 * Routines to display title screens...
67 void DoBriefingColorStuff ();
68 int get_new_message_num(char **message);
69 int DefineBriefingBox (char **buf);
71 extern unsigned RobSX,RobSY,RobDX,RobDY; // Robot movie coords
76 char CurBriefScreenName[15]="brief03.pcx";
80 //Begin D1X modification
81 #define MAX_BRIEFING_COLORS 7
82 //End D1X modification
84 #define SHAREWARE_ENDING_FILENAME "ending.tex"
86 // Can be set by -noscreens command line option. Causes bypassing of all briefing screens.
87 int Skip_briefing_screens=0;
88 int Briefing_foreground_colors[MAX_BRIEFING_COLORS], Briefing_background_colors[MAX_BRIEFING_COLORS];
89 int Current_color = 0;
92 extern int check_button_press();
95 extern void macintosh_quit(void);
98 // added by Jan Bobrowski for variable-size menu screen
99 static int rescale_x(int x)
101 return x * GWIDTH / 320;
104 static int rescale_y(int y)
106 return y * GHEIGHT / 200;
110 int local_key_inkey(void)
116 if (rval == KEY_PRINT_SCREEN) {
118 return 0; //say no key pressed
121 if (check_button_press()) //joystick or mouse button pressed?
123 else if (mouse_button_state(0))
126 if ( rval == KEY_Q+KEY_COMMAND )
132 int local_key_inkey(void)
137 if (!GetOSEvent(everyEvent, &event))
140 if (event.what != keyDown)
143 rval = (int)((event.message & keyCodeMask) >> 8);
145 if (rval == KEY_PRINT_SCREEN) {
147 return 0; //say no key pressed
150 if (check_button_press()) //joystick or mouse button pressed?
153 if ( rval == KEY_Q+KEY_COMMAND )
160 int show_title_screen( char * filename, int allow_keys, int from_hog_only )
165 ubyte palette_save[768];
166 char new_filename[FILENAME_LEN+1] = "";
170 strcpy(new_filename,"\x01"); //only read from hog file
173 strcat(new_filename,filename);
174 filename = new_filename;
176 title_bm.bm_data=NULL;
177 if ((pcx_error=pcx_read_bitmap( filename, &title_bm, BM_LINEAR, New_pal ))!=PCX_ERROR_NONE) {
178 printf( "File '%s', PCX load error: %s (%i)\n (No big deal, just no title screen.)\n",filename, pcx_errormsg(pcx_error), pcx_error);
179 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));
180 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",filename, pcx_errormsg(pcx_error), pcx_error);
183 memcpy(palette_save,gr_palette,sizeof(palette_save));
185 //vfx_set_palette_sub( New_pal );
187 gr_palette_load( New_pal );
192 gr_set_current_canvas( NULL );
193 show_fullscr(&title_bm);
195 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
197 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
199 gr_palette_load( New_pal );
200 timer = timer_get_fixed_seconds() + i2f(3);
202 if ( local_key_inkey() && allow_keys ) break;
203 if ( timer_get_fixed_seconds() > timer ) break;
205 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
207 gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
208 d_free(title_bm.bm_data);
212 int intro_played = 0;
214 void show_titles(void)
217 int played=MOVIE_NOT_PLAYED; //default is not played
219 int song_playing = 0;
222 #define MOVIE_REQUIRED 0
224 #define MOVIE_REQUIRED 1
227 { //show bundler screens
228 char filename[FILENAME_LEN];
230 played=MOVIE_NOT_PLAYED; //default is not played
232 played = PlayMovie("pre_i.mve",0);
235 strcpy(filename,MenuHires?"pre_i1b.pcx":"pre_i1.pcx");
237 while (PHYSFS_exists(filename))
239 show_title_screen( filename, 1, 0 );
246 init_subtitles("intro.tex");
247 played = PlayMovie("intro.mve",MOVIE_REQUIRED);
251 if (played != MOVIE_NOT_PLAYED)
254 { //didn't get intro movie, try titles
256 played = PlayMovie("titles.mve",MOVIE_REQUIRED);
258 if (played == MOVIE_NOT_PLAYED)
260 char filename[FILENAME_LEN];
262 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
264 set_screen_mode(SCREEN_MENU);
266 con_printf( CON_DEBUG, "\nPlaying title song..." );
267 songs_play_song( SONG_TITLE, 1);
269 con_printf( CON_DEBUG, "\nShowing logo screens..." );
271 strcpy(filename, MenuHires?"iplogo1b.pcx":"iplogo1.pcx"); // OEM
272 if (! cfexist(filename))
273 strcpy(filename, "iplogo1.pcx"); // SHAREWARE
274 if (! cfexist(filename))
275 strcpy(filename, "mplogo.pcx"); // MAC SHAREWARE
276 if (cfexist(filename))
277 show_title_screen(filename, 1, 1);
279 strcpy(filename, MenuHires?"logob.pcx":"logo.pcx"); // OEM
280 if (! cfexist(filename))
281 strcpy(filename, "logo.pcx"); // SHAREWARE
282 if (! cfexist(filename))
283 strcpy(filename, "plogo.pcx"); // MAC SHAREWARE
284 if (cfexist(filename))
285 show_title_screen(filename, 1, 1);
289 { //show bundler movie or screens
291 char filename[FILENAME_LEN];
292 PHYSFS_file *movie_handle;
294 played=MOVIE_NOT_PLAYED; //default is not played
296 //check if OEM movie exists, so we don't stop the music if it doesn't
297 movie_handle = PHYSFS_openRead("oem.mve");
300 PHYSFS_close(movie_handle);
301 played = PlayMovie("oem.mve",0);
302 song_playing = 0; //movie will kill sound
307 strcpy(filename,MenuHires?"oem1b.pcx":"oem1.pcx");
309 while (PHYSFS_exists(filename))
311 show_title_screen( filename, 1, 0 );
318 songs_play_song( SONG_TITLE, 1);
321 void show_loading_screen(ubyte *title_pal)
323 //grs_bitmap title_bm;
327 strcpy(filename, MenuHires?"descentb.pcx":"descent.pcx");
328 if (! cfexist(filename))
329 strcpy(filename, MenuHires?"descntob.pcx":"descento.pcx"); // OEM
330 if (! cfexist(filename))
331 strcpy(filename, "descentd.pcx"); // SHAREWARE
332 if (! cfexist(filename))
333 strcpy(filename, "descentb.pcx"); // MAC SHAREWARE
335 gr_set_mode(MenuHires?SM(640,480):SM(320,200));
337 set_screen_mode(SCREEN_MENU);
340 FontHires = FontHiresAvailable && MenuHires;
342 if ((pcx_error=pcx_read_fullscr( filename, title_pal ))==PCX_ERROR_NONE) {
343 //vfx_set_palette_sub( title_pal );
345 gr_palette_fade_in( title_pal, 32, 0 );
348 Error( "Couldn't load pcx file '%s', PCX load error: %s\n",filename, pcx_errormsg(pcx_error));
352 char bs_name[14]; // filename, eg merc01. Assumes .lbm suffix.
355 short text_ulx, text_uly; // upper left x,y of text window
356 short text_width, text_height; // width and height of text window
359 #define BRIEFING_SECRET_NUM 31 // This must correspond to the first secret level which must come at the end of the list.
360 #define BRIEFING_OFFSET_NUM 4 // This must correspond to the first level screen (ie, past the bald guy briefing screens)
362 #define SHAREWARE_ENDING_LEVEL_NUM 0x7f
363 #define REGISTERED_ENDING_LEVEL_NUM 0x7e
366 #define ENDING_LEVEL_NUM SHAREWARE_ENDING_LEVEL_NUM
368 #define ENDING_LEVEL_NUM REGISTERED_ENDING_LEVEL_NUM
371 #define MAX_BRIEFING_SCREENS 60
373 briefing_screen Briefing_screens[MAX_BRIEFING_SCREENS]=
374 {{"brief03.pcx",0,3,8,8,257,177}}; // default=0!!!
376 briefing_screen D1_Briefing_screens[] = {
377 { "brief01.pcx", 0, 1, 13, 140, 290, 59 },
378 { "brief02.pcx", 0, 2, 27, 34, 257, 177 },
379 { "brief03.pcx", 0, 3, 20, 22, 257, 177 },
380 { "brief02.pcx", 0, 4, 27, 34, 257, 177 },
382 { "moon01.pcx", 1, 5, 10, 10, 300, 170 }, // level 1
383 { "moon01.pcx", 2, 6, 10, 10, 300, 170 }, // level 2
384 { "moon01.pcx", 3, 7, 10, 10, 300, 170 }, // level 3
386 { "venus01.pcx", 4, 8, 15, 15, 300, 200 }, // level 4
387 { "venus01.pcx", 5, 9, 15, 15, 300, 200 }, // level 5
389 { "brief03.pcx", 6, 10, 20, 22, 257, 177 },
390 { "merc01.pcx", 6, 11, 10, 15, 300, 200 }, // level 6
391 { "merc01.pcx", 7, 12, 10, 15, 300, 200 }, // level 7
394 { "brief03.pcx", 8, 13, 20, 22, 257, 177 },
395 { "mars01.pcx", 8, 14, 10, 100, 300, 200 }, // level 8
396 { "mars01.pcx", 9, 15, 10, 100, 300, 200 }, // level 9
397 { "brief03.pcx", 10, 16, 20, 22, 257, 177 },
398 { "mars01.pcx", 10, 17, 10, 100, 300, 200 }, // level 10
400 { "jup01.pcx", 11, 18, 10, 40, 300, 200 }, // level 11
401 { "jup01.pcx", 12, 19, 10, 40, 300, 200 }, // level 12
402 { "brief03.pcx", 13, 20, 20, 22, 257, 177 },
403 { "jup01.pcx", 13, 21, 10, 40, 300, 200 }, // level 13
404 { "jup01.pcx", 14, 22, 10, 40, 300, 200 }, // level 14
406 { "saturn01.pcx", 15, 23, 10, 40, 300, 200 }, // level 15
407 { "brief03.pcx", 16, 24, 20, 22, 257, 177 },
408 { "saturn01.pcx", 16, 25, 10, 40, 300, 200 }, // level 16
409 { "brief03.pcx", 17, 26, 20, 22, 257, 177 },
410 { "saturn01.pcx", 17, 27, 10, 40, 300, 200 }, // level 17
412 { "uranus01.pcx", 18, 28, 100, 100, 300, 200 }, // level 18
413 { "uranus01.pcx", 19, 29, 100, 100, 300, 200 }, // level 19
414 { "uranus01.pcx", 20, 30, 100, 100, 300, 200 }, // level 20
415 { "uranus01.pcx", 21, 31, 100, 100, 300, 200 }, // level 21
417 { "neptun01.pcx", 22, 32, 10, 20, 300, 200 }, // level 22
418 { "neptun01.pcx", 23, 33, 10, 20, 300, 200 }, // level 23
419 { "neptun01.pcx", 24, 34, 10, 20, 300, 200 }, // level 24
421 { "pluto01.pcx", 25, 35, 10, 20, 300, 200 }, // level 25
422 { "pluto01.pcx", 26, 36, 10, 20, 300, 200 }, // level 26
423 { "pluto01.pcx", 27, 37, 10, 20, 300, 200 }, // level 27
425 { "aster01.pcx", -1, 38, 10, 90, 300, 200 }, // secret level -1
426 { "aster01.pcx", -2, 39, 10, 90, 300, 200 }, // secret level -2
427 { "aster01.pcx", -3, 40, 10, 90, 300, 200 }, // secret level -3
430 { "end01.pcx", SHAREWARE_ENDING_LEVEL_NUM, 1, 23, 40, 320, 200 }, // shareware end
432 { "end02.pcx", REGISTERED_ENDING_LEVEL_NUM, 1, 5, 5, 300, 200 }, // registered end
433 { "end01.pcx", REGISTERED_ENDING_LEVEL_NUM, 2, 23, 40, 320, 200 }, // registered end
434 { "end03.pcx", REGISTERED_ENDING_LEVEL_NUM, 3, 5, 5, 300, 200 }, // registered end
439 #define NUM_D1_BRIEFING_SCREENS (sizeof(D1_Briefing_screens)/sizeof(briefing_screen))
441 int Briefing_text_x, Briefing_text_y;
443 void init_char_pos(int x, int y)
447 mprintf ((0,"Setting init x=%d y=%d\n",x,y));
450 grs_canvas *Robot_canv = NULL;
451 vms_angvec Robot_angles;
453 char Bitmap_name[32] = "";
454 #define EXIT_DOOR_MAX 14
455 #define OTHER_THING_MAX 10 // Adam: This is the number of frames in your new animating thing.
456 #define DOOR_DIV_INIT 6
457 sbyte Door_dir=1, Door_div_count=0, Animating_bitmap_type=0;
459 //-----------------------------------------------------------------------------
460 void show_bitmap_frame(void)
462 grs_canvas *curcanv_save, *bitmap_canv=0;
464 grs_bitmap *bitmap_ptr;
466 // Only plot every nth frame.
467 if (Door_div_count) {
472 Door_div_count = DOOR_DIV_INIT;
474 if (Bitmap_name[0] != 0) {
478 // Set supertransparency color to black
479 if (!New_pal_254_bash) {
480 New_pal_254_bash = 1;
482 New_pal[254*3+1] = 0;
483 New_pal[254*3+2] = 0;
484 gr_palette_load( New_pal );
487 switch (Animating_bitmap_type) {
489 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 64, 64);
492 bitmap_canv = gr_create_sub_canvas(grd_curcanv, rescale_x(220), rescale_x(45), 94, 94);
495 // Adam: Change here for your new animating bitmap thing. 94, 94 are bitmap size.
497 Int3(); // Impossible, illegal value for Animating_bitmap_type
500 curcanv_save = grd_curcanv; grd_curcanv = bitmap_canv;
502 pound_signp = strchr(Bitmap_name, '#');
503 Assert(pound_signp != NULL);
505 dig1 = *(pound_signp+1);
506 dig2 = *(pound_signp+2);
510 num = (dig1-'0')*10 + (dig2-'0');
512 switch (Animating_bitmap_type) {
515 if (num > EXIT_DOOR_MAX) {
518 } else if (num < 0) {
525 if (num > OTHER_THING_MAX)
532 *(pound_signp+1) = (num / 10) + '0';
533 *(pound_signp+2) = (num % 10) + '0';
534 *(pound_signp+3) = 0;
536 *(pound_signp+1) = (num % 10) + '0';
537 *(pound_signp+2) = 0;
542 bi = piggy_find_bitmap(Bitmap_name);
543 bitmap_ptr = &GameBitmaps[bi.index];
547 gr_bitmapm(0, 0, bitmap_ptr);
549 grd_curcanv = curcanv_save;
552 switch (Animating_bitmap_type) {
554 if (num == EXIT_DOOR_MAX) {
557 } else if (num == 0) {
569 //-----------------------------------------------------------------------------
570 void show_briefing_bitmap(grs_bitmap *bmp)
572 grs_canvas *curcanv_save, *bitmap_canv;
574 bitmap_canv = gr_create_sub_canvas(grd_curcanv, 220, 45, bmp->bm_w, bmp->bm_h);
575 curcanv_save = grd_curcanv;
576 gr_set_current_canvas(bitmap_canv);
577 gr_bitmapm(0, 0, bmp);
578 gr_set_current_canvas(curcanv_save);
583 //-----------------------------------------------------------------------------
584 void show_spinning_robot_frame(int robot_num)
586 grs_canvas *curcanv_save;
588 if (robot_num != -1) {
589 Robot_angles.h += 150;
591 curcanv_save = grd_curcanv;
592 grd_curcanv = Robot_canv;
593 Assert(Robot_info[robot_num].model_num != -1);
594 draw_model_picture(Robot_info[robot_num].model_num, &Robot_angles);
595 grd_curcanv = curcanv_save;
600 //-----------------------------------------------------------------------------
601 void init_spinning_robot(void) //(int x,int y,int w,int h)
603 //Robot_angles.p += 0;
604 //Robot_angles.b += 0;
605 //Robot_angles.h += 0;
607 int x = rescale_x(138);
608 int y = rescale_y(55);
609 int w = rescale_x(166);
610 int h = rescale_y(138);
612 Robot_canv = gr_create_sub_canvas(grd_curcanv, x, y, w, h);
616 //---------------------------------------------------------------------------
617 // Returns char width.
618 // If show_robot_flag set, then show a frame of the spinning robot.
619 int show_char_delay(char the_char, int delay, int robot_num, int cursor_flag)
623 static fix start_time=0;
625 message[0] = the_char;
628 if (start_time==0 && timer_get_fixed_seconds()<0)
629 start_time=timer_get_fixed_seconds();
631 gr_get_string_size(message, &w, &h, &aw );
633 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
635 // Draw cursor if there is some delay and caller says to draw cursor
636 if (cursor_flag && delay) {
637 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
638 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
643 delay=fixdiv (F1_0,i2f(15));
645 if ((Bitmap_name[0] != 0) && (delay != 0))
648 if (RobotPlaying && (delay != 0))
651 while (timer_get_fixed_seconds() < (start_time + delay)) {
652 if (RobotPlaying && delay != 0)
656 show_spinning_robot_frame(robot_num);
658 start_time = timer_get_fixed_seconds();
661 if (cursor_flag && delay) {
662 gr_set_fontcolor(Erase_color, -1);
663 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
666 // Draw the character
667 gr_set_fontcolor(Briefing_background_colors[Current_color], -1);
668 gr_printf(Briefing_text_x, Briefing_text_y, message );
670 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
671 gr_printf(Briefing_text_x+1, Briefing_text_y, message );
673 if (delay) gr_update();
675 // if (the_char != ' ')
676 // if (!digi_is_sound_playing(SOUND_MARKER_HIT))
677 // digi_play_sample( SOUND_MARKER_HIT, F1_0 );
682 //-----------------------------------------------------------------------------
683 int load_briefing_screen( int screen_num )
689 fname = Briefing_screens[screen_num].bs_name;
691 fname = CurBriefScreenName;
693 if ((pcx_error = pcx_read_fullscr(fname, New_pal)) != PCX_ERROR_NONE) {
694 printf( "File '%s', PCX load error: %s\n (It's a briefing screen. Does this cause you pain?)\n", fname, pcx_errormsg(pcx_error));
695 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);
696 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n", fname, pcx_errormsg(pcx_error), pcx_error);
702 int load_new_briefing_screen( char *fname )
706 mprintf ((0,"Loading new briefing <%s>\n",fname));
707 strcpy (CurBriefScreenName,fname);
709 if (gr_palette_fade_out( New_pal, 32, 0 ))
712 if ((pcx_error=pcx_read_fullscr( fname, New_pal ))!=PCX_ERROR_NONE) {
713 //if ((pcx_error=pcx_read_bitmap( fname, &grd_curcanv->cv_bitmap, grd_curcanv->cv_bitmap.bm_type, New_pal ))!=PCX_ERROR_NONE) {
714 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);
715 Error( "Error loading briefing screen <%s>, PCX load error: %s (%i)\n",fname, pcx_errormsg(pcx_error), pcx_error);
718 gr_copy_palette(gr_palette, New_pal, sizeof(gr_palette));
720 if (gr_palette_fade_in( New_pal, 32, 0 ))
722 DoBriefingColorStuff();
729 #define KEY_DELAY_DEFAULT ((F1_0*20)/1000)
731 //-----------------------------------------------------------------------------
732 int get_message_num(char **message)
736 while (**message == ' ')
739 while ((**message >= '0') && (**message <= '9')) {
740 num = 10*num + **message-'0';
744 while (*(*message)++ != 10) // Get and drop eoln
750 //-----------------------------------------------------------------------------
751 void get_message_name(char **message, char *result)
753 while (**message == ' ')
756 while ((**message != ' ') && (**message != 10)) {
757 if (**message != '\n')
758 *result++ = **message;
763 while (*(*message)++ != 10) // Get and drop eoln
769 //-----------------------------------------------------------------------------
770 void flash_cursor(int cursor_flag)
772 if (cursor_flag == 0)
775 if ((timer_get_fixed_seconds() % (F1_0/2) ) > (F1_0/4))
776 gr_set_fontcolor(Briefing_foreground_colors[Current_color], -1);
778 gr_set_fontcolor(Erase_color, -1);
780 gr_printf(Briefing_text_x+1, Briefing_text_y, "_" );
784 extern int InitMovieBriefing();
787 //-----------------------------------------------------------------------------
788 // Return true if message got aborted by user (pressed ESC), else return false.
789 int show_briefing_message(int screen_num, char *message)
793 briefing_screen *bsp;
794 int delay_count = KEY_DELAY_DEFAULT;
798 static int tab_stop=0;
799 int flashing_cursor=0;
800 int new_page=0,GotZ=0;
801 char spinRobotName[]="rba.mve",kludge; // matt don't change this!
805 int hum_channel=-1,printing_channel=-1;
806 int LineAdjustment=1;
815 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
818 // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y));
819 gr_set_curfont( GAME_FONT );
823 MALLOC(bsp, briefing_screen, 1);
824 memcpy(bsp, &Briefing_screens[screen_num], sizeof(briefing_screen));
825 bsp->text_ulx = rescale_x(bsp->text_ulx);
826 bsp->text_uly = rescale_y(bsp->text_uly);
827 bsp->text_width = rescale_x(bsp->text_width);
828 bsp->text_height = rescale_y(bsp->text_height);
829 init_char_pos(bsp->text_ulx, bsp->text_uly);
831 bsp=&Briefing_screens[0];
832 init_char_pos(bsp->text_ulx, bsp->text_uly-(8*(1+MenuHires)));
840 screen_num=DefineBriefingBox (&message);
841 //load_new_briefing_screen (Briefing_screens[screen_num].bs_name);
843 bsp = &Briefing_screens[screen_num];
844 init_char_pos(bsp->text_ulx, bsp->text_uly);
846 prev_ch = 10; // read to eoln
847 } else if (ch=='U') {
848 screen_num=get_message_num(&message);
849 bsp = &Briefing_screens[screen_num];
850 init_char_pos(bsp->text_ulx, bsp->text_uly);
851 prev_ch = 10; // read to eoln
852 } else if (ch == 'C') {
853 Current_color = get_message_num(&message)-1;
854 Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS));
856 } else if (ch == 'F') { // toggle flashing cursor
857 flashing_cursor = !flashing_cursor;
859 while (*message++ != 10)
861 } else if (ch == 'T') {
862 tab_stop = get_message_num(&message);
863 tab_stop*=(1+MenuHires);
864 prev_ch = 10; // read to eoln
865 } else if (ch == 'R') {
866 if (Robot_canv != NULL) {
876 init_spinning_robot();
877 robot_num = get_message_num(&message);
878 while (*message++ != 10)
882 spinRobotName[2]=kludge; // ugly but proud
884 RobotPlaying=InitRobotMovie(spinRobotName);
886 // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 );
890 DoBriefingColorStuff ();
891 mprintf ((0,"Robot playing is %d!!!",RobotPlaying));
894 prev_ch = 10; // read to eoln
895 } else if (ch == 'N') {
896 //--grs_bitmap *bitmap_ptr;
897 if (Robot_canv != NULL) {
902 get_message_name(&message, Bitmap_name);
903 strcat(Bitmap_name, "#0");
904 Animating_bitmap_type = 0;
906 } else if (ch == 'O') {
907 if (Robot_canv != NULL) {
912 get_message_name(&message, Bitmap_name);
913 strcat(Bitmap_name, "#0");
914 Animating_bitmap_type = 1;
916 } else if (ch=='A') {
917 LineAdjustment=1-LineAdjustment;
918 } else if (ch=='Z') {
919 //mprintf ((0,"Got a Z!\n"));
921 #if 1 //defined (D2_OEM) || defined(COMPILATION) || (defined(MACINTOSH) && defined(SHAREWARE))
924 if (LineAdjustment==1)
931 while ((fname[i]=*message) != '\n') {
937 while (*message++ != 10) // Get and drop eoln
944 while (fname[i]!='.') {
945 fname2[i] = fname[i];
955 if ((MenuHires && cfexist(fname2)) || !cfexist(fname))
956 load_new_briefing_screen (fname2);
958 load_new_briefing_screen (fname);
961 //load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
963 } else if (ch == 'B') {
964 char bitmap_name[32];
965 grs_bitmap guy_bitmap;
966 ubyte temp_palette[768];
969 if (Robot_canv != NULL) {
974 get_message_name(&message, bitmap_name);
975 strcat(bitmap_name, ".bbm");
976 guy_bitmap.bm_data = NULL;
977 iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette);
978 Assert(iff_error == IFF_NO_ERROR);
979 gr_remap_bitmap_good( &guy_bitmap, temp_palette, -1, -1 );
981 show_briefing_bitmap(&guy_bitmap);
982 d_free(guy_bitmap.bm_data);
984 // } else if (ch==EOF) {
986 // } else if (ch == 'B') {
987 // if (Robot_canv != NULL) {
988 // d_free(Robot_canv);
992 // bitmap_num = get_message_num(&message);
993 // if (bitmap_num != -1)
994 // show_briefing_bitmap(Textures[bitmap_num]);
995 // prev_ch = 10; // read to eoln
996 } else if (ch == 'S') {
1001 if (printing_channel>-1)
1002 digi_stop_sound( printing_channel );
1003 printing_channel=-1;
1007 start_time = timer_get_fixed_seconds();
1008 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1010 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1012 flash_cursor(flashing_cursor);
1016 if (robot_num != -1)
1017 show_spinning_robot_frame(robot_num);
1019 if (Bitmap_name[0] != 0)
1020 show_bitmap_frame();
1021 start_time += KEY_DELAY_DEFAULT/2;
1025 if (keypress == KEY_BACKSP)
1028 if (keypress == KEY_ESC)
1031 flashing_cursor = 0;
1033 } else if (ch == 'P') { // New page.
1035 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1036 // printing to it! You know, $Z !!!
1037 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1041 while (*message != 10) {
1042 message++; // drop carriage return after special escape sequence
1048 } else if (ch == '\t') { // Tab
1049 if (Briefing_text_x - bsp->text_ulx < tab_stop)
1050 Briefing_text_x = bsp->text_ulx + tab_stop;
1051 } else if ((ch == ';') && (prev_ch == 10)) {
1052 while (*message++ != 10)
1055 } else if (ch == '\\') {
1057 } else if (ch == 10) {
1058 if (prev_ch != '\\') {
1061 Briefing_text_y += (8*(MenuHires+1));
1064 Briefing_text_x = bsp->text_ulx;
1065 if (Briefing_text_y > bsp->text_uly + bsp->text_height) {
1066 load_briefing_screen(screen_num);
1067 Briefing_text_x = bsp->text_ulx;
1068 Briefing_text_y = bsp->text_uly;
1071 if (ch == 13) //Can this happen? Above says ch==10
1078 Int3(); // Hey ryan!!!! You gotta load a screen before you start
1079 // printing to it! You know, $Z !!!
1080 load_new_briefing_screen (MenuHires?"end01b.pcx":"end01.pcx");
1086 printing_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_PRINTING), F1_0, 0xFFFF/2, 1, -1, -1, -1 );
1090 Briefing_text_x += show_char_delay(ch, delay_count, robot_num, flashing_cursor);
1094 // Check for Esc -> abort.
1096 key_check=local_key_inkey();
1101 if (_RedrawScreen) {
1102 _RedrawScreen = FALSE;
1103 hum_channel = digi_start_sound( digi_xlat_sound(SOUND_BRIEFING_HUM), F1_0/2, 0xFFFF/2, 1, -1, -1, -1 );
1104 key_check = KEY_ESC;
1107 if ( key_check == KEY_ESC ) {
1112 if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER))
1115 #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
1116 if ((key_check == KEY_ALTED+KEY_ENTER) ||
1117 (key_check == KEY_ALTED+KEY_PADENTER))
1118 gr_toggle_fullscreen();
1121 if (Briefing_text_x > bsp->text_ulx + bsp->text_width) {
1122 Briefing_text_x = bsp->text_ulx;
1123 Briefing_text_y += bsp->text_uly;
1126 if ((new_page) || (Briefing_text_y > bsp->text_uly + bsp->text_height)) {
1132 if (printing_channel>-1)
1133 digi_stop_sound( printing_channel );
1134 printing_channel=-1;
1138 start_time = timer_get_fixed_seconds();
1139 while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key
1140 while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2)
1142 flash_cursor(flashing_cursor);
1145 if (robot_num != -1)
1146 show_spinning_robot_frame(robot_num);
1147 if (Bitmap_name[0] != 0)
1148 show_bitmap_frame();
1149 start_time += KEY_DELAY_DEFAULT/2;
1158 if (keypress == KEY_BACKSP)
1161 if (keypress == KEY_ESC) {
1166 load_briefing_screen(screen_num);
1167 Briefing_text_x = bsp->text_ulx;
1168 Briefing_text_y = bsp->text_uly;
1169 delay_count = KEY_DELAY_DEFAULT;
1178 if (Robot_canv != NULL)
1179 {d_free(Robot_canv); Robot_canv=NULL;}
1182 digi_stop_sound( hum_channel );
1183 if (printing_channel>-1)
1184 digi_stop_sound( printing_channel );
1192 //-----------------------------------------------------------------------------
1193 // Return a pointer to the start of text for screen #screen_num.
1194 char * get_briefing_message(int screen_num)
1196 char *tptr = Briefing_text;
1200 Assert(screen_num >= 0);
1202 while ( (*tptr != 0 ) && (screen_num != cur_screen)) {
1207 cur_screen = get_message_num(&tptr);
1211 if (screen_num!=cur_screen)
1217 //-----------------------------------------------------------------------------
1218 // Load Descent briefing text.
1219 int load_screen_text(char *filename, char **buf)
1224 int have_binary = 0;
1226 if ((tfile = cfopen(filename,"rb")) == NULL) {
1227 char nfilename[30], *ptr;
1229 strcpy(nfilename, filename);
1230 if ((ptr = strrchr(nfilename, '.')))
1232 strcat(nfilename, ".txb");
1233 if ((ifile = cfopen(nfilename, "rb")) == NULL) {
1234 mprintf ((0,"can't open %s!\n",nfilename));
1236 //Error("Cannot open file %s or %s", filename, nfilename);
1239 mprintf ((0,"reading...\n"));
1242 len = cfilelength(ifile);
1243 MALLOC(*buf, char, len+500);
1244 mprintf ((0,"len=%d\n",len));
1245 for (x=0, i=0; i < len; i++, x++) {
1246 cfread (*buf+x,1,1,ifile);
1247 // mprintf ((0,"%c",*(*buf+x)));
1254 len = cfilelength(tfile);
1255 MALLOC(*buf, char, len+500);
1256 for (x=0, i=0; i < len; i++, x++) {
1257 cfread (*buf+x,1,1,tfile);
1258 // mprintf ((0,"%c",*(*buf+x)));
1264 //cfread(*buf, 1, len, tfile);
1269 decode_text(*buf, len);
1274 //-----------------------------------------------------------------------------
1275 // Return true if message got aborted, else return false.
1276 int show_briefing_text(int screen_num)
1280 message_ptr = get_briefing_message
1281 (EMULATING_D1 ? Briefing_screens[screen_num].message_num : screen_num);
1283 if (message_ptr==NULL)
1286 DoBriefingColorStuff();
1288 return show_briefing_message(screen_num, message_ptr);
1291 void DoBriefingColorStuff ()
1293 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 40, 0);
1294 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 6, 0);
1296 Briefing_foreground_colors[1] = gr_find_closest_color_current( 40, 33, 35);
1297 Briefing_background_colors[1] = gr_find_closest_color_current( 5, 5, 5);
1299 Briefing_foreground_colors[2] = gr_find_closest_color_current( 8, 31, 54);
1300 Briefing_background_colors[2] = gr_find_closest_color_current( 1, 4, 7);
1304 Briefing_foreground_colors[0] = gr_find_closest_color_current( 0, 54, 0);
1305 Briefing_background_colors[0] = gr_find_closest_color_current( 0, 19, 0);
1307 Briefing_foreground_colors[1] = gr_find_closest_color_current( 42, 38, 32);
1308 Briefing_background_colors[1] = gr_find_closest_color_current( 14, 14, 14);
1310 //Begin D1X addition
1312 Briefing_foreground_colors[2] = gr_find_closest_color_current( 63, 0, 0);
1313 Briefing_background_colors[2] = gr_find_closest_color_current( 31, 0, 0);
1316 Briefing_foreground_colors[3] = gr_find_closest_color_current( 0, 0, 54);
1317 Briefing_background_colors[3] = gr_find_closest_color_current( 0, 0, 19);
1319 Briefing_foreground_colors[4] = gr_find_closest_color_current( 14, 14, 14);
1320 Briefing_background_colors[4] = gr_find_closest_color_current( 0, 0, 0);
1322 Briefing_foreground_colors[5] = gr_find_closest_color_current( 54, 54, 0);
1323 Briefing_background_colors[5] = gr_find_closest_color_current( 19, 19, 0);
1325 Briefing_foreground_colors[6] = gr_find_closest_color_current( 0, 54, 54);
1326 Briefing_background_colors[6] = gr_find_closest_color_current( 0, 19, 19);
1329 Erase_color = gr_find_closest_color_current(0, 0, 0);
1332 //-----------------------------------------------------------------------------
1333 // Return true if screen got aborted by user, else return false.
1334 int show_briefing_screen( int screen_num, int allow_keys)
1337 //ubyte palette_save[768];
1339 New_pal_254_bash = 0;
1341 if (Skip_briefing_screens) {
1342 mprintf((0, "Skipping briefing screen [%s]\n", &Briefing_screens[screen_num].bs_name));
1349 grs_bitmap briefing_bm;
1351 gr_init_bitmap_data(&briefing_bm);
1352 if ((pcx_error=pcx_read_bitmap(Briefing_screens[screen_num].bs_name, &briefing_bm, BM_LINEAR, New_pal))!=PCX_ERROR_NONE) {
1354 if ((pcx_error=pcx_read_fullscr(Briefing_screens[screen_num].bs_name, New_pal))!=PCX_ERROR_NONE) {
1356 printf("PCX load error: %s. File '%s'\n\n", pcx_errormsg(pcx_error), Briefing_screens[screen_num].bs_name);
1357 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));
1363 //memcpy(palette_save, gr_palette, sizeof(palette_save));
1364 //memcpy(New_pal, gr_palette, sizeof(gr_palette));
1366 //vfx_set_palette_sub( New_pal );
1368 gr_palette_load(New_pal);
1372 gr_set_current_canvas( NULL );
1373 show_fullscr(&briefing_bm);
1376 //added on 9/13/98 by adb to make arch's requiring updates work
1378 //end changes by adb
1381 gr_free_bitmap_data (&briefing_bm);
1384 if (gr_palette_fade_in( New_pal, 32, allow_keys ))
1387 //memcpy(gr_palette,New_pal,sizeof(gr_palette));
1392 key_close(); // kill the keyboard handler during briefing screens for movies
1394 rval = show_briefing_text(screen_num);
1399 #if defined (MACINTOSH) || defined(WINDOWS)
1400 memcpy(New_pal,gr_palette,sizeof(gr_palette)); // attempt to get fades after briefing screens done correctly.
1404 if (gr_palette_fade_out( New_pal, 32, allow_keys ))
1407 //gr_copy_palette(gr_palette, palette_save, sizeof(palette_save));
1409 //d_free(briefing_bm.bm_data);
1415 //-----------------------------------------------------------------------------
1416 void do_briefing_screens(char *filename,int level_num)
1418 int abort_briefing_screens = 0;
1419 int cur_briefing_screen = 0;
1421 if (Skip_briefing_screens) {
1422 mprintf((0, "Skipping all briefing screens.\n"));
1427 return; // no briefing screens at all for demo
1431 mprintf ((0,"Trying briefing screen <%s>\n",filename));
1433 if (!filename || !*filename)
1436 if (!load_screen_text(filename, &Briefing_text))
1440 songs_play_song( SONG_BRIEFING, 1 );
1445 set_screen_mode( SCREEN_MENU );
1447 gr_set_current_canvas(NULL);
1449 mprintf ((0,"Playing briefing screen <%s>, level %d\n",filename,level_num));
1456 for (i = 0; i < NUM_D1_BRIEFING_SCREENS; i++)
1457 memcpy(&Briefing_screens[i], &D1_Briefing_screens[i], sizeof(briefing_screen));
1459 if (level_num == 1) {
1460 while ((!abort_briefing_screens) && (Briefing_screens[cur_briefing_screen].level_num == 0)) {
1461 abort_briefing_screens = show_briefing_screen(cur_briefing_screen, 0);
1462 cur_briefing_screen++;
1466 if (!abort_briefing_screens) {
1467 for (cur_briefing_screen = 0; cur_briefing_screen < NUM_D1_BRIEFING_SCREENS; cur_briefing_screen++)
1468 if (Briefing_screens[cur_briefing_screen].level_num == level_num)
1469 if (show_briefing_screen(cur_briefing_screen, 0))
1474 show_briefing_screen(level_num,0);
1476 d_free (Briefing_text);
1483 int DefineBriefingBox (char **buf)
1488 n=get_new_message_num (buf);
1490 Assert(n < MAX_BRIEFING_SCREENS);
1492 while (**buf!=' ') {
1497 name[i]='\0'; // slap a delimiter on this guy
1499 strcpy (Briefing_screens[n].bs_name,name);
1500 Briefing_screens[n].level_num=get_new_message_num (buf);
1501 Briefing_screens[n].message_num=get_new_message_num (buf);
1502 Briefing_screens[n].text_ulx=get_new_message_num (buf);
1503 Briefing_screens[n].text_uly=get_new_message_num (buf);
1504 Briefing_screens[n].text_width=get_new_message_num (buf);
1505 Briefing_screens[n].text_height=get_message_num (buf); // NOTICE!!!
1507 Briefing_screens[n].text_ulx = rescale_x(Briefing_screens[n].text_ulx);
1508 Briefing_screens[n].text_uly = rescale_y(Briefing_screens[n].text_uly);
1509 Briefing_screens[n].text_width = rescale_x(Briefing_screens[n].text_width);
1510 Briefing_screens[n].text_height = rescale_y(Briefing_screens[n].text_height);
1515 int get_new_message_num(char **message)
1519 while (**message == ' ')
1522 while ((**message >= '0') && (**message <= '9')) {
1523 num = 10*num + **message-'0';
1532 void show_order_form()
1537 unsigned char title_pal[768];
1538 char exit_screen[16];
1540 gr_set_current_canvas( NULL );
1545 strcpy(exit_screen, MenuHires?"ordrd2ob.pcx":"ordrd2o.pcx"); // OEM
1546 if (! cfexist(exit_screen))
1547 strcpy(exit_screen, MenuHires?"orderd2b.pcx":"orderd2.pcx"); // SHAREWARE, prefer mac if hires
1548 if (! cfexist(exit_screen))
1549 strcpy(exit_screen, MenuHires?"orderd2.pcx":"orderd2b.pcx"); // SHAREWARE, have to rescale
1550 if (! cfexist(exit_screen))
1551 strcpy(exit_screen, MenuHires?"warningb.pcx":"warning.pcx"); // D1
1552 if (! cfexist(exit_screen))
1553 return; // D2 registered
1555 if ((pcx_error=pcx_read_fullscr( exit_screen, title_pal ))==PCX_ERROR_NONE) {
1556 //vfx_set_palette_sub( title_pal );
1557 gr_palette_fade_in( title_pal, 32, 0 );
1559 while (!key_inkey() && !mouse_button_state(0)) {} //key_getch();
1560 gr_palette_fade_out( title_pal, 32, 0 );
1563 Int3(); //can't load order screen