OSDN Git Service

got 8086 port of wolf3d to work and sod to work
[proj16/16.git] / 16 / WOLFSRC / MUNGE.C
1 \r
2 /*\r
3 =================\r
4 =\r
5 = VL_MungePic\r
6 =\r
7 =================\r
8 */\r
9 \r
10 void VL_MungePic (unsigned char far *source, unsigned width, unsigned height)\r
11 {\r
12         unsigned        x,y,plane,size,pwidth;\r
13         unsigned char   far *temp, far *dest, far *srcline;\r
14 \r
15         size = width*height;\r
16 \r
17         if (width&3)\r
18                 errout ("VL_MungePic: Not divisable by 4!\n");\r
19 \r
20 //\r
21 // copy the pic to a temp buffer\r
22 //\r
23         temp = (unsigned char far *)farmalloc (size);\r
24         if (!temp)\r
25                 errout ("Non enough memory for munge buffer!\n");\r
26 \r
27         _fmemcpy (temp,source,size);\r
28 \r
29 //\r
30 // munge it back into the original buffer\r
31 //\r
32         dest = source;\r
33         pwidth = width/4;\r
34 \r
35         for (plane=0;plane<4;plane++)\r
36         {\r
37                 srcline = temp;\r
38                 for (y=0;y<height;y++)\r
39                 {\r
40                         for (x=0;x<pwidth;x++)\r
41                                 *dest++ = *(srcline+x*4+plane);\r
42                         srcline+=width;\r
43                 }\r
44         }\r
45 \r
46         free (temp);\r
47 }\r
48 \r