home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / credits.c < prev    next >
Text File  |  1998-06-08  |  11KB  |  372 lines

  1. /*
  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-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/main/rcs/credits.c $
  15.  * $Revision: 2.2 $
  16.  * $Author: john $
  17.  * $Date: 1995/06/14 17:26:08 $
  18.  * 
  19.  * Routines to display the credits.
  20.  * 
  21.  * $Log: credits.c $
  22.  * Revision 2.2  1995/06/14  17:26:08  john
  23.  * Fixed bug with VFX palette not getting loaded for credits, titles.
  24.  * 
  25.  * Revision 2.1  1995/03/06  15:23:30  john
  26.  * New screen techniques.
  27.  * 
  28.  * Revision 2.0  1995/02/27  11:29:25  john
  29.  * New version 2.0, which has no anonymous unions, builds with
  30.  * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  31.  * 
  32.  * Revision 1.33  1995/02/11  12:41:56  john
  33.  * Added new song method, with FM bank switching..
  34.  * 
  35.  * Revision 1.32  1995/02/03  14:18:06  john
  36.  * Added columns.
  37.  * 
  38.  * Revision 1.31  1994/12/28  10:43:00  john
  39.  * More VFX tweaking.
  40.  * 
  41.  * Revision 1.30  1994/12/20  18:22:31  john
  42.  * Added code to support non-looping songs, and put
  43.  * it in for endlevel and credits.
  44.  * 
  45.  * Revision 1.29  1994/12/15  14:23:00  adam
  46.  * fixed timing.
  47.  * 
  48.  * Revision 1.28  1994/12/14  16:56:33  adam
  49.  * *** empty log message ***
  50.  * 
  51.  * Revision 1.27  1994/12/14  12:18:11  adam
  52.  * messed w/timing
  53.  * 
  54.  * Revision 1.26  1994/12/12  22:52:59  matt
  55.  * Fixed little bug
  56.  * 
  57.  * Revision 1.25  1994/12/12  22:49:35  adam
  58.  * *** empty log message ***
  59.  * 
  60.  * Revision 1.24  1994/12/09  23:16:50  john
  61.  * Make credits.txb load.
  62.  * 
  63.  * Revision 1.23  1994/12/09  00:41:54  mike
  64.  * fix hang in automap print screen.
  65.  * 
  66.  * Revision 1.22  1994/12/09  00:34:22  matt
  67.  * Added support for half-height lines
  68.  * 
  69.  * Revision 1.21  1994/12/08  18:36:03  yuan
  70.  * More HOGfile support.
  71.  * 
  72.  * Revision 1.20  1994/12/04  14:48:17  john
  73.  * Made credits restore playing descent.hmp.
  74.  * 
  75.  * Revision 1.19  1994/12/04  14:30:20  john
  76.  * Added hooks for music..
  77.  * 
  78.  * Revision 1.18  1994/12/04  12:06:46  matt
  79.  * Put in support for large font
  80.  * 
  81.  * Revision 1.17  1994/12/01  10:47:27  john
  82.  * Took out code that allows keypresses to change scroll rate.
  83.  * 
  84.  * Revision 1.16  1994/11/30  12:10:52  adam
  85.  * added support for PCX titles/brief screens
  86.  * 
  87.  * Revision 1.15  1994/11/27  23:12:17  matt
  88.  * Made changes for new mprintf calling convention
  89.  * 
  90.  * Revision 1.14  1994/11/27  19:51:46  matt
  91.  * Made screen shots work in a few more places
  92.  * 
  93.  * Revision 1.13  1994/11/18  16:41:51  adam
  94.  * trimmed some more meat for shareware
  95.  * 
  96.  * Revision 1.12  1994/11/10  20:38:29  john
  97.  * Made credits not loop.
  98.  * 
  99.  * Revision 1.11  1994/11/05  15:04:06  john
  100.  * Added non-popup menu for the main menu, so that scores and credits don't have to save
  101.  * the background.
  102.  * 
  103.  * Revision 1.10  1994/11/05  14:05:52  john
  104.  * Fixed fade transitions between all screens by making gr_palette_fade_in and out keep
  105.  * track of whether the palette is faded in or not.  Then, wherever the code needs to fade out,
  106.  * it just calls gr_palette_fade_out and it will fade out if it isn't already.  The same with fade_in.
  107.  * This eliminates the need for all the flags like Menu_fade_out, game_fade_in palette, etc.
  108.  * 
  109.  * Revision 1.9  1994/11/04  12:02:32  john
  110.  * Fixed fading transitions a bit more.
  111.  * 
  112.  * Revision 1.8  1994/11/04  11:30:44  john
  113.  * Fixed fade transitions between game/menu/credits.
  114.  * 
  115.  * Revision 1.7  1994/11/04  11:06:32  john
  116.  * Added code to support credit fade table.
  117.  * 
  118.  * Revision 1.6  1994/11/04  10:16:13  john
  119.  * Made the credits fade in/out smoothly on top of a bitmap background.
  120.  * 
  121.  * Revision 1.5  1994/11/03  21:24:12  john
  122.  * Made credits exit the instant a key is pressed.
  123.  * Made it scroll a bit slower.
  124.  * 
  125.  * Revision 1.4  1994/11/03  21:20:28  john
  126.  * Working.
  127.  * 
  128.  * Revision 1.3  1994/11/03  21:01:24  john
  129.  * First version of credits that works.
  130.  * 
  131.  * Revision 1.2  1994/11/03  20:17:39  john
  132.  * Added initial code for showing credits.
  133.  * 
  134.  * Revision 1.1  1994/11/03  20:09:05  john
  135.  * Initial revision
  136.  * 
  137.  * 
  138.  */
  139.  
  140.  
  141. #pragma off (unreferenced)
  142. static char rcsid[] = "$Id: credits.c 2.2 1995/06/14 17:26:08 john Exp $";
  143. #pragma on (unreferenced)
  144.  
  145. #include <stdio.h>
  146. #include <stdlib.h>
  147. #include <string.h>
  148. #include <dos.h>
  149. #include <stdarg.h>
  150. #include <ctype.h>
  151.  
  152. #include "error.h"
  153. #include "types.h"
  154. #include "gr.h"
  155. #include "mono.h"
  156. #include "key.h"
  157. #include "palette.h"
  158. #include "game.h"
  159. #include "timer.h"
  160.  
  161. #include "newmenu.h"
  162. #include "gamefont.h"
  163. #include "network.h"
  164. #include "iff.h"
  165. #include "pcx.h"
  166. #include "mem.h"
  167. #include "mouse.h"
  168. #include "joy.h"
  169. #include "screens.h"
  170. #include "digi.h"
  171.  
  172. #include "cfile.h"
  173. #include "compbit.h"
  174. #include "vfx.h"
  175. #include "songs.h"
  176.  
  177. #define ROW_SPACING 11
  178. #define NUM_LINES 20            //19
  179.  
  180. 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,
  181. 11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,
  182. 20,21,21,22,22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,
  183. 28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,
  184. 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,
  185. 30,30,30,30,29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,
  186. 25,25,24,24,24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,
  187. 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,
  188. 5,4,4,3,3,2,2,1 };
  189.  
  190. extern ubyte *gr_bitblt_fade_table;
  191.  
  192. grs_font * header_font;
  193. grs_font * title_font;
  194. grs_font * names_font;
  195.  
  196. void credits_show()
  197. {
  198.     int i, j, l, done;
  199.     CFILE * file;
  200.     char buffer[NUM_LINES][80];
  201.     grs_bitmap backdrop;
  202.     ubyte backdrop_palette[768];
  203.     int pcx_error;
  204.     int buffer_line = 0;
  205.     fix last_time;
  206.     fix time_delay = 4180;            // ~ F1_0 / 12.9
  207.     int first_line_offset,extra_inc=0;
  208.     int have_bin_file = 0;
  209.     char * tempp;
  210.  
  211.     set_screen_mode(SCREEN_MENU);
  212.  
  213.     // Clear out all tex buffer lines.
  214.     for (i=0; i<NUM_LINES; i++ ) buffer[i][0] = 0;
  215.  
  216.     have_bin_file = 0;
  217.     file = cfopen( "credits.tex", "rb" );
  218.     if (file == NULL) {
  219.         file = cfopen("credits.txb", "rb");
  220.         if (file == NULL)
  221.             Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
  222.         have_bin_file = 1;
  223.     }
  224.  
  225.     gr_use_palette_table( "credits.256" );
  226.     header_font = gr_init_font( "font1-1.fnt" );
  227.     title_font = gr_init_font( "font2-3.fnt" );
  228.     names_font = gr_init_font( "font2-2.fnt" );
  229.     backdrop.bm_data=NULL;
  230.     pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,grd_curcanv->cv_bitmap.bm_type,backdrop_palette);
  231.     if (pcx_error != PCX_ERROR_NONE)        {
  232.         cfclose(file);
  233.         return;
  234.     }
  235.  
  236.     songs_play_song( SONG_CREDITS, 0 );
  237.  
  238.     gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
  239.  
  240.     gr_set_current_canvas(NULL);
  241.     gr_bitmap(0,0,&backdrop);
  242.     gr_palette_fade_in( gr_palette, 32, 0 );
  243.     vfx_set_palette_sub( gr_palette );
  244.  
  245.     //gr_clear_canvas(BM_XRGB(0,0,0));
  246.     key_flush();
  247.     last_time = timer_get_fixed_seconds();
  248.     done = 0;
  249.     first_line_offset = 0;
  250.     while( 1 )    {
  251.         int k;
  252.  
  253.         do {
  254.             buffer_line = (buffer_line+1) % NUM_LINES;
  255.             if (cfgets( buffer[buffer_line], 80, file ))    {
  256.                 char *p;
  257.                 if (have_bin_file) {                // is this a binary tbl file
  258.                     for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) {
  259.                         encode_rotate_left(&(buffer[buffer_line][i]));
  260.                         buffer[buffer_line][i] ^= BITMAP_TBL_XOR;
  261.                         encode_rotate_left(&(buffer[buffer_line][i]));
  262.                     }
  263.                 }
  264.                 p = strchr(&buffer[buffer_line][0],'\n');
  265.                 if (p) *p = '\0';
  266.             } else    {
  267.                 //fseek( file, 0, SEEK_SET);
  268.                 buffer[buffer_line][0] = 0;
  269.                 done++;
  270.             }
  271.         } while (extra_inc--);
  272.         extra_inc = 0;
  273.  
  274.         for (i=0; i<ROW_SPACING; i++ )    {
  275.             int y;
  276.  
  277.             y = first_line_offset - i;
  278.  
  279.             gr_set_current_canvas(VR_offscreen_buffer);
  280.             gr_bitmap(0,0,&backdrop);
  281.             for (j=0; j<NUM_LINES; j++ )    {
  282.                 char *s;
  283.  
  284.                 l = (buffer_line + j + 1 ) %  NUM_LINES;
  285.                 s = buffer[l];
  286.  
  287.                 if ( s[0] == '!' ) {
  288.                     s++;
  289.                 } else if ( s[0] == '$' )    {
  290.                     grd_curcanv->cv_font = header_font;
  291.                     s++;
  292.                 } else if ( s[0] == '*' )    {
  293.                     grd_curcanv->cv_font = title_font;
  294.                     s++;
  295.                 } else
  296.                     grd_curcanv->cv_font = names_font;
  297.  
  298.                 gr_bitblt_fade_table = fade_values;
  299.  
  300.                 tempp = strchr( s, '\t' );
  301.                 if ( tempp )    {
  302.                     int w, h, aw;
  303.                     *tempp = 0;
  304.                     gr_get_string_size( s, &w, &h, &aw );
  305.                     gr_printf( (160-w)/2, y, s );
  306.                     gr_get_string_size( &tempp[1], &w, &h, &aw );
  307.                     gr_printf( 160+((160-w)/2), y, &tempp[1] );
  308.                     *tempp = '\t';
  309.                 } else {
  310.                     gr_printf( 0x8000, y, s );
  311.                 }
  312.                 gr_bitblt_fade_table = NULL;
  313.                 if (buffer[l][0] == '!')
  314.                     y += ROW_SPACING/2;
  315.                 else
  316.                     y += ROW_SPACING;
  317.             }
  318.             gr_bm_ubitblt(320, 200, 0, 0, 0, 0, &(VR_offscreen_buffer->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) );
  319.  
  320.             while( timer_get_fixed_seconds() < last_time+time_delay );
  321.             last_time = timer_get_fixed_seconds();
  322.         
  323.  
  324.             k = key_inkey();
  325.  
  326.             #ifndef NDEBUG
  327.             if (k == KEY_BACKSP) {
  328.                 Int3();
  329.                 k=0;
  330.             }
  331.             #endif
  332.  
  333. //            {
  334. //                fix ot = time_delay;
  335. //                time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
  336. //                if (ot!=time_delay)    {
  337. //                    mprintf( (0, "[%x] ", time_delay ));
  338. //                }
  339. //            }
  340.  
  341.             if (k == KEY_PRINT_SCREEN) {
  342.                 save_screen_shot(0);
  343.                 k = 0;
  344.             }
  345.  
  346.             if ((k>0)||(done>NUM_LINES))    {
  347.                     gr_close_font(header_font);
  348.                     gr_close_font(title_font);
  349.                     gr_close_font(names_font);
  350.                     gr_palette_fade_out( gr_palette, 32, 0 );
  351.                     gr_use_palette_table( "palette.256" );
  352.                     free(backdrop.bm_data);
  353.                     cfclose(file);
  354.                     songs_play_song( SONG_TITLE, 1 );
  355.                     return;
  356.             }
  357.         }
  358.  
  359.         if (buffer[(buffer_line + 1 ) %  NUM_LINES][0] == '!') {
  360.             first_line_offset -= ROW_SPACING-ROW_SPACING/2;
  361.             if (first_line_offset <= -ROW_SPACING) {
  362.                 first_line_offset += ROW_SPACING;
  363.                 extra_inc++;
  364.             }
  365.         }
  366.     }
  367.  
  368. }
  369.  
  370.  
  371. 
  372.