|
Post by Doug Bagnall on Dec 5, 2015 15:51:16 GMT
To allow individual bits of a variable to be set, reset and read. There are two possible options for this: one to allow any global variable to be used, and another local to individual sprites.
For global variables, have a command such as SETBIT with two parameters. The first is the global variable, and the second the bit number (0 to 7). For example, the following code would set bit 2 of the global variable A:
SETBIT A 2
To reset a bit, have a command such as RESETBIT which has the same parameters as SETBIT. For example, the following code would reset bit 2 of global variable A:
RESETBIT A 2
To read a bit, have a command such as READBIT which has the same parameters as before. For example, the following code would read bit 2 of global variable A, and if set would complete the code within the IF/ENDIF block:
IF READBIT A 2 ... ENDIF
For local sprite variables where we quite often need to store status information, we could have three new commands, SETSTATUS, RESETSTATUS, and READSTATUS, each followed by a bit number (0 to 7). This would allow 8 status elements and use only one byte. The commands could be used as follows (to set, reset and read bit 2):
SETSTATUS 2
RESETSTATUS 2
IF READSTATUS 2 ... ENDIF
|
|
|
Post by andrewvanbeck on Dec 11, 2015 11:35:17 GMT
Agreed, this would be really handy, it seems almost wasteful to use up a variable just for a true or false flag... if we could use this with PARAMA and PARAMB then we could really expand on what we can do with sprites, AI, and other game logic.
|
|