home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / texmap / scanline.c < prev    next >
Text File  |  1998-06-08  |  5KB  |  224 lines

  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
  12. */
  13. /*
  14.  * $Source: f:/miner/source/texmap/rcs/scanline.c $
  15.  * $Revision: 1.2 $
  16.  * $Author: john $
  17.  * $Date: 1995/02/20 18:23:39 $
  18.  * 
  19.  * Routines to draw the texture mapped scanlines.
  20.  * 
  21.  * $Log: scanline.c $
  22.  * Revision 1.2  1995/02/20  18:23:39  john
  23.  * Added new module for C versions of inner loops.
  24.  * 
  25.  * Revision 1.1  1995/02/20  17:42:27  john
  26.  * Initial revision
  27.  * 
  28.  * 
  29.  */
  30.  
  31.  
  32. #pragma off (unreferenced)
  33. static char rcsid[] = "$Id: scanline.c 1.2 1995/02/20 18:23:39 john Exp $";
  34. #pragma on (unreferenced)
  35.  
  36. #include <math.h>
  37. #include <limits.h>
  38. #include <stdio.h>
  39. #include <conio.h>
  40. #include <stdlib.h>
  41.  
  42. #include "fix.h"
  43. #include "mono.h"
  44. #include "gr.h"
  45. #include "grdef.h"
  46. #include "texmap.h"
  47. #include "texmapl.h"
  48. #include "scanline.h"
  49.  
  50. void c_tmap_scanline_flat()
  51. {
  52.     ubyte *dest;
  53.     int x;
  54.  
  55.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y )  );
  56.  
  57.     for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  58.         *dest++ = tmap_flat_color;
  59.     }
  60. }
  61.  
  62. void c_tmap_scanline_shaded()
  63. {
  64.     int fade;
  65.     ubyte *dest;
  66.     int x;
  67.  
  68.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );
  69.  
  70.     fade = tmap_flat_shade_value<<8;
  71.     for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  72.         *dest++ = gr_fade_table[ fade |(*dest)];
  73.     }
  74. }
  75.  
  76. void c_tmap_scanline_lin_nolight()
  77. {
  78.     ubyte *dest;
  79.     uint c;
  80.     int x;
  81.     fix u,v,dudx, dvdx;
  82.  
  83.     u = fx_u;
  84.     v = fx_v*64;
  85.     dudx = fx_du_dx; 
  86.     dvdx = fx_dv_dx*64; 
  87.  
  88.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );
  89.  
  90.     if (!Transparency_on)    {
  91.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  92.             *dest++ = (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ];
  93.             u += dudx;
  94.             v += dvdx;
  95.         }
  96.     } else {
  97.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  98.             c = (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ];
  99.             if ( c!=255)
  100.                 *dest = c;
  101.             dest++;
  102.             u += dudx;
  103.             v += dvdx;
  104.         }
  105.     }
  106. }
  107.  
  108.  
  109. void c_tmap_scanline_lin()
  110. {
  111.     ubyte *dest;
  112.     uint c;
  113.     int x;
  114.     fix u,v,l,dudx, dvdx, dldx;
  115.  
  116.     u = fx_u;
  117.     v = fx_v*64;
  118.     dudx = fx_du_dx; 
  119.     dvdx = fx_dv_dx*64; 
  120.  
  121.     l = fx_l>>8;
  122.     dldx = fx_dl_dx>>8;
  123.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );
  124.  
  125.     if (!Transparency_on)    {
  126.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  127.             *dest++ = gr_fade_table[ (l&(0xff00)) + (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ] ];
  128.             l += dldx;
  129.             u += dudx;
  130.             v += dvdx;
  131.         }
  132.     } else {
  133.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  134.             c = (uint)pixptr[ (f2i(v)&(64*63)) + (f2i(u)&63) ];
  135.             if ( c!=255)
  136.                 *dest = gr_fade_table[ (l&(0xff00)) + c ];
  137.             dest++;
  138.             l += dldx;
  139.             u += dudx;
  140.             v += dvdx;
  141.         }
  142.     }
  143. }
  144.  
  145.  
  146. void c_tmap_scanline_per_nolight()
  147. {
  148.     ubyte *dest;
  149.     uint c;
  150.     int x;
  151.     fix u,v,z,dudx, dvdx, dzdx;
  152.  
  153.     u = fx_u;
  154.     v = fx_v*64;
  155.     z = fx_z;
  156.     dudx = fx_du_dx; 
  157.     dvdx = fx_dv_dx*64; 
  158.     dzdx = fx_dz_dx;
  159.  
  160.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );
  161.  
  162.     if (!Transparency_on)    {
  163.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  164.             *dest++ = (uint)pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ];
  165.             u += dudx;
  166.             v += dvdx;
  167.             z += dzdx;
  168.         }
  169.     } else {
  170.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  171.             c = (uint)pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ];
  172.             if ( c!=255)
  173.                 *dest = c;
  174.             dest++;
  175.             u += dudx;
  176.             v += dvdx;
  177.             z += dzdx;
  178.         }
  179.     }
  180. }
  181.  
  182. void c_tmap_scanline_per()
  183. {
  184.     ubyte *dest;
  185.     uint c;
  186.     int x;
  187.     fix u,v,z,l,dudx, dvdx, dzdx, dldx;
  188.  
  189.     u = fx_u;
  190.     v = fx_v*64;
  191.     z = fx_z;
  192.     dudx = fx_du_dx; 
  193.     dvdx = fx_dv_dx*64; 
  194.     dzdx = fx_dz_dx;
  195.  
  196.     l = fx_l>>8;
  197.     dldx = fx_dl_dx>>8;
  198.     dest = (ubyte *)(write_buffer + fx_xleft + (bytes_per_row * fx_y)  );
  199.  
  200.     if (!Transparency_on)    {
  201.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  202.             *dest++ = gr_fade_table[ (l&(0xff00)) + (uint)pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ] ];
  203.             l += dldx;
  204.             u += dudx;
  205.             v += dvdx;
  206.             z += dzdx;
  207.         }
  208.     } else {
  209.         for (x= fx_xright-fx_xleft+1 ; x > 0; --x ) {
  210.             c = (uint)pixptr[ ( (v/z)&(64*63) ) + ((u/z)&63) ];
  211.             if ( c!=255)
  212.                 *dest = gr_fade_table[ (l&(0xff00)) + c ];
  213.             dest++;
  214.             l += dldx;
  215.             u += dudx;
  216.             v += dvdx;
  217.             z += dzdx;
  218.         }
  219.     }
  220. }
  221.  
  222.  
  223. 
  224.