#22445 - Wriggler - Mon Jun 21, 2004 1:25 pm
Hi guys,
Whilst relatively new to GBA programming, I have a small bit of C experience. However, I just want someone to clarify for me what this means (code taken from Pern Project Sprite tutorial):
Now I can see that the first line ANDs the hex value and attribute one. The comment informs that this clears the memory there. How exactly does this work? I don't understand how the "&" actually manages the memory and clears the pointer?
Also, the second line ORs the variable "x" to the attribute1 pointer. I assume this "adds" the value of x to the memory at attribute1. Again, what exactly is going on here?
I know this is fairly basic C, so apologies if I'm wasting anyone's time. I'm just after an explanation of the functionality of AND and OR, and a description of the difference between them.
Thanks a lot in advance!
Cheers,
Ben
Whilst relatively new to GBA programming, I have a small bit of C experience. However, I just want someone to clarify for me what this means (code taken from Pern Project Sprite tutorial):
Code: |
sp->attribute1 = sp->attribute1 & 0xFE00; //clear the old x value sp->attribute1 = sp->attribute1 | x; |
Now I can see that the first line ANDs the hex value and attribute one. The comment informs that this clears the memory there. How exactly does this work? I don't understand how the "&" actually manages the memory and clears the pointer?
Also, the second line ORs the variable "x" to the attribute1 pointer. I assume this "adds" the value of x to the memory at attribute1. Again, what exactly is going on here?
I know this is fairly basic C, so apologies if I'm wasting anyone's time. I'm just after an explanation of the functionality of AND and OR, and a description of the difference between them.
Thanks a lot in advance!
Cheers,
Ben