Difference between revisions of "AGI Command Reference - Arithmetic Commands"

From AGI Wiki
Jump to navigationJump to search
Line 1: Line 1:
 
<div align="center">Page:  
 
<div align="center">Page:  
'''[ 1 ]'''
+
'''[ 1 ]''' |
[[AGI Command Reference 2|2]]
+
[[AGI Command Reference 2 - COMMANDS TO LOAD AND UNLOAD RESOURCES|AGI Command Reference 2]] |
[[AGI Command Reference 3|3]]
+
[[AGI Command Reference 3 - PROGRAM CONTROL COMMANDS|AGI Command Reference 3]] |
[[AGI Command Reference 4|4]]
+
[[AGI Command Reference 4 - OBJECT CONTROL COMMANDS|AGI Command Reference 4]] |
[[AGI Command Reference 5|5]]
+
[[AGI Command Reference 5 - OBJECT DESCRIPTION COMMANDS|AGI Command Reference 5]] |
[[AGI Command Reference 6|6]]
+
[[AGI Command Reference 6 - OBJECT MOTION CONTROL COMMANDS|AGI Command Reference 6]] |
[[AGI Command Reference 7|7]]
+
[[AGI Command Reference 7 - INVENTORY ITEM MANAGEMENT COMMANDS|AGI Command Reference 7]] |
[[AGI Command Reference 8|8]]
+
[[AGI Command Reference 8 - PICTURE RESOURCE MANAGEMENT COMMANDS|AGI Command Reference 8]] |
[[AGI Command Reference 9|9]]
+
[[AGI Command Reference 9 - SOUND RESOURCE MANAGEMENT COMMANDS|AGI Command Reference 9]] |
[[AGI Command Reference 10|10]]
+
[[AGI Command Reference 10 - TEXT MANAGEMENT COMMANDS|AGI Command Reference 10]] |
[[AGI Command Reference 11|11]]
+
[[AGI Command Reference 11 - STRING MANAGEMENT COMMANDS|AGI Command Reference 11]] |
[[AGI Command Reference 12|12]]
+
[[AGI Command Reference 12 - INITIALIZATION COMMANDS|AGI Command Reference 12]] |
[[AGI Command Reference 13|13]]
+
[[AGI Command Reference 13 - MENU MANAGEMENT COMMANDS|AGI Command Reference 13]] |
[[AGI Command Reference 14|14]]
+
[[AGI Command Reference 14 - TEST COMMANDS|AGI Command Reference 14]] |
[[AGI Command Reference 15|15]]
+
[[AGI Command Reference 15 - OTHER COMMANDS|AGI Command Reference 15]] |
[[AGI Command Reference 16|16]]
+
[[AGI Command Reference 16 - UNKNOWN COMMANDS|AGI Command Reference 16]]
 
</div>
 
</div>
  

Revision as of 20:00, 12 December 2013

 

I ARITHMETIC COMMANDS

Commands that operate on variables:

increment(n);

The value of the variable Var(n) is incremented by one, i.e.
Var(n) = Var(n)+1. If the value is already 255, it is left unchanged.

decrement(n);

The value of the variable Var(n) is decremented by one, i.e.
Var(n) = Var(n)-1. If the value is 0, it is left unchanged.

assign(n, m);

Variable Var(n) is assigned the value m, i.e. Var(n) = m

assignv(n, m);

Variable Var(n) is assigned the value of Var(m), i.e.
Var(n) = Var(m).

addn(n, m);

The value of variable Var(n) is incremented by m, i.e.
Var(n) = Var(n) + m.

addv(n, m);

The value of variable Var(n) is incremented by the value of Var(m), i.e. Var(n) = Var(n) + m.
[Now what happens in the above two commands on 8-bit overflow: does the result wrap over 0 or stays 255?
I.e. is 250 + 10 == 4 or 250 + 10 == 255?]

subn(n, m);

The value of Var(n) is decremented by m, I.e. Var(n) = Var(n) - m

subv(n, m);

The value of Var(n) is decremented by Var(m), i.e. Var(n) = Var(n) - Var(m).
[Again, what happens when the result must be negative: is
1 - 2 == 255 or 1 - 2 == 0?]

lindirectn(n, m);

Variable Var(i) where i is the value of Var(n) is assigned a value m, i.e. Var(Var(n)) = m.

lindirectv(n, m);

Variable Var(i) where i is the value of Var(n) is assigned the value of Var(m), i.e. Var(Var(n)) = Var(m).

rindirect(n, m);

Variable Var(n) is assigned the value of Var(i) where i is the value of Var(m), i.e. Var(n) = Var(Var(m)).

muln(n, m);

Variable Var(n) is multiplied by m, i.e. Var(n) = Var(n) * m.

mulv(n, m);

Variable Var(n) is multiplied by the value of Var(m), i.e.
Var(n) = Var(n) * Var(m).
[What happens on overflow?]

divn(n, m)

Variable Var(n) is divided by m, i.e. Var(n) = Var(n) / m.

divv(n, m)

Variable Var(n) is divided by the value of Var(m),
i.e. Var(n) = Var(n) / Var(m). [What happens on division by 0?]

random(n, m, k)

Variable Var(k) is assigned a random value in the range between n and m. Now let us consider the commands changing flag values. Remember that a flag can only have a value 0 or 1.

set(n)

flag(n) is set to 1.

set.v(n)

flag(i), where i is the value of var (n), is set to 1. i.e.
flag(var(n)) = 1.

reset(n)

flag(n) is set to 0.

reset.v(n)

flag(i), where i is the value of var (n), is set to 0, i.e.
flag(var(n)) = 0.

toggle(n)

flag(n) toggles its value.

toggle.v(n)

flag(i), where i is the value of var (n), i.e. flag(var(n)), toggles is value.

Page: [ 1 ] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16