<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AXlib_Masked_Sprites</id>
	<title>TI-BASIC:Xlib Masked Sprites - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://learn.cemetech.net/index.php?action=history&amp;feed=atom&amp;title=TI-BASIC%3AXlib_Masked_Sprites"/>
	<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Xlib_Masked_Sprites&amp;action=history"/>
	<updated>2026-05-28T13:44:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.3</generator>
	<entry>
		<id>http://learn.cemetech.net/index.php?title=TI-BASIC:Xlib_Masked_Sprites&amp;diff=545&amp;oldid=prev</id>
		<title>Maintenance script: Initial automated import</title>
		<link rel="alternate" type="text/html" href="http://learn.cemetech.net/index.php?title=TI-BASIC:Xlib_Masked_Sprites&amp;diff=545&amp;oldid=prev"/>
		<updated>2016-02-24T18:06:38Z</updated>

		<summary type="html">&lt;p&gt;Initial automated import&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;What would happen if there was a background already layed out on the screen, and you wanted to overlay a sprite on top of it? If you use any type of logic to draw the sprite, the background and sprite would get destroyed. Like this:&lt;br /&gt;
&lt;br /&gt;
[[File:Linkunmasked.png|190px]]&lt;br /&gt;
&lt;br /&gt;
Do you notice the extra white space around Link, where the background should be? One technique programmers use to prevent this is called Masking. Here&amp;#039;s one technique to do this.&lt;br /&gt;
&lt;br /&gt;
= Masking with AND =&lt;br /&gt;
&lt;br /&gt;
This is the most common technique that even assembly programmers use. What happens is the programmer creates 2 different sprites, one is the actual sprite, the other is a &amp;quot;mask&amp;quot;. Here&amp;#039;s how you create the mask.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|First take a regular sprite like this:|| [[File:Linksprite.png]]&lt;br /&gt;
|-&lt;br /&gt;
|And fill in the background with black pixels, so it looks like this:|| [[File:Linksprite2.png]]&lt;br /&gt;
|-&lt;br /&gt;
|Now just XOR the original sprite, so the filled background remains like this:|| [[File:Linkmask.png]]&lt;br /&gt;
|-&lt;br /&gt;
|The final result gives the mask of the sprite. Save this and the original sprite in a picture.||[[File:Linkresult.png]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Now when you display the sprite, you&amp;#039;d first &amp;#039;&amp;#039;AND&amp;#039;&amp;#039; the Mask to the screen (no update), and then &amp;#039;&amp;#039;XOR&amp;#039;&amp;#039; or &amp;#039;&amp;#039;OR&amp;#039;&amp;#039; the original sprite. The mask will force the pixels that take up the sprite&amp;#039;s image off, clearing a space for the sprite, but not overwriting the background.  For example:&lt;br /&gt;
&lt;br /&gt;
 PROGRAM:Mask&lt;br /&gt;
 :real(0,0    \\ Clear the screen&lt;br /&gt;
 :real(2,0,0,0,6,4,0,6,0,4,9,0,16,1    \\ Draws background tilemap stored in Pic9, notice 16*16 mode&lt;br /&gt;
 :real(1,24,32,2,16,1,0,0,1,0,0    \\ Draws mask&lt;br /&gt;
 :real(1,24,32,2,16,1,0,16,3,0,1    \\ Draw sprite[[Category:TI-BASIC]]&lt;br /&gt;
[[Category:TIBD]]&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>