|
|
1.1 root 1: 1.1.1.3 ! root 2: //************************************************************************** ! 3: //** ! 4: //** r_main.c : Heretic 2 : Raven Software, Corp. ! 5: //** ! 6: //** $RCSfile: r_main.c,v $ ! 7: //** $Revision: 1.16 $ ! 8: //** $Date: 96/01/06 18:37:41 $ ! 9: //** $Author: bgokey $ ! 10: //** ! 11: //************************************************************************** 1.1 root 12: 1.1.1.3 ! root 13: #include <math.h> ! 14: #include "h2def.h" ! 15: #include "r_local.h" 1.1 root 16: 1.1.1.2 root 17: int viewangleoffset; 1.1 root 18: 1.1.1.2 root 19: #ifdef __WATCOMC__ 20: int newViewAngleOff; 21: #endif 1.1 root 22: 1.1.1.2 root 23: int validcount = 1; // increment every time a check is made 1.1 root 24: 1.1.1.2 root 25: lighttable_t *fixedcolormap; 26: extern lighttable_t **walllights; 1.1 root 27: 1.1.1.2 root 28: int centerx, centery; 29: fixed_t centerxfrac, centeryfrac; 30: fixed_t projection; 1.1 root 31: 1.1.1.2 root 32: int framecount; // just for profiling purposes 1.1 root 33: 1.1.1.2 root 34: int sscount, linecount, loopcount; 1.1 root 35: 36: fixed_t viewx, viewy, viewz; 37: angle_t viewangle; 38: fixed_t viewcos, viewsin; 39: player_t *viewplayer; 40: 1.1.1.2 root 41: int detailshift; // 0 = high, 1 = low 42: 43: // 44: // precalculated math tables 45: // 46: angle_t clipangle; 47: 48: // The viewangletox[viewangle + FINEANGLES/4] lookup maps the visible view 49: // angles to screen X coordinates, flattening the arc to a flat projection 50: // plane. There will be many angles mapped to the same X. 51: int viewangletox[FINEANGLES/2]; 52: 53: // The xtoviewangleangle[] table maps a screen pixel to the lowest viewangle 54: // that maps back to x ranges from clipangle to -clipangle 55: angle_t xtoviewangle[SCREENWIDTH+1]; 56: 57: // the finetangentgent[angle+FINEANGLES/4] table holds the fixed_t tangent 58: // values for view angles, ranging from MININT to 0 to MAXINT. 59: // fixed_t finetangent[FINEANGLES/2]; 60: 61: // fixed_t finesine[5*FINEANGLES/4]; 62: fixed_t *finecosine = &finesine[FINEANGLES/4]; 63: 1.1 root 64: 1.1.1.2 root 65: lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; 66: lighttable_t *scalelightfixed[MAXLIGHTSCALE]; 67: lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; 68: 69: int extralight; // bumped light from gun blasts 70: 71: void (*colfunc) (void); 72: void (*basecolfunc) (void); 73: void (*fuzzcolfunc) (void); 74: void (*transcolfunc) (void); 75: void (*spanfunc) (void); 1.1 root 76: 1.1.1.2 root 77: /* 78: =================== 79: = 80: = R_AddPointToBox 81: = 82: =================== 83: */ 1.1 root 84: 1.1.1.3 ! root 85: /* 1.1.1.2 root 86: void R_AddPointToBox (int x, int y, fixed_t *box) 87: { 88: if (x< box[BOXLEFT]) 89: box[BOXLEFT] = x; 90: if (x> box[BOXRIGHT]) 91: box[BOXRIGHT] = x; 92: if (y< box[BOXBOTTOM]) 93: box[BOXBOTTOM] = y; 94: if (y> box[BOXTOP]) 95: box[BOXTOP] = y; 96: } 1.1.1.3 ! root 97: */ 1.1 root 98: 99: 1.1.1.2 root 100: /* 101: =============================================================================== 102: = 103: = R_PointOnSide 104: = 105: = Returns side 0 (front) or 1 (back) 106: =============================================================================== 107: */ 108: 109: int R_PointOnSide (fixed_t x, fixed_t y, node_t *node) 110: { 111: fixed_t dx,dy; 112: fixed_t left, right; 113: 114: if (!node->dx) 115: { 116: if (x <= node->x) 117: return node->dy > 0; 118: return node->dy < 0; 119: } 120: if (!node->dy) 121: { 122: if (y <= node->y) 123: return node->dx < 0; 124: return node->dx > 0; 125: } 126: 127: dx = (x - node->x); 128: dy = (y - node->y); 129: 130: // try to quickly decide by looking at sign bits 131: if ( (node->dy ^ node->dx ^ dx ^ dy)&0x80000000 ) 132: { 133: if ( (node->dy ^ dx) & 0x80000000 ) 134: return 1; // (left is negative) 135: return 0; 136: } 137: 138: left = FixedMul ( node->dy>>FRACBITS , dx ); 139: right = FixedMul ( dy , node->dx>>FRACBITS ); 140: 141: if (right < left) 142: return 0; // front side 143: return 1; // back side 144: } 145: 146: 147: int R_PointOnSegSide (fixed_t x, fixed_t y, seg_t *line) 148: { 149: fixed_t lx, ly; 150: fixed_t ldx, ldy; 151: fixed_t dx,dy; 152: fixed_t left, right; 153: 154: lx = line->v1->x; 155: ly = line->v1->y; 156: 157: ldx = line->v2->x - lx; 158: ldy = line->v2->y - ly; 159: 160: if (!ldx) 161: { 162: if (x <= lx) 163: return ldy > 0; 164: return ldy < 0; 165: } 166: if (!ldy) 167: { 168: if (y <= ly) 169: return ldx < 0; 170: return ldx > 0; 171: } 172: 173: dx = (x - lx); 174: dy = (y - ly); 175: 176: // try to quickly decide by looking at sign bits 177: if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 ) 178: { 179: if ( (ldy ^ dx) & 0x80000000 ) 180: return 1; // (left is negative) 181: return 0; 182: } 183: 184: left = FixedMul ( ldy>>FRACBITS , dx ); 185: right = FixedMul ( dy , ldx>>FRACBITS ); 186: 187: if (right < left) 188: return 0; // front side 189: return 1; // back side 190: } 191: 1.1 root 192: 193: /* 194: =============================================================================== 195: = 196: = R_PointToAngle 197: = 198: =============================================================================== 199: */ 200: 1.1.1.2 root 201: // to get a global angle from cartesian coordinates, the coordinates are 202: // flipped until they are in the first octant of the coordinate system, then 203: // the y (<=x) is scaled and divided by x to get a tangent (slope) value 204: // which is looked up in the tantoangle[] table. The +1 size is to handle 205: // the case when x==y without additional checking. 206: #define SLOPERANGE 2048 207: #define SLOPEBITS 11 208: #define DBITS (FRACBITS-SLOPEBITS) 209: 1.1 root 210: 1.1.1.2 root 211: extern int tantoangle[SLOPERANGE+1]; // get from tables.c 212: 213: // int tantoangle[SLOPERANGE+1]; 1.1 root 214: 215: int SlopeDiv (unsigned num, unsigned den) 216: { 217: unsigned ans; 218: if (den < 512) 219: return SLOPERANGE; 220: ans = (num<<3)/(den>>8); 221: return ans <= SLOPERANGE ? ans : SLOPERANGE; 222: } 223: 1.1.1.2 root 224: angle_t R_PointToAngle (fixed_t x, fixed_t y) 225: { 226: x -= viewx; 227: y -= viewy; 1.1 root 228: if ( (!x) && (!y) ) 229: return 0; 230: if (x>= 0) 1.1.1.2 root 231: { // x >=0 1.1 root 232: if (y>= 0) 1.1.1.2 root 233: { // y>= 0 1.1 root 234: if (x>y) 1.1.1.2 root 235: return tantoangle[ SlopeDiv(y,x)]; // octant 0 1.1 root 236: else 1.1.1.2 root 237: return ANG90-1-tantoangle[ SlopeDiv(x,y)]; // octant 1 1.1 root 238: } 239: else 1.1.1.2 root 240: { // y<0 1.1 root 241: y = -y; 242: if (x>y) 1.1.1.2 root 243: return -tantoangle[SlopeDiv(y,x)]; // octant 8 1.1 root 244: else 1.1.1.2 root 245: return ANG270+tantoangle[ SlopeDiv(x,y)]; // octant 7 1.1 root 246: } 247: } 248: else 1.1.1.2 root 249: { // x<0 1.1 root 250: x = -x; 251: if (y>= 0) 1.1.1.2 root 252: { // y>= 0 1.1 root 253: if (x>y) 1.1.1.2 root 254: return ANG180-1-tantoangle[ SlopeDiv(y,x)]; // octant 3 1.1 root 255: else 1.1.1.2 root 256: return ANG90+ tantoangle[ SlopeDiv(x,y)]; // octant 2 1.1 root 257: } 258: else 1.1.1.2 root 259: { // y<0 1.1 root 260: y = -y; 261: if (x>y) 1.1.1.2 root 262: return ANG180+tantoangle[ SlopeDiv(y,x)]; // octant 4 1.1 root 263: else 1.1.1.2 root 264: return ANG270-1-tantoangle[ SlopeDiv(x,y)]; // octant 5 1.1 root 265: } 1.1.1.2 root 266: } 267: 1.1 root 268: return 0; 269: } 270: 271: 1.1.1.2 root 272: angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2) 273: { 274: viewx = x1; 275: viewy = y1; 276: return R_PointToAngle (x2, y2); 277: } 278: 279: 280: fixed_t R_PointToDist (fixed_t x, fixed_t y) 281: { 282: int angle; 283: fixed_t dx, dy, temp; 284: fixed_t dist; 285: 286: dx = abs(x - viewx); 287: dy = abs(y - viewy); 288: 289: if (dy>dx) 290: { 291: temp = dx; 292: dx = dy; 293: dy = temp; 294: } 295: 296: angle = (tantoangle[ FixedDiv(dy,dx)>>DBITS ]+ANG90) >> ANGLETOFINESHIFT; 297: 298: dist = FixedDiv (dx, finesine[angle] ); // use as cosine 299: 300: return dist; 301: } 302: 303: 304: 1.1 root 305: /* 1.1.1.2 root 306: ================= 1.1 root 307: = 1.1.1.2 root 308: = R_InitPointToAngle 1.1 root 309: = 1.1.1.2 root 310: ================= 1.1 root 311: */ 312: 1.1.1.2 root 313: void R_InitPointToAngle (void) 1.1 root 314: { 1.1.1.2 root 315: // now getting from tables.c 316: #if 0 317: int i; 318: long t; 319: float f; 320: // 321: // slope (tangent) to angle lookup 322: // 323: for (i=0 ; i<=SLOPERANGE ; i++) 1.1 root 324: { 1.1.1.2 root 325: f = atan( (float)i/SLOPERANGE )/(3.141592657*2); 326: t = 0xffffffff*f; 327: tantoangle[i] = t; 1.1 root 328: } 1.1.1.2 root 329: #endif 330: } 331: 332: //============================================================================= 333: 334: /* 335: ================ 336: = 337: = R_ScaleFromGlobalAngle 338: = 339: = Returns the texture mapping scale for the current line at the given angle 340: = rw_distance must be calculated first 341: ================ 342: */ 343: 344: fixed_t R_ScaleFromGlobalAngle (angle_t visangle) 345: { 346: fixed_t scale; 347: int anglea, angleb; 348: int sinea, sineb; 349: fixed_t num,den; 350: 351: #if 0 352: { 353: fixed_t dist,z; 354: fixed_t sinv, cosv; 355: 356: sinv = finesine[(visangle-rw_normalangle)>>ANGLETOFINESHIFT]; 357: dist = FixedDiv (rw_distance, sinv); 358: cosv = finecosine[(viewangle-visangle)>>ANGLETOFINESHIFT]; 359: z = abs(FixedMul (dist, cosv)); 360: scale = FixedDiv(projection, z); 361: return scale; 362: } 363: #endif 364: 365: anglea = ANG90 + (visangle-viewangle); 366: angleb = ANG90 + (visangle-rw_normalangle); 367: // bothe sines are allways positive 368: sinea = finesine[anglea>>ANGLETOFINESHIFT]; 369: sineb = finesine[angleb>>ANGLETOFINESHIFT]; 370: num = FixedMul(projection,sineb)<<detailshift; 371: den = FixedMul(rw_distance,sinea); 372: if (den > num>>16) 1.1 root 373: { 1.1.1.2 root 374: scale = FixedDiv (num, den); 375: if (scale > 64*FRACUNIT) 376: scale = 64*FRACUNIT; 377: else if (scale < 256) 378: scale = 256; 1.1 root 379: } 1.1.1.2 root 380: else 381: scale = 64*FRACUNIT; 382: 383: return scale; 1.1 root 384: } 385: 386: 387: 388: /* 1.1.1.2 root 389: ================= 1.1 root 390: = 1.1.1.2 root 391: = R_InitTables 1.1 root 392: = 1.1.1.2 root 393: ================= 1.1 root 394: */ 395: 1.1.1.2 root 396: void R_InitTables (void) 1.1 root 397: { 1.1.1.2 root 398: // now getting from tables.c 399: #if 0 400: int i; 401: float a, fv; 402: int t; 403: 404: // 405: // viewangle tangent table 406: // 407: for (i=0 ; i<FINEANGLES/2 ; i++) 408: { 409: a = (i-FINEANGLES/4+0.5)*PI*2/FINEANGLES; 410: fv = FRACUNIT*tan (a); 411: t = fv; 412: finetangent[i] = t; 413: } 1.1 root 414: 1.1.1.2 root 415: // 416: // finesine table 417: // 418: for (i=0 ; i<5*FINEANGLES/4 ; i++) 1.1 root 419: { 1.1.1.2 root 420: // OPTIMIZE: mirror... 421: a = (i+0.5)*PI*2/FINEANGLES; 422: t = FRACUNIT*sin (a); 423: finesine[i] = t; 1.1 root 424: } 1.1.1.2 root 425: #endif 1.1 root 426: 1.1.1.2 root 427: } 1.1 root 428: 429: 430: /* 1.1.1.2 root 431: ================= 1.1 root 432: = 1.1.1.2 root 433: = R_InitTextureMapping 1.1 root 434: = 1.1.1.2 root 435: ================= 1.1 root 436: */ 437: 1.1.1.2 root 438: void R_InitTextureMapping (void) 1.1 root 439: { 1.1.1.2 root 440: int i; 441: int x; 442: int t; 443: fixed_t focallength; 1.1 root 444: 445: 1.1.1.2 root 446: // 447: // use tangent table to generate viewangletox 448: // viewangletox will give the next greatest x after the view angle 449: // 450: // calc focallength so FIELDOFVIEW angles covers SCREENWIDTH 451: focallength = FixedDiv (centerxfrac 452: , finetangent[FINEANGLES/4+FIELDOFVIEW/2] ); 453: 454: for (i=0 ; i<FINEANGLES/2 ; i++) 455: { 456: if (finetangent[i] > FRACUNIT*2) 457: t = -1; 458: else if (finetangent[i] < -FRACUNIT*2) 459: t = viewwidth+1; 460: else 461: { 462: t = FixedMul (finetangent[i], focallength); 463: t = (centerxfrac - t+FRACUNIT-1)>>FRACBITS; 464: if (t < -1) 465: t = -1; 466: else if (t>viewwidth+1) 467: t = viewwidth+1; 468: } 469: viewangletox[i] = t; 470: } 1.1 root 471: 1.1.1.2 root 472: // 473: // scan viewangletox[] to generate xtoviewangleangle[] 474: // 475: // xtoviewangle will give the smallest view angle that maps to x 476: for (x=0;x<=viewwidth;x++) 477: { 478: i = 0; 479: while (viewangletox[i]>x) 480: i++; 481: xtoviewangle[x] = (i<<ANGLETOFINESHIFT)-ANG90; 482: } 1.1 root 483: 1.1.1.2 root 484: // 485: // take out the fencepost cases from viewangletox 486: // 487: for (i=0 ; i<FINEANGLES/2 ; i++) 488: { 489: t = FixedMul (finetangent[i], focallength); 490: t = centerx - t; 491: if (viewangletox[i] == -1) 492: viewangletox[i] = 0; 493: else if (viewangletox[i] == viewwidth+1) 494: viewangletox[i] = viewwidth; 495: } 1.1 root 496: 1.1.1.2 root 497: clipangle = xtoviewangle[0]; 498: } 1.1 root 499: 1.1.1.2 root 500: //============================================================================= 1.1 root 501: 502: /* 1.1.1.2 root 503: ==================== 1.1 root 504: = 1.1.1.2 root 505: = R_InitLightTables 1.1 root 506: = 1.1.1.2 root 507: = Only inits the zlight table, because the scalelight table changes 508: = with view size 509: = 510: ==================== 1.1 root 511: */ 512: 1.1.1.2 root 513: #define DISTMAP 2 1.1 root 514: 1.1.1.2 root 515: void R_InitLightTables (void) 516: { 517: int i,j, level, startmap; 518: int scale; 1.1 root 519: 1.1.1.2 root 520: // 521: // Calculate the light levels to use for each level / distance combination 522: // 523: for (i=0 ; i< LIGHTLEVELS ; i++) 524: { 525: startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; 526: for (j=0 ; j<MAXLIGHTZ ; j++) 527: { 528: scale = FixedDiv ((SCREENWIDTH/2*FRACUNIT), (j+1)<<LIGHTZSHIFT); 529: scale >>= LIGHTSCALESHIFT; 530: level = startmap - scale/DISTMAP; 531: if (level < 0) 532: level = 0; 533: if (level >= NUMCOLORMAPS) 534: level = NUMCOLORMAPS-1; 535: zlight[i][j] = colormaps + level*256; 536: } 537: } 538: } 1.1 root 539: 540: 1.1.1.2 root 541: /* 542: ============== 543: = 544: = R_SetViewSize 545: = 546: = Don't really change anything here, because i might be in the middle of 547: = a refresh. The change will take effect next refresh. 548: = 549: ============== 550: */ 1.1 root 551: 1.1.1.2 root 552: boolean setsizeneeded; 553: int setblocks, setdetail; 1.1 root 554: 1.1.1.2 root 555: void R_SetViewSize (int blocks, int detail) 556: { 557: setsizeneeded = true; 558: setblocks = blocks; 559: setdetail = detail; 1.1 root 560: } 561: 562: /* 1.1.1.2 root 563: ============== 1.1 root 564: = 1.1.1.2 root 565: = R_ExecuteSetViewSize 1.1 root 566: = 1.1.1.2 root 567: ============== 1.1 root 568: */ 569: 1.1.1.2 root 570: void R_ExecuteSetViewSize (void) 1.1 root 571: { 1.1.1.2 root 572: fixed_t cosadj, dy; 573: int i,j, level, startmap; 1.1 root 574: 1.1.1.2 root 575: setsizeneeded = false; 1.1 root 576: 1.1.1.2 root 577: if (setblocks == 11) 578: { 579: scaledviewwidth = SCREENWIDTH; 580: viewheight = SCREENHEIGHT; 581: } 582: else 583: { 584: scaledviewwidth = setblocks*32; 1.1.1.3 ! root 585: viewheight = (setblocks*161/10); 1.1.1.2 root 586: } 1.1 root 587: 1.1.1.2 root 588: detailshift = setdetail; 589: viewwidth = scaledviewwidth>>detailshift; 590: 591: centery = viewheight/2; 592: centerx = viewwidth/2; 593: centerxfrac = centerx<<FRACBITS; 594: centeryfrac = centery<<FRACBITS; 595: projection = centerxfrac; 596: 597: if (!detailshift) 598: { 599: colfunc = basecolfunc = R_DrawColumn; 600: fuzzcolfunc = R_DrawFuzzColumn; 601: transcolfunc = R_DrawTranslatedColumn; 602: spanfunc = R_DrawSpan; 603: } 604: else 605: { 606: colfunc = basecolfunc = R_DrawColumnLow; 607: fuzzcolfunc = R_DrawFuzzColumn; 608: transcolfunc = R_DrawTranslatedColumn; 609: spanfunc = R_DrawSpanLow; 610: } 611: 612: R_InitBuffer (scaledviewwidth, viewheight); 613: 614: R_InitTextureMapping (); 615: 616: // 617: // psprite scales 618: // 619: pspritescale = FRACUNIT*viewwidth/SCREENWIDTH; 620: pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth; 621: 622: // 623: // thing clipping 624: // 625: for (i=0 ; i<viewwidth ; i++) 626: screenheightarray[i] = viewheight; 627: 628: // 629: // planes 630: // 631: for (i=0 ; i<viewheight ; i++) 632: { 633: dy = ((i-viewheight/2)<<FRACBITS)+FRACUNIT/2; 634: dy = abs(dy); 635: yslope[i] = FixedDiv ( (viewwidth<<detailshift)/2*FRACUNIT, dy); 636: } 1.1 root 637: 1.1.1.2 root 638: for (i=0 ; i<viewwidth ; i++) 639: { 640: cosadj = abs(finecosine[xtoviewangle[i]>>ANGLETOFINESHIFT]); 641: distscale[i] = FixedDiv (FRACUNIT,cosadj); 642: } 643: 644: // 645: // Calculate the light levels to use for each level / scale combination 646: // 647: for (i=0 ; i< LIGHTLEVELS ; i++) 648: { 649: startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; 650: for (j=0 ; j<MAXLIGHTSCALE ; j++) 651: { 652: level = startmap - j*SCREENWIDTH/(viewwidth<<detailshift)/DISTMAP; 653: if (level < 0) 654: level = 0; 655: if (level >= NUMCOLORMAPS) 656: level = NUMCOLORMAPS-1; 657: scalelight[i][j] = colormaps + level*256; 658: } 659: } 1.1 root 660: 1.1.1.2 root 661: // 662: // draw the border 663: // 664: R_DrawViewBorder (); // erase old menu stuff 665: } 1.1 root 666: 667: 668: /* 669: ============== 670: = 1.1.1.2 root 671: = R_Init 1.1 root 672: = 673: ============== 674: */ 675: 1.1.1.3 ! root 676: int detailLevel; ! 677: int screenblocks; 1.1 root 678: 1.1.1.3 ! root 679: void R_Init(void) 1.1.1.2 root 680: { 1.1.1.3 ! root 681: R_InitData(); ! 682: R_InitPointToAngle(); ! 683: R_InitTables(); 1.1.1.2 root 684: // viewwidth / viewheight / detailLevel are set by the defaults 1.1.1.3 ! root 685: R_SetViewSize(screenblocks, detailLevel); ! 686: R_InitPlanes(); ! 687: R_InitLightTables(); ! 688: R_InitSkyMap(); 1.1.1.2 root 689: R_InitTranslationTables(); 690: framecount = 0; 691: } 1.1 root 692: 1.1.1.2 root 693: /* 694: ============== 695: = 696: = R_PointInSubsector 697: = 698: ============== 699: */ 1.1 root 700: 1.1.1.2 root 701: subsector_t *R_PointInSubsector (fixed_t x, fixed_t y) 1.1 root 702: { 1.1.1.2 root 703: node_t *node; 704: int side, nodenum; 1.1 root 705: 1.1.1.2 root 706: if (!numnodes) // single subsector is a special case 707: return subsectors; 1.1 root 708: 1.1.1.2 root 709: nodenum = numnodes-1; 1.1 root 710: 1.1.1.2 root 711: while (! (nodenum & NF_SUBSECTOR) ) 712: { 713: node = &nodes[nodenum]; 714: side = R_PointOnSide (x, y, node); 715: nodenum = node->children[side]; 716: } 717: 718: return &subsectors[nodenum & ~NF_SUBSECTOR]; 719: 720: } 721: 722: //---------------------------------------------------------------------------- 723: // 724: // PROC R_SetupFrame 725: // 726: //---------------------------------------------------------------------------- 727: 728: void R_SetupFrame(player_t *player) 729: { 730: int i; 731: int tableAngle; 732: int tempCentery; 1.1.1.3 ! root 733: int intensity; 1.1.1.2 root 734: 735: //drawbsp = 1; 736: viewplayer = player; 737: #ifdef __WATCOMC__ 1.1.1.3 ! root 738: if(newViewAngleOff) ! 739: { ! 740: viewangleoffset = newViewAngleOff<<ANGLETOFINESHIFT; ! 741: } 1.1.1.2 root 742: #endif 743: viewangle = player->mo->angle+viewangleoffset; 744: tableAngle = viewangle>>ANGLETOFINESHIFT; 1.1.1.3 ! root 745: viewx = player->mo->x; ! 746: viewy = player->mo->y; ! 747: ! 748: if(localQuakeHappening[displayplayer] && !paused) ! 749: { ! 750: intensity = localQuakeHappening[displayplayer]; ! 751: viewx += ((M_Random() % (intensity<<2)) ! 752: -(intensity<<1))<<FRACBITS; ! 753: viewy += ((M_Random()%(intensity<<2)) ! 754: -(intensity<<1))<<FRACBITS; 1.1.1.2 root 755: } 1.1.1.3 ! root 756: 1.1.1.2 root 757: extralight = player->extralight; 758: viewz = player->viewz; 759: 760: tempCentery = viewheight/2+(player->lookdir)*screenblocks/10; 761: if(centery != tempCentery) 762: { 763: centery = tempCentery; 764: centeryfrac = centery<<FRACBITS; 765: for(i = 0; i < viewheight; i++) 766: { 767: yslope[i] = FixedDiv ((viewwidth<<detailshift)/2*FRACUNIT, 768: abs(((i-centery)<<FRACBITS)+FRACUNIT/2)); 769: } 770: } 771: viewsin = finesine[tableAngle]; 772: viewcos = finecosine[tableAngle]; 773: sscount = 0; 774: if(player->fixedcolormap) 775: { 776: fixedcolormap = colormaps+player->fixedcolormap 777: *256*sizeof(lighttable_t); 778: walllights = scalelightfixed; 779: for(i = 0; i < MAXLIGHTSCALE; i++) 780: { 781: scalelightfixed[i] = fixedcolormap; 782: } 783: } 784: else 785: { 786: fixedcolormap = 0; 787: } 788: framecount++; 789: validcount++; 790: if(BorderNeedRefresh) 791: { 792: if(setblocks < 10) 793: { 794: R_DrawViewBorder(); 795: } 796: BorderNeedRefresh = false; 797: BorderTopRefresh = false; 798: UpdateState |= I_FULLSCRN; 799: } 800: if(BorderTopRefresh) 801: { 802: if(setblocks < 10) 803: { 804: R_DrawTopBorder(); 805: } 806: BorderTopRefresh = false; 807: UpdateState |= I_MESSAGES; 808: } 809: 810: #ifdef __NeXT__ 811: RD_ClearMapWindow (); 812: #endif 813: #ifdef __WATCOMC__ 814: destview = destscreen+(viewwindowx>>2)+viewwindowy*80; 1.1 root 815: #endif 816: 1.1.1.2 root 817: #if 0 818: { 819: static int frame; 820: memset (screen, frame, SCREENWIDTH*SCREENHEIGHT); 821: frame++; 822: } 1.1 root 823: #endif 824: } 825: 1.1.1.2 root 826: /* 827: ============== 828: = 829: = R_RenderView 830: = 831: ============== 832: */ 833: 834: void R_RenderPlayerView (player_t *player) 835: { 836: R_SetupFrame (player); 837: R_ClearClipSegs (); 838: R_ClearDrawSegs (); 839: R_ClearPlanes (); 840: R_ClearSprites (); 841: NetUpdate (); // check for new console commands 1.1.1.3 ! root 842: ! 843: // Make displayed player invisible locally ! 844: if (localQuakeHappening[displayplayer] && gamestate == GS_LEVEL) ! 845: { ! 846: players[displayplayer].mo->flags2 |= MF2_DONTDRAW; ! 847: R_RenderBSPNode (numnodes-1); // head node is the last node output ! 848: players[displayplayer].mo->flags2 &= ~MF2_DONTDRAW; ! 849: } ! 850: else ! 851: { ! 852: R_RenderBSPNode (numnodes-1); // head node is the last node output ! 853: } ! 854: 1.1.1.2 root 855: NetUpdate (); // check for new console commands 856: R_DrawPlanes (); 857: NetUpdate (); // check for new console commands 858: R_DrawMasked (); 859: NetUpdate (); // check for new console commands 860: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.