Starts an if statement where the condition compares a word from a specified offset to a specified word to see if they are equal. If the condition is true then execute the following lines of code. Otherwise skip to the end of the if statement then continue executing codes.
One endIf can be applied. If more than one needs to be applied use the End If/Else codetype.
Syntax
Gecko Code
Lua Script Equivalent
Parameters
Examples
The following code will compare the word at address 803EFF4C against 00100000. If they are equal then the condition is true and it will write the word 00000002 at address 803EFF50. Line 3 applies an endIf.
Gecko Code
Lua Script Equivalent
Memory View
Assuming ba = 80000000...
The codetype is 20 which means the address calculation is ba + 3EFF4C = 80000000 + 3EFF4C = 803EFF4C.
So if the word at address 803EFF4C is equal to 00100000, then the word 00000002 is written at address 803EFF50.
Nested If
The following code will compare the value at address 802C0028 against 000000FF. If they are equal then the condition is true and it will write the byte value 01 at address 802C0038. Next it will compare the value at address 802C002C against 00000001. If they are equal then the condition is true and it will write the byte value 02 at address 802C0038. Line 5 applies two endIf's.
Gecko Code
Lua Script Equivalent
Memory View
Assuming ba = 80000000...
The codetype is 20 for both which means the address calculation is ba + XXXXXX.
Line 1: ba + 2C0028 = 80000000 + 2C0028 = 802C0028.
Line 3: ba + 2C002C = 80000000 + 2C002C = 802C002C.
So if the word at address 802C0028 is equal to 000000FF, then tye byte 01 is written at address 802C0038.
But then also if the word at address 802C002C is equal to 00000001, then the byte 02 is written at address 802C0038.
Note: In the case of this code if both If Codetypes are true both of the byte write codes are set to write to the same address.
Looking at the top memory view only the first If Codetype is true while the second is false. This results in address 802C0038 having value 01.
Where as in the bottom memory view both the first and the second If Codetypes are true.
Which results in address 802C0038 having value 02.
Applying an endIf
The following code will compare the word at address 801000D4 against 00000080. If they are equal then the condition is true and it will write the word 00000002 at address 801000E4. Line 3 is another If Codetype. However before the comparison is made it will apply an endIf. Then it will compare the word at address 801000D4 against 00000040. If they are equal then the condition is true and it will write the word 00000001 at address 801000E4. Line 5 applies an endIf.
Gecko Code
Lua Script Equivalent
Memory View
Assuming po = 0x80000000.
The codetype is 30 for both which means the address calculation is po + XXXXXX.
Line 1: po + 1000D4 = 80000000 + 1000D4 = 801000D4.
Line 3: po + 1000EC = 80000000 + 1000EC = 801000EC.
So if the word at address 801000D4 is equal to 00000080, then word 00000002 is written at address 801000E4.
Then if the word at address 801000EC is equal to 00000040, then word 00000001 is written at address 801000FC.
Note: That on Line 3 XXXXXX = 1000ED. This means first apply the endIf then use 1000EC for address calculation. This is reflected on Lines 3 and 4 of the Lua Script Equivalent.