ZDoom ACS disassembler/decompiler

Any utility that assists in the creation of mods, assets, etc, go here.

Re: ZDoom ACS disassembler/decompiler

Postby FDARI » Wed Sep 14, 2011 4:19 am

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.
User avatar
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.
 
Joined: 03 Nov 2009

Re: ZDoom ACS disassembler/decompiler

Postby Blue Shadow » Wed Sep 14, 2011 5:31 am

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.
User avatar
Blue Shadow
 
 
 
Joined: 14 Nov 2010
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: ZDoom ACS disassembler/decompiler

Postby FDARI » Wed Sep 14, 2011 6:35 am

Well... If you compile
Code: Select allExpand view
script 1 (void) { int i = 1<<16; }

I believe you will produce exactly the same bytecode as if you compile
Code: Select allExpand view
script 1 (void) { int i = 1.0; }
So 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.
User avatar
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.
 
Joined: 03 Nov 2009

Re: ZDoom ACS disassembler/decompiler

Postby Kappes Buur » Wed Sep 14, 2011 11:22 am

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

Code: Select allExpand view
//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));
    }
}


and the decompiled version of the above from the BEHAVIOR lump

Code: Select allExpand view
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;

    }
}


So it seems that the listacs result must be taken with a grain of salt many grains of salt and an Anicin
User avatar
Kappes Buur
 
 
 
Joined: 17 Jul 2003
Location: British Columbia Canada

Re: ZDoom ACS disassembler/decompiler

Postby FDARI » Wed Sep 14, 2011 6:42 pm

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.

Code: Select allExpand view
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 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.
User avatar
FDARI
Melbourne is actually pronounced Mel-Byn, as though it were a wizard.
 
Joined: 03 Nov 2009

Re: ZDoom ACS disassembler/decompiler

Postby cortlong50 » Fri Sep 27, 2013 11:24 pm

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?
User avatar
cortlong50
editing my comments ad nauseam
 
Joined: 24 Jun 2013
Location: UT-WA

Re: ZDoom ACS disassembler/decompiler

Postby Kinsie » Sat Sep 28, 2013 4:55 am

cortlong50 wrote:EXACT SAME THING. any ideas?
Yeah, try not bumping 2 year old threads.
User avatar
Kinsie
A Concept Utterly Obsolete
 
Joined: 22 Oct 2004
Location: MAP33
Discord: Find Me...
Twitch ID: thekinsie

Re: ZDoom ACS disassembler/decompiler

Postby The Zombie Killer » Sat Sep 28, 2013 5:14 am

@Ral22 & @cortlong50
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 allExpand view
echo off
cls
set /p fname=Filename:
listacs -d %fname% -o %fname%.acs
pause
exit


-TZK
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: ZDoom ACS disassembler/decompiler

Postby cortlong50 » Sun Sep 29, 2013 5:34 pm

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.
User avatar
cortlong50
editing my comments ad nauseam
 
Joined: 24 Jun 2013
Location: UT-WA

Re: ZDoom ACS disassembler/decompiler

Postby The Zombie Killer » Sun Sep 29, 2013 11:54 pm

@cortlong50
Download the standalone py2exe version. Put the batch file in the same folder as the py2exe version and then run it.

-TZK
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: ZDoom ACS disassembler/decompiler

Postby cortlong50 » Wed Oct 02, 2013 10:20 pm

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.
User avatar
cortlong50
editing my comments ad nauseam
 
Joined: 24 Jun 2013
Location: UT-WA

Re: ZDoom ACS disassembler/decompiler

Postby The Zombie Killer » Thu Oct 03, 2013 3:58 am

Try the batch file with the listacs that I included in this ACS package

-TZK
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: ZDoom ACS disassembler/decompiler

Postby cortlong50 » Sat Oct 05, 2013 10:43 pm

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.
User avatar
cortlong50
editing my comments ad nauseam
 
Joined: 24 Jun 2013
Location: UT-WA

Re: ZDoom ACS disassembler/decompiler

Postby cortlong50 » Sun Oct 06, 2013 12:39 pm

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.
User avatar
cortlong50
editing my comments ad nauseam
 
Joined: 24 Jun 2013
Location: UT-WA

Re: ZDoom ACS disassembler/decompiler

Postby nambona890 » Mon Nov 24, 2014 2:35 am

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.
User avatar
nambona890
WADs with faces for enemies and loud sounds are now Terry WADs.
Banned User
 
Joined: 31 May 2014
Location: Realm 69

PreviousNext

Return to Editors / Asset Manipulation

Who is online

Users browsing this forum: No registered users and 1 guest