2006-03-20 17:12:09 +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-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Routines to display the credits.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <conf.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "error.h"
|
|
|
|
#include "pstypes.h"
|
|
|
|
#include "gr.h"
|
|
|
|
#include "key.h"
|
|
|
|
#include "palette.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "gamepal.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "gamefont.h"
|
|
|
|
#include "pcx.h"
|
|
|
|
#include "screens.h"
|
|
|
|
#include "digi.h"
|
|
|
|
#include "cfile.h"
|
|
|
|
#include "text.h"
|
|
|
|
#include "songs.h"
|
|
|
|
|
2006-04-14 10:26:12 +00:00
|
|
|
#define ROW_SPACING (SHEIGHT / 17)
|
2006-08-22 00:01:06 +00:00
|
|
|
#define NUM_LINES 20 //14
|
2007-09-01 14:02:49 +00:00
|
|
|
#define CREDITS_FILE (cfexist("credits.txb")?"credits.tex":(cfexist("ocredits.txb")?"ocredits.tex":"mcredits.tex"))
|
2008-02-24 14:41:27 +00:00
|
|
|
#define CREDITS_BACKGROUND_FILENAME (((HIRESMODE) && cfexist("starsb.pcx"))?"starsb.pcx":"stars.pcx")
|
2006-03-26 13:50:17 +00:00
|
|
|
#ifdef SHAREWARE
|
|
|
|
#define ALLOWED_CHAR 'S'
|
|
|
|
#else
|
|
|
|
#define ALLOWED_CHAR 'R'
|
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//if filename passed is NULL, show normal credits
|
2008-02-24 14:41:27 +00:00
|
|
|
void credits_show()
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
|
|
|
CFILE * file;
|
2006-03-26 13:50:17 +00:00
|
|
|
int i, j, l, done;
|
2006-03-20 17:12:09 +00:00
|
|
|
int pcx_error;
|
|
|
|
int buffer_line = 0;
|
2006-03-26 13:50:17 +00:00
|
|
|
int first_line_offset;
|
|
|
|
int extra_inc=0;
|
2006-03-20 17:12:09 +00:00
|
|
|
int have_bin_file = 0;
|
|
|
|
char * tempp;
|
|
|
|
char filename[32];
|
2006-03-26 13:50:17 +00:00
|
|
|
char buffer[NUM_LINES][80];
|
|
|
|
ubyte backdrop_palette[768];
|
|
|
|
grs_bitmap backdrop;
|
2006-03-20 17:12:09 +00:00
|
|
|
grs_canvas *CreditsOffscreenBuf=NULL;
|
|
|
|
|
|
|
|
// Clear out all tex buffer lines.
|
|
|
|
for (i=0; i<NUM_LINES; i++ )
|
|
|
|
buffer[i][0] = 0;
|
|
|
|
|
|
|
|
sprintf(filename, "%s", CREDITS_FILE);
|
|
|
|
have_bin_file = 0;
|
2008-02-24 14:41:27 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
file = cfopen( filename, "rb" );
|
|
|
|
if (file == NULL) {
|
|
|
|
char nfile[32];
|
|
|
|
|
|
|
|
tempp = strchr(filename, '.');
|
|
|
|
*tempp = '\0';
|
|
|
|
sprintf(nfile, "%s.txb", filename);
|
|
|
|
file = cfopen(nfile, "rb");
|
|
|
|
if (file == NULL)
|
|
|
|
Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
|
|
|
|
have_bin_file = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_screen_mode(SCREEN_MENU);
|
|
|
|
gr_use_palette_table( "credits.256" );
|
|
|
|
backdrop.bm_data=NULL;
|
|
|
|
|
|
|
|
pcx_error = pcx_read_bitmap(CREDITS_BACKGROUND_FILENAME,&backdrop, BM_LINEAR,backdrop_palette);
|
|
|
|
if (pcx_error != PCX_ERROR_NONE) {
|
|
|
|
cfclose(file);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
songs_play_song( SONG_CREDITS, 1 );
|
|
|
|
|
|
|
|
gr_remap_bitmap_good( &backdrop,backdrop_palette, -1, -1 );
|
|
|
|
|
|
|
|
gr_set_current_canvas(NULL);
|
2006-03-26 13:50:17 +00:00
|
|
|
show_fullscr(&backdrop);
|
2008-03-20 23:23:46 +00:00
|
|
|
gr_palette_load( gr_palette );
|
2007-10-29 21:40:49 +00:00
|
|
|
CreditsOffscreenBuf = gr_create_sub_canvas(grd_curcanv,0,0,SWIDTH,SHEIGHT);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
if (!CreditsOffscreenBuf)
|
|
|
|
Error("Not enough memory to allocate Credits Buffer.");
|
|
|
|
|
|
|
|
key_flush();
|
|
|
|
|
2006-03-26 13:50:17 +00:00
|
|
|
done = 0;
|
2006-08-22 00:01:06 +00:00
|
|
|
|
2006-03-26 13:50:17 +00:00
|
|
|
first_line_offset = 0;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2006-03-26 13:50:17 +00:00
|
|
|
while( 1 ) {
|
2006-03-20 17:12:09 +00:00
|
|
|
int k;
|
|
|
|
|
|
|
|
do {
|
|
|
|
buffer_line = (buffer_line+1) % NUM_LINES;
|
|
|
|
get_line:;
|
|
|
|
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]);
|
|
|
|
p = buffer[buffer_line];
|
|
|
|
if (p[0] == ';')
|
|
|
|
goto get_line;
|
|
|
|
|
|
|
|
if (p[0] == '%')
|
|
|
|
{
|
|
|
|
if (p[1] == ALLOWED_CHAR)
|
|
|
|
strcpy(p,p+2);
|
|
|
|
else
|
|
|
|
goto get_line;
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
//fseek( file, 0, SEEK_SET);
|
|
|
|
buffer[buffer_line][0] = 0;
|
|
|
|
done++;
|
|
|
|
}
|
|
|
|
} while (extra_inc--);
|
|
|
|
extra_inc = 0;
|
|
|
|
|
2007-01-25 23:58:28 +00:00
|
|
|
for (i=0; i<ROW_SPACING; i += (SHEIGHT/200)) {
|
2006-03-20 17:12:09 +00:00
|
|
|
int y;
|
|
|
|
|
|
|
|
y = first_line_offset - i;
|
2007-03-22 11:32:22 +00:00
|
|
|
gr_flip();
|
2006-03-20 17:12:09 +00:00
|
|
|
gr_set_current_canvas(CreditsOffscreenBuf);
|
2006-03-26 13:50:17 +00:00
|
|
|
show_fullscr(&backdrop);
|
2006-03-20 17:12:09 +00:00
|
|
|
for (j=0; j<NUM_LINES; j++ ) {
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
l = (buffer_line + j + 1 ) % NUM_LINES;
|
|
|
|
s = buffer[l];
|
|
|
|
|
|
|
|
if ( s[0] == '!' ) {
|
|
|
|
s++;
|
|
|
|
} else if ( s[0] == '$' ) {
|
2008-02-24 14:41:27 +00:00
|
|
|
gr_set_curfont( HUGE_FONT );
|
2006-03-20 17:12:09 +00:00
|
|
|
s++;
|
|
|
|
} else if ( s[0] == '*' ) {
|
2008-02-24 14:41:27 +00:00
|
|
|
gr_set_curfont( MEDIUM3_FONT );
|
2006-03-20 17:12:09 +00:00
|
|
|
s++;
|
|
|
|
} else
|
2008-02-24 14:41:27 +00:00
|
|
|
gr_set_curfont( MEDIUM2_FONT );
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
tempp = strchr( s, '\t' );
|
2006-03-26 13:50:17 +00:00
|
|
|
if ( !tempp ) {
|
2006-03-20 17:12:09 +00:00
|
|
|
// Wacky Fast Credits thing
|
|
|
|
int w, h, aw;
|
|
|
|
|
|
|
|
gr_get_string_size( s, &w, &h, &aw);
|
|
|
|
gr_printf( 0x8000, y, s );
|
|
|
|
}
|
2006-04-14 10:26:12 +00:00
|
|
|
y += ROW_SPACING;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
2007-12-23 00:51:59 +00:00
|
|
|
timer_delay2(25);
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//see if redbook song needs to be restarted
|
|
|
|
songs_check_redbook_repeat();
|
|
|
|
|
|
|
|
k = key_inkey();
|
|
|
|
|
|
|
|
if (k == KEY_PRINT_SCREEN) {
|
|
|
|
save_screen_shot(0);
|
|
|
|
k = 0;
|
|
|
|
}
|
|
|
|
|
2008-02-24 14:41:27 +00:00
|
|
|
if ((k>0)||(done>NUM_LINES))
|
|
|
|
{
|
|
|
|
gr_free_bitmap_data (&backdrop);
|
|
|
|
cfclose(file);
|
|
|
|
songs_play_song( SONG_TITLE, 1 );
|
|
|
|
gr_free_sub_canvas(CreditsOffscreenBuf);
|
2006-03-20 17:12:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|