dxx-rebirth/main/credits.c

187 lines
4.3 KiB
C
Raw Normal View History

2006-03-20 16:43:15 +00:00
/*
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
2006-03-20 16:43:15 +00:00
/*
*
* Routines to display the credits.
2006-03-20 16:43:15 +00:00
*
*/
#ifdef RCS
#pragma off (unreferenced)
static char rcsid[] = "$Id: credits.c,v 1.1.1.1 2006/03/17 19:44:11 zicodxx Exp $";
#pragma on (unreferenced)
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include "error.h"
#include "pstypes.h"
2006-03-20 16:43:15 +00:00
#include "gr.h"
#include "key.h"
#include "palette.h"
#include "game.h"
#include "timer.h"
#include "gamefont.h"
#include "pcx.h"
#include "u_mem.h"
#include "screens.h"
#include "digi.h"
#include "cfile.h"
#include "songs.h"
#include "text.h"
2006-03-20 16:43:15 +00:00
2007-10-29 21:40:49 +00:00
#define ROW_SPACING (SHEIGHT/17)
#define NUM_LINES 20 //14
#define CREDITS_BACKGROUND_FILENAME "stars.pcx"
#define CREDITS_FILE "credits.tex"
2006-03-20 16:43:15 +00:00
//if filename passed is NULL, show normal credits
void credits_show()
2006-03-20 16:43:15 +00:00
{
CFILE * file;
int i, j, l, done;
2006-03-20 16:43:15 +00:00
int pcx_error;
int buffer_line = 0;
int first_line_offset;
int extra_inc=0;
2006-03-20 16:43:15 +00:00
int have_bin_file = 0;
char * tempp;
char filename[32];
char buffer[NUM_LINES][80];
ubyte backdrop_palette[768];
2006-03-20 16:43:15 +00:00
grs_canvas *CreditsOffscreenBuf=NULL;
grs_bitmap backdrop;
2006-03-20 16:43:15 +00:00
// Clear out all tex buffer lines.
for (i=0; i<NUM_LINES; i++ )
buffer[i][0] = 0;
sprintf(filename, "%s", CREDITS_FILE);
2006-03-20 16:43:15 +00:00
have_bin_file = 0;
file = cfopen( "credits.tex", "rb" );
2006-03-20 16:43:15 +00:00
if (file == NULL) {
file = cfopen("credits.txb", "rb");
2006-03-20 16:43:15 +00:00
if (file == NULL)
Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
have_bin_file = 1;
}
set_screen_mode(SCREEN_MENU);
gr_palette_fade_out( gr_palette,32,0);
backdrop.bm_data=NULL;
pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
if (pcx_error != PCX_ERROR_NONE) {
2006-03-20 16:43:15 +00:00
cfclose(file);
return;
}
songs_play_song( SONG_CREDITS, 1 );
2006-03-20 16:43:15 +00:00
gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
gr_set_current_canvas(NULL);
show_fullscr(&backdrop);
gr_palette_fade_in( gr_palette, 32, 0 );
2007-10-29 21:40:49 +00:00
CreditsOffscreenBuf = gr_create_sub_canvas(grd_curcanv,0,0,SWIDTH,SHEIGHT);
2006-03-20 16:43:15 +00:00
if (!CreditsOffscreenBuf)
Error("Not enough memory to allocate Credits Buffer.");
2006-03-20 16:43:15 +00:00
key_flush();
2006-03-20 16:43:15 +00:00
done = 0;
2006-03-20 16:43:15 +00:00
first_line_offset = 0;
while( 1 ) {
2006-03-20 16:43:15 +00:00
int k;
do {
buffer_line = (buffer_line+1) % NUM_LINES;
2006-03-20 16:43:15 +00:00
if (cfgets( buffer[buffer_line], 80, file )) {
char *p;
if (have_bin_file) // is this a binary tbl file
decode_text_line (buffer[buffer_line]);
2006-03-20 16:43:15 +00:00
p = strchr(&buffer[buffer_line][0],'\n');
if (p) *p = '\0';
} else {
buffer[buffer_line][0] = 0;
done++;
}
} while (extra_inc--);
extra_inc = 0;
for (i=0; i<ROW_SPACING; i += (SHEIGHT/200) ) {
2006-03-20 16:43:15 +00:00
int y;
y = first_line_offset - i;
gr_flip();
2006-03-20 16:43:15 +00:00
gr_set_current_canvas(CreditsOffscreenBuf);
show_fullscr(&backdrop);
for (j=0; j<NUM_LINES; j++ ) {
2006-03-20 16:43:15 +00:00
char *s;
l = (buffer_line + j + 1 ) % NUM_LINES;
2006-03-20 16:43:15 +00:00
s = buffer[l];
if ( s[0] == '!' ) {
s++;
} else if ( s[0] == '$' ) {
gr_set_curfont( HUGE_FONT );
2006-03-20 16:43:15 +00:00
s++;
} else if ( s[0] == '*' ) {
gr_set_curfont( MEDIUM3_FONT );
2006-03-20 16:43:15 +00:00
s++;
} else
gr_set_curfont( MEDIUM2_FONT );
2006-03-20 16:43:15 +00:00
tempp = strchr( s, '\t' );
if ( !tempp ) {
// Wacky Fast Credits thing
2006-03-20 16:43:15 +00:00
int w, h, aw;
gr_get_string_size( s, &w, &h, &aw);
2006-03-20 16:43:15 +00:00
gr_printf( 0x8000, y, s );
}
y += ROW_SPACING;
2006-03-20 16:43:15 +00:00
}
gr_update();
2006-03-20 16:43:15 +00:00
timer_delay2(25);
2006-03-20 16:43:15 +00:00
k = key_inkey();
if (k == KEY_PRINT_SCREEN) {
save_screen_shot(0);
k = 0;
}
if ((k>0)||(done>NUM_LINES))
{
gr_free_bitmap_data (&backdrop);
cfclose(file);
songs_play_song( SONG_TITLE, 1 );
gr_free_sub_canvas(CreditsOffscreenBuf);
return;
2006-03-20 16:43:15 +00:00
}
}
}
}