]> icculus.org git repositories - btb/d2x.git/blob - main/credits.c
typo
[btb/d2x.git] / main / credits.c
1 /* $Id: credits.c,v 1.8 2003-10-10 09:36:34 btb Exp $ */
2 /*
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.
13 */
14
15 /*
16  *
17  * Routines to display the credits.
18  *
19  * Old Log:
20  * Revision 1.8  1995/11/07  13:54:56  allender
21  * loop shareware song since it is too short
22  *
23  * Revision 1.7  1995/10/31  10:24:25  allender
24  * shareware stuff
25  *
26  * Revision 1.6  1995/10/27  15:17:57  allender
27  * minor fix to get them to look right at top and bottom
28  * of screens
29  *
30  * Revision 1.5  1995/10/21  22:50:49  allender
31  * credits is way cool!!!!
32  *
33  * Revision 1.3  1995/08/08  13:45:26  allender
34  * added macsys header file
35  *
36  * Revision 1.2  1995/07/17  08:49:48  allender
37  * make work in 640x480 -- still needs major work!!
38  *
39  * Revision 1.1  1995/05/16  15:24:01  allender
40  * Initial revision
41  *
42  * Revision 2.2  1995/06/14  17:26:08  john
43  * Fixed bug with VFX palette not getting loaded for credits, titles.
44  *
45  * Revision 2.1  1995/03/06  15:23:30  john
46  * New screen techniques.
47  *
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.
51  *
52  * Revision 1.33  1995/02/11  12:41:56  john
53  * Added new song method, with FM bank switching..
54  *
55  * Revision 1.32  1995/02/03  14:18:06  john
56  * Added columns.
57  *
58  * Revision 1.31  1994/12/28  10:43:00  john
59  * More VFX tweaking.
60  *
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.
64  *
65  * Revision 1.29  1994/12/15  14:23:00  adam
66  * fixed timing.
67  *
68  * Revision 1.28  1994/12/14  16:56:33  adam
69  * *** empty log message ***
70  *
71  * Revision 1.27  1994/12/14  12:18:11  adam
72  * messed w/timing
73  *
74  * Revision 1.26  1994/12/12  22:52:59  matt
75  * Fixed little bug
76  *
77  * Revision 1.25  1994/12/12  22:49:35  adam
78  * *** empty log message ***
79  *
80  * Revision 1.24  1994/12/09  23:16:50  john
81  * Make credits.txb load.
82  *
83  * Revision 1.23  1994/12/09  00:41:54  mike
84  * fix hang in automap print screen.
85  *
86  * Revision 1.22  1994/12/09  00:34:22  matt
87  * Added support for half-height lines
88  *
89  * Revision 1.21  1994/12/08  18:36:03  yuan
90  * More HOGfile support.
91  *
92  * Revision 1.20  1994/12/04  14:48:17  john
93  * Made credits restore playing descent.hmp.
94  *
95  * Revision 1.19  1994/12/04  14:30:20  john
96  * Added hooks for music..
97  *
98  * Revision 1.18  1994/12/04  12:06:46  matt
99  * Put in support for large font
100  *
101  * Revision 1.17  1994/12/01  10:47:27  john
102  * Took out code that allows keypresses to change scroll rate.
103  *
104  * Revision 1.16  1994/11/30  12:10:52  adam
105  * added support for PCX titles/brief screens
106  *
107  * Revision 1.15  1994/11/27  23:12:17  matt
108  * Made changes for new mprintf calling convention
109  *
110  * Revision 1.14  1994/11/27  19:51:46  matt
111  * Made screen shots work in a few more places
112  *
113  * Revision 1.13  1994/11/18  16:41:51  adam
114  * trimmed some more meat for shareware
115  *
116  * Revision 1.12  1994/11/10  20:38:29  john
117  * Made credits not loop.
118  *
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
121  * the background.
122  *
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.
128  *
129  * Revision 1.9  1994/11/04  12:02:32  john
130  * Fixed fading transitions a bit more.
131  *
132  * Revision 1.8  1994/11/04  11:30:44  john
133  * Fixed fade transitions between game/menu/credits.
134  *
135  * Revision 1.7  1994/11/04  11:06:32  john
136  * Added code to support credit fade table.
137  *
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.
140  *
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.
144  *
145  * Revision 1.4  1994/11/03  21:20:28  john
146  * Working.
147  *
148  * Revision 1.3  1994/11/03  21:01:24  john
149  * First version of credits that works.
150  *
151  * Revision 1.2  1994/11/03  20:17:39  john
152  * Added initial code for showing credits.
153  *
154  * Revision 1.1  1994/11/03  20:09:05  john
155  * Initial revision
156  *
157  *
158  */
159
160 #ifdef HAVE_CONFIG_H
161 #include <conf.h>
162 #endif
163
164 #ifdef RCS
165 static char rcsid[] = "$Id: credits.c,v 1.8 2003-10-10 09:36:34 btb Exp $";
166 #endif
167
168 #ifdef WINDOWS
169 #include "desw.h"
170 #endif
171
172 #include <stdio.h>
173 #include <stdlib.h>
174 #include <string.h>
175 #include <stdarg.h>
176 #include <ctype.h>
177
178 #include "pa_enabl.h"                   //$$POLY_ACC
179 #include "error.h"
180 #include "pstypes.h"
181 #include "gr.h"
182 #include "mono.h"
183 #include "key.h"
184 #include "palette.h"
185 #include "game.h"
186 #include "gamepal.h"
187 #include "timer.h"
188
189 #include "newmenu.h"
190 #include "gamefont.h"
191 #ifdef NETWORK
192 #include "network.h"
193 #endif
194 #include "iff.h"
195 #include "pcx.h"
196 #include "u_mem.h"
197 #include "mouse.h"
198 #include "joy.h"
199 #include "screens.h"
200 #include "digi.h"
201
202 #include "cfile.h"
203 #include "compbit.h"
204 #include "songs.h"
205 #include "menu.h"                       // for MenuHires
206
207 #if defined(POLY_ACC)
208 #include "poly_acc.h"
209 #endif
210
211 #define ROW_SPACING (MenuHires?26:11)
212 #define NUM_LINES_HIRES 21
213 #define NUM_LINES (MenuHires?NUM_LINES_HIRES:20)
214
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,
223 5,4,4,3,3,2,2,1 };
224
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};
241
242 extern ubyte *gr_bitblt_fade_table;
243
244 grs_font * header_font;
245 grs_font * title_font;
246 grs_font * names_font;
247
248 #ifdef SHAREWARE
249 #define ALLOWED_CHAR 'S'
250 #else
251 #define ALLOWED_CHAR 'R'
252 #endif
253
254 #ifdef RELEASE
255 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"\x01starsb.pcx":"\x01stars.pcx")        //only read from hog file
256 #else
257 #define CREDITS_BACKGROUND_FILENAME (MenuHires?"starsb.pcx":"stars.pcx")
258 #endif
259
260 typedef struct box {
261         int left, top, width, height;
262 } box;
263
264 #define CREDITS_FILE    (cfexist("mcredits.tex")?"mcredits.tex":cfexist("ocredits.tex")?"ocredits.tex":"credits.tex")
265
266 //if filename passed is NULL, show normal credits
267 void credits_show(char *credits_filename)
268 {
269         int i, j, l, done;
270         CFILE * file;
271         char buffer[NUM_LINES_HIRES][80];
272         grs_bitmap backdrop;
273         ubyte backdrop_palette[768];
274         int pcx_error;
275         int buffer_line = 0;
276         fix last_time;
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;
282         char * tempp;
283         char filename[32];
284
285 WIN(int credinit = 0;)
286
287         box dirty_box[NUM_LINES_HIRES];
288         grs_canvas *CreditsOffscreenBuf=NULL;
289
290         WINDOS(
291                 dd_grs_canvas *save_canv,
292                 grs_canvas *save_canv
293         );
294
295         WINDOS(
296                 save_canv = dd_grd_curcanv,
297                 save_canv = grd_curcanv
298         );
299
300         // Clear out all tex buffer lines.
301         for (i=0; i<NUM_LINES; i++ )
302         {
303                 buffer[i][0] = 0;
304                 dirty_box[i].left = dirty_box[i].top = dirty_box[i].width = dirty_box[i].height = 0;
305         }
306
307
308         sprintf(filename, "%s", CREDITS_FILE);
309         have_bin_file = 0;
310         if (credits_filename) {
311                 strcpy(filename,credits_filename);
312                 have_bin_file = 1;
313         }
314         file = cfopen( filename, "rb" );
315         if (file == NULL) {
316                 char nfile[32];
317                 
318                 if (credits_filename)
319                         return;         //ok to not find special filename
320
321                 tempp = strchr(filename, '.');
322                 *tempp = '\0';
323                 sprintf(nfile, "%s.txb", filename);
324                 file = cfopen(nfile, "rb");
325                 if (file == NULL)
326                         Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
327                 have_bin_file = 1;
328         }
329
330         set_screen_mode(SCREEN_MENU);
331
332         WIN(DEFINE_SCREEN(NULL));
333
334 #ifdef WINDOWS
335 CreditsPaint:
336 #endif
337         gr_use_palette_table( "credits.256" );
338 #ifdef OGL
339         gr_palette_load(gr_palette);
340 #endif
341 #if defined(POLY_ACC)
342         pa_update_clut(gr_palette, 0, 256, 0);
343 #endif
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;
348
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.
351
352         pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
353         if (pcx_error != PCX_ERROR_NONE)                {
354                 cfclose(file);
355                 return;
356         }
357
358         songs_play_song( SONG_CREDITS, 1 );
359
360         gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
361
362 WINDOS(
363         dd_gr_set_current_canvas(NULL), 
364         gr_set_current_canvas(NULL)
365 );
366 WIN(DDGRLOCK(dd_grd_curcanv));
367         gr_bitmap(0,0,&backdrop);
368 WIN(DDGRUNLOCK(dd_grd_curcanv));
369         gr_update();
370         gr_palette_fade_in( gr_palette, 32, 0 );
371
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.
376
377 #ifndef PA_3DFX_VOODOO
378 #ifndef WINDOWS
379         if (MenuHires && VR_offscreen_buffer->cv_w == 640)      {
380                 CreditsOffscreenBuf = VR_offscreen_buffer;
381         }
382         else if (MenuHires)     {
383                 CreditsOffscreenBuf = gr_create_canvas(640,480);
384         }
385         else {
386                 CreditsOffscreenBuf = gr_create_canvas(320,200);
387         }
388 #else
389         CreditsOffscreenBuf = gr_create_canvas(640,480);
390 #endif                          
391 #else
392         CreditsOffscreenBuf = gr_create_canvas(640,480);
393 #endif
394
395         if (!CreditsOffscreenBuf)
396                 Error("Not enough memory to allocate Credits Buffer.");
397
398         //gr_clear_canvas(BM_XRGB(0,0,0));
399         key_flush();
400
401 #ifdef WINDOWS
402         if (!credinit)  
403 #endif
404         {
405                 last_time = timer_get_fixed_seconds();
406                 done = 0;
407                 first_line_offset = 0;
408         }
409
410         WIN(credinit = 1);
411
412         while( 1 )      {
413                 int k;
414
415                 do {
416                         buffer_line = (buffer_line+1) % NUM_LINES;
417 get_line:;
418                         if (cfgets( buffer[buffer_line], 80, file ))    {
419                                 char *p;
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]));
425                                         }
426                                 }
427                                 p = buffer[buffer_line];
428                                 if (p[0] == ';')
429                                         goto get_line;
430
431                                 if (p[0] == '%')
432                                 {
433                                         if (p[1] == ALLOWED_CHAR)
434                                                 strcpy(p,p+2);
435                                         else
436                                                 goto get_line;
437                                 }
438
439                                 p = strchr(&buffer[buffer_line][0],'\n');
440                                 if (p) *p = '\0';
441                         } else  {
442                                 //fseek( file, 0, SEEK_SET);
443                                 buffer[buffer_line][0] = 0;
444                                 done++;
445                         }
446                 } while (extra_inc--);
447                 extra_inc = 0;
448
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) ) {)
451                         int y;
452
453                         y = first_line_offset - i;
454
455                         gr_set_current_canvas(CreditsOffscreenBuf);
456                 
457                         gr_bitmap(0,0,&backdrop);
458
459                         for (j=0; j<NUM_LINES; j++ )    {
460                                 char *s;
461
462                                 l = (buffer_line + j + 1 ) %  NUM_LINES;
463                                 s = buffer[l];
464
465                                 if ( s[0] == '!' ) {
466                                         s++;
467                                 } else if ( s[0] == '$' )       {
468                                         grd_curcanv->cv_font = header_font;
469                                         s++;
470                                 } else if ( s[0] == '*' )       {
471                                         grd_curcanv->cv_font = title_font;
472                                         s++;
473                                 } else
474                                         grd_curcanv->cv_font = names_font;
475
476                                 gr_bitblt_fade_table = (MenuHires?fade_values_hires:fade_values);
477
478                                 tempp = strchr( s, '\t' );
479                                 if ( tempp )    {
480                                 //      Wacky Credits thing
481                                         int w, h, aw, w2, x1, x2;
482
483                                         *tempp = 0;
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] );
490
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;
495
496                                         *tempp = '\t';
497                 
498                                 } else {
499                                 // Wacky Fast Credits thing
500                                         int w, h, aw;
501
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;
507
508                                         gr_printf( 0x8000, y, s );
509                                 }
510                                 gr_bitblt_fade_table = NULL;
511                                 if (buffer[l][0] == '!')
512                                         y += ROW_SPACING/2;
513                                 else
514                                         y += ROW_SPACING;
515                         }
516
517                         {       // Wacky Fast Credits Thing
518                                 box     *new_box;
519                                 grs_bitmap *tempbmp;
520
521                                 for (j=0; j<NUM_LINES; j++ )
522                                 {
523                                         new_box = &dirty_box[j];
524
525                                         tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
526
527                                 WIN(DDGRSCREENLOCK);
528 #if defined(POLY_ACC)
529                                         if(new_box->width != 0)
530 #endif
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);
535                                 }
536
537 #if defined(POLY_ACC)
538                 pa_flush();
539 #endif
540
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++ )
544                                 {
545                                         new_box = &dirty_box[j];
546
547                                         tempbmp = &(CreditsOffscreenBuf->cv_bitmap);
548
549                                         gr_bm_bitblt(   new_box->width
550                                                                         ,new_box->height+2
551                                                                         ,new_box->left
552                                                                         ,new_box->top
553                                                                         ,new_box->left
554                                                                         ,new_box->top
555                                                                         ,&backdrop
556                                                                         ,tempbmp );
557                                 }
558                                 
559 #endif
560                         gr_update();
561                                 
562                         }
563
564 //              Wacky Fast Credits thing doesn't need this (it's done above)
565 //@@            WINDOS(
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) );
568 //@@            );
569
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();
573                 
574                 #ifdef WINDOWS
575                         {
576                                 MSG msg;
577
578                                 DoMessageStuff(&msg);
579
580                                 if (_RedrawScreen) {
581                                         _RedrawScreen = FALSE;
582
583                                         gr_close_font(header_font);
584                                         gr_close_font(title_font);
585                                         gr_close_font(names_font);
586
587                                         d_free(backdrop.bm_data);
588                                         gr_free_canvas(CreditsOffscreenBuf);
589                 
590                                         goto CreditsPaint;
591                                 }
592
593                                 DDGRRESTORE;
594                         }
595                 #endif
596
597                         //see if redbook song needs to be restarted
598                         songs_check_redbook_repeat();
599
600                         k = key_inkey();
601
602                         #ifndef NDEBUG
603                         if (k == KEY_BACKSP) {
604                                 Int3();
605                                 k=0;
606                         }
607                         #endif
608
609 //                      {
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 ));
614 //                              }
615 //                      }
616
617                         if (k == KEY_PRINT_SCREEN) {
618                                 save_screen_shot(0);
619                                 k = 0;
620                         }
621
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);
629                                         cfclose(file);
630                                 WINDOS(
631                                         dd_gr_set_current_canvas(save_canv),
632                                         gr_set_current_canvas(save_canv)
633                                 );
634                                         songs_play_song( SONG_TITLE, 1 );
635
636                                 #ifdef WINDOWS
637                                         gr_free_canvas(CreditsOffscreenBuf);
638                                 #else                                   
639                                         if (CreditsOffscreenBuf != VR_offscreen_buffer)
640                                                 gr_free_canvas(CreditsOffscreenBuf);
641                                 #endif
642
643                                 WIN(DEFINE_SCREEN(Menu_pcx_name));
644                         
645                                 return;
646                         }
647                 }
648
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;
653                                 extra_inc++;
654                         }
655                 }
656         }
657
658 }