R_MAIN.C 16 KB

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