home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / MacWT 0.04 / wt / slice.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-31  |  1.8 KB  |  68 lines  |  [TEXT/MMCC]

  1. /*
  2. **  wt -- a 3d game engine
  3. **
  4. **  Copyright (C) 1994 by Chris Laurel
  5. **  email:  claurel@mr.net
  6. **  snail mail:  Chris Laurel, 5700 W Lake St #208,  St. Louis Park, MN  55416
  7. **
  8. **  This program is free software; you can redistribute it and/or modify
  9. **  it under the terms of the GNU General Public License as published by
  10. **  the Free Software Foundation; either version 2 of the License, or
  11. **  (at your option) any later version.
  12. **
  13. **  This program is distributed in the hope that it will be useful,
  14. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. **  GNU General Public License for more details.
  17. **
  18. **  You should have received a copy of the GNU General Public License
  19. **  along with this program; if not, write to the Free Software
  20. **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22.  
  23.  
  24. inline void draw_wall_slice(Pixel *start, Pixel *end, unsigned char *tex_base,
  25.                 fixed tex_y, fixed tex_dy, int fb_width, 
  26.                 int tex_height, int npix)
  27. {
  28.      unsigned mask = tex_height - 1;
  29.  
  30. #ifdef    PARANOID
  31.     if (npix < 0)
  32.         return;
  33. #endif
  34.  
  35.      while (start >= end) {
  36.       *start = tex_base[FIXED_TO_INT(tex_y) & mask];
  37.       tex_y += tex_dy;
  38.       start -= fb_width;
  39.      }
  40. }
  41.  
  42.  
  43. inline void draw_floor_slice(Pixel *start, unsigned char *tex,
  44.                  fixed x, fixed y, fixed dx, fixed dy,
  45.                  int tex_width)
  46. {
  47.      if (*start != 255)
  48.       return;
  49.  
  50.      if (tex_width == 64) {
  51.       while (*start == 255) {
  52.            x &= 0x3fffff;
  53.            y &= 0x3fffff;
  54.            *start++ = tex[((y >> 16) << 6) + (x >> 16)];
  55.            x += dx;
  56.            y += dy;
  57.       }
  58.      } else {
  59.       while (*start == 255) {
  60.            x &= 0x7fffff;
  61.            y &= 0x7fffff;
  62.            *start++ = tex[((y >> 16) << 7) + (x >> 16)];
  63.            x += dx;
  64.            y += dy;
  65.       }
  66.      }
  67. }
  68.