<?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/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Abe's Codeblog</title>
	<atom:link href="http://abepralle.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://abepralle.wordpress.com</link>
	<description>Notes and essays on programming and gamedev</description>
	<lastBuildDate>Sun, 26 Jul 2009 18:47:26 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='abepralle.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/1b1c04793e6ad4597d91f0e0bb9c2457?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Abe's Codeblog</title>
		<link>http://abepralle.wordpress.com</link>
	</image>
			<item>
		<title>Automatic Properties, In-Line Classes, Delegate Properties, and caseNext</title>
		<link>http://abepralle.wordpress.com/2009/07/26/automatic-properties-in-line-classes-delegate-properties-and-casenext/</link>
		<comments>http://abepralle.wordpress.com/2009/07/26/automatic-properties-in-line-classes-delegate-properties-and-casenext/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 18:43:18 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=163</guid>
		<description><![CDATA[For the last couple of weeks I&#8217;ve been trying to come up with a good semi-automatic resource-loading framework for Plasmacore.  For each revision I added a new feature or two to Slag; I ended up not truly needing most of them but they&#8217;re good features nonetheless.  Here&#8217;s a quick overview of the new features &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=163&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>For the last couple of weeks I&#8217;ve been trying to come up with a good semi-automatic resource-loading framework for Plasmacore.  For each revision I added a new feature or two to Slag; I ended up not truly needing most of them but they&#8217;re good features nonetheless.  Here&#8217;s a quick overview of the new features &#8211; mostly by example.</p>
<p><span id="more-163"></span></p>
<h3>Automatic Properties</h3>
<p>First we have <em>automatic properties </em>that can be used when you have a single <em>init</em> method that stores each of its arguments into a property you&#8217;ve just defined.  Here&#8217;s an example of old code:</p>
<pre>  class Person
    PROPERTIES
      name : String
      age : Int32

    METHODS
      method init( name, age ):
  endClass</pre>
<p>Here&#8217;s the same code with automatic properties:</p>
<pre>  class Person( String name, Int32 age )
  endClass</pre>
<p>or even just:</p>
<pre>  class Person( String name, Int32 age );</pre>
<p>You can add additional properties and methods as you like.</p>
<h3>In-Line Classes</h3>
<p>Slag now supports in-line classes that work pretty much just like Java&#8217;s anonymous classes.  In addition, &#8220;METHODS&#8221; is now the default member category (so you can omit it if you start a class definition with a method), which makes in-line method definitions easier.  An example:</p>
<pre>  class Operator
    method init:
    method apply( Real64 lhs, Real64 rhs ).Real64: abstract
  endClass
  ...
  method test( Real64 left, Operator op, Real64 right ):
    println( op.apply(left,right) )
  ...
  local Operator plus = Operator() with
        method apply( Real64 lhs, Real64 rhs ).Real64: return lhs + rhs
      endWith

  local Operator minus = Operator() with
        method apply( Real64 lhs, Real64 rhs ).Real64: return lhs - rhs
      endWith

  test( 5, plus, 3 )  # prints: 8
  test( 5, minus, 3 ) # prints: 2
  test( 5, Operator() with
        method apply( Real64 lhs, Real64 rhs ).Real64: return lhs * rhs
      endWith, 3 )  # prints: 15</pre>
<h3>Delegate Properties</h3>
<p>Delegate properties allow you to specify that any unresolved method calls or property accesses be forwarded to one property in particular.  This is of particular use when you want to make one object that is essentially a proxy for another.  Example:</p>
<pre>  class String
    PROPERTIES
      data : delegate Array&lt;&lt;Char&gt;&gt;
      hash_code : Int32
    ...
  endClass
  ...
  local String mesg = "Delegate *this*!"
  println( mesg.count )  # same as saying "mesg.data.count" - prints: 16</pre>
<p>Only one property can be defined as a delegate.  Underneath the mechanism is very simple: at compile time failed member accesses are reevaluated with the delegate property.</p>
<h3>caseNext</h3>
<p><em>caseNext </em>is handy in a <em>which</em> where you want to do something different every time based on a counter but you don&#8217;t really care what the case values are.  It just takes the previous case value (literal integer required), adds one to it, and makes that the new case.  For example, to load a different graphic (my plan is revealed!) each time a method is called:</p>
<pre>  method load_next.Logical:
    load_index++
    which (load_index)
      caseNext: img_alpha = Image("alpha.png")
      caseNext: img_beta = Image("beta.png")
      caseNext: img_gamma = Image("gamma.png")
      caseNext: return false
    endWhich
    return true</pre>
<p>If you started with &#8220;case 5:&#8221; then the first <em>caseNext</em> would be a shorthand for &#8220;case 6:&#8221;.  If you start with <em>caseNext</em> (as above) then it resolves to &#8220;case 1:&#8221;.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/163/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/163/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/163/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=163&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/07/26/automatic-properties-in-line-classes-delegate-properties-and-casenext/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>Dynamic texture sheets, iPhone and Android dev, UTF-8 source files</title>
		<link>http://abepralle.wordpress.com/2009/07/12/dynamic-texture-sheets-iphone-and-android-dev-utf-8-source-files/</link>
		<comments>http://abepralle.wordpress.com/2009/07/12/dynamic-texture-sheets-iphone-and-android-dev-utf-8-source-files/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 09:54:05 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=160</guid>
		<description><![CDATA[Some odds and ends:
ITEM: We finished up Wyrmhunter for the iPhone a week ago and submitted it to Apple.  They haven&#8217;t gotten around to approving it yet, but we&#8217;re hopeful it&#8217;ll be soon.
ITEM: One of the last major things was a revamp of my dynamic texture sheet management system.  With its already limited drawing speed, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=160&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Some odds and ends:</p>
<p>ITEM: We finished up <em>Wyrmhunter </em>for the iPhone a week ago and submitted it to Apple.  They haven&#8217;t gotten around to approving it yet, but we&#8217;re hopeful it&#8217;ll be soon.</p>
<p>ITEM: One of the last major things was a revamp of my dynamic texture sheet management system.  With its already limited drawing speed, the best bet for the iPhone is to place all images on one big texture (or several), queue up a bunch of triangles as different images are drawn, and then render everything at once.  Even better is if you don&#8217;t have to lay things out yourself but can have Plasmacore do it for you as you dynamically load and unload images.</p>
<p><span id="more-160"></span>My initial stab at the problem worked well in some cases and very poorly in others.  I started out with one big region of unused texture.  Then after the first allocation I split it into several chunks &#8211; one used, the others not.  I decided to make everything below the used area one chunk and then the remaining strip to the right another chunk.  If the original free chunk were:</p>
<p>CC<br />
CC</p>
<p>Then after allocation &#8220;A&#8221; it would be:</p>
<p>AB<br />
CC</p>
<p>The problem was that I could end up with a whole lot of &#8220;B&#8221; chunks of various sizes that didn&#8217;t quite fit together.  There would sometimes be plenty of room to put something but no chunk large enough to put it in.  It was fragmentation but worse: it wasn&#8217;t that there were used areas, it was that the free areas were adjacent but slightly disjoint.</p>
<p>I beat my head against the problem for about a week and tried 6 or 7 different approaches.  I felt that the key was being able to span multiple free regions, but if I used regions as they became available then they were too disjoint, and if I used some sort of grid layout then the search area was too big.</p>
<p>Then <em>finally</em> I finally hit on the solution: when I allocated a region I would split the entire layout area (including all regions used and unused) along both axes to make the allocated region the exact right size while keeping all cells lined up at all 4 edges.  Imagine an Excel spreadsheet where you&#8217;ve randomly adjusted the widths of some columns, the heights of some rows, and filled in random cells &#8211; that&#8217;s what my texture sheet would look like after some heavy cycles of allocation and freeing.  Incidentally two adjacent empty rows become merged again, as do two adjacent empty columns.</p>
<p>The allocation algorithm is this: scan all regions row by row.  If a region is unused and unmarked, see if it&#8217;s the corner of a space that will fit the image (ensure available width at region is &lt;= necessary width, then ensure available height at each region is &lt;= necessary height).  If the space is big enough, <em>mark</em> the all of the rows as in use that are wide enough <em>all the way down</em>, mark all of the columns that are high enough <em>all the way to the right</em>, add the space to a list of possibilities, and continue searching.</p>
<p>The neat thing is that by marking the possible matches as you go you really cut down on the number of candidate spots you have to check for &#8211; and each candidate region you find is a corner already.</p>
<p>For example, say we had allocation A already and free regions B, C, and D:</p>
<p>ABB<br />
CDD</p>
<p>When we try to fit in a new allocation we&#8217;ll find spots B (corner of BB/DD) and C (corner of CDD) &#8211; and that&#8217;s it!  The other possible spots will already be marked as used as we find the top-left B and then C.  Between the two, we&#8217;ll pick the one that has the best {exact match, matching width, matching height, smallest area} crossed with the one that has {no gaps above, has gaps above}.</p>
<p>I hope you can see what I&#8217;m getting at here&#8230; I tried drawing some nicer graphics and so on but it was getting way too complicated for what it was worth.  Anyhow, the code is in and it&#8217;s working beautifully.</p>
<p>ITEM: I&#8217;ve now turned my attention to porting Plasmacore to Android &#8211; it&#8217;s pretty virgin territory and, like Google itself, I think Android could be a sleeping giant (albeit a slightly unwieldy, slightly dorky giant).  Over half of us at <em>Plasmaworks</em> now have G1 phones.  I still like my iPhone but I&#8217;ll admit there&#8217;s a lot of nice stuff about Android.</p>
<p>I got stuck for a while on an esoteric gcc pointer bug that cropped up in my Slag VM code.  It only happens when you have a certain optimization level turned on, which Android does by default.  Say I have a pointer to integer &#8220;ip&#8221; &#8211; I could retrieve an integer at that address and increment the pointer to the next value with:</p>
<p>int x = *(ip++);</p>
<p>This is equivalent to:</p>
<p>int** ip_ptr = &amp;ip;<br />
int x = *((*ip_ptr)++);</p>
<p>which is equivalent to:</p>
<p>int x = *((*(&amp;ip))++);</p>
<p>What I really wanted to do was access a double instead of an int at that position and then advance &#8220;ip&#8221; to point past the double.  I had:</p>
<p>double n = *((*((double**)&amp;ip))++);</p>
<p>I made it a macro and was using it in a place or two, but it was Bug City on Androids gcc configuration.  I went back to doing it a simpler way across a couple of steps.</p>
<p>ITEM: Finally let me tell you about an interesting discovery.  Some stray unicode characters were exposing a UTF-8 encoding/decoding bug in my compiler + VM.  What I didn&#8217;t realize is that Vim (and apparently other editors&#8230;?) load and save text files in UTF-8 already &#8211; I had assumed Vim would only operate on raw bytes.   UTF-8, by the by, is a scheme to translate text that would normally be 2 bytes per character into 1 byte per character for most symbols and then 2 or 3 bytes for the less common symbols.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=160&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/07/12/dynamic-texture-sheets-iphone-and-android-dev-utf-8-source-files/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone drawing speed &#8211; Part 2</title>
		<link>http://abepralle.wordpress.com/2009/05/13/iphone-drawing-speed-part-2/</link>
		<comments>http://abepralle.wordpress.com/2009/05/13/iphone-drawing-speed-part-2/#comments</comments>
		<pubDate>Wed, 13 May 2009 19:15:34 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=157</guid>
		<description><![CDATA[I just finished implementing an automatic texture sheet system for iPhone Plasmacore.  By default it automatically places image textures onto a single 1024&#215;1024 texture sheet, creating additional sheets if you run out of room.  In addition I&#8217;ve transparently buffered all drawing calls, so drawing 50 images will just store up 100 triangles and then render [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=157&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just finished implementing an automatic texture sheet system for iPhone Plasmacore.  By default it automatically places image textures onto a single 1024&#215;1024 texture sheet, creating additional sheets if you run out of room.  In addition I&#8217;ve transparently buffered all drawing calls, so drawing 50 images will just store up 100 triangles and then render them all at once later.</p>
<p>There&#8217;s significant speed-up over my previous implementation, but you&#8217;ll still have to be careful.  The results:</p>
<ul>
<li>I altered the system to redraw at 30 fps instead of 60.  Even a blank screen can&#8217;t quite hold steady at 60 fps, so I&#8217;d rather aim for a steady 30 fps on iPhone.  No changes required to your Plasmacore programs.</li>
<li>iPhone Plasmacore can draw about 9280/x square images in 1/30 second, where x is the size of a single dimension of the image (16 px or higher; smaller images are roughly the same).  [Edit: make that "9280 / sqrt(x)" where x is the number of pixels per image].  So around 580 16&#215;16 pixel images, 290 32&#215;32 images, or 145 64&#215;64 images.</li>
<li>Sound effects will probably slow it down a bit more; I need to do some further testing with that.</li>
</ul>
<p>Looking good for modestly complex games!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/157/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/157/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/157/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=157&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/05/13/iphone-drawing-speed-part-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone drawing speed</title>
		<link>http://abepralle.wordpress.com/2009/05/06/iphone-drawing-speed/</link>
		<comments>http://abepralle.wordpress.com/2009/05/06/iphone-drawing-speed/#comments</comments>
		<pubDate>Thu, 07 May 2009 04:35:32 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=153</guid>
		<description><![CDATA[I&#8217;ve been doing some initial drawing tests on the iPhone with so-so results.
Turns out it uses a graphics chip that renders different tile sections of the screen in parallel.  I couldn&#8217;t find any info on how big the tiles are offhand.
Here are my very informal results. [Clarification: I'm drawing tile/sprite images as a series of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=153&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been doing some initial drawing tests on the iPhone with so-so results.</p>
<p>Turns out it uses a graphics chip that renders different tile sections of the screen in parallel.  I couldn&#8217;t find any info on how big the tiles are offhand.</p>
<p>Here are my very informal results. [Clarification: I'm drawing tile/sprite images as a series of individual calls, each with its own 2D transform]</p>
<p>In 1/60th of a second, the iPhone can draw about:<br />
24 textured polygons in the same spot, quarter-screen size or less.<br />
OR 75 spaced-out polys (32&#215;32 in this case)<br />
OR 6 full-screen polys.</p>
<p>Notes:<br />
- This is with a tight drawing-only loop.  Logic &amp; sound adds a bit of overhead &#8211; not an excessive amount but then again every bit hurts.<br />
- Things that <em>didn&#8217;t</em> significantly improve the speed: turning off texturing, turning off back-buffer clear, turning off alpha blending, using texture formats with fewer bytes per pixel.</p>
<p>In light of this I&#8217;m gonna tweak Plasmacore for iPhone so that it&#8217;s CYOB (Clear Your Own Backbuffer).  Not to save time clearing the backbuffer, but to allow you to get tricky (if you want) and only redraw altered portions of the screen.  The good news is that Plasmacore (as usual) will still update() at 60fps no matter how slow the draw() is going, so things might get a little <em>rougher</em> but they won&#8217;t get <em>slower</em>.</p>
<p>A final tip will be to avoid drawing font-based text &#8211; use prerendered words!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=153&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/05/06/iphone-drawing-speed/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>Slag wrapper methods</title>
		<link>http://abepralle.wordpress.com/2009/05/03/slag-wrapper-methods/</link>
		<comments>http://abepralle.wordpress.com/2009/05/03/slag-wrapper-methods/#comments</comments>
		<pubDate>Sun, 03 May 2009 09:01:25 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=151</guid>
		<description><![CDATA[I&#8217;ve been encountering some programming situations lately that cried out for some aspect-oriented features that weren&#8217;t in Slag &#8211; until tonight!
A bit of background: aspect-oriented programming (AOP), in a nutshell, is being able to write your program as independent layers of functionality that are merged together to create the final result.  For example, mixing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=151&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve been encountering some programming situations lately that cried out for some aspect-oriented features that weren&#8217;t in Slag &#8211; until tonight!</p>
<p><span id="more-151"></span>A bit of background: aspect-oriented programming (AOP), in a nutshell, is being able to write your program as independent layers of functionality that are merged together to create the final result.  For example, mixing drawing code in with your game logic is frowned upon, since if you need to entirely re-do either of those aspects &#8211; or port your software to a different system &#8211; then you&#8217;ve got to wade through everything looking for the bits and pieces you need to change.</p>
<p>This Slag code can be tough to maintain:</p>
<pre>  class Spaceship
    METHODS
      method init: set_position; load_graphics
      method update: ...
      method draw: ...
  endClass

  class Laser
    METHODS
      method init: set_position; load_graphics
      method update: ...
      method draw: ...
  endClass</pre>
<p>while this AO Slag code behaves the same and is easier to work with in the long run:</p>
<pre>  class Spaceship
    METHODS
      method init: set_position
      method update: ...
  endClass

  class Laser
    METHODS
      method init: set_position
      method update: ...
  endClass
  ...
  overlaying augment Spaceship
    METHODS
      method init: underlying; load_graphics
      method draw: ...
  endAugment

  overlaying augment Laser
    METHODS
      method init: underlying; load_graphics
      method draw: ...
  endAugment</pre>
<p>* * *</p>
<p>In retrospect I realize that Slag&#8217;s AO features were focused on creating static class definitions and what it <em>needs</em> are some AO features to assist dynamic calls between objects.</p>
<p>Prime example: Plasmacore v2 operates on a system of view windows, each with its own 2D transformation matrix (usually there&#8217;s just one window, btw).  For a view to be drawn it needs to push its transformation matrix onto the transform stack, draw itself, and then pop off its transformation matrix.</p>
<p>To allow the draw() method to be easily overridden I can&#8217;t put the transform adjustments in that method itself, so what I end up with is:</p>
<pre>  view.push_transform
  view.draw
  view.pop_transform</pre>
<p>It&#8217;d be really nice to allow an application programmer to just call &#8220;view.draw&#8221; and have the transforms automatically pushed and popped.  There&#8217;s various kludgy ways to do it &#8211; especially renaming the actual draw to something else &#8211; but I came up with a more elegant way that was fairly quick to implement.</p>
<p>Slag v2 now has <em>wrapper methods</em>.  If you call a method &#8220;fn&#8221; and there&#8217;s a method &#8220;fn-wrapper&#8221; defined, fn-wrapper() is the method that ACTUALLY gets called, and it should call the original fn() at some point.  The View class would now look like this:</p>
<pre>  class View
    METHODS
      method draw: ...

      method draw-wrapper:
        push_transform
        draw
        pop_transform</pre>
<p>From the outside you&#8217;d just call &#8220;view.draw&#8221; and it would actually call &#8220;view.draw-wrapper&#8221;.</p>
<p>The reason why you couldn&#8217;t do this with an ordinary aspect is that the calls to push/pop transform would become embedded in the actual draw code, which would make overriding draw() a hassle.</p>
<p>All of that is <em>almost</em> true.  There&#8217;s an additional twist &#8211; Murphy noticed a flaw in this new system and suggested a very elegant solution!</p>
<p>The problem is, say that class Beta extends Alpha and Beta defines draw-wrapper but Alpha doesn&#8217;t.  In accordance with the standard rules of polymorphism, if you were to write:</p>
<pre>  local Alpha a = Beta()
  a.draw</pre>
<p>then it would call Beta::draw() without calling Beta::draw-wrapper() since the call context is class Alpha and the compiler can&#8217;t know for sure that the object will have the wrapper method.</p>
<p>The solution is to take any class with both &#8220;fn&#8221; and &#8220;fn-wrapper&#8221; defined and, in the compiler, change the names to be &#8220;fn-inner&#8221; and &#8220;fn&#8221;, respectively.  The name is unchanged in base classes without wrapper methods, and the wrapper methods take on the original name in extended classes so that they&#8217;re called polymorphically.</p>
<p>I added wrapper methods into the compiler tonight &#8211; only took me about an hour after getting the idea ironed out!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/151/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/151/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/151/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=151&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/05/03/slag-wrapper-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>Smart Pointers in C++</title>
		<link>http://abepralle.wordpress.com/2009/04/12/smart-pointers-in-c/</link>
		<comments>http://abepralle.wordpress.com/2009/04/12/smart-pointers-in-c/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 00:08:09 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=144</guid>
		<description><![CDATA[I just programmed this up for a friend who&#8217;s wrestling with good ol&#8217; dynamic allocation issues in C++.  It&#8217;s a &#8220;smart pointer&#8221; class that takes all the hard work out of managing dynamic memory.  You can find this kind of stuff elsewhere on the net too, but here&#8217;s my take:
smartpointer.h



#ifndef SMARTPOINTER_H
#define SMARTPOINTER_H
//====================================================================
//  smartpointer.h
//
//  [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=144&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I just programmed this up for a friend who&#8217;s wrestling with good ol&#8217; dynamic allocation issues in C++.  It&#8217;s a &#8220;smart pointer&#8221; class that takes all the hard work out of managing dynamic memory.  You can find this kind of stuff elsewhere on the net too, but here&#8217;s my take:</p>
<p><span id="more-144"></span><strong>smartpointer.h</strong></p>
<hr />
<strong><br />
</strong></p>
<pre>#ifndef SMARTPOINTER_H
#define SMARTPOINTER_H
//====================================================================
//  smartpointer.h
//
//  2009.04.12 by Abe.Pralle (at) gmail.com
//  This code is released to the public domain.
//====================================================================

#include &lt;iostream&gt;
using namespace std;

template &lt;class ObjectType&gt;
class SharedReference
{
  public:
    int count;
    ObjectType* object;

    SharedReference( ObjectType* object )
    {
      this-&gt;object = object;
      count = 1;
    }

    void retain() { ++count; }

    void release()
    {
      if (--count == 0)
      {
        delete object;
        delete this;
      }
    }
};

template &lt;class ObjectType&gt;
class Ref
{
  private:
    SharedReference&lt;ObjectType&gt;* ref;

  public:
    Ref()
    {
      ref = 0;
    }

    Ref( ObjectType* object )
    {
      ref = new SharedReference&lt;ObjectType&gt;(object);
    }

    Ref( const Ref&lt;ObjectType&gt;&amp; other )
    {
      ref = 0;
      operator=(other);
    }

    ~Ref()
    {
      if (ref) ref-&gt;release();
    }

    void operator=( const Ref&lt;ObjectType&gt;&amp; other )
    {
      if (other.ref) other.ref-&gt;retain();
      if (ref) ref-&gt;release();
      ref = other.ref;
    }

    void operator=( ObjectType* object )
    {
      if (ref) ref-&gt;release();
      ref = new SharedReference&lt;ObjectType&gt;( object );
    }

    ObjectType* operator*()
    {
      if (ref) return ref-&gt;object;
      else return (ObjectType*) NULL;
    }

    ObjectType* operator-&gt;()
    {
      if (ref) return ref-&gt;object;
      else return (ObjectType*) NULL;
    }
};

#endif // SMARTPOINTER_H</pre>
<hr />
<strong>smartpointer.cpp</strong></p>
<hr />
<pre>#include &lt;iostream&gt;
using namespace std;

#include "smartpointer.h"

class Fruit
{
  public:
    const char* name;

    Fruit( const char* name ) { this-&gt;name = name; }
    ~Fruit() { cout &lt;&lt; " [deleting " &lt;&lt; name &lt;&lt; "]" &lt;&lt; endl; }
};

Ref&lt;Fruit&gt; make_fruit();
void mess_with_ref( Ref&lt;Fruit&gt; fruit );

int main()
{
  Ref&lt;Fruit&gt; fruit = make_fruit();

  cout &lt;&lt; "I have an " &lt;&lt; fruit-&gt;name &lt;&lt; endl;

  fruit = new Fruit( "grapes" );
  cout &lt;&lt; "Now it's some " &lt;&lt; fruit-&gt;name &lt;&lt; endl;

  mess_with_ref( fruit );

  cout &lt;&lt; "Still " &lt;&lt; fruit-&gt;name &lt;&lt; "!" &lt;&lt; endl;

  Ref&lt;Fruit&gt; fruit2 = fruit;
  cout &lt;&lt; "If I have two references to " &lt;&lt; fruit-&gt;name &lt;&lt; endl;
  fruit = new Fruit( "strawberries" );
  cout &lt;&lt; "And I set one of them to some " &lt;&lt; fruit-&gt;name &lt;&lt; endl;
  cout &lt;&lt; "Then I still have some " &lt;&lt; fruit2-&gt;name &lt;&lt; endl;

  return 0;
}

Ref&lt;Fruit&gt; make_fruit()
{
  Ref&lt;Fruit&gt; apple = new Fruit( "apple" );
  Ref&lt;Fruit&gt; orange = new Fruit( "orange" );
  return apple;
}

void mess_with_ref( Ref&lt;Fruit&gt; fruit )
{
  fruit = new Fruit( "some kind of weird pear" );

  Fruit* f = *fruit;
  cout &lt;&lt; "Got the object pointer back to " &lt;&lt; f-&gt;name &lt;&lt; endl;
}</pre>
<hr />
Test program output:</p>
<pre>
 [deleting orange]
I have an apple
 [deleting apple]
Now it's some grapes
Got the object pointer back to some kind of weird pear
 [deleting some kind of weird pear]
Still grapes!
If I have two references to grapes
And I set one of them to some strawberries
Then I still have some grapes
 [deleting grapes]
 [deleting strawberries]
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/144/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/144/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/144/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=144&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/04/12/smart-pointers-in-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>iPhone 2D projection matrix, FPU</title>
		<link>http://abepralle.wordpress.com/2009/04/02/iphone-2d-projection-matrix-fpu/</link>
		<comments>http://abepralle.wordpress.com/2009/04/02/iphone-2d-projection-matrix-fpu/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:32:34 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=140</guid>
		<description><![CDATA[iPhoneCore (Plasmacore for iPhone) is nearing completion!
Item 1:  I had an interesting issue today.  I&#8217;d just got my graphics all drawing when I noticed that my bitmap text was blurry.
Using a trick I&#8217;d learned in DirectX, I first tried subtracting 0.5 from each drawing coordinate to compensate for center-of-texel sampling like you have to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=140&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>iPhoneCore (Plasmacore for iPhone) is nearing completion!</p>
<p>Item 1:  I had an interesting issue today.  I&#8217;d just got my graphics all drawing when I noticed that my bitmap text was blurry.</p>
<p>Using a trick I&#8217;d learned in DirectX, I first tried subtracting 0.5 from each drawing coordinate to compensate for center-of-texel sampling like you have to do in DX.  The text was instantly crisp.  However:</p>
<p>I then thought I&#8217;d see if lines &amp; points needed a 0.5 adjustment, so I drew some lines on the edges of the screen.  This graphics test worked fine on the simulator, but on the actual iPhone another problem appeared: floating point error was messing up pixel precision!  If I drew lines in screen columns 0, 1, 2, 3, and 319, then line 0 wouldn&#8217;t show up, lines 1 &amp; 2 would both be in column 1, column2 would be skipped, and columns 3 and 319 would be fine.</p>
<p><span id="more-140"></span>I tried tweaking the orthographic projection matrix several different ways: glOrthof(0,319,479,0,&#8230;), glOrthof(0,320,480,0,&#8230;), glOrthof(0.5,319.5,479.5,0.5), and glOrthof(1,320,480,1).  None of them were accurate for all pixel positions.</p>
<p>Finally, after hours of screwing around, I realized I could ditch the floating point-based pixel-to-unit OpenGL ES transformation matrix and do a better job of it myself using doubles instead of floats!</p>
<p>[Side bar: how many numbers on the number line between 1.0 and 2.0?  Infinitely many!  How much memory do you need to be able to represent any number between 1.0 and 2.0 with complete accuracy?  An infinite amount!  So computers use an approximation scheme referred to as "floating point numbers".  The original "float" type has 32 bits and works okay.  The expanded "double" type uses double the amount of memory (64 bits) and has twice the accuracy.  Computers originally only supported integer arithmetic and did floating point calculations in software, so for a while floats and doubles were much slower than integers.  These days most computers have built-in floating point math (via FPU's = Floating Point Units).]</p>
<p>I set the OpenGL transformation matrix to be the identity matrix.  Then OpenGL expects coordinates in the range -1.0..1.0, so I made the following 2D transformation matrix of doubles:</p>
<p>[ 1.0/160.0, 0.0, -1.0;<br />
0.0, -1.0/240.0, 1.0;<br />
0.0, 0.0, 1.0 ]</p>
<p>I was then able to transform pixel coordinates (0..319,0..479) with pixel-perfect accuracy!  Not only that, but it clarified my bitmap text drawing to where I didn&#8217;t need any -0.5 translation &#8211; in this case, it think the original benefit of -0.5 was more from compensating for floating point error more than it was from compensating for any sort of texel sampling setting.</p>
<p>Item 2:  With my bitmap text working I did some integer versus double speed calculations on the iPhone hardware.  Adding 1 to an integer sum a million times (in the Slag virtual machine) took 0.60 seconds whereas adding 1.0 to a double sum took 0.68 seconds.  Not bad &#8211; it&#8217;s totally awesome that doubles aren&#8217;t hella slow or anything!</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/140/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/140/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/140/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=140&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/04/02/iphone-2d-projection-matrix-fpu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>Quick thoughts on game prototyping and managing risk (Gamasutra)</title>
		<link>http://abepralle.wordpress.com/2009/02/02/quick-thoughts-on-game-prototyping-and-managing-risk-gamasutra/</link>
		<comments>http://abepralle.wordpress.com/2009/02/02/quick-thoughts-on-game-prototyping-and-managing-risk-gamasutra/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 17:11:50 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=137</guid>
		<description><![CDATA[http://www.gamasutra.com/php-bin/news_index.php?story=22093
&#8220;We are always going to be dealing with a succession of low-level, non-critical, non-fatal failures that we can then kind of attenuate and make less frequent and make less severe,&#8221; the Far Cry 2 developer continues.
&#8220;The only way that I can think of at this stage to kind of manage that problem is to embrace [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=137&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://www.gamasutra.com/php-bin/news_index.php?story=22093">http://www.gamasutra.com/php-bin/news_index.php?story=22093</a></p>
<p style="padding-left:30px;">&#8220;We are always going to be dealing with a succession of low-level, non-critical, non-fatal failures that we can then kind of attenuate and make less frequent and make less severe,&#8221; the <em>Far Cry 2</em> developer continues.</p>
<p>&#8220;The only way that I can think of at this stage to kind of manage that problem is to embrace it and say, &#8216;Great. Let&#8217;s make sure that we&#8217;re prototyping things. Let&#8217;s make sure that we&#8217;re putting stuff into the game as fast as possible so that we can see if we&#8217;re even on the right path with it.&#8217;&#8221;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/137/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/137/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/137/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=137&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/02/02/quick-thoughts-on-game-prototyping-and-managing-risk-gamasutra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating balanced in-game economies (Gamasutra)</title>
		<link>http://abepralle.wordpress.com/2009/01/29/creating-balanced-in-game-economies-gamasutra/</link>
		<comments>http://abepralle.wordpress.com/2009/01/29/creating-balanced-in-game-economies-gamasutra/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 17:44:22 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Game Design]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=134</guid>
		<description><![CDATA[Interesting piece:  http://www.gamasutra.com/php-bin/news_index.php?story=22002
An excerpt:
&#8230;the early days of Ultima Online were infamous for the game’s wild and chaotic economy. Zachary Booth Simpson wrote a classic analysis of UO in 1999, detailing some of the more notable problems experienced at launch:
- the crafting system encouraged massive over-production by rewarding players for each item produced
- this over-production led [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=134&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Interesting piece:  <a href="http://www.gamasutra.com/php-bin/news_index.php?story=22002">http://www.gamasutra.com/php-bin/news_index.php?story=22002</a></p>
<p>An excerpt:</p>
<p style="padding-left:30px;">&#8230;the early days of <em>Ultima Online</em> were infamous for the game’s wild and chaotic economy. Zachary Booth Simpson wrote a classic analysis of <em>UO</em> in 1999, detailing some of the more notable problems experienced at launch:</p>
<p style="padding-left:30px;">- the crafting system encouraged massive over-production by rewarding players for each item produced<br />
- this over-production led to hyper-inflation as NPC shopkeepers printed money on demand to buy the worthless items<br />
- players used vendors as unlimited safety deposit boxes by setting the prices for their own goods far above market value<br />
- item hoarding by players forced the team to abandon the closed-loop economy as the world began to empty out of goods<br />
- player cartels (including one from a rival game company!) cornered the market on magical Reagents, preventing average users from casting spells</p>
<p style="padding-left:30px;">
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/134/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/134/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/134/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=134&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/01/29/creating-balanced-in-game-economies-gamasutra/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
		<item>
		<title>86 Int16, Int8; unified Logical type</title>
		<link>http://abepralle.wordpress.com/2009/01/25/86-int16-int8-unified-logical-type/</link>
		<comments>http://abepralle.wordpress.com/2009/01/25/86-int16-int8-unified-logical-type/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 22:09:49 +0000</pubDate>
		<dc:creator>Abe Pralle</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://abepralle.wordpress.com/?p=131</guid>
		<description><![CDATA[While giving a presentation the other day, someone asked me why Slag had so many primitive types.  I&#8217;d never really thought about it before &#8211; I just started out with equivalents of Java&#8217;s 8 types as a baseline and added two more I was keen on (unsigned 8-bit Byte and Ternary types).

The question got me [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=131&subd=abepralle&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>While giving a presentation the other day, someone asked me why Slag had so many primitive types.  I&#8217;d never really thought about it before &#8211; I just started out with equivalents of Java&#8217;s 8 types as a baseline and added two more I was keen on (unsigned 8-bit Byte and Ternary types).</p>
<p><span id="more-131"></span></p>
<p>The question got me thinking though, and I realized that two of my types were dead weights: Int16 and Int8.  No one really uses them &#8211; I don&#8217;t use them.  They just complicate the compiler and VM by having two kinds of 16-bit values (Int16, Char) and two kinds of 8-bit values (Int8, Byte).  So they&#8217;re gone: I&#8217;m taking them out of my gen2 stuff right now.</p>
<p>Furthermore, I&#8217;ve decided to combine the Boolean and Ternary types to create a unified Logical type.  A <em>true/false</em> Boolean is useful for the usual reasons, and then the <em>yes/no/void </em>Ternary only became useful when I allowed it to be used in any place where a Boolean is expected.  With that being the case, there&#8217;s really no reason to have both.</p>
<p>My new Logical type can have values of <em>true, false,</em> and <em>void</em> (with alternate literal names <em>gt, eq, </em>and <em>lt</em>).  <em>void</em> means &#8220;not applicable&#8221;, essentially.  Any logical operation like <em>and</em>, <em>or, </em>or <em>not </em>will treat both <em>false</em> and <em>void</em> as <em>false</em> &#8211; the only difference will be that &#8220;==false&#8221; and &#8220;==void&#8221; (or !=&#8230;) will give different answers.  Note that using Logical in place of Boolean will work <em>exactly</em> the same as you&#8217;re used to; it&#8217;s only when &#8220;void&#8221; values may be involved that you have to be a little careful about comparing things to <em>false</em> versus <em>void</em>.</p>
<p>After the dust settles, here&#8217;s a quick run-down of the remaining 7 primitive types:</p>
<ul>
<li>Int64 &#8211; a 64-bit signed (can be positive or negative) integer.  Useful for random numbers, timestamps, and for indexing and counting data more than 2 GB in size (the upper limit of an Int32).</li>
<li>Int32 &#8211; the standard signed integer made popular by generations of 32-bit CPUs.  Big enough to store most whole numbers you would want to work with while taking up half the space of an Int64.</li>
<li>Char &#8211; an unsigned (non-negative) 16-bit value.  Used to represent character codes from the Unicode table.  Each text string is made up of an array of Chars.</li>
<li>Byte &#8211; an unsigned 8-bit value.  Files and RAM are made of bytes.</li>
<li>Real64 &#8211; a 64-bit real number (aka &#8220;double&#8221;).  The standard for calculations involving real numbers.</li>
<li>Real32 &#8211; aka &#8220;float&#8221;.  Not nearly as precise as Real64, but still used heavily to store 3D game models and terrain since that&#8217;s a lot of data and it only takes half the space that Real64 data would.</li>
<li>Logical &#8211; a qualitative rather than quantitative type, Logical can have the values <em>true, false,</em> and <em>void</em>.  For example, a checkbox could be true if checked, false if not checked, or void if disabled.  &#8220;not true&#8221; is &#8220;false&#8221; while &#8220;not false&#8221; and &#8220;not void&#8221; both result in &#8220;true&#8221;, allowing Logical to be used in the same way as Java&#8217;s Boolean type when desired.</li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abepralle.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abepralle.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abepralle.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abepralle.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abepralle.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abepralle.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abepralle.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abepralle.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abepralle.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abepralle.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abepralle.wordpress.com&blog=3845996&post=131&subd=abepralle&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://abepralle.wordpress.com/2009/01/25/86-int16-int8-unified-logical-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/c945ac50e567d69b031a514e7f585c82?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">Abe Pralle</media:title>
		</media:content>
	</item>
	</channel>
</rss>