ZDoom ACS disassembler/decompiler

Any utility that assists in the creation of mods, assets, etc, go here.
Forum rules
The Projects forums are ONLY for YOUR PROJECTS! If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.

ZDoom ACS disassembler/decompiler

Postby jspenguin » Sat Apr 11, 2009 10:50 pm

A few days ago, I came across a WAD with really cool scripts but no source included. To my dismay, the listacs utility available on the ZDoom download page only supports the old Hexen ACS format.

So, I decided to write my own disassembler. It should support all three formats: Hexen, ZDoom (ACSE), and ZDoom compact (ACSe).
This version includes a rudimentary decompiler as well, although it currently generates spaghetti code.

You'll need Python version 2.5 or later to run it. If you don't want to do a full install of Python, I have a standalone version (using Py2Exe) available here; however, since it includes the Python runtime, it's big (1.72MB) and my bandwidth is limited. If anyone else wants to host it, be my guest.

EDIT: Fixed some bugs.
I probably should have tried to re-compile the output before I posted. Apparently, ACC recognizes 'goto' as a keyword, but not as a statement. Also fixed a bug causing certain script types not to be recognized.
You do not have the required permissions to view the files attached to this post.
Last edited by jspenguin on Sun Apr 12, 2009 1:16 pm, edited 1 time in total.
jspenguin
 

Re: ZDoom ACS disassembler/decompiler

Postby Gez » Sun Apr 12, 2009 11:59 am

Interesting, I didn't even know there were two different ZDoom formats for compiled scripts...
Gez
 
 
 
Joined: 06 Jul 2007

Re: ZDoom ACS disassembler/decompiler

Postby bagheadspidey » Sun Apr 12, 2009 4:49 pm

This is incredible -- great job! I tested it with a fairly complicated acs script and it threw some errors, but it still decoded most of it. Here's the file if you're interested in testing it.
User avatar
bagheadspidey
 
Joined: 21 Oct 2007

Re: ZDoom ACS disassembler/decompiler

Postby Cutmanmike » Tue Apr 14, 2009 2:34 am

Woo! Now I can get a script back I foolishly compiled and didn't keep the source too.

jspenguin wrote:A few days ago, I came across a WAD with really cool scripts but no source included.


Curious, what WAD was that?
User avatar
Cutmanmike
Is it hot in here or is it just ZScript
 
Joined: 06 Oct 2003
Location: United Kingdom

Re: ZDoom ACS disassembler/decompiler

Postby Enjay » Tue Apr 14, 2009 3:33 am

I fully support this and very much look forward to continued work on this. The old compiled format could be very successfully decompiled by a number of tools (the most successful I found was deepdeacc - which could reliably decompile scripts that could usually then be recompiled without error).

However, when the format changed that all broke. Previously I had used deepdeacc to decompile scripts from other people's work to see how things were done and also for my own stuff if I had lost/messed up the original ACS file somehow. Getting decent decompiling functionality back would be a really welcome thing as far as I'm concerned.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: ZDoom ACS disassembler/decompiler

Postby Kappes Buur » Wed Jul 07, 2010 4:41 pm

I just happen to go to jspenguin's website
http://jspenguin.org:81/listacs/
and found that a new version listacs-0.4.zip is available, presumably it has some improvements over the 0.3 version.
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia, Canada

Re: ZDoom ACS disassembler/decompiler

Postby Ral22 » Tue Sep 13, 2011 10:47 am

I seem unable to run this. I've tried both the stand-alone and the version that requires Python (After I installed Python 2.7.2). I'm running it on Windows 7, if it helps.

To summarize what happens, it opens, I see all the instructions in the programs menu for a split second, and then it quits out on it's own.

Any ideas? Or is there a different ACS decompiler I should be using?
User avatar
Ral22
stoneshipMapper
 
Joined: 05 Sep 2010
Location: Land of Dawn and Thunder

Re: ZDoom ACS disassembler/decompiler

Postby Kappes Buur » Tue Sep 13, 2011 11:07 am

I had just posted in viewtopic.php?f=3&t=30840

When I dragged the object file onto listacs.exe, just like you I saw some text scroll by but no output file was generated.
Then I opened cmd and used the command line

Code: Select allExpand view
listacs file.o >> file.acs


But all I got was p-code.

Makes me wonder how bagheadspidey did it with soulstlr.o :?:
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia, Canada

Re: ZDoom ACS disassembler/decompiler

Postby Enjay » Tue Sep 13, 2011 12:27 pm

Where is the bag-headed one anyway? I've been missing his presence for some time now.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: ZDoom ACS disassembler/decompiler

Postby Kappes Buur » Tue Sep 13, 2011 1:27 pm

Thanks to disposable_username2 over on viewtopic.php?f=3&t=30840&p=584115#p584110 I can now generate the scripts from object files

Code: Select allExpand view
listacs -d file.o >> file.acs


It would have been nice if there had been a HowTo.txt with Listacs.
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia, Canada

Re: ZDoom ACS disassembler/decompiler

Postby Enjay » Tue Sep 13, 2011 2:36 pm

Kappes Buur wrote:Thanks to disposable_username2 over on viewtopic.php?f=3&t=30840&p=584115#p584110 I can now generate the scripts from object files.


Can you actually generate actual scripts from the new format object files?

I'm still getting output like this:

Code: Select allExpand view
         8: script 100, type = 1 (OPEN), flags = 0000, argc = 0
           8: PUSHNUMBER 39
          16: PUSHNUMBER 1
          24: PUSHNUMBER 70
          32: SETCAMERATOTEXTURE
          36: PUSHNUMBER 14
          44: PUSHNUMBER 80
          52: PUSHNUMBER 0
          60: LSPEC3 185
          68: PUSHNUMBER 14
          76: PUSHNUMBER 5
          84: PUSHNUMBER 0
          92: PUSHNUMBER 30
         100: PUSHNUMBER 0
         108: LSPEC5 187
etc
etc
etc
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: ZDoom ACS disassembler/decompiler

Postby Kappes Buur » Tue Sep 13, 2011 3:21 pm

I exported a BEHAVIOR lump from Daedalus.wad to the listacs directory.
Then I made a batch file with this
Code: Select allExpand view
listacs.exe -d BEHAVIOR.lmp >> sc.acs


The generated file sc.acs then had this (exert):

script 19 (int local0, int local1) // addr = 1447, flags=0000
{
Generic_Ceiling(local0, 8, 48, 0, 8);
Generic_Floor(local0, 8, 48, 0, 0);
TagWait(local0);
Delay(32);
Generic_Floor(local0, 8, 48, 0, 24);
Ceiling_LowerAndCrush(local0, 4, 20);
TagWait(local0);
Terminate;

}
script 20 (void) // addr = 1491, flags=0000
{
ThingSound(61, 2, 127);
Delay(const: 70);
restart;

}
script 21 (void) // addr = 1500, flags=0000
{
SetPlayerProperty(0, 1, 0);
Teleport_NoFog(1);
Terminate;

}
script 22 (void) // addr = 1511, flags=0000
{
Delay(3);
ACS_Execute(100, 12, 0, 0, 0);
SetPlayerProperty(0, 0, 0);
Teleport_NewMap(12, 16);
Terminate;

}
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia, Canada

Re: ZDoom ACS disassembler/decompiler

Postby Enjay » Tue Sep 13, 2011 3:26 pm

Hmmm... Daedalus is quite old. I wonder if it uses an older compiled format? I used the same command line as you (except the file names) on a newish file of mine and just got the "pushnumber" output listed above.

[edit] Trying an old behavior lump from Hexen, I did get a readable and compilable script. So perhaps it can do the old ones but not the new ones. [/edit]

[edit2] Forget that. It was just me getting things wrong. I do get proper output from listacs. [/edit2]

[edit3] Although part of the output was:

Code: Select allExpand view
goto_block = 0; restart;


and this failed to compile with ACC:

Code: Select allExpand view
**** ERROR ****
Line 161 in file "C:\Doom\zdoomutils\~TEST.acs" ...
C:\Doom\zdoomutils\~TEST.acs:161: goto_block : Identifier has not been declared.

>     goto_block =
>                ^
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: ZDoom ACS disassembler/decompiler

Postby Ral22 » Wed Sep 14, 2011 12:38 am

Well, ListACS seems to be working, so it is just me then. Is it possible that one of you could make a small How-To guide? I would greatly appreciate it if you could.
User avatar
Ral22
stoneshipMapper
 
Joined: 05 Sep 2010
Location: Land of Dawn and Thunder

Re: ZDoom ACS disassembler/decompiler

Postby Blue Shadow » Wed Sep 14, 2011 1:51 am

Is it a limit that it doesn't back-convert fixed point numbers to be fixed point numbers instead of what they represent? Check this out.

This is a script from the original acs file...
Code: Select allExpand view
Script S_HPMXUP (void)
{
  int hp_increase = random(1, 5);

  AmbientSound("misc/maxup", 64);
  HudMessage(s:"Maximum Health increased..."; HUDMSG_TYPEON, 1, CR_WHITE, 0.5, 0.1, 3.0, 0.03, 1.5);
  SetActorProperty(0, APROP_SPAWNHEALTH, GetActorProperty(0, APROP_SPAWNHEALTH) + hp_increase);
  SetActorProperty(0, APROP_HEALTH, GetActorProperty(0, APROP_HEALTH) + hp_increase);
}

...and this is the one from the decompiled one.
Code: Select allExpand view
script 906 (void) // addr = 444, flags=0000
{
    int local0;
    local0 = Random(1, 5);
    AmbientSound("misc/maxup", 64);
    HudMessage(s:"Maximum Health increased..."; 2, 1, 9, 32768, 6553, 196608, 1966, 98304);
    SetActorProperty(APROP_Health, 17, 17);
    SetActorProperty(APROP_Health, 0, 0);
    Terminate;

}
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD (Modern GZDoom)

Next

Return to Editors / Asset Manipulation

Who is online

Users browsing this forum: No registered users and 0 guests