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