Difference between revisions of "ANDVar"
(Created page with "= {BB} {{IE_BB}} = {{IE_BB_ex}} {{IE_BB_desc}} See also: {BA} {{IE_BA}} ― {BE} {{IE_BE}} == <span id="Variable1">Varia...") |
|||
Line 8: | Line 8: | ||
− | == | + | == Variable 1 : Half-Word (hex) == |
{{Variables}} | {{Variables}} | ||
== Variable 2 : Half-Word (hex) == | == Variable 2 : Half-Word (hex) == | ||
− | + | {{Variables}} |
Revision as of 00:05, 17 February 2014
{BB} ANDVar
ANDVar(xVAR1,xVAR2)
AND Variable bitwise operand | Variable1 = Variable1 AND Variable2
This command compares the individual bits of the value between two Variables, and produces a single binary output.
With AND, the resulting bit outputs are set to 1 (TRUE) only if both values' bit inputs are 1. This makes this a good way to disable a specific bit within a byte without changing the rest of the bits.
The bits available within a single byte are:
- 0x80
- 0x40
- 0x20
- 0x10
- 0x08
- 0x04
- 0x02
- 0x01
So, for example, if you want to edit a unit's Battle Stats to remove the Dead status (which is bit 0x20), but leave their other statii unchanged, you would UnitAddress their Unit ID, LoadAddress their stats at 0x0058 & 0x01BB into temporary variables (let's say 0x0070 & 0x0071), SET(x0072,x00DF), and then run ANDVar(x0070,x0072) and ANDVar(x0071,x0072), before using SaveAddress to put the corrected values back. Because the Dead status is in bit 0x20, a value of DF means that every bit except 0x20 is set to 1. As a result, the other statii in that byte will remain unchanged, but by forcing 0x20 to be set to 1 in the ImmediateValue, it will zero out the Dead bit in the final result.
See also: {BA} AND ― {BE} ZERO
Variable 1 : Half-Word (hex)
Click here for the list of Variables
Variable 2 : Half-Word (hex)
Click here for the list of Variables