home *** CD-ROM | disk | FTP | other *** search
- /*
- * Zoom function
- *
- * Patrice Mandin
- */
-
- #include "doomtype.h"
- #include "doomdef.h"
- #include "z_zone.h"
- #include "i_zoom.h"
-
- static int zoomwidth=0;
- static int zoomheight=0;
-
- static int *zoomxtable=NULL;
- static int *zoomytable=NULL;
- /*
- void *zoomedscreen=NULL;
- */
- void I_ZoomInit(int dstwidth,int dstheight)
- {
- int i;
- int *zoomtable;
-
- /* Recalculate x table ? */
-
- if (dstwidth!=zoomwidth)
- {
- if (zoomxtable!=NULL)
- {
- Z_Free(zoomxtable);
- }
- zoomtable = zoomxtable = Z_Malloc(dstwidth*sizeof(int), PU_STATIC, NULL);
-
- for (i=0;i<dstwidth;i++)
- {
- *zoomtable++ = (SCREENWIDTH*i)/dstwidth;
- }
- zoomwidth=dstwidth;
- }
-
- /* Recalculate y table ? */
-
- if (dstheight!=zoomheight)
- {
- if (zoomytable!=NULL)
- {
- Z_Free(zoomytable);
- }
- zoomtable = zoomytable = Z_Malloc(dstheight*sizeof(int), PU_STATIC, NULL);
-
- for (i=0;i<dstheight;i++)
- {
- *zoomtable++ = (SCREENHEIGHT*i)/dstheight;
- }
- zoomheight=dstheight;
- }
- }
-
- void I_Zoom8(byte *srcscreen,byte *dstscreen)
- {
- int x,y;
- int *zoomx,*zoomy;
- byte *dstline;
-
- dstline=dstscreen;
-
- zoomy=zoomytable;
- for (y=0;y<zoomheight;y++)
- {
- byte *srcline;
-
- srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
-
- zoomx=zoomxtable;
- for (x=0;x<zoomwidth;x++)
- {
- *dstline++ = srcline[*zoomx++];
- }
- }
- }
-
- void I_Zoom16(unsigned short *srcscreen,unsigned short *dstscreen)
- {
- int x,y;
- int *zoomx,*zoomy;
- unsigned short *dstline;
-
- dstline=dstscreen;
-
- zoomy=zoomytable;
- for (y=0;y<zoomheight;y++)
- {
- unsigned short *srcline;
-
- srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
-
- zoomx=zoomxtable;
- for (x=0;x<zoomwidth;x++)
- {
- *dstline++ = srcline[*zoomx++];
- }
- }
- }
-
- void I_Zoom24(byte *srcscreen,byte *dstscreen)
- {
- int x,y;
- int *zoomx,*zoomy;
- byte *dstline;
-
- dstline=dstscreen;
-
- zoomy=zoomytable;
- for (y=0;y<zoomheight;y++)
- {
- byte *srcline;
-
- srcline=srcscreen+(*zoomy++)*SCREENWIDTH*3;
-
- zoomx=zoomxtable;
- for (x=0;x<zoomwidth;x++)
- {
- *dstline++ = srcline[*zoomx];
- *dstline++ = srcline[*zoomx];
- *dstline++ = srcline[*zoomx++];
- }
- }
- }
-
- void I_Zoom32(unsigned long *srcscreen,unsigned long *dstscreen)
- {
- int x,y;
- int *zoomx,*zoomy;
- unsigned long *dstline;
-
- dstline=dstscreen;
-
- zoomy=zoomytable;
- for (y=0;y<zoomheight;y++)
- {
- unsigned long *srcline;
-
- srcline=srcscreen+(*zoomy++)*SCREENWIDTH;
-
- zoomx=zoomxtable;
- for (x=0;x<zoomwidth;x++)
- {
- *dstline++ = srcline[*zoomx++];
- }
- }
- }
-
-