Page 8 of 8

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 26 Sep 2013, 09:12
by B-$hep
Does your decompiler decompiles WHILE_EXEC ENDWHILE commands?

Do you know what these means: S_PLUS_S, S_MINUS_I, i know they are operators but whats the I and S?
Integer and String?

I did my own small mini decompiler few months ago, just very small, yesterday i was in a mood to decompile WHILE_EXEC ENDWHILE commands but its not complete because of these S_MINUS_I etc things. But it was alot easier to write new one from scratch than integrate something into C++ code of yours. I did it in Delphi. It decompiles simple WHILE_EXEC ENDWHILE loops. Also "++" and "--" for correct variables.

I added other commands as needed for my small test scripts. I only focused atm on loops and IF_ENDIFs.
By writing my own code i know how all works and how i could make different things.

Again, i repeat: im focused on loops and IF_ENDIFs. Nothing fancy, so its small and clean. For very specific tasks only.

Must finish that before trying IF_ENDIF. Especially nested things.

WHILE_EXEC could be also nested?

I must understand whats the difference between the S and I

Edit!
For ex. my simple script:

Code: Select all

PLAYER_PED player = (49.5, 46.5, 1.0) 25 0


COUNTER loop = 321

LEVELSTART 
WHILE_EXEC ( loop< 5621 )
do_nowt
endwhile

LEVELEND
It used ID: 86 which is "S_LESS_I"
"loop" is string in his own way, but what difference it makes to miss2?
Its just variable.

I dont get it.

TM or anybody, do you have a complete list what kind of types and operators can be used to compare/add/ divide different things? Are they all documented correctly in dma docs?

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 26 Sep 2013, 10:12
by Sektor
S might be Signed Integer.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 26 Sep 2013, 20:14
by B-$hep
That makes sense. Thanks.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 28 Sep 2013, 08:14
by T.M.
Sektor wrote:S might be Signed Integer.
Not in this case.

Sint32 = Signed Integer (32 bits)
B-$hep wrote: It used ID: 86 which is "S_LESS_I"
"loop" is string in his own way, but what difference it makes to miss2?
Its just variable.

I dont get it.
Read the source dude... its all there. Just look at the functions... it cant be that hard.

S_EQUAL_I = String Equal Integer (= checks if variable value equals integer)
B-$hep wrote:TM or anybody, do you have a complete list what kind of types and operators can be used to compare/add/ divide different things? Are they all documented correctly in dma docs?
The complete list is in the source code of Epic GTA2 Script Decompiler.

DMA docs, dont trust them at all. I Went through them all, and corrected billions of incorrect information. The correct information is encoded into the sources, once again.

[mis]
// math functions: (note: S_MINUS_I wont compile!)
TWO_PARAMS_LAYOUT(S_PLUS_I, sprintf_str("%s + %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT(I_PLUS_S, sprintf_str("%d + %s", data.sintvar1, getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(I_MINUS_S, sprintf_str("%d - %s", data.sintvar1, getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(S_PLUS_S, sprintf_str("%s + %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(S_MINUS_S, sprintf_str("%s - %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT(DECREMENT, sprintf_str("--%s", getname(data.var1).c_str()));
TWO_PARAMS_LAYOUT(INCREMENT, sprintf_str("++%s", getname(data.var1).c_str()));

FOUR_PARAMS_LAYOUT(S_IS_S_MINUS_I, sprintf_str("SET %s = (%s - %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_PLUS_I, sprintf_str("SET %s = (%s + %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_DIV_I, sprintf_str("SET %s = (%s / %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MULT_I, sprintf_str("SET %s = (%s * %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MOD_I, sprintf_str("SET %s = (%s MOD %d)", getname(data.var1).c_str(), getname(data.var2).c_str(), data.sintvar3));
FOUR_PARAMS_LAYOUT(S_IS_S_MINUS_S, sprintf_str("SET %s = (%s - %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_PLUS_S, sprintf_str("SET %s = (%s + %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_DIV_S, sprintf_str("SET %s = (%s / %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_MULT_S, sprintf_str("SET %s = (%s * %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));
FOUR_PARAMS_LAYOUT(S_IS_S_MOD_S, sprintf_str("SET %s = (%s MOD %s)", getname(data.var1).c_str(), getname(data.var2).c_str(), getname(data.var3).c_str()));

// boolean comparison functions with max 2 params:
TWO_PARAMS_LAYOUT_BOOL(S_EQUAL_I, sprintf_str("%s = %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_GEQUAL_I, sprintf_str("%s >= %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_GREATER_I, sprintf_str("%s > %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_LESS_I, sprintf_str("%s < %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_LEQUAL_I, sprintf_str("%s <= %d", getname(data.var1).c_str(), data.sintvar2));
TWO_PARAMS_LAYOUT_BOOL(S_EQUAL_S, sprintf_str("%s = %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_GEQUAL_S, sprintf_str("%s >= %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_GREATER_S, sprintf_str("%s > %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_LESS_S, sprintf_str("%s < %s", getname(data.var1).c_str(), getname(data.var2).c_str()));
TWO_PARAMS_LAYOUT_BOOL(S_LEQUAL_S, sprintf_str("%s <= %s", getname(data.var1).c_str(), getname(data.var2).c_str()));[/mis]

How hard it really is, to figure out that %s means string and %d means integer? Note that "sintvar" means signed integer variable. Check sources for more information.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 21 Feb 2018, 21:23
by Sektor
I tried compiling this in VS2013. I needed to add #include <functional> to get it to compile.

When I tried to use it in Epic Map Editor, I got "Error: File not found or cannot be read". Does the map editor use a different version of the decompiler or did VS2013 break something?

I mostly just want to enable SCR_debug_all_lines.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 22 Feb 2018, 11:28
by T.M.
Sektor wrote:I tried compiling this in VS2013. I needed to add #include <functional> to get it to compile.

When I tried to use it in Epic Map Editor, I got "Error: File not found or cannot be read". Does the map editor use a different version of the decompiler or did VS2013 break something?

I mostly just want to enable SCR_debug_all_lines.
I think there is some problem with the way you compiled the DLL. Looking at my sources comments, my issue was:
// Note: To be able to use this as a DLL, you must set both projects to use the
// same setting: "Multi-threaded DLL (/MD)" or it will crash!

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 22 Feb 2018, 11:59
by Sektor
It was already set to that. It’s not crashing, it’s returning an error code when trying to read the SCR. Probably some IO works different on VS2013.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 22 Feb 2018, 17:56
by T.M.
Sektor wrote:It was already set to that. It’s not crashing, it’s returning an error code when trying to read the SCR. Probably some IO works different on VS2013.
Ah i see. The file pointer is returning NULL. Seems like your SCR file does not have sufficient rights for reading, or your compiled DLL does not have those rights.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 17 Mar 2021, 10:29
by odg
If anyone's interested - as part of a larger project I'm working on, I put TM's decompiler code into a git repository, made a few small changes, and I've got it to compile successfully on Linux. My changes are mainly to make it more portable and add support for a build system.

See here: https://gitlab.com/classic-gta/gta2-scr-decompiler

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 19 Mar 2021, 00:28
by _L1pE_
odg wrote: 17 Mar 2021, 10:29 If anyone's interested - as part of a larger project I'm working on, I put TM's decompiler code into a git repository, made a few small changes, and I've got it to compile successfully on Linux. My changes are mainly to make it more portable and add support for a build system.

See here: https://gitlab.com/classic-gta/gta2-scr-decompiler
Very nice, thanks for making it Linux native.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 09 May 2021, 09:19
by B-$hep
What are you doing odg?

GTA2 remake?
There is no need for another half finished thing. Internet has many of them by now.
Nobody ever gets to the hard stuff and gives up.
Rendering map and stuff is easy.

Coding AI, cars is where people give up. And there the story ends.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 10 May 2021, 07:45
by JernejL
B-$hep wrote: 09 May 2021, 09:19 What are you doing odg?

GTA2 remake?
There is no need for another half finished thing. Internet has many of them by now.
Nobody ever gets to the hard stuff and gives up.
Rendering map and stuff is easy.

Coding AI, cars is where people give up. And there the story ends.

If by decompiling with advanced stuff like ghidra you reach same working state of physics and logic, it is doable.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 13 May 2021, 17:23
by B-$hep
Surprise surprise but im doing that for a while now.
Im working on different things at once.

Making code more readable in Ghidra etc..

I have many ideas how to find all the logic and stuff in GTA2 and call them in my code.

Its hard but everything is possible.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 16 May 2021, 15:39
by odg
B-$hep wrote: 09 May 2021, 09:19 What are you doing odg?

GTA2 remake?
There is no need for another half finished thing. Internet has many of them by now.
Nobody ever gets to the hard stuff and gives up.
Rendering map and stuff is easy.

Coding AI, cars is where people give up. And there the story ends.
Hi B-$hep! Not really a full remake, but maybe one day. I'm well aware of previous attempted remakes and similar games. Basically I'd eventually like to make a game engine for top down games, which is compatible with the GTA 1+2 assets, and so could be used as a drop-in replacement for the GTA 1/2 engines, or to make new games. It will be open source and cross platform. I know it's ambitious so I'm doing it in a modular way, one part at a time, starting with a library to parse and import the assets.

Also note that I'm not really interested in doing any disassembly or reverse engineering of the original libraries or executables. I'll study the games by playing and researching them, and aim to be as close as is reasonably possible. Partly for legal reasons, and partly because I think the result will end up being more modern and elegant. I'm actually quite looking forward to doing the physics, I have a background in maths.

I've been a fan of classic GTA for years (I've read this forum and been on chatrooms off-and-on over the years too), and now work in IT/programming, so it seems like a natural hobby project. There's no rush, as I'm just doing it in my spare time when not working. I'm not planning on trying to commercialise it, it's purely a non-profit, fun, open source project.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 17 May 2021, 15:13
by _L1pE_
odg, you taken a look at this yet https://github.com/codenamecpp/carnage3d ? It's similar to what you're doing, but focused on GTA 1, might be helpful.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 22 May 2021, 20:00
by odg
_L1pE_ wrote: 17 May 2021, 15:13 odg, you taken a look at this yet https://github.com/codenamecpp/carnage3d ? It's similar to what you're doing, but focused on GTA 1, might be helpful.
Yes I've been following Carnage3D for a while, it looks really good! I'd like to try to chat to the dev at some point, maybe we could collaborate.

One of the benefits of a modular approach I mentioned is that multiple projects can share code, it avoids duplicated effort and everyone can benefit from improvements. Perhaps over time the community could build a collection of open and interoperable tools, libraries and engines.

Re: Epic GTA2 Script Decompiler (AKA SCR Decompiler)

Posted: 28 Jul 2021, 09:18
by T.M.
odg wrote: 17 Mar 2021, 10:29 If anyone's interested - as part of a larger project I'm working on, I put TM's decompiler code into a git repository, made a few small changes, and I've got it to compile successfully on Linux. My changes are mainly to make it more portable and add support for a build system.

See here: https://gitlab.com/classic-gta/gta2-scr-decompiler
Cool to see someone twiddling with my stuff 8-)