
                             WAXEDIT.TXT v. 1.5
                        _____________________________


Author:

        TheRedDeth@aol.com -- me, Jonathan Wise

Thank yous:

        Cmdr Krud@aol.com -- the one who got me into Dark Forces editing.  He
                gave me many of the editing ideas I've used and many of the 
                ones I will use in later versions.  He is also my first beta-
                tester.  [NEW] I also need to thank him for a lot of help with
                logics.

        CarGoCo@aol.com -- did a lot of the programming and hacking of the WAX
                files that made all this possible.  He wrote WAXVIEW which is 
                included in this package.  [NEW] Thanx for the help with 
                logics.

        My Beta-Testers -- To write a program, it's gotta work, and you guys 
                tested it to make sure that it did.  Lots of thanx to:

                Cmdr Krud@aol.com
                YODA DAGO@aol.com
                MSuther876@aol.com
                Driver9@aol.com
                Tyderian@aol.com

        Daron Stinnett and the rest of the DF crew -- without you guys, none 
                of this would have been possible.  Thanx for a great game (and
                hopefully many more).

        yborckmans@abcomp.linex.com -- Yves provided the editor that all of us
                love so much.  And he has give us the format for a compressed 
                FME, something none of this would have been possible without.
                [NEW] Yet another person who has helped with logics.

        Everyone I forgot to mention -- Thanx for your help.  Sorry I forgot
                to mention ya'.   

Copyright stuff:

   +------------------------------------------------------------------------+
   | Dark Forces is (c) LucasArts Entertainment Company                     |
   | DOOM        is (c) iD Software                                         |
   |                                                                        |
   | None of these have anything to do with these totally unofficial specs, |
   | and shouldn't be bothered with them in any way.                        |
   +------------------------------------------------------------------------+

I don't know why I mentioned DOOM in there.  Actually because I copyed this
Copyright stuff directly out of Yves Borckmans DF_SPECS.DOC file.


Other important last minute stuff:

Feel free to distribute this stuff all you want, as long as it's in its 
original packaging.  No editing the exe's or this text file.  If you want 
source code (C++ only), e-mail me, you have my address.  You can edit the 
source code for your own use only.  You cannot distribute the edited source 
code without my persmission.  So there.

WAX file structure:

typedef struct
{
        int                                     width;                  // width in pixels
        int                                     height;                 // height in pixels
        int                                     compression;    // compression type
        int                                     size;                           // total size of compressed cell
        dword                                   *aOffsets;              // column byte offset table
        dword                                   pad1;
        byte                                    data[];                 // cell data stored in columns
} Cell;

typedef struct
{
        fixed                                   xShift;                 // x center point
        fixed                                   yShift;                 // y center point
        int                                     flip;                           // 0 = none, 1 = h, 2 = v
        Cell                                    *pCell;                 // offset to cell
        fixed                                   unitwidth;              // cell width in feet
        fixed                                   unitheight;             // cell height in feet
        dword                                   pad3;
        dword                                   pad4;
} Frame;

typedef struct
{
        dword                                   pad1;
        dword                                   pad2;
        dword                                   pad3;
        dword                                   pad4;
        Frame                                   *apFrame[32];   // Offsets to frames
} Seq;

typedef struct
{
        fixed                                   worldWidth;             // real-world width in fixed point (16/16)
        fixed                                   worldHeight;    // real-world height in fixed point (16/16)
        int                                     frameRate;              // frames per second
        dword                                   nFrames;                        // number of frames in this wax
        dword                                   pad2;
        dword                                   pad3;
        dword                                   pad4;
        Seq                                     *apSeq[32];             // View table (Offsets)
} Wax;

typedef struct
{
        fixed                                   version;                        // File version control                                                 
        int                                     nSeqs;                  // Number of seqs
        int                                     nFrames;                        // Number of frames
        int                                     nCells;                 // Number of Cells
        dword                                   xScale;                 // x wax scale
        dword                                   yScale;                 // y wax scale
        dword                                   extraLight;             // extra lighting
        dword                                   pad4;
        Wax                                     *apWax[32];             // Offset from file start to each wax           
} WaxHeader;


This is fairly self explanatory (at least the comments are), but I'll go ahead
and explain it anyway.  

note: padX = padding (always 0)
*whatever = pointer to whatever

WaxHeader:

        xScale -- how the WAX gets bigger/smaller on the horizontal scale
        yScale -- ditto, except on the vertical scale
        extraLight -- how much light does the WAX give off

Wax:

        worldWidth -- what it says
        worldHeight -- ditto

Seq:

        nothing important to explain here

Frame:

        xShift -- movement of center to left or right
        yShift -- movement of center up or down
        flip -- Like the 3DO flip.  [NEW] Very important, see section on it
        unitWidth -- the width
        unitHeight -- the height

Cell:  //This is what we extract and put back in

        width -- used to calculate size of Cell if compression == 0
        height -- ditto
        compression -- compression == 0 // not compressed
                       compression == 1 // compressed
        size -- used to calculate size of Cell if compression == 1
        data -- the picture

Hope you now have a thorough understanding of a WAX file structure.


What the programs do/don't do:

        WAX2FME  -- extracts multiple cells from a file
                    eats about 500K, but I think you can manage that if you're
                    able to play Dark Forces
        FME2WAX  -- takes your edited cells and puts them back in the WAX
                    requires that you have complete and unedited versions of 
                    the WAX you are replacing in the directory of the program.
                    [NEW] You do NOT need to make back-ups of the files you   
                    are replacing.  FME2WAX 2.0 does it for you.
        WAXTRACE -- this program traces through the WAX and shows you what the
                    values of stuff are.  It's for you people who want to 
                    create editors, not just edit.
        WAXON    -- views a WAX.  While it may not be essential for editing, it
                    sure is helpful.  Let me tell you, you don't want to edit 
                    without it.
                    [NEW] WAXON is included this time.

How to create a WAX:

This, of course, is the reason you downloaded this program, so I guess I might
as well tell you how to use it.

VIEWING A WAX:
        This is the easiest task.  Just use WAX2FME to extract the Cells, then
        run Yves's FMEVIEW with the new fmes (included with DFUSE).  
        [NEW] I'm not sure if you will be able to view your extracted FME's 
        with FMEVIEW because header1 is not included in the WAX and is thus
        not included in extracted FME's.

CREATING A NEW WAX:
        To do this, you will need CarGoCo's FMECAD.  Use it to create a set of
        new FME's to put in the WAX.  This must be the same number of WAXES as
        there are in the WAX you are replacing.  Then you can use FME2WAX to 
        create a brand spankin' new WAX.

EDITING A WAX:
        To edit a WAX, use WAX2FME on the WAX.  Then use FMECAD to edit the 
        resulting FME's.  You can use FME2WAX to put the new FME's back into 
        a WAX.  You can only edit the uncompressed FME's inside the WAX, as 
        there is no editor available to edit compressed FME's right now.
        [NEW] because of reasons listed above, you can't edit until we know 
        more about header1 of FME's.

[NEW] Flip:
        Now that you know how to edit a WAX, I think it's a good time to bring
        up Flip. If you examine the file structue, you'll notice that there is
        a flip variable.  This can be used make WAX editing simpler and faster
        -- but only if you know how to use it.  It will seem a little 
        complicated at first, but it's worth it in the long term.  If you've 
        done any 3DO editing, I believe it is similar (although I haven't done
        any 3D0 editing myself).  Let me try and explain...

        If you view STORMFIN.WAX (it's best to CarGoCo's waxview, but you can
        extract it if you want), you'll notice all the pictures have the storm
        trooper facing in the same direction (I think it's left).  Now, if 
        you've played the game, you should notice that the Storm Trooper can 
        face left or right.  LA used the flip variable to make it appear as   
        though the storm trooper is facing right.  You can use this too, in 
        the same way.

        I haven't really studied the flip variable much at all.  I just know 
        it is there.  I don't even know what any given value entails.  In my 
        next version of WAXEDIT, I may include a flipping option inside 
        FME2WAX, but for now, we'll have to improvise.  Since, by using 
        FME2WAX, we replace a complete version of the WAX, we know that the 
        flip value will remain intact (exactly as LA used it).  So all we need
        to do is make our new waxes shown from the views that the Storm 
        Trooper (or whatever) is shown.

        It's really not all that difficult.  If you didn't understand it or 
        are having trouble, reread it.  If you're still having trouble, e-mail
        me.

[NEW] A word on logics:

        I'm not exactly the expert on this, so you might be better off talking
        to someone else about the subject.  Through a little bit of work on my
        own, and a lot of help from friends, and a whole lot of listening to 
        other people talk about it, I have managed to piece together a little
        bit about logics.  I have to thank Cmdr Krud for really doing most of
        the work for this section.

        If there's one thing that really holds us still in WAX editing, it's 
        logics.  Logics prevent us from doing a lot of stuff we would really
        like to do.  If only we could edit them...

        Well, before we can edit them, we have to know what they are, and 
        that's a good portion of the problem.  We're not quite sure how 
        they're stored, or where they're stored, or even how they're defined.
        Let's work on the last one for now.

        As it turns out, logics (or at least parts of them) are stored inside
        the WAX's.  This means that we can edit the logics to some degree 
        (though indirectly) through the WAX's.  Flip is one example of this
        (although it's not a very good one).  I think that the xShift and 
        yShift variables are also examples, although I'm not quite sure right
        now (testing is in progress).  What I think these variables are are 
        definitions for how far an object can move in a single ray-trace.  If
        this is true, it means that we can change how fast an enemy is, among
        other things.

        Now that I've speculated about logics enough, let me speculate a 
        little more about what they are.  It is possible that the above is not
        actually part of the logic, but simply used by the logic.  I'm going 
        to give a loose definition of logics, and let you decifer exactly what
        they are.

        As far as I can tell, logics seem to be the Artificial Intelligence 
        for the WAX's.  I think that they also tell the game engine when to 
        load which frame of the wax, and when, and how far, to move the WAX
        at any given time.

        That was pretty complicated.  Even more complicated than flip I 
        suppose.  But, you don't need to read this again to edit WAX's.  It's
        just here to kind of "get you prepared" for the future of WAX editing.
        
        If you formulate any opinions about WAX's, don't hesitate to send them
        to me.  

What you should expect in later versions:

        WAX2FME may be reconfigured to eat less memory 
        FME2WAX may be rewritten so it doesn't have that mean requirement
        WAXTRACE may display more info, and explain what the info means 
        WAXON it depends what CarGoCo wants to do with it
        Expect expansion on the flip variable.  It can save you a lot of 
                editing time, if you know how to use it.

In v. 2.0

        You'll probably see a WAX<->BMP converter
        Maybe an editor for compressed FME's
        [NEW] LOTS of expansion on logics

In v. 3.0

        I can't be certain, but I think you may get a full WAX editor which
        doesn't require you to create huge files.  Don't count on it for sure
        though.  This is a long time in the future, and what happens then, 
        depends on what happens now.

In v. 89.1136

        A Dark Forces 4 editor.  


Well, that's about it.  Enjoy your editing experience, but bear in mind, you
can't edit compressed FME's until and editor for them comes out.  But the most
important thing of all is: HAVE FUN!!!


