home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / v_vieo24.c < prev    next >
C/C++ Source or Header  |  1999-12-17  |  5KB  |  186 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. /*     Gamma correction LUT stuff. */
  21. /*     Functions to draw patches (by post) directly to screen. */
  22. /*     Functions to blit a block to the screen. */
  23. /*  */
  24. /* ----------------------------------------------------------------------------- */
  25.  
  26.  
  27. static const char
  28. rcsid[] = "$Id: v_video.c,v 1.5 1997/02/03 22:45:13 b1 Exp $";
  29.  
  30.  
  31. #include "i_system.h"
  32. #include "r_local.h"
  33.  
  34. #include "doomdef.h"
  35. #include "doomdata.h"
  36.  
  37. #include "m_bbox.h"
  38. #include "m_swap.h"
  39.  
  40. #include "v_video.h"
  41. #include "i_video.h"
  42.  
  43. /*  Each screen is [SCREENWIDTH*SCREENHEIGHT];  */
  44. extern byte    *screens[5];    
  45.  
  46. /*  */
  47. /*  V_DrawPatch */
  48. /*  Masks a column based masked pic to the screen.  */
  49. /*  */
  50. void
  51. V_DrawPatch24
  52. ( int        x,
  53.   int        y,
  54.   int        scrn,
  55.   patch_t*    patch ) 
  56.     unsigned long    couleur;
  57.  
  58.     int        count;
  59.     int        col; 
  60.     column_t*    column; 
  61.     byte    *desttop,*dest;
  62.     byte    *source; 
  63.     int        w; 
  64.  
  65.     y -= SHORT(patch->topoffset); 
  66.     x -= SHORT(patch->leftoffset); 
  67. #ifdef RANGECHECK 
  68.     if (x<0
  69.     ||x+SHORT(patch->width) >SCREENWIDTH
  70.     || y<0
  71.     || y+SHORT(patch->height)>SCREENHEIGHT 
  72.     || (unsigned)scrn>4)
  73.     {
  74.       fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y );
  75.       /*  No I_Error abort - what is up with TNT.WAD? */
  76.       fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n");
  77.       return;
  78.     }
  79. #endif 
  80.  
  81.     if (!scrn)
  82.     V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 
  83.  
  84.     col = 0; 
  85.     desttop = screens[scrn] + (y*SCREENWIDTH+x)*3; 
  86.      
  87.     w = SHORT(patch->width); 
  88.  
  89.     for ( ; col<w ; x++, col++, desttop+=3)
  90.     { 
  91.     column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); 
  92.  
  93.     /*  step through the posts in a column  */
  94.     while (column->topdelta != 0xff ) 
  95.     { 
  96.         source = (byte *)column + 3; 
  97.         dest = desttop + column->topdelta*SCREENWIDTH*3; 
  98.         count = column->length; 
  99.              
  100.         while (count--) 
  101.         { 
  102.         couleur = truecolor_palette[*source++];
  103.     
  104.         *dest++ = couleur; 
  105.         *dest++ = couleur >> 8; 
  106.         *dest++ = couleur >> 16; 
  107.  
  108.         dest += (SCREENWIDTH*3)-3; 
  109.         } 
  110.         column = (column_t *)(  (byte *)column + column->length 
  111.                     + 4 ); 
  112.     } 
  113.     }             
  114.  
  115. /*  */
  116. /*  V_DrawPatchFlipped  */
  117. /*  Masks a column based masked pic to the screen. */
  118. /*  Flips horizontally, e.g. to mirror face. */
  119. /*  */
  120. void
  121. V_DrawPatchFlipped24
  122. ( int        x,
  123.   int        y,
  124.   int        scrn,
  125.   patch_t*    patch ) 
  126.  
  127.     int        count;
  128.     int        col; 
  129.     column_t*    column; 
  130.     byte    *desttop,*dest;
  131.     byte    *source; 
  132.     int        w; 
  133.     unsigned long    couleur;
  134.      
  135.     y -= SHORT(patch->topoffset); 
  136.     x -= SHORT(patch->leftoffset); 
  137. #ifdef RANGECHECK 
  138.     if (x<0
  139.     ||x+SHORT(patch->width) >SCREENWIDTH
  140.     || y<0
  141.     || y+SHORT(patch->height)>SCREENHEIGHT 
  142.     || (unsigned)scrn>4)
  143.     {
  144.       fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );
  145.       I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
  146.     }
  147. #endif 
  148.  
  149.     if (!scrn)
  150.     V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 
  151.  
  152.     col = 0; 
  153.     desttop = screens[scrn] + (y*SCREENWIDTH+x)*3; 
  154.      
  155.     w = SHORT(patch->width); 
  156.  
  157.     for ( ; col<w ; x++, col++, desttop+=3) 
  158.     { 
  159.     column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); 
  160.  
  161.     /*  step through the posts in a column  */
  162.     while (column->topdelta != 0xff ) 
  163.     { 
  164.         source = (byte *)column + 3; 
  165.         dest = desttop + column->topdelta*SCREENWIDTH*3; 
  166.         count = column->length; 
  167.              
  168.         while (count--) 
  169.         { 
  170.         couleur = truecolor_palette[*source++];
  171.  
  172.         *dest++ = couleur; 
  173.         *dest++ = couleur >> 8; 
  174.         *dest++ = couleur >> 16; 
  175.  
  176.         dest += (SCREENWIDTH*3)-3; 
  177.         } 
  178.         column = (column_t *)(  (byte *)column + column->length 
  179.                     + 4 ); 
  180.     } 
  181.     }             
  182.