<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Collisions on Programming the Atari VCS in Assembly</title><link>https://cdeever.github.io/atari-vcs/docs/collisions/</link><description>Recent content in Collisions on Programming the Atari VCS in Assembly</description><generator>Hugo</generator><language>en-us</language><atom:link href="https://cdeever.github.io/atari-vcs/docs/collisions/index.xml" rel="self" type="application/rss+xml"/><item><title>The Collision Registers</title><link>https://cdeever.github.io/atari-vcs/docs/collisions/the-collision-registers/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cdeever.github.io/atari-vcs/docs/collisions/the-collision-registers/</guid><description>&lt;h1 id="the-collision-registers"&gt;The Collision Registers&lt;a class="anchor" href="#the-collision-registers"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The TIA tracks collisions between its six drawable objects — the two &lt;a href="https://cdeever.github.io/atari-vcs/docs/sprites/drawing-a-player/"&gt;players&lt;/a&gt;, two &lt;a href="https://cdeever.github.io/atari-vcs/docs/sprites/missiles-and-ball/"&gt;missiles, the ball&lt;/a&gt;, and the &lt;a href="https://cdeever.github.io/atari-vcs/docs/playfield/"&gt;playfield&lt;/a&gt;. Six objects make &lt;strong&gt;15 possible pairs&lt;/strong&gt;, and the chip reports them across &lt;strong&gt;eight read-only registers&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id="detection-is-geometric-and-it-latches"&gt;Detection is geometric, and it latches&lt;a class="anchor" href="#detection-is-geometric-and-it-latches"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As the beam paints each visible pixel, the TIA asks a simple question: are two objects &lt;em&gt;both lit here&lt;/em&gt;? If so, it sets the corresponding collision bit. Two things follow from that:&lt;/p&gt;</description></item><item><title>Reading &amp; Clearing</title><link>https://cdeever.github.io/atari-vcs/docs/collisions/reading-collisions/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cdeever.github.io/atari-vcs/docs/collisions/reading-collisions/</guid><description>&lt;h1 id="reading--clearing"&gt;Reading &amp;amp; Clearing&lt;a class="anchor" href="#reading--clearing"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The TIA does the detecting; your job is two small, regular acts: &lt;strong&gt;read&lt;/strong&gt; the &lt;a href="https://cdeever.github.io/atari-vcs/docs/collisions/the-collision-registers/"&gt;latches&lt;/a&gt; once the frame has been drawn, and &lt;strong&gt;clear&lt;/strong&gt; them before the next one. Get that rhythm right and collisions are nearly free; get it wrong and they either never fire or never stop.&lt;/p&gt;
&lt;h2 id="testing-a-latch-with-bit"&gt;Testing a latch with &lt;code&gt;BIT&lt;/code&gt;&lt;a class="anchor" href="#testing-a-latch-with-bit"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Each collision flag sits in bit 7 (and bit 6) of its register, which is exactly where &lt;code&gt;BIT&lt;/code&gt; is most useful: it copies a memory location&amp;rsquo;s bit 7 into the &lt;strong&gt;N&lt;/strong&gt; flag and bit 6 into the &lt;strong&gt;V&lt;/strong&gt; flag, without changing any register (&lt;a href="https://cdeever.github.io/atari-vcs/docs/6502-basics/registers/"&gt;see Registers &amp;amp; Flags&lt;/a&gt;). So one &lt;code&gt;BIT&lt;/code&gt; tests both pairs at once:&lt;/p&gt;</description></item></channel></rss>