Garth's Equipment Shop wrote:
Can you two please explain to me this setting a certain bit of a variable? And low or high byte? This is all greek to me. :P
If you look at the ACK manual, the 'general-purpose' variables (A through Z and A2 through Z2) are divided into two groups.
The first group (A-G and A2-G2) can hold values in the range of 0-255, while the second group (H-Z and H2-Z2) can hold values from 0-65535 (the manual says 65534 but this is most likely a typo).
The reason these range restrictions exist is because of the amount of computer memory that is used to store these variables.
The smaller variables (A-G, A2-G2) have one byte of storage (8 bits) for each variable. The variables are stored in binary format, which means that each bit represents the presence or absence of a power-of-two value. The values for all 8 bits are summed to form the value of the variable. Using the typical convention, 'bit 0' represents the smallest value bit and 'bit 7' represents the highest value bit, so the values represented by each bit are:
bit 0 - 1
bit 1 - 2
bit 2 - 4
bit 3 - 8
bit 4 - 16
bit 5 - 32
bit 6 - 64
bit 7 - 128
So, for example, if you store the value 23 in one of these variables, this is represented by setting bits 0, 1, 2, and 4 to 1, and all other bits to 0, so the value is:
variable = 128*0 + 64*0 + 32*0 + 16*1 + 8*0 + 4*1 + 2*1 + 1*1
or,
variable = 16 + 4 + 2 + 1 = 23.
If you set all the bits in the variable to 0 (binary value 00000000b), this represents 0, and if you set all the bits in the variable to 1 (binary value 11111111b), this represents the sum of all the bits, or 255.
The larger variables are stored using 16 bits (maximum value 65535) which operate in the same manner.
For the 16 bit variables, you can also consider them as the sum of a 'low byte' and a 'high byte', where each byte is 8 bits. If you look in the ACK source code, this is actually the way these variables are stored internally, such that
variable value = (low byte value) + (high byte value * 256)
Garth's Equipment Shop wrote:
Does this make it possible to use a variable more than once in a game? Can you use a bit of a var and still use the same var normally elsewhere in game?
No, you are using the same variable in either case. For example, if you have variable A set to 10 (binary value 00001010b), and you set bit 7 to 1, the new value of variable A will be 138 (10001010b).
Garth's Equipment Shop wrote:
Also if the megapatch requires certain variables to remain unused in a game that uses megapatch, then the patch probably ought to include a list of variables for the game designer to make sure he/she avoids using other than for megapatch related purposes.
The list of variables used is included in the 'readme.txt' file in the megapatch ZIP. The current list is: W, X, Y, and Z.
Variables T and D are also used, but only if you have the corresponding features enabled by setting the appropriate bits in variable Z.