<?xml version="1.0" encoding="ISO-8859-1"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>ReCode | ReCode / Recent Changes</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.RecentChanges?action=rss</link>
<description>ReCode.Recent Changes</description>
<lastBuildDate>Wed, 02 Jan 2013 05:37:41 GMT</lastBuildDate>
<item>
<title>ReCode / (Boost) QVM Update</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.BoostQVMUpdated</link>
<description><![CDATA[<p class='vspace'>Happy new year -- and a new update to the (Boost) QVM library (note, this library has not been reviewed yet and it is not part of Boost.)
</p>
<p class='vspace'>Boost QVM provides a set of generic functions for working with quaternions, and vector and matrix types of static size. All operations use a type-traits system, which enables types from other vector/matrix libraries to be integrated in a common type-safe interface.
</p>
<p class='vspace'>The current source code and documentation is available <a class='urllink' href='http://www.revergestudios.com/boost-qvm' rel='nofollow'>here</a>. It contains minor bug fixes, and the following new features:
</p>
<p class='vspace'>- view proxies that negate matrix rows and columns (negr/negc)
</p>
<p class='vspace'>- view proxies that swap two rows or columns in a matrix (swapr/swapc)
</p>
<p class='vspace'>- functions for indexing at run-time of any vector or matrix object of arbitrary size.
</p>
]]></description>
<dc:contributor>emil</dc:contributor>
<dc:date>2013-01-02T05:37:41Z</dc:date>
<pubDate>Wed, 02 Jan 2013 05:37:41 GMT</pubDate>
</item>
<item>
<title>ReCode / Depth Of Field</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.DepthOfField</link>
<description><![CDATA[<p>In prototyping for a new video game, here at Reverge we needed to implement a depth of field effect in our engine. It turned out to be an interesting technical challenge so I decided to mention it here.
</p>
<div class='vspace'></div><h2>Background</h2>
<p>In photography, depth of field is an artistic effect that makes objects in the picture appear sharper or blurrier depending on their depth (how far away they are from the camera.) Here are a couple of examples (images courtesy of Wikipedia):
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_flowers.jpg' alt='' title='' /><code> </code><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_cat.jpg' alt='' title='' /></div>
<p class='vspace'>The following diagram shows the depth of field graphically, however keep in mind that there isn't a sudden drop in sharpness: in any photograph, only a single plane is in perfect focus -- at all other depths, the sharpness varies smoothly.
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_diagram.png' alt='' title='' /></div>
<p class='vspace'>The blurriness is an artifact of projecting the scene onto a 2D surface using a lens. In the case of a camera, the 2D surface the image is projected on is the CCD; in the case of the human eye, it is the retina.
</p>
<p class='vspace'>In general, a point from the observed object isn't projected into a single point on the 2D surface. Depending on the geometry of the lens, the depth of the object in the scene, and the distance between the 2D surface and the lens, a beam of light from the object will hit an area on the 2D surface which looks something like a circle, technically called the <em>circle of confusion</em>:
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_coc.png' alt='' title='' /></div>
<p class='vspace'>An important physical property of the retina is that it is composed of many individual photo receptors. Depending on the circle of confusion, the projection of a point from the scene will hit a different number of these receptors, and so the bigger the circle of confusion, the blurrier the object appears and the less detail is available for the brain to see. To compensate, the eye continuously adjust the geometry of its lens, minimizing the circle of confusion for the object we're focusing on, and that makes it appear sharp.
</p>
<p class='vspace'>A CCD is also composed of many individual photo receptors, and so the effect of the circle of confusion on the resulting image is very similar to the effect it has on the retina. This is what makes depth of field such an important artistic tool in photography: it removes detail from parts of the image depending on their depth, very similarly to the way refocusing the lens of your eye does it normally. So, the brain focuses on the sharp areas of the image by default.
</p>
<div class='vspace'></div><h2>Depth of field in movie production</h2>
<p>A lot of the depth of field effects you see in movies are done in post production. This means that they aren't a result of the physical properties of the lens the shots were taken with. In other words, they're fake.
</p>
<p class='vspace'>Since each frame is affected by the circle of confusion, even sharp objects are not uniformly sharp: with high enough resolution, a small amount of blurring can be seen throughout the image. So, some algorithms for faking depth of field effect in post production simply increase the blurriness present in the image, which already depends "correctly" on the depth.
</p>
<div class='vspace'></div><h2>Depth blur</h2>
<p>In computer graphics, raytracing techniques can easily be adapted to simulate lens and the resulting circle of confusion. However, games and other real-time applications use simple polygon rasterization to display images. There is no lens, and there is no circle of confusion. So, not only depth of field has to be faked, but it can not be faked by increasing the blurriness that already exists in the image, since the image is perfectly sharp (more precisely, any blurriness in the image has nothing to do with depth.)
</p>
<p class='vspace'>Realtime depth of field effects are done as a post-effect, meaning, they operate on the final 2D image after all 3D rendering and lighting has been completed. The technique is sometimes called a <em>depth blur</em>, because it applies varying amount of blur to all pixels based on their depth. Here is a capture of what this looks like:
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_plane.jpg' alt='' title='' /></div>
<p class='vspace'>Depth blur is typically implemented in 3 passes:
</p>
<div class='vspace'></div><div class='indent'>1. The scene is rendered into a render target that can also be used as a texture, capturing the depth of each pixel either in the alpha channel or in a separate render target.
<div class='vspace'></div></div><div class='indent'>2. The captured 2D image is resampled to a lower resolution, and the result from that is processed by a 2D gaussian kernel (note, this processing includes the depth values captured in the previous step, not only the RGB component.)
<div class='vspace'></div><div class='indent'><em>As a side note, the 2D gaussian can be trivially decomposed into two 1D passes. This reduces the number of texture fetches significantly: for example a 5x5 2D gaussian requires 25 reads whereas decomposing it to two 1D gaussians requires only 10 reads total (5+5). Less obvious is that bilinear interpolation (which the texture samplers support for free!) can be used to further reduce the number of reads while still producing a mathematically correct result. The technique is described in <a class='urllink' href='http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/' rel='nofollow'>this excellent article</a>.</em>
</div><div class='vspace'></div></div><div class='indent'>3. The normal and lower resolution versions of the image are bound as textures, and processed by a pixel shader which samples both of them, producing an output by linearly interpolating the samples based on the corresponding depth values. This is where the effect of the circle of confusion can be simulated: we take a fixed number of samples (for example, 7 or 8) arranged in a circle that is scaled appropriately for both images.
<div class='vspace'></div><div class='indent'><em>A second caution, keep in mind that due to <a class='urllink' href='http://en.wikipedia.org/wiki/Mipmap' rel='nofollow'>mipmapping</a>, objects that are closest to the camera typically appear at maximum sharpness in video games, which offsets the blurring of up-close objects that we need. This can be controlled by carefully lowering the maximum resolution in the textures.</em>
</div></div><div class='vspace'></div><h2>A final refinement</h2>
<p>Simple depth blur doesn't produce satisfactory results in general. Consider a foreground object in focus that is in front of a background that is supposed to be blurred. The background pixels that are immediately next to pixels of the foreground object must be blurred, meaning, some of the color from the neighboring objects should bleed into them -- but not from the pixels that are part of the foreground (in-focus) object. To get a correct result, we need to blur with pixels that are <em>behind</em> (deeper than) that object, and the problem is that we don't have those pixels.
</p>
<p class='vspace'>Therefore, if we simply blur based on depth, a foreground in-focus object will bleed onto the background. To our eyes, this looks very wrong.
</p>
<p class='vspace'>One possible fix is, in the last step where we average the 7 or 8 samples interpolated by their corresponding depth, we could exclude in-focus pixels that are closer than the rest of the samples. The results produced by this simple hack turned out to be quite satisfactory for us.
</p>
<p class='vspace'>Here is the final result -- note how the foreground in-focus object does not bleed into the blurred background.
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_ot1.jpg' alt='' title='' /></div>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/dof_ot2.jpg' alt='' title='' /></div>
<p><a name='comment1' id='comment1'></a>
</p><div class='messagehead' > 
<h5>gemicha  &#8212;  <span style='font-size:83%'>18 December 2012, 14:00</span>  </h5>
</div><div class='messageitem' > 
<p><a class='urllink' href='https://www.youtube.com/watch?v=OUYuUs1aaCU' rel='nofollow'>https://www.youtube.com/watch?v=OUYuUs1aaCU</a>
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>gemicha</dc:contributor>
<dc:date>2012-12-18T22:00:40Z</dc:date>
<pubDate>Tue, 18 Dec 2012 22:00:40 GMT</pubDate>
</item>
<item>
<title>ReCode / Possible Loss Of Data</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.PossibleLossOfData</link>
<description><![CDATA[<p>If static type checking is useful for detecting bugs, it is an even more powerful refactoring tool. In a well designed program, it is often possible to make a change in an interface, then rely on the compiler to report errors for all places in the code that need to be altered to match. In general, it is A Good Thing to design code that relies on static type checking as much as possible.
</p>
<p class='vspace'>But one of the most common problems programmers inflict on themselves is when they try to use the static type checking built in C and C++ compilers to detect bugs due to integer conversions that result in loss of precision.
</p>
<p class='vspace'>Let's say in a class called <code>point</code>, we have reasons to store X and Y as <code>short</code>s rather than <code>int</code>s:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">class</span> point<br />
<span class="br0">&#123;</span><br />
&#160; <span class="kw2">short</span> x_, y_;<br />
<span class="kw1">public</span>:<br />
&#160; point<span class="br0">&#40;</span> <span class="kw2">short</span> x, <span class="kw2">short</span> y <span class="br0">&#41;</span>:<br />
&#160; &#160; x_<span class="br0">&#40;</span>x<span class="br0">&#41;</span>,<br />
&#160; &#160; y_<span class="br0">&#40;</span>y<span class="br0">&#41;</span><br />
&#160; <span class="br0">&#123;</span><br />
&#160; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span>;<br />
<br />
<span class="kw2">void</span> bar<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&#160; point p<span class="br0">&#40;</span>x,y<span class="br0">&#41;</span>; <span class="co1">//oops?</span><br />
<span class="br0">&#125;</span></div></div>
</div>
<p class='vspace'>Right, we might have a problem. On most platforms, the <code>int</code> and <code>short</code> types are 32- and 16-bits in size, respectively. This means that the call to the <code>point</code> constructor <em>may</em> result in loss of data.
</p>
<p class='vspace'>It would be very nice if we could get the compiler to point out all instances where an <code>int</code> is implicitly converted to a <code>short</code>, so that we can verify that the loss of precision is desirable or at least that it isn't a problem.
</p>
<p class='vspace'>So we enable the appropriate warning:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;">warning C4242: <span class="st0">'argument'</span> : conversion from <span class="st0">'int'</span> to <span class="st0">'short'</span>, possible loss of data</div></div>
</div>
<p class='vspace'>What makes this especially desirable is that function (and constructor) declarations are usually separated in a header file. The thinking is, if a careless programmer calls the constructor with <code>int</code> arguments, the compiler will point out the possible problem, the programmer will inspect the code carefully to confirm that the loss of precision is OK, and then... Well,
</p>
<div class='vspace'></div><h2>Then what?</h2>
<p>What do you say? Casting? Yes, this situation is a textbook example for using casts:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw2">void</span> bar<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&#160; point p<span class="br0">&#40;</span><span class="br0">&#40;</span><span class="kw2">short</span><span class="br0">&#41;</span>x,<span class="br0">&#40;</span><span class="kw2">short</span><span class="br0">&#41;</span>y<span class="br0">&#41;</span>; <span class="co1">//Trust me, it's OK</span><br />
<span class="br0">&#125;</span></div></div>
</div>
<p class='vspace'>The trouble is, in the original program, the compiler would have truncated <code>x</code> and <code>y</code> <em>only if</em> they needed to be truncated. The program that uses casts to avoid the warning will truncate <code>x</code> and <code>y</code> even if they don't need to be truncated.
</p>
<p class='vspace'>We've changed the semantics of the program in a way that's not just dangerous, it's <em>more dangerous than the potential bug the warning was intended to detect.</em> If during later refactoring we realize that we do need the extra precision of <code>int</code>, the <code>point</code> class will have to change accordingly:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">class</span> point<br />
<span class="br0">&#123;</span><br />
&#160; <span class="kw2">int</span> x_, y_;<br />
<span class="kw1">public</span>:<br />
&#160; point<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span>:<br />
&#160; &#160; x_<span class="br0">&#40;</span>x<span class="br0">&#41;</span>,<br />
&#160; &#160; y_<span class="br0">&#40;</span>y<span class="br0">&#41;</span><br />
&#160; <span class="br0">&#123;</span><br />
&#160; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span>;<br />
<br />
<span class="kw2">void</span> bar<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&#160; point p<span class="br0">&#40;</span><span class="br0">&#40;</span><span class="kw2">short</span><span class="br0">&#41;</span>x,<span class="br0">&#40;</span><span class="kw2">short</span><span class="br0">&#41;</span>y<span class="br0">&#41;</span>; <span class="co1">//Trust me, it's OK</span><br />
<span class="br0">&#125;</span></div></div>
</div>
<p class='vspace'>And now we don't have a warning but we have a nasty bug, all because we explicitly instructed the compiler to do something bad (cast), something that it's carefully designed not to do!
</p>
<p class='vspace'>The source of the bug is the ill-advised attempt to use static type checking to detect what is inherently a run-time error. Converting an <code>int</code> to a <code>short</code> is dangerous only if the run-time value of <code>x</code> exceeds the valid range for <code>short</code> integers. A better approach is to ditch the warning and the cast it comes with, and use <code>assert</code>:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw2">void</span> bar<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&#160; assert<span class="br0">&#40;</span>x&gt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">min</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; assert<span class="br0">&#40;</span>x&lt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">max</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; assert<span class="br0">&#40;</span>y&gt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">min</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; assert<span class="br0">&#40;</span>y&lt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">max</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; point p<span class="br0">&#40;</span>x,y<span class="br0">&#41;</span>; <span class="co1">//Now we *know* we're OK</span><br />
<span class="br0">&#125;</span></div></div>
</div>
<p class='vspace'>But now... even if we assume that programmers will always <code>assert</code> before calling <code>foo</code> (quite an assumption!) the resulting code is pretty ugly to look at.
</p>
<p class='vspace'>To solve the problem, we need to take a step back and look at the original reasons why the <code>point</code> constructor takes <code>short</code>s instead of <code>int</code>s. Clearly, this is because the values are copied to the members of class <code>point</code>, which are of type <code>short</code> to save memory. Note, however, that the savings come from the <code>point</code> members, not from the constructor itself taking <code>short</code>s -- the latter was done for "consistency", which A) doesn't make it correct, and B) as we'll see later isn't even consistent.
</p>
<p class='vspace'>First, we should make the constructor take <code>int</code> parameters regardless of the type of the (private) members:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">class</span> point<br />
<span class="br0">&#123;</span><br />
&#160; <span class="kw2">short</span> x_, y_;<br />
<span class="kw1">public</span>:<br />
&#160; point<span class="br0">&#40;</span> <span class="kw2">int</span> x, <span class="kw2">int</span> y <span class="br0">&#41;</span>:<br />
&#160; &#160; x_<span class="br0">&#40;</span>x<span class="br0">&#41;</span>,<br />
&#160; &#160; y_<span class="br0">&#40;</span>y<span class="br0">&#41;</span><br />
&#160; <span class="br0">&#123;</span><br />
&#160; &#160; assert<span class="br0">&#40;</span>x&gt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">min</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; &#160; assert<span class="br0">&#40;</span>x&lt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">max</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; &#160; assert<span class="br0">&#40;</span>y&gt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">min</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; &#160; assert<span class="br0">&#40;</span>y&lt;=std::<span class="me2">numeric_limits</span>&lt;short&gt;::<span class="me2">max</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&#160; <span class="br0">&#125;</span><br />
<span class="br0">&#125;</span>;</div></div>
</div>
<p class='vspace'>This promotes consistency throughout the program, regardless of what type the members of class <code>point</code> are this week. The constructor is also the perfect place to put our <code>assert</code>s, thus completely relieving the caller from the burden of truncating <code>int</code>s to <code>short</code>s.
</p>
<p class='vspace'>Second,
</p>
<div class='vspace'></div><h2>C++ and C are obsessed with ints</h2>
<p>Using <code>short</code> or <code>char</code> in any kind of integer expression ends up promoting them to <code>int</code> anyway. This can be illustrated by the following program:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="co2">#include &lt;iostream&gt;</span><br />
<br />
<span class="kw2">int</span> main<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
&#160; <span class="kw2">unsigned</span> <span class="kw2">short</span> x=<span class="nu0">65535</span>;<br />
&#160; std::<span class="me2">cout</span> &lt;&lt; <span class="kw1">sizeof</span><span class="br0">&#40;</span>x<span class="br0">&#41;</span> &lt;&lt; <span class="st0">&#34;, &#34;</span> &lt;&lt; <span class="kw1">sizeof</span><span class="br0">&#40;</span>x+x<span class="br0">&#41;</span> &lt;&lt; <span class="st0">&#34;, &#34;</span> &lt;&lt; x+x;<br />
<span class="br0">&#125;</span></div></div>
</div>
<p class='vspace'>The typical output of this program is:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="nu0">2</span>, <span class="nu0">4</span>, <span class="nu0">131070</span></div></div>
</div>
<p class='vspace'>Note that it prints 131070 for <code>x+x</code>, even though <code>x</code> is of type <code>short</code> and (for 16-bit <code>short</code>s anyway) wouldn't be able to hold that value. That's because <code>x+x</code> is of type <code>int</code>.
</p>
<p class='vspace'>As another example, if we pass something like <code>x+1</code> (which would be pretty common) to a function that takes <code>short</code>, the program will first produce an <code>int</code> which is then truncated to a <code>short</code> as part of the function call (and I'm not aware of a way to make compilers issue a warning in this case, not that it would be desirable anyway.)
</p>
<p class='vspace'>The best way to be consistent is to use the consistency of C and C++ to always promote small integer types to <code>int</code>. This means to forget about <code>char</code> and <code>short</code> as function arguments; they are (almost) never justified. The net effect of using them is that the program will contain a lot more places where data gets truncated, which makes it more prone to bugs.
</p>
<p class='vspace'>Avoiding <code>char</code> and <code>short</code> function arguments is not ideal, but it is better than using dangerous casts to suppress a retarded warning that should never have been enabled to begin with.
</p><div class='messagehead' > 
<h5>Gregory  &#8212;  <span style='font-size:83%'>02 June 2012, 04:46</span>  </h5>
</div><div class='messageitem' > 
<p>I disagree.
</p>
<p class='vspace'>Having Point's constructor take ints then assert then cast just hides information.
</p>
<p class='vspace'>Now, your code breaks *eventually* at runtime while the user of the class could have been aware of coordinates range restrictions.
</p>
<p class='vspace'>Also, your point about refactoring is contrived as many tutorials, blog posts or text books examples are :) The false promise of OOP: make a class, hide data in private members, provide public accessors. It's just piling up layers of useless code, coding for refactoring scenari that would never happen in real life imho
</p></div>
<p class='vspace'><a name='comment2' id='comment2'></a>
</p><div class='messagehead' > 
<h5>Emil  &#8212;  <span style='font-size:83%'>05 June 2012, 23:45</span>  </h5>
</div><div class='messageitem' > 
<p>What casts are you talking about, my suggestion doesn't have casts. Removing the asserts won't catch a possible runtime error, but even that is safer than the casts people commonly use to avoid the warning that they think protects them from something.
</p>
<p class='vspace'>By the way, notice that standard functions that take or return characters (like getch, tolower, etc.) use int and not char. What'd be the point of returning char anyway? So that foo(getch()) could resolve to a different overload than foo(getch()+1)? :)
</p></div>
<p class='vspace'><a name='comment3' id='comment3'></a>
</p><div class='messagehead' > 
<h5>Arseny Kapoulkine  &#8212;  <span style='font-size:83%'>11 June 2012, 14:52</span>  </h5>
</div><div class='messageitem' > 
<p>getch() can return EOF.
tolower can receive EOF.
Oh, and C did not have overloading.
</p>
<p class='vspace'>You can make a safe_cast utility function to avoid a hidden bug (assert) and to keep the natural type information.
</p></div>
<p class='vspace'><a name='comment4' id='comment4'></a>
</p><div class='messagehead' > 
<h5>Emil  &#8212;  <span style='font-size:83%'>18 June 2012, 13:10</span>  </h5>
</div><div class='messageitem' > 
<p>The real reason why getch() et al. communicate in terms of ints is that there is no static type checking in K&amp;R C.
</p>
<p class='vspace'>Anyway, do I understand correctly that you're proposing to use some kind of <code>safe_cast</code> every time you call a function that takes a short? Like:
</p>
<div class='vspace'></div><pre class='escaped'>void foo( short x );

void bar( int x )
{
  foo(safe_cast&lt;short&gt;(x));
}</pre>
<p class='vspace'>?
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>Emil</dc:contributor>
<dc:date>2012-06-18T20:10:53Z</dc:date>
<pubDate>Mon, 18 Jun 2012 20:10:53 GMT</pubDate>
</item>
<item>
<title>ReCode / Version Control</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.VersionControl</link>
<description><![CDATA[<p>Call me arrogant, but when I'm not happy with how something works, besides looking for a better alternative, I start thinking: "now how'd I do this if I were to design it". Usually those thoughts are a total waste of time since I don't have the expertise or the capacity to get to anything tangible, but occasionally I get motivated and start working on problems that are way too ambitious for me to take on.
</p>
<p class='vspace'>One of the projects that I've started years ago and never finished is a version control system. The main problem I have with Subversion, Perforce, Git and the like is that they're way too slow for us game developers. In games, besides code, we need to store very many and very large binary blobs. So many that even over a gigabit local network syncing the entire project tree to the latest revision is a major pain.
</p>
<p class='vspace'>The net effect is that developers become hesitant to syncing: your local revision of the project is in good working order, why would you bring in changes that might break it? The answer, of course, is that frequent syncing makes merging easier and more reliable. Yes, you might sync to something broken, but why is this a problem? You have a version control system right? You should be able to undo a situation like that in no time!
</p>
<p class='vspace'>But you can't. It takes forever to sync! So you keep working, until you're ready to commit. At this point you *should* first sync, but you don't. It takes forever to sync and forever more to undo a bad sync!
</p>
<p class='vspace'>Is it possible for syncing to work faster? After all, the version control system already uses binary deltas and you can't easily improve the speed of your network. So it boils down to how many and how big your files are, nothing can be done about that right? Not quite.
</p>
<p class='vspace'>Regardless of how large the files are, they are all being created and modified by people; and regardless of how productive people are, in practice all changes they make are highly localized. People work on individual files, and compared to the size of the entire project tree even Photoshop files are tiny on their own.
</p>
<p class='vspace'>So, there is no reason whatsoever for the version control system to wait for me to request a sync before it begins to transfer the data. In fact, there is no reason whatsoever to wait for someone to commit a change. As soon as a file is modified locally, that change can be mirrored to all other users who are likely to need it in the future. That way whenever they're ready to sync, the operation would involve moving a bunch of local files. And that *is* fast.
</p>
<p class='vspace'>Does such a version control system exist? Is it possible to emulate this behavior with existing software? Is there any reason why such a design is undesirable?
</p><div class='messagehead' > 
<h5>Andrew Armstrong  &#8212;  <span style='font-size:83%'>11 January 2011, 09:05</span>  </h5>
</div><div class='messageitem' > 
<p>That sounds awesome, especially if you used multicast somehow (because it's background it'd not matter if it lost some packets here and there as long as it does file checks), which would cut down on network congestion too, even for large files.
</p>
<p class='vspace'>As long as hard drives were large, there would hardly be any reason not to do that, as long as there are 2 local syncs - the active one you're using and the background one (containing changed files only presumably!).
</p>
<p class='vspace'>Would be fun to know if it exists anywhere already for sure.
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Geoff  &#8212;  <span style='font-size:83%'>15 June 2011, 11:13</span>  </h5>
</div><div class='messageitem' > 
<p>This sounds like a suggestion to implement  shared network drives as version control.
</p>
<p class='vspace'>You would also have to solve the problem of people modifying one (potentially) large file multiple times in quick succession, possibly causing network congestion and beyond that; read/write errors or lock contention due to attempting to update the file while the file is still being broadcast to other computers over the network. Your best bet would probably instead be to sync files in an automated manner at scheduled times throughout the day (varying frequency by file size if desired).
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>Geoff</dc:contributor>
<dc:date>2011-06-15T18:13:52Z</dc:date>
<pubDate>Wed, 15 Jun 2011 18:13:52 GMT</pubDate>
</item>
<item>
<title>ReCode / Computer Language Memes</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.ComputerLanguageMemes</link>
<description><![CDATA[<p>Here are some computer language memes for your enjoyment. :)
</p><hr />
<h2  style='text-align: center;'>Type safety as seen by fans of value-typed languages</h2>
<div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/languages3.gif' alt='' title='' /></div>
<hr />
<h2  style='text-align: center;'>Languages as seen by fans of other languages</h2>
<div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/languages1.jpg' alt='' title='' /></div>
<hr />
<h2  style='text-align: center;'>Microsoft languages as seen by fans of other Microsoft languages</h2>
<div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/languages2.jpg' alt='' title='' /></div>
<hr />
<p class='vspace'>
</p><div class='messagehead' > 
<h5>OvermindDL1  &#8212;  <span style='font-size:83%'>17 February 2010, 18:34</span>  </h5>
</div><div class='messageitem' > 
<p>Hehe, so awesome, and quite true for everything I fit into.  ^.^
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>emil</dc:contributor>
<dc:date>2011-04-26T09:28:14Z</dc:date>
<pubDate>Tue, 26 Apr 2011 09:28:14 GMT</pubDate>
</item>
<item>
<title>ReCode / Otter</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.Otter</link>
<description><![CDATA[<p>It's official, we've licensed the <a class='urllink' href='http://www.aonyxsoftware.com' rel='nofollow'>Otter UI</a> library to use in <a class='urllink' href='http://www.skullgirls.com' rel='nofollow'>Skullgirls</a>.
</p>
<p class='vspace'>Why Otter and not Scaleform? Perhaps the most important design decision for any middleware is where it draws the line in the sand: how much it does, and how much it relies on the game to provide. You don't want it to leave a critical and difficult problem for the game to deal with, but you also don't want it doing trivial things, which often makes the middleware unnecessarily rigid and inflexible.
</p>
<p class='vspace'>In a nutshell:
</p>
<div class='vspace'></div><ul><li>Otter does not use Flash, so it comes with its own animation editor.
</li><li>Otter doesn't have a script of its own, which means that the UI logic can be implemented in C++ or in Lua. This removes the need for a separate Flash interpreter in your game.
</li><li>Otter's runtime (the "player", in Flash terms) does not do any rendering. Instead, it just tells your game what textures to load and what polygons to draw -- which makes it <em>very</em> portable. Besides, it integrates seamlessly in your engine's shading framework.
</li></ul><p class='vspace'>Lastly but perhaps most importantly, the Aonyx team has been a pleasure to work with.
</p>
]]></description>
<dc:contributor>emil</dc:contributor>
<dc:date>2011-04-24T19:19:51Z</dc:date>
<pubDate>Sun, 24 Apr 2011 19:19:51 GMT</pubDate>
</item>
<item>
<title>ReCode / Bitfield Intricacies</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.BitfieldIntricacies</link>
<description><![CDATA[<p>This week a coworker was porting a networking library from Windows to PS3. Once the library was compiling and sort of working, he started plowing through subtle bugs, most due to the different byte ordering.
</p>
<p class='vspace'>He showed me a union similar to this:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">struct</span> foo<br />
<span class="br0">&#123;</span><br />
&#160; <span class="kw2">int</span> a:<span class="nu0">1</span>;<br />
&#160; <span class="kw2">int</span> b:<span class="nu0">31</span>;<br />
<span class="br0">&#125;</span>;<br />
<br />
<span class="kw2">union</span> bar<br />
<span class="br0">&#123;</span><br />
&#160; foo x;<br />
&#160; <span class="kw2">int</span> y;<br />
<span class="br0">&#125;</span>;</div></div>
</div>
<p class='vspace'>The idea here is to use the union, <em>bar</em>, to convert <em>foo</em> to network byte order when sending, and (if necessary) back to host byte order when receiving.
</p>
<p class='vspace'>Even if we set aside the obvious issues of size (we don't really know that an int is 32 bits) and aliasing rules (if you write <em>x</em> in the union, reading <em>y</em> is undefined behavior), such code is buggy also because when bitfields are used, it is unspecified whether the bits are allocated from the least significant to most significant bytes, or the other way around. The code worked on Windows only because both peers are compiled with the same compiler.
</p>
<p class='vspace'>But what caught my eye was the <em>int</em> bitfield of size 1. Clearly, you can store two values in it, and it is safe to assume that one of them is 0. But what is the other value? I wasn't sure.
</p>
<p class='vspace'>My thinking was, if the 1-bit two's complement format is used, then the possible values would be -1 and 0. But then again, we're talking about a bitfield, and in fact a 1-bit bitfield, so 0 and 1 also seem logical values.
</p>
<p class='vspace'>It turns out, the C standard states that the behavior in this case is implementation-defined.
</p>
<p class='vspace'>What's more, if a bitfield is of type <em>unsigned int</em>, then it is unsigned, but unless you explicitly say <em>signed int</em>, it is implementation-defined whether you're going to get a signed or unsigned int!
</p>
<p class='vspace'>So, going back to the original 1-bit bitfield value of type <em>int</em>, it is implementation-defined whether its range is [-1,0] or [0,1].
</p>
<p class='vspace'>In reality this subtlety is difficult to notice for 1-bit bitfields, because in boolean contexts 0 is false, and both -1 and 1 are true. However, to avoid portability problems, when larger bitfields are used, signed should be specified explicitly if negative values are needed.
</p>
]]></description>
<dc:contributor>emil</dc:contributor>
<dc:date>2011-04-07T06:19:04Z</dc:date>
<pubDate>Thu, 07 Apr 2011 06:19:04 GMT</pubDate>
</item>
<item>
<title>ReCode / Google Animation</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.GoogleAnimation</link>
<description><![CDATA[<p>Lately the Google logo is nice and animated. Or was, depending on when you read this post. Anyway, this is what it looks/looked like:
</p>
<div class='vspace'></div><div  style='text-align: center;'><img src='http://www.revergestudios.com/reblog/uploads/ReCode/google.gif' alt='' title='' /></div>
<p class='vspace'>The colorful balls bounce away from the cursor and that's lots of fun I suppose, unless you're a geek and you notice that OMG this stupid little animation is taking 100% of my CPU time running at no more than 10 frames per second! And that comes from the same company whose product happily announces that it has found more than a billion results in 0.25 seconds. I know, not a fair comparison, but still -- I wonder how many millennia would the search engine need to find a billion matches had it been running on Javascript or whatever advanced, Just-In-Time compiled, Virtual Machine powered, Garbage Collected, uber-secure engine powers the colorful balls.
</p>
<p class='vspace'>What's the big deal, you say? It's just a bunch of colorful balls, they'll be gone in a day or two!
</p>
<p class='vspace'>I wish the same could be said about Java in general. Whenever I run any Java-powered program on my computer, even when the program is idle, the OS often needs to power up the fan. To collect a dead object perhaps, who knows. The point is, ever since Java's arrival, we've heard the same mantra over and over: <em>"Oh, it's slow now but don't you worry it'll get faster. Soon. Like, tomorrow. JIT FTW!"</em>
</p>
<p class='vspace'>I've lost count on how many years I've been hearing that.
</p>
<p class='vspace'>But aren't these colorful dots fun anyway? Not if you realize how wasteful and inefficient the whole thing is. It really is a <a class='urllink' href='http://en.wikipedia.org/wiki/Googleplex' rel='nofollow'>Googleplex</a> slower than it should be. :)
</p><div class='messagehead' > 
<h5>OvermindDL1  &#8212;  <span style='font-size:83%'>19 September 2010, 17:52</span>  </h5>
</div><div class='messageitem' > 
<p>Actually it takes 7% of my CPU and runs a *lot* faster then 10fps, but then I am running Firefox4 with its new javascript JIT, what are you using?
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Yang Zhang  &#8212;  <span style='font-size:83%'>29 September 2010, 01:01</span>  </h5>
</div><div class='messageitem' > 
<p><a class='urllink' href='http://www.azulsystems.com/blog/cliff-click/2009-09-06-java-vs-c-performanceagain' rel='nofollow'>http://www.azulsystems.com/blog/cliff-click/2009-09-06-java-vs-c-performanceagain</a>
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>sonicth  &#8212;  <span style='font-size:83%'>05 April 2011, 13:10</span>  </h5>
</div><div class='messageitem' > 
<p>java or javascript its all the same, about collecting of dead objects i guess ;)
</p>
<p class='vspace'>a faster gc language is objective-c, or even c#
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>sonicth</dc:contributor>
<dc:date>2011-04-05T20:10:25Z</dc:date>
<pubDate>Tue, 05 Apr 2011 20:10:25 GMT</pubDate>
</item>
<item>
<title>ReCode / (Boost) LA becomes (Boost) QVM</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.BoostQVM</link>
<description><![CDATA[<p class='vspace'>Last year I've started on a 3D math library project called (Boost) LA. As indicated by the parenthesis, my intention is to request an official Boost review. I don't have much time to devote to this project, but this last weekend I've finished a major refactoring based on feedback from the preliminary Boost review, while adding a few missing pieces -- most notably support for quaternions.
</p>
<p class='vspace'>LA stands for Linear Algebra, but the initial feedback I got made it clear that the name is incorrect. To make the library domain clearer, I've decided to rename it to QVM, which stands for Quaternions, Vectors and Matrices.
</p>
<p class='vspace'>Click <a class='urllink' href='http://www.revergestudios.com/reblog/uploads/ReCode/boost-qvm.zip' rel='nofollow'>boost-qvm.zip</a> to download the source code and tests. This is a very preliminary announcement but of course I welcome all feedback here or privately at emildotchevski@gmail.com. Unfortunately I have not yet updated the documentation; for now, please refer to the <a class='urllink' href='http://www.revergestudios.com/boost-la/index.html' rel='nofollow'>original (Boost) LA documentation</a> which is correct semantically, but keep in mind the differences I've outlined below.
</p>
<div class='vspace'></div><h2>Operator| "pipe" overload gone</h2>
<p>Based on feedback, I've removed the operator| "pipe" overload which was used to chain up view proxies. View proxies can be used to access (with zero abstraction penalty) an object "as if" it is of a different type. For example in (Boost) LA you could say:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;">m|col&lt;<span class="nu0">1</span>&gt; *= s;</div></div>
</div>
<p class='vspace'>to multiply column 1 of the matrix <em>m</em>, as if it is a vector, by the scalar <em>s</em>. In (Boost) QVM the following expression achieves the same result:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;">col&lt;<span class="nu0">1</span>&gt;<span class="br0">&#40;</span>m<span class="br0">&#41;</span> *= s;</div></div>
</div>
<div class='vspace'></div><h2>Simplified header files</h2>
<p>Also based on feedback, I have consolidated the very many and small (Boost) LA header files into much fewer files. This makes using the library simpler.
</p>
<p class='vspace'>A new naming convention helps make header file names shorter:
</p>
<div class='vspace'></div><ul><li>"q" stands for quaternion, "v" stands for vector, and "m" stands for matrix.
</li><li>numbers indicate dimensionality, so 2 means 2D, 3 means 3D, etc.
</li></ul><p class='vspace'>For example, to get function overloads that can be used with any vector type, you'd #include "boost/qvm/v.hpp", while if you only wanted to work with 2D vector types, you'd #include "boost/qvm/v2.hpp". To get operations between matrices and vectors, you'd #include "boost/qvm/vm.hpp" or "boost/qvm/vm3.hpp" if you needed only the 3D overloads.
</p>
<p class='vspace'>Header files defining view proxies are named depending on the type of the input and the output type; for example view proxies that map matrix types to vector types are defined in "boost/qvm/map_mv.hpp".
</p>
<div class='vspace'></div><h2>New namespace sfinae</h2>
<p>The main namespace boost::qvm contains all (Boost) QVM types and functions. All function and operator overloads found in boost::qvm which use SFINAE are also available in the new namespace boost::qvm::sfinae. Therefore, while
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">using</span> <span class="kw1">namespace</span> boost::<span class="me2">qvm</span>;</div></div>
</div>
<p class='vspace'>may introduce ambiguities, it should now be always safe to say
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="kw1">using</span> <span class="kw1">namespace</span> boost::<span class="me2">qvm</span>::<span class="me2">sfinae</span>;</div></div>
</div>
<p class='vspace'>The above directive does not bring any types in scope. The introduced overloads are extremely generic (meaning, any overload that takes a specific type will take precedence) yet are only available for types for which the appropriate boost::qvm::q_traits/v_traits/m_traits is defined.
</p>
<div class='vspace'></div><h2>Element access</h2>
<p>The main innovation in this library is that it uses SFINAE to define operations which kick-in for <em>any</em> appropriate types, including user-defined types. This is what enables the view proxy functionality, which would have been impractical if each of the matrix or vector types it produces had to define its own operations.
</p>
<p class='vspace'>This design needs a way to access quaternion, vector and matrix elements generically. Traditionally, vector and matrix types overload operator[] or operator() to provide element access, which is impossible to do generically since the C++ standard requires them to be member functions.
</p>
<p class='vspace'>Using a function such as get&lt;Y&gt; or something similar to access elements is not very practical, so (Boost) LA used operator| overload for that purpose. (Boost) QVM uses operator% instead, because it has higher precedence (refer to <a class='urllink' href='http://www.difranco.net/cop2220/op-prec.htm' rel='nofollow'>this link</a>). For example, in (Boost) QVM, to access the Y of a vector you'd use the following notation:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;">v%Y</div></div>
</div>
<p class='vspace'>The same syntax is used for swizzling view proxies, for example:
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;">v%YXZ; <span class="co1">//Swaps the X and Y of a 3D vecttor</span><br />
v%YXZ1; <span class="co1">//Maps a 3D vector as 4D vector, swapping X and Y and adding the constant 1 as the last element. </span></div></div>
</div>
<p>
</p><div class='messagehead' > 
<h5>Alex  &#8212;  <span style='font-size:83%'>24 January 2011, 20:10</span>  </h5>
</div><div class='messageitem' > 
<p>Looks good, but the library is missing quaternion to rotation matrix conversions.
</p>
<p class='vspace'>Also, slerp looks like it'll have precision issues when nm is really close to 0. I would recommend a fourth optional parameter that specifies at which point to just do linear interpolation. It should default to something like 0.01 though.
</p>
<p class='vspace'>Not a fan of the % notation either. At least | looked better despite its precedence issues. Also % has precedence issues as well, in expressions like "5 * v%X".
</p>
<p class='vspace'>Fairly minor stuff. I was rolling my own quaternion stuff, but now I'll probably just switch over to qvm.
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Emil  &#8212;  <span style='font-size:83%'>25 January 2011, 00:53</span>  </h5>
</div><div class='messageitem' > 
<p>Conversions between types are handled by the make function template. As the first template parameter you specify the type you want to make, for example make&lt;my_quat&gt;(m), where my_quat is a quaternion type and m's type is a 3x3 matrix. See libs/qvm/test/make_test.cpp.
</p>
<p class='vspace'>I hear you about the slerp precision problems, I'll fix it. I also agree that the % notation sucks but do we have a better alternative? I guess we can go back to | (for element access only.)
</p>
<p class='vspace'>Thanks for the feedback!
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Alex  &#8212;  <span style='font-size:83%'>25 January 2011, 20:28</span>  </h5>
</div><div class='messageitem' > 
<p class='vspace'>Whoops, I missed the make&lt;my_mat&gt;(my_quat) specialization. Cool!
</p>
<p class='vspace'>As for the % notation. Personally I prefer the old | notation. However, I'm sidestepping the issue by overloading the [] operator in my custom vector class and the () operator in my custom matrix class for element access. With more effort, I could also support v[YXZ], but I don't currently need swizzling so I've not implemented all the overloads necessary for that.
</p>
<p class='vspace'>I've switched my project over from boost::la and my own quaternion stuff (which was quite similar, but not as nicely integrated) to qvm today. Turned out to be an easy transition :)
</p>
<p class='vspace'>This is a really good library, hope it makes it into boost!
</p>
<div class='vspace'></div></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Daniel  &#8212;  <span style='font-size:83%'>15 February 2011, 01:12</span>  </h5>
</div><div class='messageitem' > 
<p>You say that the function overloads using SFINAE are so generic that it is save to `using namespace boost::qvm::sfinae`.
If that is really the case, what is the reason for not putting them directly into the global namespace?
</p></div>
<p class='vspace'><a name='comment5' id='comment5'></a>
</p><div class='messagehead' > 
<h5>Emil  &#8212;  <span style='font-size:83%'>15 February 2011, 14:49</span>  </h5>
</div><div class='messageitem' > 
<p>The reason has to do with hiding. For example, any operator* in a user-defined namespace N would hide a global namespace operator* for scopes within namespace N. To make the overload resolution consider an unrelated (in ADL terms) operator*, it needs to be brought in scope (and you can't specify the global namespace in a using directive.)
</p>
<p class='vspace'>Realistically though, namespace sfinae gets undue attention in this post as well as in the documentation. By default, users should do <em>using namespace boost::qvm</em>. In case this introduces ambiguities, most likely they'd deal with them by qualifying the names; <em>using boost::qvm::sfinae</em> is simply another option which might be more convenient.
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>emil</dc:contributor>
<dc:date>2011-02-15T23:12:48Z</dc:date>
<pubDate>Tue, 15 Feb 2011 23:12:48 GMT</pubDate>
</item>
<item>
<title>ReCode / CALL-151</title>
<link>http://www.revergestudios.com/reblog/index.php?n=ReCode.CALL-151</link>
<description><![CDATA[<p>It is only natural for people to think with nostalgia about the good 'ol days: "oh man, back in the day things were so simple!" Objectively speaking, obviously, the "good 'ol days" sucked: that simplicity is only skin deep.
</p>
<p class='vspace'>Yes, a telephone was much easier to use in the 70s, but then again it didn't do <em>that</em> much, did it? Could you imagine having to memorize the phone numbers of everyone you need to text or call? Right, that would have sucked. How about having to fast forward in order to get to the next song on a compact cassette? Ouch.
</p>
<p class='vspace'>Yet, some things from the past are worth admiring. To me, a steam engine is prettier than the most advanced internal combustion engines of today. Not really practical, yet pretty.
</p>
<p class='vspace'>But I'm a programmer, and a lot of the old stuff I admire is software. And while I have (if only once) programmed a computer with punchcards, those were already antiques when I was in school; the computer I grew up programming was the Apple ][.
</p>
<div class='vspace'></div><div class='indent'><em>Actually, not quite: I grew up in Bulgaria which was a member of <a class='urllink' href='http://en.wikipedia.org/wiki/COMECON' rel='nofollow'>COMECON</a>, an economic organization of the communist states. According to Wikipedia, at its peak Bulgaria produced 40% of the computers in COMECON. Some of what we did was what China does today: copying and mass-producing western technology. So I grew up programming the Pravetz-82, which was an Apple ][ clone built with Bulgarian-made clone of the <a class='urllink' href='http://en.wikipedia.org/wiki/MOS_Technology_6502' rel='nofollow'>6502</a> CPU. :)</em>
</div><p class='vspace'>So here we go: at the risk of wasting my time raving about something most programmers today can't appreciate, I'll try to explain but just a tiny bit of Wozniak's brilliancy:
</p>
<div class='vspace'></div><h2>The Apple ][ floppy disk controller bootstrapping routine</h2>
<p>Some background: on physical magnetic media, you can't "just record data". Instead, 1 is encoded as a magnetic polarity transition (also known as flux reversal), and 0 is encoded as, well, lack of transition. Basically, for each bit there is a limited time window in which flux reversal is expected to occur. If it occurs, the bit is 1, otherwise it's 0. The problem is that the time window is so small that there is a limit on the accuracy with which the data window length can be measured. So, while detecting a series of ones is not a problem, it's difficult to know how many zeroes are encoded in a measured period of lack of flux reversal.
</p>
<p class='vspace'>Wozniak's original hardware design imposed two constraints on the raw data:
</p>
<div class='vspace'></div><ul><li>between any two 1-bits, there can be no more than one 0-bit, and
</li><li>each 8-bit byte must start with a 1-bit
</li></ul><p class='vspace'>However, using simple FM encoding "wastes" 4 bits per raw byte, which would allow only 10 256-byte sectors per track to be recorded. Instead, he devised a more complex encoding scheme that was based on the fact that there are 34 8-bit numbers which have the top bit set and no two 0-bits in a row. That way, 13 sectors per track could be recorded. Later on the hardware design of the floppy disk controller was modified to allow no more than one occurrence of two consecutive 0-bits in a byte, which lead to different encoding called 6&2; it allowed 16 sectors per track.
</p>
<p class='vspace'>A conventional floppy disk controller design would put all this bit twiddling in silicone which just DMAs the decoded bytes in memory -- but it would cost more in hardware. So what is a Wozniak to do? Obviously: screw hardware, do everything in software.
</p>
<p class='vspace'>That would have been impressive enough on a 6502 CPU, but even more impressive is what is required of the bootstrapping routine. It must:
</p>
<div class='vspace'></div><ul><li>generate the 6&amp;2 decoding table in RAM
</li><li>seek the disk drive to track zero
</li><li>look for the beginning marker of sector zero and read the raw data in RAM
</li><li>decode the data and jump into it
</li></ul><p class='vspace'>...all in no more than 256 bytes of code, which is the addressing limit for the ROM on Apple ][ expansion cards.
</p>
<p class='vspace'>By the way, there are no timers on the Apple ][, all timing is based on the CPU clock, e.g. you'd know that an INX instruction takes 2 microseconds to execute. The 6502 has three 8-bit registers: an accumulator A which can add, subtract, shift, rotate, and, or, xor, etc., and two 8-bit index registers X and Y which can do none of those operations. :)
</p>
<div class='vspace'></div><div class='sourceblock'>
 <div class='sourceblocktext'><div class="cpp" style="font-family: monospace;color: #303030; margin-left: 10px;"><span class="br0">&#93;</span>CALL<span class="nu0">-151</span><br />
*C600L<br />
<br />
C600-&#160; &#160;A2 <span class="nu0">20</span>&#160; &#160; &#160; &#160;LDX&#160; &#160;<span class="co2">#$20</span><br />
C602-&#160; &#160;A0 <span class="nu0">00</span>&#160; &#160; &#160; &#160;LDY&#160; &#160;<span class="co2">#$00</span><br />
C604-&#160; &#160;A2 <span class="nu0">03</span>&#160; &#160; &#160; &#160;LDX&#160; &#160;<span class="co2">#$03</span><br />
C606-&#160; &#160;<span class="nu0">86</span> 3C&#160; &#160; &#160; &#160;STX&#160; &#160;$3C<br />
C608-&#160; &#160;8A&#160; &#160; &#160; &#160; &#160; TXA<br />
C609-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C60A-&#160; &#160;<span class="nu0">24</span> 3C&#160; &#160; &#160; &#160;BIT&#160; &#160;$3C<br />
C60C-&#160; &#160;F0 <span class="nu0">10</span>&#160; &#160; &#160; &#160;BEQ&#160; &#160;$C61E<br />
C60E-&#160; &#160;<span class="nu0">05</span> 3C&#160; &#160; &#160; &#160;ORA&#160; &#160;$3C<br />
C610-&#160; &#160;<span class="nu0">49</span> FF&#160; &#160; &#160; &#160;EOR&#160; &#160;<span class="co2">#$FF</span><br />
C612-&#160; &#160;<span class="nu0">29</span> 7E&#160; &#160; &#160; &#160;AND&#160; &#160;<span class="co2">#$7E</span><br />
C614-&#160; &#160;B0 <span class="nu0">08</span>&#160; &#160; &#160; &#160;BCS&#160; &#160;$C61E<br />
C616-&#160; &#160;4A&#160; &#160; &#160; &#160; &#160; LSR<br />
C617-&#160; &#160;D0 FB&#160; &#160; &#160; &#160;BNE&#160; &#160;$C614<br />
C619-&#160; &#160;<span class="nu0">98</span>&#160; &#160; &#160; &#160; &#160; TYA<br />
C61A-&#160; &#160;9D <span class="nu0">56</span> <span class="nu0">03</span>&#160; &#160; STA&#160; &#160;$<span class="nu0">0356</span>,X<br />
C61D-&#160; &#160;C8&#160; &#160; &#160; &#160; &#160; INY<br />
C61E-&#160; &#160;E8&#160; &#160; &#160; &#160; &#160; INX<br />
C61F-&#160; &#160;<span class="nu0">10</span> E5&#160; &#160; &#160; &#160;BPL&#160; &#160;$C606<br />
C621-&#160; &#160;<span class="nu0">20</span> <span class="nu0">58</span> FF&#160; &#160; JSR&#160; &#160;$FF58<br />
C624-&#160; &#160;BA&#160; &#160; &#160; &#160; &#160; TSX<br />
C625-&#160; &#160;BD <span class="nu0">00</span> <span class="nu0">01</span>&#160; &#160; LDA&#160; &#160;$<span class="nu0">0100</span>,X<br />
C628-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C629-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C62A-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C62B-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C62C-&#160; &#160;<span class="nu0">85</span> 2B&#160; &#160; &#160; &#160;STA&#160; &#160;$2B<br />
C62E-&#160; &#160;AA&#160; &#160; &#160; &#160; &#160; TAX<br />
C62F-&#160; &#160;BD 8E C0&#160; &#160; LDA&#160; &#160;$C08E,X<br />
C632-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C635-&#160; &#160;BD 8A C0&#160; &#160; LDA&#160; &#160;$C08A,X<br />
C638-&#160; &#160;BD <span class="nu0">89</span> C0&#160; &#160; LDA&#160; &#160;$C089,X<br />
C63B-&#160; &#160;A0 <span class="nu0">50</span>&#160; &#160; &#160; &#160;LDY&#160; &#160;<span class="co2">#$50</span><br />
C63D-&#160; &#160;BD <span class="nu0">80</span> C0&#160; &#160; LDA&#160; &#160;$C080,X<br />
C640-&#160; &#160;<span class="nu0">98</span>&#160; &#160; &#160; &#160; &#160; TYA<br />
C641-&#160; &#160;<span class="nu0">29</span> <span class="nu0">03</span>&#160; &#160; &#160; &#160;AND&#160; &#160;<span class="co2">#$03</span><br />
C643-&#160; &#160;0A&#160; &#160; &#160; &#160; &#160; ASL<br />
C644-&#160; &#160;<span class="nu0">05</span> 2B&#160; &#160; &#160; &#160;ORA&#160; &#160;$2B<br />
C646-&#160; &#160;AA&#160; &#160; &#160; &#160; &#160; TAX<br />
C647-&#160; &#160;BD <span class="nu0">81</span> C0&#160; &#160; LDA&#160; &#160;$C081,X<br />
C64A-&#160; &#160;A9 <span class="nu0">56</span>&#160; &#160; &#160; &#160;LDA&#160; &#160;<span class="co2">#$56</span><br />
C64C-&#160; &#160;<span class="nu0">20</span> A8 FC&#160; &#160; JSR&#160; &#160;$FCA8<br />
C64F-&#160; &#160;<span class="nu0">88</span>&#160; &#160; &#160; &#160; &#160; DEY<br />
C650-&#160; &#160;<span class="nu0">10</span> EB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C63D<br />
C652-&#160; &#160;<span class="nu0">85</span> <span class="nu0">26</span>&#160; &#160; &#160; &#160;STA&#160; &#160;$<span class="nu0">26</span><br />
C654-&#160; &#160;<span class="nu0">85</span> 3D&#160; &#160; &#160; &#160;STA&#160; &#160;$3D<br />
C656-&#160; &#160;<span class="nu0">85</span> <span class="nu0">41</span>&#160; &#160; &#160; &#160;STA&#160; &#160;$<span class="nu0">41</span><br />
C658-&#160; &#160;A9 <span class="nu0">08</span>&#160; &#160; &#160; &#160;LDA&#160; &#160;<span class="co2">#$08</span><br />
C65A-&#160; &#160;<span class="nu0">85</span> <span class="nu0">27</span>&#160; &#160; &#160; &#160;STA&#160; &#160;$<span class="nu0">27</span><br />
C65C-&#160; &#160;<span class="nu0">18</span>&#160; &#160; &#160; &#160; &#160; CLC<br />
C65D-&#160; &#160;<span class="nu0">08</span>&#160; &#160; &#160; &#160; &#160; PHP<br />
C65E-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C661-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C65E<br />
C663-&#160; &#160;<span class="nu0">49</span> D5&#160; &#160; &#160; &#160;EOR&#160; &#160;<span class="co2">#$D5</span><br />
C665-&#160; &#160;D0 F7&#160; &#160; &#160; &#160;BNE&#160; &#160;$C65E<br />
C667-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C66A-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C667<br />
C66C-&#160; &#160;C9 AA&#160; &#160; &#160; &#160;CMP&#160; &#160;<span class="co2">#$AA</span><br />
C66E-&#160; &#160;D0 F3&#160; &#160; &#160; &#160;BNE&#160; &#160;$C663<br />
C670-&#160; &#160;EA&#160; &#160; &#160; &#160; &#160; NOP<br />
C671-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C674-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C671<br />
C676-&#160; &#160;C9 <span class="nu0">96</span>&#160; &#160; &#160; &#160;CMP&#160; &#160;<span class="co2">#$96</span><br />
C678-&#160; &#160;F0 <span class="nu0">09</span>&#160; &#160; &#160; &#160;BEQ&#160; &#160;$C683<br />
C67A-&#160; &#160;<span class="nu0">28</span>&#160; &#160; &#160; &#160; &#160; PLP<br />
C67B-&#160; &#160;<span class="nu0">90</span> DF&#160; &#160; &#160; &#160;BCC&#160; &#160;$C65C<br />
C67D-&#160; &#160;<span class="nu0">49</span> AD&#160; &#160; &#160; &#160;EOR&#160; &#160;<span class="co2">#$AD</span><br />
C67F-&#160; &#160;F0 <span class="nu0">25</span>&#160; &#160; &#160; &#160;BEQ&#160; &#160;$C6A6<br />
C681-&#160; &#160;D0 D9&#160; &#160; &#160; &#160;BNE&#160; &#160;$C65C<br />
C683-&#160; &#160;A0 <span class="nu0">03</span>&#160; &#160; &#160; &#160;LDY&#160; &#160;<span class="co2">#$03</span><br />
C685-&#160; &#160;<span class="nu0">85</span> <span class="nu0">40</span>&#160; &#160; &#160; &#160;STA&#160; &#160;$<span class="nu0">40</span><br />
C687-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C68A-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C687<br />
C68C-&#160; &#160;2A&#160; &#160; &#160; &#160; &#160; ROL<br />
C68D-&#160; &#160;<span class="nu0">85</span> 3C&#160; &#160; &#160; &#160;STA&#160; &#160;$3C<br />
C68F-&#160; &#160;BD 8C C0&#160; &#160; LDA&#160; &#160;$C08C,X<br />
C692-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C68F<br />
C694-&#160; &#160;<span class="nu0">25</span> 3C&#160; &#160; &#160; &#160;AND&#160; &#160;$3C<br />
C696-&#160; &#160;<span class="nu0">88</span>&#160; &#160; &#160; &#160; &#160; DEY<br />
C697-&#160; &#160;D0 EC&#160; &#160; &#160; &#160;BNE&#160; &#160;$C685<br />
C699-&#160; &#160;<span class="nu0">28</span>&#160; &#160; &#160; &#160; &#160; PLP<br />
C69A-&#160; &#160;C5 3D&#160; &#160; &#160; &#160;CMP&#160; &#160;$3D<br />
C69C-&#160; &#160;D0 BE&#160; &#160; &#160; &#160;BNE&#160; &#160;$C65C<br />
C69E-&#160; &#160;A5 <span class="nu0">40</span>&#160; &#160; &#160; &#160;LDA&#160; &#160;$<span class="nu0">40</span><br />
C6A0-&#160; &#160;C5 <span class="nu0">41</span>&#160; &#160; &#160; &#160;CMP&#160; &#160;$<span class="nu0">41</span><br />
C6A2-&#160; &#160;D0 B8&#160; &#160; &#160; &#160;BNE&#160; &#160;$C65C<br />
C6A4-&#160; &#160;B0 B7&#160; &#160; &#160; &#160;BCS&#160; &#160;$C65D<br />
C6A6-&#160; &#160;A0 <span class="nu0">56</span>&#160; &#160; &#160; &#160;LDY&#160; &#160;<span class="co2">#$56</span><br />
C6A8-&#160; &#160;<span class="nu0">84</span> 3C&#160; &#160; &#160; &#160;STY&#160; &#160;$3C<br />
C6AA-&#160; &#160;BC 8C C0&#160; &#160; LDY&#160; &#160;$C08C,X<br />
C6AD-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C6AA<br />
C6AF-&#160; &#160;<span class="nu0">59</span> D6 <span class="nu0">02</span>&#160; &#160; EOR&#160; &#160;$02D6,Y<br />
C6B2-&#160; &#160;A4 3C&#160; &#160; &#160; &#160;LDY&#160; &#160;$3C<br />
C6B4-&#160; &#160;<span class="nu0">88</span>&#160; &#160; &#160; &#160; &#160; DEY<br />
C6B5-&#160; &#160;<span class="nu0">99</span> <span class="nu0">00</span> <span class="nu0">03</span>&#160; &#160; STA&#160; &#160;$<span class="nu0">0300</span>,Y<br />
C6B8-&#160; &#160;D0 EE&#160; &#160; &#160; &#160;BNE&#160; &#160;$C6A8<br />
C6BA-&#160; &#160;<span class="nu0">84</span> 3C&#160; &#160; &#160; &#160;STY&#160; &#160;$3C<br />
C6BC-&#160; &#160;BC 8C C0&#160; &#160; LDY&#160; &#160;$C08C,X<br />
C6BF-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C6BC<br />
C6C1-&#160; &#160;<span class="nu0">59</span> D6 <span class="nu0">02</span>&#160; &#160; EOR&#160; &#160;$02D6,Y<br />
C6C4-&#160; &#160;A4 3C&#160; &#160; &#160; &#160;LDY&#160; &#160;$3C<br />
C6C6-&#160; &#160;<span class="nu0">91</span> <span class="nu0">26</span>&#160; &#160; &#160; &#160;STA&#160; &#160;<span class="br0">&#40;</span>$<span class="nu0">26</span><span class="br0">&#41;</span>,Y<br />
C6C8-&#160; &#160;C8&#160; &#160; &#160; &#160; &#160; INY<br />
C6C9-&#160; &#160;D0 EF&#160; &#160; &#160; &#160;BNE&#160; &#160;$C6BA<br />
C6CB-&#160; &#160;BC 8C C0&#160; &#160; LDY&#160; &#160;$C08C,X<br />
C6CE-&#160; &#160;<span class="nu0">10</span> FB&#160; &#160; &#160; &#160;BPL&#160; &#160;$C6CB<br />
C6D0-&#160; &#160;<span class="nu0">59</span> D6 <span class="nu0">02</span>&#160; &#160; EOR&#160; &#160;$02D6,Y<br />
C6D3-&#160; &#160;D0 <span class="nu0">87</span>&#160; &#160; &#160; &#160;BNE&#160; &#160;$C65C<br />
C6D5-&#160; &#160;A0 <span class="nu0">00</span>&#160; &#160; &#160; &#160;LDY&#160; &#160;<span class="co2">#$00</span><br />
C6D7-&#160; &#160;A2 <span class="nu0">56</span>&#160; &#160; &#160; &#160;LDX&#160; &#160;<span class="co2">#$56</span><br />
C6D9-&#160; &#160;CA&#160; &#160; &#160; &#160; &#160; DEX<br />
C6DA-&#160; &#160;<span class="nu0">30</span> FB&#160; &#160; &#160; &#160;BMI&#160; &#160;$C6D7<br />
C6DC-&#160; &#160;B1 <span class="nu0">26</span>&#160; &#160; &#160; &#160;LDA&#160; &#160;<span class="br0">&#40;</span>$<span class="nu0">26</span><span class="br0">&#41;</span>,Y<br />
C6DE-&#160; &#160;5E <span class="nu0">00</span> <span class="nu0">03</span>&#160; &#160; LSR&#160; &#160;$<span class="nu0">0300</span>,X<br />
C6E1-&#160; &#160;2A&#160; &#160; &#160; &#160; &#160; ROL<br />
C6E2-&#160; &#160;5E <span class="nu0">00</span> <span class="nu0">03</span>&#160; &#160; LSR&#160; &#160;$<span class="nu0">0300</span>,X<br />
C6E5-&#160; &#160;2A&#160; &#160; &#160; &#160; &#160; ROL<br />
C6E6-&#160; &#160;<span class="nu0">91</span> <span class="nu0">26</span>&#160; &#160; &#160; &#160;STA&#160; &#160;<span class="br0">&#40;</span>$<span class="nu0">26</span><span class="br0">&#41;</span>,Y<br />
C6E8-&#160; &#160;C8&#160; &#160; &#160; &#160; &#160; INY<br />
C6E9-&#160; &#160;D0 EE&#160; &#160; &#160; &#160;BNE&#160; &#160;$C6D9<br />
C6EB-&#160; &#160;E6 <span class="nu0">27</span>&#160; &#160; &#160; &#160;INC&#160; &#160;$<span class="nu0">27</span><br />
C6ED-&#160; &#160;E6 3D&#160; &#160; &#160; &#160;INC&#160; &#160;$3D<br />
C6EF-&#160; &#160;A5 3D&#160; &#160; &#160; &#160;LDA&#160; &#160;$3D<br />
C6F1-&#160; &#160;CD <span class="nu0">00</span> <span class="nu0">08</span>&#160; &#160; CMP&#160; &#160;$<span class="nu0">0800</span><br />
C6F4-&#160; &#160;A6 2B&#160; &#160; &#160; &#160;LDX&#160; &#160;$2B<br />
C6F6-&#160; &#160;<span class="nu0">90</span> DB&#160; &#160; &#160; &#160;BCC&#160; &#160;$C6D3<br />
C6F8-&#160; &#160;4C <span class="nu0">01</span> <span class="nu0">08</span>&#160; &#160; JMP&#160; &#160;$<span class="nu0">0801</span><br />
C6FB-&#160; &#160;<span class="nu0">00</span>&#160; &#160; &#160; &#160; &#160; BRK<br />
C6FC-&#160; &#160;<span class="nu0">00</span>&#160; &#160; &#160; &#160; &#160; BRK<br />
C6FD-&#160; &#160;<span class="nu0">00</span>&#160; &#160; &#160; &#160; &#160; BRK<br />
C6FE-&#160; &#160;<span class="nu0">00</span>&#160; &#160; &#160; &#160; &#160; BRK<br />
C6FF-&#160; &#160;<span class="nu0">00</span>&#160; &#160; &#160; &#160; &#160; BRK</div></div>
</div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Christer Ericson  &#8212;  <span style='font-size:83%'>15 September 2009, 11:33</span>  </h5>
</div><div class='messageitem' > 
<p>The Apple II disk controller and associated hardware is probably the most impressive design I know.
</p>
<p class='vspace'>You forgot to mention there's a second 256 byte "program" which is the controller state machine for shifting bits in (and out) of the memory mapped register(s) that the boot ROM addresses (the &#36;C08C,X location, etc).
</p>
<p class='vspace'>Changing both programs is what allowed the transition from DOS 3.2 to DOS 3.3 (13 to 16 sectors per track).
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Vladimir Strinski  &#8212;  <span style='font-size:83%'>15 September 2009, 14:40</span>  </h5>
</div><div class='messageitem' > 
<p>To add on top of that - he not only coded everything within the 256 bytes, he had a few bytes at the end to spare!
</p>
<p class='vspace'>AND on top of that - the first two bytes are a reserved value so the BIOS would recognize the controller, so you can't really use them.
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Emil  &#8212;  <span style='font-size:83%'>15 September 2009, 15:29</span>  </h5>
</div><div class='messageitem' > 
<p>Here are some pictures I found of Bulgarian-made Apple ][ clones: the first two are of Pravetz-82 from the late 70s/early 80s, the third picture is of Pravetz-8C from the late 80s/early 90s. These Bulgarian computers were compatible with Apple ][, but their evolution didn't entirely follow the evolution of Apple ][, e.g. some models didn't have an exact original.
</p>
<div class='vspace'></div><div><img src='http://www.revergestudios.com/reblog/uploads/ReCode/Pravetz-82_1.jpg' alt='' title='' /></div>
<div class='vspace'></div><div><img src='http://www.revergestudios.com/reblog/uploads/ReCode/Pravetz-82_2.jpg' alt='' title='' /></div>
<div class='vspace'></div><div><img src='http://www.revergestudios.com/reblog/uploads/ReCode/Pravetz-8C.jpg' alt='' title='' /></div>
<div class='vspace'></div></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Brad Snickenberg  &#8212;  <span style='font-size:83%'>19 April 2010, 19:03</span>  </h5>
</div><div class='messageitem' > 
<p>Back in the '70s you didn't memorize everyone's #, you had them written in your address book (an actual book) and if they weren't in there you looked them up in the phone book which had everyone in town's names and phone #'s listed. OMG privacy!
</p>
<p class='vspace'>yo! <a class='urllink' href='http://www.appleIIe.com' rel='nofollow'>http://www.appleIIe.com</a>
</p></div>
<p class='vspace'>
</p><div class='messagehead' > 
<h5>Ivailo Colov  &#8212;  <span style='font-size:83%'>08 January 2011, 11:12</span>  </h5>
</div><div class='messageitem' > 
<p>The original cpu used in Pravetz 82,8M was a Synertek SY6502 , the bulgarian cpu clone ( CM630) came later with the 8A,8C and 8s Models. Some 82s and 8Ms were with Rockwell R6502 chip.NIce memories ,thankyou :)
</p></div>
<div class='vspace'></div>
]]></description>
<dc:contributor>Ivailo Colov</dc:contributor>
<dc:date>2011-01-08T19:12:36Z</dc:date>
<pubDate>Sat, 08 Jan 2011 19:12:36 GMT</pubDate>
</item>
</channel>
</rss>
