home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / v_video8.c < prev    next >
C/C++ Source or Header  |  1999-12-17  |  4KB  |  175 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. /*  V_DrawPatch */
  47. /*  Masks a column based masked pic to the screen.  */
  48. /*  */
  49. void
  50. V_DrawPatch8
  51. ( int        x,
  52.   int        y,
  53.   int        scrn,
  54.   patch_t*    patch ) 
  55.  
  56.     int        count;
  57.     int        col; 
  58.     column_t*    column; 
  59.     byte*    desttop;
  60.     byte*    dest;
  61.     byte*    source; 
  62.     int        w; 
  63.      
  64.     y -= SHORT(patch->topoffset); 
  65.     x -= SHORT(patch->leftoffset); 
  66. #ifdef RANGECHECK 
  67.     if (x<0
  68.     ||x+SHORT(patch->width) >SCREENWIDTH
  69.     || y<0
  70.     || y+SHORT(patch->height)>SCREENHEIGHT 
  71.     || (unsigned)scrn>4)
  72.     {
  73.       fprintf( stderr, "Patch at %d,%d exceeds LFB\n", x,y );
  74.       /*  No I_Error abort - what is up with TNT.WAD? */
  75.       fprintf( stderr, "V_DrawPatch: bad patch (ignored)\n");
  76.       return;
  77.     }
  78. #endif 
  79.  
  80.     if (!scrn)
  81.     V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 
  82.  
  83.     col = 0; 
  84.     desttop = screens[scrn]+y*SCREENWIDTH+x; 
  85.      
  86.     w = SHORT(patch->width); 
  87.  
  88.     for ( ; col<w ; x++, col++, desttop++)
  89.     { 
  90.     column = (column_t *)((byte *)patch + LONG(patch->columnofs[col])); 
  91.  
  92.     /*  step through the posts in a column  */
  93.     while (column->topdelta != 0xff ) 
  94.     { 
  95.         source = (byte *)column + 3; 
  96.         dest = desttop + column->topdelta*SCREENWIDTH; 
  97.         count = column->length; 
  98.              
  99.         while (count--) 
  100.         { 
  101.         *dest = *source++; 
  102.         dest += SCREENWIDTH; 
  103.         } 
  104.         column = (column_t *)(  (byte *)column + column->length 
  105.                     + 4 ); 
  106.     } 
  107.     }             
  108.  
  109. /*  */
  110. /*  V_DrawPatchFlipped  */
  111. /*  Masks a column based masked pic to the screen. */
  112. /*  Flips horizontally, e.g. to mirror face. */
  113. /*  */
  114. void
  115. V_DrawPatchFlipped8
  116. ( int        x,
  117.   int        y,
  118.   int        scrn,
  119.   patch_t*    patch ) 
  120.  
  121.     int        count;
  122.     int        col; 
  123.     column_t*    column; 
  124.     byte*    desttop;
  125.     byte*    dest;
  126.     byte*    source; 
  127.     int        w; 
  128.      
  129.     y -= SHORT(patch->topoffset); 
  130.     x -= SHORT(patch->leftoffset); 
  131. #ifdef RANGECHECK 
  132.     if (x<0
  133.     ||x+SHORT(patch->width) >SCREENWIDTH
  134.     || y<0
  135.     || y+SHORT(patch->height)>SCREENHEIGHT 
  136.     || (unsigned)scrn>4)
  137.     {
  138.       fprintf( stderr, "Patch origin %d,%d exceeds LFB\n", x,y );
  139.       I_Error ("Bad V_DrawPatch in V_DrawPatchFlipped");
  140.     }
  141. #endif 
  142.  
  143.     if (!scrn)
  144.     V_MarkRect (x, y, SHORT(patch->width), SHORT(patch->height)); 
  145.  
  146.     col = 0; 
  147.     desttop = screens[scrn]+y*SCREENWIDTH+x; 
  148.      
  149.     w = SHORT(patch->width); 
  150.  
  151.     for ( ; col<w ; x++, col++, desttop++) 
  152.     { 
  153.     column = (column_t *)((byte *)patch + LONG(patch->columnofs[w-1-col])); 
  154.  
  155.     /*  step through the posts in a column  */
  156.     while (column->topdelta != 0xff ) 
  157.     { 
  158.         source = (byte *)column + 3; 
  159.         dest = desttop + column->topdelta*SCREENWIDTH; 
  160.         count = column->length; 
  161.              
  162.         while (count--) 
  163.         { 
  164.         *dest = *source++; 
  165.         dest += SCREENWIDTH; 
  166.         } 
  167.         column = (column_t *)(  (byte *)column + column->length 
  168.                     + 4 ); 
  169.     } 
  170.     }             
  171. }
  172.