Announcement

Collapse
No announcement yet.

The MOO2 LBX format explained...

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • The MOO2 LBX format explained...

    I've figured out almost everything concerning the LBX package, palette and image formats. I will give a brief summary of my findings so far in the hope that someone else can fill the holes.

    The LBX archive format itself is really simple. It has a header:
    2 bytes = number of files in archive
    4 bytes = verification code (should always be 65197)
    2 bytes = unknown (version? file type? i am not convinced by either)
    then follows the offsets of all the files in the archive at 4 bytes each, pluss the offset of the end of the file, which should be identical to the file size.

    The palette format seems quite simple, 4 bytes for each value of 256 colours as follows:
    1 byte is always the value 1
    1 byte for red, 1 for green, and 1 for blue
    However, the values are 6bits, and to use them you need to multiply them by 4 to get meaningful values. Strange. There seems to be a lot of junk data after this - if it means anything I cannot make head and tails out of it.

    The image format is complicated and not very bright. There is a header:
    2 bytes = width
    2 bytes = height
    2 bytes = unknown (always zero, I think)
    2 bytes = number of offsets
    2 bytes = number of frames, always(?) one less than above
    2 bytes = unknown
    4 bytes = offset to beginning of image data
    then follows a list of 4 byte offsets to each frame, relative to the beginning of the archived file (not the LBX file!), and the last one points to the end of the archived file.

    If there now is space between our current position and the image data, there is palette override information here. This has the following format:
    1 byte = index into palette; or zero if you should just increase your palette counter by one, to point to the next palette entry (yes, there is no good reason for doing it this way)
    1 byte red, 1 byte green, 1 byte red; as above, multiply values by four.

    Next follows the image data. Read each 'line' as follows: The first 2 bytes indicates data format. If it is zero _or_ if it is the first byte, in which case it is always one, read it like this:
    2 bytes = increase y counter (start at zero) by this amount; if this number is 1000, immediately abort; this is an EOF marker, and beyond this may be junk data. Jump to next frame offset when you find an EOF.
    2 bytes = number of pixels in pixel array
    2 bytes = x position in image where you should start laying pixels
    then follows 1 byte for each pixel.
    If the first 2 bytes are more than zero, then this number is the number of 1-byte pixels following. I believe they should be added at the current (x,y) position, but they are special in some way I do not yet understand. I get some artifacts in some of the images that use this.

    Some images need additional palettes to be shown properly. The ships, for instance, have palette override information in a 2x1 image that is in every 49th ships.lbx image. This image contains illegal junk data, and should not be processed. This probably also applies to other 2x1 or 1x1 images. If you use palette 12 in fonts.lbx with one of these override palettes, you get the correct palette for the given player.

    I have written .c code to read this data and display it. If anyone is desperate to see it in its current unfinished state, just let me know.

    Time for some sleep....

  • #2
    Concerning the two ways that data is stored in the LBX, my interpretation of the data format is obviously correct, but I suspect it is not the whole story. Everything done the second way can be done better using the first way, so why did they create two ways to store the image data?

    Most of the ship images do not contain any data of the second type. Attached are some examples of ships that contain both. In the second column is the ship drawn using only data of the first type, and the third column using only data of the second type. The first column contains both.

    Would anyone try a guess?
    Attached Files

    Comment


    • #3
      Is this yours:

      Comment


      • #4
        No, but I read this page, and it helped me along.

        Comment


        • #5
          R u bio?

          He published the LBXplorer (still beta) some years ago.

          Dunno if u understand german?!

          Bio wrote here ( http://www.crazy-board.net/vB/showpo...37&postcount=5 ) that he will finish his work soon...

          The new version can read and edit lbx-files of MOO, MOO2 and MOM.
          "Football is like chess, only without the dice." Lukas Podolski

          Comment


          • #6
            No, I am not bio. Nor do I understand much German, I'm afraid. If someone could inform bio that we're duplicating each others work, I would be grateful.

            Is there a new version of lbxexplorer somewhere? The version I have has lots of palette problems and in general is not very helpful.

            I have figured out the problems I had with image data of the second type. It appears the second byte for that data type is what you need to add to your x axis when you lay the pixels. It is a weird format, incredibly inefficient. Oh, well.

            I'm almost done figuring out the animations and the palettes now, and I can view almost all the graphics as they are in the game.

            Comment


            • #7
              bio just wrote 1 post in that forum...

              and he hasnt published his email...

              but u can ask the forum-administration to send him ur mail: info@crazy-board.net
              "Football is like chess, only without the dice." Lukas Podolski

              Comment


              • #8
                I have done programming before (Amiga and VIC20!!!) and I have an aptitude for it. Could someone explain to me how I should go about getting into hacking these LBX (and other) files. What programs do I need/ what programming language(s) do I need to learn.

                I want to do this, as I have been monkeying around with the tech trees using OCL and am trying to create a very different game setting. The problem is, I can't edit the text that explains what the techs do. Therefore, if I want to play multiplayer, nobody but me will know what everything does.
                I could write a document to go with it, but this seems to be a poor solution.

                Or alternatively, if that file is easy to crack (being mianly just text) could someone make something like OCL to deal with this issue. Then the OCL editor will truly come into its own.

                M

                Comment


                • #9
                  Originally posted by Per
                  Most of the ship images do not contain any data of the second type. Attached are some examples of ships that contain both. In the second column is the ship drawn using only data of the first type, and the third column using only data of the second type. The first column contains both.

                  Would anyone try a guess?
                  They were planning on releasing a mod to the public for us to customize new ships?
                  "BANANA POWAAAAH!!! (exclamation Zopperoni style)" - Mercator, in the OT 'What fruit are you?' thread
                  Join the Civ2 Democratic Game! We have a banana option in every poll just for you to vote for!
                  Many thanks to Zealot for wasting his time on the jobs section at Gamasutra - MarkG in the article SMAC2 IN FULL 3D? http://apolyton.net/misc/
                  Always thought settlers looked like Viking helmets. Took me a while to spot they were supposed to be wagons. - The pirate about Settlers in Civ 1

                  Comment


                  • #10
                    Morraine said:

                    The problem is, I can't edit the text that explains what the techs do.
                    This should be easy, if I understand you. The "help.lbx" has text that is readable with a hex editor.

                    As a test, I altered what it said for the Achilles Targeting thingee, then saved it. Sure enough, the altered text popped up when right-clicking in tech review, and also when right-clicking on the ship system in the ship design screen.

                    The particular hex editor I used is here:



                    BTW, the "defense" mod makes mention of a "help.lbx" that was supposed to come with it, but which seems to have been lost in the download sites.

                    Comment


                    • #11
                      Hi Freeciv,

                      I would really be interested in taking a look at your code Freeciv! I have been looking for a way to replace the images in the game with some of my own.

                      Could someone suggest a way to do this?

                      Cheers!
                      -Phil

                      Comment


                      • #12
                        A mod for MoO 2 would sooooo cool...
                        "BANANA POWAAAAH!!! (exclamation Zopperoni style)" - Mercator, in the OT 'What fruit are you?' thread
                        Join the Civ2 Democratic Game! We have a banana option in every poll just for you to vote for!
                        Many thanks to Zealot for wasting his time on the jobs section at Gamasutra - MarkG in the article SMAC2 IN FULL 3D? http://apolyton.net/misc/
                        Always thought settlers looked like Viking helmets. Took me a while to spot they were supposed to be wagons. - The pirate about Settlers in Civ 1

                        Comment


                        • #13
                          Zealot: there is already a mod , actually a couple of them. The mainstream one is developed and constantly enhanced by Lordbrazen. There are also a few other mods out there. Another one gaining momentum is a mod by 7.

                          Comment

                          Working...
                          X