<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coranac &#187; Uncategorized</title>
	<atom:link href="http://www.coranac.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coranac.com</link>
	<description>my own little world</description>
	<lastBuildDate>Sat, 19 Nov 2011 16:43:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Today&#8217;s steam deal : SpaceChem</title>
		<link>http://www.coranac.com/2011/07/steam-deal-spacechem/</link>
		<comments>http://www.coranac.com/2011/07/steam-deal-spacechem/#comments</comments>
		<pubDate>Fri, 01 Jul 2011 18:23:59 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=222</guid>
		<description><![CDATA[This is just a small head&#8217;s up (I intend to do a larger discussion later) about one of the most awesome and geeky indie-games available at the moment: SpaceChem by Zachatronics Industries. &#160; The basic premise behind SpaceChem is chemical engineering: in each assignment, you get some input molecules and you have to turn them [...]]]></description>
			<content:encoded><![CDATA[<p>
This is just a small head&#8217;s up (I intend to do a larger discussion later) about one of the most awesome and geeky indie-games available at the moment: <a href="http://store.steampowered.com/app/92800/">SpaceChem</a> by <a href="http://www.zachtronicsindustries.com/">Zachatronics Industries</a>.
</p>
<p><div>&nbsp;</div></p>
<p>
The basic premise behind SpaceChem is chemical engineering: in each assignment, you get some input molecules and you have to turn them into the requested output molecules via bonding and unbonding their atoms, and the occasional nuclear fusion. A simple (and decidedly sub-optimal) example:
</p>
<p><div>&nbsp;</div><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/Gk8JwvtVs38?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Gk8JwvtVs38?version=3" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object><div>&nbsp;</div></p>
<p>
The chemistry part is just a front, though. What the game <i>really</i> is, is a programming simulator. You have a tiny board (10&times;8) board with input and output zones and two &#8216;waldos&#8217; that trace a path on which you place and execute instructions: basically a tiny dual-threaded CPU with a select instruction set. I know it sounds simple, and that&#8217;s exactly right: it <i>sounds</i> simple. However, working out a workable design hard, VERY hard. Especially when you try to optimize a design for least time or components.
</p>
<p>
There are in-game leaderboards, showing you how much a design that you have toiled away at for hours actually sucks sweaty donkey balls, and a more detailed scoreboard at <a href="http://spacechem.net/">spacechem.net</a>. You can also upload your solutions to youtube. Here&#8217;s one of mine for &ldquo;Gas Works Park&rdquo;, where you turn some random carbon strings (C<sub>3</sub> / C<sub>4</sub>) and water (H<sub>2</sub>O) and turn them into methane (CH<sub>4</sub>) and carbondioxide (CO<sub>2</sub>). Solution details can be found in the video description.
</p>
<p><div>&nbsp;</div><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/dTVM_1sJq5o?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/dTVM_1sJq5o?version=3" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object><div>&nbsp;</div></p>
<ul>
<li>
Publisher site (with other engineering games): <a href="http://www.zachtronicsindustries.com/">Zachatronics Industries</a>
  </li>
<li>
Game site: <a href="http://www.spacechemthegame.com/">http://www.spacechemthegame.com/</a>
  </li>
<li>
Review: <a href="http://www.rockpapershotgun.com/2011/01/10/wot-i-think-spacechem">http://www.rockpapershotgun.com/2011/01/10/wot-i-think-spacechem</a>
  </li>
</ul>
<p><div>&nbsp;</div></p>
<p>
If you like programming and games (which probably describes readers here pretty well), you need to give this a try.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2011/07/steam-deal-spacechem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Grit 0.8.6 : synchronization update</title>
		<link>http://www.coranac.com/2010/03/grit-0-8-6-synchronization-update/</link>
		<comments>http://www.coranac.com/2010/03/grit-0-8-6-synchronization-update/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 12:56:43 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=169</guid>
		<description><![CDATA[This is just an update to synchronize what I have with devkitPro&#8216;s distribution of grit. This includes updates to the makefile, and turning back the way the size-constant was defined back to a #define. Apparently, consts aren&#8217;t constanty enough for C compilers for use in array declarations. Shame, I would have liked to get rid [...]]]></description>
			<content:encoded><![CDATA[<p>
This is just an update to synchronize what I have with <a href="http://www.devkitpro.org">devkitPro</a>&#8216;s distribution of grit. This includes updates to the makefile, and turning back the way the size-constant was defined back to a <code>#define</code>. Apparently, <code>const</code>s aren&#8217;t constanty enough for C compilers for use in array declarations. Shame, I would have liked to get rid of macros as much as possible  <kbd>:(</kbd>.
</p>
<p></p>
<p>
In any case, the two versions should be identical again <small>(with one small exception, namely that my version emits a <code>.size</code> directive for assembly, but that&#8217;s a minor something that should not affect anyone.)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/03/grit-0-8-6-synchronization-update/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>grit 0.8.4 (out with the old bugs, in with the new)</title>
		<link>http://www.coranac.com/2010/02/grit-0-8-4/</link>
		<comments>http://www.coranac.com/2010/02/grit-0-8-4/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 20:04:14 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=154</guid>
		<description><![CDATA[Okay, so it&#8217;s been a while, but there&#8217;s finally a new version for grit. &#160; First of all, the vector::insert should finally be fixed. And there was much rejoicing. I&#8217;ve also added an option for forcing the map palette-index (-mp &#60;num&#62;, which should help with NDS backgrounds that use ext-palettes. &#160; Also &#8211; and this [...]]]></description>
			<content:encoded><![CDATA[<p>
Okay, so it&#8217;s been a while, but there&#8217;s finally a new version for grit.
</p>
<p><div>&nbsp;</div></p>
<p>
First of all, the <code>vector::insert</code> should finally be fixed. And there was much rejoicing. I&#8217;ve also added an option for forcing the map palette-index (<tt>-mp &lt;num&gt;</tt>, which should help with NDS backgrounds that use ext-palettes.
</p>
<p><div>&nbsp;</div></p>
<p>
Also &ndash; and this one is pretty big &ndash; I&#8217;ve <b>completely replaced</b> the tile-mapping routines for something more general. The new method should be able to handle variable-sized tiles (<tt>-tw &lt;n&gt;</tt> and <tt>-th &lt;n&gt;</tt>) and is mostly independent of bitdepth. Specifically, bitdepths over 8 bpp can be handled as well, at least in principle. It also means that the external tileset can be a metatile-set as well now, which is good if you&#8217;re using metatiles.
</p>
<p>
With this new method also comes a way to create a custom bitformat for maps (<tt>-mB</tt> flag). I&#8217;m not entirely sure how this can be used yet, but using more than 10 bits for the tile-index, or a 1bpp collision map should be possible now.
</p>
<p>
Since this is a fairly major change, I kinda expect there&#8217;s still some bugs in the system. I have tested it for a number of options, but you know how it is with multi-platform stuff. In particular, if any of you big-endian-system users have trouble now, this will probably be the cause.
</p>
<p>
And now I will leave you with a &hellip;
</p>
<ul>
<li><a href=/projects/#grit>link to grit</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/02/grit-0-8-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Because robots need love too</title>
		<link>http://www.coranac.com/2010/01/because-robots-need-love-too/</link>
		<comments>http://www.coranac.com/2010/01/because-robots-need-love-too/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 19:15:33 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=147</guid>
		<description><![CDATA[<br />
<b>Warning</b>:  getimagesize() [<a href='function.getimagesize'>function.getimagesize</a>]: Filename cannot be empty in <b>/home/coranac/public_html/wordpress/wp-content/plugins/crnfilters.php</b> on line <b>466</b><br />
From xkcd (obviously) T_T]]></description>
			<content:encoded><![CDATA[<br />
<b>Warning</b>:  getimagesize() [<a href='function.getimagesize'>function.getimagesize</a>]: Filename cannot be empty in <b>/home/coranac/public_html/wordpress/wp-content/plugins/crnfilters.php</b> on line <b>466</b><br />
<p>
From <a href="http://xkcd.com/695/">xkcd</a> (obviously)
</p>
<p><div class="cpt" style="width:px;">
  <a href="" target="_blank">  <img src="" 
    alt="" width="" /></a><br />
  
</div>
</p>
<p>
<kbd>T_T</kbd></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/01/because-robots-need-love-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Symmetrical date is symmetrical</title>
		<link>http://www.coranac.com/2010/01/symmetrical-date-is-symmetrical/</link>
		<comments>http://www.coranac.com/2010/01/symmetrical-date-is-symmetrical/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 18:32:46 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=142</guid>
		<description><![CDATA[Random trivia: today is January 2nd, 2010. Or, in the One True Date Formatting, 20100102 : a symmetrical date. The next one won&#8217;t be November next year. insert obigatory &#8220;symmetrical&#8221; macro here]]></description>
			<content:encoded><![CDATA[<p>
Random trivia: today is January 2<sup>nd</sup>, 2010. Or, in the<br />
<a href="http://en.wikipedia.org/wiki/ISO_8601">One True Date Formatting</a>, 20100102 : a symmetrical date. The next one won&#8217;t be November next year.
</p>
<div class=cblock><i>insert obigatory &#8220;symmetrical&#8221; macro here</i></div>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/01/symmetrical-date-is-symmetrical/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Define: overthinking</title>
		<link>http://www.coranac.com/2008/08/define-overthinking/</link>
		<comments>http://www.coranac.com/2008/08/define-overthinking/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 18:07:47 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[ramble]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=55</guid>
		<description><![CDATA[&#60;ramble&#62; I think too much. Or so people keep telling me. And they may have a point. Anyway, so I&#8217;m working on this assembly version of toncset for, well, just because I guess. A fill routine has 3 parts: a head, a main run and a tail. The main part fills 32-bit chunks (words) when [...]]]></description>
			<content:encoded><![CDATA[<div>&lt;ramble&gt;</div>
<p>
I think too much. Or so people keep telling me. And they may have a<br />
point.
</p>
<p>
Anyway, so I&#8217;m working on this assembly version of<br />
<a href="http://www.coranac.com/2008/01/25/tonccpy/">toncset</a><br />
for, well, just because I guess. A fill<br />
routine has 3 parts: a head, a main run and a tail. The main part<br />
fills 32-bit chunks (words) when there&#8217;s more than 4 bytes left and<br />
when the destination is word-aligned. This part is easy, because<br />
you can just dump words with <code>stmia</code> or <code>str</code>.<br />
For an example of this, see my older<br />
<a href="http://www.coranac.com/2007/11/09/new-memset16-routine/">memset16 post</a>.
</p>
<p>
The tail is for the remaining bytes after the main part. Under normal<br />
circumstances you could do this byte for byte, but some sections of<br />
GBA/NDS memory do not take kindly to byte-writes, so you&#8217;d have to<br />
read the word, mask the appropriate bytes out/in and then write it<br />
back. This is mostly just annoying, but still very doable.
</p>
<p>
The head part, however, is both annoying and tricky. It consist of<br />
filling the unaligned bytes in the first word of a run so that the<br />
main part can do its thing. This is similar to the tail part, in that<br />
it requires bitmasks. However, it&#8217;s also possible that both the<br />
beginning <i>and</i> and of a run occur in the same word, effectively<br />
making the head the tail as well, so you&#8217;d have to apply a double mask<br />
&hellip; somehow. In C, it looks something like this:
</p>
<div class="cpp">
<div class="cpp proglist" style=" "><span class="coMULTI">/* Input:<br />
&nbsp; void *dstv; &nbsp; // potentially non-aligned<br />
&nbsp; u32 fill; &nbsp; &nbsp; // Already extended to full 32-bit if appropriate.<br />
&nbsp; uint size;&nbsp; &nbsp; // &gt; 0<br />
*/</span></p>
<p>u32 addr= (u32)dstv;<br />
<span class="kw1">int</span> left= addr&amp;<span class="nu0">3</span>;<br />
<span class="kw1">if</span>(left != <span class="nu0">0</span>)<br />
{<br />
&nbsp; &nbsp; u32 *dst= (u32*)(addr&amp;~<span class="nu0">3</span>);<br />
&nbsp; &nbsp; <span class="kw1">int</span> right= left+size;<br />
&nbsp; &nbsp; u32 mask= <span class="nu0">0xFFFFFFFF</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">if</span>(right &lt; <span class="nu0">4</span>) &nbsp; <span class="co1">// Everything in a single word: head and tail.</span><br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; mask= ~(mask&lt;&lt;<span class="nu0">8</span>*size);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create right-mask 000F</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mask &lt;&lt;= <span class="nu0">8</span>*left;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create mid mask 00F0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; *dst = (*dst &amp;~ mask) | (fill &amp; mask);<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span>;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; <span class="kw1">else</span><br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; mask &lt;&lt;= <span class="nu0">8</span>*left;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// Create left mask FFF0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; *dst = (*dst &amp;~ mask) | (fill &amp; mask);<br />
&nbsp; &nbsp; &nbsp; &nbsp; size= right-<span class="nu0">4</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; *dst++;<br />
&nbsp; &nbsp; }<br />
}</div>
</div>
<p>
This bit of C translates roughly into the following ARM code:
</p>
<div class="gccarm">
<div class="gccarm proglist" style=" ">&nbsp; &nbsp; <span class="co1">@ Reglist</span><br />
&nbsp; &nbsp; <span class="co1">@ r0 : dst</span><br />
&nbsp; &nbsp; <span class="co1">@ r1 : src</span><br />
&nbsp; &nbsp; <span class="co1">@ r2 : size</span><br />
&nbsp; &nbsp; <span class="co1">@ r3 : left (dst&amp;3) / right (left+size) / data</span><br />
&nbsp; &nbsp; <span class="co1">@ r4 : lshift (left*8)</span><br />
&nbsp; &nbsp; <span class="co1">@ r5 : rshift (right*8) / mask</span><br />
&nbsp; &nbsp; <span class="co1">@ ip : maskBase (0xFFFFFFFF)</span><br />
.Lfgset_head:<br />
&nbsp; &nbsp; <span class="re1">bic</span> &nbsp; &nbsp; <span class="kw2">r0</span>, <span class="kw2">r0</span>,#<span class="nu0">3</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Align dst</span><br />
&nbsp; &nbsp; <span class="re1">mvn</span> &nbsp; &nbsp; <span class="kw2">ip</span>, #<span class="nu0">0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Set-up mask (0xFFFFFFFF)</span><br />
&nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">r4</span>, <span class="kw2">r3</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ (left*=8) != 0 : right-side only</span><br />
&nbsp; &nbsp; <span class="re1">add</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw2">r2</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ right= left+size</span><br />
&nbsp; &nbsp; <span class="re1">cmp</span> &nbsp; &nbsp; <span class="kw2">r3</span>, #<span class="nu0">4</span></p>
<p>&nbsp; &nbsp; <span class="co1">@ &lt;= 4 : single-word. Shrink mask, do usual and quit early</span><br />
&nbsp; &nbsp; <span class="re1">movlo</span> &nbsp; <span class="kw2">r5</span>, <span class="kw2">r2</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ \.</span><br />
&nbsp; &nbsp; <span class="re1">mvnlo</span> &nbsp; <span class="kw2">ip</span>, <span class="kw2">ip</span>, <span class="kw1">lsl</span> <span class="kw2">r5</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ &#8211; r5= ((1&lt;&lt;8*size)-1)&lt;&lt;(8*left);</span><br />
&nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">r5</span>, <span class="kw2">ip</span>, <span class="kw1">lsl</span> <span class="kw2">r4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ /</span></p>
<p>&nbsp; &nbsp; <span class="re1">subhi</span> &nbsp; <span class="kw2">r2</span>, <span class="kw2">r3</span>, #<span class="nu0">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Adjust size for follow-ups</span></p>
<p>&nbsp; &nbsp; <span class="co1">@ Mask in r1 and write back to dst</span><br />
&nbsp; &nbsp; <span class="re2">ldr</span> &nbsp; &nbsp; <span class="kw2">r3</span>, [<span class="kw2">r0</span>]<br />
&nbsp; &nbsp; <span class="re1">bic</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw2">r5</span><br />
&nbsp; &nbsp; <span class="re1">and</span> &nbsp; &nbsp; <span class="kw2">r5</span>, <span class="kw2">r1</span>, <span class="kw2">r5</span><br />
&nbsp; &nbsp; <span class="re1">orr</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r5</span><br />
&nbsp; &nbsp; <span class="re2">str</span> &nbsp; &nbsp; <span class="kw2">r3</span>, [<span class="kw2">r0</span>], #<span class="nu0">4</span></p>
<p>&nbsp; &nbsp; bhi &nbsp; &nbsp; .Lfgset_main&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Longer stretch : go back.</span><br />
&nbsp; &nbsp; <span class="re2">bx</span>&nbsp; &nbsp; &nbsp; <span class="kw2">lr</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Single-word fill : finished.</span></div>
</div>
<p>
The main thing I thought when I&#8217;d written this down was &ldquo;meh&rdquo;.<br />
You will note that registers <code>r4</code> and <code>r5</code> are<br />
used here, which means stack-work (omitted here for brevity). The<br />
positioning of pushing and popping makes everything a little awkward,<br />
so I was off looking for something else.
</p>
<p>
The essence of the problem here is that you can only use five registers<br />
without touching the stack: <code>r0-r3</code> and <code>ip</code><br />
(<code>r12</code>). Now, <code>r0-r2</code> are taken<br />
by the destination, fill and size, so I can&#8217;t do anything with those.<br />
I also need one to store the left-edge (<code>r3</code> in this case),<br />
leaving us with one for the right edge, the left and right shift<br />
intermediaries, and the left and right masks. Right! Crap <kbd>-_-</kbd>.
</p>
<p></p>
<p>
So; strategies. Well, one of the reasons I need to use so many<br />
registers is because the lifetimes overlap. For example, I still need<br />
<code>left</code> for a while because shifting the mask up comes last<br />
here. I can&#8217;t use <code>r2</code> for multiple purposes either because<br />
I&#8217;ll need it for the size. Now, I could free up <code>r3</code> by<br />
making the left-mask first, but then I might get in trouble when creating<br />
the right-mask. Also, <code>right-4</code> is actually<br />
what <code>size</code> wants to be when it grows up in the long-run<br />
case, so I can use that there as well. I&#8217;d just have to undo that<br />
for the short case, or perhaps even create the right-mask from<br />
negative numbers.
</p>
<p>
At this point I figured it would be helpful to take a look at the<br />
various ways of creating the masks I needed. The standard form for a<br />
0x000000FF-style bitmask is <code>(1&lt;&lt;x)-1</code>, but there are<br />
others as well. The following list holds a few examples.
</p>
<div class="cpp">
<div class="cpp proglist" style=" "><span class="co1">// Bitmask examples. Assume x=8 (in r1)</span></p>
<p>&nbsp;( <span class="nu0">1</span>&lt;&lt;x)-<span class="nu0">1</span>; &nbsp; &nbsp; <span class="co1">// 000000FF.&nbsp; &nbsp; mov r0, #1; rsb r0, r0, r0, lsl r1;</span><br />
~(-<span class="nu0">1</span>&lt;&lt;x); &nbsp; &nbsp; &nbsp; <span class="co1">// 000000FF.&nbsp; &nbsp; mvn r0, #0; mvn r0, r0, lsl r1;</span><br />
&nbsp; -<span class="nu0">1</span>&lt;&lt;x;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// FFFFFF00.&nbsp; &nbsp; mvn r0, #0; mov r0, r0, lsl r1;</span><br />
-( <span class="nu0">1</span>&lt;&lt;x); &nbsp; &nbsp; &nbsp; <span class="co1">// FFFFFF00.&nbsp; &nbsp; mov r0, #1; sub r0, r0, r0 lsl r1; sub r0, #1</span><br />
&nbsp; -<span class="nu0">1</span>&gt;&gt;x;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// 00FFFFFF.&nbsp; &nbsp; mvn r0, #0; mov r0, r0, lsr r1;</span><br />
~(-<span class="nu0">1</span>&gt;&gt;x); &nbsp; &nbsp; &nbsp; <span class="co1">// FF000000.&nbsp; &nbsp; mvn r0, #0; mvn r0, r0, lsl r1;</span></div>
</div>
<p>
All of these use +1 or &minus;1 as their base, and all but one is<br />
a two-instruction affair. The left-mask looks like 0xFFFFFF00, so<br />
the most obvious one to pick here is <code>-1&lt;&lt;x</code>.<br />
Technically, the right-mask is 0x000000FF, using<br />
<code>x&nbsp;=&nbsp;8*right&nbsp;=&nbsp;8*(left+size)</code>.<br />
However, you can also see it as a 0x00FFFFFF-style mask if you<br />
use <code>4-right</code>. This solves two problems at once. First,<br />
it is the negative of the new size, so the value is readily available.<br />
Second, this mask is a right-shifted 0xFFFFFFFF, but as the lower bits<br />
are shifted out anyway, it doesn&#8217;t actually have to be a proper<br />
0xFFFFFFFF; it can be a 0xFFFFFF00 as well, which we have in the form<br />
of the left-mask. In other words, we don&#8217;t require as many registers<br />
for temps because we already have everything we need. The resulting<br />
code is this:
</p>
<div class="gccarm">
<div class="gccarm proglist" style=" ">&nbsp; &nbsp; <span class="re1">add</span> &nbsp; &nbsp; <span class="kw2">r2</span>, <span class="kw2">r3</span>, <span class="kw2">r2</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ (1a) right := left+size.</span><br />
&nbsp; &nbsp; <span class="re1">movs</span>&nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span><br />
&nbsp; &nbsp; <span class="re1">mvn</span> &nbsp; &nbsp; <span class="kw2">ip</span>, #<span class="nu0">0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ ip= -1</span><br />
&nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">ip</span>, <span class="kw1">lsl</span> <span class="kw2">r3</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ lmask := (-1)&lt;&lt;(8*left)</span><br />
&nbsp; &nbsp; <span class="re1">subs</span>&nbsp; &nbsp; <span class="kw2">r2</span>, <span class="kw2">r2</span>, #<span class="nu0">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ (1b) aligned size= right-4</span></p>
<p>&nbsp; &nbsp; <span class="co1">@ new size &lt; 0 : single-word fill</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">rsblo</span> &nbsp; <span class="kw2">r2</span>, <span class="kw2">r2</span>, #<span class="nu0">0</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ &#8211; (2) r3= -8*size</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">movlo</span> &nbsp; <span class="kw2">r2</span>, <span class="kw2">r2</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span>&nbsp; &nbsp; &nbsp; <span class="co1">@ /</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">andlo</span> &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw1">lsr</span> <span class="kw2">r2</span>&nbsp; <span class="co1">@ (3) mask = lmask &amp; rmask</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="co1">@# inserts and jumps</span></div>
</div>
<p>
See? No <code>r4</code> and <code>r5</code> anywhere. The<br />
key is toying around with <code>r2</code> and <code>r3</code>. While<br />
<code>r2</code> is reserved for the size, it needs to modified anyway<br />
to account for the work done here. In the end, size should be<br />
right&minus;4, which is what points (1a) and (1b) do. Since<br />
<code>right-4</code> is a <code>right&lt;4</code> as well, we can use<br />
its result as the condition for the special case; the result<br />
being the negative distance from the word-edge. As explained above,<br />
the right-mask can be constructed from the left-mask by<br />
<code>lmask&gt;&gt;(-8*size)</code>, which is done at points (2) and<br />
(3).
</p>
<p>
It&#8217;s a little hairy, but it works. And yet, it still evoked a feeling<br />
of &ldquo;meh&rdquo; like before. It&#8217;s the two instructions at point (2) that annoyed me. The reason it&#8217;s two instructions and not one is because you<br />
can&#8217;t multiply by &minus;8 in one go. By +8, yes: that&#8217;s a<br />
shifted-<code>mov</code>; &minus;1, yes: that&#8217;s<br />
<code>rsb,&nbsp;r2,&nbsp;#0</code>; but the combination is difficult<br />
because the shift only applies to the second operand. A<br />
<code>sub r2,&nbsp;#0,&nbsp;r2,&nbsp;lsl&nbsp;#3</code> would do it,<br />
but the first operand needs to be a register and I don&#8217;t have a spare<br />
one with zero in it. I could make one, that just means I have an<br />
extra instruction somewhere else. I <i>do</i>, however, have either<br />
a +1 or &minus;1 in <code>ip</code>, maybe I can use that somehow.<br />
And then it hits me: the carry flag!
</p>
<p>
There are <code>adc</code>, <code>sbc</code> and <code>rsb</code><br />
instructions that add <i>C</i>, <i>C</i>&minus;1 and <i>C</i>&minus;1<br />
to the result, respectively. Setting or clearing the carry flag is<br />
easy, so that&#8217;s not a problem. All I need now is to start the<br />
flag using +1 instead of &minus;1 to cancel out the &minus;1 in <code>sbc</code> or <code>rsc</code>. As it turns out, I can do that<br />
I use this format for the left-mask: <code>-(1&lt;&lt;x)</code>. In the<br />
mask overview above I listed thi as a 3-instruction gig, but as it turns<br />
out I can use the carry-trick here to for one instruction less. The final<br />
version (for just the head part) looks like this:
</p>
<div class="gccarm">
<div class="gccarm proglist" style=" ">&nbsp; &nbsp; <span class="re1">ands</span>&nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r0</span>, #<span class="nu0">3</span><br />
&nbsp; &nbsp; beq &nbsp; &nbsp; .Lfgset_main&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Jump to main stint is aligned</span></p>
<p>.Lfgset_head:<br />
&nbsp; &nbsp; <span class="re1">bic</span> &nbsp; &nbsp; <span class="kw2">r0</span>, <span class="kw2">r0</span>, #<span class="nu0">3</span><br />
&nbsp; &nbsp; <span class="re1">add</span> &nbsp; &nbsp; <span class="kw2">r2</span>, <span class="kw2">r3</span>, <span class="kw2">r2</span><br />
&nbsp; &nbsp; <span class="re1">movs</span>&nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ left*8 ; clear carry</span><br />
&nbsp; &nbsp; <span class="re1">mov</span> &nbsp; &nbsp; <span class="kw2">ip</span>, #<span class="nu0">1</span><br />
&nbsp; &nbsp; <span class="re1">sbc</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">ip</span>, <span class="kw2">ip</span>, <span class="kw1">lsl</span> <span class="kw2">r3</span>&nbsp; &nbsp; &nbsp; <span class="co1">@ -(1&lt;&lt;8*left) +1-1</span><br />
&nbsp; &nbsp; <span class="re1">subs</span>&nbsp; &nbsp; <span class="kw2">r2</span>, <span class="kw2">r2</span>, #<span class="nu0">4</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ size= right-4</span></p>
<p>&nbsp; &nbsp; <span class="co1">@ If negative (==carry clear), this is a single-word fill</span><br />
&nbsp; &nbsp; <span class="co1">@ This requires a truncated mask (like 0x0000FF00)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">sbclo</span> &nbsp; <span class="kw2">r2</span>, <span class="kw2">ip</span>, <span class="kw2">r2</span>, <span class="kw1">lsl</span> #<span class="nu0">3</span>&nbsp; &nbsp; &nbsp; <span class="co1">@ x= -8*size +1-1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re1">andlo</span> &nbsp; <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw2">r3</span>, <span class="kw1">lsr</span> <span class="kw2">r2</span>&nbsp; &nbsp; &nbsp; <span class="co1">@ mask= mask &amp; (mask&gt;&gt;-8*size);</span></p>
<p>&nbsp; &nbsp; <span class="co1">@ Insert and jump to main stint if available.</span><br />
.Lfgset_insert:<br />
&nbsp; &nbsp; <span class="re2">ldr</span> &nbsp; &nbsp; <span class="kw2">ip</span>, [<span class="kw2">r0</span>]<br />
&nbsp; &nbsp; <span class="re1">bic</span> &nbsp; &nbsp; <span class="kw2">ip</span>, <span class="kw2">ip</span>, <span class="kw2">r3</span><br />
&nbsp; &nbsp; <span class="re1">and</span> &nbsp; &nbsp; <span class="kw2">r3</span>, <span class="kw2">r1</span>, <span class="kw2">r3</span><br />
&nbsp; &nbsp; <span class="re1">orr</span> &nbsp; &nbsp; <span class="kw2">ip</span>, <span class="kw2">ip</span>, <span class="kw2">r3</span><br />
&nbsp; &nbsp; <span class="re2">str</span> &nbsp; &nbsp; <span class="kw2">ip</span>, [<span class="kw2">r0</span>], #<span class="nu0">4</span></p>
<p>&nbsp; &nbsp; bhi &nbsp; &nbsp; .Lfgset_main&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Longer stretch</span><br />
&nbsp; &nbsp; <span class="re2">bx</span>&nbsp; &nbsp; &nbsp; <span class="kw2">lr</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">@ Single-word fill : finished.</span></div>
</div>
<p>
Sweeeet <kbd>:)</kbd>. I was happy with this, until I realized what I&#8217;d<br />
been working on: an exception of an exception. This would definitely<br />
<i>not</i> be part of the 20% of the code that uses 80% of the runtime,<br />
so it&#8217;s really not something one should worry about. Interesting, yes,<br />
and I learned a few new tricks, but perhaps time would have been better<br />
spent on getting 5% extra out of the main loop. The only problem there<br />
is that that is just boring old unrolling a bit, whereas the head<br />
presented a more &lsquo;interesting&rsquo; problem so I went for that<br />
instead.
</p>
<p>
So yeah; I think too much <kbd>&gt;_&gt;</kbd>
</p>
<div>&lt;/ramble&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/08/define-overthinking/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>And this year^Hdecade&#8217;s award for irony goes to &#8230;</title>
		<link>http://www.coranac.com/2008/04/expelled/</link>
		<comments>http://www.coranac.com/2008/04/expelled/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 15:30:12 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/2008/04/04/and-this-yearhdecades-award-for-irony-goes-to/</guid>
		<description><![CDATA[Expelled : No intelligence allowed! Give them a hearty round of scorn and ridicule, folks. OK, perhaps a bit of backstory is in order here. There&#8217;s this strange thing going on in the USA known as the Creation-evolution controversy. In a nutshell, on one side you have the Theory of Evolution, accepted by all but [...]]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://en.wikipedia.org/wiki/Expelled:_No_Intelligence_Allowed">Expelled : No intelligence allowed</a>! Give them a hearty round of scorn and ridicule, folks.
</p>
<p></p>
<p>
OK, perhaps a bit of backstory is in order here.
</p>
<p>
There&#8217;s this strange thing going on in the USA known as the <a href="http://en.wikipedia.org/wiki/Creation-evolution_controversy">Creation-evolution controversy</a>. In a nutshell, on one side you have the Theory of Evolution, accepted by all but a fraction of the scientists and supported by evidence from multiple fields; and on the other you have groups (usually motivated by their religion or ignorance and frequently both) screaming &ldquo;nuh-uh!&rdquo;, backed up by arguments ranging from utterly insane, to fabrications, misunderstandings, red herrings, and &ldquo;I dunno, Magic Man dun it&rdquo;. No, I&#8217;m not embellishing here: there are <a href="http://www.talkorigins.org/indexcc/">long lists of creationists claims</a> that often make no sense at all, but are still used even after being debunked decades ago. As an example how silly these can be, consider the <a href="http://www.youtube.com/watch?v=nfv-Qn1M58I">Banana argument</a>. And no, this is not a parody; they&#8217;re absolutely serious.
</p>
<p>
After the scientists got so fed up by the constant misrepresentations that they <a href="http://richarddawkins.net/article,119,Why-I-Wont-Debate-Creationists,Richard-Dawkins">won&#8217;t even debate anymore</a> and several defeats in courts, the creationists came up with a new strategy: <a href="http://en.wikipedia.org/wiki/Intelligent_design">Intelligent Design</a> (ID).<br />
They&#8217;ve been quite clever with this, actually. For one, they&#8217;re leaving the Bible out of<br />
it and claiming that life&#8217;s complexity can only come about through an intelligent,<br />
yet unnamed (wink, wink), designer. They also claim that all they want is a fair hearing; that the scientists are being mean with their insistence on evidence and<br />
refusal to accept bogus reasoning.</p>
<p><!--The fact that they only have anti-evo and no<br />
pro-ID points, and that ID has already been judged unscientific in the <a href="http://en.wikipedia.org/wiki/Kitzmiller_v._Dover_Area_School_District">Kitzmiller &#8211; Dover trial</a> doesn&#8217;t seem to matter to them. &#8211;>
</p>
<p></p>
<p>
Enter <i>Expelled</i>. You&#8217;d have to read the wikipedia page for details, but<br />
the idea behind the movie is to highlight this repression by<br />
scientists; that the evolutionists are actively &lsquo;expelling&rsquo; people critical of<br />
evolution. It so happens that they&#8217;ve interviewed a number of evolutionary<br />
biologists (<a href="http://scienceblogs.com/pharyngula/2007/08/im_gonna_be_a_movie_star.php">under false pretenses</a>) for their views on the<br />
subject. This is now widely regarded as a bad move.
</p>
<p>You see, one of them happened to be<br />
PZ Myers, a vocal critic of creationism and other irrationality on his blog pharyngula. You can see how hostile he is in <a href="http://www.youtube.com/watch?v=GgW9vJ4QyFw">this video</a> (I&#8217;d point to the <i>Expelled</i> trailers with the interview, but they pulled it). Ever since the interview, he and other science-bloggers have been keeping an eye on the movie, pointing out flaws in the producers&#8217; arguments whenever<br />
they went public with anything.
</p>
<p>
And now it gets interesting. About two weeks ago, there was a screening of the<br />
movie in Minneapolis. He reserved a place via their website, went to<br />
the theatre &hellip; but was <a href="http://scienceblogs.com/pharyngula/2008/03/expelled.php">barred from entering</a>.<br />
To spell it out: here&#8217;s a movie accusing evolutionists of expelling their critics,<br />
expelling their critics. And then <a href="http://scienceblogs.com/pharyngula/2008/03/an_admission_from_mark_mathis.php"><i>lying</i></a> about it afterwards! Repeatedly! Seriously, you just can&#8217;t make this stuff up.
</p>
<p>
Naturally, this is now all over the blogosphere. The original account has well over 1600 comments. Many other science bloggers have commented on it as well. <a href="http://scienceblogs.com/gregladen/2008/03/pz_myers_expelled_gains_sainth.php">Greg Laden&#8217;s blog</a> has a list of over 100 links, including to stories from the NY Times and Salon. Another interesting detail is that Myers was accompanied by Richard Dawkins (yes, <i>that</i> Richard Dawkins), who did get in. The two had a nice little discussion afterwards, which can be seen <a href="http://richarddawkins.net/article,2389,Discussion-on-PZ-Myers-being-expelled-from-Expelled,Richard-Dawkins-PZ-Myers">here</a>.
</p>
<p></p>
<p>Other interesting links</p>
<ul>
<li><a href="http://richarddawkins.net/article,2394,Lying-for-Jesus,Richard-Dawkins"><br />
Dawkins&#8217; review of the movie</a>. It&#8217;s fairly long, but a good read.</li>
<li><a href="http://blogs.orlandosentinel.com/entertainment_movies_blog/2008/02/is-ben-stein-th.html">Orlando   Earlier review in Orlando Sentinel</a>. Here Roger Moore describes his experience at an earlier viewing, which includes being invited to a screening but didn&#8217;t sign the NDA (for a movie claiming to favor free speech. Nice). The comments there are also illuminating.
  </li>
<li><a href="http://www.expelledexposed.com/">expelledexposed.com</a>. A short list of links to reviews and news articles.</li>
<li><a href="http://scienceblogs.com/strangerfruit/2008/04/expelled_in_tempe_the_expected.php"><br />
Recent efforts to keep critics from current viewers</a>.</li>
<li>And just to keep things light-hearted, there&#8217;s also <a href="http://www.youtube.com/watch?v=eaGgpGLxLQw">this</a>.
</ul>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/04/expelled/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code highlighting. Neat.</title>
		<link>http://www.coranac.com/2007/11/code-highlighting-neat/</link>
		<comments>http://www.coranac.com/2007/11/code-highlighting-neat/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 16:17:46 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[geshi]]></category>
		<category><![CDATA[highlight]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.coranac.com/2007/11/09/code-highlighting-neat/</guid>
		<description><![CDATA[I use quite a bit of code in my documents. Now, you can&#8217;t exactly copy code from an editor to an HTML page &#8230; at least, not if you want formatting to be maintained. Before now, used my standard text editor to convert it to html, and then post-process to remove excess styles and such. [...]]]></description>
			<content:encoded><![CDATA[<p>
I use quite a bit of code in my documents. Now, you can&#8217;t exactly<br />
copy code from an editor to an HTML page &hellip; at least, not if<br />
you want formatting to be maintained. Before now, used my standard<br />
text editor to convert it to html, and then post-process to remove<br />
excess styles and such. This worked, but it&#8217;s still a little cumbersome.
</p>
<p>
After some searching, I found <a href="http://qbnz.com/highlighter/">GeSHi</a>, a php package that<br />
will convert and highlight code for use on the web <i>and</i> it is<br />
very customizable as well. Very nice. Before I had even looked into<br />
how I could use this, I found out that there is a WP plugin that uses<br />
it as well: <a href="http://blog.igeek.info/wp-plugins/igsyntax-hiliter/">IG-syntax hiliter</a>. So now I can do this:
</p>
<div class="cpp">
<div class="cpp proglist" style=" ">Keywords:<br />
<span class="kw1">void</span> <span class="kw1">for</span> <span class="kw1">return</span> <span class="kw1">int</span></p>
<p>Comments:<br />
<span class="coMULTI">/* cmt */</span><br />
<span class="co1">// cmt</span></p>
<p>Strings/characters:<br />
<span class="st0">&quot;hello&quot;</span><br />
<span class="st0">&#8216;x&#8217;</span></p>
<p>Numbers:<br />
<span class="nu0">12345</span>, , +<span class="nu0">12</span>, -<span class="nu0">12</span>, <span class="nu0">01234</span>, <span class="nu0">0x12ab34</span>, <span class="nu0">0X12AB34</span>, <br />
<span class="nu0">1.234</span>, <span class="nu0">1.2e3</span>, <span class="nu0">1.2e-3</span></p>
<p><span class="coMULTI">/* Affine tilemap demo */</span><br />
<span class="kw1">void</span> test_tte_ase()<br />
{<br />
&nbsp; &nbsp; <span class="co1">// Base inits</span><br />
&nbsp; &nbsp; irq_init(<span class="kw2">NULL</span>);<br />
&nbsp; &nbsp; irq_add(II_VBLANK, <span class="kw2">NULL</span>);<br />
&nbsp; &nbsp; REG_DISPCNT= DCNT_MODE1 | DCNT_BG2;</p>
<p>&nbsp; &nbsp; <span class="co1">// Init affine text for 32x32t bg</span><br />
&nbsp; &nbsp; tte_init_ase(<span class="nu0">2</span>, BG_CBB(<span class="nu0">0</span>) | BG_SBB(<span class="nu0">28</span>) | BG_AFF_32x32, <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="nu0">0</span>, CLR_YELLOW, <span class="nu0">0xFE</span>, <span class="kw2">NULL</span>, <span class="kw2">NULL</span>);</p>
<p>&nbsp; &nbsp; <span class="co1">// Write something</span><br />
&nbsp; &nbsp; tte_write(<span class="st0">&quot;\\{P:120,80}o&quot;</span>);<br />
&nbsp; &nbsp; tte_write(<span class="st0">&quot;\\{P:72,104}Round, round, \\{P:80,112}round we go&quot;</span>);</p>
<p>&nbsp; &nbsp; AFF_SRC_EX asx= { <span class="nu0">124</span> &lt;&lt; <span class="nu0">8</span>, <span class="nu0">84</span> &lt;&lt; <span class="nu0">8</span>, <span class="nu0">120</span>, <span class="nu0">80</span>, <span class="nu0">0&#215;100</span>, <span class="nu0">0&#215;100</span>, <span class="nu0">0</span> };<br />
&nbsp; &nbsp; bg_rotscale_ex(&amp;REG_BG_AFFINE[<span class="nu0">2</span>], &amp;asx);</p>
<p>&nbsp; &nbsp; <span class="co1">// Rotate it</span><br />
&nbsp; &nbsp; <span class="kw1">while</span>(<span class="nu0">1</span>)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; VBlankIntrWait();<br />
&nbsp; &nbsp; &nbsp; &nbsp; key_poll();</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; asx.alpha += <span class="nu0">0&#215;111</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bg_rotscale_ex(&amp;REG_BG_AFFINE[<span class="nu0">2</span>], &amp;asx);</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span>(key_hit(KEY_START))<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">break</span>;<br />
&nbsp; &nbsp; }<br />
}</div>
</div>
<p>
That should be C code. And by golly it works <kbd>:)</kbd>. Now I just have to make something for ARM asm.
</p>
<p></p>
<p class=ni>
There are some caveats to the plugin and geshi, though.
</p>
<ul>
<li>
    On the plugin side, it works as an extra filter in the displaying process. However, when writing the code in the post, that&#8217;ll be standard C, complete with brackets and ampersands and such. So it is vitally important to turn off the visual editor and auto-validating of XHTML. It you don&#8217;t, there will be trouble when you save the post.
  </li>
<li>
    By default, the plugin uses line numbers (bleh) and a few other extras that clutter the actual code. So I turned those off in the plugin options. However, this wasn&#8217;t enough for everything. The geshi settings for number parsing and using CSS-classes highlighting are also turned off, and if you want those (and I do), you&#8217;ll have to<br />
make a few changes to the plugin manually. In particular, I needed<br />
to add `<code>$geshi-&gt;enable_classes(true)</code>&#8216; and<br />
`<code>$geshi-&gt;set_number_highlighting(true)</code>&#8216;.
  </li>
<li>
    The regexp for numbers in geshi is incomplete: it doesn&#8217;t do hex<br />
or floats, for example. In <code>parse_non_string_part()</code><br />
use this instead:<br />
    [php]<br />
    $reg= &#8220;#\\b((0[xX][0-9A-Fa-f]+)|([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)|([0-9]))\\b#&#8221;;<br />
    $stuff_to_parse= preg_replace($reg, &#8220;<|/NUM!/>\\1|>&#8221;, $stuff_to_parse);<br />
    [/php]
  </li>
</ul>
<p>
Regexp help courtesy of <a href="http://www.regular-expressions.info/">www.regular-expressions.info</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2007/11/code-highlighting-neat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LOL wordpress</title>
		<link>http://www.coranac.com/2007/10/lol-wordpress/</link>
		<comments>http://www.coranac.com/2007/10/lol-wordpress/#comments</comments>
		<pubDate>Fri, 26 Oct 2007 21:26:54 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.coranac.com/wordpress/2007/10/02/lol-wordpress/</guid>
		<description><![CDATA[Ever since I started my non-university site, I&#8217;ve been meaning to create a nice DB-driven back-end to manage it all, perhaps with some bells and maybe even whistles. However, I never came round to doing so because, well, I&#8217;m not exactly fond of building interfaces and there was other stuff to do as well. It [...]]]></description>
			<content:encoded><![CDATA[<p class=ni>
Ever since I started my non-university site, I&#8217;ve been meaning to create a nice DB-driven<br />
back-end to manage it all, perhaps with some bells and maybe even whistles.<br />
However, I never came round to doing so because, well, I&#8217;m not exactly fond<br />
of building interfaces and there was other stuff to do as well. It also seemed<br />
a bit silly to do all that work myself when there are other packages out there<br />
that do everything for you. So in the end I decided to follow in the herd down<br />
to wordpress.
</p>
<p>
It&#8217;s &hellip; nice. Changing styles is easy and you can build your own page<br />
templates and text filters to customize everything. One of my worries was that<br />
it&#8217;d limit me in my post formatting, but I can do everything in HTML just like<br />
I always did &hellip; once I turned off the visual editor and removed the<br />
<tt>wpautop</tt> and <tt>wptexturize</tt> filters.<br />
Of course, one of the downsides of using someone else&#8217;s system is that you<br />
have to learn how everything works. So at the moment everything&#8217;s still<br />
pretty simplistic. I&#8217;m not entirely sure if the stuff I have can really be presented<br />
the way I want by wordpress, but I seem to get by so far. At least I&#8217;ll be able<br />
to update a little easier now.
</p>
<p></p>
<p>
So, this is what my site looks like now. Yeah I know, bland site is bland, but at<br />
least it works. There&#8217;s posts over here <b>&darr;</b> and a navbar over<br />
there <b>&rarr;</b>.<br />
You may notice that there are two links to &lsquo;projects&rsquo; there<br />
&ndash; that&#8217;s something wordpressy. It makes a division between<br />
&lsquo;Posts&rsquo;, basically journal items with timestamps, and<br />
&lsquo;Pages&rsquo;, which are standalone. Tonc would be an example of<br />
Pages. The <a href="/projects">projects page</a> and<br />
<a href="/documents">documents</a> would be part of that too. Updates on<br />
those items, however, would be announced as posts.
</p>
<p></p>
<p>
Oh, and yes, I have been a little revisionist in the post orders. The past month<br />
or so has been a sort of trial run for all this stuff so there are many posts all<br />
at once right now. We apologize for the inconvenience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2007/10/lol-wordpress/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>wordpress 2.3 HTML entity bug</title>
		<link>http://www.coranac.com/2007/10/entity-post/</link>
		<comments>http://www.coranac.com/2007/10/entity-post/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 18:01:08 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[entity]]></category>
		<category><![CDATA[wordpress bug]]></category>

		<guid isPermaLink="false">http://localhost/index.php/2007/10/08/entity-post/</guid>
		<description><![CDATA[There is/was a rather annoying bug in wordpress 2.3. Normally when editing pages in the advanced editor, the actual text of the post/page has to be preprocessed to convert things like &#38;times; to &#38;amp;times; so that it wouldn&#8217;t show up in the editor as &#215;, and ditto for angle brackets. The extra ampersands and brackets [...]]]></description>
			<content:encoded><![CDATA[<p>
There is/was a rather annoying bug in wordpress 2.3. Normally when editing pages in the advanced editor, the actual text of the post/page has to be preprocessed to convert things like <code>&amp;times;</code> to <code>&amp;amp;times;</code> so that it wouldn&#8217;t show up in the editor as <code>&times;</code>, and ditto for angle brackets. The extra ampersands and brackets would then be removed before saving. However, in the 2.3 upgrade a few things in the core structure of post/page retrieval had been changed and the somehow the the page-retrieval <i>didn&#8217;t</i> do the pre-processing anymore. The upshot was that the amps and brackets got converted to normal ascii and unicode, <strike>seriously</strike>completely messing up your pages.
</p>
<p>
I managed to track the problem to <code>get_post()</code> and <code>get_page()</code> in <tt>wp-includes/post.php</tt>. <code>get_post()</code> did get the upgrade, but <code>get_page()</code> didn&#8217;t. The latter needs to be updated to carry and use a third parameter, and call <code>sanitize_post()</code> like <code>get_post()</code> does.
</p>
<p>
Of course, right after doing this I found out that a fix was already present in the SVN. Just update the file with <a href="http://trac.wordpress.org/browser/branches/2.3/wp-includes/post.php">this one</a>. Ain&#8217;t that always the way.
</p>
<p></p>
<p class=ni>
To see if you are affected as well, make a <b>new</b> page and input the following:
</p>
<blockquote><p>
&amp;times; &amp;gt; entities
</p></blockquote>
<p class=ni>
Then hit `Save and Continue Editing&#8217;. If the text has changed to &ldquo;&times; &gt; entities&rdquo;, you&#8217;re in trouble: <i>every</i> page you edit in that state will have its entities converted. Get the fixed file as soon as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2007/10/entity-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!--
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
</head>
<body>
<p>
My database has called in sick. Please imagine some 
annoying elevator tune till he gets back.
</p>
<p>
<small>[[Doo-di-doo tooo. Dum-di-dum-di-doo-dooo.]]</small>
</p>
</body>
</html>

-->
