1 /* $Id: credits.c,v 1.8 2003-10-10 09:36:34 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.
17 * Routines to display the credits.
20 * Revision 1.8 1995/11/07 13:54:56 allender
21 * loop shareware song since it is too short
23 * Revision 1.7 1995/10/31 10:24:25 allender
26 * Revision 1.6 1995/10/27 15:17:57 allender
27 * minor fix to get them to look right at top and bottom
30 * Revision 1.5 1995/10/21 22:50:49 allender
31 * credits is way cool!!!!
33 * Revision 1.3 1995/08/08 13:45:26 allender
34 * added macsys header file
36 * Revision 1.2 1995/07/17 08:49:48 allender
37 * make work in 640x480 -- still needs major work!!
39 * Revision 1.1 1995/05/16 15:24:01 allender
42 * Revision 2.2 1995/06/14 17:26:08 john
43 * Fixed bug with VFX palette not getting loaded for credits, titles.
45 * Revision 2.1 1995/03/06 15:23:30 john
46 * New screen techniques.
48 * Revision 2.0 1995/02/27 11:29:25 john
49 * New version 2.0, which has no anonymous unions, builds with
50 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
52 * Revision 1.33 1995/02/11 12:41:56 john
53 * Added new song method, with FM bank switching..
55 * Revision 1.32 1995/02/03 14:18:06 john
58 * Revision 1.31 1994/12/28 10:43:00 john
61 * Revision 1.30 1994/12/20 18:22:31 john
62 * Added code to support non-looping songs, and put
63 * it in for endlevel and credits.
65 * Revision 1.29 1994/12/15 14:23:00 adam
68 * Revision 1.28 1994/12/14 16:56:33 adam
69 * *** empty log message ***
71 * Revision 1.27 1994/12/14 12:18:11 adam
74 * Revision 1.26 1994/12/12 22:52:59 matt
77 * Revision 1.25 1994/12/12 22:49:35 adam
78 * *** empty log message ***
80 * Revision 1.24 1994/12/09 23:16:50 john
81 * Make credits.txb load.
83 * Revision 1.23 1994/12/09 00:41:54 mike
84 * fix hang in automap print screen.
86 * Revision 1.22 1994/12/09 00:34:22 matt
87 * Added support for half-height lines
89 * Revision 1.21 1994/12/08 18:36:03 yuan
90 * More HOGfile support.
92 * Revision 1.20 1994/12/04 14:48:17 john
93 * Made credits restore playing descent.hmp.
95 * Revision 1.19 1994/12/04 14:30:20 john
96 * Added hooks for music..
98 * Revision 1.18 1994/12/04 12:06:46 matt
99 * Put in support for large font
101 * Revision 1.17 1994/12/01 10:47:27 john
102 * Took out code that allows keypresses to change scroll rate.
104 * Revision 1.16 1994/11/30 12:10:52 adam
105 * added support for PCX titles/brief screens
107 * Revision 1.15 1994/11/27 23:12:17 matt
108 * Made changes for new mprintf calling convention
110 * Revision 1.14 1994/11/27 19:51:46 matt
111 * Made screen shots work in a few more places
113 * Revision 1.13 1994/11/18 16:41:51 adam
114 * trimmed some more meat for shareware
116 * Revision 1.12 1994/11/10 20:38:29 john
117 * Made credits not loop.
119 * Revision 1.11 1994/11/05 15:04:06 john
120 * Added non-popup menu for the main menu, so that scores and credits don't have to save
123 * Revision 1.10 1994/11/05 14:05:52 john
124 * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep
125 * track of whether the palette is faded in or not. Then, wherever the code needs to fade out,
126 * it just calls gr_palette_fade_out and it will fade out if it isn't already. The same with fade_in.
127 * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc.
129 * Revision 1.9 1994/11/04 12:02:32 john
130 * Fixed fading transitions a bit more.
132 * Revision 1.8 1994/11/04 11:30:44 john
133 * Fixed fade transitions between game/menu/credits.
135 * Revision 1.7 1994/11/04 11:06:32 john
136 * Added code to support credit fade table.
138 * Revision 1.6 1994/11/04 10:16:13 john
139 * Made the credits fade in/out smoothly on top of a bitmap background.
141 * Revision 1.5 1994/11/03 21:24:12 john
142 * Made credits exit the instant a key is pressed.
143 * Made it scroll a bit slower.
145 * Revision 1.4 1994/11/03 21:20:28 john
148 * Revision 1.3 1994/11/03 21:01:24 john
149 * First version of credits that works.
151 * Revision 1.2 1994/11/03 20:17:39 john
152 * Added initial code for showing credits.
154 * Revision 1.1 1994/11/03 20:09:05 john
165 static char rcsid[] = "$Id: credits.c,v 1.8 2003-10-10 09:36:34 btb Exp $";
178 #include "pa_enabl.h" //$$POLY_ACC
190 #include "gamefont.h"
205 #include "menu.h" // for MenuHires
207 #if defined(POLY_ACC)
208 #include "poly_acc.h"
211 #define ROW_SPACING (MenuHires?26:11)
212 #define NUM_LINES_HIRES 21
213 #define NUM_LINES (MenuHires?NUM_LINES_HIRES:20)
215 ubyte fade_values[200] = { 1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,8,9,9,10,10,
216 11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,
217 20,21,21,22,22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,
218 28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,
219 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,
220 30,30,30,30,29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,
221 25,25,24,24,24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,
222 17,16,16,15,15,15,14,14,13,13,12,12,12,11,11,10,10,9,9,8,8,8,7,7,6,6,5,
225 ubyte fade_values_hires[480] = { 1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,
226 5,5,5,6,6,6,6,6,7,7,7,7,7,8,8,8,8,8,9,9,9,9,9,10,10,10,10,10,10,11,11,11,11,11,12,12,12,12,12,12,
227 13,13,13,13,13,14,14,14,14,14,14,15,15,15,15,15,15,16,16,16,16,16,17,17,17,17,17,17,18,18,
228 18,18,18,18,18,19,19,19,19,19,19,20,20,20,20,20,20,20,21,21,21,21,21,21,22,22,22,22,22,22,
229 22,22,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,25,26,26,26,26,
230 26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,29,29,29,
231 29,29,29,29,29,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
232 30,30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
233 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,
234 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,29,29,29,29,29,29,29,29,29,29,29,29,
235 29,29,28,28,28,28,28,28,28,28,28,28,28,28,27,27,27,27,27,27,27,27,27,27,26,26,26,26,26,26,
236 26,26,26,25,25,25,25,25,25,25,25,25,24,24,24,24,24,24,24,24,23,23,23,23,23,23,23,22,22,22,
237 22,22,22,22,22,21,21,21,21,21,21,20,20,20,20,20,20,20,19,19,19,19,19,19,18,18,18,18,18,18,
238 18,17,17,17,17,17,17,16,16,16,16,16,15,15,15,15,15,15,14,14,14,14,14,14,13,13,13,13,13,12,
239 12,12,12,12,12,11,11,11,11,11,10,10,10,10,10,10,9,9,9,9,9,8,8,8,8,8,7,7,7,7,7,6,6,6,6,6,5,5,5,5,
240 5,5,4,4,4,4,4,3,3,3,3,3,2,2,2,2,2,1,1};
242 extern ubyte *gr_bitblt_fade_table;
244 grs_font * header_font;
245 grs_font * title_font;
246 grs_font * names_font;
249 #define ALLOWED_CHAR 'S'
251 #define ALLOWED_CHAR 'R'
255 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"\x01starsb.pcx":"\x01stars.pcx") //only read from hog file
257 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"starsb.pcx":"stars.pcx")
261 int left, top, width, height;
264 #define CREDITS_FILE (cfexist("mcredits.tex")?"mcredits.tex":cfexist("ocredits.tex")?"ocredits.tex":"credits.tex")
266 //if filename passed is NULL, show normal credits
267 void credits_show(char *credits_filename)
271 char buffer[NUM_LINES_HIRES][80];
273 ubyte backdrop_palette[768];
277 // fix time_delay = 4180; // ~ F1_0 / 12.9
278 // fix time_delay = 1784;
279 fix time_delay = 2800;
280 int first_line_offset,extra_inc=0;
281 int have_bin_file = 0;
285 WIN(int credinit = 0;)
287 box dirty_box[NUM_LINES_HIRES];
288 grs_canvas *CreditsOffscreenBuf=NULL;
291 dd_grs_canvas *save_canv,
292 grs_canvas *save_canv
296 save_canv = dd_grd_curcanv,
297 save_canv = grd_curcanv
300 // Clear out all tex buffer lines.
301 for (i=0; i<NUM_LINES; i++ )
304 dirty_box[i].left = dirty_box[i].top = dirty_box[i].width = dirty_box[i].height = 0;
308 sprintf(filename, "%s", CREDITS_FILE);
310 if (credits_filename) {
311 strcpy(filename,credits_filename);
314 file = cfopen( filename, "rb" );
318 if (credits_filename)
319 return; //ok to not find special filename
321 tempp = strchr(filename, '.');
323 sprintf(nfile, "%s.txb", filename);
324 file = cfopen(nfile, "rb");
326 Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
330 set_screen_mode(SCREEN_MENU);
332 WIN(DEFINE_SCREEN(NULL));
337 gr_use_palette_table( "credits.256" );
339 gr_palette_load(gr_palette);
341 #if defined(POLY_ACC)
342 pa_update_clut(gr_palette, 0, 256, 0);
344 header_font = gr_init_font( MenuHires?"font1-1h.fnt":"font1-1.fnt" );
345 title_font = gr_init_font( MenuHires?"font2-3h.fnt":"font2-3.fnt" );
346 names_font = gr_init_font( MenuHires?"font2-2h.fnt":"font2-2.fnt" );
347 backdrop.bm_data=NULL;
349 //MWA Made backdrop bitmap linear since it should always be. the current canvas may not
350 //MWA be linear, so we can't rely on grd_curcanv->cv_bitmap->bm_type.
352 pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
353 if (pcx_error != PCX_ERROR_NONE) {
358 songs_play_song( SONG_CREDITS, 1 );
360 gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
363 dd_gr_set_current_canvas(NULL),
364 gr_set_current_canvas(NULL)
366 WIN(DDGRLOCK(dd_grd_curcanv));
367 gr_bitmap(0,0,&backdrop);
368 WIN(DDGRUNLOCK(dd_grd_curcanv));
370 gr_palette_fade_in( gr_palette, 32, 0 );
372 // Create a new offscreen buffer for the credits screen
373 //MWA Let's be a little smarter about this and check the VR_offscreen buffer
374 //MWA for size to determine if we can use that buffer. If the game size
375 //MWA matches what we need, then lets save memory.
377 #ifndef PA_3DFX_VOODOO
379 if (MenuHires && VR_offscreen_buffer->cv_w == 640) {
380 CreditsOffscreenBuf = VR_offscreen_buffer;
382 else if (MenuHires) {
383 CreditsOffscreenBuf = gr_create_canvas(640,480);
386 CreditsOffscreenBuf = gr_create_canvas(320,200);
389 CreditsOffscreenBuf = gr_create_canvas(640,480);
392 CreditsOffscreenBuf = gr_create_canvas(640,480);
395 if (!CreditsOffscreenBuf)
396 Error("Not enough memory to allocate Credits Buffer.");
398 //gr_clear_canvas(BM_XRGB(0,0,0));
405 last_time = timer_get_fixed_seconds();
407 first_line_offset = 0;
416 buffer_line = (buffer_line+1) % NUM_LINES;
418 if (cfgets( buffer[buffer_line], 80, file )) {
420 if (have_bin_file) { // is this a binary tbl file
421 for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) {
422 encode_rotate_left(&(buffer[buffer_line][i]));
423 buffer[buffer_line][i] ^= BITMAP_TBL_XOR;
424 encode_rotate_left(&(buffer[buffer_line][i]));
427 p = buffer[buffer_line];
433 if (p[1] == ALLOWED_CHAR)
439 p = strchr(&buffer[buffer_line][0],'\n');
442 //fseek( file, 0, SEEK_SET);
443 buffer[buffer_line][0] = 0;
446 } while (extra_inc--);
449 NO_DFX (for (i=0; i<ROW_SPACING; i += (MenuHires?2:1) ) {)
450 PA_DFX (for (i=0; i<ROW_SPACING; i += (MenuHires?2:1) ) {)
453 y = first_line_offset - i;
455 gr_set_current_canvas(CreditsOffscreenBuf);
457 gr_bitmap(0,0,&backdrop);
459 for (j=0; j<NUM_LINES; j++ ) {
462 l = (buffer_line + j + 1 ) % NUM_LINES;
467 } else if ( s[0] == '$' ) {
468 grd_curcanv->cv_font = header_font;
470 } else if ( s[0] == '*' ) {
471 grd_curcanv->cv_font = title_font;
474 grd_curcanv->cv_font = names_font;
476 gr_bitblt_fade_table = (MenuHires?fade_values_hires:fade_values);
478 tempp = strchr( s, '\t' );
480 // Wacky Credits thing
481 int w, h, aw, w2, x1, x2;
484 gr_get_string_size( s, &w, &h, &aw );
485 x1 = ((MenuHires?320:160)-w)/2;
486 gr_printf( x1 , y, s );
487 gr_get_string_size( &tempp[1], &w2, &h, &aw );
488 x2 = (MenuHires?320:160)+(((MenuHires?320:160)-w2)/2);
489 gr_printf( x2, y, &tempp[1] );
491 dirty_box[j].left = ((MenuHires?320:160)-w)/2;
492 dirty_box[j].top = y;
493 dirty_box[j].width =(x2+w2)-x1;
494 dirty_box[j].height = h;
499 // Wacky Fast Credits thing
502 gr_get_string_size( s, &w, &h, &aw);
503 dirty_box[j].width = w;
504 dirty_box[j].height = h;
505 dirty_box[j].top = y;
506 dirty_box[j].left = ((MenuHires?640:320) - w) / 2;
508 gr_printf( 0x8000, y, s );
510 gr_bitblt_fade_table = NULL;
511 if (buffer[l][0] == '!')
517 { // Wacky Fast Credits Thing
521 for (j=0; j<NUM_LINES; j++ )
523 new_box = &dirty_box[j];
525 tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
528 #if defined(POLY_ACC)
529 if(new_box->width != 0)
531 gr_bm_bitblt( new_box->width + 1, new_box->height +4,
532 new_box->left, new_box->top, new_box->left, new_box->top,
533 tempbmp, &(grd_curscreen->sc_canvas.cv_bitmap) );
534 WIN(DDGRSCREENUNLOCK);
537 #if defined(POLY_ACC)
541 #if !defined(POLY_ACC) || defined(MACINTOSH)
542 MAC( if(!PAEnabled) ) // POLY_ACC always on for the macintosh
543 for (j=0; j<NUM_LINES; j++ )
545 new_box = &dirty_box[j];
547 tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
549 gr_bm_bitblt( new_box->width
564 // Wacky Fast Credits thing doesn't need this (it's done above)
566 //@@ dd_gr_blt_notrans(CreditsOffscreenBuf, 0,0,0,0, dd_grd_screencanv, 0,0,0,0),
567 //@@ gr_bm_ubitblt(grd_curcanv->cv_w, grd_curcanv->cv_h, 0, 0, 0, 0, &(CreditsOffscreenBuf->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) );
570 // mprintf( ( 0, "Fr = %d", (timer_get_fixed_seconds() - last_time) ));
571 while( timer_get_fixed_seconds() < last_time+time_delay );
572 last_time = timer_get_fixed_seconds();
578 DoMessageStuff(&msg);
581 _RedrawScreen = FALSE;
583 gr_close_font(header_font);
584 gr_close_font(title_font);
585 gr_close_font(names_font);
587 d_free(backdrop.bm_data);
588 gr_free_canvas(CreditsOffscreenBuf);
597 //see if redbook song needs to be restarted
598 songs_check_redbook_repeat();
603 if (k == KEY_BACKSP) {
610 // fix ot = time_delay;
611 // time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
612 // if (ot!=time_delay) {
613 // mprintf( (0, "[%x] ", time_delay ));
617 if (k == KEY_PRINT_SCREEN) {
622 if ((k>0)||(done>NUM_LINES)) {
623 gr_close_font(header_font);
624 gr_close_font(title_font);
625 gr_close_font(names_font);
626 gr_palette_fade_out( gr_palette, 32, 0 );
627 gr_use_palette_table( DEFAULT_PALETTE );
628 d_free(backdrop.bm_data);
631 dd_gr_set_current_canvas(save_canv),
632 gr_set_current_canvas(save_canv)
634 songs_play_song( SONG_TITLE, 1 );
637 gr_free_canvas(CreditsOffscreenBuf);
639 if (CreditsOffscreenBuf != VR_offscreen_buffer)
640 gr_free_canvas(CreditsOffscreenBuf);
643 WIN(DEFINE_SCREEN(Menu_pcx_name));
649 if (buffer[(buffer_line + 1 ) % NUM_LINES][0] == '!') {
650 first_line_offset -= ROW_SPACING-ROW_SPACING/2;
651 if (first_line_offset <= -ROW_SPACING) {
652 first_line_offset += ROW_SPACING;