home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / games / doom / pmdoom / src / i_zoom.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-12-17  |  2.5 KB  |  154 lines

  1. /*
  2.  *    Zoom function
  3.  *
  4.  *    Patrice Mandin
  5.  */
  6.  
  7. #include "doomtype.h"
  8. #include "doomdef.h"
  9. #include "z_zone.h"
  10. #include "i_zoom.h"
  11.  
  12. static int zoomwidth=0;
  13. static int zoomheight=0;
  14.  
  15. static int *zoomxtable=NULL;
  16. static int *zoomytable=NULL;
  17. /*
  18. void *zoomedscreen=NULL;
  19. */
  20. void I_ZoomInit(int dstwidth,int dstheight)
  21. {
  22.     int i;
  23.     int *zoomtable;
  24.  
  25.     /* Recalculate x table ? */
  26.     
  27.     if (dstwidth!=zoomwidth)
  28.     {
  29.         if (zoomxtable!=NULL)
  30.         {
  31.             Z_Free(zoomxtable);
  32.         }
  33.         zoomtable = zoomxtable = Z_Malloc(dstwidth*sizeof(int), PU_STATIC, NULL);
  34.  
  35.         for (i=0;i<dstwidth;i++)
  36.         {
  37.             *zoomtable++ = (SCREENWIDTH*i)/dstwidth;
  38.         }
  39.         zoomwidth=dstwidth;
  40.     }
  41.  
  42.     /* Recalculate y table ? */
  43.  
  44.     if (dstheight!=zoomheight)
  45.     {
  46.         if (zoomytable!=NULL)
  47.         {
  48.             Z_Free(zoomytable);
  49.         }
  50.         zoomtable = zoomytable = Z_Malloc(dstheight*sizeof(int), PU_STATIC, NULL);
  51.  
  52.         for (i=0;i<dstheight;i++)
  53.         {
  54.             *zoomtable++ = (SCREENHEIGHT*i)/dstheight;
  55.         }
  56.         zoomheight=dstheight;
  57.     }
  58. }
  59.  
  60. void I_Zoom8(byte *srcscreen,byte *dstscreen)
  61. {
  62.     int x,y;
  63.     int *zoomx,*zoomy;
  64.     byte *dstline;
  65.  
  66.     dstline=dstscreen;
  67.  
  68.     zoomy=zoomytable;
  69.     for (y=0;y<zoomheight;y++)
  70.     {
  71.         byte *srcline;
  72.                 
  73.         srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
  74.  
  75.         zoomx=zoomxtable;
  76.         for (x=0;x<zoomwidth;x++)
  77.         {
  78.             *dstline++ = srcline[*zoomx++];
  79.         }
  80.     }
  81. }
  82.  
  83. void I_Zoom16(unsigned short *srcscreen,unsigned short *dstscreen)
  84. {
  85.     int x,y;
  86.     int *zoomx,*zoomy;
  87.     unsigned short *dstline;
  88.  
  89.     dstline=dstscreen;
  90.  
  91.     zoomy=zoomytable;
  92.     for (y=0;y<zoomheight;y++)
  93.     {
  94.         unsigned short *srcline;
  95.  
  96.         srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
  97.  
  98.         zoomx=zoomxtable;
  99.         for (x=0;x<zoomwidth;x++)
  100.         {
  101.             *dstline++ = srcline[*zoomx++];
  102.         }
  103.     }
  104. }
  105.  
  106. void I_Zoom24(byte *srcscreen,byte *dstscreen)
  107. {
  108.     int x,y;
  109.     int *zoomx,*zoomy;
  110.     byte *dstline;
  111.  
  112.     dstline=dstscreen;
  113.  
  114.     zoomy=zoomytable;
  115.     for (y=0;y<zoomheight;y++)
  116.     {
  117.         byte *srcline;
  118.                 
  119.         srcline=srcscreen+(*zoomy++)*SCREENWIDTH*3;
  120.  
  121.         zoomx=zoomxtable;
  122.         for (x=0;x<zoomwidth;x++)
  123.         {
  124.             *dstline++ = srcline[*zoomx];
  125.             *dstline++ = srcline[*zoomx];
  126.             *dstline++ = srcline[*zoomx++];
  127.         }
  128.     }
  129. }
  130.  
  131. void I_Zoom32(unsigned long *srcscreen,unsigned long *dstscreen)
  132. {
  133.     int x,y;
  134.     int *zoomx,*zoomy;
  135.     unsigned long *dstline;
  136.  
  137.     dstline=dstscreen;
  138.  
  139.     zoomy=zoomytable;
  140.     for (y=0;y<zoomheight;y++)
  141.     {
  142.         unsigned long *srcline;
  143.                 
  144.         srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
  145.  
  146.         zoomx=zoomxtable;
  147.         for (x=0;x<zoomwidth;x++)
  148.         {
  149.             *dstline++ = srcline[*zoomx++];
  150.         }
  151.     }
  152. }
  153.  
  154.