| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#include "client.h" |
| 35 |
#include "snd_local.h" |
| 36 |
|
| 37 |
#define MAXSIZE 8 |
| 38 |
#define MINSIZE 4 |
| 39 |
|
| 40 |
#define DEFAULT_CIN_WIDTH 512 |
| 41 |
#define DEFAULT_CIN_HEIGHT 512 |
| 42 |
|
| 43 |
#define ROQ_QUAD 0x1000 |
| 44 |
#define ROQ_QUAD_INFO 0x1001 |
| 45 |
#define ROQ_CODEBOOK 0x1002 |
| 46 |
#define ROQ_QUAD_VQ 0x1011 |
| 47 |
#define ROQ_QUAD_JPEG 0x1012 |
| 48 |
#define ROQ_QUAD_HANG 0x1013 |
| 49 |
#define ROQ_PACKET 0x1030 |
| 50 |
#define ZA_SOUND_MONO 0x1020 |
| 51 |
#define ZA_SOUND_STEREO 0x1021 |
| 52 |
|
| 53 |
#define MAX_VIDEO_HANDLES 16 |
| 54 |
|
| 55 |
|
| 56 |
static void RoQ_init( void ); |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
static long ROQ_YY_tab[256]; |
| 68 |
static long ROQ_UB_tab[256]; |
| 69 |
static long ROQ_UG_tab[256]; |
| 70 |
static long ROQ_VG_tab[256]; |
| 71 |
static long ROQ_VR_tab[256]; |
| 72 |
static unsigned short vq2[256*16*4]; |
| 73 |
static unsigned short vq4[256*64*4]; |
| 74 |
static unsigned short vq8[256*256*4]; |
| 75 |
|
| 76 |
|
| 77 |
typedef struct { |
| 78 |
byte linbuf[DEFAULT_CIN_WIDTH*DEFAULT_CIN_HEIGHT*4*2]; |
| 79 |
byte file[65536]; |
| 80 |
short sqrTable[256]; |
| 81 |
|
| 82 |
int mcomp[256]; |
| 83 |
byte *qStatus[2][32768]; |
| 84 |
|
| 85 |
long oldXOff, oldYOff, oldysize, oldxsize; |
| 86 |
|
| 87 |
int currentHandle; |
| 88 |
} cinematics_t; |
| 89 |
|
| 90 |
typedef struct { |
| 91 |
char fileName[MAX_OSPATH]; |
| 92 |
int CIN_WIDTH, CIN_HEIGHT; |
| 93 |
int xpos, ypos, width, height; |
| 94 |
qboolean looping, holdAtEnd, dirty, alterGameState, silent, shader; |
| 95 |
fileHandle_t iFile; |
| 96 |
e_status status; |
| 97 |
int startTime; |
| 98 |
int lastTime; |
| 99 |
long tfps; |
| 100 |
long RoQPlayed; |
| 101 |
long ROQSize; |
| 102 |
unsigned int RoQFrameSize; |
| 103 |
long onQuad; |
| 104 |
long numQuads; |
| 105 |
long samplesPerLine; |
| 106 |
unsigned int roq_id; |
| 107 |
long screenDelta; |
| 108 |
|
| 109 |
void ( *VQ0)(byte *status, void *qdata ); |
| 110 |
void ( *VQ1)(byte *status, void *qdata ); |
| 111 |
void ( *VQNormal)(byte *status, void *qdata ); |
| 112 |
void ( *VQBuffer)(byte *status, void *qdata ); |
| 113 |
|
| 114 |
long samplesPerPixel; |
| 115 |
byte* gray; |
| 116 |
unsigned int xsize, ysize, maxsize, minsize; |
| 117 |
|
| 118 |
qboolean half, smootheddouble, inMemory; |
| 119 |
long normalBuffer0; |
| 120 |
long roq_flags; |
| 121 |
long roqF0; |
| 122 |
long roqF1; |
| 123 |
long t[2]; |
| 124 |
long roqFPS; |
| 125 |
int playonwalls; |
| 126 |
byte* buf; |
| 127 |
long drawX, drawY; |
| 128 |
} cin_cache; |
| 129 |
|
| 130 |
static cinematics_t cin; |
| 131 |
static cin_cache cinTable[MAX_VIDEO_HANDLES]; |
| 132 |
static int currentHandle = -1; |
| 133 |
static int CL_handle = -1; |
| 134 |
|
| 135 |
extern int s_soundtime; |
| 136 |
|
| 137 |
|
| 138 |
void CIN_CloseAllVideos(void) { |
| 139 |
int i; |
| 140 |
|
| 141 |
for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { |
| 142 |
if (cinTable[i].fileName[0] != 0 ) { |
| 143 |
CIN_StopCinematic(i); |
| 144 |
} |
| 145 |
} |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
static int CIN_HandleForVideo(void) { |
| 150 |
int i; |
| 151 |
|
| 152 |
for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { |
| 153 |
if ( cinTable[i].fileName[0] == 0 ) { |
| 154 |
return i; |
| 155 |
} |
| 156 |
} |
| 157 |
Com_Error( ERR_DROP, "CIN_HandleForVideo: none free" ); |
| 158 |
return -1; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
extern int CL_ScaledMilliseconds(void); |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
static void RllSetupTable( void ) |
| 174 |
{ |
| 175 |
int z; |
| 176 |
|
| 177 |
for (z=0;z<128;z++) { |
| 178 |
cin.sqrTable[z] = (short)(z*z); |
| 179 |
cin.sqrTable[z+128] = (short)(-cin.sqrTable[z]); |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
long RllDecodeMonoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput ,unsigned short flag) |
| 199 |
{ |
| 200 |
unsigned int z; |
| 201 |
int prev; |
| 202 |
|
| 203 |
if (signedOutput) |
| 204 |
prev = flag - 0x8000; |
| 205 |
else |
| 206 |
prev = flag; |
| 207 |
|
| 208 |
for (z=0;z<size;z++) { |
| 209 |
prev = to[z] = (short)(prev + cin.sqrTable[from[z]]); |
| 210 |
} |
| 211 |
return size; |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
long RllDecodeMonoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput,unsigned short flag) |
| 230 |
{ |
| 231 |
unsigned int z; |
| 232 |
int prev; |
| 233 |
|
| 234 |
if (signedOutput) |
| 235 |
prev = flag - 0x8000; |
| 236 |
else |
| 237 |
prev = flag; |
| 238 |
|
| 239 |
for (z = 0; z < size; z++) { |
| 240 |
prev = (short)(prev + cin.sqrTable[from[z]]); |
| 241 |
to[z*2+0] = to[z*2+1] = (short)(prev); |
| 242 |
} |
| 243 |
|
| 244 |
return size; |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
long RllDecodeStereoToStereo(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag) |
| 262 |
{ |
| 263 |
unsigned int z; |
| 264 |
unsigned char *zz = from; |
| 265 |
int prevL, prevR; |
| 266 |
|
| 267 |
if (signedOutput) { |
| 268 |
prevL = (flag & 0xff00) - 0x8000; |
| 269 |
prevR = ((flag & 0x00ff) << 8) - 0x8000; |
| 270 |
} else { |
| 271 |
prevL = flag & 0xff00; |
| 272 |
prevR = (flag & 0x00ff) << 8; |
| 273 |
} |
| 274 |
|
| 275 |
for (z=0;z<size;z+=2) { |
| 276 |
prevL = (short)(prevL + cin.sqrTable[*zz++]); |
| 277 |
prevR = (short)(prevR + cin.sqrTable[*zz++]); |
| 278 |
to[z+0] = (short)(prevL); |
| 279 |
to[z+1] = (short)(prevR); |
| 280 |
} |
| 281 |
|
| 282 |
return (size>>1); |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
long RllDecodeStereoToMono(unsigned char *from,short *to,unsigned int size,char signedOutput, unsigned short flag) |
| 300 |
{ |
| 301 |
unsigned int z; |
| 302 |
int prevL,prevR; |
| 303 |
|
| 304 |
if (signedOutput) { |
| 305 |
prevL = (flag & 0xff00) - 0x8000; |
| 306 |
prevR = ((flag & 0x00ff) << 8) -0x8000; |
| 307 |
} else { |
| 308 |
prevL = flag & 0xff00; |
| 309 |
prevR = (flag & 0x00ff) << 8; |
| 310 |
} |
| 311 |
|
| 312 |
for (z=0;z<size;z+=1) { |
| 313 |
prevL= prevL + cin.sqrTable[from[z*2]]; |
| 314 |
prevR = prevR + cin.sqrTable[from[z*2+1]]; |
| 315 |
to[z] = (short)((prevL + prevR)/2); |
| 316 |
} |
| 317 |
|
| 318 |
return size; |
| 319 |
} |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
static void move8_32( byte *src, byte *dst, int spl ) |
| 330 |
{ |
| 331 |
int i; |
| 332 |
|
| 333 |
for(i = 0; i < 8; ++i) |
| 334 |
{ |
| 335 |
memcpy(dst, src, 32); |
| 336 |
src += spl; |
| 337 |
dst += spl; |
| 338 |
} |
| 339 |
} |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
static void move4_32( byte *src, byte *dst, int spl ) |
| 350 |
{ |
| 351 |
int i; |
| 352 |
|
| 353 |
for(i = 0; i < 4; ++i) |
| 354 |
{ |
| 355 |
memcpy(dst, src, 16); |
| 356 |
src += spl; |
| 357 |
dst += spl; |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
static void blit8_32( byte *src, byte *dst, int spl ) |
| 370 |
{ |
| 371 |
int i; |
| 372 |
|
| 373 |
for(i = 0; i < 8; ++i) |
| 374 |
{ |
| 375 |
memcpy(dst, src, 32); |
| 376 |
src += 32; |
| 377 |
dst += spl; |
| 378 |
} |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
static void blit4_32( byte *src, byte *dst, int spl ) |
| 389 |
{ |
| 390 |
int i; |
| 391 |
|
| 392 |
for(i = 0; i < 4; ++i) |
| 393 |
{ |
| 394 |
memmove(dst, src, 16); |
| 395 |
src += 16; |
| 396 |
dst += spl; |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
static void blit2_32( byte *src, byte *dst, int spl ) |
| 409 |
{ |
| 410 |
memcpy(dst, src, 8); |
| 411 |
memcpy(dst+spl, src+8, 8); |
| 412 |
} |
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
static void blitVQQuad32fs( byte **status, unsigned char *data ) |
| 423 |
{ |
| 424 |
unsigned short newd, celdata, code; |
| 425 |
unsigned int index, i; |
| 426 |
int spl; |
| 427 |
|
| 428 |
newd = 0; |
| 429 |
celdata = 0; |
| 430 |
index = 0; |
| 431 |
|
| 432 |
spl = cinTable[currentHandle].samplesPerLine; |
| 433 |
|
| 434 |
do { |
| 435 |
if (!newd) { |
| 436 |
newd = 7; |
| 437 |
celdata = data[0] + data[1]*256; |
| 438 |
data += 2; |
| 439 |
} else { |
| 440 |
newd--; |
| 441 |
} |
| 442 |
|
| 443 |
code = (unsigned short)(celdata&0xc000); |
| 444 |
celdata <<= 2; |
| 445 |
|
| 446 |
switch (code) { |
| 447 |
case 0x8000: |
| 448 |
blit8_32( (byte *)&vq8[(*data)*128], status[index], spl ); |
| 449 |
data++; |
| 450 |
index += 5; |
| 451 |
break; |
| 452 |
case 0xc000: |
| 453 |
index++; |
| 454 |
for(i=0;i<4;i++) { |
| 455 |
if (!newd) { |
| 456 |
newd = 7; |
| 457 |
celdata = data[0] + data[1]*256; |
| 458 |
data += 2; |
| 459 |
} else { |
| 460 |
newd--; |
| 461 |
} |
| 462 |
|
| 463 |
code = (unsigned short)(celdata&0xc000); celdata <<= 2; |
| 464 |
|
| 465 |
switch (code) { |
| 466 |
case 0x8000: |
| 467 |
blit4_32( (byte *)&vq4[(*data)*32], status[index], spl ); |
| 468 |
data++; |
| 469 |
break; |
| 470 |
case 0xc000: |
| 471 |
blit2_32( (byte *)&vq2[(*data)*8], status[index], spl ); |
| 472 |
data++; |
| 473 |
blit2_32( (byte *)&vq2[(*data)*8], status[index]+8, spl ); |
| 474 |
data++; |
| 475 |
blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2, spl ); |
| 476 |
data++; |
| 477 |
blit2_32( (byte *)&vq2[(*data)*8], status[index]+spl*2+8, spl ); |
| 478 |
data++; |
| 479 |
break; |
| 480 |
case 0x4000: |
| 481 |
move4_32( status[index] + cin.mcomp[(*data)], status[index], spl ); |
| 482 |
data++; |
| 483 |
break; |
| 484 |
} |
| 485 |
index++; |
| 486 |
} |
| 487 |
break; |
| 488 |
case 0x4000: |
| 489 |
move8_32( status[index] + cin.mcomp[(*data)], status[index], spl ); |
| 490 |
data++; |
| 491 |
index += 5; |
| 492 |
break; |
| 493 |
case 0x0000: |
| 494 |
index += 5; |
| 495 |
break; |
| 496 |
} |
| 497 |
} while ( status[index] != NULL ); |
| 498 |
} |
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
static void ROQ_GenYUVTables( void ) |
| 509 |
{ |
| 510 |
float t_ub,t_vr,t_ug,t_vg; |
| 511 |
long i; |
| 512 |
|
| 513 |
t_ub = (1.77200f/2.0f) * (float)(1<<6) + 0.5f; |
| 514 |
t_vr = (1.40200f/2.0f) * (float)(1<<6) + 0.5f; |
| 515 |
t_ug = (0.34414f/2.0f) * (float)(1<<6) + 0.5f; |
| 516 |
t_vg = (0.71414f/2.0f) * (float)(1<<6) + 0.5f; |
| 517 |
for(i=0;i<256;i++) { |
| 518 |
float x = (float)(2 * i - 255); |
| 519 |
|
| 520 |
ROQ_UB_tab[i] = (long)( ( t_ub * x) + (1<<5)); |
| 521 |
ROQ_VR_tab[i] = (long)( ( t_vr * x) + (1<<5)); |
| 522 |
ROQ_UG_tab[i] = (long)( (-t_ug * x) ); |
| 523 |
ROQ_VG_tab[i] = (long)( (-t_vg * x) + (1<<5)); |
| 524 |
ROQ_YY_tab[i] = (long)( (i << 6) | (i >> 2) ); |
| 525 |
} |
| 526 |
} |
| 527 |
|
| 528 |
#define VQ2TO4(a,b,c,d) { \ |
| 529 |
*c++ = a[0]; \ |
| 530 |
*d++ = a[0]; \ |
| 531 |
*d++ = a[0]; \ |
| 532 |
*c++ = a[1]; \ |
| 533 |
*d++ = a[1]; \ |
| 534 |
*d++ = a[1]; \ |
| 535 |
*c++ = b[0]; \ |
| 536 |
*d++ = b[0]; \ |
| 537 |
*d++ = b[0]; \ |
| 538 |
*c++ = b[1]; \ |
| 539 |
*d++ = b[1]; \ |
| 540 |
*d++ = b[1]; \ |
| 541 |
*d++ = a[0]; \ |
| 542 |
*d++ = a[0]; \ |
| 543 |
*d++ = a[1]; \ |
| 544 |
*d++ = a[1]; \ |
| 545 |
*d++ = b[0]; \ |
| 546 |
*d++ = b[0]; \ |
| 547 |
*d++ = b[1]; \ |
| 548 |
*d++ = b[1]; \ |
| 549 |
a += 2; b += 2; } |
| 550 |
|
| 551 |
#define VQ2TO2(a,b,c,d) { \ |
| 552 |
*c++ = *a; \ |
| 553 |
*d++ = *a; \ |
| 554 |
*d++ = *a; \ |
| 555 |
*c++ = *b; \ |
| 556 |
*d++ = *b; \ |
| 557 |
*d++ = *b; \ |
| 558 |
*d++ = *a; \ |
| 559 |
*d++ = *a; \ |
| 560 |
*d++ = *b; \ |
| 561 |
*d++ = *b; \ |
| 562 |
a++; b++; } |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
static unsigned short yuv_to_rgb( long y, long u, long v ) |
| 573 |
{ |
| 574 |
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); |
| 575 |
|
| 576 |
r = (YY + ROQ_VR_tab[v]) >> 9; |
| 577 |
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 8; |
| 578 |
b = (YY + ROQ_UB_tab[u]) >> 9; |
| 579 |
|
| 580 |
if (r<0) r = 0; |
| 581 |
if (g<0) g = 0; |
| 582 |
if (b<0) b = 0; |
| 583 |
if (r > 31) r = 31; |
| 584 |
if (g > 63) g = 63; |
| 585 |
if (b > 31) b = 31; |
| 586 |
|
| 587 |
return (unsigned short)((r<<11)+(g<<5)+(b)); |
| 588 |
} |
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
static unsigned int yuv_to_rgb24( long y, long u, long v ) |
| 598 |
{ |
| 599 |
long r,g,b,YY = (long)(ROQ_YY_tab[(y)]); |
| 600 |
|
| 601 |
r = (YY + ROQ_VR_tab[v]) >> 6; |
| 602 |
g = (YY + ROQ_UG_tab[u] + ROQ_VG_tab[v]) >> 6; |
| 603 |
b = (YY + ROQ_UB_tab[u]) >> 6; |
| 604 |
|
| 605 |
if (r<0) r = 0; |
| 606 |
if (g<0) g = 0; |
| 607 |
if (b<0) b = 0; |
| 608 |
if (r > 255) r = 255; |
| 609 |
if (g > 255) g = 255; |
| 610 |
if (b > 255) b = 255; |
| 611 |
|
| 612 |
return LittleLong ((unsigned long)((r)|(g<<8)|(b<<16))|(255UL<<24)); |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
static void decodeCodeBook( byte *input, unsigned short roq_flags ) |
| 624 |
{ |
| 625 |
long i, j, two, four; |
| 626 |
unsigned short *aptr, *bptr, *cptr, *dptr; |
| 627 |
long y0,y1,y2,y3,cr,cb; |
| 628 |
byte *bbptr, *baptr, *bcptr, *bdptr; |
| 629 |
union { |
| 630 |
unsigned int *i; |
| 631 |
unsigned short *s; |
| 632 |
} iaptr, ibptr, icptr, idptr; |
| 633 |
|
| 634 |
if (!roq_flags) { |
| 635 |
two = four = 256; |
| 636 |
} else { |
| 637 |
two = roq_flags>>8; |
| 638 |
if (!two) two = 256; |
| 639 |
four = roq_flags&0xff; |
| 640 |
} |
| 641 |
|
| 642 |
four *= 2; |
| 643 |
|
| 644 |
bptr = (unsigned short *)vq2; |
| 645 |
|
| 646 |
if (!cinTable[currentHandle].half) { |
| 647 |
if (!cinTable[currentHandle].smootheddouble) { |
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
if (cinTable[currentHandle].samplesPerPixel==2) { |
| 652 |
for(i=0;i<two;i++) { |
| 653 |
y0 = (long)*input++; |
| 654 |
y1 = (long)*input++; |
| 655 |
y2 = (long)*input++; |
| 656 |
y3 = (long)*input++; |
| 657 |
cr = (long)*input++; |
| 658 |
cb = (long)*input++; |
| 659 |
*bptr++ = yuv_to_rgb( y0, cr, cb ); |
| 660 |
*bptr++ = yuv_to_rgb( y1, cr, cb ); |
| 661 |
*bptr++ = yuv_to_rgb( y2, cr, cb ); |
| 662 |
*bptr++ = yuv_to_rgb( y3, cr, cb ); |
| 663 |
} |
| 664 |
|
| 665 |
cptr = (unsigned short *)vq4; |
| 666 |
dptr = (unsigned short *)vq8; |
| 667 |
|
| 668 |
for(i=0;i<four;i++) { |
| 669 |
aptr = (unsigned short *)vq2 + (*input++)*4; |
| 670 |
bptr = (unsigned short *)vq2 + (*input++)*4; |
| 671 |
for(j=0;j<2;j++) |
| 672 |
VQ2TO4(aptr,bptr,cptr,dptr); |
| 673 |
} |
| 674 |
} else if (cinTable[currentHandle].samplesPerPixel==4) { |
| 675 |
ibptr.s = bptr; |
| 676 |
for(i=0;i<two;i++) { |
| 677 |
y0 = (long)*input++; |
| 678 |
y1 = (long)*input++; |
| 679 |
y2 = (long)*input++; |
| 680 |
y3 = (long)*input++; |
| 681 |
cr = (long)*input++; |
| 682 |
cb = (long)*input++; |
| 683 |
*ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); |
| 684 |
*ibptr.i++ = yuv_to_rgb24( y1, cr, cb ); |
| 685 |
*ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); |
| 686 |
*ibptr.i++ = yuv_to_rgb24( y3, cr, cb ); |
| 687 |
} |
| 688 |
|
| 689 |
icptr.s = vq4; |
| 690 |
idptr.s = vq8; |
| 691 |
|
| 692 |
for(i=0;i<four;i++) { |
| 693 |
iaptr.s = vq2; |
| 694 |
iaptr.i += (*input++)*4; |
| 695 |
ibptr.s = vq2; |
| 696 |
ibptr.i += (*input++)*4; |
| 697 |
for(j=0;j<2;j++) |
| 698 |
VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); |
| 699 |
} |
| 700 |
} else if (cinTable[currentHandle].samplesPerPixel==1) { |
| 701 |
bbptr = (byte *)bptr; |
| 702 |
for(i=0;i<two;i++) { |
| 703 |
*bbptr++ = cinTable[currentHandle].gray[*input++]; |
| 704 |
*bbptr++ = cinTable[currentHandle].gray[*input++]; |
| 705 |
*bbptr++ = cinTable[currentHandle].gray[*input++]; |
| 706 |
*bbptr++ = cinTable[currentHandle].gray[*input]; input +=3; |
| 707 |
} |
| 708 |
|
| 709 |
bcptr = (byte *)vq4; |
| 710 |
bdptr = (byte *)vq8; |
| 711 |
|
| 712 |
for(i=0;i<four;i++) { |
| 713 |
baptr = (byte *)vq2 + (*input++)*4; |
| 714 |
bbptr = (byte *)vq2 + (*input++)*4; |
| 715 |
for(j=0;j<2;j++) |
| 716 |
VQ2TO4(baptr,bbptr,bcptr,bdptr); |
| 717 |
} |
| 718 |
} |
| 719 |
} else { |
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
if (cinTable[currentHandle].samplesPerPixel==2) { |
| 724 |
for(i=0;i<two;i++) { |
| 725 |
y0 = (long)*input++; |
| 726 |
y1 = (long)*input++; |
| 727 |
y2 = (long)*input++; |
| 728 |
y3 = (long)*input++; |
| 729 |
cr = (long)*input++; |
| 730 |
cb = (long)*input++; |
| 731 |
*bptr++ = yuv_to_rgb( y0, cr, cb ); |
| 732 |
*bptr++ = yuv_to_rgb( y1, cr, cb ); |
| 733 |
*bptr++ = yuv_to_rgb( ((y0*3)+y2)/4, cr, cb ); |
| 734 |
*bptr++ = yuv_to_rgb( ((y1*3)+y3)/4, cr, cb ); |
| 735 |
*bptr++ = yuv_to_rgb( (y0+(y2*3))/4, cr, cb ); |
| 736 |
*bptr++ = yuv_to_rgb( (y1+(y3*3))/4, cr, cb ); |
| 737 |
*bptr++ = yuv_to_rgb( y2, cr, cb ); |
| 738 |
*bptr++ = yuv_to_rgb( y3, cr, cb ); |
| 739 |
} |
| 740 |
|
| 741 |
cptr = (unsigned short *)vq4; |
| 742 |
dptr = (unsigned short *)vq8; |
| 743 |
|
| 744 |
for(i=0;i<four;i++) { |
| 745 |
aptr = (unsigned short *)vq2 + (*input++)*8; |
| 746 |
bptr = (unsigned short *)vq2 + (*input++)*8; |
| 747 |
for(j=0;j<2;j++) { |
| 748 |
VQ2TO4(aptr,bptr,cptr,dptr); |
| 749 |
VQ2TO4(aptr,bptr,cptr,dptr); |
| 750 |
} |
| 751 |
} |
| 752 |
} else if (cinTable[currentHandle].samplesPerPixel==4) { |
| 753 |
ibptr.s = bptr; |
| 754 |
for(i=0;i<two;i++) { |
| 755 |
y0 = (long)*input++; |
| 756 |
y1 = (long)*input++; |
| 757 |
y2 = (long)*input++; |
| 758 |
y3 = (long)*input++; |
| 759 |
cr = (long)*input++; |
| 760 |
cb = (long)*input++; |
| 761 |
*ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); |
| 762 |
*ibptr.i++ = yuv_to_rgb24( y1, cr, cb ); |
| 763 |
*ibptr.i++ = yuv_to_rgb24( ((y0*3)+y2)/4, cr, cb ); |
| 764 |
*ibptr.i++ = yuv_to_rgb24( ((y1*3)+y3)/4, cr, cb ); |
| 765 |
*ibptr.i++ = yuv_to_rgb24( (y0+(y2*3))/4, cr, cb ); |
| 766 |
*ibptr.i++ = yuv_to_rgb24( (y1+(y3*3))/4, cr, cb ); |
| 767 |
*ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); |
| 768 |
*ibptr.i++ = yuv_to_rgb24( y3, cr, cb ); |
| 769 |
} |
| 770 |
|
| 771 |
icptr.s = vq4; |
| 772 |
idptr.s = vq8; |
| 773 |
|
| 774 |
for(i=0;i<four;i++) { |
| 775 |
iaptr.s = vq2; |
| 776 |
iaptr.i += (*input++)*8; |
| 777 |
ibptr.s = vq2; |
| 778 |
ibptr.i += (*input++)*8; |
| 779 |
for(j=0;j<2;j++) { |
| 780 |
VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); |
| 781 |
VQ2TO4(iaptr.i, ibptr.i, icptr.i, idptr.i); |
| 782 |
} |
| 783 |
} |
| 784 |
} else if (cinTable[currentHandle].samplesPerPixel==1) { |
| 785 |
bbptr = (byte *)bptr; |
| 786 |
for(i=0;i<two;i++) { |
| 787 |
y0 = (long)*input++; |
| 788 |
y1 = (long)*input++; |
| 789 |
y2 = (long)*input++; |
| 790 |
y3 = (long)*input; input+= 3; |
| 791 |
*bbptr++ = cinTable[currentHandle].gray[y0]; |
| 792 |
*bbptr++ = cinTable[currentHandle].gray[y1]; |
| 793 |
*bbptr++ = cinTable[currentHandle].gray[((y0*3)+y2)/4]; |
| 794 |
*bbptr++ = cinTable[currentHandle].gray[((y1*3)+y3)/4]; |
| 795 |
*bbptr++ = cinTable[currentHandle].gray[(y0+(y2*3))/4]; |
| 796 |
*bbptr++ = cinTable[currentHandle].gray[(y1+(y3*3))/4]; |
| 797 |
*bbptr++ = cinTable[currentHandle].gray[y2]; |
| 798 |
*bbptr++ = cinTable[currentHandle].gray[y3]; |
| 799 |
} |
| 800 |
|
| 801 |
bcptr = (byte *)vq4; |
| 802 |
bdptr = (byte *)vq8; |
| 803 |
|
| 804 |
for(i=0;i<four;i++) { |
| 805 |
baptr = (byte *)vq2 + (*input++)*8; |
| 806 |
bbptr = (byte *)vq2 + (*input++)*8; |
| 807 |
for(j=0;j<2;j++) { |
| 808 |
VQ2TO4(baptr,bbptr,bcptr,bdptr); |
| 809 |
VQ2TO4(baptr,bbptr,bcptr,bdptr); |
| 810 |
} |
| 811 |
} |
| 812 |
} |
| 813 |
} |
| 814 |
} else { |
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
if (cinTable[currentHandle].samplesPerPixel==2) { |
| 819 |
for(i=0;i<two;i++) { |
| 820 |
y0 = (long)*input; input+=2; |
| 821 |
y2 = (long)*input; input+=2; |
| 822 |
cr = (long)*input++; |
| 823 |
cb = (long)*input++; |
| 824 |
*bptr++ = yuv_to_rgb( y0, cr, cb ); |
| 825 |
*bptr++ = yuv_to_rgb( y2, cr, cb ); |
| 826 |
} |
| 827 |
|
| 828 |
cptr = (unsigned short *)vq4; |
| 829 |
dptr = (unsigned short *)vq8; |
| 830 |
|
| 831 |
for(i=0;i<four;i++) { |
| 832 |
aptr = (unsigned short *)vq2 + (*input++)*2; |
| 833 |
bptr = (unsigned short *)vq2 + (*input++)*2; |
| 834 |
for(j=0;j<2;j++) { |
| 835 |
VQ2TO2(aptr,bptr,cptr,dptr); |
| 836 |
} |
| 837 |
} |
| 838 |
} else if (cinTable[currentHandle].samplesPerPixel == 1) { |
| 839 |
bbptr = (byte *)bptr; |
| 840 |
|
| 841 |
for(i=0;i<two;i++) { |
| 842 |
*bbptr++ = cinTable[currentHandle].gray[*input]; input+=2; |
| 843 |
*bbptr++ = cinTable[currentHandle].gray[*input]; input+=4; |
| 844 |
} |
| 845 |
|
| 846 |
bcptr = (byte *)vq4; |
| 847 |
bdptr = (byte *)vq8; |
| 848 |
|
| 849 |
for(i=0;i<four;i++) { |
| 850 |
baptr = (byte *)vq2 + (*input++)*2; |
| 851 |
bbptr = (byte *)vq2 + (*input++)*2; |
| 852 |
for(j=0;j<2;j++) { |
| 853 |
VQ2TO2(baptr,bbptr,bcptr,bdptr); |
| 854 |
} |
| 855 |
} |
| 856 |
} else if (cinTable[currentHandle].samplesPerPixel == 4) { |
| 857 |
ibptr.s = bptr; |
| 858 |
for(i=0;i<two;i++) { |
| 859 |
y0 = (long)*input; input+=2; |
| 860 |
y2 = (long)*input; input+=2; |
| 861 |
cr = (long)*input++; |
| 862 |
cb = (long)*input++; |
| 863 |
*ibptr.i++ = yuv_to_rgb24( y0, cr, cb ); |
| 864 |
*ibptr.i++ = yuv_to_rgb24( y2, cr, cb ); |
| 865 |
} |
| 866 |
|
| 867 |
icptr.s = vq4; |
| 868 |
idptr.s = vq8; |
| 869 |
|
| 870 |
for(i=0;i<four;i++) { |
| 871 |
iaptr.s = vq2; |
| 872 |
iaptr.i += (*input++)*2; |
| 873 |
ibptr.s = vq2 + (*input++)*2; |
| 874 |
ibptr.i += (*input++)*2; |
| 875 |
for(j=0;j<2;j++) { |
| 876 |
VQ2TO2(iaptr.i,ibptr.i,icptr.i,idptr.i); |
| 877 |
} |
| 878 |
} |
| 879 |
} |
| 880 |
} |
| 881 |
} |
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
static void recurseQuad( long startX, long startY, long quadSize, long xOff, long yOff ) |
| 892 |
{ |
| 893 |
byte *scroff; |
| 894 |
long bigx, bigy, lowx, lowy, useY; |
| 895 |
long offset; |
| 896 |
|
| 897 |
offset = cinTable[currentHandle].screenDelta; |
| 898 |
|
| 899 |
lowx = lowy = 0; |
| 900 |
bigx = cinTable[currentHandle].xsize; |
| 901 |
bigy = cinTable[currentHandle].ysize; |
| 902 |
|
| 903 |
if (bigx > cinTable[currentHandle].CIN_WIDTH) bigx = cinTable[currentHandle].CIN_WIDTH; |
| 904 |
if (bigy > cinTable[currentHandle].CIN_HEIGHT) bigy = cinTable[currentHandle].CIN_HEIGHT; |
| 905 |
|
| 906 |
if ( (startX >= lowx) && (startX+quadSize) <= (bigx) && (startY+quadSize) <= (bigy) && (startY >= lowy) && quadSize <= MAXSIZE) { |
| 907 |
useY = startY; |
| 908 |
scroff = cin.linbuf + (useY+((cinTable[currentHandle].CIN_HEIGHT-bigy)>>1)+yOff)*(cinTable[currentHandle].samplesPerLine) + (((startX+xOff))*cinTable[currentHandle].samplesPerPixel); |
| 909 |
|
| 910 |
cin.qStatus[0][cinTable[currentHandle].onQuad ] = scroff; |
| 911 |
cin.qStatus[1][cinTable[currentHandle].onQuad++] = scroff+offset; |
| 912 |
} |
| 913 |
|
| 914 |
if ( quadSize != MINSIZE ) { |
| 915 |
quadSize >>= 1; |
| 916 |
recurseQuad( startX, startY , quadSize, xOff, yOff ); |
| 917 |
recurseQuad( startX+quadSize, startY , quadSize, xOff, yOff ); |
| 918 |
recurseQuad( startX, startY+quadSize , quadSize, xOff, yOff ); |
| 919 |
recurseQuad( startX+quadSize, startY+quadSize , quadSize, xOff, yOff ); |
| 920 |
} |
| 921 |
} |
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
static void setupQuad( long xOff, long yOff ) |
| 933 |
{ |
| 934 |
long numQuadCels, i,x,y; |
| 935 |
byte *temp; |
| 936 |
|
| 937 |
if (xOff == cin.oldXOff && yOff == cin.oldYOff && |
| 938 |
(long)cinTable[currentHandle].ysize == cin.oldysize && |
| 939 |
(long)cinTable[currentHandle].xsize == cin.oldxsize) { |
| 940 |
return; |
| 941 |
} |
| 942 |
|
| 943 |
cin.oldXOff = xOff; |
| 944 |
cin.oldYOff = yOff; |
| 945 |
cin.oldysize = cinTable[currentHandle].ysize; |
| 946 |
cin.oldxsize = cinTable[currentHandle].xsize; |
| 947 |
|
| 948 |
numQuadCels = (cinTable[currentHandle].xsize*cinTable[currentHandle].ysize) / (16); |
| 949 |
numQuadCels += numQuadCels/4; |
| 950 |
numQuadCels += 64; |
| 951 |
|
| 952 |
cinTable[currentHandle].onQuad = 0; |
| 953 |
|
| 954 |
for(y=0;y<(long)cinTable[currentHandle].ysize;y+=16) |
| 955 |
for(x=0;x<(long)cinTable[currentHandle].xsize;x+=16) |
| 956 |
recurseQuad( x, y, 16, xOff, yOff ); |
| 957 |
|
| 958 |
temp = NULL; |
| 959 |
|
| 960 |
for(i=(numQuadCels-64);i<numQuadCels;i++) { |
| 961 |
cin.qStatus[0][i] = temp; |
| 962 |
cin.qStatus[1][i] = temp; |
| 963 |
} |
| 964 |
} |
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
static void readQuadInfo( byte *qData ) |
| 975 |
{ |
| 976 |
if (currentHandle < 0) return; |
| 977 |
|
| 978 |
cinTable[currentHandle].xsize = qData[0]+qData[1]*256; |
| 979 |
cinTable[currentHandle].ysize = qData[2]+qData[3]*256; |
| 980 |
cinTable[currentHandle].maxsize = qData[4]+qData[5]*256; |
| 981 |
cinTable[currentHandle].minsize = qData[6]+qData[7]*256; |
| 982 |
|
| 983 |
cinTable[currentHandle].CIN_HEIGHT = cinTable[currentHandle].ysize; |
| 984 |
cinTable[currentHandle].CIN_WIDTH = cinTable[currentHandle].xsize; |
| 985 |
|
| 986 |
cinTable[currentHandle].samplesPerLine = cinTable[currentHandle].CIN_WIDTH*cinTable[currentHandle].samplesPerPixel; |
| 987 |
cinTable[currentHandle].screenDelta = cinTable[currentHandle].CIN_HEIGHT*cinTable[currentHandle].samplesPerLine; |
| 988 |
|
| 989 |
cinTable[currentHandle].half = qfalse; |
| 990 |
cinTable[currentHandle].smootheddouble = qfalse; |
| 991 |
|
| 992 |
cinTable[currentHandle].VQ0 = cinTable[currentHandle].VQNormal; |
| 993 |
cinTable[currentHandle].VQ1 = cinTable[currentHandle].VQBuffer; |
| 994 |
|
| 995 |
cinTable[currentHandle].t[0] = cinTable[currentHandle].screenDelta; |
| 996 |
cinTable[currentHandle].t[1] = -cinTable[currentHandle].screenDelta; |
| 997 |
|
| 998 |
cinTable[currentHandle].drawX = cinTable[currentHandle].CIN_WIDTH; |
| 999 |
cinTable[currentHandle].drawY = cinTable[currentHandle].CIN_HEIGHT; |
| 1000 |
|
| 1001 |
|
| 1002 |
if ( cls.glconfig.hardwareType == GLHW_RAGEPRO || cls.glconfig.maxTextureSize <= 256) { |
| 1003 |
if (cinTable[currentHandle].drawX>256) { |
| 1004 |
cinTable[currentHandle].drawX = 256; |
| 1005 |
} |
| 1006 |
if (cinTable[currentHandle].drawY>256) { |
| 1007 |
cinTable[currentHandle].drawY = 256; |
| 1008 |
} |
| 1009 |
if (cinTable[currentHandle].CIN_WIDTH != 256 || cinTable[currentHandle].CIN_HEIGHT != 256) { |
| 1010 |
Com_Printf("HACK: approxmimating cinematic for Rage Pro or Voodoo\n"); |
| 1011 |
} |
| 1012 |
} |
| 1013 |
} |
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
static void RoQPrepMcomp( long xoff, long yoff ) |
| 1024 |
{ |
| 1025 |
long i, j, x, y, temp, temp2; |
| 1026 |
|
| 1027 |
i=cinTable[currentHandle].samplesPerLine; j=cinTable[currentHandle].samplesPerPixel; |
| 1028 |
if ( cinTable[currentHandle].xsize == (cinTable[currentHandle].ysize*4) && !cinTable[currentHandle].half ) { j = j+j; i = i+i; } |
| 1029 |
|
| 1030 |
for(y=0;y<16;y++) { |
| 1031 |
temp2 = (y+yoff-8)*i; |
| 1032 |
for(x=0;x<16;x++) { |
| 1033 |
temp = (x+xoff-8)*j; |
| 1034 |
cin.mcomp[(x*16)+y] = cinTable[currentHandle].normalBuffer0-(temp2+temp); |
| 1035 |
} |
| 1036 |
} |
| 1037 |
} |
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
static void initRoQ( void ) |
| 1048 |
{ |
| 1049 |
if (currentHandle < 0) return; |
| 1050 |
|
| 1051 |
cinTable[currentHandle].VQNormal = (void (*)(byte *, void *))blitVQQuad32fs; |
| 1052 |
cinTable[currentHandle].VQBuffer = (void (*)(byte *, void *))blitVQQuad32fs; |
| 1053 |
cinTable[currentHandle].samplesPerPixel = 4; |
| 1054 |
ROQ_GenYUVTables(); |
| 1055 |
RllSetupTable(); |
| 1056 |
} |
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
|
| 1061 |
|
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
static void RoQReset( void ) { |
| 1082 |
|
| 1083 |
if (currentHandle < 0) return; |
| 1084 |
|
| 1085 |
FS_FCloseFile( cinTable[currentHandle].iFile ); |
| 1086 |
FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue); |
| 1087 |
|
| 1088 |
FS_Read (cin.file, 16, cinTable[currentHandle].iFile); |
| 1089 |
RoQ_init(); |
| 1090 |
cinTable[currentHandle].status = FMV_LOOPED; |
| 1091 |
} |
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
static void RoQInterrupt(void) |
| 1102 |
{ |
| 1103 |
byte *framedata; |
| 1104 |
short sbuf[32768]; |
| 1105 |
int ssize; |
| 1106 |
|
| 1107 |
if (currentHandle < 0) return; |
| 1108 |
|
| 1109 |
FS_Read( cin.file, cinTable[currentHandle].RoQFrameSize+8, cinTable[currentHandle].iFile ); |
| 1110 |
if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { |
| 1111 |
if (cinTable[currentHandle].holdAtEnd==qfalse) { |
| 1112 |
if (cinTable[currentHandle].looping) { |
| 1113 |
RoQReset(); |
| 1114 |
} else { |
| 1115 |
cinTable[currentHandle].status = FMV_EOF; |
| 1116 |
} |
| 1117 |
} else { |
| 1118 |
cinTable[currentHandle].status = FMV_IDLE; |
| 1119 |
} |
| 1120 |
return; |
| 1121 |
} |
| 1122 |
|
| 1123 |
framedata = cin.file; |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
redump: |
| 1128 |
switch(cinTable[currentHandle].roq_id) |
| 1129 |
{ |
| 1130 |
case ROQ_QUAD_VQ: |
| 1131 |
if ((cinTable[currentHandle].numQuads&1)) { |
| 1132 |
cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[1]; |
| 1133 |
RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 ); |
| 1134 |
cinTable[currentHandle].VQ1( (byte *)cin.qStatus[1], framedata); |
| 1135 |
cinTable[currentHandle].buf = cin.linbuf + cinTable[currentHandle].screenDelta; |
| 1136 |
} else { |
| 1137 |
cinTable[currentHandle].normalBuffer0 = cinTable[currentHandle].t[0]; |
| 1138 |
RoQPrepMcomp( cinTable[currentHandle].roqF0, cinTable[currentHandle].roqF1 ); |
| 1139 |
cinTable[currentHandle].VQ0( (byte *)cin.qStatus[0], framedata ); |
| 1140 |
cinTable[currentHandle].buf = cin.linbuf; |
| 1141 |
} |
| 1142 |
if (cinTable[currentHandle].numQuads == 0) { |
| 1143 |
Com_Memcpy(cin.linbuf+cinTable[currentHandle].screenDelta, cin.linbuf, cinTable[currentHandle].samplesPerLine*cinTable[currentHandle].ysize); |
| 1144 |
} |
| 1145 |
cinTable[currentHandle].numQuads++; |
| 1146 |
cinTable[currentHandle].dirty = qtrue; |
| 1147 |
break; |
| 1148 |
case ROQ_CODEBOOK: |
| 1149 |
decodeCodeBook( framedata, (unsigned short)cinTable[currentHandle].roq_flags ); |
| 1150 |
break; |
| 1151 |
case ZA_SOUND_MONO: |
| 1152 |
if (!cinTable[currentHandle].silent) { |
| 1153 |
ssize = RllDecodeMonoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); |
| 1154 |
S_RawSamples(0, ssize, 22050, 2, 1, (byte *)sbuf, 1.0f, -1); |
| 1155 |
} |
| 1156 |
break; |
| 1157 |
case ZA_SOUND_STEREO: |
| 1158 |
if (!cinTable[currentHandle].silent) { |
| 1159 |
if (cinTable[currentHandle].numQuads == -1) { |
| 1160 |
S_Update(); |
| 1161 |
s_rawend[0] = s_soundtime; |
| 1162 |
} |
| 1163 |
ssize = RllDecodeStereoToStereo( framedata, sbuf, cinTable[currentHandle].RoQFrameSize, 0, (unsigned short)cinTable[currentHandle].roq_flags); |
| 1164 |
S_RawSamples(0, ssize, 22050, 2, 2, (byte *)sbuf, 1.0f, -1); |
| 1165 |
} |
| 1166 |
break; |
| 1167 |
case ROQ_QUAD_INFO: |
| 1168 |
if (cinTable[currentHandle].numQuads == -1) { |
| 1169 |
readQuadInfo( framedata ); |
| 1170 |
setupQuad( 0, 0 ); |
| 1171 |
cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); |
| 1172 |
} |
| 1173 |
if (cinTable[currentHandle].numQuads != 1) cinTable[currentHandle].numQuads = 0; |
| 1174 |
break; |
| 1175 |
case ROQ_PACKET: |
| 1176 |
cinTable[currentHandle].inMemory = cinTable[currentHandle].roq_flags; |
| 1177 |
cinTable[currentHandle].RoQFrameSize = 0; |
| 1178 |
break; |
| 1179 |
case ROQ_QUAD_HANG: |
| 1180 |
cinTable[currentHandle].RoQFrameSize = 0; |
| 1181 |
break; |
| 1182 |
case ROQ_QUAD_JPEG: |
| 1183 |
break; |
| 1184 |
default: |
| 1185 |
cinTable[currentHandle].status = FMV_EOF; |
| 1186 |
break; |
| 1187 |
} |
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
if ( cinTable[currentHandle].RoQPlayed >= cinTable[currentHandle].ROQSize ) { |
| 1192 |
if (cinTable[currentHandle].holdAtEnd==qfalse) { |
| 1193 |
if (cinTable[currentHandle].looping) { |
| 1194 |
RoQReset(); |
| 1195 |
} else { |
| 1196 |
cinTable[currentHandle].status = FMV_EOF; |
| 1197 |
} |
| 1198 |
} else { |
| 1199 |
cinTable[currentHandle].status = FMV_IDLE; |
| 1200 |
} |
| 1201 |
return; |
| 1202 |
} |
| 1203 |
|
| 1204 |
framedata += cinTable[currentHandle].RoQFrameSize; |
| 1205 |
cinTable[currentHandle].roq_id = framedata[0] + framedata[1]*256; |
| 1206 |
cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3]*256 + framedata[4]*65536; |
| 1207 |
cinTable[currentHandle].roq_flags = framedata[6] + framedata[7]*256; |
| 1208 |
cinTable[currentHandle].roqF0 = (signed char)framedata[7]; |
| 1209 |
cinTable[currentHandle].roqF1 = (signed char)framedata[6]; |
| 1210 |
|
| 1211 |
if (cinTable[currentHandle].RoQFrameSize>65536||cinTable[currentHandle].roq_id==0x1084) { |
| 1212 |
Com_DPrintf("roq_size>65536||roq_id==0x1084\n"); |
| 1213 |
cinTable[currentHandle].status = FMV_EOF; |
| 1214 |
if (cinTable[currentHandle].looping) { |
| 1215 |
RoQReset(); |
| 1216 |
} |
| 1217 |
return; |
| 1218 |
} |
| 1219 |
if (cinTable[currentHandle].inMemory && (cinTable[currentHandle].status != FMV_EOF)) { cinTable[currentHandle].inMemory--; framedata += 8; goto redump; } |
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
cinTable[currentHandle].RoQPlayed += cinTable[currentHandle].RoQFrameSize+8; |
| 1226 |
} |
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
|
| 1231 |
|
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
static void RoQ_init( void ) |
| 1237 |
{ |
| 1238 |
cinTable[currentHandle].startTime = cinTable[currentHandle].lastTime = CL_ScaledMilliseconds(); |
| 1239 |
|
| 1240 |
cinTable[currentHandle].RoQPlayed = 24; |
| 1241 |
|
| 1242 |
|
| 1243 |
cinTable[currentHandle].roqFPS = cin.file[ 6] + cin.file[ 7]*256; |
| 1244 |
|
| 1245 |
if (!cinTable[currentHandle].roqFPS) cinTable[currentHandle].roqFPS = 30; |
| 1246 |
|
| 1247 |
cinTable[currentHandle].numQuads = -1; |
| 1248 |
|
| 1249 |
cinTable[currentHandle].roq_id = cin.file[ 8] + cin.file[ 9]*256; |
| 1250 |
cinTable[currentHandle].RoQFrameSize = cin.file[10] + cin.file[11]*256 + cin.file[12]*65536; |
| 1251 |
cinTable[currentHandle].roq_flags = cin.file[14] + cin.file[15]*256; |
| 1252 |
|
| 1253 |
if (cinTable[currentHandle].RoQFrameSize > 65536 || !cinTable[currentHandle].RoQFrameSize) { |
| 1254 |
return; |
| 1255 |
} |
| 1256 |
|
| 1257 |
} |
| 1258 |
|
| 1259 |
|
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
static void RoQShutdown( void ) { |
| 1268 |
const char *s; |
| 1269 |
|
| 1270 |
if (!cinTable[currentHandle].buf) { |
| 1271 |
return; |
| 1272 |
} |
| 1273 |
|
| 1274 |
if ( cinTable[currentHandle].status == FMV_IDLE ) { |
| 1275 |
return; |
| 1276 |
} |
| 1277 |
Com_DPrintf("finished cinematic\n"); |
| 1278 |
cinTable[currentHandle].status = FMV_IDLE; |
| 1279 |
|
| 1280 |
if (cinTable[currentHandle].iFile) { |
| 1281 |
FS_FCloseFile( cinTable[currentHandle].iFile ); |
| 1282 |
cinTable[currentHandle].iFile = 0; |
| 1283 |
} |
| 1284 |
|
| 1285 |
if (cinTable[currentHandle].alterGameState) { |
| 1286 |
clc.state = CA_DISCONNECTED; |
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
s = Cvar_VariableString( "nextmap" ); |
| 1292 |
if ( s[0] ) { |
| 1293 |
Cbuf_ExecuteText( EXEC_APPEND, va("%s\n", s) ); |
| 1294 |
Cvar_Set( "nextmap", "" ); |
| 1295 |
} |
| 1296 |
CL_handle = -1; |
| 1297 |
} |
| 1298 |
cinTable[currentHandle].fileName[0] = 0; |
| 1299 |
currentHandle = -1; |
| 1300 |
} |
| 1301 |
|
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
e_status CIN_StopCinematic(int handle) { |
| 1308 |
|
| 1309 |
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF; |
| 1310 |
currentHandle = handle; |
| 1311 |
|
| 1312 |
Com_DPrintf("trFMV::stop(), closing %s\n", cinTable[currentHandle].fileName); |
| 1313 |
|
| 1314 |
if (!cinTable[currentHandle].buf) { |
| 1315 |
return FMV_EOF; |
| 1316 |
} |
| 1317 |
|
| 1318 |
if (cinTable[currentHandle].alterGameState) { |
| 1319 |
if ( clc.state != CA_CINEMATIC ) { |
| 1320 |
return cinTable[currentHandle].status; |
| 1321 |
} |
| 1322 |
} |
| 1323 |
cinTable[currentHandle].status = FMV_EOF; |
| 1324 |
RoQShutdown(); |
| 1325 |
|
| 1326 |
return FMV_EOF; |
| 1327 |
} |
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
e_status CIN_RunCinematic (int handle) |
| 1339 |
{ |
| 1340 |
int start = 0; |
| 1341 |
int thisTime = 0; |
| 1342 |
|
| 1343 |
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return FMV_EOF; |
| 1344 |
|
| 1345 |
if (cin.currentHandle != handle) { |
| 1346 |
currentHandle = handle; |
| 1347 |
cin.currentHandle = currentHandle; |
| 1348 |
cinTable[currentHandle].status = FMV_EOF; |
| 1349 |
RoQReset(); |
| 1350 |
} |
| 1351 |
|
| 1352 |
if (cinTable[handle].playonwalls < -1) |
| 1353 |
{ |
| 1354 |
return cinTable[handle].status; |
| 1355 |
} |
| 1356 |
|
| 1357 |
currentHandle = handle; |
| 1358 |
|
| 1359 |
if (cinTable[currentHandle].alterGameState) { |
| 1360 |
if ( clc.state != CA_CINEMATIC ) { |
| 1361 |
return cinTable[currentHandle].status; |
| 1362 |
} |
| 1363 |
} |
| 1364 |
|
| 1365 |
if (cinTable[currentHandle].status == FMV_IDLE) { |
| 1366 |
return cinTable[currentHandle].status; |
| 1367 |
} |
| 1368 |
|
| 1369 |
thisTime = CL_ScaledMilliseconds(); |
| 1370 |
if (cinTable[currentHandle].shader && (abs(thisTime - cinTable[currentHandle].lastTime))>100) { |
| 1371 |
cinTable[currentHandle].startTime += thisTime - cinTable[currentHandle].lastTime; |
| 1372 |
} |
| 1373 |
cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); |
| 1374 |
|
| 1375 |
start = cinTable[currentHandle].startTime; |
| 1376 |
while( (cinTable[currentHandle].tfps != cinTable[currentHandle].numQuads) |
| 1377 |
&& (cinTable[currentHandle].status == FMV_PLAY) ) |
| 1378 |
{ |
| 1379 |
RoQInterrupt(); |
| 1380 |
if (start != cinTable[currentHandle].startTime) { |
| 1381 |
cinTable[currentHandle].tfps = (((CL_ScaledMilliseconds() - cinTable[currentHandle].startTime)*3)/100); |
| 1382 |
start = cinTable[currentHandle].startTime; |
| 1383 |
} |
| 1384 |
} |
| 1385 |
|
| 1386 |
cinTable[currentHandle].lastTime = thisTime; |
| 1387 |
|
| 1388 |
if (cinTable[currentHandle].status == FMV_LOOPED) { |
| 1389 |
cinTable[currentHandle].status = FMV_PLAY; |
| 1390 |
} |
| 1391 |
|
| 1392 |
if (cinTable[currentHandle].status == FMV_EOF) { |
| 1393 |
if (cinTable[currentHandle].looping) { |
| 1394 |
RoQReset(); |
| 1395 |
} else { |
| 1396 |
RoQShutdown(); |
| 1397 |
return FMV_EOF; |
| 1398 |
} |
| 1399 |
} |
| 1400 |
|
| 1401 |
return cinTable[currentHandle].status; |
| 1402 |
} |
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBits ) { |
| 1410 |
unsigned short RoQID; |
| 1411 |
char name[MAX_OSPATH]; |
| 1412 |
int i; |
| 1413 |
|
| 1414 |
if (strstr(arg, "/") == NULL && strstr(arg, "\\") == NULL) { |
| 1415 |
Com_sprintf (name, sizeof(name), "video/%s", arg); |
| 1416 |
} else { |
| 1417 |
Com_sprintf (name, sizeof(name), "%s", arg); |
| 1418 |
} |
| 1419 |
|
| 1420 |
if (!(systemBits & CIN_system)) { |
| 1421 |
for ( i = 0 ; i < MAX_VIDEO_HANDLES ; i++ ) { |
| 1422 |
if (!strcmp(cinTable[i].fileName, name) ) { |
| 1423 |
return i; |
| 1424 |
} |
| 1425 |
} |
| 1426 |
} |
| 1427 |
|
| 1428 |
Com_DPrintf("CIN_PlayCinematic( %s )\n", arg); |
| 1429 |
|
| 1430 |
Com_Memset(&cin, 0, sizeof(cinematics_t) ); |
| 1431 |
currentHandle = CIN_HandleForVideo(); |
| 1432 |
|
| 1433 |
cin.currentHandle = currentHandle; |
| 1434 |
|
| 1435 |
strcpy(cinTable[currentHandle].fileName, name); |
| 1436 |
|
| 1437 |
cinTable[currentHandle].ROQSize = 0; |
| 1438 |
cinTable[currentHandle].ROQSize = FS_FOpenFileRead (cinTable[currentHandle].fileName, &cinTable[currentHandle].iFile, qtrue); |
| 1439 |
|
| 1440 |
if (cinTable[currentHandle].ROQSize<=0) { |
| 1441 |
Com_DPrintf("play(%s), ROQSize<=0\n", arg); |
| 1442 |
cinTable[currentHandle].fileName[0] = 0; |
| 1443 |
return -1; |
| 1444 |
} |
| 1445 |
|
| 1446 |
CIN_SetExtents(currentHandle, x, y, w, h); |
| 1447 |
CIN_SetLooping(currentHandle, (systemBits & CIN_loop)!=0); |
| 1448 |
|
| 1449 |
cinTable[currentHandle].CIN_HEIGHT = DEFAULT_CIN_HEIGHT; |
| 1450 |
cinTable[currentHandle].CIN_WIDTH = DEFAULT_CIN_WIDTH; |
| 1451 |
cinTable[currentHandle].holdAtEnd = (systemBits & CIN_hold) != 0; |
| 1452 |
cinTable[currentHandle].alterGameState = (systemBits & CIN_system) != 0; |
| 1453 |
cinTable[currentHandle].playonwalls = 1; |
| 1454 |
cinTable[currentHandle].silent = (systemBits & CIN_silent) != 0; |
| 1455 |
cinTable[currentHandle].shader = (systemBits & CIN_shader) != 0; |
| 1456 |
|
| 1457 |
if (cinTable[currentHandle].alterGameState) { |
| 1458 |
|
| 1459 |
if ( uivm ) { |
| 1460 |
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE ); |
| 1461 |
} |
| 1462 |
} else { |
| 1463 |
cinTable[currentHandle].playonwalls = cl_inGameVideo->integer; |
| 1464 |
} |
| 1465 |
|
| 1466 |
initRoQ(); |
| 1467 |
|
| 1468 |
FS_Read (cin.file, 16, cinTable[currentHandle].iFile); |
| 1469 |
|
| 1470 |
RoQID = (unsigned short)(cin.file[0]) + (unsigned short)(cin.file[1])*256; |
| 1471 |
if (RoQID == 0x1084) |
| 1472 |
{ |
| 1473 |
RoQ_init(); |
| 1474 |
|
| 1475 |
|
| 1476 |
cinTable[currentHandle].status = FMV_PLAY; |
| 1477 |
Com_DPrintf("trFMV::play(), playing %s\n", arg); |
| 1478 |
|
| 1479 |
if (cinTable[currentHandle].alterGameState) { |
| 1480 |
clc.state = CA_CINEMATIC; |
| 1481 |
} |
| 1482 |
|
| 1483 |
Con_Close(); |
| 1484 |
|
| 1485 |
if (!cinTable[currentHandle].silent) { |
| 1486 |
s_rawend[0] = s_soundtime; |
| 1487 |
} |
| 1488 |
|
| 1489 |
return currentHandle; |
| 1490 |
} |
| 1491 |
Com_DPrintf("trFMV::play(), invalid RoQ ID\n"); |
| 1492 |
|
| 1493 |
RoQShutdown(); |
| 1494 |
return -1; |
| 1495 |
} |
| 1496 |
|
| 1497 |
void CIN_SetExtents (int handle, int x, int y, int w, int h) { |
| 1498 |
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; |
| 1499 |
cinTable[handle].xpos = x; |
| 1500 |
cinTable[handle].ypos = y; |
| 1501 |
cinTable[handle].width = w; |
| 1502 |
cinTable[handle].height = h; |
| 1503 |
cinTable[handle].dirty = qtrue; |
| 1504 |
} |
| 1505 |
|
| 1506 |
void CIN_SetLooping(int handle, qboolean loop) { |
| 1507 |
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; |
| 1508 |
cinTable[handle].looping = loop; |
| 1509 |
} |
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
void CIN_ResampleCinematic(int handle, int *buf2) { |
| 1519 |
int ix, iy, *buf3, xm, ym, ll; |
| 1520 |
byte *buf; |
| 1521 |
|
| 1522 |
buf = cinTable[handle].buf; |
| 1523 |
|
| 1524 |
xm = cinTable[handle].CIN_WIDTH/256; |
| 1525 |
ym = cinTable[handle].CIN_HEIGHT/256; |
| 1526 |
ll = 8; |
| 1527 |
if (cinTable[handle].CIN_WIDTH==512) { |
| 1528 |
ll = 9; |
| 1529 |
} |
| 1530 |
|
| 1531 |
buf3 = (int*)buf; |
| 1532 |
if (xm==2 && ym==2) { |
| 1533 |
byte *bc2, *bc3; |
| 1534 |
int ic, iiy; |
| 1535 |
|
| 1536 |
bc2 = (byte *)buf2; |
| 1537 |
bc3 = (byte *)buf3; |
| 1538 |
for (iy = 0; iy<256; iy++) { |
| 1539 |
iiy = iy<<12; |
| 1540 |
for (ix = 0; ix<2048; ix+=8) { |
| 1541 |
for(ic = ix;ic<(ix+4);ic++) { |
| 1542 |
*bc2=(bc3[iiy+ic]+bc3[iiy+4+ic]+bc3[iiy+2048+ic]+bc3[iiy+2048+4+ic])>>2; |
| 1543 |
bc2++; |
| 1544 |
} |
| 1545 |
} |
| 1546 |
} |
| 1547 |
} else if (xm==2 && ym==1) { |
| 1548 |
byte *bc2, *bc3; |
| 1549 |
int ic, iiy; |
| 1550 |
|
| 1551 |
bc2 = (byte *)buf2; |
| 1552 |
bc3 = (byte *)buf3; |
| 1553 |
for (iy = 0; iy<256; iy++) { |
| 1554 |
iiy = iy<<11; |
| 1555 |
for (ix = 0; ix<2048; ix+=8) { |
| 1556 |
for(ic = ix;ic<(ix+4);ic++) { |
| 1557 |
*bc2=(bc3[iiy+ic]+bc3[iiy+4+ic])>>1; |
| 1558 |
bc2++; |
| 1559 |
} |
| 1560 |
} |
| 1561 |
} |
| 1562 |
} else { |
| 1563 |
for (iy = 0; iy<256; iy++) { |
| 1564 |
for (ix = 0; ix<256; ix++) { |
| 1565 |
buf2[(iy<<8)+ix] = buf3[((iy*ym)<<ll) + (ix*xm)]; |
| 1566 |
} |
| 1567 |
} |
| 1568 |
} |
| 1569 |
} |
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
void CIN_DrawCinematic (int handle) { |
| 1577 |
float x, y, w, h; |
| 1578 |
byte *buf; |
| 1579 |
|
| 1580 |
if (handle < 0 || handle>= MAX_VIDEO_HANDLES || cinTable[handle].status == FMV_EOF) return; |
| 1581 |
|
| 1582 |
if (!cinTable[handle].buf) { |
| 1583 |
return; |
| 1584 |
} |
| 1585 |
|
| 1586 |
x = cinTable[handle].xpos; |
| 1587 |
y = cinTable[handle].ypos; |
| 1588 |
w = cinTable[handle].width; |
| 1589 |
h = cinTable[handle].height; |
| 1590 |
buf = cinTable[handle].buf; |
| 1591 |
SCR_AdjustFrom640( &x, &y, &w, &h ); |
| 1592 |
|
| 1593 |
if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) { |
| 1594 |
int *buf2; |
| 1595 |
|
| 1596 |
buf2 = Hunk_AllocateTempMemory( 256*256*4 ); |
| 1597 |
|
| 1598 |
CIN_ResampleCinematic(handle, buf2); |
| 1599 |
|
| 1600 |
re.DrawStretchRaw( x, y, w, h, 256, 256, (byte *)buf2, handle, qtrue); |
| 1601 |
cinTable[handle].dirty = qfalse; |
| 1602 |
Hunk_FreeTempMemory(buf2); |
| 1603 |
return; |
| 1604 |
} |
| 1605 |
|
| 1606 |
re.DrawStretchRaw( x, y, w, h, cinTable[handle].drawX, cinTable[handle].drawY, buf, handle, cinTable[handle].dirty); |
| 1607 |
cinTable[handle].dirty = qfalse; |
| 1608 |
} |
| 1609 |
|
| 1610 |
void CL_PlayCinematic_f(void) { |
| 1611 |
char *arg, *s; |
| 1612 |
int bits = CIN_system; |
| 1613 |
|
| 1614 |
Com_DPrintf("CL_PlayCinematic_f\n"); |
| 1615 |
if (clc.state == CA_CINEMATIC) { |
| 1616 |
SCR_StopCinematic(); |
| 1617 |
} |
| 1618 |
|
| 1619 |
arg = Cmd_Argv( 1 ); |
| 1620 |
s = Cmd_Argv(2); |
| 1621 |
|
| 1622 |
if ((s && s[0] == '1') || Q_stricmp(arg,"demoend.roq")==0 || Q_stricmp(arg,"end.roq")==0) { |
| 1623 |
bits |= CIN_hold; |
| 1624 |
} |
| 1625 |
if (s && s[0] == '2') { |
| 1626 |
bits |= CIN_loop; |
| 1627 |
} |
| 1628 |
|
| 1629 |
S_StopAllSounds (); |
| 1630 |
|
| 1631 |
CL_handle = CIN_PlayCinematic( arg, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, bits ); |
| 1632 |
if (CL_handle >= 0) { |
| 1633 |
do { |
| 1634 |
SCR_RunCinematic(); |
| 1635 |
} while (cinTable[currentHandle].buf == NULL && cinTable[currentHandle].status == FMV_PLAY); |
| 1636 |
} |
| 1637 |
} |
| 1638 |
|
| 1639 |
|
| 1640 |
void SCR_DrawCinematic (void) { |
| 1641 |
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { |
| 1642 |
CIN_DrawCinematic(CL_handle); |
| 1643 |
} |
| 1644 |
} |
| 1645 |
|
| 1646 |
void SCR_RunCinematic (void) |
| 1647 |
{ |
| 1648 |
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { |
| 1649 |
CIN_RunCinematic(CL_handle); |
| 1650 |
} |
| 1651 |
} |
| 1652 |
|
| 1653 |
void SCR_StopCinematic(void) { |
| 1654 |
if (CL_handle >= 0 && CL_handle < MAX_VIDEO_HANDLES) { |
| 1655 |
CIN_StopCinematic(CL_handle); |
| 1656 |
S_StopAllSounds (); |
| 1657 |
CL_handle = -1; |
| 1658 |
} |
| 1659 |
} |
| 1660 |
|
| 1661 |
void CIN_UploadCinematic(int handle) { |
| 1662 |
if (handle >= 0 && handle < MAX_VIDEO_HANDLES) { |
| 1663 |
if (!cinTable[handle].buf) { |
| 1664 |
return; |
| 1665 |
} |
| 1666 |
if (cinTable[handle].playonwalls <= 0 && cinTable[handle].dirty) { |
| 1667 |
if (cinTable[handle].playonwalls == 0) { |
| 1668 |
cinTable[handle].playonwalls = -1; |
| 1669 |
} else { |
| 1670 |
if (cinTable[handle].playonwalls == -1) { |
| 1671 |
cinTable[handle].playonwalls = -2; |
| 1672 |
} else { |
| 1673 |
cinTable[handle].dirty = qfalse; |
| 1674 |
} |
| 1675 |
} |
| 1676 |
} |
| 1677 |
|
| 1678 |
|
| 1679 |
if (cinTable[handle].dirty && (cinTable[handle].CIN_WIDTH != cinTable[handle].drawX || cinTable[handle].CIN_HEIGHT != cinTable[handle].drawY)) { |
| 1680 |
int *buf2; |
| 1681 |
|
| 1682 |
buf2 = Hunk_AllocateTempMemory( 256*256*4 ); |
| 1683 |
|
| 1684 |
CIN_ResampleCinematic(handle, buf2); |
| 1685 |
|
| 1686 |
re.UploadCinematic( cinTable[handle].CIN_WIDTH, cinTable[handle].CIN_HEIGHT, 256, 256, (byte *)buf2, handle, qtrue); |
| 1687 |
cinTable[handle].dirty = qfalse; |
| 1688 |
Hunk_FreeTempMemory(buf2); |
| 1689 |
} else { |
| 1690 |
|
| 1691 |
re.UploadCinematic( cinTable[handle].CIN_WIDTH, cinTable[handle].CIN_HEIGHT, cinTable[handle].drawX, cinTable[handle].drawY, |
| 1692 |
cinTable[handle].buf, handle, cinTable[handle].dirty); |
| 1693 |
cinTable[handle].dirty = qfalse; |
| 1694 |
} |
| 1695 |
|
| 1696 |
if (cl_inGameVideo->integer == 0 && cinTable[handle].playonwalls == 1) { |
| 1697 |
cinTable[handle].playonwalls--; |
| 1698 |
} |
| 1699 |
else if (cl_inGameVideo->integer != 0 && cinTable[handle].playonwalls != 1) { |
| 1700 |
cinTable[handle].playonwalls = 1; |
| 1701 |
} |
| 1702 |
} |
| 1703 |
} |
| 1704 |
|