2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 static char rcsid[] = "$Id: credits.c,v 1.2 2001-01-20 13:49:14 bradleyb Exp $";
30 #include "pa_enabl.h" //$$POLY_ACC
55 #include "menu.h" // for MenuHires
61 #define ROW_SPACING (MenuHires?26:11)
62 #define NUM_LINES_HIRES 21
63 #define NUM_LINES (MenuHires?NUM_LINES_HIRES:20)
65 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,
66 11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,
67 20,21,21,22,22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,
68 28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,
69 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,
70 30,30,30,30,29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,
71 25,25,24,24,24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,
72 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,
75 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,
76 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,
77 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,
78 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,
79 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,
80 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,
81 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,
82 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,
83 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,
84 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,
85 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,
86 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,
87 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,
88 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,
89 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,
90 5,5,4,4,4,4,4,3,3,3,3,3,2,2,2,2,2,1,1};
92 extern ubyte *gr_bitblt_fade_table;
93 extern void gr_bm_bitblt(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest);
95 grs_font * header_font;
96 grs_font * title_font;
97 grs_font * names_font;
100 #define ALLOWED_CHAR 'S'
102 #define ALLOWED_CHAR 'R'
106 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"\x01starsb.pcx":"\x01stars.pcx") //only read from hog file
108 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"starsb.pcx":"stars.pcx")
112 int left, top, width, height;
116 #define CREDITS_FILE "mcredits.tex"
119 #define CREDITS_FILE "ocredits.tex"
121 #define CREDITS_FILE "credits.tex"
125 //if filename passed is NULL, show normal credits
126 void credits_show(char *credits_filename)
130 char buffer[NUM_LINES_HIRES][80];
132 ubyte backdrop_palette[768];
136 // fix time_delay = 4180; // ~ F1_0 / 12.9
137 // fix time_delay = 1784;
138 fix time_delay = 2800;
139 int first_line_offset,extra_inc=0;
140 int have_bin_file = 0;
144 WIN(int credinit = 0;)
146 box dirty_box[NUM_LINES_HIRES];
147 grs_canvas *CreditsOffscreenBuf=NULL;
150 dd_grs_canvas *save_canv,
151 grs_canvas *save_canv
155 save_canv = dd_grd_curcanv,
156 save_canv = grd_curcanv
159 // Clear out all tex buffer lines.
160 for (i=0; i<NUM_LINES; i++ )
163 dirty_box[i].left = dirty_box[i].top = dirty_box[i].width = dirty_box[i].height = 0;
167 sprintf(filename, "%s", CREDITS_FILE);
169 if (credits_filename) {
170 strcpy(filename,credits_filename);
173 file = cfopen( filename, "rb" );
177 if (credits_filename)
178 return; //ok to not find special filename
180 tempp = strchr(filename, '.');
182 sprintf(nfile, "%s.txb", filename);
183 file = cfopen(nfile, "rb");
185 Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
189 set_screen_mode(SCREEN_MENU);
191 WIN(DEFINE_SCREEN(NULL));
196 gr_use_palette_table( "credits.256" );
197 #if defined(POLY_ACC)
198 pa_update_clut(gr_palette, 0, 256, 0);
200 header_font = gr_init_font( MenuHires?"font1-1h.fnt":"font1-1.fnt" );
201 title_font = gr_init_font( MenuHires?"font2-3h.fnt":"font2-3.fnt" );
202 names_font = gr_init_font( MenuHires?"font2-2h.fnt":"font2-2.fnt" );
203 backdrop.bm_data=NULL;
205 //MWA Made backdrop bitmap linear since it should always be. the current canvas may not
206 //MWA be linear, so we can't rely on grd_curcanv->cv_bitmap->bm_type.
208 pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
209 if (pcx_error != PCX_ERROR_NONE) {
214 songs_play_song( SONG_CREDITS, 1 );
216 gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
219 dd_gr_set_current_canvas(NULL),
220 gr_set_current_canvas(NULL)
222 WIN(DDGRLOCK(dd_grd_curcanv));
223 gr_bitmap(0,0,&backdrop);
224 WIN(DDGRUNLOCK(dd_grd_curcanv));
226 gr_palette_fade_in( gr_palette, 32, 0 );
228 // Create a new offscreen buffer for the credits screen
229 //MWA Let's be a little smarter about this and check the VR_offscreen buffer
230 //MWA for size to determine if we can use that buffer. If the game size
231 //MWA matches what we need, then lets save memory.
233 #ifndef PA_3DFX_VOODOO
235 if (MenuHires && VR_offscreen_buffer->cv_w == 640) {
236 CreditsOffscreenBuf = VR_offscreen_buffer;
238 else if (MenuHires) {
239 CreditsOffscreenBuf = gr_create_canvas(640,480);
242 CreditsOffscreenBuf = gr_create_canvas(320,200);
245 CreditsOffscreenBuf = gr_create_canvas(640,480);
248 CreditsOffscreenBuf = gr_create_canvas(640,480);
251 if (!CreditsOffscreenBuf)
252 Error("Not enough memory to allocate Credits Buffer.");
254 //gr_clear_canvas(BM_XRGB(0,0,0));
261 last_time = timer_get_fixed_seconds();
263 first_line_offset = 0;
272 buffer_line = (buffer_line+1) % NUM_LINES;
274 if (cfgets( buffer[buffer_line], 80, file )) {
276 if (have_bin_file) { // is this a binary tbl file
277 for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) {
278 encode_rotate_left(&(buffer[buffer_line][i]));
279 buffer[buffer_line][i] ^= BITMAP_TBL_XOR;
280 encode_rotate_left(&(buffer[buffer_line][i]));
283 p = buffer[buffer_line];
289 if (p[1] == ALLOWED_CHAR)
295 p = strchr(&buffer[buffer_line][0],'\n');
298 //fseek( file, 0, SEEK_SET);
299 buffer[buffer_line][0] = 0;
302 } while (extra_inc--);
305 NO_DFX (for (i=0; i<ROW_SPACING; i += (MenuHires?2:1) ) {)
306 PA_DFX (for (i=0; i<ROW_SPACING; i += (MenuHires?2:1) ) {)
309 y = first_line_offset - i;
311 gr_set_current_canvas(CreditsOffscreenBuf);
313 gr_bitmap(0,0,&backdrop);
315 for (j=0; j<NUM_LINES; j++ ) {
318 l = (buffer_line + j + 1 ) % NUM_LINES;
323 } else if ( s[0] == '$' ) {
324 grd_curcanv->cv_font = header_font;
326 } else if ( s[0] == '*' ) {
327 grd_curcanv->cv_font = title_font;
330 grd_curcanv->cv_font = names_font;
332 gr_bitblt_fade_table = (MenuHires?fade_values_hires:fade_values);
334 tempp = strchr( s, '\t' );
336 // Wacky Credits thing
337 int w, h, aw, w2, x1, x2;
340 gr_get_string_size( s, &w, &h, &aw );
341 x1 = ((MenuHires?320:160)-w)/2;
342 gr_printf( x1 , y, s );
343 gr_get_string_size( &tempp[1], &w2, &h, &aw );
344 x2 = (MenuHires?320:160)+(((MenuHires?320:160)-w2)/2);
345 gr_printf( x2, y, &tempp[1] );
347 dirty_box[j].left = ((MenuHires?320:160)-w)/2;
348 dirty_box[j].top = y;
349 dirty_box[j].width =(x2+w2)-x1;
350 dirty_box[j].height = h;
355 // Wacky Fast Credits thing
358 gr_get_string_size( s, &w, &h, &aw);
359 dirty_box[j].width = w;
360 dirty_box[j].height = h;
361 dirty_box[j].top = y;
362 dirty_box[j].left = ((MenuHires?640:320) - w) / 2;
364 gr_printf( 0x8000, y, s );
366 gr_bitblt_fade_table = NULL;
367 if (buffer[l][0] == '!')
373 { // Wacky Fast Credits Thing
377 for (j=0; j<NUM_LINES; j++ )
379 new_box = &dirty_box[j];
381 tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
384 #if defined(POLY_ACC)
385 if(new_box->width != 0)
387 gr_bm_bitblt( new_box->width + 1, new_box->height +4,
388 new_box->left, new_box->top, new_box->left, new_box->top,
389 tempbmp, &(grd_curscreen->sc_canvas.cv_bitmap) );
390 WIN(DDGRSCREENUNLOCK);
393 #if defined(POLY_ACC)
397 #if !defined(POLY_ACC) || defined(MACINTOSH)
398 MAC( if(!PAEnabled) ) // POLY_ACC always on for the macintosh
399 for (j=0; j<NUM_LINES; j++ )
401 new_box = &dirty_box[j];
403 tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
405 gr_bm_bitblt( new_box->width
420 // Wacky Fast Credits thing doesn't need this (it's done above)
422 //@@ dd_gr_blt_notrans(CreditsOffscreenBuf, 0,0,0,0, dd_grd_screencanv, 0,0,0,0),
423 //@@ gr_bm_ubitblt(grd_curcanv->cv_w, grd_curcanv->cv_h, 0, 0, 0, 0, &(CreditsOffscreenBuf->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) );
426 // mprintf( ( 0, "Fr = %d", (timer_get_fixed_seconds() - last_time) ));
427 while( timer_get_fixed_seconds() < last_time+time_delay );
428 last_time = timer_get_fixed_seconds();
434 DoMessageStuff(&msg);
437 _RedrawScreen = FALSE;
439 gr_close_font(header_font);
440 gr_close_font(title_font);
441 gr_close_font(names_font);
443 d_free(backdrop.bm_data);
444 gr_free_canvas(CreditsOffscreenBuf);
453 //see if redbook song needs to be restarted
454 songs_check_redbook_repeat();
459 if (k == KEY_BACKSP) {
466 // fix ot = time_delay;
467 // time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
468 // if (ot!=time_delay) {
469 // mprintf( (0, "[%x] ", time_delay ));
473 if (k == KEY_PRINT_SCREEN) {
478 if ((k>0)||(done>NUM_LINES)) {
479 gr_close_font(header_font);
480 gr_close_font(title_font);
481 gr_close_font(names_font);
482 gr_palette_fade_out( gr_palette, 32, 0 );
483 gr_use_palette_table( DEFAULT_PALETTE );
484 d_free(backdrop.bm_data);
487 dd_gr_set_current_canvas(save_canv),
488 gr_set_current_canvas(save_canv)
490 songs_play_song( SONG_TITLE, 1 );
493 gr_free_canvas(CreditsOffscreenBuf);
495 if (CreditsOffscreenBuf != VR_offscreen_buffer)
496 gr_free_canvas(CreditsOffscreenBuf);
499 WIN(DEFINE_SCREEN(Menu_pcx_name));
505 if (buffer[(buffer_line + 1 ) % NUM_LINES][0] == '!') {
506 first_line_offset -= ROW_SPACING-ROW_SPACING/2;
507 if (first_line_offset <= -ROW_SPACING) {
508 first_line_offset += ROW_SPACING;