Headcannon Game Engine Script Commands - Math Operations (Bit Shifting)
Index:
Bit Shifting - 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<<Reg |
(D) (E) | _Reg=Chr<<Const |
(D) (E) | _Reg=Chr<<Chr |
(D) (E) | _Reg=Chr<<Obj |
(D) (E) | _Reg=Obj<<Reg |
(D) (E) | _Reg=Obj<<Const |
(D) (E) | _Reg=Obj<<Chr |
(D) (E) | _Reg=Obj<<Obj |
(D) (E) | _Reg=Const<<Reg |
(D) (E) | _Reg=Const<<Const |
(D) (E) | _Reg=Const<<Chr |
(D) (E) | _Reg=Const<<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<<Reg |
(D) (E) | _Chr=Chr<<Const |
(D) (E) | _Chr=Chr<<Chr |
(D) (E) | _Chr=Chr<<Obj |
(D) (E) | _Chr=Obj<<Reg |
(D) (E) | _Chr=Obj<<Const |
(D) (E) | _Chr=Obj<<Chr |
(D) (E) | _Chr=Obj<<Obj |
(D) (E) | _Chr=Const<<Reg |
(D) (E) | _Chr=Const<<Const |
(D) (E) | _Chr=Const<<Chr |
(D) (E) | _Chr=Const<<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<<Reg |
(D) (E) | _Obj=Chr<<Const |
(D) (E) | _Obj=Chr<<Chr |
(D) (E) | _Obj=Chr<<Obj |
(D) (E) | _Obj=Obj<<Reg |
(D) (E) | _Obj=Obj<<Const |
(D) (E) | _Obj=Obj<<Chr |
(D) (E) | _Obj=Obj<<Obj |
(D) (E) | _Obj=Const<<Reg |
(D) (E) | _Obj=Const<<Const |
(D) (E) | _Obj=Const<<Chr |
(D) (E) | _Obj=Const<<Obj |
(D) (E) | _Reg=Reg>>Reg |
(D) (E) | _Reg=Reg>>Const |
(D) (E) | _Reg=Reg>>Chr |
(D) (E) | _Reg=Reg>>Obj |
(D) (E) | _Reg=Chr>>Reg |
(D) (E) | _Reg=Chr>>Const |
(D) (E) | _Reg=Chr>>Chr |
(D) (E) | _Reg=Chr>>Obj |
(D) (E) | _Reg=Obj>>Reg |
(D) (E) | _Reg=Obj>>Const |
(D) (E) | _Reg=Obj>>Chr |
(D) (E) | _Reg=Obj>>Obj |
(D) (E) | _Reg=Const>>Reg |
(D) (E) | _Reg=Const>>Const |
(D) (E) | _Reg=Const>>Chr |
(D) (E) | _Reg=Const>>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>>Reg |
(D) (E) | _Chr=Chr>>Const |
(D) (E) | _Chr=Chr>>Chr |
(D) (E) | _Chr=Chr>>Obj |
(D) (E) | _Chr=Obj>>Reg |
(D) (E) | _Chr=Obj>>Const |
(D) (E) | _Chr=Obj>>Chr |
(D) (E) | _Chr=Obj>>Obj |
(D) (E) | _Chr=Const>>Reg |
(D) (E) | _Chr=Const>>Const |
(D) (E) | _Chr=Const>>Chr |
(D) (E) | _Chr=Const>>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>>Reg |
(D) (E) | _Obj=Chr>>Const |
(D) (E) | _Obj=Chr>>Chr |
(D) (E) | _Obj=Chr>>Obj |
(D) (E) | _Obj=Obj>>Reg |
(D) (E) | _Obj=Obj>>Const |
(D) (E) | _Obj=Obj>>Chr |
(D) (E) | _Obj=Obj>>Obj |
(D) (E) | _Obj=Const>>Reg |
(D) (E) | _Obj=Const>>Const |
(D) (E) | _Obj=Const>>Chr |
(D) (E) | _Obj=Const>>Obj |
Bit Shifting - 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 |
(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:
Bit Shifting - Preserve original values:
3 LSH 5 = 96
3 * 32 = 96
00000011 LSH 5 = 01100000
(In the above example, the bits were shifted [moved] to the left 5 times, moving all 1's
and 0's to the left, and bringing in 5 more 0's from the right [When a bit moves left
past the highest bit place, it "falls ofF"])
A Right shift performs division by powers of 2:
97 RSH 3 = 12
97 / 8 = 12 (remainder 1)
01100001 RSH 3 = 00001100
(In the above example, the bits were shifted [moved] to the right 3 times, moving all 1's
and 0's to the right, and bringing in 3 more 0's from the left [When a bit moves right
past the 0th bit, it "falls off"])
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
The value of the variable given by "Var ID 1" is left- or right-shifted by the value of the variable given by "Var ID 2",
and the result is stored in the variable given by "Dest Var ID".
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.
Bit Shifting - Overwrite original values:
3 LSH 5 = 96
3 * 32 = 96
00000011 LSH 5 = 01100000
(In the above example, the bits were shifted [moved] to the left 5 times, moving all 1's
and 0's to the left, and bringing in 5 more 0's from the right [When a bit moves left
past the highest bit place, it "falls ofF"])
A Right shift performs division by powers of 2:
97 RSH 3 = 12
97 / 8 = 12 (remainder 1)
01100001 RSH 3 = 00001100
(In the above example, the bits were shifted [moved] to the right 3 times, moving all 1's
and 0's to the right, and bringing in 3 more 0's from the left [When a bit moves right
past the 0th bit, it "falls off"])
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
The value of the variable given by "Dest" is left- or right-shifted by the value of the variable given by "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:
Bit Shifting - Preserve original values:
#_Reg=Chr<<Const ;Left-shift the value of User-created "Active Variable" 18 of the Player "Fetched" to "Reference 0" by 3, and place the result in "User Register" 7
: a18 ;(Chr0) User-created "Active Variable" of the Player "Fetched" to "Reference 0"
: 3 ;(Const) 3
: U7 ;(Dest) "User Register" 7
; ----------
#_Chr=Chr>>Chr ;Right-shift the value of User-created "Active Variable" 12 of the Player "Fetched" to "Reference 0" by 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"
; ----------
#_Obj=Reg<<Obj ;Left-shift the value of "User Register" 24 by 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"
Bit Shifting - Overwrite original values:
#_Reg<<=Obj ;Left-shift the value of "User Register" 3 by 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>>=Chr ;Right-shift the value of User-created "Active Variable" 6 of the Player "Fetched" to "Reference 2" by 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 ;Left-shift the value of "Extra Variable" 8 of the Object "Fetched" to "Reference 2" by 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"