ZDoom ACS disassembler/decompiler

Any utility that assists in the creation of mods, assets, etc, go here. For example: Ultimate Doom Builder, Slade, WadSmoosh, Oblige, etc.
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.
jspenguin

ZDoom ACS disassembler/decompiler

Post by jspenguin »

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.
Attachments
listacs-0.3.zip
More bugfixes: failed reading old-style scripts
(22.92 KiB) Downloaded 2387 times
listacs-0.2.zip
(22.92 KiB) Downloaded 554 times
Last edited by jspenguin on Sun Apr 12, 2009 1:16 pm, edited 1 time in total.
Gez
 
 
Posts: 17831
Joined: Fri Jul 06, 2007 3:22 pm

Re: ZDoom ACS disassembler/decompiler

Post by Gez »

Interesting, I didn't even know there were two different ZDoom formats for compiled scripts...
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by bagheadspidey »

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
Cutmanmike
Posts: 11335
Joined: Mon Oct 06, 2003 3:41 pm
Operating System Version (Optional): Windows 10
Location: United Kingdom
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Cutmanmike »

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
Enjay
 
 
Posts: 26508
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Enjay »

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
Kappes Buur
 
 
Posts: 4114
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Kappes Buur »

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
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Ral22 »

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
Kappes Buur
 
 
Posts: 4114
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Kappes Buur »

I had just posted in http://forum.zdoom.org/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 all

listacs file.o >> file.acs
But all I got was p-code.

Makes me wonder how bagheadspidey did it with soulstlr.o :?:
User avatar
Enjay
 
 
Posts: 26508
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Enjay »

Where is the bag-headed one anyway? I've been missing his presence for some time now.
User avatar
Kappes Buur
 
 
Posts: 4114
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Kappes Buur »

Thanks to disposable_username2 over on http://forum.zdoom.org/viewtopic.php?f= ... 15#p584110 I can now generate the scripts from object files

Code: Select all

listacs -d file.o >> file.acs
It would have been nice if there had been a HowTo.txt with Listacs.
User avatar
Enjay
 
 
Posts: 26508
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Enjay »

Kappes Buur wrote:Thanks to disposable_username2 over on http://forum.zdoom.org/viewtopic.php?f= ... 15#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 all

         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
Kappes Buur
 
 
Posts: 4114
Joined: Thu Jul 17, 2003 12:19 am
Graphics Processor: nVidia (Legacy GZDoom)
Location: British Columbia, Canada
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Kappes Buur »

I exported a BEHAVIOR lump from Daedalus.wad to the listacs directory.
Then I made a batch file with this

Code: Select all

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
Enjay
 
 
Posts: 26508
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Enjay »

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 all

goto_block = 0; restart;
and this failed to compile with ACC:

Code: Select all

**** 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
Ral22
Posts: 531
Joined: Sun Sep 05, 2010 12:09 pm
Preferred Pronouns: He/Him
Location: The Fortress of Dr. Radiaki
Contact:

Re: ZDoom ACS disassembler/decompiler

Post by Ral22 »

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.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: ZDoom ACS disassembler/decompiler

Post by Blue Shadow »

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 all

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 all

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;

}
Post Reply

Return to “Creation, Conversion, and Editing”