un-wasm

General Mech2 related Developments go here. Discussions welcome!

Moderator: Skyfaller

Forum rules
If you are writing a guide please do not post it here! Post in the Dev FAQ section please.
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

un-wasm

Post by quota4stupid »

It's far from perfect/complete, but I've knocked together a little application to decompile BWD files back into WASM source. It can be downloaded here. It requires the Java 6 runtime, which can be downloaded from here if you don't already have it.

From the command line "java -jar jmw2.jar" will print out usage instructions. As an example (assuming you have Mercenaries installed in C:\MERCS) running:

Code: Select all

java -jar jmw2.jar unwasm -source C:\MERCS\MW2.PRJ -all
from the command line will decompile all of the BWD files in the Mercs project file into the current directory.

The output files *should* be compilable with WASM, but don't always work properly. The following is a list of bugs/shortcomings that I know about:
  • Star names (used in the "star" and "mission" constructs) aren't actually stored in the BWD chunks that use them - instead they are identified by a "group ID" value. I make a best effort to properly map these ID values back to star names by searching the including gp_spec BWD files, but sometimes there are gaps, in which case I try to make a guess at the name. It doesn't always work :-P
  • There is a similar situation with object names - these aren't stored in the BWD either (again, the binary uses ID values). In this case I wrangle up a name based on the name of the geometry file the object uses. This mostly works OK, but some of the MEC files make for ugly reading.
  • There is an "critical" value in the mission tables that I can't identify, and it's driving me insane! :-P The various mission building FAQs only identify "Mandatory" and "Optional", but there is a 3rd value! I can't find anything by hexdumping WASM.EXE either, so at the moment it just craps out if it encounters this value :-(
  • I haven't been bothered decoding the weapon/ammo ID values yet (this wont be hard, just time consuming - I will get to it eventually :-)). As such, any place weapons/ammo are refered to in the xxxxCAM1.BWD files, I output the numeric value but comment it out (since WASM expects a name).
  • I haven't decoded the VWSP chunk yet (only occurs once in MW2MECH.BWD, and probably isn't all that important anyway), so this doesn't get decompiled.
  • Likewise, I'm still working on the patch record in the WTHR chunk, so these wont decompile yet either (having said that, they don't appear to be used in any BWD anyway, so it doesn't really matter).
  • It will output a lot of warnings about chunks that have unknown fields and how data may be lost - this is nothing to panic about, it just means those particular chunks still have bytes I haven't decoded yet, so when they are exported back to WASM source, there may be some loss of information... practically speaking though, I don't think anything important is missing... probably ;-)
  • I've also got an issue, when trying to recompile sources, of WASM complaining that certain files (generally audio in mission tables) don't exist in the project file. It also complains of not being able to find "Null" in the project file when this is used to indicate "no file" in the mission table, despite the fact that this is what the DEM1 and DEM2 examples in the Mercs tools directory use!! :-P
I've written this to help me finish decoding the last little bits of the BWD format, but I thought there might be a few people here who might be interested in it too :-) If you do use it and find any bugs or problems not listed above, please let me know.
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: un-wasm

Post by Col.Kell »

:shock: Wow.
I am so going to test this. I was saddened by believing allmhuran's words that Ed Wong had a BWD-to-text converter lost to time.
There is an "critical" value in the mission tables that I can't identify, and it's driving me insane! :P
I do have some useful info that may help you on that, quota. Please take a look at my notes here in this thread.
MechWarrior 2: 31stCC
Image
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: un-wasm

Post by quota4stupid »

Col.Kell wrote::shock: Wow.
I am so going to test this. I was saddened by believing allmhuran's words that Ed Wong had a BWD-to-text converter lost to time.
I hope you find it useful despite its flaws. Most of the output can be recompiled back to BWD with WASM, but I had a lot of troubles trying to get xxxxSCN1.WLD files to recompile - it seems that a lot of the audio files they link to aren't actually in the project file :-P Not to mention that WASM suddenly decides that specifying "Null" as a mission objective target is invalid, despite it being used that way in the samples on the CD! :-P

Having said that, I think you might enjoy looking over the mission tables in some of those files - some of the ones actually used in game are quite intricate - it's pretty cool stuff :-D
Col.Kell wrote:
There is an "critical" value in the mission tables that I can't identify, and it's driving me insane! :P
I do have some useful info that may help you on that, quota. Please take a look at my notes here in this thread.
Thanks, but no luck :-( The mystery value is 0x4E, which means there's a 3rd option (Mandatory, Optional, ?) but I can't find ANY hint of it anyway (none of the mission building FAQs, not in the 3D editor, not in WASM.EXE hexdump - NOWHERE!) It is supremely frustrating... Ultimately, I think the only way I'm going to be able to assign a label to it is by experimenting with the sim - build a custom mission, insert the mystery value, and try to figure out how it effects the game :-P Maybe later this week...
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: un-wasm

Post by Col.Kell »

4E? I only know of 4D and 4F... no clue what that value is. Maybe I'll put 4E into a mission objective and see what happens. I'll have to check that out and try the unwasm in a couple of days, I have to leave town for a while and won't be back til then, I have friends to visit and a C\SrA CAP promotion to celebrate (check my rank sig the next few days :) )
MechWarrior 2: 31stCC
Image
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: un-wasm

Post by quota4stupid »

Col.Kell wrote:4E? I only know of 4D and 4F... no clue what that value is.
And so you see why it drives me mad! ;-)
Col.Kell wrote:I have to leave town for a while and won't be back til then
Who did you kill? ;-)
Col.Kell wrote:I have friends to visit and a C\SrA CAP promotion to celebrate (check my rank sig the next few days :) )
Have fun :-)
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: un-wasm

Post by Col.Kell »

I'm back!
quota4stupid wrote:
Col.Kell wrote:4E? I only know of 4D and 4F... no clue what that value is.
And so you see why it drives me mad! ;-)
Ah the little anoying things... kinda like when I aborted the construction of two KAM mechs because I didn't know how to put in negative xyz values. xP
quota4stupid wrote:
Col.Kell wrote:I have friends to visit and a C\SrA CAP promotion to celebrate (check my rank sig the next few days :) )
Have fun :-)
:) And I have, promoting to Senior Airman was great. Now I need to get to changing my sig now. :P
MechWarrior 2: 31stCC
Image
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: un-wasm

Post by Col.Kell »

One quick question; if I want Java Runtime 6 for my Windows XP (32bit), which one should I get?
MechWarrior 2: 31stCC
Image
User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: un-wasm

Post by quota4stupid »

Col.Kell wrote:One quick question; if I want Java Runtime 6 for my Windows XP (32bit), which one should I get?
"JRE6 Update 13" for "Windows" (the other two Windows options are different 64-bit flavours) :-)
User avatar
Sir MMPD Radick
Clan Nova Captain
Clan Nova Captain
Posts: 1625
Joined: Tue Jan 22, 2008 10:07 am

Re: un-wasm

Post by Sir MMPD Radick »

Kell always go grab the latest one off of the sun website.

(Heh looks like quota beat me to posting by a few sec)
James 3:5-10: My Reminder
And the tongue is a fire, a world of iniquity: so is the tongue among our members, that it defileth the whole body. Out of the same mouth proceedeth blessing and cursing. My brethren, these things ought not so to be.
User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: un-wasm

Post by Col.Kell »

== Gone til' Monday morning -- CAP SAREX ==
MechWarrior 2: 31stCC
Image
Post Reply