Hendricks266, on 14 January 2012 - 01:41 PM, said:
Does anyone know of the proper way to set and un-set bits in CON using andvar, orvar, xorvar, etc., rather than addvar or subvar?
Setting bits via CON is quite obvious; as DeeperThought already stated, it should be done like this (sets the bit 8, for example):
orvar TEMP 8
Also, in order to reset a bit, you aren't ought to use an "if" statement; instead, you may perform a bitwise AND operation using the negated bit mask (that is, all bits are on except one that needs to be reset). Note that the hexadecimal number format suits better for this:
andvar TEMP 0xFFF7
Since 0xFFFF minus 8 gives 0xFFF7, this operation would reset the bit 8 which was set in the previous line.
Here's a short table of conversions between decimal and hexadecimal number representations and their inverses for 16-bit tags (such as the cstat parameters). It can be continued until 32768, but I think you've got the idea.
Decimal Hex Inv. Hex
1 0x0001 0xFFFE
2 0x0002 0xFFFD
4 0x0004 0xFFFB
8 0x0008 0xFFF7
16 0x0010 0xFFEF