2006-03-20 17:12:09 +00:00
|
|
|
/*
|
2014-06-01 17:55:23 +00:00
|
|
|
* Portions of this file are copyright Rebirth contributors and licensed as
|
|
|
|
* described in COPYING.txt.
|
|
|
|
* Portions of this file are copyright Parallax Software and licensed
|
|
|
|
* according to the Parallax license below.
|
|
|
|
* See COPYING.txt for license details.
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
|
2012-07-07 18:35:06 +00:00
|
|
|
#include "dxxerror.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "pstypes.h"
|
|
|
|
#include "gr.h"
|
2010-03-22 03:31:02 +00:00
|
|
|
#include "window.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "key.h"
|
2011-01-02 17:07:44 +00:00
|
|
|
#include "mouse.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "palette.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "gamefont.h"
|
|
|
|
#include "pcx.h"
|
2012-11-11 00:14:30 +00:00
|
|
|
#include "credits.h"
|
2010-03-22 03:31:02 +00:00
|
|
|
#include "u_mem.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "screens.h"
|
|
|
|
#include "digi.h"
|
2009-03-03 12:55:27 +00:00
|
|
|
#include "rbaudio.h"
|
2006-03-20 17:12:09 +00:00
|
|
|
#include "text.h"
|
|
|
|
#include "songs.h"
|
2008-06-04 19:30:43 +00:00
|
|
|
#include "menu.h"
|
2011-01-10 19:40:55 +00:00
|
|
|
#include "config.h"
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
|
|
|
#include "mission.h"
|
|
|
|
#include "gamepal.h"
|
2013-03-03 19:41:09 +00:00
|
|
|
#include "args.h"
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2006-03-20 17:12:09 +00:00
|
|
|
|
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
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
#define CREDITS_FILE "credits.tex"
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2011-06-01 07:59:55 +00:00
|
|
|
#define CREDITS_FILE (PHYSFSX_exists("mcredits.tex",1)?"mcredits.tex":PHYSFSX_exists("ocredits.tex",1)?"ocredits.tex":"credits.tex")
|
2013-06-27 10:48:59 +00:00
|
|
|
#define ALLOWED_CHAR ( Current_mission==NULL ? 'R' : (is_SHAREWARE ? 'S' : 'R'))
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2010-03-22 03:31:02 +00:00
|
|
|
|
2013-12-22 22:03:07 +00:00
|
|
|
struct credits
|
2010-03-22 03:31:02 +00:00
|
|
|
{
|
2011-06-01 07:59:55 +00:00
|
|
|
PHYSFS_file * file;
|
2010-03-22 03:31:02 +00:00
|
|
|
int have_bin_file;
|
|
|
|
char buffer[NUM_LINES][80];
|
|
|
|
int buffer_line;
|
|
|
|
int first_line_offset;
|
|
|
|
int extra_inc;
|
|
|
|
int done;
|
|
|
|
int row;
|
|
|
|
grs_bitmap backdrop;
|
2013-12-22 22:03:07 +00:00
|
|
|
};
|
2010-03-22 03:31:02 +00:00
|
|
|
|
2013-10-27 22:00:14 +00:00
|
|
|
static int credits_handler(window *wind, d_event *event, credits *cr)
|
2010-03-22 03:31:02 +00:00
|
|
|
{
|
2011-01-10 19:40:55 +00:00
|
|
|
int j, l, y;
|
2010-03-22 03:31:02 +00:00
|
|
|
char * tempp;
|
|
|
|
|
|
|
|
switch (event->type)
|
|
|
|
{
|
|
|
|
case EVENT_KEY_COMMAND:
|
2010-04-02 05:01:08 +00:00
|
|
|
if (!call_default_handler(event)) // if not print screen, debug etc
|
|
|
|
window_close(wind);
|
|
|
|
return 1;
|
2010-03-22 03:31:02 +00:00
|
|
|
|
2011-01-02 11:25:51 +00:00
|
|
|
case EVENT_MOUSE_BUTTON_DOWN:
|
|
|
|
case EVENT_MOUSE_BUTTON_UP:
|
2011-01-14 09:51:13 +00:00
|
|
|
if (event_mouse_get_button(event) == MBTN_LEFT || event_mouse_get_button(event) == MBTN_RIGHT)
|
2011-01-02 11:25:51 +00:00
|
|
|
{
|
|
|
|
window_close(wind);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-03-22 03:31:02 +00:00
|
|
|
case EVENT_IDLE:
|
2011-02-14 22:52:33 +00:00
|
|
|
if (cr->done>NUM_LINES)
|
|
|
|
{
|
|
|
|
window_close(wind);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_WINDOW_DRAW:
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
timer_delay(F1_0/17);
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2010-12-23 22:38:33 +00:00
|
|
|
timer_delay(F1_0/28);
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2010-03-22 03:31:02 +00:00
|
|
|
|
|
|
|
if (cr->row == 0)
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
cr->buffer_line = (cr->buffer_line+1) % NUM_LINES;
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2010-03-22 03:31:02 +00:00
|
|
|
get_line:;
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2013-11-23 00:13:36 +00:00
|
|
|
if (PHYSFSX_fgets( cr->buffer[cr->buffer_line], cr->file )) {
|
2010-03-22 03:31:02 +00:00
|
|
|
char *p;
|
|
|
|
if (cr->have_bin_file) // is this a binary tbl file
|
|
|
|
decode_text_line (cr->buffer[cr->buffer_line]);
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_I)
|
|
|
|
p = strchr(&cr->buffer[cr->buffer_line][0],'\n');
|
|
|
|
if (p) *p = '\0';
|
|
|
|
#elif defined(DXX_BUILD_DESCENT_II)
|
2010-03-22 03:31:02 +00:00
|
|
|
p = cr->buffer[cr->buffer_line];
|
|
|
|
if (p[0] == ';')
|
|
|
|
goto get_line;
|
|
|
|
|
|
|
|
if (p[0] == '%')
|
|
|
|
{
|
|
|
|
if (p[1] == ALLOWED_CHAR)
|
2013-06-27 10:48:59 +00:00
|
|
|
{
|
2013-12-03 23:21:36 +00:00
|
|
|
int i = 0;
|
|
|
|
for (i = 0; p[i]; i++)
|
2013-06-27 10:48:59 +00:00
|
|
|
p[i] = p[i+2];
|
|
|
|
}
|
2010-03-22 03:31:02 +00:00
|
|
|
else
|
|
|
|
goto get_line;
|
|
|
|
}
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2010-03-22 03:31:02 +00:00
|
|
|
} else {
|
|
|
|
//fseek( file, 0, SEEK_SET);
|
|
|
|
cr->buffer[cr->buffer_line][0] = 0;
|
|
|
|
cr->done++;
|
|
|
|
}
|
|
|
|
} while (cr->extra_inc--);
|
|
|
|
cr->extra_inc = 0;
|
|
|
|
}
|
2011-01-10 19:40:55 +00:00
|
|
|
|
|
|
|
// cheap but effective: towards end of credits sequence, fade out the music volume
|
|
|
|
if (cr->done >= NUM_LINES-16)
|
|
|
|
{
|
2013-06-27 10:55:19 +00:00
|
|
|
static int curvol = -10;
|
|
|
|
if (curvol == -10)
|
|
|
|
curvol = GameCfg.MusicVolume;
|
|
|
|
if (curvol > (NUM_LINES-cr->done)/2)
|
2011-01-10 19:40:55 +00:00
|
|
|
{
|
|
|
|
curvol = (NUM_LINES-cr->done)/2;
|
|
|
|
songs_set_volume(curvol);
|
|
|
|
}
|
|
|
|
}
|
2010-03-22 03:31:02 +00:00
|
|
|
|
|
|
|
y = cr->first_line_offset - cr->row;
|
|
|
|
show_fullscr(&cr->backdrop);
|
|
|
|
for (j=0; j<NUM_LINES; j++ ) {
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
l = (cr->buffer_line + j + 1 ) % NUM_LINES;
|
|
|
|
s = cr->buffer[l];
|
|
|
|
|
|
|
|
if ( s[0] == '!' ) {
|
|
|
|
s++;
|
|
|
|
} else if ( s[0] == '$' ) {
|
|
|
|
gr_set_curfont( HUGE_FONT );
|
|
|
|
s++;
|
|
|
|
} else if ( s[0] == '*' ) {
|
|
|
|
gr_set_curfont( MEDIUM3_FONT );
|
|
|
|
s++;
|
|
|
|
} else
|
|
|
|
gr_set_curfont( MEDIUM2_FONT );
|
|
|
|
|
|
|
|
tempp = strchr( s, '\t' );
|
|
|
|
if ( !tempp ) {
|
|
|
|
// Wacky Fast Credits thing
|
|
|
|
int w, h, aw;
|
|
|
|
|
|
|
|
gr_get_string_size( s, &w, &h, &aw);
|
2013-01-03 16:23:24 +00:00
|
|
|
gr_string( 0x8000, y, s );
|
2010-03-22 03:31:02 +00:00
|
|
|
}
|
|
|
|
y += ROW_SPACING;
|
|
|
|
}
|
|
|
|
|
|
|
|
cr->row += SHEIGHT/200;
|
|
|
|
if (cr->row >= ROW_SPACING)
|
|
|
|
cr->row = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVENT_WINDOW_CLOSE:
|
|
|
|
gr_free_bitmap_data (&cr->backdrop);
|
2011-06-01 07:59:55 +00:00
|
|
|
PHYSFS_close(cr->file);
|
2011-01-10 19:40:55 +00:00
|
|
|
songs_set_volume(GameCfg.MusicVolume);
|
2010-03-22 03:31:02 +00:00
|
|
|
songs_play_song( SONG_TITLE, 1 );
|
|
|
|
d_free(cr);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
//if filename passed is NULL, show normal credits
|
2012-11-11 00:14:30 +00:00
|
|
|
void credits_show(const char *credits_filename)
|
2006-03-20 17:12:09 +00:00
|
|
|
{
|
2010-03-22 03:31:02 +00:00
|
|
|
credits *cr;
|
|
|
|
window *wind;
|
|
|
|
int i;
|
2006-03-20 17:12:09 +00:00
|
|
|
int pcx_error;
|
|
|
|
char * tempp;
|
|
|
|
char filename[32];
|
2013-01-06 21:03:57 +00:00
|
|
|
palette_array_t backdrop_palette;
|
2010-03-22 03:31:02 +00:00
|
|
|
|
|
|
|
MALLOC(cr, credits, 1);
|
|
|
|
if (!cr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
cr->have_bin_file = 0;
|
|
|
|
cr->buffer_line = 0;
|
|
|
|
cr->first_line_offset = 0;
|
|
|
|
cr->extra_inc = 0;
|
|
|
|
cr->done = 0;
|
|
|
|
cr->row = 0;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
// Clear out all tex buffer lines.
|
|
|
|
for (i=0; i<NUM_LINES; i++ )
|
2010-03-22 03:31:02 +00:00
|
|
|
cr->buffer[i][0] = 0;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
sprintf(filename, "%s", CREDITS_FILE);
|
2010-03-22 03:31:02 +00:00
|
|
|
cr->have_bin_file = 0;
|
2008-10-16 17:27:02 +00:00
|
|
|
if (credits_filename) {
|
|
|
|
strcpy(filename,credits_filename);
|
2010-03-22 03:31:02 +00:00
|
|
|
cr->have_bin_file = 1;
|
2008-10-16 17:27:02 +00:00
|
|
|
}
|
2011-06-01 07:59:55 +00:00
|
|
|
cr->file = PHYSFSX_openReadBuffered( filename );
|
2010-03-22 03:31:02 +00:00
|
|
|
if (cr->file == NULL) {
|
2006-03-20 17:12:09 +00:00
|
|
|
char nfile[32];
|
|
|
|
|
2008-10-16 17:27:02 +00:00
|
|
|
if (credits_filename)
|
2011-04-13 19:11:22 +00:00
|
|
|
{
|
|
|
|
d_free(cr);
|
2008-10-16 17:27:02 +00:00
|
|
|
return; //ok to not find special filename
|
2011-04-13 19:11:22 +00:00
|
|
|
}
|
2008-10-16 17:27:02 +00:00
|
|
|
|
2006-03-20 17:12:09 +00:00
|
|
|
tempp = strchr(filename, '.');
|
|
|
|
*tempp = '\0';
|
|
|
|
sprintf(nfile, "%s.txb", filename);
|
2011-06-01 07:59:55 +00:00
|
|
|
cr->file = PHYSFSX_openReadBuffered(nfile);
|
2010-03-22 03:31:02 +00:00
|
|
|
if (cr->file == NULL)
|
2006-03-20 17:12:09 +00:00
|
|
|
Error("Missing CREDITS.TEX and CREDITS.TXB file\n");
|
2010-03-22 03:31:02 +00:00
|
|
|
cr->have_bin_file = 1;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_screen_mode(SCREEN_MENU);
|
2013-03-03 01:03:33 +00:00
|
|
|
#if defined(DXX_BUILD_DESCENT_II)
|
2006-03-20 17:12:09 +00:00
|
|
|
gr_use_palette_table( "credits.256" );
|
2013-03-03 01:03:33 +00:00
|
|
|
#endif
|
2010-03-22 03:31:02 +00:00
|
|
|
cr->backdrop.bm_data=NULL;
|
2006-03-20 17:12:09 +00:00
|
|
|
|
2010-03-22 03:31:02 +00:00
|
|
|
pcx_error = pcx_read_bitmap(STARS_BACKGROUND,&cr->backdrop, BM_LINEAR,backdrop_palette);
|
2006-03-20 17:12:09 +00:00
|
|
|
if (pcx_error != PCX_ERROR_NONE) {
|
2011-06-01 07:59:55 +00:00
|
|
|
PHYSFS_close(cr->file);
|
2011-04-13 19:11:22 +00:00
|
|
|
d_free(cr);
|
2006-03-20 17:12:09 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
songs_play_song( SONG_CREDITS, 1 );
|
|
|
|
|
2010-03-22 03:31:02 +00:00
|
|
|
gr_remap_bitmap_good( &cr->backdrop,backdrop_palette, -1, -1 );
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
gr_set_current_canvas(NULL);
|
2010-03-22 03:31:02 +00:00
|
|
|
show_fullscr(&cr->backdrop);
|
2008-03-20 23:23:46 +00:00
|
|
|
gr_palette_load( gr_palette );
|
2006-03-20 17:12:09 +00:00
|
|
|
|
|
|
|
key_flush();
|
|
|
|
|
2013-12-01 05:21:47 +00:00
|
|
|
wind = window_create(&grd_curscreen->sc_canvas, 0, 0, SWIDTH, SHEIGHT, credits_handler, cr);
|
2010-03-22 03:31:02 +00:00
|
|
|
if (!wind)
|
|
|
|
{
|
|
|
|
d_event event = { EVENT_WINDOW_CLOSE };
|
|
|
|
credits_handler(NULL, &event, cr);
|
|
|
|
return;
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|
2010-03-22 03:31:02 +00:00
|
|
|
|
|
|
|
while (window_exists(wind))
|
|
|
|
event_process();
|
2006-03-20 17:12:09 +00:00
|
|
|
}
|