Headcannon Game Engine Script Commands - Math Operations (AND)
Index:
Bitwise AND - Preserve original values:
(D) (E) | _Reg=Reg&Reg |
(D) (E) | _Reg=Reg&Const |
(D) (E) | _Reg=Reg&Chr |
(D) (E) | _Reg=Reg&Obj |
(D) (E) | _Reg=Chr&Const |
(D) (E) | _Reg=Chr&Chr |
(D) (E) | _Reg=Chr&Obj |
(D) (E) | _Reg=Obj&Const |
(D) (E) | _Reg=Obj&Obj |
(D) (E) | _Chr=Reg&Reg |
(D) (E) | _Chr=Reg&Const |
(D) (E) | _Chr=Reg&Chr |
(D) (E) | _Chr=Reg&Obj |
(D) (E) | _Chr=Chr&Const |
(D) (E) | _Chr=Chr&Chr |
(D) (E) | _Chr=Chr&Obj |
(D) (E) | _Chr=Obj&Const |
(D) (E) | _Chr=Obj&Obj |
(D) (E) | _Obj=Reg&Reg |
(D) (E) | _Obj=Reg&Const |
(D) (E) | _Obj=Reg&Chr |
(D) (E) | _Obj=Reg&Obj |
(D) (E) | _Obj=Chr&Const |
(D) (E) | _Obj=Chr&Chr |
(D) (E) | _Obj=Chr&Obj |
(D) (E) | _Obj=Obj&Const |
(D) (E) | _Obj=Obj&Obj |
Bitwise AND - Overwrite original values:
(D) (E) | _Reg&=Reg |
(D) (E) | _Reg&=Chr |
(D) (E) | _Reg&=Obj |
(D) (E) | _Reg&=Const |
(D) (E) | _Chr&=Reg |
(D) (E) | _Chr&=Chr |
(D) (E) | _Chr&=Obj |
(D) (E) | _Chr&=Const |
(D) (E) | _Obj&=Reg |
(D) (E) | _Obj&=Chr |
(D) (E) | _Obj&=Obj |
(D) (E) | _Obj&=Const |
Descriptions:
Bitwise AND - Preserve original values:
3 = 0011
AND 5 = 0101
------ ----
1 = 0001
Commands only exist for unique expressions; expressions for two variables in reverse
order of any of the commands above are not included because they will return the same
result.
In the case of two Players, Var 1 is read from the Player "Fetched" to "Reference 0", and Var 2 is
read from the Player "Fetched" to "Reference 1"
In the case of two Objects, Var 1 is read from the Object "Fetched" to "Reference 0", and Var 2 is
read from the Object "Fetched" to "Reference 1"
In the case that only one Player is used for input, and/or only one Object is used for input, the Player
"Fetched" to "Reference 0" is used, and the Object "Fetched" to "Reference 0" is used.
The Destination variable is always considered to be from the Object or Player "Fetched" to "Reference 2"
Parameters:
- Var ID 1
- Var ID 2
- Dest Var ID
"Var ID 1" and "Var ID 2" are the IDs of the variables on which to perform the AND operation,
and "Dest Var ID" is the ID of the variable in which to store the result.
In the case of "Registers", "Var ID" is the ID of the "Register" that should be read/written. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable that should be read/written. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, "Var ID" is the ID of the Object Variable that should be read/written. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
In the case of a Constant Value, "Var ID" is the actual value to be used in the calculation, rather than any variable ID.
Bitwise AND - Overwrite original values:
_Reg&=Reg
_Reg&=Chr
_Reg&=Obj
_Reg&=Const
_Chr&=Reg
_Chr&=Chr
_Chr&=Obj
_Chr&=Const
_Obj&=Reg
_Obj&=Chr
_Obj&=Obj
_Obj&=Const
(ALL) (Example)
These Commands AND the values of the given Destination variable and the given Source variable,
and place the result into the given Destination variable, overwriting its previous content.
Dest &= Src
AND is a bitwise operation, meaning that it affects a value on a BIT
level. Any value can be expressed as a Binary number containing several BITs (Binary
Digits), 32 BITs in the case of HCGE's Variables. The AND operation compares two values
bit for bit and generates a result bit that is on (1) if the first AND second bit are on,
and off (0) if only one or the other is on, or if neither are on, as in the given example:
3 = 0011
AND 5 = 0101
------ ----
1 = 0001
The Source variable is always considered to be from the Object or Player "Fetched" to "Reference 0"
The Destination variable is always considered to be from the Object or Player "Fetched" to "Reference 2"
Parameters:
- Src Var ID
- Dest Var ID
"Dest" is ANDed with "Src", and the result is placed into "Dest"
In the case of "Registers", "Var ID" is the ID of the "Register" that should be read/written. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable that should be read/written. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, "Var ID" is the ID of the Object Variable that should be read/written. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
In the case of a Constant Value, "Var ID" is the actual value to be used in the calculation, rather than any variable ID.
Examples:
Bitwise AND - Preserve original values:
#_Reg=Chr0&Const ;AND the value of User-created "Active Variable" 18 of the Player "Fetched" to "Reference 0" with 256, and place the result in "User Register" 7
: a18 ;(Chr0) User-created "Active Variable" of the Player "Fetched" to "Reference 0"
: 256 ;(Const) 256
: U7 ;(Dest) "User Register" 7
; ----------
#_Chr2=Chr0&Chr1 ;AND the value of User-created "Active Variable" 12 of the Player "Fetched" to "Reference 0" with the value of User-created "Active Variable" 13 of the Player "Fetched" to "Reference 1", and place the result in User-created "Active Variable" 2 of the Player "Fetched" to "Reference 2"
: a12 ;(Chr0) User-created "Active Variable" 12 of the Player "Fetched" to "Reference 0"
: a13 ;(Chr1) User-created "Active Variable" 13 of the Player "Fetched" to "Reference 1"
: a2 ;(Dest) User-created "Active Variable" 2 of the Player "Fetched" to "Reference 2"
; ----------
#_Obj2=Reg&Obj0 ;AND the value of "User Register" 24 with the value of "Extra Variable" 4 of the Object "Fetched" to "Reference 0", and place the result in "Extra Variable" 8 of the Object "Fetched" to "Reference 2"
: U24 ;(Reg) "User Register" 24
: E4 ;(Obj0) "Extra Variable" 4 of the Object "Fetched" to "Reference 0"
: E8 ;(Dest) "Extra Variable" 8 of the Object "Fetched" to "Reference 2"
Bitwise AND - Overwrite original values:
#_Reg&=Obj0 ;AND the value of "User Register" 3 with the value of "Extra Variable" 4 of the Object "Fetched" to "Reference 0", and place the result back into "User Register" 3
: E1 ;(Chr0) "Extra Variable" 4 of the Object "Fetched" to "Reference 0"
: U3 ;(Dest) "User Register" 3
; ----------
#_Chr2&=Chr0 ;AND the value of User-created "Active Variable" 6 of the Player "Fetched" to "Reference 2" with the value of User-created "Active Variable" 9 of the Player "Fetched" to "Reference 0", and place the result back into User-created "Active Variable" 6 of the Player "Fetched" to "Reference 2"
: a9 ;(Chr0) User-created "Active Variable" 9 of the Player "Fetched" to "Reference 0"
: a6 ;(Dest) User-created "Active Variable" 6 of the Player "Fetched" to "Reference 2"
; ----------
#_Obj2&=Const ;AND the value of "Extra Variable" 8 of the Object "Fetched" to "Reference 2" with 12, and place the result back into "Extra Variable" 8 of the Object "Fetched" to "Reference 2"
: 12 ;(Const) 12
: E8 ;(Dest) "Extra Variable" 8 of the Object "Fetched" to "Reference 2"