home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 25 / amigaformatcd25.iso / websites / amidoom / adoom_src-0.7.lha / ADoom_src / r_segs.c < prev    next >
C/C++ Source or Header  |  1998-01-15  |  17KB  |  753 lines

  1. // Emacs style mode select   -*- C++ -*- 
  2. //-----------------------------------------------------------------------------
  3. //
  4. // $Id:$
  5. //
  6. // Copyright (C) 1993-1996 by id Software, Inc.
  7. //
  8. // This source is available for distribution and/or modification
  9. // only under the terms of the DOOM Source Code License as
  10. // published by id Software. All rights reserved.
  11. //
  12. // The source is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
  15. // for more details.
  16. //
  17. // $Log:$
  18. //
  19. // DESCRIPTION:
  20. //    All the clipping: columns, horizontal spans, sky columns.
  21. //
  22. //-----------------------------------------------------------------------------
  23.  
  24.  
  25. static const char
  26. rcsid[] = "$Id: r_segs.c,v 1.3 1997/01/29 20:10:19 b1 Exp $";
  27.  
  28.  
  29.  
  30.  
  31.  
  32. #include <stdlib.h>
  33.  
  34. #include "i_system.h"
  35.  
  36. #include "doomdef.h"
  37. #include "doomstat.h"
  38.  
  39. #include "r_local.h"
  40. #include "r_sky.h"
  41.  
  42.  
  43. // OPTIMIZE: closed two sided lines as single sided
  44.  
  45. // True if any of the segs textures might be visible.
  46. boolean        segtextured;    
  47.  
  48. // False if the back side is the same plane.
  49. boolean        markfloor;    
  50. boolean        markceiling;
  51.  
  52. boolean        maskedtexture;
  53. int        toptexture;
  54. int        bottomtexture;
  55. int        midtexture;
  56.  
  57.  
  58. angle_t        rw_normalangle;
  59. // angle to line origin
  60. int        rw_angle1;    
  61.  
  62. //
  63. // regular wall
  64. //
  65. int        rw_x;
  66. int        rw_stopx;
  67. angle_t        rw_centerangle;
  68. fixed_t        rw_offset;
  69. fixed_t        rw_distance;
  70. fixed_t        rw_scale;
  71. fixed_t        rw_scalestep;
  72. fixed_t        rw_midtexturemid;
  73. fixed_t        rw_toptexturemid;
  74. fixed_t        rw_bottomtexturemid;
  75.  
  76. int        worldtop;
  77. int        worldbottom;
  78. int        worldhigh;
  79. int        worldlow;
  80.  
  81. fixed_t        pixhigh;
  82. fixed_t        pixlow;
  83. fixed_t        pixhighstep;
  84. fixed_t        pixlowstep;
  85.  
  86. fixed_t        topfrac;
  87. fixed_t        topstep;
  88.  
  89. fixed_t        bottomfrac;
  90. fixed_t        bottomstep;
  91.  
  92.  
  93. lighttable_t**    walllights;
  94.  
  95. short*        maskedtexturecol;
  96.  
  97.  
  98.  
  99. //
  100. // R_RenderMaskedSegRange
  101. //
  102. void
  103. R_RenderMaskedSegRange
  104. ( drawseg_t*    ds,
  105.   int        x1,
  106.   int        x2 )
  107. {
  108.     unsigned    index;
  109.     column_t*    col;
  110.     int        lightnum;
  111.     int        texnum;
  112.     
  113.     // Calculate light table.
  114.     // Use different light tables
  115.     //   for horizontal / vertical / diagonal. Diagonal?
  116.     // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
  117.     curline = ds->curline;
  118.     frontsector = curline->frontsector;
  119.     backsector = curline->backsector;
  120.     texnum = texturetranslation[curline->sidedef->midtexture];
  121.     
  122.     lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;
  123.  
  124.     if (curline->v1->y == curline->v2->y)
  125.     lightnum--;
  126.     else if (curline->v1->x == curline->v2->x)
  127.     lightnum++;
  128.  
  129.     if (lightnum < 0)        
  130.     walllights = scalelight[0];
  131.     else if (lightnum >= LIGHTLEVELS)
  132.     walllights = scalelight[LIGHTLEVELS-1];
  133.     else
  134.     walllights = scalelight[lightnum];
  135.  
  136.     maskedtexturecol = ds->maskedtexturecol;
  137.  
  138.     rw_scalestep = ds->scalestep;        
  139.     spryscale = ds->scale1 + (x1 - ds->x1)*rw_scalestep;
  140.     mfloorclip = ds->sprbottomclip;
  141.     mceilingclip = ds->sprtopclip;
  142.     
  143.     // find positioning
  144.     if (curline->linedef->flags & ML_DONTPEGBOTTOM)
  145.     {
  146.     dc_texturemid = frontsector->floorheight > backsector->floorheight
  147.         ? frontsector->floorheight : backsector->floorheight;
  148.     dc_texturemid = dc_texturemid + textureheight[texnum] - viewz;
  149.     }
  150.     else
  151.     {
  152.     dc_texturemid =frontsector->ceilingheight<backsector->ceilingheight
  153.         ? frontsector->ceilingheight : backsector->ceilingheight;
  154.     dc_texturemid = dc_texturemid - viewz;
  155.     }
  156.     dc_texturemid += curline->sidedef->rowoffset;
  157.             
  158.     if (fixedcolormap)
  159.     dc_colormap = fixedcolormap;
  160.     
  161.     // draw the columns
  162.     for (dc_x = x1 ; dc_x <= x2 ; dc_x++)
  163.     {
  164.     // calculate lighting
  165.     if (maskedtexturecol[dc_x] != MAXSHORT)
  166.     {
  167.         if (!fixedcolormap)
  168.         {
  169.         index = spryscale>>LIGHTSCALESHIFT;
  170.  
  171.         if (index >=  MAXLIGHTSCALE )
  172.             index = MAXLIGHTSCALE-1;
  173.  
  174.         dc_colormap = walllights[index];
  175.         }
  176.             
  177.         sprtopscreen = centeryfrac - FixedMul(dc_texturemid, spryscale);
  178.         dc_iscale = 0xffffffffu / (unsigned)spryscale;
  179.         
  180.         // draw the texture
  181.         col = (column_t *)( 
  182.         (byte *)R_GetColumn(texnum,maskedtexturecol[dc_x]) -3);
  183.             
  184. //#ifndef AMIGA
  185.         R_DrawMaskedColumn (col);
  186. //#else
  187. //        R_DrawMaskedColumnAmi (col, TYPE_NORMAL);
  188. //#endif
  189.         maskedtexturecol[dc_x] = MAXSHORT;
  190.     }
  191.     spryscale += rw_scalestep;
  192.     }
  193.     
  194. }
  195.  
  196.  
  197.  
  198.  
  199. //
  200. // R_RenderSegLoop
  201. // Draws zero, one, or two textures (and possibly a masked
  202. //  texture) for walls.
  203. // Can draw or mark the starting pixel of floor and ceiling
  204. //  textures.
  205. // CALLED: CORE LOOPING ROUTINE.
  206. //
  207. #define HEIGHTBITS        12
  208. #define HEIGHTUNIT        (1<<HEIGHTBITS)
  209.  
  210. void R_RenderSegLoop (void)
  211. {
  212.     angle_t        angle;
  213.     unsigned        index;
  214.     int            yl;
  215.     int            yh;
  216.     int            mid;
  217.     fixed_t        texturecolumn;
  218.     int            top;
  219.     int            bottom;
  220.  
  221.     //texturecolumn = 0;                // shut up compiler warning
  222.  
  223.     for ( ; rw_x < rw_stopx ; rw_x++)
  224.     {
  225.     // mark floor / ceiling areas
  226.     yl = (topfrac+HEIGHTUNIT-1)>>HEIGHTBITS;
  227.  
  228.     // no space above wall?
  229.     if (yl < ceilingclip[rw_x]+1)
  230.         yl = ceilingclip[rw_x]+1;
  231.     
  232.     if (markceiling)
  233.     {
  234.         top = ceilingclip[rw_x]+1;
  235.         bottom = yl-1;
  236.  
  237.         if (bottom >= floorclip[rw_x])
  238.         bottom = floorclip[rw_x]-1;
  239.  
  240.         if (top <= bottom)
  241.         {
  242.         ceilingplane->top[rw_x] = top;
  243.         ceilingplane->bottom[rw_x] = bottom;
  244.         }
  245.     }
  246.         
  247.     yh = bottomfrac>>HEIGHTBITS;
  248.  
  249.     if (yh >= floorclip[rw_x])
  250.         yh = floorclip[rw_x]-1;
  251.  
  252.     if (markfloor)
  253.     {
  254.         top = yh+1;
  255.         bottom = floorclip[rw_x]-1;
  256.         if (top <= ceilingclip[rw_x])
  257.         top = ceilingclip[rw_x]+1;
  258.         if (top <= bottom)
  259.         {
  260.         floorplane->top[rw_x] = top;
  261.         floorplane->bottom[rw_x] = bottom;
  262.         }
  263.     }
  264.     
  265.     // texturecolumn and lighting are independent of wall tiers
  266.     if (segtextured)
  267.     {
  268.         // calculate texture offset
  269.         angle = (rw_centerangle + xtoviewangle[rw_x])>>ANGLETOFINESHIFT;
  270.         texturecolumn = rw_offset-FixedMul(finetangent[angle],rw_distance);
  271.         texturecolumn >>= FRACBITS;
  272.         // calculate lighting
  273.         index = rw_scale>>LIGHTSCALESHIFT;
  274.  
  275.         if (index >=  MAXLIGHTSCALE )
  276.         index = MAXLIGHTSCALE-1;
  277.  
  278.         dc_colormap = walllights[index];
  279.         dc_x = rw_x;
  280.         dc_iscale = 0xffffffffu / (unsigned)rw_scale;
  281.     }
  282.     
  283.     // draw the wall tiers
  284.     if (midtexture)
  285.     {
  286.         // single sided line
  287.         dc_yl = yl;
  288.         dc_yh = yh;
  289.         dc_texturemid = rw_midtexturemid;
  290.         dc_source = R_GetColumn(midtexture,texturecolumn);
  291.         colfunc ();
  292.         ceilingclip[rw_x] = viewheight;
  293.         floorclip[rw_x] = -1;
  294.     }
  295.     else
  296.     {
  297.         // two sided line
  298.         if (toptexture)
  299.         {
  300.         // top wall
  301.         mid = pixhigh>>HEIGHTBITS;
  302.         pixhigh += pixhighstep;
  303.  
  304.         if (mid >= floorclip[rw_x])
  305.             mid = floorclip[rw_x]-1;
  306.  
  307.         if (mid >= yl)
  308.         {
  309.             dc_yl = yl;
  310.             dc_yh = mid;
  311.             dc_texturemid = rw_toptexturemid;
  312.             dc_source = R_GetColumn(toptexture,texturecolumn);
  313.             colfunc ();
  314.             ceilingclip[rw_x] = mid;
  315.         }
  316.         else
  317.             ceilingclip[rw_x] = yl-1;
  318.         }
  319.         else
  320.         {
  321.         // no top wall
  322.         if (markceiling)
  323.             ceilingclip[rw_x] = yl-1;
  324.         }
  325.             
  326.         if (bottomtexture)
  327.         {
  328.         // bottom wall
  329.         mid = (pixlow+HEIGHTUNIT-1)>>HEIGHTBITS;
  330.         pixlow += pixlowstep;
  331.  
  332.         // no space above wall?
  333.         if (mid <= ceilingclip[rw_x])
  334.             mid = ceilingclip[rw_x]+1;
  335.         
  336.         if (mid <= yh)
  337.         {
  338.             dc_yl = mid;
  339.             dc_yh = yh;
  340.             dc_texturemid = rw_bottomtexturemid;
  341.             dc_source = R_GetColumn(bottomtexture,
  342.                         texturecolumn);
  343.             colfunc ();
  344.             floorclip[rw_x] = mid;
  345.         }
  346.         else
  347.             floorclip[rw_x] = yh+1;
  348.         }
  349.         else
  350.         {
  351.         // no bottom wall
  352.         if (markfloor)
  353.             floorclip[rw_x] = yh+1;
  354.         }
  355.             
  356.         if (maskedtexture)
  357.         {
  358.         // save texturecol
  359.         //  for backdrawing of masked mid texture
  360.         maskedtexturecol[rw_x] = texturecolumn;
  361.         }
  362.     }
  363.         
  364.     rw_scale += rw_scalestep;
  365.     topfrac += topstep;
  366.     bottomfrac += bottomstep;
  367.  
  368.     }
  369. }
  370.  
  371.  
  372.  
  373.  
  374. //
  375. // R_StoreWallRange
  376. // A wall segment will be drawn
  377. //  between start and stop pixels (inclusive).
  378. //
  379. void
  380. R_StoreWallRange
  381. ( int    start,
  382.   int    stop )
  383. {
  384.     fixed_t        hyp;
  385.     fixed_t        sineval;
  386.     angle_t        distangle, offsetangle;
  387.     fixed_t        vtop;
  388.     int            lightnum;
  389.  
  390.     // don't overflow and crash
  391.     if (ds_p == &drawsegs[MAXDRAWSEGS])
  392.     return;        
  393.         
  394. #ifdef RANGECHECK
  395.     if (start >=viewwidth || start > stop)
  396.     I_Error ("Bad R_RenderWallRange: %i to %i", start , stop);
  397. #endif
  398.     
  399.     sidedef = curline->sidedef;
  400.     linedef = curline->linedef;
  401.  
  402.     // mark the segment as visible for auto map
  403.     linedef->flags |= ML_MAPPED;
  404.     
  405.     // calculate rw_distance for scale calculation
  406.     rw_normalangle = curline->angle + ANG90;
  407.     offsetangle = iabs(rw_normalangle-rw_angle1);
  408.     
  409.     if (offsetangle > ANG90)
  410.     offsetangle = ANG90;
  411.  
  412.     distangle = ANG90 - offsetangle;
  413.     hyp = R_PointToDist (curline->v1->x, curline->v1->y);
  414.     sineval = finesine[distangle>>ANGLETOFINESHIFT];
  415.     rw_distance = FixedMul (hyp, sineval);
  416.         
  417.     
  418.     ds_p->x1 = rw_x = start;
  419.     ds_p->x2 = stop;
  420.     ds_p->curline = curline;
  421.     rw_stopx = stop+1;
  422.     
  423.     // calculate scale at both ends and step
  424.     ds_p->scale1 = rw_scale = 
  425.     R_ScaleFromGlobalAngle (viewangle + xtoviewangle[start]);
  426.     
  427.     if (stop > start )
  428.     {
  429.     ds_p->scale2 = R_ScaleFromGlobalAngle (viewangle + xtoviewangle[stop]);
  430.     ds_p->scalestep = rw_scalestep = 
  431.         (ds_p->scale2 - rw_scale) / (stop-start);
  432.     }
  433.     else
  434.     {
  435.     // UNUSED: try to fix the stretched line bug
  436. #if 0
  437.     if (rw_distance < FRACUNIT/2)
  438.     {
  439.         fixed_t        trx,try;
  440.         fixed_t        gxt,gyt;
  441.  
  442.         trx = curline->v1->x - viewx;
  443.         try = curline->v1->y - viewy;
  444.             
  445.         gxt = FixedMul(trx,viewcos); 
  446.         gyt = -FixedMul(try,viewsin); 
  447.         ds_p->scale1 = FixedDiv(projection, gxt-gyt)<<detailshift;
  448.     }
  449. #endif
  450.     ds_p->scale2 = ds_p->scale1;
  451.     }
  452.     
  453.     // calculate texture boundaries
  454.     //  and decide if floor / ceiling marks are needed
  455.     worldtop = frontsector->ceilingheight - viewz;
  456.     worldbottom = frontsector->floorheight - viewz;
  457.     
  458.     midtexture = toptexture = bottomtexture = maskedtexture = 0;
  459.     ds_p->maskedtexturecol = NULL;
  460.     
  461.     if (!backsector)
  462.     {
  463.     // single sided line
  464.     midtexture = texturetranslation[sidedef->midtexture];
  465.     // a single sided line is terminal, so it must mark ends
  466.     markfloor = markceiling = true;
  467.     if (linedef->flags & ML_DONTPEGBOTTOM)
  468.     {
  469.         vtop = frontsector->floorheight +
  470.         textureheight[sidedef->midtexture];
  471.         // bottom of texture at bottom
  472.         rw_midtexturemid = vtop - viewz;    
  473.     }
  474.     else
  475.     {
  476.         // top of texture at top
  477.         rw_midtexturemid = worldtop;
  478.     }
  479.     rw_midtexturemid += sidedef->rowoffset;
  480.  
  481.     ds_p->silhouette = SIL_BOTH;
  482.     ds_p->sprtopclip = screenheightarray;
  483.     ds_p->sprbottomclip = negonearray;
  484.     ds_p->bsilheight = MAXINT;
  485.     ds_p->tsilheight = MININT;
  486.     }
  487.     else
  488.     {
  489.     // two sided line
  490.     ds_p->sprtopclip = ds_p->sprbottomclip = NULL;
  491.     ds_p->silhouette = 0;
  492.     
  493.     if (frontsector->floorheight > backsector->floorheight)
  494.     {
  495.         ds_p->silhouette = SIL_BOTTOM;
  496.         ds_p->bsilheight = frontsector->floorheight;
  497.     }
  498.     else if (backsector->floorheight > viewz)
  499.     {
  500.         ds_p->silhouette = SIL_BOTTOM;
  501.         ds_p->bsilheight = MAXINT;
  502.         // ds_p->sprbottomclip = negonearray;
  503.     }
  504.     
  505.     if (frontsector->ceilingheight < backsector->ceilingheight)
  506.     {
  507.         ds_p->silhouette |= SIL_TOP;
  508.         ds_p->tsilheight = frontsector->ceilingheight;
  509.     }
  510.     else if (backsector->ceilingheight < viewz)
  511.     {
  512.         ds_p->silhouette |= SIL_TOP;
  513.         ds_p->tsilheight = MININT;
  514.         // ds_p->sprtopclip = screenheightarray;
  515.     }
  516.         
  517.     if (backsector->ceilingheight <= frontsector->floorheight)
  518.     {
  519.         ds_p->sprbottomclip = negonearray;
  520.         ds_p->bsilheight = MAXINT;
  521.         ds_p->silhouette |= SIL_BOTTOM;
  522.     }
  523.     
  524.     if (backsector->floorheight >= frontsector->ceilingheight)
  525.     {
  526.         ds_p->sprtopclip = screenheightarray;
  527.         ds_p->tsilheight = MININT;
  528.         ds_p->silhouette |= SIL_TOP;
  529.     }
  530.     
  531.     worldhigh = backsector->ceilingheight - viewz;
  532.     worldlow = backsector->floorheight - viewz;
  533.         
  534.     // hack to allow height changes in outdoor areas
  535.     if (frontsector->ceilingpic == skyflatnum 
  536.         && backsector->ceilingpic == skyflatnum)
  537.     {
  538.         worldtop = worldhigh;
  539.     }
  540.     
  541.             
  542.     if (worldlow != worldbottom 
  543.         || backsector->floorpic != frontsector->floorpic
  544.         || backsector->lightlevel != frontsector->lightlevel)
  545.     {
  546.         markfloor = true;
  547.     }
  548.     else
  549.     {
  550.         // same plane on both sides
  551.         markfloor = false;
  552.     }
  553.     
  554.             
  555.     if (worldhigh != worldtop 
  556.         || backsector->ceilingpic != frontsector->ceilingpic
  557.         || backsector->lightlevel != frontsector->lightlevel)
  558.     {
  559.         markceiling = true;
  560.     }
  561.     else
  562.     {
  563.         // same plane on both sides
  564.         markceiling = false;
  565.     }
  566.     
  567.     if (backsector->ceilingheight <= frontsector->floorheight
  568.         || backsector->floorheight >= frontsector->ceilingheight)
  569.     {
  570.         // closed door
  571.         markceiling = markfloor = true;
  572.     }
  573.     
  574.  
  575.     if (worldhigh < worldtop)
  576.     {
  577.         // top texture
  578.         toptexture = texturetranslation[sidedef->toptexture];
  579.         if (linedef->flags & ML_DONTPEGTOP)
  580.         {
  581.         // top of texture at top
  582.         rw_toptexturemid = worldtop;
  583.         }
  584.         else
  585.         {
  586.         vtop =
  587.             backsector->ceilingheight
  588.             + textureheight[sidedef->toptexture];
  589.         
  590.         // bottom of texture
  591.         rw_toptexturemid = vtop - viewz;    
  592.         }
  593.     }
  594.     if (worldlow > worldbottom)
  595.     {
  596.         // bottom texture
  597.         bottomtexture = texturetranslation[sidedef->bottomtexture];
  598.  
  599.         if (linedef->flags & ML_DONTPEGBOTTOM )
  600.         {
  601.         // bottom of texture at bottom
  602.         // top of texture at top
  603.         rw_bottomtexturemid = worldtop;
  604.         }
  605.         else    // top of texture at top
  606.         rw_bottomtexturemid = worldlow;
  607.     }
  608.     rw_toptexturemid += sidedef->rowoffset;
  609.     rw_bottomtexturemid += sidedef->rowoffset;
  610.     
  611.     // allocate space for masked texture tables
  612.     if (sidedef->midtexture)
  613.     {
  614.         // masked midtexture
  615.         maskedtexture = true;
  616.         ds_p->maskedtexturecol = maskedtexturecol = lastopening - rw_x;
  617.         lastopening += rw_stopx - rw_x;
  618.     }
  619.     }
  620.     
  621.     // calculate rw_offset (only needed for textured lines)
  622.     segtextured = midtexture | toptexture | bottomtexture | maskedtexture;
  623.  
  624.     if (segtextured)
  625.     {
  626.     offsetangle = rw_normalangle-rw_angle1;
  627.     
  628.     if (offsetangle > ANG180)
  629.         offsetangle = -offsetangle;
  630.  
  631.     if (offsetangle > ANG90)
  632.         offsetangle = ANG90;
  633.  
  634.     sineval = finesine[offsetangle >>ANGLETOFINESHIFT];
  635.     rw_offset = FixedMul (hyp, sineval);
  636.  
  637.     if (rw_normalangle-rw_angle1 < ANG180)
  638.         rw_offset = -rw_offset;
  639.  
  640.     rw_offset += sidedef->textureoffset + curline->offset;
  641.     rw_centerangle = ANG90 + viewangle - rw_normalangle;
  642.     
  643.     // calculate light table
  644.     //  use different light tables
  645.     //  for horizontal / vertical / diagonal
  646.     // OPTIMIZE: get rid of LIGHTSEGSHIFT globally
  647.     if (!fixedcolormap)
  648.     {
  649.         lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT)+extralight;
  650.  
  651.         if (curline->v1->y == curline->v2->y)
  652.         lightnum--;
  653.         else if (curline->v1->x == curline->v2->x)
  654.         lightnum++;
  655.  
  656.         if (lightnum < 0)        
  657.         walllights = scalelight[0];
  658.         else if (lightnum >= LIGHTLEVELS)
  659.         walllights = scalelight[LIGHTLEVELS-1];
  660.         else
  661.         walllights = scalelight[lightnum];
  662.     }
  663.     }
  664.     
  665.     // if a floor / ceiling plane is on the wrong side
  666.     //  of the view plane, it is definitely invisible
  667.     //  and doesn't need to be marked.
  668.     
  669.   
  670.     if (frontsector->floorheight >= viewz)
  671.     {
  672.     // above view plane
  673.     markfloor = false;
  674.     }
  675.     
  676.     if (frontsector->ceilingheight <= viewz 
  677.     && frontsector->ceilingpic != skyflatnum)
  678.     {
  679.     // below view plane
  680.     markceiling = false;
  681.     }
  682.  
  683.     
  684.     // calculate incremental stepping values for texture edges
  685.     worldtop >>= 4;
  686.     worldbottom >>= 4;
  687.     
  688.     topstep = -FixedMul (rw_scalestep, worldtop);
  689.     topfrac = (centeryfrac>>4) - FixedMul (worldtop, rw_scale);
  690.  
  691.     bottomstep = -FixedMul (rw_scalestep,worldbottom);
  692.     bottomfrac = (centeryfrac>>4) - FixedMul (worldbottom, rw_scale);
  693.     
  694.  
  695.     if (backsector)
  696.     {    
  697.     worldhigh >>= 4;
  698.     worldlow >>= 4;
  699.  
  700.     if (worldhigh < worldtop)
  701.     {
  702.         pixhigh = (centeryfrac>>4) - FixedMul (worldhigh, rw_scale);
  703.         pixhighstep = -FixedMul (rw_scalestep,worldhigh);
  704.     }
  705.     
  706.     if (worldlow > worldbottom)
  707.     {
  708.         pixlow = (centeryfrac>>4) - FixedMul (worldlow, rw_scale);
  709.         pixlowstep = -FixedMul (rw_scalestep,worldlow);
  710.     }
  711.     }
  712.     
  713.     // render it
  714.     if (markceiling)
  715.     ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
  716.     
  717.     if (markfloor)
  718.     floorplane = R_CheckPlane (floorplane, rw_x, rw_stopx-1);
  719.  
  720.     R_RenderSegLoop ();
  721.  
  722.     
  723.     // save sprite clipping info
  724.     if ( ((ds_p->silhouette & SIL_TOP) || maskedtexture)
  725.      && !ds_p->sprtopclip)
  726.     {
  727.     memcpy (lastopening, ceilingclip+start, 2*(rw_stopx-start));
  728.     ds_p->sprtopclip = lastopening - start;
  729.     lastopening += rw_stopx - start;
  730.     }
  731.     
  732.     if ( ((ds_p->silhouette & SIL_BOTTOM) || maskedtexture)
  733.      && !ds_p->sprbottomclip)
  734.     {
  735.     memcpy (lastopening, floorclip+start, 2*(rw_stopx-start));
  736.     ds_p->sprbottomclip = lastopening - start;
  737.     lastopening += rw_stopx - start;    
  738.     }
  739.  
  740.     if (maskedtexture && !(ds_p->silhouette&SIL_TOP))
  741.     {
  742.     ds_p->silhouette |= SIL_TOP;
  743.     ds_p->tsilheight = MININT;
  744.     }
  745.     if (maskedtexture && !(ds_p->silhouette&SIL_BOTTOM))
  746.     {
  747.     ds_p->silhouette |= SIL_BOTTOM;
  748.     ds_p->bsilheight = MAXINT;
  749.     }
  750.     ds_p++;
  751. }
  752.  
  753.