Difference between revisions of "0AB1"

From GTAMods Wiki
Jump to navigation Jump to search
(page updates)
Line 1: Line 1:
<code>0AB1=-1,call_scm_func %1p%</code><br>
+
{{This|For GTA III's and Vice City's equivalent, use 05F5.}}
'''Description''': Calls a scm function<br>
+
{{Icon|SA}} (with [[CLEO]])
'''Parameter 1''': [[Label]] (SCM function start)<br>
+
<hr />
'''Parameter 2''': number of parameters to pass<br>
+
'''Description'''
'''Parameters 3-32''': (optional) Parameters if there are ones<br>
+
: Calls a scm function
'''Supports''': [[San Andreas]] with [[CLEO]]<br>
+
'''Syntax'''
 +
 +
'''Parameter'''
 +
: [''label'']
 +
:: [[Label]] (SCM function start)
 +
: [''int'']
 +
:: Number of parameters to pass
 +
: [''any'']
 +
:: Parameters if there are ones (optional), up to 30
 +
 
 
This opcode calls a SCM function, passes the parameters to it and stores a result to variable(s). The passed parameters values are copied to the local variables in series, then the thread execution is transferred to the label, it executes code there and returns after opcode [[0AB2]] is executed.
 
This opcode calls a SCM function, passes the parameters to it and stores a result to variable(s). The passed parameters values are copied to the local variables in series, then the thread execution is transferred to the label, it executes code there and returns after opcode [[0AB2]] is executed.
  

Revision as of 23:44, 8 January 2015

For GTA III's and Vice City's equivalent, use 05F5.

San Andreas (with CLEO)


Description

Calls a scm function

Syntax

0AB1: call_scm_func [label] [int] ( [

Parameter

[label]
Label (SCM function start)
[int]
Number of parameters to pass
[any]
Parameters if there are ones (optional), up to 30

This opcode calls a SCM function, passes the parameters to it and stores a result to variable(s). The passed parameters values are copied to the local variables in series, then the thread execution is transferred to the label, it executes code there and returns after opcode 0AB2 is executed.

Example

This is a simple example of the SCM function calculating the square number.

How it works. First of all, the game comes to the opcode 0AB1. The game reads the number of parameters to pass (1) and its values (10). The variable 0@ of the current thread equates to 10 (if there would more parameters to pass, the next one will be copied to the 1@, then 2@ and so on). After that the thread jumps to the label @GetSQR,. Here the square number is calculated (of a value in the 0@). Again, if there would be more parameters, the values of 1@, 2@ etc may be taken in to account, if needed. After the calculation, the game comes to the opcode 0AB2. The value of 0@ equals to 10*10 = 100 at this moment. Then the following happens: the returned value(s) (0@) is copied to the variable(s) that is written in the opcode 0AB1 which called this function. In our example such variable is $result. After storing of the result, the thread returns back to the 0AB1 and comes to the command end_thread. The value of the $result equals to the 100 (which is square of 10) at this moment. Finally say that 0AB2 could return not only the variables values, but also the number constants. For example, 0AB2: ret 1 1 will forever stores 1 to the result. Also pay attention that the local variables are stayed unchanged after the function calling. In this example, the variable 0@ contains a value of 5 before 0AB1. Despite the fact that this variable was used in the function, after the calling it still equals to 5. This covers on all 32 local variables, so you can freely work with them within a function without fear to lose data.

Keywords

CLEO, scm function, call