Re: A86: XORing Sprites


[Prev][Next][Index][Thread]

Re: A86: XORing Sprites




> From what I've heard when you XOR a sprite to the screen it
> draws it to the specified spot and also erases the old one.
> Is this correct?

No, it's not correct.  XOR is boolean logic.  It checks each
individual pixel as it makes changes.  If the old sprite has
the pixel on and the new sprite does not, the pixel remains
on.  If the old sprite does not have the pixel on but the new
sprite does, the pixel remains on.  If both or neither have
the pixel on, the pixel is turned off.  More simply, if a pixel
on both sprites is the same, it's off.  If it's different, it's on.

> And also does it erase every other sprite currently displayed?

For the above reason, no.

> or just the ones that are exactly like the one you are drawing
> during that call?

XOR has the interesting affect of being undone by being done
the same way twice.  This is not true of any other boolean
expression.

Boolean chart:

1 AND 1 is 1
1 AND 0 is 0
0 AND 1 is 0
0 AND 0 is 0
1 OR 1 is 1
1 OR 0 is 1
0 OR 1 is 1
0 OR 0 is 0
1 XOR 1 is 0
1 XOR 0 is 1
0 XOR 1 is 1
0 XOR 0 is 0

There are other boolean expressions, but they are less common.