]> 4ch.mooo.com Git - 16.git/blobdiff - 16/WOLFSRC/MUNGE.C
got 8086 port of wolf3d to work and sod to work
[16.git] / 16 / WOLFSRC / MUNGE.C
diff --git a/16/WOLFSRC/MUNGE.C b/16/WOLFSRC/MUNGE.C
new file mode 100755 (executable)
index 0000000..87f9eb7
--- /dev/null
@@ -0,0 +1,48 @@
+\r
+/*\r
+=================\r
+=\r
+= VL_MungePic\r
+=\r
+=================\r
+*/\r
+\r
+void VL_MungePic (unsigned char far *source, unsigned width, unsigned height)\r
+{\r
+       unsigned        x,y,plane,size,pwidth;\r
+       unsigned char   far *temp, far *dest, far *srcline;\r
+\r
+       size = width*height;\r
+\r
+       if (width&3)\r
+               errout ("VL_MungePic: Not divisable by 4!\n");\r
+\r
+//\r
+// copy the pic to a temp buffer\r
+//\r
+       temp = (unsigned char far *)farmalloc (size);\r
+       if (!temp)\r
+               errout ("Non enough memory for munge buffer!\n");\r
+\r
+       _fmemcpy (temp,source,size);\r
+\r
+//\r
+// munge it back into the original buffer\r
+//\r
+       dest = source;\r
+       pwidth = width/4;\r
+\r
+       for (plane=0;plane<4;plane++)\r
+       {\r
+               srcline = temp;\r
+               for (y=0;y<height;y++)\r
+               {\r
+                       for (x=0;x<pwidth;x++)\r
+                               *dest++ = *(srcline+x*4+plane);\r
+                       srcline+=width;\r
+               }\r
+       }\r
+\r
+       free (temp);\r
+}\r
+\r