<?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; projects</title>
	<atom:link href="http://www.coranac.com/category/proj/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coranac.com</link>
	<description>my own little world</description>
	<lastBuildDate>Tue, 06 Jul 2010 21:30:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>setds 1.01 and an annoying yet oddly fitting bug</title>
		<link>http://www.coranac.com/2010/04/setds-1-01/</link>
		<comments>http://www.coranac.com/2010/04/setds-1-01/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 19:09:21 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[nds]]></category>
		<category><![CDATA[setds]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=189</guid>
		<description><![CDATA[
It seems that a bug in the hiscore entry code that I thought I&#8217;d fixed over a month ago got resurrected in setds v1.0. So I fixed it &#8211; refixed it &#8211; today and we&#8217;re now at setds v1.01.

&#160;

Sigh. Gaddammit &#62;_&#60;
]]></description>
			<content:encoded><![CDATA[<p>
It seems that a bug in the hiscore entry code that I <i>thought</i> I&#8217;d fixed over a month ago got resurrected in setds v1.0. So I fixed it &ndash; <i>re</i>fixed it &ndash; today and we&#8217;re now at <a href="[$HOME/projects/setds">setds v1.01</a>.
</p>
<p><div>&nbsp;</div></p>
<p>
<small>Sigh. Gaddammit <kbd>&gt;_&lt;</kbd></small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/04/setds-1-01/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>setds 1.0</title>
		<link>http://www.coranac.com/2010/04/setds-1-0/</link>
		<comments>http://www.coranac.com/2010/04/setds-1-0/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 08:57:34 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[nds]]></category>
		<category><![CDATA[setds]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=185</guid>
		<description><![CDATA[
I&#8217;ve finally taken the time to add proper saving that works on hardware
(at least on my R4, which is the only card I have right now). I&#8217;ve also fixed a
very annoying game-hanging bug and did some tweaking here and there, like
correcting the decay constant so that I can finally get the scores that I was [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve finally taken the time to add proper saving that works on hardware<br />
(at least on my R4, which is the only card I have right now). I&#8217;ve also fixed a<br />
very annoying game-hanging bug and did some tweaking here and there, like<br />
correcting the decay constant so that I can finally get the scores that I was used to on tatset (2300+, wooo!).
</p>
<p>
This is pretty much where I wanted to go with this game, so it&#8217;s now version 1.0. I may add some other things later, but for now I guess it&#8217;s done.
</p>
<h4>Changes</h4>
<ul>
<li>new: FAT saving enabled <kbd>:D</kbd>. It&#8217;s intended for<br />
    <a href="http://www.devkitpro.org/hbmenu">argv-capable</a><br />
    cards, though. You can still save without one of those, but you&#8217;ll have to<br />
    put in a little work.
  </li>
<li>
    new: Reset/Back buttons for high-score screen.
  </li>
<li>
    fix: Bug in shuffle code. Fixes the occasional hang at start of a new game.
  </li>
<li>
    tweak: I&#8217;ve altered the decay constant slightly; it should be closer to<br />
    the original tatset now. The upshot is that scores will be a little higher.
  </li>
<li>
    tweak: Slightly bigger buttons.
  </li>
</ul>
<h4>Links</h4>
<ul>
<li><a href="http://www.coranac.com/projects/setds">setds project page</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2010/04/setds-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I maek game :D</title>
		<link>http://www.coranac.com/2009/12/setds/</link>
		<comments>http://www.coranac.com/2009/12/setds/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 19:12:00 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[nds]]></category>
		<category><![CDATA[setds]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[game]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=139</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 />

Okay, so it&#8217;s only a card game; but a game nonetheless.

&#160;

The game in question is an NDS implementation of

SET. Set is a card-matching game
with 81 cards (see below). The figures on the cards have four
properties and 3 possibilities for each property. The key is to find
three cards for which the values of each property are [...]]]></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>
Okay, so it&#8217;s <i>only</i> a card game; but a game nonetheless.
</p>
<p><div>&nbsp;</div></p>
<p>
The game in question is an NDS implementation of<br />

<a href="http://en.wikipedia.org/wiki/Set_%28game%29">SET</a>. <i>Set</i> is a card-matching game<br />
with 81 cards (see below). The figures on the cards have four<br />
properties and 3 possibilities for each property. The key is to find<br />
three cards for which the values of each property are either all<br />
<b>equal</b> or all <b>different</b>. Looking at the color property,<br />
for example, a &#8220;Red Red Red&#8221; combination could (yes &#8220;could&#8221;; there<br />
are still three other properties to consider) form a set.<br />
&#8220;Red Green Blue&#8221; would also work, but &#8220;Red Green Green&#8221; would not.
</p>
<p>
Further details can be found in the readme and the game itself.
</p>
<div class="cblock">
<div class="cpt" style="width:px;">
  <a href="" target="_blank">  <img src="" 
    alt="" width="" /></a><br />
  
</div>

</div>
<p><div>&nbsp;</div></p>
<p>
The game is <i>mostly</i> finished. There may be some tweaking to do<br />
here and there, but right now I don&#8217;t want to get bogged down in a<br />
massive fine-tuning-fest &ndash; especially since I&#8217;m not sure what<br />
parts need fine-tuning &hellip; and because there&#8217;s<br />
<a href="http://www.coranac.com/projects/grit">other stuff</a> I really should get<br />
back to.
</p>
<p>
That said, all important aspects work &hellip; with <b>one</b><br />
exception: hiscore saving. Yes, <i>that</i>. I&#8217;ve seen the<br />
multitude of threads on the subject but sofar I&#8217;m unsure of what would<br />
work on both hardware and emulator, so I&#8217;m leaving it as is for now.<br />
If anyone has a tidy hw+emu solution, please do tell.
</p>
<h4>Links</h4>
<ul>
<li>binary: <a href="http://www.coranac.com/files/setds-bin.zip">setds-bin.zip</a> (146k)</li>
<li>source: <a href="http://www.coranac.com/files/setds-src.zip">setds-src.zip</a> (354k)</li>
<li>readme: <a href="http://www.coranac.com/files/setds-readme.txt">setds-readme.txt</a></li>
</ul>
<p><div>&nbsp;</div></p>
<p>
Oh, and merry Christmas everybody.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2009/12/setds/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>mode 7 addendum</title>
		<link>http://www.coranac.com/2009/04/mode-7-addendum/</link>
		<comments>http://www.coranac.com/2009/04/mode-7-addendum/#comments</comments>
		<pubDate>Sun, 19 Apr 2009 16:32:53 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[tonc]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mode7]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=67</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 />

Okay. Apparently, I am an idiot who can&#8217;t do math.

&#160;

One of the longer chapters in Tonc is
Mode 7 part 2, which covers
pretty much all the hairy details of producing mode 7 effects on the
GBA. The money shot for in terms of code is the following functions,
which calculates the affine parameters of the background for each
scanline [...]]]></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>
Okay. Apparently, I am an idiot who can&#8217;t do math.
</p>
<p><div>&nbsp;</div></p>
<p>
One of the longer chapters in Tonc is<br />
<a href="/tonc/text/mode7ex.htm">Mode 7 part 2</a>, which covers<br />
pretty much all the hairy details of producing mode 7 effects on the<br />
GBA. The money shot for in terms of code is the following functions,<br />
which calculates the affine parameters of the background for each<br />
scanline in section <a href="/tonc/text/mode7ex.htm#ssec-code-bg">21.7.3</a>.
</p>
<div class="cpp">
<div class="cpp proglist" style=" ">IWRAM_CODE <span class="kw1">void</span> m7_prep_affines(M7_LEVEL *level)<br />
{<br />
&nbsp; &nbsp; <span class="kw1">if</span>(level-&gt;horizon &gt;= SCREEN_HEIGHT)<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span>;</p>
<p>&nbsp; &nbsp; <span class="kw1">int</span> ii, ii0= (level-&gt;horizon&gt;=<span class="nu0">0</span> ? level-&gt;horizon : <span class="nu0">0</span>);</p>
<p>&nbsp; &nbsp; M7_CAM *cam= level-&gt;camera;<br />
&nbsp; &nbsp; FIXED xc= cam-&gt;pos.x, yc= cam-&gt;pos.y, zc=cam-&gt;pos.z;</p>
<p>&nbsp; &nbsp; BG_AFFINE *bga= &amp;level-&gt;bgaff[ii0];</p>
<p>&nbsp; &nbsp; FIXED yb, zb; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// b&#8217; = Rx(theta) * &nbsp;(L, ys, -D)</span><br />
&nbsp; &nbsp; FIXED cf, sf, ct, st; &nbsp; <span class="co1">// sines and cosines</span><br />
&nbsp; &nbsp; FIXED lam, lcf, lsf; &nbsp; &nbsp;<span class="co1">// scale and scaled (co)sine(phi)</span><br />
&nbsp; &nbsp; cf= cam-&gt;u.x; &nbsp; &nbsp; &nbsp;sf= cam-&gt;u.z;<br />
&nbsp; &nbsp; ct= cam-&gt;v.y; &nbsp; &nbsp; &nbsp;st= cam-&gt;w.y;<br />
&nbsp; &nbsp; <span class="kw1">for</span>(ii= ii0; ii&lt;SCREEN_HEIGHT; ii++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; yb= (ii-M7_TOP)*ct + M7_D*st;<br />
&nbsp; &nbsp; &nbsp; &nbsp; lam= DivSafe( yc&lt;&lt;<span class="nu0">12</span>, &nbsp;yb); &nbsp; &nbsp; <span class="co1">// .12f &nbsp; &nbsp;&lt;- OI!!!</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; lcf= lam*cf&gt;&gt;<span class="nu0">8</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// .12f</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; lsf= lam*sf&gt;&gt;<span class="nu0">8</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// .12f</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; bga-&gt;pa= lcf&gt;&gt;<span class="nu0">4</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// .8f</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bga-&gt;pc= lsf&gt;&gt;<span class="nu0">4</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// .8f</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// lambda·Rx·b</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; zb= (ii-M7_TOP)*st &#8211; M7_D*ct; &nbsp; <span class="co1">// .8f</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bga-&gt;dx= xc + (lcf&gt;&gt;<span class="nu0">4</span>)*M7_LEFT &#8211; (lsf*zb&gt;&gt;<span class="nu0">12</span>); &nbsp;<span class="co1">// .8f</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bga-&gt;dy= zc + (lsf&gt;&gt;<span class="nu0">4</span>)*M7_LEFT + (lcf*zb&gt;&gt;<span class="nu0">12</span>); &nbsp;<span class="co1">// .8f</span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// hack that I need for fog. pb and pd are unused anyway</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; bga-&gt;pb= lam;<br />
&nbsp; &nbsp; &nbsp; &nbsp; bga++;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; level-&gt;bgaff[SCREEN_HEIGHT]= level-&gt;bgaff[<span class="nu0">0</span>];<br />
}</div>
</div>
<p>
For details on what all the terms mean, go the page in question.<br />
For now, just note that call to <code>DivSafe()</code> to calculate<br />
the scaling factor &lambda; and recall that division on the GBA is<br />
pretty slow. In <a href="/tonc/text/mode7.htm">Mode 7 part 1</a>,<br />
I used a LUT, but here I figured that since the <code>yb</code> term<br />
can be anything thanks to the pitch you can&#8217;t do that. After helping<br />
Ruben with his mode 7 demo, it turns out that you can.
</p>
<p><div>&nbsp;</div></p>
<p><div class="cpt" style="width:px;">
  <a href="" target="_blank">  <img src="" id="img-crd-c2p2"
    alt="" width="" /></a><br />
  <b>Fig&nbsp;1. </b>
</div>
</p>
<p>
Fig&nbsp;1 shows the situation. There is a camera<br />
(the black triangle) that is tilted down by pitch angle &theta;. I&#8217;ve<br />
put the origin at the back of the camera because it makes things<br />
easier to read. The<br />
front of the camera is the projection plane, which is essentially<br />
the screen. A ray is cast from the back of the camera on to the floor<br />
and this ray intersects the projection plane. The coordinates<br />
of this point are <b>x</b><sub>p</sub> =<br />
(<i>y</i><sub>p</sub>, <i>D</i>) in projection plane space, which<br />
corresponds to point (<i>y</i><sub>b</sub>, <i>z</i><sub>b</sub>) in<br />
world space. This is simply rotating point <b>x</b><sub>p</sub> by<br />
&theta;. The scaling factor is the ratio between the <i>y</i> or<br />
<i>z</i> coordinates of the points on the floor and on the projection<br />
plane, so that&#8217;s:
</p>
<p><table class="eqtbl">
<tr>
<td class="eqnrcell"></td>
  <td class="eqcell"><br />
<img src='http://www.coranac.com/cgi-bin/mimetex.cgi?%5Clambda%20%3D%20y_c%20%2F%20y_b%2C'<br />
	title="\lambda = y_c / y_b,"<br />
	alt="\lambda = y_c / y_b," /><br />
</td>
</tr>
</table></p>
<p>
and for <i>y</i><sub>b</sub> the rotation gives us:
</p>
<p><table class="eqtbl">
<tr>
<td class="eqnrcell"></td>
  <td class="eqcell"><br />
<img src='http://www.coranac.com/cgi-bin/mimetex.cgi?y_b%20%3D%20y_p%20cos%20%5Ctheta%20%2B%20D%20sin%20%5Ctheta%2C'<br />
	title="y_b = y_p cos \theta + D sin \theta,"<br />
	alt="y_b = y_p cos \theta + D sin \theta," /><br />
</td>
</tr>
</table></p>
<p>
where <i>y</i><sub>c</sub> is the camera height,<br />
<i>y</i><sub>p</sub> is a scanline offset (measured from the center of the screen) and <i>D</i> is the focus<br />
length.
</p>
<p>
Now, the point is that while <i>y</i><sub>b</sub> is variable<br />
and non-integral when &theta; &ne; 0, it is still bounded! What&#8217;s more,<br />
you can easily calculate its maximum value, since it&#8217;s simply the<br />
maximum length of <b>x</b><sub>p</sub>. Calling this factor <i>R</i>,<br />
we get:
</p>
<p><table class="eqtbl">
<tr>
<td class="eqnrcell"></td>
  <td class="eqcell"><br />
<img src='http://www.coranac.com/cgi-bin/mimetex.cgi?R%20%3D%20%5Csqrt%7Bmax%28y_p%29%5E2%20%2B%20D%5E2%7D'<br />
	title="R = \sqrt{max(y_p)^2 + D^2}"<br />
	alt="R = \sqrt{max(y_p)^2 + D^2}" /><br />
</td>
</tr>
</table></p>
<p>
This factor <i>R</i>, rounded up, is the size of the required LUT.<br />
In my particular case, I&#8217;ve used <i>y</i><sub>p</sub>= scanline&minus;80<br />
and <i>D</i> = 256, which gives<br />
<i>R</i>&nbsp;=&nbsp;sqrt((160&minus;80)&sup2;&nbsp;+&nbsp;256&sup2;)<br />
= 268.2. In other words, I need a division LUT with 269 entries. Using .16<br />
fixed point numbers for this LUT, the replacement code is essentially:
</p>
<div class="cpp">
<div class="cpp proglist" style=" "><span class="co1">// The new division LUT. For 1/0 and 1/1, 0xFFFF is used.</span><br />
u16 m7_div_lut[<span class="nu0">270</span>]= <br />
{<br />
&nbsp; &nbsp; <span class="nu0">0xFFFF</span>, <span class="nu0">0xFFFF</span>, <span class="nu0">0&#215;8000</span>, <span class="nu0">0&#215;5556</span>, &#8230;<br />
};</p>
<p>
<span class="co1">// Inside the function</span><br />
&nbsp; &nbsp; <span class="kw1">for</span>(ii= ii0; ii&lt;SCREEN_HEIGHT; ii++)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; yb= (ii-M7_TOP)*ct + M7_D*st; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// .8</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; lam= (yc*m7_div_lut[yb&gt;&gt;<span class="nu0">8</span>])&gt;&gt;<span class="nu0">12</span>;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// .8*.16/.12 = .12</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &#8230; <span class="co1">// business as usual</span><br />
&nbsp; &nbsp; }</div>
</div>
<p>
At this point, several questions may arise.
</p>
<ul>
<li>
    <b>What about negative <i>y</i><sub>b</sub>?</b> The beauty here<br />
    is that while <i>y</i><sub>b</sub> may be negative in principle,<br />
    such values would correspond to lines above the horizon and we don&#8217;t<br />
    calculate those anyway.
  </li>
<li>
    <b>Won&#8217;t non-integral <i>y</i><sub>b</sub> cause inaccurate look-ups?</b><br />
    True, <i>y</i><sub>b</sub> will have a fractional part that<br />
    is simply cut off during a simple look-up and some sort of<br />
    interpolation would be better. However, in testing there were no<br />
    noticeable differences between direct look-up, lerped look-up or<br />
    using <code>Div()</code>, so the simplest method suffices.
  </li>
<li>
    <b>Are .16 fixed point numbers enough?</b>. Yes, apparently so.
  </li>
<li>
    <b>ZOMG OVERFLOW! Are .16 fixed point numbers too high?</b><br />
    Technically, yes, there is a risk of overflow when the camera height<br />
    gets too high. However, at high altitudes the map is going to look<br />
    like crap anyway due to the low resolution of the screen.<br />
    Furthermore, the hardware only uses 8.8 fixeds, so scales above<br />
    256.0 wouldn&#8217;t work anyway.
  </li>
</ul>
<p>
And finally:
</p>
<ul>
<li>
  <b>What do I win?</b><br />
  With <code>Div()</code> <code>m7_prep_affines()</code> takes<br />
  about 51k cycles. With the direct look-up this reduces to about 13k:<br />
  a speed increase by a factor of 4.
  </li>
</ul>
<p><div>&nbsp;</div></p>
<p>
So yeah, this is what I <i>should</i> have figured out years ago, but<br />
somehow kept overlooking it. I&#8217;m not sure if I&#8217;ll add this whole thing to<br />
Tonc&#8217;s text and code, but I&#8217;ll at least put up a link to here. Thanks<br />
Ruben, for showing me how to do this properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2009/04/mode-7-addendum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aaaand, 0.8.3</title>
		<link>http://www.coranac.com/2008/12/aaaand-083/</link>
		<comments>http://www.coranac.com/2008/12/aaaand-083/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 17:49:18 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[grit]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=62</guid>
		<description><![CDATA[
Well that was fast.


Dovoto discovered some quirks in the way names were used under shared data runs and had a nice suggestion to allow images to be added via grit files as well. There was also some other small niggly bits that needed straightening out. So yeah, grit v0.8.3.


link to grit

]]></description>
			<content:encoded><![CDATA[<p>
Well that was fast.
</p>
<p>
Dovoto discovered some quirks in the way names were used under shared data runs and had a nice suggestion to allow images to be added via grit files as well. There was also some other small niggly bits that needed straightening out. So yeah, grit v0.8.3.
</p>
<ul>
<li><a href=/projects/#grit>link to grit</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/12/aaaand-083/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>grit 0.8.2 / usenti 1.7.10</title>
		<link>http://www.coranac.com/2008/11/grit-082-usenti-1710/</link>
		<comments>http://www.coranac.com/2008/11/grit-082-usenti-1710/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 17:58:21 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[grit]]></category>
		<category><![CDATA[usenti]]></category>
		<category><![CDATA[grf]]></category>
		<category><![CDATA[metatiles]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=61</guid>
		<description><![CDATA[
Apparently, the GRF format didn&#8217;t quite follow the official RIFF specs, so I had to fix it (thanks for pointing it out, Daniel). While I was at it, I also changed the names of the meta-tile arrays if a meta-map was asked for. In stead of the -Map affix, it now uses the more logical [...]]]></description>
			<content:encoded><![CDATA[<p>
Apparently, the GRF format didn&#8217;t quite follow the official RIFF specs, so I had to fix it (thanks for pointing it out, Daniel). While I was at it, I also changed the names of the meta-tile arrays if a meta-map was asked for. In stead of the <code>-Map</code> affix, it now uses the more logical <code>-MetaTiles</code>. Yes, this probably will break something, but in the long run it&#8217;s better this way and it&#8217;s a compiler error, so it&#8217;s easy to fix.
</p>
<p>
Usenti&#8217;s been updated to match.
</p>
<p><div>&nbsp;</div></p>
<ul>
<li><a href=/projects/#grit>link to grit</a></li>
<li><a href=/projects/#usenti>link to usenti</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/11/grit-082-usenti-1710/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>tonc 1.4 official release</title>
		<link>http://www.coranac.com/2008/08/tonc-14-official-release/</link>
		<comments>http://www.coranac.com/2008/08/tonc-14-official-release/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 13:05:24 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[tonc]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[gba]]></category>
		<category><![CDATA[tonc 1.4]]></category>
		<category><![CDATA[update]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=54</guid>
		<description><![CDATA[
The files have need downloadable for a while now as a preview, but I finally put the text up on the main site as well so I guess that makes it official. Tonc is now at version 1.4. As mentioned before, the main new thing is TTE, a system for text for all occasions. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>
The files have need downloadable for a while now as a preview, but I finally put the text up on the <a href="http://www.coranac.com/tonc">main site</a> as well so I guess that makes it official. Tonc is now at version 1.4. As mentioned before, the main new thing is <a href="http://www.coranac.com/tonc/text/tte.htm">TTE</a>, a system for text for all occasions. I&#8217;ve also used grit in some of the advanced demos, so if you want to see how you can do advanced work with it, check out the mode 7 demos and the tte demo.
</p>
<p>
This will be the last version of Tonc. It&#8217;s really gone on long enough now.
</p>
<p></p>
<p>Files and linkies :</p>
<ul>
<li>Main site : <a href="http://www.coranac.com/tonc">www.coranac.com/tonc</a>
  </li>
<li>
    Tonclib manual : <a href="http://www.coranac.com/man/tonclib/">www.coranac.com/man/tonclib/</a>
  </li>
</ul>
<ul>
<li>Example binaries : <a href="/files/tonc-bin.zip">tonc-bin.zip</a> (521k)
  </li>
<li>Example code + tonclib : <a href="/files/tonc-code.zip">tonc-code.zip</a> (1.1M)
  </li>
<li>Text + images : <a href="/files/tonc-text.zip">tonc-text.zip</a> (1.4M)
  </li>
<li>Text in CHM : <a href="/files/tonc.chm">tonc.chm</a> (1.7M)
  </li>
<li>Text in PDF : <a href="/files/tonc.pdf">tonc.pdf</a> (6.9M. No, I don&#8217;t know where the extra 3 MB came from either.)
  </li>
</ul>
<p></p>
<p>
Right! Now what &hellip;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/08/tonc-14-official-release/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>tonc 1.4 preview</title>
		<link>http://www.coranac.com/2008/05/tonc-14-preview/</link>
		<comments>http://www.coranac.com/2008/05/tonc-14-preview/#comments</comments>
		<pubDate>Mon, 26 May 2008 20:54:59 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[tonc]]></category>
		<category><![CDATA[tte]]></category>

		<guid isPermaLink="false">http://www.coranac.com/?p=49</guid>
		<description><![CDATA[
I&#8217;m close to releasing the latest (and probably last; this really has gone on long enough) version of Tonc. As a preview, I&#8217;m releasing the PDF a little early in the hope that someone may take a look and offer some feedback before the official release (aw, c&#8217;mon, it&#8217;s only 400 pages).


The changes mostly relate [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;m close to releasing the latest (and probably last; this really has gone on long enough) version of Tonc. As a preview, I&#8217;m releasing the PDF a little early in the hope that someone may take a look and offer some feedback before the official release (aw, c&#8217;mon, it&#8217;s only 400 pages).
</p>
<p>
The changes mostly relate to the new<br />
<a href="http://www.coranac.com/man/tonclib/">Tonc Text Engine</a>, a text system for all occasions. There&#8217;s a new chapter describing how TTE works, how to write general character printers for (almost) for arbitrary sized fonts and every type of graphics, and a few other things. It&#8217;s fairly long and could use sanity checking from someone else.
</p>
<p>
Also, many of the older demos now use TTE for their text as well. As a result they look cleaner and prettier, but it&#8217;s possible there are some left-overs from older versions. So have at it.
</p>
<ul>
<li><a href="http://www.coranac.com/files/tonc/tonc-1.4.pdf">Tonc 1.4 preview (PDF, 4.3 MB)</a>.</li>
<li><a href="http://www.coranac.com/files/misc/tte.pdf">TTE chapter only (PDF, 584 kB)</a>.</li>
<li>All relevant 1.4 files: <a href="http://www.coranac.com/files/tonc/">here</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/05/tonc-14-preview/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Surface drawing routines.</title>
		<link>http://www.coranac.com/2008/05/surface-drawing-routines/</link>
		<comments>http://www.coranac.com/2008/05/surface-drawing-routines/#comments</comments>
		<pubDate>Wed, 14 May 2008 16:19:28 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[tonc]]></category>
		<category><![CDATA[gba]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[surface]]></category>

		<guid isPermaLink="false">http://www.coranac.com/2008/05/14/48/</guid>
		<description><![CDATA[
I&#8217;ve been building a basic interface for dealing with graphic surfaces lately. I
already had most of the routines for 16bpp and 8bpp bitmaps in older Toncs, but
but their use was still somewhat awkward because you had to provide some
details of the destination manually; most notably a base pointer and the pitch.
This got more than a [...]]]></description>
			<content:encoded><![CDATA[<p>
I&#8217;ve been building a basic interface for dealing with graphic surfaces lately. I<br />
already had most of the routines for 16bpp and 8bpp bitmaps in older Toncs, but<br />
but their use was still somewhat awkward because you had to provide some<br />
details of the destination manually; most notably a base pointer and the pitch.<br />
This got more than a little annoying, especially when trying to make blitters as<br />
well. So I made some changes.
</p>
<p></p>
<div class="cpp">
<div class="cpp proglist" style=" "><span class="kw1">typedef</span> <span class="kw1">struct</span> TSurface<br />
{<br />
&nbsp; &nbsp; u8&nbsp; *data;&nbsp; &nbsp; &nbsp; <span class="co1">//!&lt; Surface data pointer.</span><br />
&nbsp; &nbsp; u32 pitch;&nbsp; &nbsp; &nbsp; <span class="co1">//!&lt; Scanline pitch in bytes (PONDER: alignment?).</span><br />
&nbsp; &nbsp; u16 width;&nbsp; &nbsp; &nbsp; <span class="co1">//!&lt; Image width in pixels. </span><br />
&nbsp; &nbsp; u16 height; &nbsp; &nbsp; <span class="co1">//!&lt; Image width in pixels.</span><br />
&nbsp; &nbsp; u8&nbsp; bpp;&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">//!&lt; Bits per pixel.</span><br />
&nbsp; &nbsp; u8&nbsp; type; &nbsp; &nbsp; &nbsp; <span class="co1">//!&lt; Surface type (not used that much).</span><br />
&nbsp; &nbsp; u16 palSize;&nbsp; &nbsp; <span class="co1">//!&lt; Number of colors.</span><br />
&nbsp; &nbsp; u16 *palData; &nbsp; <span class="co1">//!&lt; Pointer to palette.</span><br />
} TSurface;</div>
</div>
<p>
I&#8217;ve rebuilt the routines around a surface description struct called<br />
<code>TSurface</code> (see above). This way, I can just initialize the<br />
surface somewhere and just pass the pointer to that surface around.<br />
There are a number of different kinds of surfaces. The most important<br />
ones are these three:
</p>
<ul>
<li><b>bmp16</b>. 16bpp bitmap surfaces.</li>
<li><b>bmp8</b>. 8bpp bitmap surfaces.</li>
<li><b>chr4c</b>. 4bpp tiled surfaces, in column-major order (i.e., tile 1 is<br />
<i>under</i> tile 0 instead of to the right). Column-major order may seem<br />
strange, but it actually simplifies the code considerably. There is also a<br />
<code>chr4<b>r</b></code> mode for normal, row-major tiling, but that&#8217;s unfinished<br />
and will probably remain so.
</ul>
<div class="cptfr" style="width:240px;">
  <img src="http://www.coranac.com/img/post/surface.gif"<br />
    alt="surface.gba movie" /><br />
  Demonstrating surface routines for 4bpp tiles.
</div>
<p>
For each of these three, I have the most important rendering functions:<br />
plotting pixels, lines, rectangles and <b>blits</b>. Yes, blits too. Even for<br />
<code>chr4c</code>-mode. There are routines for frames (empty<br />
rectangles) and floodfill as well. The functions have a uniform interface<br />
with respect to surface-type, so switching between them should be<br />
easy were it necessary. There are also tables with function pointers<br />
to these routines, so by using those you need not really care about<br />
the details of the surface after its creation. I&#8217;ll probably add a<br />
pointer to such a table in <code>TSurface</code> in the future.
</p>
<p></p>
<p>Linkies</p>
<ul>
<li>Demo project: <a href="http://www.coranac.com/files/misc/surface.zip">surface.zip</a>.</li>
<li>Tonclib: <a href="http://www.coranac.com/files/misc/tonclib-20080514.zip">tonclib</a>. </li>
<li><a href="http://www.coranac.com/man/tonclib/group__grpSurface.htm">Tonclib manual, TSurface module</a>.</li>
</ul>
<p>
<p>The image on the right is the result of the following routine.<br />
Turret pic semi-knowingly provided by<br />
<a href="http://helmetedrodent.kickassgamers.com/Pika/blog/">Kawa</a>.
</p>
<div class="cpp">
<div class="cpp proglist" style=" "><span class="kw1">void</span> test_surface_procs(<span class="kw1">const</span> TSurface *src, TSurface *dst, <br />
&nbsp; &nbsp; <span class="kw1">const</span> TSurfaceProcTab *procs, u16 colors[])<br />
{<br />
&nbsp; &nbsp; <span class="co1">// Init object text</span><br />
&nbsp; &nbsp; tte_init_obj(&amp;oam_mem[<span class="nu0">127</span>], ATTR0_TALL, ATTR1_SIZE_8, <span class="nu0">512</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; CLR_YELLOW, <span class="nu0">0</span>, &amp;vwf_default, <span class="kw2">NULL</span>);<br />
&nbsp; &nbsp; tte_init_con();<br />
&nbsp; &nbsp; tte_set_margins(<span class="nu0">8</span>, <span class="nu0">140</span>, <span class="nu0">160</span>, <span class="nu0">152</span>);</p>
<p>&nbsp; &nbsp; <span class="co1">// And go!</span><br />
&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{es;P}%s surface primitives#{w:60}&quot;</span>, procs-&gt;name);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{es;P}Rect#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;rect(dst, <span class="nu0">20</span>, <span class="nu0">20</span>, <span class="nu0">100</span>, <span class="nu0">100</span>, colors[<span class="nu0">0</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Frame#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;frame(dst, <span class="nu0">21</span>, <span class="nu0">21</span>, <span class="nu0">99</span>, <span class="nu0">99</span>, colors[<span class="nu0">1</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Hlines#{w:20}&quot;</span>);</p>
<p>&nbsp; &nbsp; procs-&gt;hline(dst, <span class="nu0">23</span>, <span class="nu0">23</span>, <span class="nu0">96</span>, colors[<span class="nu0">2</span>]);<br />
&nbsp; &nbsp; procs-&gt;hline(dst, <span class="nu0">23</span>, <span class="nu0">96</span>, <span class="nu0">96</span>, colors[<span class="nu0">2</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Vlines#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;vline(dst, <span class="nu0">23</span>, <span class="nu0">25</span>, <span class="nu0">94</span>, colors[<span class="nu0">3</span>]);<br />
&nbsp; &nbsp; procs-&gt;vline(dst, <span class="nu0">96</span>, <span class="nu0">25</span>, <span class="nu0">94</span>, colors[<span class="nu0">3</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Lines#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;line(dst, <span class="nu0">25</span>, <span class="nu0">25</span>, <span class="nu0">94</span>, <span class="nu0">40</span>, colors[<span class="nu0">4</span>]);<br />
&nbsp; &nbsp; procs-&gt;line(dst, <span class="nu0">94</span>, <span class="nu0">25</span>, <span class="nu0">79</span>, <span class="nu0">94</span>, colors[<span class="nu0">4</span>]);<br />
&nbsp; &nbsp; procs-&gt;line(dst, <span class="nu0">94</span>, <span class="nu0">94</span>, <span class="nu0">25</span>, <span class="nu0">79</span>, colors[<span class="nu0">4</span>]);<br />
&nbsp; &nbsp; procs-&gt;line(dst, <span class="nu0">25</span>, <span class="nu0">94</span>, <span class="nu0">40</span>, <span class="nu0">25</span>, colors[<span class="nu0">4</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Full blit#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;blit(dst, <span class="nu0">120</span>, <span class="nu0">16</span>, src-&gt;width, src-&gt;height, src, <span class="nu0">0</span>, <span class="nu0">0</span>);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Partial blit#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;blit(dst, <span class="nu0">40</span>, <span class="nu0">40</span>, <span class="nu0">40</span>, <span class="nu0">40</span>, src, <span class="nu0">12</span>, <span class="nu0">8</span>);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Floodfill#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;flood(dst, <span class="nu0">40</span>, <span class="nu0">32</span>, colors[<span class="nu0">5</span>]);<br />
&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P}Again !#{w:20}&quot;</span>);<br />
&nbsp; &nbsp; procs-&gt;flood(dst, <span class="nu0">40</span>, <span class="nu0">32</span>, colors[<span class="nu0">6</span>]);</p>
<p>&nbsp; &nbsp; tte_printf(<span class="st0">&quot;#{w:30;es;P;w:30}Ta-dah!!!#{w:20}&quot;</span>);</p>
<p>&nbsp; &nbsp; key_wait_till_hit(KEY_ANY);<br />
}</p>
<p><span class="co1">// Test 4bpp tiled, column-major surfaces</span><br />
<span class="kw1">void</span> test_chr4c_procs()<br />
{<br />
&nbsp; &nbsp; TSurface turret, dst;</p>
<p>&nbsp; &nbsp; <span class="co1">// Init turret for blitting.</span><br />
&nbsp; &nbsp; srf_init(&amp;turret, SRF_CHR4C, turretChr4cTiles, <span class="nu0">128</span>, <span class="nu0">128</span>, <span class="nu0">4</span>, <span class="kw2">NULL</span>);</p>
<p>&nbsp; &nbsp; <span class="co1">// Init destination surface</span><br />
&nbsp; &nbsp; srf_init(&amp;dst, SRF_CHR4C, tile_mem[<span class="nu0">0</span>], <span class="nu0">240</span>, <span class="nu0">160</span>, <span class="nu0">4</span>, pal_bg_mem);<br />
&nbsp; &nbsp; schr4c_prep_map(&amp;dst, se_mem[<span class="nu0">31</span>], <span class="nu0">0</span>);<br />
&nbsp; &nbsp; GRIT_CPY(pal_bg_mem, turretChr4cPal);</p>
<p>&nbsp; &nbsp; <span class="co1">// Set video stuff</span><br />
&nbsp; &nbsp; REG_DISPCNT= DCNT_MODE0 | DCNT_BG2 | DCNT_OBJ | DCNT_OBJ_1D;<br />
&nbsp; &nbsp; REG_BG2CNT= BG_CBB(<span class="nu0">0</span>)|BG_SBB(<span class="nu0">31</span>);</p>
<p>&nbsp; &nbsp; u16 colors[<span class="nu0">8</span>]= { <span class="nu0">6</span>, <span class="nu0">13</span>, <span class="nu0">1</span>, <span class="nu0">14</span>, <span class="nu0">15</span>, <span class="nu0">0</span>, <span class="nu0">14</span>, <span class="nu0">0</span> };</p>
<p>&nbsp; &nbsp; <span class="co1">// Run internal tester</span><br />
&nbsp; &nbsp; test_surface_procs(&amp;turret, &amp;dst, &amp;chr4c_tab, colors);<br />
}</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/05/surface-drawing-routines/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grit 0.8.1</title>
		<link>http://www.coranac.com/2008/05/grit-081/</link>
		<comments>http://www.coranac.com/2008/05/grit-081/#comments</comments>
		<pubDate>Mon, 12 May 2008 14:37:22 +0000</pubDate>
		<dc:creator>cearn</dc:creator>
				<category><![CDATA[grit]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.coranac.com/2008/05/12/grit-081/</guid>
		<description><![CDATA[
Grit 0.8.1 is out now. I&#8217;ve made three somewhat small changes here. First,
there was some trouble with shared palettes/tiles if there was no -O or
-S option. &#8220;Trouble&#8221;, as in segmentation fault. This should
now be fixed.


I&#8217;ve also reformatted the include guards from __FOO__
to GRIT_FOO_H. GCC uses that format for internal
#defines and it is very territorial about [...]]]></description>
			<content:encoded><![CDATA[<p>
Grit 0.8.1 is out now. I&#8217;ve made three somewhat small changes here. First,<br />
there was some trouble with shared palettes/tiles if there was no -O or<br />
-S option. &ldquo;Trouble&rdquo;, as in segmentation fault. This should<br />
now be fixed.
</p>
<p>
I&#8217;ve also reformatted the include guards from <code>__FOO__</code><br />
to <code>GRIT_FOO_H</code>. GCC uses that format for internal<br />
#defines and it is very territorial about such matters. So, say, when you<br />
have <tt>elf.png</tt>, GCC gets cranky because that would hide its<br />
own <code>__ELF__</code>, and guess who wins out there? Again,<br />
thanks for pointing these things out, Quirky.
</p>
<p>
The last item is the addition of column-major tiling. This can be<br />
useful for horizontal scrolling games, since the data or the columns are<br />
all adjacent instead of a whole scanline apart. A second benefit of<br />
this mode is that rendering to tiles is made considerably easier (and a<br />
little bit faster too).
</p>
<p>
In case you hadn&#8217;t noticed yet, I&#8217;ve also put the <a href="http://www.coranac.com/man/grit/html/index.htm">manual on-line</a>.<br />
This shows the basic options for grit and wingrit, and now there&#8217;s a<br />
description of how to use it in makefiles as well. This includes how the<br />
building the grit-demo project works. This one&#8217;s quite interesting, so<br />
please check it out.
</p>
<p></p>
<p><a href="http://www.coranac.com/projects/#grit">Project link</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coranac.com/2008/05/grit-081/feed/</wfw:commentRss>
		<slash:comments>5</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>

-->