2003-11-07 06:30:06 +00:00
|
|
|
/* $Id: movie.c,v 1.32 2003-11-07 06:30:06 btb Exp $ */
|
2002-01-18 07:26:54 +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
|
2002-08-26 06:50:45 +00:00
|
|
|
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
|
2002-01-18 07:26:54 +00:00
|
|
|
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
|
|
|
|
*/
|
|
|
|
|
2003-10-10 09:36:35 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Movie Playing Stuff
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <conf.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
#ifdef RCS
|
2003-11-07 06:30:06 +00:00
|
|
|
static char rcsid[] = "$Id: movie.c,v 1.32 2003-11-07 06:30:06 btb Exp $";
|
2002-07-22 02:20:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define DEBUG_LEVEL CON_NORMAL
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
#include <string.h>
|
2002-07-22 02:20:05 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2002-01-18 07:26:54 +00:00
|
|
|
#include <fcntl.h>
|
2002-07-22 02:20:05 +00:00
|
|
|
#include <unistd.h>
|
2002-01-18 07:26:54 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
|
|
|
#include "movie.h"
|
2002-07-22 02:20:05 +00:00
|
|
|
#include "console.h"
|
|
|
|
#include "args.h"
|
2002-01-18 07:26:54 +00:00
|
|
|
#include "key.h"
|
2002-07-22 02:20:05 +00:00
|
|
|
#include "digi.h"
|
2002-01-18 07:26:54 +00:00
|
|
|
#include "songs.h"
|
2002-07-22 02:20:05 +00:00
|
|
|
#include "inferno.h"
|
|
|
|
#include "palette.h"
|
2002-01-18 07:26:54 +00:00
|
|
|
#include "strutil.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "u_mem.h"
|
|
|
|
#include "byteswap.h"
|
|
|
|
#include "gr.h"
|
2002-07-22 02:20:05 +00:00
|
|
|
#include "gamefont.h"
|
|
|
|
#include "cfile.h"
|
|
|
|
#include "menu.h"
|
2003-02-18 07:37:19 +00:00
|
|
|
#include "libmve.h"
|
2002-07-22 02:20:05 +00:00
|
|
|
#include "text.h"
|
2003-02-24 12:03:16 +00:00
|
|
|
#include "screens.h"
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
extern int MenuHiresAvailable;
|
|
|
|
extern char CDROM_dir[];
|
|
|
|
|
|
|
|
#define VID_PLAY 0
|
|
|
|
#define VID_PAUSE 1
|
|
|
|
|
|
|
|
int Vid_State;
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Subtitle data
|
|
|
|
typedef struct {
|
|
|
|
short first_frame,last_frame;
|
|
|
|
char *msg;
|
|
|
|
} subtitle;
|
|
|
|
|
|
|
|
#define MAX_SUBTITLES 500
|
2002-07-22 02:20:05 +00:00
|
|
|
#define MAX_ACTIVE_SUBTITLES 3
|
2002-01-18 07:26:54 +00:00
|
|
|
subtitle Subtitles[MAX_SUBTITLES];
|
|
|
|
int Num_subtitles;
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
// Movielib data
|
2002-07-22 02:20:05 +00:00
|
|
|
typedef struct {
|
|
|
|
char name[FILENAME_LEN];
|
|
|
|
int offset,len;
|
|
|
|
} ml_entry;
|
|
|
|
|
|
|
|
#define MLF_ON_CD 1
|
|
|
|
#define MAX_MOVIES_PER_LIB 50 //determines size of malloc
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[100]; //[FILENAME_LEN];
|
|
|
|
int n_movies;
|
|
|
|
ubyte flags,pad[3];
|
|
|
|
ml_entry *movies;
|
|
|
|
} movielib;
|
|
|
|
|
|
|
|
#ifdef D2_OEM
|
2002-07-23 01:05:31 +00:00
|
|
|
char movielib_files[][FILENAME_LEN] = {"intro-l.mvl","other-l.mvl","robots-l.mvl","oem-l.mvl"};
|
2002-07-22 02:20:05 +00:00
|
|
|
#else
|
2002-07-23 01:05:31 +00:00
|
|
|
char movielib_files[][FILENAME_LEN] = {"intro-l.mvl","other-l.mvl","robots-l.mvl"};
|
2002-07-22 02:20:05 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define N_BUILTIN_MOVIE_LIBS (sizeof(movielib_files)/sizeof(*movielib_files))
|
|
|
|
#define N_MOVIE_LIBS (N_BUILTIN_MOVIE_LIBS+1)
|
|
|
|
#define EXTRA_ROBOT_LIB N_BUILTIN_MOVIE_LIBS
|
|
|
|
movielib *movie_libs[N_MOVIE_LIBS];
|
|
|
|
|
|
|
|
|
|
|
|
//do we have the robot movies available
|
|
|
|
int robot_movies = 0; //0 means none, 1 means lowres, 2 means hires
|
|
|
|
|
2003-03-21 23:13:25 +00:00
|
|
|
int MovieHires = 1; //default is highres
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *RoboFile = NULL;
|
|
|
|
int RoboFilePos = 0;
|
2002-08-27 04:14:18 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
// Function Prototypes
|
2002-07-22 02:20:05 +00:00
|
|
|
int RunMovie(char *filename, int highres_flag, int allow_abort,int dx,int dy);
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *open_movie_file(char *filename, int must_have);
|
|
|
|
int reset_movie_file(CFILE *handle);
|
2002-07-22 02:20:05 +00:00
|
|
|
|
|
|
|
void change_filename_ext( char *dest, char *src, char *ext );
|
|
|
|
void decode_text_line(char *p);
|
|
|
|
void draw_subtitles(int frame_num);
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
// ----------------------------------------------------------------------
|
|
|
|
void* MPlayAlloc(unsigned size)
|
|
|
|
{
|
|
|
|
return d_malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MPlayFree(void *p)
|
|
|
|
{
|
|
|
|
d_free(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
unsigned int FileRead(void *handle, void *buf, unsigned int count)
|
|
|
|
{
|
|
|
|
unsigned numread;
|
2003-06-19 05:40:20 +00:00
|
|
|
numread = cfread(buf, 1, count, (CFILE *)handle);
|
2003-06-10 04:46:16 +00:00
|
|
|
return (numread == count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//filename will actually get modified to be either low-res or high-res
|
|
|
|
//returns status. see values in movie.h
|
|
|
|
int PlayMovie(const char *filename, int must_have)
|
|
|
|
{
|
|
|
|
char name[FILENAME_LEN],*p;
|
|
|
|
int c, ret;
|
2002-08-26 06:50:45 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
#ifndef RELEASE
|
2002-08-31 12:14:01 +00:00
|
|
|
if (FindArg("-nomovies"))
|
2002-01-18 07:26:54 +00:00
|
|
|
return MOVIE_NOT_PLAYED;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
strcpy(name,filename);
|
|
|
|
|
|
|
|
if ((p=strchr(name,'.')) == NULL) //add extension, if missing
|
|
|
|
strcat(name,".mve");
|
|
|
|
|
|
|
|
//check for escape already pressed & abort if so
|
|
|
|
while ((c=key_inkey()) != 0)
|
|
|
|
if (c == KEY_ESC)
|
|
|
|
return MOVIE_ABORTED;
|
|
|
|
|
|
|
|
// Stop all digital sounds currently playing.
|
|
|
|
digi_stop_all();
|
|
|
|
|
|
|
|
// Stop all songs
|
|
|
|
songs_stop_all();
|
|
|
|
|
2002-07-22 06:29:00 +00:00
|
|
|
digi_close();
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-02-19 03:09:38 +00:00
|
|
|
// Start sound
|
|
|
|
if (!FindArg("-nosound"))
|
|
|
|
MVE_sndInit(1);
|
|
|
|
else
|
|
|
|
MVE_sndInit(-1);
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
ret = RunMovie(name,MovieHires,must_have,-1,-1);
|
|
|
|
|
2003-02-14 03:45:31 +00:00
|
|
|
if (!FindArg("-nosound"))
|
|
|
|
digi_init();
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-07-22 06:29:00 +00:00
|
|
|
Screen_mode = -1; //force screen reset
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
void MovieShowFrame(ubyte *buf, uint bufw, uint bufh, uint sx, uint sy,
|
|
|
|
uint w, uint h, uint dstx, uint dsty)
|
|
|
|
{
|
|
|
|
grs_bitmap source_bm;
|
|
|
|
|
|
|
|
//mprintf((0,"MovieShowFrame %d,%d %d,%d %d,%d %d,%d\n",bufw,bufh,sx,sy,w,h,dstx,dsty));
|
|
|
|
|
|
|
|
Assert(bufw == w && bufh == h);
|
|
|
|
|
|
|
|
source_bm.bm_x = source_bm.bm_y = 0;
|
|
|
|
source_bm.bm_w = source_bm.bm_rowsize = bufw;
|
|
|
|
source_bm.bm_h = bufh;
|
|
|
|
source_bm.bm_type = BM_LINEAR;
|
|
|
|
source_bm.bm_flags = 0;
|
|
|
|
source_bm.bm_data = buf;
|
|
|
|
|
|
|
|
gr_bm_ubitblt(bufw,bufh,dstx,dsty,sx,sy,&source_bm,&grd_curcanv->cv_bitmap);
|
|
|
|
}
|
|
|
|
|
|
|
|
//our routine to set the pallete, called from the movie code
|
|
|
|
void MovieSetPalette(unsigned char *p, unsigned start, unsigned count)
|
|
|
|
{
|
|
|
|
if (count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
//mprintf((0,"SetPalette p=%x, start=%d, count=%d\n",p,start,count));
|
|
|
|
|
|
|
|
//Color 0 should be black, and we get color 255
|
|
|
|
Assert(start>=1 && start+count-1<=254);
|
|
|
|
|
|
|
|
//Set color 0 to be black
|
|
|
|
gr_palette[0] = gr_palette[1] = gr_palette[2] = 0;
|
|
|
|
|
|
|
|
//Set color 255 to be our subtitle color
|
|
|
|
gr_palette[765] = gr_palette[766] = gr_palette[767] = 50;
|
|
|
|
|
|
|
|
//movie libs palette into our array
|
|
|
|
memcpy(gr_palette+start*3,p+start*3,count*3);
|
|
|
|
|
|
|
|
//finally set the palette in the hardware
|
|
|
|
//gr_palette_load(gr_palette);
|
|
|
|
|
|
|
|
//MVE_SetPalette(p, start, count);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-01 02:49:06 +00:00
|
|
|
#if 0
|
|
|
|
typedef struct bkg {
|
|
|
|
short x, y, w, h; // The location of the menu.
|
|
|
|
grs_bitmap * bmp; // The background under the menu.
|
|
|
|
} bkg;
|
|
|
|
|
|
|
|
bkg movie_bg = {0,0,0,0,NULL};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BOX_BORDER (MenuHires?40:20)
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2002-09-01 02:49:06 +00:00
|
|
|
void show_pause_message(char *msg)
|
|
|
|
{
|
|
|
|
int w,h,aw;
|
|
|
|
int x,y;
|
|
|
|
|
|
|
|
gr_set_current_canvas(NULL);
|
|
|
|
gr_set_curfont( SMALL_FONT );
|
|
|
|
|
|
|
|
gr_get_string_size(msg,&w,&h,&aw);
|
|
|
|
|
|
|
|
x = (grd_curscreen->sc_w-w)/2;
|
|
|
|
y = (grd_curscreen->sc_h-h)/2;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
if (movie_bg.bmp) {
|
|
|
|
gr_free_bitmap(movie_bg.bmp);
|
|
|
|
movie_bg.bmp = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save the background of the display
|
|
|
|
movie_bg.x=x; movie_bg.y=y; movie_bg.w=w; movie_bg.h=h;
|
|
|
|
|
|
|
|
movie_bg.bmp = gr_create_bitmap( w+BOX_BORDER, h+BOX_BORDER );
|
|
|
|
|
|
|
|
gr_bm_ubitblt(w+BOX_BORDER, h+BOX_BORDER, 0, 0, x-BOX_BORDER/2, y-BOX_BORDER/2, &(grd_curcanv->cv_bitmap), movie_bg.bmp );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gr_setcolor(0);
|
|
|
|
gr_rect(x-BOX_BORDER/2,y-BOX_BORDER/2,x+w+BOX_BORDER/2-1,y+h+BOX_BORDER/2-1);
|
|
|
|
|
|
|
|
gr_set_fontcolor( 255, -1 );
|
|
|
|
|
|
|
|
gr_ustring( 0x8000, y, msg );
|
|
|
|
|
|
|
|
gr_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear_pause_message()
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
if (movie_bg.bmp) {
|
|
|
|
|
|
|
|
gr_bitmap(movie_bg.x-BOX_BORDER/2, movie_bg.y-BOX_BORDER/2, movie_bg.bmp);
|
|
|
|
|
|
|
|
gr_free_bitmap(movie_bg.bmp);
|
|
|
|
movie_bg.bmp = NULL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//returns status. see movie.h
|
|
|
|
int RunMovie(char *filename, int hires_flag, int must_have,int dx,int dy)
|
|
|
|
{
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *filehndl;
|
2002-07-22 02:20:05 +00:00
|
|
|
int result=1,aborted=0;
|
2003-02-18 07:05:14 +00:00
|
|
|
int track = 0;
|
2002-07-22 02:20:05 +00:00
|
|
|
int frame_num;
|
2002-09-01 02:49:06 +00:00
|
|
|
int key;
|
2003-02-28 11:27:05 +00:00
|
|
|
#ifdef OGL
|
|
|
|
char pal_save[768];
|
|
|
|
#endif
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-08-26 06:50:45 +00:00
|
|
|
result=1;
|
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
// Open Movie file. If it doesn't exist, no movie, just return.
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
filehndl = open_movie_file(filename,must_have);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
if (filehndl == NULL)
|
|
|
|
{
|
2002-08-26 06:50:45 +00:00
|
|
|
if (must_have)
|
2003-06-22 23:04:54 +00:00
|
|
|
con_printf(CON_NORMAL, "movie: RunMovie: Cannot open movie <%s>\n",filename);
|
2002-08-26 06:50:45 +00:00
|
|
|
return MOVIE_NOT_PLAYED;
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
MVE_memCallbacks(MPlayAlloc, MPlayFree);
|
|
|
|
MVE_ioCallbacks(FileRead);
|
|
|
|
|
2002-09-01 02:49:06 +00:00
|
|
|
if (hires_flag) {
|
2002-07-22 02:20:05 +00:00
|
|
|
gr_set_mode(SM(640,480));
|
2002-09-01 02:49:06 +00:00
|
|
|
} else {
|
2002-07-22 02:20:05 +00:00
|
|
|
gr_set_mode(SM(320,200));
|
2003-02-18 07:05:14 +00:00
|
|
|
}
|
2003-02-28 09:56:10 +00:00
|
|
|
#ifdef OGL
|
|
|
|
set_screen_mode(SCREEN_MENU);
|
2003-02-28 11:27:05 +00:00
|
|
|
gr_copy_palette(pal_save, gr_palette, 768);
|
|
|
|
memset(gr_palette, 0, 768);
|
|
|
|
gr_palette_load(gr_palette);
|
2003-02-28 09:56:10 +00:00
|
|
|
#endif
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
#if !defined(POLY_ACC)
|
|
|
|
MVE_sfCallbacks(MovieShowFrame);
|
|
|
|
MVE_palCallbacks(MovieSetPalette);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (MVE_rmPrepMovie((void *)filehndl, dx, dy, track)) {
|
2003-02-18 07:05:14 +00:00
|
|
|
Int3();
|
|
|
|
return MOVIE_NOT_PLAYED;
|
2002-09-01 02:49:06 +00:00
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
frame_num = 0;
|
|
|
|
|
2002-08-31 12:14:01 +00:00
|
|
|
FontHires = FontHiresAvailable && hires_flag;
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
while((result = MVE_rmStepMovie()) == 0) {
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
draw_subtitles(frame_num);
|
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
gr_palette_load(gr_palette); // moved this here because of flashing
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
gr_update();
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
key = key_inkey();
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
// If ESCAPE pressed, then quit movie.
|
|
|
|
if (key == KEY_ESC) {
|
|
|
|
result = aborted = 1;
|
2002-07-22 02:20:05 +00:00
|
|
|
break;
|
2003-02-18 07:05:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If PAUSE pressed, then pause movie
|
|
|
|
if (key == KEY_PAUSE) {
|
|
|
|
MVE_rmHoldMovie();
|
2002-09-01 02:49:06 +00:00
|
|
|
show_pause_message(TXT_PAUSE);
|
2002-07-22 02:20:05 +00:00
|
|
|
while (!key_inkey()) ;
|
2002-09-01 02:49:06 +00:00
|
|
|
clear_pause_message();
|
2003-02-18 07:05:14 +00:00
|
|
|
}
|
|
|
|
|
2003-01-09 00:57:42 +00:00
|
|
|
#ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE
|
2003-11-07 06:30:06 +00:00
|
|
|
if ((key == KEY_ALTED+KEY_ENTER) ||
|
|
|
|
(key == KEY_ALTED+KEY_PADENTER))
|
2002-09-04 08:13:59 +00:00
|
|
|
gr_toggle_fullscreen();
|
2003-01-09 00:57:42 +00:00
|
|
|
#endif
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
frame_num++;
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
Assert(aborted || result == MVE_ERR_EOF); ///movie should be over
|
2002-08-26 06:50:45 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
MVE_rmEndMovie();
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
cfclose(filehndl); // Close Movie File
|
2002-08-26 06:50:45 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
// Restore old graphic state
|
|
|
|
|
2002-07-22 06:29:00 +00:00
|
|
|
Screen_mode=-1; //force reset of screen mode
|
2003-02-28 11:27:05 +00:00
|
|
|
#ifdef OGL
|
|
|
|
gr_copy_palette(gr_palette, pal_save, 768);
|
|
|
|
gr_palette_load(pal_save);
|
|
|
|
#endif
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
return (aborted?MOVIE_ABORTED:MOVIE_PLAYED_FULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
int InitMovieBriefing()
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
2003-02-25 04:45:31 +00:00
|
|
|
#if 0
|
2002-07-22 02:20:05 +00:00
|
|
|
if (MenuHires)
|
|
|
|
gr_set_mode(SM(640,480));
|
|
|
|
else
|
|
|
|
gr_set_mode(SM(320,200));
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2003-02-24 12:03:16 +00:00
|
|
|
gr_init_sub_canvas( &VR_screen_pages[0], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
|
|
|
|
gr_init_sub_canvas( &VR_screen_pages[1], &grd_curscreen->sc_canvas, 0, 0, grd_curscreen->sc_w, grd_curscreen->sc_h );
|
2003-02-25 04:45:31 +00:00
|
|
|
#endif
|
2003-02-24 12:03:16 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-27 04:14:18 +00:00
|
|
|
//returns 1 if frame updated ok
|
|
|
|
int RotateRobot()
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
2003-02-18 07:05:14 +00:00
|
|
|
int err;
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
err = MVE_rmStepMovie();
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
if (err == MVE_ERR_EOF) //end of movie, so reset
|
|
|
|
{
|
|
|
|
reset_movie_file(RoboFile);
|
2003-06-10 04:46:16 +00:00
|
|
|
if (MVE_rmPrepMovie((void *)RoboFile, MenuHires?280:140, MenuHires?200:80, 0)) {
|
2003-02-18 07:05:14 +00:00
|
|
|
Int3();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (err) {
|
|
|
|
Int3();
|
|
|
|
return 0;
|
2002-08-31 12:14:01 +00:00
|
|
|
}
|
2002-08-27 04:14:18 +00:00
|
|
|
|
2002-08-31 12:14:01 +00:00
|
|
|
return 1;
|
2002-07-22 02:20:05 +00:00
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
void DeInitRobotMovie(void)
|
|
|
|
{
|
2003-02-18 07:05:14 +00:00
|
|
|
MVE_rmEndMovie();
|
2003-06-19 05:40:20 +00:00
|
|
|
cfclose(RoboFile); // Close Movie File
|
2002-07-22 02:20:05 +00:00
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
|
2002-07-26 09:25:10 +00:00
|
|
|
int InitRobotMovie(char *filename)
|
2002-07-22 02:20:05 +00:00
|
|
|
{
|
2003-02-18 07:05:14 +00:00
|
|
|
if (FindArg("-nomovies"))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
con_printf(DEBUG_LEVEL, "RoboFile=%s\n", filename);
|
|
|
|
|
2003-02-19 03:09:38 +00:00
|
|
|
MVE_sndInit(-1); //tell movies to play no sound for robots
|
|
|
|
|
2002-08-31 12:14:01 +00:00
|
|
|
RoboFile = open_movie_file(filename, 1);
|
2002-07-26 09:25:10 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
if (RoboFile == NULL)
|
|
|
|
{
|
2002-08-27 04:14:18 +00:00
|
|
|
Warning("movie: InitRobotMovie: Cannot open movie file <%s>",filename);
|
2002-07-26 09:25:10 +00:00
|
|
|
return MOVIE_NOT_PLAYED;
|
|
|
|
}
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
Vid_State = VID_PLAY;
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2003-06-10 04:46:16 +00:00
|
|
|
if (MVE_rmPrepMovie((void *)RoboFile, MenuHires?280:140, MenuHires?200:80, 0)) {
|
2003-02-18 07:05:14 +00:00
|
|
|
Int3();
|
|
|
|
return 0;
|
|
|
|
}
|
2002-07-26 09:25:10 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
RoboFilePos = cfseek(RoboFile, 0L, SEEK_CUR);
|
2002-08-31 12:14:01 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
con_printf(DEBUG_LEVEL, "RoboFilePos=%d!\n", RoboFilePos);
|
2002-07-26 09:25:10 +00:00
|
|
|
|
|
|
|
return 1;
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
/*
|
|
|
|
* Subtitle system code
|
|
|
|
*/
|
|
|
|
|
|
|
|
ubyte *subtitle_raw_data;
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//search for next field following whitespace
|
|
|
|
ubyte *next_field(ubyte *p)
|
|
|
|
{
|
|
|
|
while (*p && !isspace(*p))
|
|
|
|
p++;
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
while (*p && isspace(*p))
|
|
|
|
p++;
|
|
|
|
|
|
|
|
if (!*p)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int init_subtitles(char *filename)
|
|
|
|
{
|
|
|
|
CFILE *ifile;
|
|
|
|
int size,read_count;
|
|
|
|
ubyte *p;
|
|
|
|
int have_binary = 0;
|
|
|
|
|
|
|
|
Num_subtitles = 0;
|
|
|
|
|
|
|
|
if (! FindArg("-subtitles"))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
ifile = cfopen(filename,"rb"); //try text version
|
|
|
|
|
|
|
|
if (!ifile) { //no text version, try binary version
|
|
|
|
char filename2[FILENAME_LEN];
|
|
|
|
change_filename_ext(filename2,filename,".TXB");
|
|
|
|
ifile = cfopen(filename2,"rb");
|
|
|
|
if (!ifile)
|
|
|
|
return 0;
|
|
|
|
have_binary = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = cfilelength(ifile);
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
MALLOC (subtitle_raw_data, ubyte, size+1);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
read_count = cfread(subtitle_raw_data, 1, size, ifile);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
cfclose(ifile);
|
|
|
|
|
|
|
|
subtitle_raw_data[size] = 0;
|
|
|
|
|
|
|
|
if (read_count != size) {
|
2002-07-22 02:20:05 +00:00
|
|
|
d_free(subtitle_raw_data);
|
2002-01-18 07:26:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = subtitle_raw_data;
|
|
|
|
|
|
|
|
while (p && p < subtitle_raw_data+size) {
|
|
|
|
char *endp;
|
|
|
|
|
|
|
|
endp = strchr(p,'\n');
|
|
|
|
if (endp) {
|
|
|
|
if (endp[-1] == '\r')
|
|
|
|
endp[-1] = 0; //handle 0d0a pair
|
|
|
|
*endp = 0; //string termintor
|
|
|
|
}
|
|
|
|
|
|
|
|
if (have_binary)
|
|
|
|
decode_text_line(p);
|
|
|
|
|
|
|
|
if (*p != ';') {
|
|
|
|
Subtitles[Num_subtitles].first_frame = atoi(p);
|
|
|
|
p = next_field(p); if (!p) continue;
|
|
|
|
Subtitles[Num_subtitles].last_frame = atoi(p);
|
|
|
|
p = next_field(p); if (!p) continue;
|
|
|
|
Subtitles[Num_subtitles].msg = p;
|
|
|
|
|
|
|
|
Assert(Num_subtitles==0 || Subtitles[Num_subtitles].first_frame >= Subtitles[Num_subtitles-1].first_frame);
|
|
|
|
Assert(Subtitles[Num_subtitles].last_frame >= Subtitles[Num_subtitles].first_frame);
|
|
|
|
|
|
|
|
Num_subtitles++;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = endp+1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
void close_subtitles()
|
|
|
|
{
|
|
|
|
if (subtitle_raw_data)
|
2002-07-22 02:20:05 +00:00
|
|
|
d_free(subtitle_raw_data);
|
2002-01-18 07:26:54 +00:00
|
|
|
subtitle_raw_data = NULL;
|
|
|
|
Num_subtitles = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
//draw the subtitles for this frame
|
|
|
|
void draw_subtitles(int frame_num)
|
|
|
|
{
|
|
|
|
static int active_subtitles[MAX_ACTIVE_SUBTITLES];
|
|
|
|
static int num_active_subtitles,next_subtitle,line_spacing;
|
|
|
|
int t,y;
|
|
|
|
int must_erase=0;
|
|
|
|
|
|
|
|
if (frame_num == 0) {
|
|
|
|
num_active_subtitles = 0;
|
|
|
|
next_subtitle = 0;
|
|
|
|
gr_set_curfont( GAME_FONT );
|
|
|
|
line_spacing = grd_curcanv->cv_font->ft_h + (grd_curcanv->cv_font->ft_h >> 2);
|
|
|
|
gr_set_fontcolor(255,-1);
|
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
//get rid of any subtitles that have expired
|
|
|
|
for (t=0;t<num_active_subtitles;)
|
|
|
|
if (frame_num > Subtitles[active_subtitles[t]].last_frame) {
|
|
|
|
int t2;
|
|
|
|
for (t2=t;t2<num_active_subtitles-1;t2++)
|
|
|
|
active_subtitles[t2] = active_subtitles[t2+1];
|
|
|
|
num_active_subtitles--;
|
|
|
|
must_erase = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t++;
|
|
|
|
|
|
|
|
//get any subtitles new for this frame
|
|
|
|
while (next_subtitle < Num_subtitles && frame_num >= Subtitles[next_subtitle].first_frame) {
|
|
|
|
if (num_active_subtitles >= MAX_ACTIVE_SUBTITLES)
|
|
|
|
Error("Too many active subtitles!");
|
|
|
|
active_subtitles[num_active_subtitles++] = next_subtitle;
|
|
|
|
next_subtitle++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//find y coordinate for first line of subtitles
|
|
|
|
y = grd_curcanv->cv_bitmap.bm_h-((line_spacing+1)*MAX_ACTIVE_SUBTITLES+2);
|
|
|
|
|
|
|
|
//erase old subtitles if necessary
|
|
|
|
if (must_erase) {
|
|
|
|
gr_setcolor(0);
|
|
|
|
gr_rect(0,y,grd_curcanv->cv_bitmap.bm_w-1,grd_curcanv->cv_bitmap.bm_h-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//now draw the current subtitles
|
|
|
|
for (t=0;t<num_active_subtitles;t++)
|
|
|
|
if (active_subtitles[t] != -1) {
|
|
|
|
gr_string(0x8000,y,Subtitles[active_subtitles[t]].msg);
|
|
|
|
y += line_spacing+1;
|
|
|
|
}
|
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
movielib *init_new_movie_lib(char *filename, CFILE *fp)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
|
|
|
int nfiles,offset;
|
|
|
|
int i,n;
|
|
|
|
movielib *table;
|
|
|
|
|
|
|
|
//read movie file header
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
nfiles = cfile_read_int(fp); //get number of files
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
//table = d_malloc(sizeof(*table) + sizeof(ml_entry)*nfiles);
|
|
|
|
MALLOC(table, movielib, 1);
|
|
|
|
MALLOC(table->movies, ml_entry, nfiles);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
strcpy(table->name,filename);
|
|
|
|
table->n_movies = nfiles;
|
|
|
|
|
|
|
|
offset = 4+4+nfiles*(13+4); //id + nfiles + nfiles * (filename + size)
|
|
|
|
|
|
|
|
for (i=0;i<nfiles;i++) {
|
|
|
|
int len;
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
n = cfread(table->movies[i].name, 13, 1, fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
if ( n != 1 )
|
|
|
|
break; //end of file (probably)
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
len = cfile_read_int(fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-26 20:59:41 +00:00
|
|
|
table->movies[i].len = len;
|
2002-01-18 07:26:54 +00:00
|
|
|
table->movies[i].offset = offset;
|
|
|
|
|
|
|
|
offset += table->movies[i].len;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
cfclose(fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
table->flags = 0;
|
|
|
|
|
|
|
|
return table;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
movielib *init_old_movie_lib(char *filename, CFILE *fp)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
|
|
|
int nfiles,size;
|
|
|
|
int i;
|
|
|
|
movielib *table,*table2;
|
|
|
|
|
|
|
|
nfiles = 0;
|
|
|
|
|
|
|
|
//allocate big table
|
2002-07-22 02:20:05 +00:00
|
|
|
table = d_malloc(sizeof(*table) + sizeof(ml_entry)*MAX_MOVIES_PER_LIB);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
while( 1 ) {
|
|
|
|
int len;
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
i = cfread(table->movies[nfiles].name, 13, 1, fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
if ( i != 1 )
|
|
|
|
break; //end of file (probably)
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
i = cfread(&len, 4, 1, fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
if ( i != 1 )
|
|
|
|
Error("error reading movie library <%s>",filename);
|
|
|
|
|
|
|
|
table->movies[nfiles].len = INTEL_INT(len);
|
2003-06-16 06:57:34 +00:00
|
|
|
table->movies[nfiles].offset = cftell(fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
cfseek(fp, INTEL_INT(len), SEEK_CUR); //skip data
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
nfiles++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//allocate correct-sized table
|
|
|
|
size = sizeof(*table) + sizeof(ml_entry)*nfiles;
|
2002-07-22 02:20:05 +00:00
|
|
|
table2 = d_malloc(size);
|
2002-01-18 07:26:54 +00:00
|
|
|
memcpy(table2,table,size);
|
2002-07-22 02:20:05 +00:00
|
|
|
d_free(table);
|
2002-01-18 07:26:54 +00:00
|
|
|
table = table2;
|
|
|
|
|
|
|
|
strcpy(table->name,filename);
|
|
|
|
|
|
|
|
table->n_movies = nfiles;
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
cfclose(fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
table->flags = 0;
|
|
|
|
|
|
|
|
return table;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-08-26 06:50:45 +00:00
|
|
|
//find the specified movie library, and read in list of movies in it
|
2002-01-18 07:26:54 +00:00
|
|
|
movielib *init_movie_lib(char *filename)
|
|
|
|
{
|
|
|
|
//note: this based on cfile_init_hogfile()
|
|
|
|
|
|
|
|
char id[4];
|
2003-06-16 06:57:34 +00:00
|
|
|
CFILE *fp;
|
2002-08-26 06:50:45 +00:00
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
fp = cfopen(filename, "rb");
|
2002-08-26 06:50:45 +00:00
|
|
|
|
|
|
|
if ( fp == NULL )
|
2002-01-18 07:26:54 +00:00
|
|
|
return NULL;
|
|
|
|
|
2003-06-16 06:57:34 +00:00
|
|
|
cfread(id, 4, 1, fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
if ( !strncmp( id, "DMVL", 4 ) )
|
|
|
|
return init_new_movie_lib(filename,fp);
|
|
|
|
else if ( !strncmp( id, "DHF", 3 ) ) {
|
2003-06-16 06:57:34 +00:00
|
|
|
cfseek(fp,-1,SEEK_CUR); //old file had 3 char id
|
2002-01-18 07:26:54 +00:00
|
|
|
return init_old_movie_lib(filename,fp);
|
|
|
|
}
|
|
|
|
else {
|
2003-06-16 06:57:34 +00:00
|
|
|
cfclose(fp);
|
2002-01-18 07:26:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void close_movie(int i)
|
|
|
|
{
|
2002-07-22 02:20:05 +00:00
|
|
|
if (movie_libs[i]) {
|
|
|
|
d_free(movie_libs[i]->movies);
|
|
|
|
d_free(movie_libs[i]);
|
|
|
|
}
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
void close_movies()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i=0;i<N_MOVIE_LIBS;i++)
|
|
|
|
close_movie(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
//ask user to put the D2 CD in.
|
|
|
|
//returns -1 if ESC pressed, 0 if OK chosen
|
|
|
|
//CD may not have been inserted
|
|
|
|
int request_cd(void)
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
ubyte save_pal[256*3];
|
|
|
|
grs_canvas *save_canv,*tcanv;
|
|
|
|
int ret,was_faded=gr_palette_faded_out;
|
|
|
|
|
|
|
|
gr_palette_clear();
|
|
|
|
|
|
|
|
save_canv = grd_curcanv;
|
|
|
|
tcanv = gr_create_canvas(grd_curcanv->cv_w,grd_curcanv->cv_h);
|
|
|
|
|
|
|
|
gr_set_current_canvas(tcanv);
|
|
|
|
gr_ubitmap(0,0,&save_canv->cv_bitmap);
|
|
|
|
gr_set_current_canvas(save_canv);
|
|
|
|
|
|
|
|
gr_clear_canvas(BM_XRGB(0,0,0));
|
|
|
|
|
|
|
|
memcpy(save_pal,gr_palette,sizeof(save_pal));
|
|
|
|
|
|
|
|
memcpy(gr_palette,last_palette_for_color_fonts,sizeof(gr_palette));
|
|
|
|
|
|
|
|
try_again:;
|
|
|
|
|
|
|
|
ret = nm_messagebox( "CD ERROR", 1, "Ok", "Please insert your Descent II CD");
|
|
|
|
|
|
|
|
if (ret == -1) {
|
|
|
|
int ret2;
|
|
|
|
|
|
|
|
ret2 = nm_messagebox( "CD ERROR", 2, "Try Again", "Leave Game", "You must insert your\nDescent II CD to Continue");
|
|
|
|
|
|
|
|
if (ret2 == -1 || ret2 == 0)
|
|
|
|
goto try_again;
|
|
|
|
}
|
|
|
|
|
|
|
|
force_rb_register = 1; //disc has changed; force register new CD
|
|
|
|
|
|
|
|
gr_palette_clear();
|
|
|
|
|
|
|
|
memcpy(gr_palette,save_pal,sizeof(save_pal));
|
|
|
|
|
|
|
|
gr_ubitmap(0,0,&tcanv->cv_bitmap);
|
|
|
|
|
|
|
|
if (!was_faded)
|
|
|
|
gr_palette_load(gr_palette);
|
|
|
|
|
|
|
|
gr_free_canvas(tcanv);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
#else
|
|
|
|
con_printf(DEBUG_LEVEL, "STUB: movie: request_cd\n");
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-31 16:48:10 +00:00
|
|
|
void init_movie(char *filename, int libnum, int is_robots, int required)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
2003-10-31 16:48:10 +00:00
|
|
|
int high_res, try;
|
|
|
|
char *res = strchr(filename, '.') - 1; // 'h' == high resolution, 'l' == low
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
#ifndef RELEASE
|
2002-08-31 12:14:01 +00:00
|
|
|
if (FindArg("-nomovies")) {
|
2002-01-18 07:26:54 +00:00
|
|
|
movie_libs[libnum] = NULL;
|
|
|
|
return;
|
|
|
|
}
|
2002-07-22 02:20:05 +00:00
|
|
|
#endif
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
//for robots, load highres versions if highres menus set
|
|
|
|
if (is_robots)
|
|
|
|
high_res = MenuHiresAvailable;
|
|
|
|
else
|
|
|
|
high_res = MovieHires;
|
|
|
|
|
|
|
|
if (high_res)
|
2003-10-31 16:48:10 +00:00
|
|
|
*res = 'h';
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-10-31 16:48:10 +00:00
|
|
|
for (try = 0; (movie_libs[libnum] = init_movie_lib(filename)) == NULL; try++) {
|
2002-01-18 07:26:54 +00:00
|
|
|
char name2[100];
|
2002-08-26 06:50:45 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
strcpy(name2,CDROM_dir);
|
|
|
|
strcat(name2,filename);
|
|
|
|
movie_libs[libnum] = init_movie_lib(name2);
|
|
|
|
|
2003-10-31 16:48:10 +00:00
|
|
|
if (movie_libs[libnum] != NULL) {
|
2002-01-18 07:26:54 +00:00
|
|
|
movie_libs[libnum]->flags |= MLF_ON_CD;
|
2003-10-31 16:48:10 +00:00
|
|
|
break; // we found our movie on the CD
|
|
|
|
} else {
|
|
|
|
if (try == 0) { // first try
|
|
|
|
if (*res == 'h') { // try low res instead
|
|
|
|
*res = 'l';
|
2003-02-14 03:45:31 +00:00
|
|
|
high_res = 0;
|
2003-10-31 16:48:10 +00:00
|
|
|
} else if (*res == 'l') { // try high
|
|
|
|
*res = 'h';
|
2003-02-14 03:45:31 +00:00
|
|
|
high_res = 1;
|
2003-10-31 16:48:10 +00:00
|
|
|
} else {
|
|
|
|
if (required)
|
|
|
|
Warning("Cannot open movie file <%s>",filename);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else { // try == 1
|
|
|
|
if (required) {
|
|
|
|
*res = '*';
|
|
|
|
Warning("Cannot open any movie file <%s>", filename);
|
2002-08-27 04:14:18 +00:00
|
|
|
}
|
2003-10-31 16:48:10 +00:00
|
|
|
break;
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_robots && movie_libs[libnum]!=NULL)
|
|
|
|
robot_movies = high_res?2:1;
|
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//find and initialize the movie libraries
|
|
|
|
void init_movies()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int is_robots;
|
|
|
|
|
|
|
|
for (i=0;i<N_BUILTIN_MOVIE_LIBS;i++) {
|
|
|
|
|
|
|
|
if (!strnicmp(movielib_files[i],"robot",5))
|
|
|
|
is_robots = 1;
|
|
|
|
else
|
|
|
|
is_robots = 0;
|
|
|
|
|
|
|
|
init_movie(movielib_files[i],i,is_robots,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
movie_libs[EXTRA_ROBOT_LIB] = NULL;
|
|
|
|
|
|
|
|
atexit(close_movies);
|
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-08-27 04:14:18 +00:00
|
|
|
void init_extra_robot_movie(char *filename)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
2002-08-27 04:14:18 +00:00
|
|
|
close_movie(EXTRA_ROBOT_LIB);
|
|
|
|
init_movie(filename,EXTRA_ROBOT_LIB,1,0);
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *movie_handle;
|
|
|
|
int movie_start;
|
2003-02-18 07:05:14 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//looks through a movie library for a movie file
|
|
|
|
//returns filehandle, with fileposition at movie, or -1 if can't find
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *search_movie_lib(movielib *lib, char *filename, int must_have)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
|
|
|
int i;
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *filehandle;
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
if (lib == NULL)
|
2003-06-19 05:40:20 +00:00
|
|
|
return NULL;
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
for (i=0;i<lib->n_movies;i++)
|
|
|
|
if (!stricmp(filename,lib->movies[i].name)) { //found the movie in a library
|
|
|
|
int from_cd;
|
|
|
|
|
|
|
|
from_cd = (lib->flags & MLF_ON_CD);
|
|
|
|
|
|
|
|
if (from_cd)
|
|
|
|
songs_stop_redbook(); //ready to read from CD
|
|
|
|
|
|
|
|
do { //keep trying until we get the file handle
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
movie_handle = filehandle = cfopen(lib->name, "rb");
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
if (must_have && from_cd && filehandle == NULL)
|
|
|
|
{ //didn't get file!
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
if (request_cd() == -1) //ESC from requester
|
|
|
|
break; //bail from here. will get error later
|
|
|
|
}
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
} while (must_have && from_cd && filehandle == NULL);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
if (filehandle)
|
|
|
|
cfseek(filehandle, (movie_start = lib->movies[i].offset), SEEK_SET);
|
2002-01-18 07:26:54 +00:00
|
|
|
|
|
|
|
return filehandle;
|
|
|
|
}
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
return NULL;
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2002-01-18 07:26:54 +00:00
|
|
|
//returns file handle
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *open_movie_file(char *filename, int must_have)
|
2002-01-18 07:26:54 +00:00
|
|
|
{
|
2003-06-19 05:40:20 +00:00
|
|
|
CFILE *filehandle;
|
|
|
|
int i;
|
2002-01-18 07:26:54 +00:00
|
|
|
|
2002-07-22 02:20:05 +00:00
|
|
|
for (i=0;i<N_MOVIE_LIBS;i++) {
|
2003-06-19 05:40:20 +00:00
|
|
|
if ((filehandle = search_movie_lib(movie_libs[i], filename, must_have)) != NULL)
|
2002-01-18 07:26:54 +00:00
|
|
|
return filehandle;
|
|
|
|
}
|
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
return NULL; //couldn't find it
|
2002-01-18 07:26:54 +00:00
|
|
|
}
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-02-18 07:05:14 +00:00
|
|
|
//sets the file position to the start of this already-open file
|
2003-06-19 05:40:20 +00:00
|
|
|
int reset_movie_file(CFILE *handle)
|
2003-02-18 07:05:14 +00:00
|
|
|
{
|
|
|
|
Assert(handle == movie_handle);
|
2002-07-22 02:20:05 +00:00
|
|
|
|
2003-06-19 05:40:20 +00:00
|
|
|
cfseek(handle, movie_start, SEEK_SET);
|
2003-02-18 07:05:14 +00:00
|
|
|
|
|
|
|
return 0; //everything is cool
|
|
|
|
}
|