Jump to content

Tool for creating Dune2 WSA files


Blade

Recommended Posts

As part of a project to develop an OpenDUNE style open source version of Red Alert, I've created a number of command line tools for creating the files used in the C&C games. Since the Dune2 WSA format is so similar to the C&C one, it wasn't much work to write a tool that creates the D2 versions either. If you would like to give it a go, the tool is part of a package and is d2wsaset, the tools can be downloaded from http://omniblade.cncnet.org/tools.zip. The tool is untested currently so any feedback on if the files it generates actually work in game would be helpful.

 

The tool takes pcx files only and has options to set a loop frame and include the palette in the file. I'm not sure if Dune2 uses these options on its wsa files, so you may need to experiment or look at the existing files with a hex editor and a copy of the file format such as found at http://eob.wikispaces.com/lol.wsa. Running the tool without any options will give you instructions for use, a file name is passed to it without any extension.

Link to comment
Share on other sites

I posted a bug report on those tools, they don't handle the Delta field in the header correctly so its hit and miss if a WSA generated by those tools can actually be decoded by the game. I'm not sure how good the compression is in Ultraq's tools, but these match the compression achieved by the code WW used. When I was testing the C&C version I round tripped a couple of C&C WSA files and it even shaved a few bytes off because the format40 (actually called XORDelta by WW) encoder in this tool is slightly more efficient than the WW one was.

Link to comment
Share on other sites

I do remember the WSA files I created for Dune 2 eXtended were of a different size, and I had to play around with that parameter which governs animation speed. However, they all work fine, I don't remember any crashes.

BTW, I'm certainly going to notify Siberian_GRemlin, a known enthusiast of Westwood Studios games, of your tool. He probably will find use for it, as he's an author of a number of custom translations of Westwood titles (not limited to Dune and C&C games).

Link to comment
Share on other sites

Yeah, that animation speed parameter actually controls the size of the buffer the game needs to create to decode the frames, nothing in a WSA file actually flags the playback rate at all. Where the guys who wrote the original docs for the file spec got that from I don't know, just looking at a few related files shows that the value varies too widely to be related to timing. Anyhow, I'd be happy to hear any feedback on successful use of any of the tools, I plan to add a Dune2 shp encoder at some point too :)

Link to comment
Share on other sites

Yes. I used version 0.30 which Ultraq updated at my request to add proper faction colour support for SHPs with variable frame sizes. However, this update introduced the transparent colour bug. Previous versions can only create SHP files with fixed frame size with faction colours, and SHPs with variable frame sizes but without faction colour support.

Link to comment
Share on other sites

Do you have any documentation on how the faction colour system works? I'm guessing it has something to do with the optional palette that can be included in a frame? If not I guess I'll have to go spelunking in the OpenDUNE code and Ultraqs code to figure it out.

Link to comment
Share on other sites

  • 3 months later...

Okay, so I have a tool that can currently write none remapping dune2 shp files, which is enough to edit the TD/RA mouse cursors, but I've not yet tackled generating the lookup table I think is needed for remap.

I've looked over the code for the Red Horizon and think I know where it goes wrong though, it builds the table in the order it encounters a colour, so if the first pixel it encounters is not 0, that gets position 0 in the lookup. However I believe the game always treats 0 as transparent, it never checks the lookup for it and so 0 must always map to 0 in the lookup or you get this error.

Not that this info helps you right now, but it means I should get it right when I do it ;)

  • Upvote 1
Link to comment
Share on other sites

Okay, so it seems that the faction colors are mainly done by a 16 color lookup table, though a variable size one up to 256 colors is possible. The attached tool will take a series of pcx files named as filename ####.pcx and turn them into a shp called filename.shp. The tool is ran as "d2shpset filename" without either extension. The -l flag will tell it to create a lookup table for faction colors. I believe the 16 color tables will work, I'm not sure about the 17+ extended ones though. I'd need an example file to ensure my code matches it, but it might already work correctly. You can also use -d to disable the LCW (format80) compression for troubleshooting purposes though it will give you larger file sizes. The RedHorizon tools don't use LCW compression as apparently it made Dune2 crash. My LCW algorithm results in the exact same data as the WW code so it shouldn't have that issue, but we'll see.

P.S. Frame sizes are determined by the size of the PCX file they are created from so variable frame sizes are also possible.

d2shpset.zip

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...