CREDITS.C 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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. #pragma off (unreferenced)
  140. static char rcsid[] = "$Id: credits.c 2.2 1995/06/14 17:26:08 john Exp $";
  141. #pragma on (unreferenced)
  142. #include <stdio.h>
  143. #include <stdlib.h>
  144. #include <string.h>
  145. #include <dos.h>
  146. #include <stdarg.h>
  147. #include <ctype.h>
  148. #include "error.h"
  149. #include "types.h"
  150. #include "gr.h"
  151. #include "mono.h"
  152. #include "key.h"
  153. #include "palette.h"
  154. #include "game.h"
  155. #include "timer.h"
  156. #include "newmenu.h"
  157. #include "gamefont.h"
  158. #include "network.h"
  159. #include "iff.h"
  160. #include "pcx.h"
  161. #include "mem.h"
  162. #include "mouse.h"
  163. #include "joy.h"
  164. #include "screens.h"
  165. #include "digi.h"
  166. #include "cfile.h"
  167. #include "compbit.h"
  168. #include "vfx.h"
  169. #include "songs.h"
  170. #define ROW_SPACING 11
  171. #define NUM_LINES 20 //19
  172. 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,
  173. 11,11,12,12,12,13,13,14,14,15,15,15,16,16,17,17,17,18,18,19,19,19,20,20,
  174. 20,21,21,22,22,22,23,23,23,24,24,24,24,25,25,25,26,26,26,26,27,27,27,27,
  175. 28,28,28,28,28,29,29,29,29,29,29,30,30,30,30,30,30,30,30,30,31,31,31,31,
  176. 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,30,30,30,30,30,
  177. 30,30,30,30,29,29,29,29,29,29,28,28,28,28,28,27,27,27,27,26,26,26,26,25,
  178. 25,25,24,24,24,24,23,23,23,22,22,22,21,21,20,20,20,19,19,19,18,18,17,17,
  179. 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,
  180. 5,4,4,3,3,2,2,1 };
  181. extern ubyte *gr_bitblt_fade_table;
  182. grs_font * header_font;
  183. grs_font * title_font;
  184. grs_font * names_font;
  185. void credits_show()
  186. {
  187. int i, j, l, done;
  188. CFILE * file;
  189. char buffer[NUM_LINES][80];
  190. grs_bitmap backdrop;
  191. ubyte backdrop_palette[768];
  192. int pcx_error;
  193. int buffer_line = 0;
  194. fix last_time;
  195. fix time_delay = 4180; // ~ F1_0 / 12.9
  196. int first_line_offset,extra_inc=0;
  197. int have_bin_file = 0;
  198. char * tempp;
  199. set_screen_mode(SCREEN_MENU);
  200. // Clear out all tex buffer lines.
  201. for (i=0; i<NUM_LINES; i++ ) buffer[i][0] = 0;
  202. have_bin_file = 0;
  203. file = cfopen( "credits.tex", "rb" );
  204. if (file == NULL) {
  205. file = cfopen("credits.txb", "rb");
  206. if (file == NULL)
  207. Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
  208. have_bin_file = 1;
  209. }
  210. gr_use_palette_table( "credits.256" );
  211. header_font = gr_init_font( "font1-1.fnt" );
  212. title_font = gr_init_font( "font2-3.fnt" );
  213. names_font = gr_init_font( "font2-2.fnt" );
  214. backdrop.bm_data=NULL;
  215. pcx_error = pcx_read_bitmap("stars.pcx",&backdrop,grd_curcanv->cv_bitmap.bm_type,backdrop_palette);
  216. if (pcx_error != PCX_ERROR_NONE) {
  217. cfclose(file);
  218. return;
  219. }
  220. songs_play_song( SONG_CREDITS, 0 );
  221. gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
  222. gr_set_current_canvas(NULL);
  223. gr_bitmap(0,0,&backdrop);
  224. gr_palette_fade_in( gr_palette, 32, 0 );
  225. vfx_set_palette_sub( gr_palette );
  226. //gr_clear_canvas(BM_XRGB(0,0,0));
  227. key_flush();
  228. last_time = timer_get_fixed_seconds();
  229. done = 0;
  230. first_line_offset = 0;
  231. while( 1 ) {
  232. int k;
  233. do {
  234. buffer_line = (buffer_line+1) % NUM_LINES;
  235. if (cfgets( buffer[buffer_line], 80, file )) {
  236. char *p;
  237. if (have_bin_file) { // is this a binary tbl file
  238. for (i = 0; i < strlen(buffer[buffer_line]) - 1; i++) {
  239. encode_rotate_left(&(buffer[buffer_line][i]));
  240. buffer[buffer_line][i] ^= BITMAP_TBL_XOR;
  241. encode_rotate_left(&(buffer[buffer_line][i]));
  242. }
  243. }
  244. p = strchr(&buffer[buffer_line][0],'\n');
  245. if (p) *p = '\0';
  246. } else {
  247. //fseek( file, 0, SEEK_SET);
  248. buffer[buffer_line][0] = 0;
  249. done++;
  250. }
  251. } while (extra_inc--);
  252. extra_inc = 0;
  253. for (i=0; i<ROW_SPACING; i++ ) {
  254. int y;
  255. y = first_line_offset - i;
  256. gr_set_current_canvas(VR_offscreen_buffer);
  257. gr_bitmap(0,0,&backdrop);
  258. for (j=0; j<NUM_LINES; j++ ) {
  259. char *s;
  260. l = (buffer_line + j + 1 ) % NUM_LINES;
  261. s = buffer[l];
  262. if ( s[0] == '!' ) {
  263. s++;
  264. } else if ( s[0] == '$' ) {
  265. grd_curcanv->cv_font = header_font;
  266. s++;
  267. } else if ( s[0] == '*' ) {
  268. grd_curcanv->cv_font = title_font;
  269. s++;
  270. } else
  271. grd_curcanv->cv_font = names_font;
  272. gr_bitblt_fade_table = fade_values;
  273. tempp = strchr( s, '\t' );
  274. if ( tempp ) {
  275. int w, h, aw;
  276. *tempp = 0;
  277. gr_get_string_size( s, &w, &h, &aw );
  278. gr_printf( (160-w)/2, y, s );
  279. gr_get_string_size( &tempp[1], &w, &h, &aw );
  280. gr_printf( 160+((160-w)/2), y, &tempp[1] );
  281. *tempp = '\t';
  282. } else {
  283. gr_printf( 0x8000, y, s );
  284. }
  285. gr_bitblt_fade_table = NULL;
  286. if (buffer[l][0] == '!')
  287. y += ROW_SPACING/2;
  288. else
  289. y += ROW_SPACING;
  290. }
  291. gr_bm_ubitblt(320, 200, 0, 0, 0, 0, &(VR_offscreen_buffer->cv_bitmap), &(grd_curscreen->sc_canvas.cv_bitmap) );
  292. while( timer_get_fixed_seconds() < last_time+time_delay );
  293. last_time = timer_get_fixed_seconds();
  294. k = key_inkey();
  295. #ifndef NDEBUG
  296. if (k == KEY_BACKSP) {
  297. Int3();
  298. k=0;
  299. }
  300. #endif
  301. // {
  302. // fix ot = time_delay;
  303. // time_delay += (keyd_pressed[KEY_X] - keyd_pressed[KEY_Z])*100;
  304. // if (ot!=time_delay) {
  305. // mprintf( (0, "[%x] ", time_delay ));
  306. // }
  307. // }
  308. if (k == KEY_PRINT_SCREEN) {
  309. save_screen_shot(0);
  310. k = 0;
  311. }
  312. if ((k>0)||(done>NUM_LINES)) {
  313. gr_close_font(header_font);
  314. gr_close_font(title_font);
  315. gr_close_font(names_font);
  316. gr_palette_fade_out( gr_palette, 32, 0 );
  317. gr_use_palette_table( "palette.256" );
  318. free(backdrop.bm_data);
  319. cfclose(file);
  320. songs_play_song( SONG_TITLE, 1 );
  321. return;
  322. }
  323. }
  324. if (buffer[(buffer_line + 1 ) % NUM_LINES][0] == '!') {
  325. first_line_offset -= ROW_SPACING-ROW_SPACING/2;
  326. if (first_line_offset <= -ROW_SPACING) {
  327. first_line_offset += ROW_SPACING;
  328. extra_inc++;
  329. }
  330. }
  331. }
  332. }
  333.