Results 1 to 4 of 4

Thread: Help on compressed file from OLD DOS game

  1. #1
    Member
    Join Date
    Aug 2015
    Location
    Italy
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Question Help on compressed file from OLD DOS game

    Hi there, I am here to ask your opinion about a LZW compressed file that I can't decode.
    It should be quite simple, in fact, cause the text contained is almost readable, but there are some special characters that should be decoded exactly and I can't manage to find their position and value by hand.
    Could it be a LZSS dialect? It seems to have a recursive flag byte that tells which of the following 8 bytes are compressed or not: 0xFF mostly at the beginning of the file, tells that no byte is compressed, 0xFE only the first etc..
    Sorry guys but I am not exactly into compression thingies, I am reporting statements of a friend of mine...

    FTR the game is "Centurion defender o Rome".

    I'll appreciate any help!
    Cheers.
    Attached Files Attached Files
    Last edited by theruler; 15th August 2015 at 16:02.

  2. #2
    Programmer Jan Ondrus's Avatar
    Join Date
    Sep 2008
    Location
    Rychnov nad Kněžnou, Czech Republic
    Posts
    278
    Thanks
    33
    Thanked 137 Times in 49 Posts
    Is this correct?

    Code:
    h‹¬3Hannibal does not parley with junior officers.  Prepare for battle!~The master of Carthage doesn't deal with underlings.  Prepare for battle!~I beat your best generals, and now I am sent a subaltern? The war resumes. Hail, General! Do you seek a parley before the battle?  Ho! You intend this as a joke? As long as your legions are in Carthage, there can be no peace. In the face of a weaker foe? Oh, I think not. Hannibal does not surrender.  Not to Rome, not to anyone. Trust? Between Rome and Carthage? I am no politician, but I assure you Carthage will not be Rome's willing servant. Your bravado is most entertaining. Leave Carthage now, or fight us. Impossible.  Sound the call for battle!~Farewell, Roman.  To arms!~A foul Roman dream.  On with the war! Oh, I hardly think so, Roman. 
    
    Ľę8˝ÝSarmatia has no room for Romans.  You must leave. Rome sends a great warrior.  We have heard of you.~A great general arrives! Your fame precedes you.~Others have told us you would come.  They also told us what you would want.  Ah yes, the peace of slavery. There can be no peace between us. We are not stupid.  Your weakness is apparent. No, friend.  There will be no surrender. We trust no one.  It profits us not. This can never be, for we will not serve you. You are a windbag.  You bore me. Lay down your weapons and we will spare you. Surrender and we can talk.  Or would you fight us?~No.  Unless you leave Sarmatia, we must fight.~No, Roman.  You may surrender now. Sarmatians make war, not peace.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main(int argc, char **argv) {
      int buffer[65536];
      int b1, b2, pos = 0;
      FILE *in=fopen(argv[1],"rb");
      if (!in) perror(argv[1]), exit(1);
      FILE *out=fopen(argv[2],"wb");
      if (!out) perror(argv[2]), exit(1);
      for (int k = 0; k < 22; k++) { int c1=getc(in); } // skip first 22 bytes
      for (;;) {
        int c=getc(in);
        if (c==EOF) break;
        for (int i = 0; i < 8; i++)
        {
          if ((c & (1 << i)) != 0) {
            // literal
            int x=getc(in);
            putc(x, out); buffer[pos] = x; pos++;
          } else {
            // match
            if ((b1=getc(in)) == EOF) break;
            if ((b2=getc(in)) == EOF) break;
            int matchpos = b1 + ((b2 / 16) * 256) + 2;
            for (int j = 0; j < (b2 & 15) + 3; j++)
            {
                int x = buffer[matchpos + j];
                putc(x, out); buffer[pos] = x; pos++;
            }
          }
        }
      }
      return 0;
    }
    Attached Files Attached Files
    • File Type: zip a.zip (14.7 KB, 72 views)

  3. The Following User Says Thank You to Jan Ondrus For This Useful Post:

    theruler (15th August 2015)

  4. #3
    Member
    Join Date
    Aug 2015
    Location
    Italy
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Yes, IT IS!
    Thank you for providing me also the bin, you made my day.
    Would you tell me more about the algorithm? Is that a well known encoding method?
    and your code? Why the first 22 bytes are skipped? The dictionary?
    Sorry to bother you but compression is VERY interesting, even though I don't know much.

    I am working on a fan translation (into italian) of that old dos game and I was stuck at 90% roadmap!
    A BIG THANK YOU, AGAIN.

  5. #4
    Member
    Join Date
    Aug 2015
    Location
    Italy
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hi again Jan,
    I did some tests and found that 16 bytes you discarded at the beginning are actually useful data. The first 4 bytes are the uncompressed size of the file.

    for the record here is the code modified by another forum's user:
    Code:
    for (int k = 0; k < 4; k++) { int c1=getc(in); } // skip first 4 bytes
    ...
    int matchpos = b1 + ((b2 / 16) * 256) + 2 + 16;
    cheers!

Similar Threads

  1. My new Game Repacks - High Compression
    By hdneo in forum Data Compression
    Replies: 9
    Last Post: 10th July 2014, 22:24
  2. Game.Repack.Maker
    By Shamil Khan in forum The Off-Topic Lounge
    Replies: 4
    Last Post: 1st August 2013, 03:17
  3. Replies: 6
    Last Post: 24th April 2012, 13:50
  4. Bit guessing game
    By Shelwien in forum Data Compression
    Replies: 11
    Last Post: 24th November 2009, 02:22
  5. Replies: 3
    Last Post: 10th November 2007, 22:32

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •