R_MAIN.C 16 KB

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