2007-06-28 10:47:08 -07:00
|
|
|
/*
|
|
|
|
* SeqDisp.c (Sequence Display)
|
|
|
|
*
|
|
|
|
* Functions for the display of the Escape Sequences
|
|
|
|
*
|
|
|
|
*/
|
2006-11-06 06:40:07 -08:00
|
|
|
#include <string.h>
|
|
|
|
#include <SDL/SDL_timer.h>
|
2006-06-16 12:10:23 -07:00
|
|
|
#include <physfs.h>
|
|
|
|
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/framework/frame.h"
|
|
|
|
#include "lib/widget/widget.h"
|
|
|
|
#include "lib/ivis_common/rendmode.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "seqdisp.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/sequence/sequence.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "loop.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/ivis_common/piedef.h"
|
|
|
|
#include "lib/ivis_common/piefunc.h"
|
|
|
|
#include "lib/ivis_common/piestate.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "hci.h"//for font
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/sound/audio.h"
|
|
|
|
#include "lib/sound/cdaudio.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "deliverance.h"
|
|
|
|
#include "warzoneconfig.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
// FIXME Direct iVis implementation include!
|
|
|
|
#include "lib/ivis_opengl/screen.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
#include "multiplay.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/gamelib/gtime.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "mission.h"
|
2006-05-27 09:37:17 -07:00
|
|
|
#include "lib/script/script.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
#include "scripttabs.h"
|
|
|
|
#include "design.h"
|
|
|
|
#include "wrappers.h"
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local Definitions
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
#define INCLUDE_AUDIO
|
|
|
|
#define RPL_WIDTH 640
|
|
|
|
#define RPL_HEIGHT 480
|
|
|
|
#define RPL_DEPTH 2 //bytes, 16bit
|
|
|
|
#define RPL_BITS_555 15 //15bit
|
|
|
|
#define RPL_MASK_555 0x7fff //15bit
|
|
|
|
#define RPL_FRAME_TIME frameDuration //milliseconds
|
|
|
|
#define STD_FRAME_TIME 40 //milliseconds
|
|
|
|
#define VIDEO_PLAYBACK_WIDTH 640
|
|
|
|
#define VIDEO_PLAYBACK_HEIGHT 480
|
|
|
|
#define VIDEO_PLAYBACK_DELAY 0
|
|
|
|
#define MAX_TEXT_OVERLAYS 32
|
|
|
|
#define MAX_SEQ_LIST 6
|
|
|
|
#define SUBTITLE_BOX_MIN 430
|
|
|
|
#define SUBTITLE_BOX_MAX 480
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char pText[MAX_STR_LENGTH];
|
|
|
|
SDWORD x;
|
|
|
|
SDWORD y;
|
|
|
|
SDWORD startFrame;
|
|
|
|
SDWORD endFrame;
|
|
|
|
BOOL bSubtitle;
|
2006-02-18 10:54:37 -08:00
|
|
|
} SEQTEXT;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char *pSeq; //name of the sequence to play
|
|
|
|
char *pAudio; //name of the wav to play
|
|
|
|
BOOL bSeqLoop; //loop this sequence
|
|
|
|
SDWORD currentText; //cuurent number of text messages for this seq
|
|
|
|
SEQTEXT aText[MAX_TEXT_OVERLAYS]; //text data to display for this sequence
|
2006-02-18 10:54:37 -08:00
|
|
|
} SEQLIST;
|
2007-06-28 10:47:08 -07:00
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local Variables
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
static BOOL bBackDropWasAlreadyUp;
|
|
|
|
|
|
|
|
BOOL bSeqInit = FALSE;
|
|
|
|
BOOL bSeqPlaying = FALSE;
|
|
|
|
BOOL bAudioPlaying = FALSE;
|
|
|
|
BOOL bHoldSeqForAudio = FALSE;
|
|
|
|
BOOL bSeq8Bit = TRUE;
|
|
|
|
BOOL bCDPath = FALSE;
|
|
|
|
BOOL bHardPath = FALSE;
|
|
|
|
BOOL bSeqSubtitles = TRUE;
|
|
|
|
char aCDPath[MAX_STR_LENGTH];
|
|
|
|
char aHardPath[MAX_STR_LENGTH];
|
|
|
|
char aVideoName[MAX_STR_LENGTH];
|
|
|
|
char aAudioName[MAX_STR_LENGTH];
|
|
|
|
char aTextName[MAX_STR_LENGTH];
|
|
|
|
char aSubtitleName[MAX_STR_LENGTH];
|
|
|
|
char* pVideoBuffer = NULL;
|
2006-02-18 10:54:37 -08:00
|
|
|
UWORD *p3DFXVideoBuffer = NULL;
|
2007-06-28 10:47:08 -07:00
|
|
|
char* pVideoPalette = NULL;
|
|
|
|
VIDEO_MODE videoMode;
|
|
|
|
PERF_MODE perfMode = VIDEO_PERF_FULLSCREEN;
|
|
|
|
static SDWORD frameSkip = 1;
|
|
|
|
SEQLIST aSeqList[MAX_SEQ_LIST];
|
|
|
|
static SDWORD currentSeq = -1;
|
|
|
|
static SDWORD currentPlaySeq = -1;
|
|
|
|
static SDWORD frameDuration = 40;
|
|
|
|
|
|
|
|
static BOOL g_bResumeInGame = FALSE;
|
|
|
|
|
|
|
|
static int videoFrameTime = 0;
|
|
|
|
static SDWORD frame = 0;
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* local ProtoTypes
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
void clearVideoBuffer(iSurface *surface);
|
|
|
|
void seq_SetVideoPath(void);
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
/*
|
|
|
|
* Source
|
|
|
|
*/
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/* Renders a video sequence specified by filename to a buffer*/
|
|
|
|
BOOL seq_RenderVideoToBuffer( iSurface *pSurface, char *sequenceName, int time, int seqCommand)
|
|
|
|
{
|
|
|
|
SDWORD frameLag;
|
|
|
|
int videoTime;
|
|
|
|
BOOL state = TRUE;
|
|
|
|
|
|
|
|
if (seqCommand == SEQUENCE_KILL)
|
|
|
|
{
|
|
|
|
//stop the movie
|
|
|
|
seq_ShutDown();
|
|
|
|
bSeqPlaying = FALSE;
|
|
|
|
// bSeqInit = FALSE;
|
|
|
|
//return seq_ReleaseVideoBuffers();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bSeqInit)
|
|
|
|
{
|
|
|
|
//this is done in HCI intInitialise() now
|
|
|
|
//if ((bSeqInit = seq_SetupVideoBuffers()) == FALSE)
|
|
|
|
// return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!bSeqPlaying)
|
|
|
|
{
|
|
|
|
//set a valid video path if there is one
|
|
|
|
if(!bCDPath && !bHardPath)
|
|
|
|
{
|
|
|
|
seq_SetVideoPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bHardPath)//use this first
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(sequenceName) + strlen(aHardPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aHardPath);
|
|
|
|
strcat(aVideoName,sequenceName);
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
// check it exists. If not then try CD.
|
2006-06-16 12:10:23 -07:00
|
|
|
if ( !PHYSFS_exists( aVideoName ) && bCDPath)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(sequenceName) + strlen(aCDPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aCDPath);
|
|
|
|
strcat(aVideoName,sequenceName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bCDPath)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(sequenceName) + strlen(aCDPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aCDPath);
|
|
|
|
strcat(aVideoName,sequenceName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE,"seq_StartFullScreenVideo: sequence path not found" );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
iV_SetFont(WFont);
|
|
|
|
iV_SetTextColour(-1);
|
|
|
|
|
|
|
|
|
2006-08-08 13:03:05 -07:00
|
|
|
videoMode = VIDEO_D3D_WINDOW;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//for new timing
|
|
|
|
frame = 0;
|
2006-08-27 12:09:35 -07:00
|
|
|
videoFrameTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-08-10 06:53:26 -07:00
|
|
|
if ((bSeqPlaying = seq_SetSequenceForBuffer(aVideoName, videoFrameTime, perfMode)) == FALSE)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE,"seq_RenderVideoToBuffer: unable to initialise sequence %s",aVideoName );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
bSeqPlaying = TRUE;
|
|
|
|
frameDuration = seq_GetFrameTimeInClicks();
|
|
|
|
//jps 18 feb 99 seq_RenderOneFrameToBuffer(pVideoBuffer, 1);//skip frame if behind
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame != VIDEO_FINISHED)
|
|
|
|
{
|
|
|
|
//new call with timing
|
|
|
|
//poll the sequence player while timing the video
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
while (videoTime < (videoFrameTime + RPL_FRAME_TIME))
|
|
|
|
{
|
|
|
|
seq_RefreshVideoBuffers();
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
frameLag = videoTime - videoFrameTime;
|
|
|
|
frameLag /= RPL_FRAME_TIME;// if were running slow frame lag will be greater than 1
|
2006-02-18 10:54:37 -08:00
|
|
|
videoFrameTime += frameLag * RPL_FRAME_TIME;//frame Lag should be 1 (most of the time)
|
2007-06-28 10:47:08 -07:00
|
|
|
//call sequence player to decode a frame
|
|
|
|
frame = seq_RenderOneFrameToBuffer(pVideoBuffer, frameLag, 2, 0);//skip frame if behind
|
|
|
|
//old call
|
|
|
|
// frame = seq_RenderOneFrameToBuffer(pVideoBuffer, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame == VIDEO_FINISHED)
|
|
|
|
{
|
|
|
|
if (seqCommand == SEQUENCE_LOOP)
|
|
|
|
{
|
|
|
|
bSeqPlaying = FALSE;
|
|
|
|
state = TRUE;
|
|
|
|
}
|
|
|
|
if (seqCommand == SEQUENCE_HOLD)
|
|
|
|
{
|
|
|
|
//wait for call to stop video
|
|
|
|
state = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
state = FALSE;
|
|
|
|
seq_ShutDown();
|
|
|
|
bSeqPlaying = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (frame < 0) //an ERROR
|
|
|
|
{
|
2006-06-16 12:10:23 -07:00
|
|
|
debug( LOG_WZ, "VIDEO FRAME ERROR %d\n", frame );
|
2007-06-28 10:47:08 -07:00
|
|
|
state = FALSE;
|
|
|
|
seq_ShutDown();
|
|
|
|
bSeqPlaying = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_BlitBufferToScreen(char* screen, SDWORD screenStride, SDWORD xOffset, SDWORD yOffset)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
char c8, *d8;
|
|
|
|
UWORD c16, *p16;
|
|
|
|
SDWORD width, height;
|
|
|
|
seq_GetFrameSize(&width, &height);
|
|
|
|
|
|
|
|
if (videoMode == VIDEO_SOFT_WINDOW)
|
|
|
|
{
|
|
|
|
d8 = screen + xOffset + yOffset * screenStride;
|
|
|
|
p16 = (UWORD*)pVideoBuffer;
|
|
|
|
|
|
|
|
for (j = 0; j < height; j++)
|
|
|
|
{
|
|
|
|
for (i = 0; i < width; i++)
|
|
|
|
{
|
|
|
|
c16 = p16[i];
|
|
|
|
c16 &= RPL_MASK_555;
|
|
|
|
c8 = pVideoPalette[c16];
|
|
|
|
d8[i] = c8;
|
|
|
|
}
|
|
|
|
d8 += screenStride;
|
|
|
|
p16 += width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pie_DownLoadBufferToScreen(pVideoBuffer, xOffset, yOffset,width,height,(2*width));
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void clearVideoBuffer(iSurface *surface)
|
|
|
|
{
|
|
|
|
UDWORD i;
|
|
|
|
UDWORD *toClear;
|
|
|
|
|
|
|
|
toClear = (UDWORD *)surface->buffer;
|
|
|
|
for (i=0; i<(UDWORD)(surface->size/4); i++)
|
|
|
|
{
|
|
|
|
*toClear++ = (UDWORD)0xFCFCFCFC;
|
|
|
|
}
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL seq_ReleaseVideoBuffers(void)
|
|
|
|
{
|
|
|
|
FREE(pVideoBuffer);
|
|
|
|
FREE(pVideoPalette);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
BOOL seq_SetupVideoBuffers(void)
|
|
|
|
{
|
|
|
|
SDWORD c,mallocSize;
|
|
|
|
UBYTE r,g,b;
|
|
|
|
//assume 320 * 240 * 16bit playback surface
|
|
|
|
mallocSize = (RPL_WIDTH*RPL_HEIGHT*RPL_DEPTH);
|
|
|
|
if ((pVideoBuffer = MALLOC(mallocSize)) == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
mallocSize = 1<<(RPL_BITS_555);//palette only used in 555mode
|
|
|
|
if ((pVideoPalette = MALLOC(mallocSize)) == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Assume 555 RGB buffer for 8 bit rendering
|
|
|
|
c = 0;
|
|
|
|
for(r = 0 ; r < 32 ; r++)
|
|
|
|
{
|
|
|
|
LOADBARCALLBACK(); // loadingScreenCallback();
|
|
|
|
|
|
|
|
for(g = 0 ; g < 32 ; g++)
|
|
|
|
{
|
|
|
|
for(b = 0 ; b < 32 ; b++)
|
|
|
|
{
|
|
|
|
pVideoPalette[(SDWORD)c] = (char)pal_GetNearestColour((uint8)(r<<3),(uint8)(g<<3),(uint8)(b<<3));
|
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void seq_SetVideoPath(void)
|
|
|
|
{
|
|
|
|
// now set up the hard disc path /
|
|
|
|
|
|
|
|
if (!bHardPath)
|
|
|
|
{
|
2006-10-07 07:13:47 -07:00
|
|
|
strcpy(aHardPath, "sequences/");
|
2007-06-28 10:47:08 -07:00
|
|
|
/*#ifdef WIN32
|
2006-10-07 07:13:47 -07:00
|
|
|
fileHandle = FindFirstFile("sequences/*.rpl",&findData);
|
2007-06-28 10:47:08 -07:00
|
|
|
if (fileHandle == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
2006-02-18 10:54:37 -08:00
|
|
|
// bHardPath = FALSE; //If it fails, then why say true? Cause we *ALWAYS* need the
|
|
|
|
bHardPath=TRUE; //videos enabled. Yes, we are playing novideo.rpl, but for
|
|
|
|
return; //windows, if we don't have that directory, then what?
|
|
|
|
} //then we run into a game stopping bug!
|
2007-06-28 10:47:08 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
bHardPath = TRUE;
|
|
|
|
FindClose(fileHandle);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
*/
|
2006-02-18 10:54:37 -08:00
|
|
|
bHardPath=TRUE; //yes, always true, as it should be on windows ALSO.
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
//#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOOL SeqEndCallBack( AUDIO_SAMPLE *psSample )
|
|
|
|
{
|
|
|
|
// psSample;
|
|
|
|
bAudioPlaying = FALSE;
|
|
|
|
debug(LOG_NEVER, "************* briefing ended **************");
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//full screenvideo functions
|
2006-09-19 17:49:20 -07:00
|
|
|
static BOOL seq_StartFullScreenVideo(char* videoName, char* audioName)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2006-08-29 12:57:34 -07:00
|
|
|
bHoldSeqForAudio = FALSE;
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
frameSkip = 1;
|
|
|
|
switch(war_GetSeqMode())
|
|
|
|
{
|
|
|
|
case SEQ_SMALL:
|
|
|
|
perfMode = VIDEO_PERF_WINDOW;
|
|
|
|
break;
|
|
|
|
case SEQ_SKIP:
|
|
|
|
frameSkip = 2;
|
|
|
|
perfMode = VIDEO_PERF_SKIP_FRAMES;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
case SEQ_FULL:
|
|
|
|
perfMode = VIDEO_PERF_FULLSCREEN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//set a valid video path if there is one
|
|
|
|
if(!bCDPath && !bHardPath)
|
|
|
|
{
|
|
|
|
seq_SetVideoPath();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bHardPath)//use this first
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(videoName) + strlen(aHardPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aHardPath);
|
|
|
|
strcat(aVideoName,videoName);
|
|
|
|
|
|
|
|
// check it exists. If not then try CD.
|
2006-06-16 12:10:23 -07:00
|
|
|
if ( !PHYSFS_exists( aVideoName ) && bCDPath)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(videoName) + strlen(aCDPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aCDPath);
|
|
|
|
strcat(aVideoName,videoName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (bCDPath)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( (strlen(videoName) + strlen(aCDPath))<MAX_STR_LENGTH,"sequence path+name greater than max string" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aVideoName,aCDPath);
|
|
|
|
strcat(aVideoName,videoName);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE,"seq_StartFullScreenVideo: sequence path not found" );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//set audio path
|
|
|
|
if (audioName != NULL)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( strlen(audioName)<244,"sequence path+name greater than max string" );
|
2006-10-07 07:13:47 -07:00
|
|
|
strcpy(aAudioName,"sequenceaudio/");
|
2007-06-28 10:47:08 -07:00
|
|
|
strcat(aAudioName,audioName);
|
|
|
|
}
|
|
|
|
|
|
|
|
//start video mode
|
|
|
|
if (loop_GetVideoMode() == 0)
|
|
|
|
{
|
|
|
|
cdAudio_Pause();
|
|
|
|
loop_SetVideoPlaybackMode();
|
|
|
|
iV_SetFont(WFont);
|
|
|
|
iV_SetTextColour(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audioName != NULL)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( strlen(audioName)<244,"sequence path+name greater than max string" );
|
2006-10-07 07:13:47 -07:00
|
|
|
strcpy(aAudioName,"sequenceaudio/");
|
2007-06-28 10:47:08 -07:00
|
|
|
strcat(aAudioName,audioName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//for new timing
|
|
|
|
frame = 0;
|
2006-08-27 12:09:35 -07:00
|
|
|
videoFrameTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-08-10 06:53:26 -07:00
|
|
|
if (!seq_SetSequence(aVideoName, videoFrameTime + VIDEO_PLAYBACK_DELAY, pVideoBuffer, perfMode))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
seq_StopFullScreenVideo();
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE,"seq_StartFullScreenVideo: unable to initialise sequence %s",aVideoName );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (perfMode != VIDEO_PERF_SKIP_FRAMES)//JPS fix for video problems with some sound cards 9 may 99
|
|
|
|
{
|
|
|
|
frameDuration = seq_GetFrameTimeInClicks();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frameDuration = (seq_GetFrameTimeInClicks() * 112) / 100;//JPS fix for video problems with some sound cards 9 may 99
|
|
|
|
}
|
|
|
|
|
|
|
|
if (audioName == NULL)
|
|
|
|
{
|
|
|
|
bAudioPlaying = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bAudioPlaying = audio_PlayStream( aAudioName, AUDIO_VOL_MAX, SeqEndCallBack );
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( bAudioPlaying == TRUE,"seq_StartFullScreenVideo: unable to initialise sound %s",aAudioName );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_UpdateFullScreenVideo(CLEAR_MODE *pbClear)
|
|
|
|
{
|
|
|
|
SDWORD i, x, y, w, h;
|
|
|
|
SDWORD frame, frameLag, realFrame;
|
|
|
|
SDWORD subMin, subMax;
|
|
|
|
int videoTime;
|
|
|
|
static int videoFrameTime = 0, textFrame = 0;
|
|
|
|
BOOL bMoreThanOneSequenceLine = FALSE;
|
|
|
|
|
|
|
|
if (seq_GetCurrentFrame() == 0)
|
|
|
|
{
|
|
|
|
//for new timing
|
|
|
|
frame = 0;
|
2006-08-27 12:09:35 -07:00
|
|
|
videoFrameTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
textFrame = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_GetFrameSize(&w,&h);
|
|
|
|
|
|
|
|
x = (DISP_WIDTH - w)/2;
|
|
|
|
y = (DISP_HEIGHT - h)/2;
|
|
|
|
|
|
|
|
subMin = SUBTITLE_BOX_MAX + D_H;
|
|
|
|
subMax = SUBTITLE_BOX_MIN + D_H;
|
|
|
|
|
|
|
|
//get any text lines over bottom of the video
|
2006-02-18 10:54:37 -08:00
|
|
|
realFrame = textFrame + 1;
|
2007-06-28 10:47:08 -07:00
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].pText[0] != 0)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].bSubtitle == TRUE)
|
|
|
|
{
|
|
|
|
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame))
|
|
|
|
{
|
|
|
|
if (subMin > aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].y > SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (subMax < aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
subMax = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (aSeqList[currentPlaySeq].bSeqLoop)//if its a looped video always draw the text
|
|
|
|
{
|
|
|
|
if (subMin >= aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].y > SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (subMax < aSeqList[currentPlaySeq].aText[i].y)
|
|
|
|
{
|
|
|
|
subMax = aSeqList[currentPlaySeq].aText[i].y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].endFrame) && (realFrame < (aSeqList[currentPlaySeq].aText[i].endFrame + frameSkip)))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
if (pbClear != NULL)
|
|
|
|
{
|
|
|
|
if (perfMode != VIDEO_PERF_FULLSCREEN)
|
|
|
|
{
|
|
|
|
*pbClear = CLEAR_BLACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subMin -= D_H;//adjust video window here because text is already ofset for big screens
|
|
|
|
subMax -= D_H;
|
|
|
|
|
|
|
|
if (subMin < SUBTITLE_BOX_MIN)
|
|
|
|
{
|
|
|
|
subMin = SUBTITLE_BOX_MIN;
|
|
|
|
}
|
|
|
|
if (subMax > SUBTITLE_BOX_MAX)
|
|
|
|
{
|
|
|
|
subMax = SUBTITLE_BOX_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (subMax > subMin)
|
|
|
|
{
|
|
|
|
bMoreThanOneSequenceLine = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
if (bHoldSeqForAudio == FALSE)
|
|
|
|
{
|
|
|
|
if (perfMode != VIDEO_PERF_SKIP_FRAMES)
|
|
|
|
{
|
|
|
|
//version 1.00 release code
|
|
|
|
//poll the sequence player while timing the video
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
while (videoTime < (videoFrameTime + (RPL_FRAME_TIME * frameSkip)))
|
|
|
|
{
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
seq_RefreshVideoBuffers();
|
|
|
|
}
|
|
|
|
frameLag = videoTime - videoFrameTime;
|
|
|
|
frameLag /= RPL_FRAME_TIME;// if were running slow frame lag will be greater than 1
|
2006-02-18 10:54:37 -08:00
|
|
|
videoFrameTime += frameLag * RPL_FRAME_TIME;//frame Lag should be 1 (most of the time)
|
2007-06-28 10:47:08 -07:00
|
|
|
//call sequence player to decode a frame
|
2006-08-10 06:53:26 -07:00
|
|
|
frame = seq_RenderOneFrame(frameLag, subMin, subMax);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//new version with timeing removed
|
|
|
|
//poll the sequence player while timing the video
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
while (videoTime < (videoFrameTime + (RPL_FRAME_TIME * frameSkip)))
|
|
|
|
{
|
2006-08-27 12:09:35 -07:00
|
|
|
videoTime = SDL_GetTicks();
|
2007-06-28 10:47:08 -07:00
|
|
|
seq_RefreshVideoBuffers();
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
videoFrameTime += frameSkip * RPL_FRAME_TIME;//frame Lag should be 1 (most of the time)
|
2007-06-28 10:47:08 -07:00
|
|
|
//call sequence player to decode a frame
|
2006-08-10 06:53:26 -07:00
|
|
|
frame = seq_RenderOneFrame(frameSkip, subMin, subMax);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//call sequence player to download last frame
|
2006-08-10 06:53:26 -07:00
|
|
|
frame = seq_RenderOneFrame(0, 2, 0);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
//print any text over the video
|
2006-02-18 10:54:37 -08:00
|
|
|
realFrame = textFrame + 1;
|
2007-06-28 10:47:08 -07:00
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].aText[i].pText[0] != 0)
|
|
|
|
{
|
|
|
|
if ((realFrame >= aSeqList[currentPlaySeq].aText[i].startFrame) && (realFrame <= aSeqList[currentPlaySeq].aText[i].endFrame))
|
|
|
|
{
|
|
|
|
if (bMoreThanOneSequenceLine)
|
|
|
|
{
|
|
|
|
aSeqList[currentPlaySeq].aText[i].x = 20 + D_W;
|
|
|
|
}
|
2006-08-10 06:53:26 -07:00
|
|
|
pie_DrawTextToSurface(&(aSeqList[currentPlaySeq].aText[i].pText[0]),
|
2007-06-28 10:47:08 -07:00
|
|
|
aSeqList[currentPlaySeq].aText[i].x, aSeqList[currentPlaySeq].aText[i].y);
|
|
|
|
}
|
|
|
|
else if (aSeqList[currentPlaySeq].bSeqLoop)//if its a looped video always draw the text
|
|
|
|
{
|
|
|
|
if (bMoreThanOneSequenceLine)
|
|
|
|
{
|
|
|
|
aSeqList[currentPlaySeq].aText[i].x = 20 + D_W;
|
|
|
|
}
|
2006-08-10 06:53:26 -07:00
|
|
|
pie_DrawTextToSurface(&(aSeqList[currentPlaySeq].aText[i].pText[0]),
|
2007-06-28 10:47:08 -07:00
|
|
|
aSeqList[currentPlaySeq].aText[i].x, aSeqList[currentPlaySeq].aText[i].y);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
textFrame = frame * RPL_FRAME_TIME/STD_FRAME_TIME;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if ((frame == VIDEO_FINISHED) || (bHoldSeqForAudio))
|
|
|
|
{
|
|
|
|
#ifndef SEQ_LOOP
|
|
|
|
if (bAudioPlaying)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
if (aSeqList[currentPlaySeq].bSeqLoop)
|
|
|
|
{
|
|
|
|
seq_ClearMovie();
|
2006-08-27 12:09:35 -07:00
|
|
|
if (!seq_SetSequence(aVideoName, SDL_GetTicks() + VIDEO_PLAYBACK_DELAY, pVideoBuffer, perfMode))
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
bHoldSeqForAudio = TRUE;
|
|
|
|
}
|
|
|
|
frameDuration = seq_GetFrameTimeInClicks();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bHoldSeqForAudio = TRUE;
|
|
|
|
}
|
|
|
|
return TRUE;//should hold the video
|
|
|
|
}
|
|
|
|
#ifndef SEQ_LOOP
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;//should terminate the video
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else if (frame < 0) //an ERROR
|
|
|
|
{
|
2006-08-22 07:28:49 -07:00
|
|
|
debug( LOG_NEVER, "VIDEO FRAME ERROR %d\n", frame );
|
2007-06-28 10:47:08 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_StopFullScreenVideo(void)
|
|
|
|
{
|
|
|
|
if (!seq_AnySeqLeft())
|
|
|
|
{
|
|
|
|
loop_ClearVideoPlaybackMode();
|
|
|
|
}
|
|
|
|
|
|
|
|
seq_ShutDown();
|
|
|
|
|
|
|
|
if (!seq_AnySeqLeft())
|
|
|
|
{
|
|
|
|
if ( g_bResumeInGame == TRUE )
|
|
|
|
{
|
|
|
|
resetDesignPauseState();
|
|
|
|
intAddReticule();
|
|
|
|
g_bResumeInGame = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_GetVideoSize(SDWORD* pWidth, SDWORD* pHeight)
|
|
|
|
{
|
|
|
|
return seq_GetFrameSize(pWidth, pHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define BUFFER_WIDTH 600
|
|
|
|
#define FOLLOW_ON_JUSTIFICATION 160
|
|
|
|
#define MIN_JUSTIFICATION 40
|
|
|
|
|
|
|
|
// add a string at x,y or add string below last line if x and y are 0
|
2006-05-08 08:10:45 -07:00
|
|
|
BOOL seq_AddTextForVideo(char* pText, SDWORD xOffset, SDWORD yOffset, SDWORD startFrame, SDWORD endFrame, SDWORD bJustify, UDWORD PSXSeqNumber)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
SDWORD sourceLength, currentLength;
|
|
|
|
char* currentText;
|
|
|
|
SDWORD justification;
|
|
|
|
static SDWORD lastX;
|
|
|
|
|
|
|
|
iV_SetFont(WFont);
|
|
|
|
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( aSeqList[currentSeq].currentText < MAX_TEXT_OVERLAYS,
|
|
|
|
"seq_AddTextForVideo: too many text lines" );
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
sourceLength = strlen(pText);
|
2007-06-28 10:47:08 -07:00
|
|
|
currentLength = sourceLength;
|
|
|
|
currentText = &(aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].pText[0]);
|
|
|
|
|
|
|
|
//if the string is bigger than the buffer get the last end of the last fullword in the buffer
|
|
|
|
if (currentLength >= MAX_STR_LENGTH)
|
|
|
|
{
|
|
|
|
currentLength = MAX_STR_LENGTH - 1;
|
|
|
|
//get end of the last word
|
|
|
|
while((pText[currentLength] != ' ') && (currentLength > 0))
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
}
|
|
|
|
currentLength--;
|
|
|
|
}
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
memcpy(currentText,pText,currentLength);
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
//check the string is shortenough to print
|
|
|
|
//if not take a word of the end and try again
|
|
|
|
while(iV_GetTextWidth(currentText) > BUFFER_WIDTH)
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
while((pText[currentLength] != ' ') && (currentLength > 0))
|
|
|
|
{
|
|
|
|
currentLength--;
|
|
|
|
}
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
|
|
|
}
|
|
|
|
currentText[currentLength] = 0;//terminate the string what ever
|
|
|
|
|
|
|
|
//check if x and y are 0 and put text on next line
|
|
|
|
if (((xOffset == 0) && (yOffset == 0)) && (currentLength > 0))
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x = lastX;
|
|
|
|
// aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText-1].x;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].y = aSeqList[currentSeq].
|
|
|
|
aText[aSeqList[currentSeq].currentText-1].y + iV_GetTextLineSize();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x = xOffset + D_W;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].y = yOffset + D_H;
|
|
|
|
}
|
|
|
|
lastX = aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x;
|
|
|
|
|
|
|
|
if ((bJustify) && (currentLength == sourceLength))
|
|
|
|
{
|
|
|
|
//justify this text
|
|
|
|
justification = BUFFER_WIDTH - iV_GetTextWidth(currentText);
|
|
|
|
if ((bJustify == SEQ_TEXT_JUSTIFY) && (justification > MIN_JUSTIFICATION))
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].x += (justification/2);
|
|
|
|
}
|
|
|
|
else if ((bJustify == SEQ_TEXT_FOLLOW_ON) && (justification > FOLLOW_ON_JUSTIFICATION))
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-02-18 10:54:37 -08:00
|
|
|
//set start and finish times for the objects
|
2007-06-28 10:47:08 -07:00
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].startFrame = startFrame;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].endFrame = endFrame;
|
|
|
|
aSeqList[currentSeq].aText[aSeqList[currentSeq].currentText].bSubtitle = bJustify;
|
|
|
|
|
|
|
|
aSeqList[currentSeq].currentText++;
|
|
|
|
if (aSeqList[currentSeq].currentText >= MAX_TEXT_OVERLAYS)
|
|
|
|
{
|
|
|
|
aSeqList[currentSeq].currentText = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//check text is okay on the screen
|
|
|
|
if (currentLength < sourceLength)
|
|
|
|
{
|
|
|
|
//RECURSE x= 0 y = 0 for nextLine
|
|
|
|
if (bJustify == SEQ_TEXT_JUSTIFY)
|
|
|
|
{
|
|
|
|
bJustify = SEQ_TEXT_POSITION;
|
|
|
|
}
|
|
|
|
seq_AddTextForVideo(&pText[currentLength + 1], 0, 0, startFrame, endFrame, bJustify,0);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_ClearTextForVideo(void)
|
|
|
|
{
|
|
|
|
SDWORD i, j;
|
|
|
|
|
|
|
|
for (j=0; j < MAX_SEQ_LIST; j++)
|
|
|
|
{
|
|
|
|
for(i=0;i<MAX_TEXT_OVERLAYS;i++)
|
|
|
|
{
|
|
|
|
aSeqList[j].aText[i].pText[0] = 0;
|
|
|
|
aSeqList[j].aText[i].x = 0;
|
|
|
|
aSeqList[j].aText[i].y = 0;
|
|
|
|
aSeqList[j].aText[i].startFrame = 0;
|
|
|
|
aSeqList[j].aText[i].endFrame = 0;
|
|
|
|
aSeqList[j].aText[i].bSubtitle = 0;
|
|
|
|
}
|
|
|
|
aSeqList[j].currentText = 0;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2006-11-03 13:35:50 -08:00
|
|
|
static BOOL seq_AddTextFromFile(char *pTextName, BOOL bJustify)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2006-08-12 09:52:37 -07:00
|
|
|
char *pTextBuffer, *pCurrentLine, *pText;
|
2007-06-28 10:47:08 -07:00
|
|
|
UDWORD fileSize;
|
|
|
|
// HANDLE fileHandle;
|
|
|
|
// WIN32_FIND_DATA findData;
|
|
|
|
// BOOL endOfFile = FALSE;
|
|
|
|
SDWORD xOffset, yOffset, startFrame, endFrame;
|
2006-09-24 12:11:34 -07:00
|
|
|
const char *seps = "\n";
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2006-10-07 07:13:47 -07:00
|
|
|
strcpy(aTextName,"sequenceaudio/");
|
2007-06-28 10:47:08 -07:00
|
|
|
strcat(aTextName,pTextName);
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/*
|
|
|
|
fileHandle = FindFirstFile(aTextName,&findData);
|
|
|
|
if (fileHandle == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
FindClose(fileHandle);
|
2006-02-18 10:54:37 -08:00
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
if (loadFileToBufferNoError(aTextName, DisplayBuffer, displayBufferSize, &fileSize) == FALSE) //Did I mention this is lame? -Q
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pTextBuffer = DisplayBuffer;
|
|
|
|
pCurrentLine = strtok(pTextBuffer,seps);
|
|
|
|
while(pCurrentLine != NULL)
|
|
|
|
{
|
|
|
|
if (*pCurrentLine != '/')
|
|
|
|
{
|
|
|
|
if (sscanf(pCurrentLine,"%d %d %d %d", &xOffset, &yOffset, &startFrame, &endFrame) == 4)
|
|
|
|
{
|
|
|
|
//get the text
|
|
|
|
pText = strrchr(pCurrentLine,'"');
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" );
|
2007-06-28 10:47:08 -07:00
|
|
|
if (pText != NULL)
|
|
|
|
{
|
|
|
|
*pText = (UBYTE)0;
|
|
|
|
}
|
|
|
|
pText = strchr(pCurrentLine,'"');
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( pText != NULL,"seq_AddTextFromFile error parsing text file" );
|
2007-06-28 10:47:08 -07:00
|
|
|
if (pText != NULL)
|
|
|
|
{
|
|
|
|
seq_AddTextForVideo(&pText[1], xOffset, yOffset, startFrame, endFrame, bJustify,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//get next line
|
|
|
|
pCurrentLine = strtok(NULL,seps);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//clear the sequence list
|
|
|
|
void seq_ClearSeqList(void)
|
|
|
|
{
|
|
|
|
SDWORD i;
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
seq_ClearTextForVideo();
|
|
|
|
for(i=0;i<MAX_SEQ_LIST;i++)
|
|
|
|
{
|
|
|
|
aSeqList[i].pSeq = NULL;
|
|
|
|
}
|
|
|
|
currentSeq = -1;
|
|
|
|
currentPlaySeq = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//add a sequence to the list to be played
|
2006-11-03 13:35:50 -08:00
|
|
|
void seq_AddSeqToList(char *pSeqName, char *pAudioName, char *pTextName, BOOL bLoop, UDWORD PSXSeqNumber)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
SDWORD strLen;
|
|
|
|
currentSeq++;
|
2006-02-18 10:54:37 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
if ((currentSeq) >= MAX_SEQ_LIST)
|
|
|
|
{
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( FALSE, "seq_AddSeqToList: too many sequences" );
|
2007-06-28 10:47:08 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifdef SEQ_LOOP
|
|
|
|
bLoop = TRUE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//OK so add it to the list
|
|
|
|
aSeqList[currentSeq].pSeq = pSeqName;
|
|
|
|
aSeqList[currentSeq].pAudio = pAudioName;
|
|
|
|
aSeqList[currentSeq].bSeqLoop = bLoop;
|
2006-02-18 10:54:37 -08:00
|
|
|
if (pTextName != NULL)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
seq_AddTextFromFile(pTextName, FALSE);//SEQ_TEXT_POSITION);//ordinary text not justified
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bSeqSubtitles)
|
|
|
|
{
|
|
|
|
//check for a subtitle file
|
|
|
|
strLen = strlen(pSeqName);
|
2006-08-23 05:58:48 -07:00
|
|
|
ASSERT( strLen < MAX_STR_LENGTH,"seq_AddSeqToList: sequence name error" );
|
2007-06-28 10:47:08 -07:00
|
|
|
strcpy(aSubtitleName,pSeqName);
|
|
|
|
aSubtitleName[strLen - 4] = 0;
|
|
|
|
strcat(aSubtitleName,".txt");
|
|
|
|
seq_AddTextFromFile(aSubtitleName, TRUE);//SEQ_TEXT_JUSTIFY);//subtitles centre justified
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*checks to see if there are any sequences left in the list to play*/
|
|
|
|
BOOL seq_AnySeqLeft(void)
|
|
|
|
{
|
|
|
|
UBYTE nextSeq;
|
|
|
|
|
|
|
|
nextSeq = (UBYTE)(currentPlaySeq+1);
|
|
|
|
|
|
|
|
//check haven't reached end
|
|
|
|
if (nextSeq > MAX_SEQ_LIST)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else if (aSeqList[nextSeq].pSeq)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 17:49:20 -07:00
|
|
|
static void seqDispCDOK( void )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
BOOL bPlayedOK;
|
|
|
|
|
|
|
|
if ( bBackDropWasAlreadyUp == FALSE )
|
|
|
|
{
|
|
|
|
screen_StopBackDrop();
|
|
|
|
}
|
|
|
|
|
|
|
|
currentPlaySeq++;
|
|
|
|
if (currentPlaySeq >= MAX_SEQ_LIST)
|
|
|
|
{
|
|
|
|
bPlayedOK = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-09-03 04:22:51 -07:00
|
|
|
bPlayedOK = seq_StartFullScreenVideo( aSeqList[currentPlaySeq].pSeq, aSeqList[currentPlaySeq].pAudio );
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bPlayedOK == FALSE )
|
|
|
|
{
|
2006-09-03 04:22:51 -07:00
|
|
|
//don't do the callback if we're playing the win/lose video
|
|
|
|
if (!getScriptWinLoseVideo())
|
|
|
|
{
|
|
|
|
debug(LOG_SCRIPT, "*** Called video quit trigger!");
|
|
|
|
eventFireCallbackTrigger((TRIGGER_TYPE)CALL_VIDEO_QUIT);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
displayGameOver(getScriptWinLoseVideo() == PLAY_WIN);
|
|
|
|
}
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-19 17:49:20 -07:00
|
|
|
static void seqDispCDCancel( void )
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*returns the next sequence in the list to play*/
|
|
|
|
void seq_StartNextFullScreenVideo(void)
|
|
|
|
{
|
|
|
|
seqDispCDOK();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void seq_SetSubtitles(BOOL bNewState)
|
|
|
|
{
|
|
|
|
bSeqSubtitles = bNewState;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL seq_GetSubtitles(void)
|
|
|
|
{
|
|
|
|
return bSeqSubtitles;
|
|
|
|
}
|