home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / MacWT 0.04 / wt / slice-gas86.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-31  |  4.3 KB  |  169 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.      int count = start - end;
  29.      
  30.      if (npix < 0)
  31.       return;
  32.      if (tex_height == 64) {
  33.       tex_y <<= 10;
  34.       tex_dy <<= 10;
  35. __asm__ volatile("movl %0, %%ebx\n\t"
  36.          "movl %1, %%ecx\n\t"
  37.          "movl %2, %%edx\n\t"
  38.          "movl %3, %%esi\n\t"
  39.          "movl %4, %%edi\n"
  40.          "\t1:\n\t"
  41.          "movl %%edi, %%eax\n\t"
  42.          "shrl $26, %%eax\n\t"
  43.          "addl %%edx, %%edi\n\t"
  44.          "movb (%%ecx,%%eax), %%al\n\t"
  45.          "movb %%al, (%%ebx,%%esi)\n\t"
  46.          "subl $320, %%ebx\n\t"
  47.          "jns  1b\n"
  48.          :: "m" (count), "m" (tex_base), "m" (tex_dy),
  49.          "m" (end), "m" (tex_y):
  50.          "eax", "ebx", "ecx", "edx", "esi", "edi" );
  51. } else {
  52.      tex_y <<= 9;
  53.      tex_dy <<= 9;
  54.  
  55. __asm__ volatile("movl %0, %%ebx\n\t"
  56.          "movl %1, %%ecx\n\t"
  57.          "movl %2, %%edx\n\t"
  58.          "movl %3, %%esi\n\t"
  59.          "movl %4, %%edi\n\t"
  60.          "movl %5, %%eax\n\t"
  61.          "andl $3, %%eax\n\t"
  62.          "jz   4f\n\t"
  63.          "cmpl $1, %%eax\n\t"
  64.          "je   3f\n\t"
  65.          "cmpl $2, %%eax\n\t"
  66.          "je   2f\n\t"
  67.          "\t1:\n\t"
  68.          "movl %%edi, %%eax\n\t"
  69.          "shrl $25, %%eax\n\t"
  70.          "addl %%edx, %%edi\n\t"
  71.          "movb (%%ecx,%%eax), %%al\n\t"
  72.          "movb %%al, (%%ebx,%%esi)\n\t"
  73.          "subl $320, %%ebx\n"
  74.          "\t2:\n\t"
  75.          "movl %%edi, %%eax\n\t"
  76.          "shrl $25, %%eax\n\t"
  77.          "addl %%edx, %%edi\n\t"
  78.          "movb (%%ecx,%%eax), %%al\n\t"
  79.          "movb %%al, (%%ebx,%%esi)\n\t"
  80.          "subl $320, %%ebx\n\t"
  81.          "\t3:\n\t"
  82.          "movl %%edi, %%eax\n\t"
  83.          "shrl $25, %%eax\n\t"
  84.          "addl %%edx, %%edi\n\t"
  85.          "movb (%%ecx,%%eax), %%al\n\t"
  86.          "movb %%al, (%%ebx,%%esi)\n\t"
  87.          "subl $320, %%ebx\n"
  88.          "\t4:\n\t"
  89.          "movl %%edi, %%eax\n\t"
  90.          "shrl $25, %%eax\n\t"
  91.          "addl %%edx, %%edi\n\t"
  92.          "movb (%%ecx,%%eax), %%al\n\t"
  93.          "movb %%al, (%%ebx,%%esi)\n\t"
  94.          "subl $320, %%ebx\n\t"
  95.          "jns   1b\n"
  96.          :: "m" (count), "m" (tex_base), "m" (tex_dy),
  97.          "m" (end), "m" (tex_y), "m" (npix):
  98.          "eax", "ebx", "ecx", "edx", "esi", "edi" );
  99.      }
  100. }
  101.  
  102.  
  103. inline void draw_floor_slice(Pixel *start, unsigned char *tex,
  104.                  fixed x, fixed y, fixed dx, fixed dy,
  105.                  int tex_width)
  106. {
  107.      if (*start != 255)
  108.       return;
  109.  
  110.      if (tex_width == 128) {
  111.       
  112.       y <<= 9;
  113.       dy <<= 9;
  114.       x <<= 2;
  115.       dx <<= 2;
  116.  
  117. __asm__ volatile("movl %0, %%ebx\n\t"
  118.          "movl %1, %%edi\n\t"
  119.          "movl %2, %%eax\n\t"
  120.          "movl %3, %%edx\n\t"
  121.          "movl %4, %%esi\n\t"
  122.          "\t1:\n\t"
  123.          "movl %%edx, %%ecx\n\t"
  124.          "andl $33554431, %%eax\n\t"
  125.          "andl $4261412864, %%ecx\n\t"
  126.          "addl %%eax, %%ecx\n\t"
  127.          "shrl $18, %%ecx\n\t"
  128.          "addl %5, %%edx\n\t"
  129.          "movb (%%ecx,%%edi), %%cl\n\t"
  130.          "movb %%cl, (%%ebx)\n\t"
  131.          "incl %%ebx\n\t"
  132.          "addl %%esi, %%eax\n\t"
  133.          "cmpb $255, (%%ebx)\n\t"
  134.          "je   1b\n"
  135.          :: "m" (start), "m" (tex), "m" (x), "m" (y),
  136.          "m" (dx), "m" (dy):
  137.          "eax", "ebx", "ecx", "edx", "esi", "edi" );
  138.  
  139.      } else {
  140.       
  141.       y <<= 10;
  142.       dy <<= 10;
  143.       x <<= 4;
  144.       dx <<= 4;
  145.  
  146. __asm__ volatile("movl %0, %%ebx\n\t"
  147.          "movl %1, %%edi\n\t"
  148.          "movl %2, %%eax\n\t"
  149.          "movl %3, %%edx\n\t"
  150.          "movl %4, %%esi\n\t"
  151.          "\t1:\n\t"
  152.          "movl %%edx, %%ecx\n\t"
  153.          "andl $67108863, %%eax\n\t"
  154.          "andl $4227858432, %%ecx\n\t"
  155.          "addl %%eax, %%ecx\n\t"
  156.          "shrl $20, %%ecx\n\t"
  157.          "addl %5, %%edx\n\t"
  158.          "movb (%%ecx,%%edi), %%cl\n\t"
  159.          "movb %%cl, (%%ebx)\n\t"
  160.          "incl %%ebx\n\t"
  161.          "addl %%esi, %%eax\n\t"
  162.          "cmpb $255, (%%ebx)\n\t"
  163.          "je   1b\n"
  164.          :: "m" (start), "m" (tex), "m" (x), "m" (y),
  165.          "m" (dx), "m" (dy):
  166.          "eax", "ebx", "ecx", "edx", "esi", "edi" );
  167.      }
  168. }
  169.