Deutex Gfx compression

  • From: Andrew Apted <aapted@xxxxxxxxxxxxxxx>
  • To: yadex@xxxxxxxxxxxxx
  • Date: Thu, 25 Dec 2003 15:46:44 +1100

Hey,

Attached is a patch to Deutex 4.4.0 which compresses Doom
graphics a bit [removes duplicate columns].  It's probably
too slow to include as-is, maybe needs an option, I dunno,
posting here in case someone is interested.

Merry Christmas to all,
--
Andrew Apted  <ajapted@xxxxxxxxxxxxxxxxxxxxx>
--- src/picture.c.org   2003-12-25 12:36:43.000000000 +1100
+++ src/picture.c       2003-12-25 12:45:12.000000000 +1100
@@ -34,6 +34,7 @@
 #include "color.h"
 #include "usedidx.h"
 
+int pic_compress = 1;
 
 /*
  *     parse_pic_header
@@ -471,7 +472,39 @@
   write_i16_le (&pichead->Yinsr, Yinsr);
   colnpos=colnbase;
   for(x=0;x<rawX;x++)
-  { write_i32_le (ColOfs + x, colnpos);
+  { if (pic_compress)
+    {
+      /* AJA 2003-12-25: PIC compression, when two columns are exactly the
+       * same then we only need to store the pixels for one, and make both
+       * column pointers point to it.
+       */
+      Int16 x2,y2;
+      char pix2;
+      for (x2 = x-1; x2 >= 0; x2--)
+      {
+        for(y2 = 0; y2 < rawY; y2++)
+        {
+          rawpos=((Int32)x)+((Int32)rawX)*((Int32)y2);
+          pix=raw[rawpos];
+
+          rawpos=((Int32)x2)+((Int32)rawX)*((Int32)y2);
+          pix2=raw[rawpos];
+
+          if (pix != pix2)
+            break;
+        }
+
+        if (y2 == rawY)  // SAME !
+          break;
+      }
+
+      if (x2 >= 0)
+      {
+        ColOfs[x] = ColOfs[x2];
+        continue;
+      }
+    }
+    write_i32_le (ColOfs + x, colnpos);
     setpos=0;
     lastpix=transparent;
     for(y=0;y<rawY;y++)

Other related posts: