2004-08-23 00:15:46 +00:00
|
|
|
#include "quakedef.h"
|
2005-02-28 07:16:19 +00:00
|
|
|
#ifndef NOMEDIA
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
qbyte *data;
|
|
|
|
int count;
|
|
|
|
} cblock_t;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
typedef struct cinematics_s
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
qboolean restart_sound;
|
|
|
|
int s_rate;
|
|
|
|
int s_width;
|
|
|
|
int s_channels;
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
qbyte *pic;
|
|
|
|
qbyte *pic_pending;
|
|
|
|
|
|
|
|
// order 1 huffman stuff
|
|
|
|
int *hnodes1; // [256][256][2];
|
|
|
|
int numhnodes1[256];
|
|
|
|
|
|
|
|
int h_used[512];
|
|
|
|
int h_count[512];
|
|
|
|
|
|
|
|
|
|
|
|
int cinematictime;
|
|
|
|
qboolean cinematicpalette_active;
|
|
|
|
qbyte cinematicpalette[768];
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *cinematic_file;
|
2004-08-23 00:15:46 +00:00
|
|
|
int cinematicframe;
|
|
|
|
} cinematics_t;
|
|
|
|
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
void CIN_StopCinematic (cinematics_t *cin)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->cinematictime = 0; // done
|
|
|
|
if (cin->pic)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
Z_Free (cin->pic);
|
|
|
|
cin->pic = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->pic_pending)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
Z_Free (cin->pic_pending);
|
|
|
|
cin->pic_pending = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->cinematic_file)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_CLOSE (cin->cinematic_file);
|
|
|
|
cin->cinematic_file = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->hnodes1)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
Z_Free (cin->hnodes1);
|
|
|
|
cin->hnodes1 = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
Z_Free(cin);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==========================================================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SmallestNode1
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
static int SmallestNode1 (cinematics_t *cin, int numhnodes)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int best, bestnode;
|
|
|
|
|
|
|
|
best = 99999999;
|
|
|
|
bestnode = -1;
|
|
|
|
for (i=0 ; i<numhnodes ; i++)
|
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->h_used[i])
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!cin->h_count[i])
|
2004-08-23 00:15:46 +00:00
|
|
|
continue;
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->h_count[i] < best)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
best = cin->h_count[i];
|
2004-08-23 00:15:46 +00:00
|
|
|
bestnode = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bestnode == -1)
|
|
|
|
return -1;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->h_used[bestnode] = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
return bestnode;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Huff1TableInit
|
|
|
|
|
|
|
|
Reads the 64k counts table and initializes the node trees
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
static void Huff1TableInit (cinematics_t *cin)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int prev;
|
|
|
|
int j;
|
|
|
|
int *node, *nodebase;
|
|
|
|
qbyte counts[256];
|
|
|
|
int numhnodes;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->hnodes1 = Z_Malloc (256*256*2*4);
|
|
|
|
memset (cin->hnodes1, 0, 256*256*2*4);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
for (prev=0 ; prev<256 ; prev++)
|
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
memset (cin->h_count,0,sizeof(cin->h_count));
|
|
|
|
memset (cin->h_used,0,sizeof(cin->h_used));
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// read a row of counts
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_READ (cin->cinematic_file, counts, sizeof(counts));
|
2004-08-23 00:15:46 +00:00
|
|
|
for (j=0 ; j<256 ; j++)
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->h_count[j] = counts[j];
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// build the nodes
|
|
|
|
numhnodes = 256;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodebase = cin->hnodes1 + prev*256*2;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
while (numhnodes != 511)
|
|
|
|
{
|
|
|
|
node = nodebase + (numhnodes-256)*2;
|
|
|
|
|
|
|
|
// pick two lowest counts
|
2010-07-11 02:22:39 +00:00
|
|
|
node[0] = SmallestNode1 (cin, numhnodes);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (node[0] == -1)
|
|
|
|
break; // no more
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
node[1] = SmallestNode1 (cin, numhnodes);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (node[1] == -1)
|
|
|
|
break;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->h_count[numhnodes] = cin->h_count[node[0]] + cin->h_count[node[1]];
|
2004-08-23 00:15:46 +00:00
|
|
|
numhnodes++;
|
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->numhnodes1[prev] = numhnodes-1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Huff1Decompress
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
static cblock_t Huff1Decompress (cinematics_t *cin, cblock_t in)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
qbyte *input;
|
|
|
|
qbyte *out_p;
|
|
|
|
int nodenum;
|
|
|
|
int count;
|
|
|
|
cblock_t out;
|
|
|
|
int inbyte;
|
|
|
|
int *hnodes, *hnodesbase;
|
|
|
|
//int i;
|
|
|
|
|
|
|
|
// get decompressed count
|
|
|
|
count = in.data[0] + (in.data[1]<<8) + (in.data[2]<<16) + (in.data[3]<<24);
|
|
|
|
input = in.data + 4;
|
|
|
|
out_p = out.data = Z_Malloc (count);
|
|
|
|
|
|
|
|
// read bits
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
hnodesbase = cin->hnodes1 - 256*2; // nodes 0-255 aren't stored
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
hnodes = hnodesbase;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[0];
|
2004-08-23 00:15:46 +00:00
|
|
|
while (count)
|
|
|
|
{
|
|
|
|
inbyte = *input++;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
//-----------
|
|
|
|
if (nodenum < 256)
|
|
|
|
{
|
|
|
|
hnodes = hnodesbase + (nodenum<<9);
|
|
|
|
*out_p++ = nodenum;
|
|
|
|
if (!--count)
|
|
|
|
break;
|
2010-07-11 02:22:39 +00:00
|
|
|
nodenum = cin->numhnodes1[nodenum];
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
nodenum = hnodes[nodenum*2 + (inbyte&1)];
|
|
|
|
inbyte >>=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (input - in.data != in.count && input - in.data != in.count+1)
|
|
|
|
{
|
2011-01-29 19:53:38 +00:00
|
|
|
Con_Printf ("Decompression overread by %i\n", (int)(input - in.data) - in.count);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
out.count = out_p - out.data;
|
|
|
|
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_ReadNextFrame
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
qbyte *CIN_ReadNextFrame (cinematics_t *cin)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int r;
|
|
|
|
int command;
|
|
|
|
qbyte samples[22050/14*4];
|
|
|
|
qbyte compressed[0x20000];
|
|
|
|
int size;
|
|
|
|
qbyte *pic;
|
|
|
|
cblock_t in, huf1;
|
|
|
|
int start, end, count;
|
|
|
|
|
|
|
|
// read the next frame
|
2010-07-11 02:22:39 +00:00
|
|
|
r = VFS_READ (cin->cinematic_file, &command, 4);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (r == 0) // we'll give it one more chance
|
2010-07-11 02:22:39 +00:00
|
|
|
r = VFS_READ (cin->cinematic_file, &command, 4);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
if (r != 4)
|
2004-08-23 00:15:46 +00:00
|
|
|
return NULL;
|
|
|
|
command = LittleLong(command);
|
|
|
|
if (command == 2)
|
|
|
|
return NULL; // last frame marker
|
|
|
|
|
|
|
|
if (command == 1)
|
|
|
|
{ // read palette
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_READ (cin->cinematic_file, cin->cinematicpalette, sizeof(cin->cinematicpalette));
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// decompress the next frame
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_READ (cin->cinematic_file, &size, 4);
|
2004-08-23 00:15:46 +00:00
|
|
|
size = LittleLong(size);
|
|
|
|
if (size > sizeof(compressed) || size < 1)
|
|
|
|
Host_Error ("Bad compressed frame size");
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_READ (cin->cinematic_file, compressed, size);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// read sound
|
2010-07-11 02:22:39 +00:00
|
|
|
start = cin->cinematicframe*cin->s_rate/14;
|
|
|
|
end = (cin->cinematicframe+1)*cin->s_rate/14;
|
2004-08-23 00:15:46 +00:00
|
|
|
count = end - start;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
VFS_READ (cin->cinematic_file, samples, count*cin->s_width*cin->s_channels);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->s_width == 1)
|
|
|
|
COM_CharBias(samples, count*cin->s_channels);
|
|
|
|
else if (cin->s_width == 2)
|
|
|
|
COM_SwapLittleShortBlock((short *)samples, count*cin->s_channels);
|
2006-06-04 01:43:52 +00:00
|
|
|
|
2013-05-31 01:22:03 +00:00
|
|
|
S_RawAudio (0, samples, cin->s_rate, count, cin->s_channels, cin->s_width, 1);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
in.data = compressed;
|
|
|
|
in.count = size;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
huf1 = Huff1Decompress (cin, in);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
pic = huf1.data;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->cinematicframe++;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return pic;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_RunCinematic
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
0 = error
|
|
|
|
1 = success
|
|
|
|
2 = success but nothing changed
|
2004-08-23 00:15:46 +00:00
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
int CIN_RunCinematic (cinematics_t *cin, qbyte **outdata, int *outwidth, int *outheight, qbyte **outpalette)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int frame;
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->cinematictime <= 0)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->cinematictime = realtime;
|
|
|
|
cin->cinematicframe = -1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->cinematictime-3 > realtime*1000)
|
|
|
|
cin->cinematictime = realtime*1000;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
frame = (realtime*1000 - cin->cinematictime)*14/1000;
|
|
|
|
if (frame <= cin->cinematicframe)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
*outdata = cin->pic;
|
|
|
|
*outwidth = cin->width;
|
|
|
|
*outheight = cin->height;
|
|
|
|
*outpalette = cin->cinematicpalette;
|
|
|
|
return 2;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
if (frame > cin->cinematicframe+1)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2015-12-12 19:25:15 +00:00
|
|
|
Con_DPrintf ("Dropped frame: %i > %i\n", frame, cin->cinematicframe+1);
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->cinematictime = realtime*1000 - cin->cinematicframe*1000/14;
|
|
|
|
}
|
|
|
|
if (cin->pic)
|
|
|
|
Z_Free (cin->pic);
|
|
|
|
cin->pic = CIN_ReadNextFrame (cin);
|
|
|
|
if (!cin->pic)
|
|
|
|
{
|
|
|
|
return 0;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
*outdata = cin->pic;
|
|
|
|
*outwidth = cin->width;
|
|
|
|
*outheight = cin->height;
|
|
|
|
*outpalette = cin->cinematicpalette;
|
|
|
|
return 1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_DrawCinematic
|
|
|
|
|
|
|
|
Returns true if a cinematic is active, meaning the view rendering
|
|
|
|
should be skipped
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
/*
|
2004-08-23 00:15:46 +00:00
|
|
|
qboolean CIN_DrawCinematic (void)
|
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
if (cin->cinematictime <= 0)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (key_dest == key_menu)
|
|
|
|
{ // blank screen and pause if menu is up
|
|
|
|
// re.CinematicSetPalette(NULL);
|
|
|
|
cin.cinematicpalette_active = false;
|
|
|
|
// return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cin.cinematicpalette_active)
|
|
|
|
{
|
|
|
|
// re.CinematicSetPalette(cl.cinematicpalette);
|
|
|
|
cin.cinematicpalette_active = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cin.pic)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
Media_ShowFrame8bit(cin.pic, cin.width, cin.height, cin.cinematicpalette);
|
|
|
|
|
|
|
|
// re.DrawStretchRaw (0, 0, viddef.width, viddef.height,
|
|
|
|
// cin.width, cin.height, cin.pic);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
*/
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SCR_PlayCinematic
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
2010-07-11 02:22:39 +00:00
|
|
|
cinematics_t *CIN_PlayCinematic (char *arg)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int width, height;
|
|
|
|
char name[MAX_OSPATH];
|
|
|
|
// int old_khz;
|
2010-07-11 02:22:39 +00:00
|
|
|
vfsfile_t *file;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
cinematics_t *cin = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
file = FS_OpenVFS(arg, "rb", FS_GAME);
|
2006-01-16 14:14:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (!file)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf (name, sizeof(name), "video/%s", arg);
|
2010-07-11 02:22:39 +00:00
|
|
|
file = FS_OpenVFS(name, "rb", FS_GAME);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2006-01-16 14:14:06 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (file)
|
|
|
|
cin = Z_Malloc(sizeof(*cin));
|
|
|
|
if (cin)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
cin->cinematicframe = 0;
|
|
|
|
cin->cinematic_file = file;
|
|
|
|
|
|
|
|
VFS_READ (cin->cinematic_file, &width, 4);
|
|
|
|
VFS_READ (cin->cinematic_file, &height, 4);
|
|
|
|
cin->width = LittleLong(width);
|
|
|
|
cin->height = LittleLong(height);
|
|
|
|
|
|
|
|
VFS_READ (cin->cinematic_file, &cin->s_rate, 4);
|
|
|
|
cin->s_rate = LittleLong(cin->s_rate);
|
|
|
|
VFS_READ (cin->cinematic_file, &cin->s_width, 4);
|
|
|
|
cin->s_width = LittleLong(cin->s_width);
|
|
|
|
VFS_READ (cin->cinematic_file, &cin->s_channels, 4);
|
|
|
|
cin->s_channels = LittleLong(cin->s_channels);
|
|
|
|
|
|
|
|
Huff1TableInit (cin);
|
|
|
|
|
|
|
|
cin->cinematicframe = 0;
|
|
|
|
cin->pic = CIN_ReadNextFrame (cin);
|
2015-12-12 19:25:15 +00:00
|
|
|
cin->cinematictime = realtime*1000;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
else
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2014-02-07 08:38:40 +00:00
|
|
|
Con_Printf(CON_WARNING "Cinematic %s not found.\n", arg);
|
2010-07-11 02:22:39 +00:00
|
|
|
}
|
|
|
|
return cin;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2004-09-13 04:16:52 +00:00
|
|
|
#endif
|