ZDoom ACS disassembler/decompiler
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.
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.
-
- Posts: 1097
- Joined: Tue Nov 03, 2009 9:19 am
Re: ZDoom ACS disassembler/decompiler
There is no distinction between a fixed point number and an integer. 1.0 is in no way distinct from 1<<16. The basic form is the integer value. Going by your example, you really could use the value 98304 as a fixed point number, in which case it would indeed be understood as 1.5, and the function random(0.5, 1.5) is utterly equal to the function random(6553, 98304).
Only the integer constants actually exist in compiled code.
Only the integer constants actually exist in compiled code.
-
- Posts: 5039
- Joined: Sun Nov 14, 2010 12:59 am
Re: ZDoom ACS disassembler/decompiler
I realize that, but what I want to know here is, could this process go the other way (converting integers back to fixed point numbers)? Because to me, 1.5 makes more sense than 98304.
-
- Posts: 1097
- Joined: Tue Nov 03, 2009 9:19 am
Re: ZDoom ACS disassembler/decompiler
Well... If you compile
I believe you will produce exactly the same bytecode as if you compileSo somebody must know or guess what the int represents, because it contains none of that information itself.
You could use a separate app on the resultant text file, to find all int-constants in the file, highlight them in context and ask if you want it converted to fixed point notation.
Either that, or an extremely clever and well informed decompiler that checks what functions a constant seems to be used for and guesses what notation is most appropriate. I don't think that feature is worth adding.It will still be guessing.
Code: Select all
script 1 (void) { int i = 1<<16; }
Code: Select all
script 1 (void) { int i = 1.0; }
You could use a separate app on the resultant text file, to find all int-constants in the file, highlight them in context and ask if you want it converted to fixed point notation.
Either that, or an extremely clever and well informed decompiler that checks what functions a constant seems to be used for and guesses what notation is most appropriate. I don't think that feature is worth adding.It will still be guessing.
-
-
- Posts: 4154
- Joined: Thu Jul 17, 2003 12:19 am
- Graphics Processor: nVidia (Legacy GZDoom)
- Location: British Columbia, Canada
Re: ZDoom ACS disassembler/decompiler
While I am not totally clueless, I must admit that the decompiled output from listacs leaves me with a headache.
To wit Enjay's original script for NJMA01.WAD
and the decompiled version of the above from the BEHAVIOR lump
So it seems that the listacs result must be taken with a grain of salt many grains of salt and an Anicin
To wit Enjay's original script for NJMA01.WAD
Code: Select all
//Loads of scripts to break windows
script 3 (int id)
{
int var0;
SetLineSpecial(id,0,0,0,0,0);
thingsound(id, "glass", 127);
Setlineblocking(id,off);
setlinetexture(id, SIDE_FRONT, TEXTURE_MIDDLE, "NJWIN3A");
setlinetexture(id, SIDE_BACK, TEXTURE_MIDDLE, "NJWIN3A");
delay(const:1);
smashcount ++;
var0 = 20;
while(var0 > 0)
{
var0--;
Thing_ProjectileGravity(id, 54, random(0, 255), random(10, 40), random(5, 20));
}
}
Code: Select all
script 3 (int local0) // addr = 2980, flags=0000
{
int local1;
int goto_block;
switch (goto_block) {
case 0:
SetLineSpecial(local0, 0, 0, 0, 0, 0, 0);
ThingSound(local0, "glass", 127);
SetLineBlocking(local0, 0);
SetLineTexture(local0, 0, 1, "NJWIN3A");
SetLineTexture(local0, 1, 1, "NJWIN3A");
Delay(const: 1);
map1++;
local1 = 20;
goto_block = 2; restart;
case 2:
if (!(local1 > 0)) {
Terminate;
}
local1--;
Thing_ProjectileGravity(local0, 54, Random(0, 255), Random(10, 40), Random(5, 20));
goto_block = 2; restart;
}
}
-
- Posts: 1097
- Joined: Tue Nov 03, 2009 9:19 am
Re: ZDoom ACS disassembler/decompiler
Well... ACS has no goto, but if you contain all your code in a restartable switch, you can set the case-determining variable, go to the next iteration and let goto make the jump for you. Let us examine the flow of those instructions, and see if they might not actually reflect a probable byte-code set of instructions generated by the above code afterall.
(Probably not true: The decompiler code really implies that the ACS compiler that was used, simulated jump instructions by splitting the code into conditional segments, setting the appropriate condition at the end of each segment, and restarting the script to execute the selected segment.)
(Probably true): Compiled ACS contains, among other things, numeric-operations (such as comparison of values) and jump instructions. While, switch, if and for-conditions are all translated into a set of generic operations, involving comparison and jump. The disassembler cannot easily tell which instruction was used in the original script, to generate the compiled instructions. Therefore, it simulates the resultant instructions instead. The jump instruction has no scripted equivalent, but a switch can be used to achieve the same effect. The disassembler creates a switch that contains all the original code, and creates a case-entry at every point it might need to jump to. Jumping is simulated by setting the switch(variable) and calling RESTART, causing the switch to trigger again.
Code: Select all
script 3 (int <id|local0>)
{
int <var0|local1>;
int <undefined|goto_block>; // autogenerated code, used to store information that determines jumps in code
// initial values
// int local0 has a parameter value
// int local1 starts at 0, int goto_block starts at 0
switch (goto_block) {
case 0: // this will always be executed first, as the goto_block is always 0 until otherwise assigned
SetLineSpecial(local0, 0, 0, 0, 0, 0, 0);
ThingSound(local0, "glass", 127);
SetLineBlocking(local0, 0);
SetLineTexture(local0, 0, 1, "NJWIN3A");
SetLineTexture(local0, 1, 1, "NJWIN3A");
Delay(const: 1);
map1++; // the map-level variable formerly known as smashcount
local1 = 20; // var0 = 20
goto_block = 2; // value is set to 2; if it remains 2 when this switch is subsequently triggered, that will determine the next code block
restart; // script restart. no instructions prior to the switch change any values. The goto_block is 2.
case 2:
if (! (local1 > 0)) // the while condition was: while(var0 > 0). If the while condition is false, execution continues after the conditional code-block
{
terminate; // the conditional code-block is the end of the script, so calling terminate is an effective response to the loop-condition proving false
}
// if you did reach this point, it implies that the loop condition was satisfied
// code following this line thus corresponds to the marked part in: while (var0 > 0) { /* THIS IS THE MARKED PART */ }
local1--; // var0--
Thing_ProjectileGravity(local0, 54, Random(0, 255), Random(10, 40), Random(5, 20));
goto_block = 2; // ensuring that the next jump is to the right code block
restart; // making the jump
}
}
(Probably true): Compiled ACS contains, among other things, numeric-operations (such as comparison of values) and jump instructions. While, switch, if and for-conditions are all translated into a set of generic operations, involving comparison and jump. The disassembler cannot easily tell which instruction was used in the original script, to generate the compiled instructions. Therefore, it simulates the resultant instructions instead. The jump instruction has no scripted equivalent, but a switch can be used to achieve the same effect. The disassembler creates a switch that contains all the original code, and creates a case-entry at every point it might need to jump to. Jumping is simulated by setting the switch(variable) and calling RESTART, causing the switch to trigger again.
-
- Posts: 753
- Joined: Mon Jun 24, 2013 7:12 pm
- Location: UT-WA
Re: ZDoom ACS disassembler/decompiler
Ral22 wrote: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?
EXACT SAME THING. any ideas?
-
- Posts: 7402
- Joined: Fri Oct 22, 2004 9:22 am
- Graphics Processor: nVidia with Vulkan support
- Location: MAP33
Re: ZDoom ACS disassembler/decompiler
Yeah, try not bumping 2 year old threads.cortlong50 wrote:EXACT SAME THING. any ideas?
-
- Posts: 1528
- Joined: Thu Jul 14, 2011 12:06 am
- Location: Gold Coast, Queensland, Australia
Re: ZDoom ACS disassembler/decompiler
@Ral22 & @cortlong50
It's a command line application. You don't run it by itself.
From the readme:
-TZK
It's a command line application. You don't run it by itself.
From the readme:
Spoiler:You can use this batch file if you're lazy:
Code: Select all
echo off
cls
set /p fname=Filename:
listacs -d %fname% -o %fname%.acs
pause
exit
-
- Posts: 753
- Joined: Mon Jun 24, 2013 7:12 pm
- Location: UT-WA
Re: ZDoom ACS disassembler/decompiler
well at first i was trying to run it in python itself...but thats about as alienating as it gets (this is about two weeks of on and off messing with it) and it just isnt happening for me.
the batch file...even after messing with that says (no matter how many different ways i put information into the batch itself) says "listacs is not recognized as an internal or external command"
.....WHAT?! haha, this is usually a mess around until i get it type of situation...but this one is flabbergasting to me.
and after inputting the same info as the batch you gave me it either denies it because it is not a windows application...or it just closes...even without entering exit.
its weird.
excuse my ignorance, im just a little cloudy on how to get this off the ground.
the batch file...even after messing with that says (no matter how many different ways i put information into the batch itself) says "listacs is not recognized as an internal or external command"
.....WHAT?! haha, this is usually a mess around until i get it type of situation...but this one is flabbergasting to me.
and after inputting the same info as the batch you gave me it either denies it because it is not a windows application...or it just closes...even without entering exit.
its weird.
excuse my ignorance, im just a little cloudy on how to get this off the ground.
-
- Posts: 1528
- Joined: Thu Jul 14, 2011 12:06 am
- Location: Gold Coast, Queensland, Australia
Re: ZDoom ACS disassembler/decompiler
@cortlong50
Download the standalone py2exe version. Put the batch file in the same folder as the py2exe version and then run it.
-TZK
Download the standalone py2exe version. Put the batch file in the same folder as the py2exe version and then run it.
-TZK
-
- Posts: 753
- Joined: Mon Jun 24, 2013 7:12 pm
- Location: UT-WA
Re: ZDoom ACS disassembler/decompiler
already been done...does the same thing as trying to run "listacs.py" as a standalone.
it opens then drops super fast.
thanks for the input dude, sorry to seem like a dumb but i dont know haha.
if theres anything else let me know, but ive tried everything...compat mode on the standalone and everything.
either way, thanks again, i think ill have to live with it for now til i can try it on my desktop...unless youd be a doll and decompile my acs and send me the code? hahaha
i wanna know how to do it but my commandline has been weird ever since i reinstalled windows.
it opens then drops super fast.
thanks for the input dude, sorry to seem like a dumb but i dont know haha.
if theres anything else let me know, but ive tried everything...compat mode on the standalone and everything.
either way, thanks again, i think ill have to live with it for now til i can try it on my desktop...unless youd be a doll and decompile my acs and send me the code? hahaha
i wanna know how to do it but my commandline has been weird ever since i reinstalled windows.
-
- Posts: 1528
- Joined: Thu Jul 14, 2011 12:06 am
- Location: Gold Coast, Queensland, Australia
-
- Posts: 753
- Joined: Mon Jun 24, 2013 7:12 pm
- Location: UT-WA
Re: ZDoom ACS disassembler/decompiler
thanks dude ill give it a go!
sorry for my shortcomings.
ive been using a completely legitimate version of windows and my cmd has been an issue since i installed sp2.
its weird...because my torrented windows was fabulous...this one is missing every dll you can make up off the top of your head haha.
thanks dude.
sorry for my shortcomings.
ive been using a completely legitimate version of windows and my cmd has been an issue since i installed sp2.
its weird...because my torrented windows was fabulous...this one is missing every dll you can make up off the top of your head haha.
thanks dude.
-
- Posts: 753
- Joined: Mon Jun 24, 2013 7:12 pm
- Location: UT-WA
Re: ZDoom ACS disassembler/decompiler
still nothing. i got it to show the listacs dialogue...but now when i press anything it closes.
so what exactly would i do with this standalone i downloaded from you?
i have tried everything i can think of and im starting to think im just doing something wrong beacuse any information i can get is super bland, so for anyone else that comes along....what exactly should i do to get this to work? step by step for dummies.
so what exactly would i do with this standalone i downloaded from you?
i have tried everything i can think of and im starting to think im just doing something wrong beacuse any information i can get is super bland, so for anyone else that comes along....what exactly should i do to get this to work? step by step for dummies.
-
- Posts: 64
- Joined: Fri May 30, 2014 11:00 pm
- Location: Realm 69
Re: ZDoom ACS disassembler/decompiler
Hey, well you might need to update ListACS to a new ACS version, because there is this WAD that was pulled from /idgames called Caverns of Blood. It is a Terry WAD that slipped past the filter because the scripts and strings were obfuscated, and the scripts were obfuscated by adding an ACS command that ListACS doesn't support which blanks out all the scripts. The trap also occurs VERY randomly, but in gamemodes like LMS for Zandronum, it takes only 3 minutes. But if you are playing single player, it can take anywhere from a few minutes, to a few hours. The WAD was also made by Terry himself.