<?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>Jacob Repp &#187; c++</title>
	<atom:link href="http://jrepp.com/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://jrepp.com</link>
	<description>Game programming, music and life</description>
	<lastBuildDate>Fri, 16 Dec 2011 06:03:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Google C++ Style Guide</title>
		<link>http://jrepp.com/2009/08/03/google-c-style-guide/</link>
		<comments>http://jrepp.com/2009/08/03/google-c-style-guide/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 17:38:30 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://jrepp.com/2009/08/03/google-c-style-guide/</guid>
		<description><![CDATA[This is a nice comprehensive guide without the rhetoric you usually get in a C++ style guide. I&#8217;m still working through it Google C++ Style Guide]]></description>
			<content:encoded><![CDATA[<p>This is a nice comprehensive guide without the rhetoric you usually get in a C++ style guide. I&#8217;m still working through it</p>

<p><a href="http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml">Google C++ Style Guide</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2009/08/03/google-c-style-guide/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Yes more allocator references</title>
		<link>http://jrepp.com/2007/03/23/yes-more-allocator-references/</link>
		<comments>http://jrepp.com/2007/03/23/yes-more-allocator-references/#comments</comments>
		<pubDate>Fri, 23 Mar 2007 23:16:10 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://jrepp.com/2007/03/23/yes-more-allocator-references/</guid>
		<description><![CDATA[It&#8217;s a huge subject and while I haven&#8217;t been full-time looking at this stuff I have done some more research and dug up some more references. LKmalloc, the basis allocator for the allocator used at MS Internally at MS the &#8230; <a href="http://jrepp.com/2007/03/23/yes-more-allocator-references/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s a huge subject and while I haven&#8217;t been full-time looking at this stuff I have done some more research and dug up some more references.</p>

<p><a href="http://delivery.acm.org/10.1145/290000/286880/p176-larson.pdf?key1=286880&amp;key2=4531864711&amp;coll=&amp;dl=ACM&amp;CFID=15151515&amp;CFTOKEN=6184618">LKmalloc, the basis allocator for the allocator used at MS</a>
Internally at MS the LKmalloc library is referred to as ROCKALL, not part of the std C library distributed with visual studio. I haven&#8217;t used vc8 so that may have changed.</p>

<p><a href="http://www.malloc.de/en/">PTMalloc3</a>
A DLmalloc based allocator that aims at reducing lock contention. Used in glibc.</p>

<p><a href="http://people.freebsd.org/~jasone/jemalloc/bsdcan2006/jemalloc.pdf">JEMalloc</a>
A concurrent allocator used in FreeBSD.</p>

<p>Okay.. now honestly I&#8217;m done posting anything about heap allocators!</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2007/03/23/yes-more-allocator-references/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More local heap references</title>
		<link>http://jrepp.com/2007/03/23/more-local-heap-references/</link>
		<comments>http://jrepp.com/2007/03/23/more-local-heap-references/#comments</comments>
		<pubDate>Fri, 23 Mar 2007 03:46:21 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://jrepp.com/2007/03/23/more-local-heap-references/</guid>
		<description><![CDATA[Collecting yet more references for implementing a custom heap for C++. One of the issues you run into when using a custom heap is the notion of placement new: void *operator new (size_t size, Heap &#38;heap) { return heap.Allocate(size); } &#8230; <a href="http://jrepp.com/2007/03/23/more-local-heap-references/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Collecting yet more references for implementing a custom heap for C++. One of the issues you run into when using a custom heap is the notion of placement new:
<em>void *operator new (size_t size, Heap &amp;heap) { return heap.Allocate(size); }</em></p>

<p>Object allocations now appear so:</p>

<p><em>Heap local;
obj *p = new (local) obj();</em></p>

<p>And when deleting the memory you must ensure that you give it back to the heap:</p>

<p><em>operator delete(p, local);</em></p>

<p>That last part makes the system less friendly. You can however override the operator new and delete for &#8216;obj&#8217; and give it knoledge of a local heap.</p>

<p>More references:
<ul>
    <li><a href="http://www.cantrip.org/wave12.html">Memory management in C++</a></li>
    <li><a href="http://www.relisoft.com/book/tech/9new.html">C++ in action book (overloading operator new)</a></li>
    <li><a href="http://www.mactech.com/articles/develop/issue_02/C++_Objects_v007.html">Using C++ Objects in a Handle-Based </a></li>
</ul>
<a href="http://www.mactech.com/articles/develop/issue_02/C++_Objects_v007.html">
</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2007/03/23/more-local-heap-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a replacement STL allocator</title>
		<link>http://jrepp.com/2007/03/21/writing-a-replacement-stl-allocator/</link>
		<comments>http://jrepp.com/2007/03/21/writing-a-replacement-stl-allocator/#comments</comments>
		<pubDate>Wed, 21 Mar 2007 21:33:53 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://jrepp.com/2007/03/21/writing-a-replacement-stl-allocator/</guid>
		<description><![CDATA[I&#8217;ve recently had the task of replacing the STL allocator and thought I would record some of the more useful resources while doing this: Allocators (STL) @ Codeguru. A good article about writing a pool allocator replacement. This article provides &#8230; <a href="http://jrepp.com/2007/03/21/writing-a-replacement-stl-allocator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently had the task of replacing the STL allocator and thought I would record some of the more useful resources while doing this:</p>

<p><a href="http://www.codeguru.com/Cpp/Cpp/cpp_mfc/stl/article.php/c4079">Allocators (STL) @ Codeguru. A good article about writing a pool allocator replacement.</a></p>

<p>This article provides a good introduction to the subject with a sample replacement allocator. Things get a little more interesting when you have some state that is maintained per allocator.
<a href="http://gcc.gnu.org/onlinedocs/libstdc++/ext/mt_allocator.html">The implementation of the libstdc++ multithreaded allocator</a></p>

<p>This is a very interesting policy based allocator that is the default STL allocator on GNU/linux distributions. I assume it is very fast. I&#8217;m not actually trying to write a faster allocator.</p>

<p><a href="http://incubator.apache.org/stdcxx/">Rogue Wave&#8217;s open source stdc++ implementation</a></p>

<p>I just came across this and it looks interesting. It&#8217;s supposed to be pretty fast and stable.</p>

<p><a href="http://www.stlport.org/">STLport cross platform STL implementation</a></p>

<p>At work we use STLport. If you have to use STL most people will refer you to STLport. Most STL implemenations are pretty solid but some such as the old vc6 dinkumware library are pretty bad.</p>

<p><a href="http://gee.cs.oswego.edu/dl/html/malloc.html">Doug Lea&#8217;s malloc replacement</a></p>

<p>dlmalloc is a great replacement for the system malloc. In many cases it <em>is</em> the system implementation of malloc. The feature that I am using is the &#8216;mspaces&#8217; private heap implementation which in combination with a custom STL allocator allows systems written using STL to use indepedent heaps. Using a private heap you can collect better statistics at runtime and also thread isolate heap access to reduce lock contention.</p>

<p><a href="http://www.amazon.com/C%2B%2B-Programming-Language-Special-3rd/dp/0201700735/ref=pd_bbs_sr_1/103-8254368-5699839?ie=UTF8&amp;s=books&amp;qid=1174486361&amp;sr=8-1">The C++ Programming Language</a>
Of course the best source of all details for the C++ language. This is the only place that I found that the rebind semantics were clearly explained.
When state is maintained on the allocator it&#8217;s important to use some kind of reference maintainence for the allocator. The allocators may be copied, rebound to a different type and assigned to.</p>

<p>Someone may create a container with an allocator on their heap and you may store a reference to the container. If the caller&#8217;s allocator goes out of scope the heap needs to stay valid because you now have a container with a lot of objects allocated on it.</p>

<p>In my system there is a Heap class which acts as a wrapper around the mspace (private heap). The current design has the heaps reference linked together.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2007/03/21/writing-a-replacement-stl-allocator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RubyCube is almost ready for release</title>
		<link>http://jrepp.com/2007/03/09/rubycube-is-almost-ready-for-release/</link>
		<comments>http://jrepp.com/2007/03/09/rubycube-is-almost-ready-for-release/#comments</comments>
		<pubDate>Fri, 09 Mar 2007 17:19:51 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubycube]]></category>

		<guid isPermaLink="false">http://jrepp.com/2007/03/09/rubycube-is-almost-ready-for-release/</guid>
		<description><![CDATA[Since I&#8217;ve not had a lot of time for home-hack projects lately I&#8217;ve been focusing on getting RubyCube ready for release. It&#8217;s a small, well contained project, it&#8217;s easy to make good progress with only 30 minutes of invested time. &#8230; <a href="http://jrepp.com/2007/03/09/rubycube-is-almost-ready-for-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;ve not had a lot of time for home-hack projects lately I&#8217;ve been focusing on getting RubyCube ready for release. It&#8217;s a small, well contained project, it&#8217;s easy to make good progress with only 30 minutes of invested time.</p>

<p>RubyCube is a ruby extension that gives a high level ruby API on top of <a href="http://www.xmission.com/~nate/glut.html">GLUT</a> and <a href="http://www.ode.org/">ODE</a> currently. It abstracts away some stuff that doesn&#8217;t really belong in a graphics scripting environment but you tend to see people include anyways (like the render/update loop). I used it back in March of &#8217;06 to <a href="http://www.flickr.com/photos/lindseyrepp/sets/72057594080277664/">write a game</a> with my friend John in a matter of hours.</p>

<p><img src="http://farm1.static.flickr.com/54/111286994_7acf8a56d9.jpg?v=0" title="GameHack '06 GSpace in Action" alt="GameHack '06 GSpace in Action" align="middle" height="375" width="500" /></p>

<p>When I started I decided that I didn&#8217;t want the render loop to be bound to the performance of the ruby VM since it&#8217;s performance is pretty <a href="http://dada.perl.it/shootout/craps.html">crap</a>. Craps! score doesn&#8217;t really account for object lifetime management overhead which Ruby may have some issues with as well. Regardless of that I really like the language and I think it could make a good prototyping environment for game programming.</p>

<p>Most people when they create a language wrapper for something like OpenGL or  DirectX write a direct 1-to-1 mapping (<a href="http://sourceforge.net/projects/luasdl/">luasdl</a>, <a href="http://www.kmc.gr.jp/~ohai/rubysdl.en.html">rubysdl</a>, <a href="http://rubyforge.org/projects/rubygl/">rubygl</a>, etc). This is probably due to simplicity of implementation and maybe lack of imagination <img src='http://jrepp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . It may have something to do with not really understanding the problem domain very well, which is a huge barrier to successful software design in general.</p>

<p>So the way that I approached the problem is to create a seperate thread in the extension and use queues to communicate between the script interface and the extension. The render and object update loop is handled in C. This has a lot of benefits but is more complex to code. Overall, I have been very pleased with this design.
Currently the interface is very simple, it&#8217;s intended as a prototyping environment. It&#8217;s not the kind of thing you would build a whole game on at this point. I&#8217;m going to try the approach of release early, release often and see how that goes. I was planning on including texture support in the first release but I think I&#8217;m just going to finish the docs and tests and release it as is.</p>

<p>It currently only supports vector based graphics, no lighting and only a few simple types of animations. Oh and it doesn&#8217;t yet compile on my Mac.</p>

<p>One nice benefit of using a background thread is that you watch the render window while you&#8217;re in irb.</p>

<p>irb -r rubycube</p>

<p>irb&gt; RubyCube.startup(&#8220;My test application&#8221;, 800, 600) # create the window and thread
irb&gt; myshape = Shape.circle(100, 200, 50) # create a circle at 100,200 with radius 50
irb&gt; myshape.move_to(300, 300, 2) # move to &lt;300,300&gt; in 2 seconds
irb&gt; myshape.color(1, 0, 0)</p>

<p>You can also create custom shapes that are lists of verts, normals, colors. You can create thousands of shapes and have them animate very easily without burdening the ruby interpreter.</p>

<p>For the first release I&#8217;m shooting for the following:
<ul>
    <li>All core methods documented</li>
    <li>Test cases for all animation types</li>
    <li>Test cases for ODE physics on shapes simulation</li>
    <li>Finish stress test</li>
    <li>Perspective transform mode working</li>
</ul>
In rough order of importance after releasing the basic framework will be:
<ul>
    <li>Mac OSX support</li>
    <li>Texture/Material support</li>
    <li>Sound support</li>
    <li>Shader support</li>
    <li>Implement changes from user feedback (if any)</li>
</ul></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2007/03/09/rubycube-is-almost-ready-for-release/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>XNA RenderTargets Sample</title>
		<link>http://jrepp.com/2006/10/17/xna-rendertargets-sample/</link>
		<comments>http://jrepp.com/2006/10/17/xna-rendertargets-sample/#comments</comments>
		<pubDate>Tue, 17 Oct 2006 05:16:33 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[sample code]]></category>
		<category><![CDATA[xna]]></category>

		<guid isPermaLink="false">http://jrepp.com/2006/10/17/xna-rendertargets-sample/</guid>
		<description><![CDATA[I&#8217;ve been pretty much computer-less at home for the past week but in the bits of time here and there I put together a small sample framework that uses render targets to do a blur effect. Now this is not &#8230; <a href="http://jrepp.com/2006/10/17/xna-rendertargets-sample/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been pretty much computer-less at home for the past week but in the bits of time here and there I put together a small sample framework that uses render targets to do a blur effect. Now this is not a proper motion blur, or even a proper blending kernel, it doesn&#8217;t look all that great. The important thing is that it shows how to setup a few render targets and a screen quad and blend them into the back buffer. That little bit of setup and rending may come in handy for some XNA hackers out there. I would recommend doing a lot more with this than is demonstrated here if you want good results but this will at least get you started.</p>

<p><a href="http://jrepp.com/files/RenderTargetsSample.zip">Download Here</a>
<img src="http://jrepp.com/imgs/sample_rt.JPG" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2006/10/17/xna-rendertargets-sample/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holdem: Bug fixing career mode, UI tweaks</title>
		<link>http://jrepp.com/2006/09/29/4/</link>
		<comments>http://jrepp.com/2006/09/29/4/#comments</comments>
		<pubDate>Fri, 29 Sep 2006 18:09:00 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[holdem]]></category>
		<category><![CDATA[symbian]]></category>

		<guid isPermaLink="false">http://blog.jrepp.com/?p=4</guid>
		<description><![CDATA[I fixed a bunch of bugs in holdem last night. I got career mode working really well, both continue career and new career. I moved a bunch of the player game save logic out into it&#8217;s own class called &#8216;SaveData&#8217;. &#8230; <a href="http://jrepp.com/2006/09/29/4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I fixed a bunch of bugs in holdem last night. I got career mode working really well, both continue career and new career. I moved a bunch of the player game save logic out into it&#8217;s own class called &#8216;SaveData&#8217;. This aggregates the player basic information as well as extended stats. It uses a binary format with a version header tag to ensure consistency. I was smart about deserialization this time to avoid the <a href="http://jacobrepp.blogspot.com/2006/09/holdem-is-finally-running-woot.html">unaligned memory read problem</a> that I ran into with the pack file index.</p>

<p>On the UI side I cleaned up the main menu so continue career only shows up when you have a save game. From the in game options menu when you cash out or save and quit it does a nice transition back to the game and then either fades out to career or play now or shows the currently slightly broken quit confirmation.</p>

<p>I would love to get one more art pass over all the menus and background stuff. I may just experiment with altering the existing menu background to make it more color blend friendly and change to a larger font. I want the UI to feel very tangible and inviting.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2006/09/29/4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holdem: UI Bug Fixes</title>
		<link>http://jrepp.com/2006/09/14/12/</link>
		<comments>http://jrepp.com/2006/09/14/12/#comments</comments>
		<pubDate>Thu, 14 Sep 2006 07:00:00 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[holdem]]></category>

		<guid isPermaLink="false">http://blog.jrepp.com/?p=12</guid>
		<description><![CDATA[Fixed a bunch of nagging UI bugs tonight. I&#8217;m still not totally happy with the fonts and some of the color blending. When you&#8217;re a non-green background and you alpha blend a green menu it&#8217;s a bit jarring. Even green &#8230; <a href="http://jrepp.com/2006/09/14/12/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Fixed a bunch of nagging UI bugs tonight. I&#8217;m still not totally happy with the fonts and some of the color blending. When you&#8217;re a non-green background and you alpha blend a green menu it&#8217;s a bit jarring. Even green on green is not very appealing.</p>

<p>At least on a green background it looks semi-decent. It looked better in 32bit color. I think that dithering to 12bit makes the colors harder to pick out. I &#8216;skinnied&#8217; (if that&#8217;s even a word) up the action menu which sacrificed the &#8216;best hand&#8217; display and the bet ammount. That should make it more consistent with the other phone UI elements. The left action button is bound to the menu.</p>

<p><img src="http://photos1.blogger.com/blogger2/3211/2667/320/holdem_updated_ingame.jpg" /></p>

<p>Career mode got some love. I fixed a bunch of character select bugs. But I think I&#8217;ll the last glyph in the font should be swapped with a RUB button. Probably just a back arrow would be fine. The hiphen glyph is serving this purpose now.</p>

<p><img src="http://photos1.blogger.com/blogger2/3211/2667/320/holdem_name_edit.jpg" /></p>

<p>I also fixed the career continue mode a bit. All menu animations have been cleaned up and are sliding in and out nice and smooth.</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2006/09/14/12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holdem: Nokia 6682 Photo</title>
		<link>http://jrepp.com/2006/09/11/15/</link>
		<comments>http://jrepp.com/2006/09/11/15/#comments</comments>
		<pubDate>Mon, 11 Sep 2006 02:11:00 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[holdem]]></category>
		<category><![CDATA[symbian]]></category>

		<guid isPermaLink="false">http://blog.jrepp.com/?p=15</guid>
		<description><![CDATA[This picture is of a pretty low quality. I&#8217;ll just blame the camera.. the display on the phone is nice and makes the game look pretty sharp. I think I need to scale the fonts up a bit though as &#8230; <a href="http://jrepp.com/2006/09/11/15/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This picture is of a pretty low quality. I&#8217;ll just blame the camera.. the display on the phone is nice and makes the game look pretty sharp. I think I need to scale the fonts up a bit though as they seem a little on the small side.</p>

<p>Massimo says:
<blockquote>so what are you up to now?  working on getting the animation running?  Cuz I know what you&#8217;re not doing <img src='http://jrepp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  you&#8217;re not posting pictures of Hold&#8217;em running on your phone  <img src='http://jrepp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </blockquote>
Well somebody has to keep me honest.</p>

<p><img src="http://photos1.blogger.com/blogger2/3211/2667/320/holdem_nokia_6682.jpg" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2006/09/11/15/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Holdem is Finally Running, Woot!</title>
		<link>http://jrepp.com/2006/09/10/16/</link>
		<comments>http://jrepp.com/2006/09/10/16/#comments</comments>
		<pubDate>Sun, 10 Sep 2006 10:05:00 +0000</pubDate>
		<dc:creator>proj</dc:creator>
				<category><![CDATA[c++]]></category>
		<category><![CDATA[game programming]]></category>
		<category><![CDATA[holdem]]></category>
		<category><![CDATA[symbian]]></category>

		<guid isPermaLink="false">http://blog.jrepp.com/?p=16</guid>
		<description><![CDATA[And it looks amazing! For the record Dragonfly by Lemon D was the song that was playing when the app actually started up and ran and the time is 3am. I have been pursuing this goal of having this game &#8230; <a href="http://jrepp.com/2006/09/10/16/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>And it looks amazing! For the record Dragonfly by Lemon D was the song that was playing when the app actually started up and ran and the time is 3am. I have been pursuing this goal of having this game engine run on a symbian smart phone for some time now. I finally tracked down the finaly serious problem pretty much by accident.</p>

<p>The line that was crashing first was:</p>

<p>if(path.compare(rec-&gt;name, rec-&gt;namelen))</p>

<p>This looks totally innocent.. I&#8217;ll just say right away that it wasn&#8217;t any of the usual suspects. Keep in mind that this ran fine on other hardware architectures. The problem was actually memory alignment.</p>

<p>The records that are being referenced here are part of a block of index records stored in the resource file. I have a tool that transforms and packs files into a single file and creates one block of memory to be used as a searchable index. The structure in memory used to look like this:</p>

<p>struct RecordRef
{
uint32 offset;
uint16 nextrec;
uint16 namelen;
// char name[namelen + 1]
};</p>

<p>If I tried to access offset or nextrec and the field didn&#8217;t lay on a 4 or 2 byte boundary respectively my application would crash. This kind of problems are pretty hard to track down without a debugger. I used loglines traced to a text file on the phones internal memory through multiple builds to track this down.</p>

<p>The new structure looks like this:</p>

<p>struct RecordRef
{
uint32 offset;
uint16 nextrec;
uint16 namelen;
uint16 padding;
uint16 reserved;
// char name[namelen + 1]
};</p>

<p>I calculate the padding when the records are built in memory and before they are stored into the resource file. When they load from the file they are all nicely aligned and the code that searches the index just has to take into account padding when doing any pointer/index math.</p>

<p>Seeing the title screen on my phone makes me very happy!</p>
]]></content:encoded>
			<wfw:commentRss>http://jrepp.com/2006/09/10/16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

