<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>The TIA &amp; Racing the Beam on Programming the Atari VCS in Assembly</title><link>https://cdeever.github.io/atari-vcs/docs/tia-racing-the-beam/</link><description>Recent content in The TIA &amp; Racing the Beam 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/tia-racing-the-beam/index.xml" rel="self" type="application/rss+xml"/><item><title>The Frame Structure</title><link>https://cdeever.github.io/atari-vcs/docs/tia-racing-the-beam/frame-structure/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cdeever.github.io/atari-vcs/docs/tia-racing-the-beam/frame-structure/</guid><description>&lt;h1 id="the-frame-structure"&gt;The Frame Structure&lt;a class="anchor" href="#the-frame-structure"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The TIA produces no picture on its own — your code defines the frame by toggling the &lt;code&gt;VSYNC&lt;/code&gt; and &lt;code&gt;VBLANK&lt;/code&gt; signals at the right times and spending the right number of scanlines in each region. An NTSC frame is &lt;strong&gt;262 scanlines&lt;/strong&gt;, conventionally divided as:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Region&lt;/th&gt;
 &lt;th&gt;Lines&lt;/th&gt;
 &lt;th&gt;Purpose&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;VSYNC&lt;/td&gt;
 &lt;td&gt;3&lt;/td&gt;
 &lt;td&gt;Tells the TV &amp;ldquo;new frame starts here.&amp;rdquo;&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;VBLANK&lt;/td&gt;
 &lt;td&gt;37&lt;/td&gt;
 &lt;td&gt;Top blanking. The picture isn&amp;rsquo;t visible yet — do game logic here.&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Visible&lt;/td&gt;
 &lt;td&gt;192&lt;/td&gt;
 &lt;td&gt;The kernel. Everything the player sees is drawn here, one line at a time.&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;Overscan&lt;/td&gt;
 &lt;td&gt;30&lt;/td&gt;
 &lt;td&gt;Bottom blanking. Read input and collisions, update state.&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;


&lt;figure class="vcs-anim-figure"&gt;
 &lt;div class="vcs-anim"
 data-scene="beam"
 &gt;&lt;/div&gt;
 &lt;figcaption&gt;The beam paints 262 lines top-to-bottom; only the 192 visible lines carry picture. Press play, then scrub to freeze any moment.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h2 id="vertical-sync"&gt;Vertical sync&lt;a class="anchor" href="#vertical-sync"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A frame begins by turning on &lt;code&gt;VBLANK&lt;/code&gt; and &lt;code&gt;VSYNC&lt;/code&gt;, then holding &lt;code&gt;VSYNC&lt;/code&gt; for exactly three scanlines:&lt;/p&gt;</description></item><item><title>Color: Hue &amp; Luminance</title><link>https://cdeever.github.io/atari-vcs/docs/tia-racing-the-beam/color/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://cdeever.github.io/atari-vcs/docs/tia-racing-the-beam/color/</guid><description>&lt;h1 id="color-hue--luminance"&gt;Color: Hue &amp;amp; Luminance&lt;a class="anchor" href="#color-hue--luminance"&gt;#&lt;/a&gt;&lt;/h1&gt;
&lt;p&gt;The TIA holds exactly four color registers, one for each thing it can draw:&lt;/p&gt;
&lt;table&gt;
 &lt;thead&gt;
 &lt;tr&gt;
 &lt;th&gt;Register&lt;/th&gt;
 &lt;th&gt;Colors&lt;/th&gt;
 &lt;/tr&gt;
 &lt;/thead&gt;
 &lt;tbody&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;COLUBK&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;the background&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;COLUPF&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;the playfield (and the ball, which borrows it)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;COLUP0&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;player 0 (and missile 0)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
 &lt;td&gt;&lt;code&gt;COLUP1&lt;/code&gt;&lt;/td&gt;
 &lt;td&gt;player 1 (and missile 1)&lt;/td&gt;
 &lt;/tr&gt;
 &lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Each takes a single byte, and each is &lt;strong&gt;latched&lt;/strong&gt; — write it once and it sticks until you overwrite it. Set &lt;code&gt;COLUBK&lt;/code&gt; during startup and the background stays that color for the whole game without you ever touching it again. That, and the fact that you &lt;em&gt;can&lt;/em&gt; rewrite a color register mid-frame, are the two facts the rest of this page rests on.&lt;/p&gt;</description></item></channel></rss>