Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore RETURN_TRUE and RETURN_FALSE in SA #113

Open
thelink2012 opened this issue May 20, 2017 · 7 comments
Open

Restore RETURN_TRUE and RETURN_FALSE in SA #113

thelink2012 opened this issue May 20, 2017 · 7 comments

Comments

@thelink2012
Copy link
Owner

Not sure if that should be done at compile time (translating to other command), or at a runtime implementation.

@x87
Copy link

x87 commented May 20, 2017

What do you mean by restore? 00C5/00C6 are functional in III/VC

@thelink2012
Copy link
Owner Author

Opss... I meant VC/SA. It's functional in VC? Nice then.

@thelink2012 thelink2012 changed the title Restore RETURN_TRUE and RETURN_FALSE in III/VC Restore RETURN_TRUE and RETURN_FALSE in SA May 20, 2017
@x87
Copy link

x87 commented May 20, 2017

It is functional in VC via http://www.gtamodding.com/wiki/Opcodes_Restoration_Project or with alternate opcodes 0485, 059A. Those are valid for SA either.

@thelink2012
Copy link
Owner Author

thelink2012 commented May 20, 2017

Yes, that's the question in here, Whether RETURN_TRUE should be mapped to those commands, or re-implemented at runtime.

WHILE IS_PC_VERSION is not intuitive e.g.

@x87
Copy link

x87 commented May 21, 2017

Do we really need this opcode in such constructions? For example, Sanny Builder treats while true as a single unconditional jump:

:loop
jump @loop

If you want to use return_true/return_false as a result of CLEO functions then they still could be omitted:

if 
   0@ > 0
then
   return_true
else
   return false
end
ret

essentially the same as

0@ > 0
ret

See what I mean? The compiler might do some optimizations to omit useless code, so in runtime there will be no differences, but they will be in the decompiled code (no 1-to-1 match). In general I think it's OK.

@thelink2012
Copy link
Owner Author

thelink2012 commented May 21, 2017

Do we really need this opcode in such constructions? For example, Sanny Builder treats while true as a single unconditional jump:

Everything is a command in GTA3script. As such, to have a infinite loop you need an always true command within the while. Such condition is RETURN_TRUE, or even something like x = x.

Indeed, both can be taken out by the optimizer (only if -O), which would be zero-cost, but unfortunately it cannot for multifiles because the determinism of the compilation is compromised by the optimizer.

Yeah, the language do not have any infinite loop construct, Rockstar used labels and gotos when those were needed.

If you want to use return_true/return_false as a result of CLEO functions then they still could be omitted:

But RETURN_TRUE is not a valid command in VC/SA, see? You cannot really write this at the moment, you have to go for the uglier commands that produce the same behaviour.

@JuniorDjjr
Copy link

I just add a copy of these commands in cleo.xml, whatever...

<Command ID="0x485" Name="TRUE"/>
<Command ID="0x485" Name="RETURN_TRUE"/>
<Command ID="0x59a" Name="RETURN_FALSE"/>

I taught this in my gta3script tutorial and most people do the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants