?? cl_cin.c
字號:
cinTable[currentHandle].roqFPS = cin.file[ 6] + cin.file[ 7]*256;
if (!cinTable[currentHandle].roqFPS) cinTable[currentHandle].roqFPS = 30;
cinTable[currentHandle].numQuads = -1;
cinTable[currentHandle].roq_id = cin.file[ 8] + cin.file[ 9]*256;
cinTable[currentHandle].RoQFrameSize = cin.file[10] + cin.file[11]*256 + cin.file[12]*65536;
cinTable[currentHandle].roq_flags = cin.file[14] + cin.file[15]*256;
if (cinTable[currentHandle].RoQFrameSize > 65536 || !cinTable[currentHandle].RoQFrameSize) {
return;
}
}
/******************************************************************************
*
* Function:
*
* Description:
*
******************************************************************************/
static void RoQShutdown( void ) {
const char *s;
if (!cinTable[currentHandle].buf) {
return;
}
if ( cinTable[currentHandle].status == FMV_IDLE ) {
return;
}
Com_DPrintf("finished cinematic\n");
cinTable[currentHandle].status = FMV_IDLE;
if (cinTable[currentHandle].iFile) {
Sys_EndStreamedFile( cinTable[currentHandle].iFile );
FS_FCloseFile( cinTable[currentHandle].iFile );
cinTable[currentHandle].iFile = 0;
}
if (cinTable[currentHandle].alterGameState) {
cls.state = CA_DISCONNECTED;
// we can't just do a vstr nextmap, because
// if we are aborting the intro cinematic with
// a devmap command, nextmap would be valid by
// the time it was referenced
s = Cvar_VariableString( "nextmap" );
if ( s[0] ) {
Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", s) );
Cvar_Set( "nextmap", "" );
}
CL_handle = -1;
}
cinTable[currentHandle].fileName[0] = 0;
currentHandle = -1;
}
/*
==================
SCR_StopCinematic
==================
*/
e_status CIN_StopCinematic(int handle) {
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;
currentHandle = handle;
Com_DPrintf("trFMV::stop(), closing %s\n", cinTable[currentHandle].fileName);
if (!cinTable[currentHandle].buf) {
return FMV_EOF;
}
if (cinTable[currentHandle].alterGameState) {
if ( cls.state != CA_CINEMATIC ) {
return cinTable[currentHandle].status;
}
}
cinTable[currentHandle].status = FMV_EOF;
RoQShutdown();
return FMV_EOF;
}
/*
==================
SCR_RunCinematic
Fetch and decompress the pending frame
==================
*/
e_status CIN_RunCinematic (int handle)
{
// bk001204 - init
int start = 0;
int thisTime = 0;
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF;
if (cin.currentHandle != handle) {
currentHandle = handle;
cin.currentHandle = currentHandle;
cinTable[currentHandle].status = FMV_EOF;
RoQReset();
}
if (cinTable[handle].playonwalls < -1)
{
return cinTable[handle].status;
}
currentHandle = handle;
if (cinTable[currentHandle].alterGameState) {
if ( cls.state != CA_CINEMATIC ) {
return cinTable[currentHandle].status;
}
}
if (cinTable[currentHandle].status == FMV_IDLE) {
return cinTable[currentHandle].status;
}
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
thisTime = CL_ScaledMilliseconds()*com_timescale->value;
if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) {
cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime;
}
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value) - cinTable[currentHandle].startTime)*3)/100);
start = cinTable[currentHandle].startTime;
while( (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads)
&& (cinTable[currentHandle].status == FMV_PLAY) )
{
RoQInterrupt();
if (start != cinTable[currentHandle].startTime) {
// we need to use CL_ScaledMilliseconds because of the smp mode calls from the renderer
cinTable[currentHandle].tfps = ((((CL_ScaledMilliseconds()*com_timescale->value)
- cinTable[currentHandle].startTime)*3)/100);
start = cinTable[currentHandle].startTime;
}
}
cinTable[currentHandle].lastTime = thisTime;
if (cinTable[currentHandle].status == FMV_LOOPED) {
cinTable[currentHandle].status = FMV_PLAY;
}
if (cinTable[currentHandle].status == FMV_EOF) {
if (cinTable[currentHandle].looping) {
RoQReset();
} else {
RoQShutdown();
}
}
return cinTable[currentHandle].status;
}
/*
==================
CL_PlayCinematic
==================
*/
int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) {
unsigned short RoQID;
char name[MAX_OSPATH];
int i;
if (strstr(arg, "/") == NULL && strstr(arg, "\\") == NULL) {
Com_sprintf (name, sizeof(name), "video/%s", arg);
} else {
Com_sprintf (name, sizeof(name), "%s", arg);
}
if (!(systemBits & CIN_system)) {
for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) {
if (!strcmp(cinTable[i].fileName, name) ) {
return i;
}
}
}
Com_DPrintf("SCR_PlayCinematic( %s )\n", arg);
Com_Memset(&cin, 0, sizeof(cinematics_t) );
currentHandle = CIN_HandleForVideo();
cin.currentHandle = currentHandle;
strcpy(cinTable[currentHandle].fileName, name);
cinTable[currentHandle].ROQSize = 0;
cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue);
if (cinTable[currentHandle].ROQSize<=0) {
Com_DPrintf("play(%s), ROQSize<=0\n", arg);
cinTable[currentHandle].fileName[0] = 0;
return -1;
}
CIN_SetExtents(currentHandle, x, y, w, h);
CIN_SetLooping(currentHandle, (systemBits & CIN_loop)!=0);
cinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT;
cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH;
cinTable[currentHandle].holdAtEnd = (systemBits & CIN_hold) != 0;
cinTable[currentHandle].alterGameState = (systemBits & CIN_system) != 0;
cinTable[currentHandle].playonwalls = 1;
cinTable[currentHandle].silent = (systemBits & CIN_silent) != 0;
cinTable[currentHandle].shader = (systemBits & CIN_shader) != 0;
if (cinTable[currentHandle].alterGameState) {
// close the menu
if ( uivm ) {
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );
}
} else {
cinTable[currentHandle].playonwalls = cl_inGameVideo->integer;
}
initRoQ();
FS_Read (cin.file, 16, cinTable[currentHandle].iFile);
RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256;
if (RoQID == 0x1084)
{
RoQ_init();
// FS_Read (cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile);
// let the background thread start reading ahead
Sys_BeginStreamedFile( cinTable[currentHandle].iFile, 0x10000 );
cinTable[currentHandle].status = FMV_PLAY;
Com_DPrintf("trFMV::play(), playing %s\n", arg);
if (cinTable[currentHandle].alterGameState) {
cls.state = CA_CINEMATIC;
}
Con_Close();
s_rawend = s_soundtime;
return currentHandle;
}
Com_DPrintf("trFMV::play(), invalid RoQ ID\n");
RoQShutdown();
return -1;
}
void CIN_SetExtents (int handle, int x, int y, int w, int h) {
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
cinTable[handle].xpos = x;
cinTable[handle].ypos = y;
cinTable[handle].width = w;
cinTable[handle].height = h;
cinTable[handle].dirty = qtrue;
}
void CIN_SetLooping(int handle, qboolean loop) {
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
cinTable[handle].looping = loop;
}
/*
==================
SCR_DrawCinematic
==================
*/
void CIN_DrawCinematic (int handle) {
float x, y, w, h;
byte *buf;
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return;
if (!cinTable[handle].buf) {
return;
}
x = cinTable[handle].xpos;
y = cinTable[handle].ypos;
w = cinTable[handle].width;
h = cinTable[handle].height;
buf = cinTable[handle].buf;
SCR_AdjustFrom640( &x, &y, &w, &h );
if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) {
int ix, iy, *buf2, *buf3, xm, ym, ll;
xm = cinTable[handle].CIN_WIDTH/256;
ym = cinTable[handle].CIN_HEIGHT/256;
ll = 8;
if (cinTable[handle].CIN_WIDTH==512) {
ll = 9;
}
buf3 = (int*)buf;
buf2 = Hunk_AllocateTempMemory( 256*256*4 );
if (xm==2 && ym==2) {
byte *bc2, *bc3;
int ic, iiy;
bc2 = (byte *)buf2;
bc3 = (byte *)buf3;
for (iy = 0; iy<256; iy++) {
iiy = iy<<12;
for (ix = 0; ix<2048; ix+=8) {
for(ic = ix;ic<(ix+4);ic++) {
*bc2=(bc3[iiy+ic]+bc3[iiy+4+ic]+bc3[iiy+2048+ic]+bc3[iiy+2048+4+ic])>>2;
bc2++;
}
}
}
} else if (xm==2 && ym==1) {
byte *bc2, *bc3;
int ic, iiy;
bc2 = (byte *)buf2;
bc3 = (byte *)buf3;
for (iy = 0; iy<256; iy++) {
iiy = iy<<11;
for (ix = 0; ix<2048; ix+=8) {
for(ic = ix;ic<(ix+4);ic++) {
*bc2=(bc3[iiy+ic]+bc3[iiy+4+ic])>>1;
bc2++;
}
}
}
} else {
for (iy = 0; iy<256; iy++) {
for (ix = 0; ix<256; ix++) {
buf2[(iy<<8)+ix] = buf3[((iy*ym)<<ll) + (ix*xm)];
}
}
}
re.DrawStretchRaw( x, y, w, h, 256, 256, (byte *)buf2, handle, qtrue);
cinTable[handle].dirty = qfalse;
Hunk_FreeTempMemory(buf2);
return;
}
re.DrawStretchRaw( x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, buf, handle, cinTable[handle].dirty);
cinTable[handle].dirty = qfalse;
}
void CL_PlayCinematic_f(void) {
char *arg, *s;
qboolean holdatend;
int bits = CIN_system;
Com_DPrintf("CL_PlayCinematic_f\n");
if (cls.state == CA_CINEMATIC) {
SCR_StopCinematic();
}
arg = Cmd_Argv( 1 );
s = Cmd_Argv(2);
holdatend = qfalse;
if ((s && s[0] == '1') || Q_stricmp(arg,"demoend.roq")==0 || Q_stricmp(arg,"end.roq")==0) {
bits |= CIN_hold;
}
if (s && s[0] == '2') {
bits |= CIN_loop;
}
S_StopAllSounds ();
CL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits );
if (CL_handle >= 0) {
do {
SCR_RunCinematic();
} while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); // wait for first frame (load codebook and sound)
}
}
void SCR_DrawCinematic (void) {
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {
CIN_DrawCinematic(CL_handle);
}
}
void SCR_RunCinematic (void)
{
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {
CIN_RunCinematic(CL_handle);
}
}
void SCR_StopCinematic(void) {
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) {
CIN_StopCinematic(CL_handle);
S_StopAllSounds ();
CL_handle = -1;
}
}
void CIN_UploadCinematic(int handle) {
if (handle >= 0 && handle < MAX_VIDEO_HANDLES) {
if (!cinTable[handle].buf) {
return;
}
if (cinTable[handle].playonwalls <= 0 && cinTable[handle].dirty) {
if (cinTable[handle].playonwalls == 0) {
cinTable[handle].playonwalls = -1;
} else {
if (cinTable[handle].playonwalls == -1) {
cinTable[handle].playonwalls = -2;
} else {
cinTable[handle].dirty = qfalse;
}
}
}
re.UploadCinematic( 256, 256, 256, 256, cinTable[handle].buf, handle, cinTable[handle].dirty);
if (cl_inGameVideo->integer == 0 && cinTable[handle].playonwalls == 1) {
cinTable[handle].playonwalls--;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -