<?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>Tummai Games &#187; Explorer</title>
	<atom:link href="http://www.tummaigames.com/blog/category/development/nes/explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tummaigames.com/blog</link>
	<description>NES homebrew! Development blog for homebrew NES games</description>
	<lastBuildDate>Tue, 16 Mar 2010 13:23:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Explorer: 12 &#8211; Monster Art</title>
		<link>http://www.tummaigames.com/blog/2009/08/17/explorer-12-monster-art/</link>
		<comments>http://www.tummaigames.com/blog/2009/08/17/explorer-12-monster-art/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 14:38:42 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=194</guid>
		<description><![CDATA[Took some time away from work and hobbies to spend some time with the family.  Before I left I was working on adding some enemies into the game.  I made three different monsters and added enemy-loading logic to the room-loading routines.  The enemies display onscreen fine and die when you shoot their [...]]]></description>
			<content:encoded><![CDATA[<p>Took some time away from work and hobbies to spend some time with the family.  Before I left I was working on adding some enemies into the game.  I made three different monsters and added enemy-loading logic to the room-loading routines.  The enemies display onscreen fine and die when you shoot their HP to 0.  Tomorrow I&#8217;m going to work on some movement patterns.</p>
<p>I felt I should do some kind of update though, so here are the terrifying monsters I whipped up in GIMP.  Turn on the lights before looking at them or you might die in your sleep:</p>
<ol>
<li>Purple Tongue Head<br />
<div id="attachment_195" class="wp-caption alignnone" style="width: 138px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/08/purple_tongue_head.png" alt="When you see it coming, the shit runs down your leg." title="purple_tongue_head" width="128" height="128" class="size-full wp-image-195" /><p class="wp-caption-text">When you see it coming, the shit runs down your leg.</p></div>
</li>
<li>Eyeball<br />
<div id="attachment_196" class="wp-caption alignnone" style="width: 138px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/08/eyeball.png" alt="It&#039;s looking for something to KILL!" title="eyeball" width="128" height="128" class="size-full wp-image-196" /><p class="wp-caption-text">It's looking for something to KILL!</p></div>
</li>
<li>Shuriken<br />
<div id="attachment_197" class="wp-caption alignnone" style="width: 138px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/08/shuriken.png" alt="It&#039;s pointy." title="shuriken" width="128" height="128" class="size-full wp-image-197" /><p class="wp-caption-text">It's pointy.</p></div>
</li>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/08/17/explorer-12-monster-art/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Explorer: 11 &#8211; Sobjects</title>
		<link>http://www.tummaigames.com/blog/2009/08/06/explorer-11-sobjects/</link>
		<comments>http://www.tummaigames.com/blog/2009/08/06/explorer-11-sobjects/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 14:01:11 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=185</guid>
		<description><![CDATA[I haven&#8217;t posted in a few days and that&#8217;s because I&#8217;ve been spending my time doing research.  I&#8217;ve been peeking at other games and seeing how they handle sprite objects.  By sprite object, I mean entities in a game that are represented on screen with sprites: enemies, projectiles, powerups, etc.  When I [...]]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t posted in a few days and that&#8217;s because I&#8217;ve been spending my time doing research.  I&#8217;ve been peeking at other games and seeing how they handle <strong>sprite objects</strong>.  By sprite object, I mean entities in a game that are represented on screen with sprites: <strong>enemies</strong>, <strong>projectiles</strong>, <strong>powerups</strong>, etc.  When I was trying to code bullets, I didn&#8217;t really know how to go about it.  Should I keep them separate from other <strong>sobjects</strong> (sprite objects) or are there enough similarities to lump them together?</p>
<p>If you think about it, <strong>a bullet isn&#8217;t much different from an enemy</strong>.  It has an x and a y. It has a speed and a movement pattern.  It has a palette.  It has a hit box.  The main difference is what you check for collision against.  Enemies collide with the hero.  Hero bullets don&#8217;t.  They collide with enemies instead.</p>
<p>So some logic is different, but the data (or rather type of data stored) is the same!   As far as turning the sobject data into actual sprites, bullets can be treated just the same as enemies (the hero too).  Why do I care?  If I am able to lump them all together, I can make all the sprites in a single loop.  Here&#8217;s an example of what I mean:</p>
<h2>Sobjects to Sprites</h2>
<p>Let&#8217;s say I have a <strong>hero</strong>.  That&#8217;s one sobject.  He can shoot <strong>bullets</strong>.  Let&#8217;s say I want to allow 3 bullets maximum on the screen at a time.  That&#8217;s three more potential sobjects.  Then <strong>enemies</strong>.  Just pulling a number out of the air, lets say I want there to be 10 enemies on the screen at a time maximum.  That&#8217;s ten more potential sobjects.</p>
<p><strong>1 hero + 3 bullets + 10 enemies = 14.</strong></p>
<p>So I have 14 sobjects that could be represented on the screen at any one time.  If I treat them all the same, I can hold all of the data in arrays, like this:</p>
<pre>
<code>sobj_id: .res 14
sobj_hp: .res 14
sobj_x: .res 14
sobj_y: .res 14
sobj_hitbox_top: .res 14
sobj_hitbox_bottom: .res 14
...etc
</code>
</pre>
<p>Then whenever I need to turn them into sprites, I can just loop through them all using an index register:</p>
<pre>
<code>sobjects_to_sprites:
    ldx #$00
@loop:
    lda sobj_id, x
    <span class="codecomment">;do stuff
    ;calculate y, CHR#, attrib and x
    ;for each sprite of the sprite object
    ;and store in DMA sprite RAM</span>

    inx
    cpx #.sizeof(sobj_id) <span class="codecomment">;loop through all 14</span>
    bne @loop
    rts</code>
</pre>
<p>And that will cover all my sobjects as far as turning their data into sprites.  I don&#8217;t need to write more than one routine!</p>
<p>To differentiate between sobject <strong>types</strong> (bullet vs. enemy vs. hero), I can just have their index range set.  For example, hero is always index 0.  Bullets are always 1-3.  And enemies are always 4-13.  This way I always know what to test for collisions against: enemies will always test against index 0 (hero) and deal damage on a collision.  Enemies will also test against index 1-3 (bullets) and receive damage on a collision.</p>
<p>With defined index ranges, limit testing is easy too: If the player presses the fire button, check sobjects 1-3.  If they are full already, don&#8217;t create a new bullet.  If there is an open space there, create a new bullet.</p>
<h2>Conclusion</h2>
<p>I think I finally figured out how I&#8217;m going to arrange sprite objects.  Today I rewired all of my previous hero-moving code to fit into this new data model and I think I have it working.  Tomorrow I&#8217;m going to try to add bullets for real!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/08/06/explorer-11-sobjects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Explorer: 10 &#8211; Refocus</title>
		<link>http://www.tummaigames.com/blog/2009/08/01/explorer-10-refocus/</link>
		<comments>http://www.tummaigames.com/blog/2009/08/01/explorer-10-refocus/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 06:30:47 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=183</guid>
		<description><![CDATA[I originally started working on this game as an entry for a coding competition.  The genre was puzzle games and I thought a switch-throwing maze game would be fun to write.  I missed the deadline for the contest long ago but I kept working on the game anyway.  Now I&#8217;m thinking about [...]]]></description>
			<content:encoded><![CDATA[<p>I originally started working on this game as an entry for a coding competition.  The genre was puzzle games and I thought a switch-throwing maze game would be fun to write.  I missed the deadline for the contest long ago but I kept working on the game anyway.  Now I&#8217;m thinking about taking the game in a new direction.</p>
<p>The decision to make a maze-only game was made because there was a deadline, and because the genre for the contest was &#8220;puzzle&#8221;.  But now that I have as much time and freedom as I want, I think I&#8217;m going to expand the game beyond just finding your way through a maze.  Specifically, here are some things I want to add that weren&#8217;t in the original plan:</p>
<ol>
<li>Enemies and bosses</li>
<li>Weapons</li>
<li>A way to die (ie, health bar)</li>
<li>A way to improve (more weapons.  powerups&#8230; level ups?)</li>
</ol>
<p>In addition to these changes, I&#8217;m also going to change the setting and storyline completely.  No more treasure hunting archaeologist.  I haven&#8217;t worked out all the details but I think it&#8217;s going to be somewhat sci-fi, with the hero as a cyborg (ie, guns not swords).  I think using the Guardian Legend girl as my test sprite has influenced me in some way. :).</p>
<p>Anyway, this comes at just the right time.  I just got switches and doors working and the next thing I was going to write was a way to break the breakable blocks.  In the original maze-game concept there was going to be an item (like a hammer) that the archaeologist hero would find to allow him to break blocks.   Now I think it will be a powerup that makes your gun blast stronger.</p>
<p>Next objective: make the hero shoot a projectile when pressing A.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/08/01/explorer-10-refocus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Explorer: 10 &#8211; Sprite Collision</title>
		<link>http://www.tummaigames.com/blog/2009/07/29/explorer-10-sprite-collision/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/29/explorer-10-sprite-collision/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 13:49:59 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=166</guid>
		<description><![CDATA[In the last post, I got the hero sprite moving.  But there&#8217;s a problem: she can walk through walls.  I need to add collision detection with background tiles.  Collision detection with the background can be summed up like this:

if the player tries to move:
    check the space they want [...]]]></description>
			<content:encoded><![CDATA[<p>In the last post, I got the hero sprite moving.  But there&#8217;s a problem: she can walk through walls.  I need to add collision detection with background tiles.  Collision detection with the background can be summed up like this:</p>
<pre>
<code>if the player tries to move:
    check the space they want to move to
    if that space is solid/blocked:
        don't move
    else:
        move
</code>
</pre>
<p>The looks pretty easy, but it can actually be quite complicated.  Here are some issues:</p>
<ol>
<li>The hero sprite has x and y coordinates, which are on the pixel level.  My room tile data is stored in ram on the metatile level.  We need to make a conversion there.</li>
<li>There isn&#8217;t any one point on the hero that is a catch-all for movement checks.  If the player tries to move left, we will want to check for a collision with the left side of the hero.  If the player tries to move right, we want to check for a collision with the right side of the hero.  So we will need to make a <strong>hit box</strong>.</li>
<li>Each side of the hit box will have a length > 1, so we may have to check for a collision with more than one background tile.  For example, say the player wants to move right.  We will check using the right side of the hit box.   But it&#8217;s possible that the top half of the hit box will be adjacent to one tile, while the bottom half is adjacent to another.
<div id="attachment_167" class="wp-caption aligncenter" style="width: 409px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_hitbox_2_tiles.jpg" alt="If we only checked the top-right corner of this hit box for collision, it would show the way as clear.  But it really isn&#039;t, because the bottom half of the hit box collides with a solid tile." title="explorer_hitbox_2_tiles" width="399" height="337" class="size-full wp-image-167" /><p class="wp-caption-text">If we only checked the top-right corner of this hit box for collision, it would show the way as clear.  But it really isn't, because the bottom half of the hit box collides with a solid tile.</p></div></li>
</ol>
<h2>Step 1</h2>
<p>First thing I want to do is make a <strong>hit box</strong>.  I&#8217;m going to put it around the hero sprite&#8217;s feet.  I define where the edges are relative to the hero&#8217;s X/Y coords, then make a subroutine to calculate the box every frame:</p>
<pre>
<code><span class="codecomment">;collision box for the hero sprite (box around the feet)</span>
HERO_MOVEMENT_BOX_TOP = 26
HERO_MOVEMENT_BOX_BOTTOM = 31
HERO_MOVEMENT_BOX_LEFT = 5
HERO_MOVEMENT_BOX_RIGHT = 11
</code>
</pre>
<pre>
<code>hero_box: .res 4 <span class="codecomment">;top bottom left right</span>
</code>
</pre>
<pre>
<code>set_hero_box:
    lda hero_x
    clc
    adc #HERO_MOVEMENT_BOX_LEFT
    sta hero_box+2
    lda hero_x
    clc
    adc #HERO_MOVEMENT_BOX_RIGHT
    sta hero_box+3
    lda hero_y
    clc
    adc #HERO_MOVEMENT_BOX_TOP
    sta hero_box
    lda hero_y
    clc
    adc #HERO_MOVEMENT_BOX_BOTTOM
    sta hero_box+1
    rts
</code>
</pre>
<h2>Movement within a metatile</h2>
<p>Since every metatile is 16 pixels wide and 16 pixels tall, I can take a shortcut if I determine that the player is not at the edge of a tile.  Check out these two cases:</p>
<p><div id="attachment_172" class="wp-caption aligncenter" style="width: 120px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_hitbox_midtile.jpg" alt="We don&#039;t need to check for a collision in the left case.  The player is already on a walkable tile, and will remain on that tile if they move a pixel to the right.  " title="explorer_hitbox_midtile" width="110" height="85" class="size-full wp-image-172" /><p class="wp-caption-text">We don't need to check for a collision in the left case.  The player is already on a walkable tile, and will remain on that tile if they move a pixel to the right.  </p></div>
<p>Let&#8217;s assume the player is trying to move right.  The player is on a walkable tile in both cases.  In the first case, they are in the middle of the tile.  In the second case they are at the edge.  We only need to check for a collision in the second case.  Checking the first case would be a waste of time, because we&#8217;d be checking the tile the player is already on for walkability, but we know it must be walkable since the player is already on it.  So right away we can skip over a collision check if we determine the player to be in the middle of the tile (ie, not on the edge).</p>
<p>This is very easy to pull off with 16&#215;16 metatiles.  In all cases, the left edge of a metatile will have an x-coord of $x0, and the right edge will be $xF.  The top edge of a metatile will have a y-coord of $x0 and the bottom will be $xF.  So in our collision detection routines, we can do something like this:</p>
<pre>
<code>can_move_right:
    ldx hero_box+3 <span class="codecomment">;right edge of movement box</span>
    inx <span class="codecomment">;we want to peek at the next pixel over</span>
    txa

    and #$0F <span class="codecomment">;isolate right nibble,</span>
         <span class="codecomment">; tells us where we are WITHIN a tile</span>

    bne @move_ok <span class="codecomment">;not on the edge.  movement within current</span>
                 <span class="codecomment">;square OK (in other words, if the right</span>
                 <span class="codecomment">;nibble is 0, we are on the left edge of the</span>
                 <span class="codecomment">;NEXT tile, and therefore need to check</span>
                 <span class="codecomment">;for collision)</span>

    <span class="codecomment">;... check for collisions</span>

@move_ok:
    sec  <span class="codecomment">;return a 1 if movement is OK</span>
    rts
</code>
</pre>
<p>I use a similar check at the beginning of <strong>can_move_left</strong>, <strong>can_move_up</strong> and <strong>can_move_down</strong>.</p>
<h2>How many checks?</h2>
<p>Do I need to check one bg tile for collision or two?  It depends on the hero sprite&#8217;s position.  Imagine the player is moving right again.  If the top and bottom edges of the hit box are both within the boundaries of a single tile, we only need to check one bg tile for collision.  But check this picture (should look familiar):</p>
<div id="attachment_173" class="wp-caption aligncenter" style="width: 409px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_hitbox_2_tiles2.jpg" alt="moving right, the top and bottom edges of the hit box touch two different bg tiles.  We need to make two checks." title="explorer_hitbox_2_tiles2" width="399" height="337" class="size-full wp-image-173" /><p class="wp-caption-text">moving right, the top and bottom edges of the hit box touch two different bg tiles.  We need to make two checks.</p></div>
<p>In this case, the top and bottom edges of our hit box line up with two different bg tiles.  So we need to check both.  If either of them are unwalkable, we don&#8217;t allow movement.  </p>
<p>So, two checks or one check?  There are a couple of ways to determine if the top and bottom edges of our hit box touch different tiles.  I do it this way:</p>
<pre>
<code>    <span class="codecomment">;find how many tiles to check (1 or 2)</span>
    lda hero_box <span class="codecommen">;top edge of movement hit box</span>

    ora #$F0 <span class="codecomment">;we are going to add the box height,</span>
             <span class="codecomment">;so set us up to check for a FF-&gt;00 transition</span>

    adc #HERO_MOVEMENT_BOX_HEIGHT <span class="codecomment">;negative means our box is</span>
                                  <span class="codecomment">;h-aligned with one tile.</span>
                                  <span class="codecomment">;positive = 2 tiles</span>
    bmi @not_two

    <span class="codecomment">;... check a tile</span>

@not_two:
    <span class="codecomment">;... check a tile</span>
</code>
</pre>
<p>I do similar tests for the other directions, but for <strong>can_move_up</strong> and <strong>can_move_down</strong> I will check the left and right edges instead of the top and bottom edges.</p>
<h2>Hero pixel coords to a room coords</h2>
<p>I need to turn the hero&#8217;s pixel coordinates into room coordinates so that I can find which bg tiles to check.  Here&#8217;s my subroutine to do that:</p>
<pre>
<code><span class="codecomment">;------------------------------</span>
<span class="codecomment">; set_hero_map_coords finds the x and y room coords for the </span>
<span class="codecomment">; topleft pixel of the player's movement hit box</span>
set_hero_map_coords:
    lda hero_box+2 <span class="codecomment">;left</span>
    ldx #$00
    sec
:
    sbc #$10
    bcc :+
    inx
    jmp :-
:
    stx hero_map_x

    lda hero_box <span class="codecomment">;top</span>
    ldx #$00
    sec
:
    sbc #$10
    bcc :+
    inx
    jmp :-
:
    dex
    dex <span class="codecomment">;correct y for the status bar</span>
    stx hero_map_y
    rts
</code>
</pre>
<p>Once I have the hero&#8217;s room coordinates, I can add to or subtract from them to find the coordinates for the adjacent tiles I want to check for walkability.</p>
<h2>Walkability</h2>
<p>How do I check for walkability?  With a lookup table:</p>
<pre>
<code><span class="codecomment">;tile ids</span>
.enum
    floor
    wall
    block
    water
    block_breakable
    stairs_up
    stairs_down
    pitfall
.endenum
</code>
</pre>
<pre>
<code>.enum <span class="codecomment">;walkability</span>
    unwalkable
    walkable
.endenum
</code>
</pre>
<pre>
<code>tile_walkability:
    .byte walkable, unwalkable, unwalkable, unwalkable
    .byte unwalkable, walkable, walkable, walkable
</code>
</pre>
<p>I read a tile id from the room map in RAM and use it to index into the tile_walkability table.</p>
<p>Here&#8217;s a simplified <strong>can_move_right</strong>.  (I took out checks for room boundaries to make it more readable):</p>
<pre>
<code>can_move_right:
    ldx hero_box+3 <span class="codecomment">;right edge of movement box</span>
    inx
    txa

    and #$0F <span class="codecomment">;isolate right nibble, where are we WITHIN a tile?</span>

    bne @move_ok <span class="codecomment">;not on edge. move within current square OK</span>

    <span class="codecomment">;how many tiles to check (1 or 2)</span>
    lda hero_box <span class="codecomment">;top edge of movement box</span>
    ora #$F0
    adc #HERO_MOVEMENT_BOX_HEIGHT
    bmi @not_two

    ldy hero_map_y
    iny
    ldx hero_map_x
    inx
    jsr get_room_offset <span class="codecomment">;takes x/y room coords and returns an</span>
                        <span class="codecomment">;array index in y</span>

    lda room, y
    tay
    lda tile_walkability, y
    beq @no_move

@not_two:
    ldy hero_map_y
    ldx hero_map_x
    inx
    jsr get_room_offset

    lda room, y
    tay
    lda tile_walkability, y
    beq @no_move
@move_ok:
    sec <span class="codecomment">return 1 in the carry if we can move</span>
    rts
@no_move:
    clc <span class="codecomment">return 0 in the carry if we can't move</span>
    rts
</code>
</pre>
<p>I have seperate routines for the other 3 directions.  They are all very similar.  The last step is to update my <strong>move_hero</strong> subroutine to call these collision detection routines before moving, and then skip movement on carry clear.</p>
<h2>Conclusion</h2>
<p>Now I have a sprite that changes direction, moves, animates and bumps into walls.  Here&#8217;s the latest video demo:  </p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/a4fJnAkra9c&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/a4fJnAkra9c&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/29/explorer-10-sprite-collision/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Explorer: 9 &#8211; Sprite Movement</title>
		<link>http://www.tummaigames.com/blog/2009/07/26/explorer-9-sprite-movement/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/26/explorer-9-sprite-movement/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 15:00:19 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=159</guid>
		<description><![CDATA[Ok, I got the hero to change directions based on user input.  Now it&#8217;s time to move her.  The first step for this is to have a hero_moving flag that the input handler will set if there is d-pad input:

hero_moving: .res 1


handle_joypad:
    lda joypad1
    and #$F0
  [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I got the hero to <a href="http://www.tummaigames.com/blog/2009/07/24/explorer-8-sprite-direction/">change directions</a> based on user input.  Now it&#8217;s time to move her.  The first step for this is to have a hero_moving flag that the input handler will set if there is d-pad input:</p>
<pre>
<code>hero_moving: .res 1</code>
</pre>
<pre>
<code>handle_joypad:
    lda joypad1
    and #$F0
    beq @end
    lsr
    lsr
    lsr
    lsr
    tay
    lda direction_change_table, y
    sta hero_direction
    <strong>lda #$01
    sta hero_moving</strong>
    rts
@end:
    <strong>lda #$00
    sta hero_moving</strong>
    rts
</code>
</pre>
<p>With this updated input handler, the <strong>hero_moving</strong> flag will be 1 when the d-pad is pressed, and 0 when it is not.  And as before, our hero&#8217;s direction will be stored in <strong>hero_direction</strong>.</p>
<p>Next, I need to check the hero moving flag in my <strong>update_hero_sprite</strong> routine, which is called every frame:</p>
<pre>
<code>update_hero_sprite:
    lda hero_moving
    beq @hero_moving_done

    jsr move_hero
@hero_moving_done:
    <span class="codecomment">;...</span>
    <span class="codecomment">;write sprite data to RAM as before</span>
</code>
</pre>
<p>Now that I have the foundation laid, I need to write the <strong>move_hero</strong> routine.</p>
<h2>move_hero</h2>
<p>There are 8 possible directions the hero could be facing.  The current direction is stored in a variable called <strong>hero_direction</strong>.  The possible values for this variable are 0-7, as assigned by these constants:</p>
<pre>
<code><span class="codecomment">;direction indexes for tables</span>
SPRITE_UP =         $00
SPRITE_DOWN =       $01
SPRITE_LEFT =       $02
SPRITE_RIGHT =      $03
SPRITE_UP_LEFT =    $04
SPRITE_UP_RIGHT =   $05
SPRITE_DOWN_LEFT =  $06
SPRITE_DOWN_RIGHT = $07
</code>
</pre>
<p>I need to alter the hero&#8217;s coordinates based on the direction the player is moving.  If they are moving left, I need to subtract from <strong>hero_x</strong>.  If they are moving right, I need to add to <strong>hero_x</strong>.  If they are moving up, I need to subtract from <strong>hero_y</strong>.  If they are moving down, I need to add to <strong>hero_y</strong>.  If they are moving diagonally, I need to update both <strong>hero_x</strong> and <strong>hero_y</strong>.  There are many possibilities, and rather than have a million branch instructions, I&#8217;ll use table lookups again.  I will have one table for horizontal movement and one table for vertical movement.  I will index into these tables using <strong>hero_direction</strong>.  The tables look like this:</p>
<pre>
<code><span class="codecomment">;up, down, left, right, up_left, up_right, down_left, down_rt</span>
hero_movement_x:
    .byte $00, $00, $FF, $01, $FF, $01, $FF, $01

hero_movement_y:
    .byte $FF, $01, $00, $00, $FF, $FF, $01, $01
</code>
</pre>
<p>My <strong>move_hero</strong> routine will read from these tables and add to the hero coordinates.  Note that adding $FF to a number (on an 8-bit system) is the same as subtracting 1, since it will wrap around from $FF to $00.  Here is move_hero:</p>
<pre>
<code>move_hero:
    ldy hero_direction
    lda hero_movement_x, y
    clc
    adc hero_x
    sta hero_x

    ldy hero_direction
    lda hero_movement_y, y
    clc
    adc hero_y
    sta hero_y

    rts
</code>
</pre>
<p>And now she&#8217;s moving.</p>
<p><a href="http://morphcat.de/">miau</a> pointed out in a <a href="http://www.tummaigames.com/blog/2009/07/24/explorer-8-sprite-direction/comment-page-1/#comment-27">comment</a> that diagonal movement should really alter x and y by SQRT(2) rather than 1 (see <a href="http://en.wikipedia.org/wiki/Pythagorean_theorem">Pythagorean Theorum</a>).  This is something I didn&#8217;t consider before, so my hero covers ground a little more quickly when moving diagonally.  I&#8217;m not sure yet if this is undesirable behavior or not.  If I keep it a simple maze-solving game, it probably won&#8217;t be an issue.  If I get more ambitious and change it to a more action-oriented game with enemies (something I&#8217;ve been seriously thinking about), it may be an issue.  We&#8217;ll see :).</p>
<h2>Animation</h2>
<p>I want to talk very briefly about animating the sprite.  To do animation, I need a few things:</p>
<ol>
<li>Graphics for the various frames of animation</li>
<li>A counter to tell me when to change animation frames</li>
<li>A variable telling me the current animation frame</li>
</ol>
<p>I already have the graphics for my test sprite.  The other two I need to make myself.</p>
<pre>
<code>frame_counter: .res 1
hero_anim_frame: .res 1
</code>
</pre>
<p>The animation is a walking animation, so I don&#8217;t want the hero to animate unless she is moving.  It makes sense then to do the animation frame-changing logic in the <strong>move_hero</strong> routine.  The Guardian Legend hero sprite has a 4-frame walking animation, so here&#8217;s how I do it:</p>
<pre>
<code>move_hero:
    ldy hero_direction
    lda hero_movement_x, y
    clc
    adc hero_x
    sta hero_x

    ldy hero_direction
    lda hero_movement_y, y
    clc
    adc hero_y
    sta hero_y

    <strong>inc frame_counter</strong>
    <strong>lda frame_counter</strong>
    <strong>cmp #$0B</strong> <span class="codecomment">;change anim frame every 11 "moving frames"</span>
             <span class="codecomment">;found this number by trial and error</span>
    <strong>bcc @end</strong>

    <strong>lda #$00</strong>
    <strong>sta frame_counter</strong> <span class="codecomment">;reset counter</span>
    <strong>inc hero_anim_frame</strong> <span class="codecomment">;go to next anim frame</span>
    <strong>lda hero_anim_frame</strong> <span class="codecomment">;make sure we stay between 0 and 3</span>
    <strong>and #$03</strong>
    <strong>sta hero_anim_frame</strong>
<strong>@end:</strong>
    rts
</code>
</pre>
<p>Then I will modify my CHR tile lookup tables to handle graphics for all four frames of animation for all 8 directions.  Then I will update my <strong>update_hero_sprite</strong> routine to read from these tables based on the values of <strong>hero_anim_frame</strong> and <strong>hero_direction</strong>.  I&#8217;m not going to post the code, because it&#8217;s a little long and there are a lot of tables.  If anybody wants me to elaborate more, let me know in the comments :)</p>
<p>BTW, before I forget!  When adding new variables, it&#8217;s a good idea to initialize them.  Here is my updated <strong>initialize_hero_sprite</strong> routine:</p>
<pre>
<code>initialize_hero_sprite:
    lda #$50
    sta hero_x
    sta hero_y

    <strong>lda #$00
    sta hero_moving
    sta hero_anim_frame
    sta frame_counter</strong>

    lda #SPRITE_DOWN
    sta hero_direction

    jsr update_hero_sprite

    rts
</code>
</pre>
<h2>Conclusion</h2>
<p>Whew.  I covered a lot of ground today.  I probably should have made this two posts instead of one, but I want to hurry up and get to collision detection so I can put up the next demo video.  :)  </p>
<p>You may have noticed by now that I use <strong>hero_direction</strong> a lot to index into lookup tables.  This is because everything changes based on the hero&#8217;s direction, and lookup tables are a great alternative to long sections of compare/branch code.  Often when I find myself writing a lot of branching code I&#8217;ll see if I can come up with some scheme to turn the test value into a table index.</p>
<p>See you next time!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/26/explorer-9-sprite-movement/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Explorer: 8 &#8211; Sprite Direction</title>
		<link>http://www.tummaigames.com/blog/2009/07/24/explorer-8-sprite-direction/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/24/explorer-8-sprite-direction/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 15:51:43 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=140</guid>
		<description><![CDATA[Last time I wrote code to put a hero sprite onscreen.  In my first (pre-sprite) video demo, I had room changes triggered directly by player input.  Today I&#8217;m going to recode the input handler to alter the hero instead, specifically the hero&#8217;s direction.
Joypad revisited
I posted my joypad reading code in a previous post, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tummaigames.com/blog/2009/07/23/explorer-7-sprite-time/">Last time</a> I wrote code to put a hero sprite onscreen.  In my first (pre-sprite) <a href="http://www.youtube.com/watch?v=S5s8LmuIFS4">video demo</a>, I had room changes triggered directly by player input.  Today I&#8217;m going to recode the input handler to alter the hero instead, specifically the hero&#8217;s <strong>direction</strong>.</p>
<h2>Joypad revisited</h2>
<p>I posted my joypad reading code in a <a href="http://www.tummaigames.com/blog/2009/07/21/explorer-6-navigation-and-input/">previous post</a>, but here it is again for easy reference:</p>
<pre>
<code>update_joypad_data: <span class="codecomment">;props to blargg for A-only joypad read.</span>
    lda joypad1
    sta joypad1_old
    lda #%01111111
    sta joypad1
    sta $4016
    asl a
    sta $4016
@loop:
    lda $4016
    and #$03  <span class="codecomment">;props to Disch for Famicom support</span>
    cmp #$01
    ror joypad1 <span class="codecomment">;right, left, down, up, start, select, B, A</span>
    bcs @loop

    lda joypad1_old
    eor #$FF
    and joypad1
    sta joypad1_pressed <span class="codecomment">;this tracks off-to-on transitions.</span>

    lda joypad1
    eor #$FF
    and joypad1_old
    sta joypad1_released <span class="codecomment">;this tracks on-to-off transitions</span>
    rts
</code>
</pre>
<p>Before, I was checking <strong>joypad_pressed</strong> to determine whether or not to change a room.  This was so that if the player held down a button, it would only change rooms once (instead of once per frame held).  But now that I&#8217;m going to be using input to control the sprite, it makes more sense to check <strong>joypad1</strong> and use every frame&#8217;s input.  If the player holds down the d-pad, the sprite should keep moving.</p>
<p>But I&#8217;m not quite ready to move yet!</p>
<h2>Changing Direction</h2>
<p>I want to rewrite my input handler so that it takes d-pad input and uses it to set the hero&#8217;s direction.  This sounds pretty straightforward, but there are some special cases I need to be wary of: what happens if the player presses <strong>left+right</strong>?  or <strong>up+down</strong>?  This isn&#8217;t likely to happen on a real controller, but most people play Nintendo games on emulators these days.  If you don&#8217;t protect against these strange key combinations, you open yourself up to some pretty bizarre glitches, like the <strong>Zelda 2 acceleration glitch</strong> (commentator talks about it around the 4:20 mark):</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Vqry4oBHOsc&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Vqry4oBHOsc&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>I&#8217;m going to work around this problem by assigning a <strong>single</strong> direction to these weird combinations.  But first we need to look at our input.  In my joypad reading routine above, I store the button states in a variable called <strong>joypad1</strong>.  The left 4 bits of joypad1 will hold the d-pad states and the right 4 bits will hold the states of the other four buttons.  First I want to isolate the d-pad bits:</p>
<pre>
<code>    lda joypad1
    and #$F0
    beq @end
    lsr
    lsr
    lsr
    lsr
    <span class="codecomment">;now the d-pad button states are in the right nibble.</span>
    <span class="codecomment">;do change direction stuff here.</span>
@end:
    rts
</code>
</pre>
<p>The right nibble of the A register now holds the d-pad button states.  Next I will build a look-up table, assigning a direction to each possible combination of d-pad presses.  Let&#8217;s look at the combinations.  There are sixteen possibilities in all:</p>
<pre>
<code>0000xxxx
    ||||
    |||+--up
    ||+---down
    |+----left
    +-----right

0000 = no arrows pressed (will never happen)
0001 = up
0010 = down
0011 = <strong>up+down</strong>
0100 = left
0101 = left+up
0110 = left+down
0111 = <strong>left+up+down</strong>
1000 = right
1001 = right+up
1010 = right+down
1011 = <strong>right+up+down</strong>
1100 = <strong>right+left</strong>
1101 = <strong>right+left+up</strong>
1110 = <strong>right+left+down</strong>
1111 = <strong>right+left+down+up</strong>
</code>
</pre>
<p>The highlighted ones are the <strong>problem combinations</strong>.  I will need to assign a single, specific direction to them.  For example in the case of <strong>right+left</strong>, I will just choose one: <strong>left</strong>.  Let&#8217;s turn this into a lookup table.  Recall that I have a set of constants assigning a value to each direction (for indexing into CHR lookup tables among other things):</p>
<pre>
<code><span class="codecomment">;direction indexes for tables</span>
SPRITE_UP =         $00
SPRITE_DOWN =       $01
SPRITE_LEFT =       $02
SPRITE_RIGHT =      $03
SPRITE_UP_LEFT =    $04
SPRITE_UP_RIGHT =   $05
SPRITE_DOWN_LEFT =  $06
SPRITE_DOWN_RIGHT = $07
</code>
</pre>
<p>Now I will make a lookup table assigning these constant values to the various button combinations:</p>
<pre>
<code>direction_change_table:
    .byte $FF               ;0000 dummy value
    .byte SPRITE_UP         ;0001, up
    .byte SPRITE_DOWN       ;0010, down
    .byte <strong>SPRITE_UP</strong>         ;0011, <strong>up+down</strong>
    .byte SPRITE_LEFT       ;0100, left
    .byte SPRITE_UP_LEFT    ;0101, left+up
    .byte SPRITE_DOWN_LEFT  ;0110, left+down
    .byte <strong>SPRITE_UP_LEFT</strong>    ;0111, <strong>left+up+down</strong>
    .byte SPRITE_RIGHT      ;1000, right
    .byte SPRITE_UP_RIGHT   ;1001, right+up
    .byte SPRITE_DOWN_RIGHT ;1010, right+down
    .byte <strong>SPRITE_DOWN_RIGHT</strong> ;1011, <strong>right+up+down</strong>
    .byte <strong>SPRITE_LEFT</strong>       ;1100, <strong>left+right</strong>
    .byte <strong>SPRITE_UP_RIGHT</strong>   ;1101, <strong>left+right+up</strong>
    .byte <strong>SPRITE_DOWN_RIGHT</strong> ;1110, <strong>left+right+down</strong>
    .byte <strong>SPRITE_DOWN_LEFT</strong>  ;1111, <strong>left+right+up+down
</strong></code>
</pre>
<p>Now all button combinations have a <strong>single</strong> direction associated with each of them.  All that I have left to do is read from this table and set the hero&#8217;s direction, like so:</p>
<pre>
<code>handle_joypad:
    lda joypad1
    and #$F0
    beq @end
    lsr
    lsr
    lsr
    lsr
    tay <span class="codecomment">;right nibble has the d-pad button states. use as index</span>
    lda direction_change_table, y
    sta hero_direction
@end:
    rts
</code>
</pre>
<h2>Changing the sprite</h2>
<p>The rest of the work is already done for me.  I already have a routine <strong>update_hero_sprite</strong> (see <a href="http://www.tummaigames.com/blog/2009/07/23/explorer-7-sprite-time/">last post</a>) that takes <strong>hero_direction</strong> and uses it to index into some CHR lookup tables.  I don&#8217;t have to change anything to get the new sprites to display.  It works! (you can see the input in the bottom left of each picture):</p>
<div id="attachment_151" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_sprite_up.jpg" alt="If I press up, the sprite faces up." title="explorer_sprite_up" width="400" height="350" class="size-full wp-image-151" /><p class="wp-caption-text">If I press up, the sprite faces up.</p></div>
<div id="attachment_152" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_sprite_down_right.jpg" alt="Pressing down+right makes her face southeast" title="explorer_sprite_down_right" width="400" height="350" class="size-full wp-image-152" /><p class="wp-caption-text">Pressing down+right makes her face southeast</p></div>
<div id="attachment_153" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_sprite_left_right.jpg" alt="Left+Right gets mapped to left." title="explorer_sprite_left_right" width="400" height="350" class="size-full wp-image-153" /><p class="wp-caption-text">Left+Right gets mapped to left.</p></div>
<div id="attachment_154" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_sprite_up_down_left_right.jpg" alt="up+down+left+right" title="explorer_sprite_up_down_left_right" width="400" height="350" class="size-full wp-image-154" /><p class="wp-caption-text">up+down+left+right</p></div>
<h2>Conclusion</h2>
<p>My hero sprite is now capable of looking in 8 directions.  I use a lookup table to assign a specific direction to each possible d-pad button combination.  The next step is to actually move her in the direction she is facing.  And when she is moving, I will want to animate her.  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/24/explorer-8-sprite-direction/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Explorer: 7 &#8211; Sprite Time</title>
		<link>http://www.tummaigames.com/blog/2009/07/23/explorer-7-sprite-time/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/23/explorer-7-sprite-time/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 13:55:57 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=124</guid>
		<description><![CDATA[Now that I have some test rooms and can navigate between them, it&#8217;s time to stick a sprite in the game.  I couldn&#8217;t draw a rock to save my life, much less a cool character sprite, so for now I am going to rip one from another game to use for testing.  Here [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have some test rooms and can navigate between them, it&#8217;s time to stick a <strong>sprite</strong> in the game.  I couldn&#8217;t draw a rock to save my life, much less a cool character sprite, so for now I am going to rip one from another game to use for testing.  Here she is:</p>
<div id="attachment_125" class="wp-caption aligncenter" style="width: 58px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/tgl_sprite.png" alt="She&#039;s from The Guardian Legend." title="tgl_sprite" width="48" height="96" class="size-full wp-image-125" /><p class="wp-caption-text">She's from The Guardian Legend.</p></div>
<p>This is the sprite from <strong>The Guardian Legend</strong>.  I chose her as my test sprite for a few reasons:</p>
<ol>
<li>Her <strong>dimensions</strong>.  She is 16&#215;32, which is the size I want for my game&#8217;s hero sprite.</li>
<li>Her <strong>proportions</strong>.  Specifically her feet.  I have narrow 16 pixel passages that the player will need to fit through.  I want to allow a small amount of left-to-right and up-to-down movement within those 16 pixel hallways.  If the sprite is too fat it will look like they are stomping on the walls.</li>
<li>Her <strong>directions</strong>.  She can face 8 different directions, which is what I want for my game.</li>
<li>Her <strong>animation</strong>.  She has a 4-frame animation that looks smooth and is CHR-efficient.  Something I want to imitate.</li>
</ol>
<h2>Getting a sprite onscreen</h2>
<p>First things first I need some variables for the hero.  Right off the bat I know I will need to track her <strong>coordinates</strong> and <strong>direction</strong>:</p>
<pre>
<code>.segment "ZP": zeropage
hero_x: .res 1 <span class="codecomment">;based on top left of sprite</span>
hero_y: .res 1
hero_direction: .res 1
</code>
</pre>
<p>Next I will need to initialize those variables.  This subroutine will be called when the game engine is loaded:</p>
<pre>
<code><span class="codecomment">;direction indexes for tables</span>
SPRITE_UP =         $00
SPRITE_DOWN =       $01
SPRITE_LEFT =       $02
SPRITE_RIGHT =      $03
SPRITE_UP_LEFT =    $04
SPRITE_UP_RIGHT =   $05
SPRITE_DOWN_LEFT =  $06
SPRITE_DOWN_RIGHT = $07

initialize_hero:
    lda #$50    <span class="codecomment">;place her somewhere on the map</span>
    sta hero_x
    sta hero_y

    lda #SPRITE_DOWN
    sta hero_direction

    jsr update_hero_sprite

    rts
</code>
</pre>
<p>The hero will have a different appearance based on the direction she is facing.  I will have lookup tables to find which CHR tile number to use.  I index into these tables with a <strong>direction index</strong>.  Those constants at the top define the direction indexes (indices?  whatever).</p>
<p><strong>update_hero_sprite</strong> is a routine that will be called every frame.  It&#8217;s job will be to calculate the sprites&#8217; x, y, tile number and flip/palette settings and store them in RAM.  Later, in the NMI we will copy those values to the PPU (Picture Processing Unit) using <strong>DMA transfer</strong>.</p>
<p>Speaking of which, the hero sprite is actually made up of 4 sprites.  On the NES, you have a choice between 8&#215;8 sprites and 8&#215;16 sprites.  I will be using 8&#215;16 sprites.  The hero is 16&#215;32, which is 4 8&#215;16 sprites:</p>
<div id="attachment_127" class="wp-caption aligncenter" style="width: 64px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/tgl_sprite_broken.png" alt="This character sprite is actually made up of 4 8x16 sprites" title="tgl_sprite_broken" width="54" height="100" class="size-full wp-image-127" /><p class="wp-caption-text">This character sprite is actually made up of 4 8x16 sprites</p></div>
<p>So let&#8217;s get her on the screen:</p>
<pre>
<code>update_hero_sprite:
    lda hero_direction
    tax       <span class="codecomment">;we use this index to read from tables</span>

    lda #hero_top_left  <span class="codecomment">;sprite number.</span>
    asl
    asl     <span class="codecomment">;each sprite has 4 bytes of data</span>
    tay     <span class="codecomment">;we use this index to write sprite data to RAM</span>

    <span class="codecomment">;sprite data is stored, in order: y, tile #, attrib, x</span>
    lda hero_y
    sta sprite_RAM, y

    lda hero_x
    sta sprite_RAM+3, y

    lda sprite_tiles_top_left, x
    sta sprite_RAM+1, y

    lda hero_sprite_flips, x  <span class="codecomment">;right, up_right and down_right </span>
                              <span class="codecomment">;are just flips of left, up_left</span>
                              <span class="codecomment">;and down_left. Flip values are</span>
                              <span class="codecomment">; stored in a table</span>
    sta sprite_RAM+2, y

    lda #hero_top_right    <span class="codecomment">;top right, sprite #</span>
    asl
    asl
    tay

    lda hero_y
    sta sprite_RAM, y

    lda hero_x
    clc
    adc #$08    <span class="codecomment">;8 pixels to the right of the top left sprite</span>
    sta sprite_RAM+3, y

    lda sprite_tiles_top_right, x
    sta sprite_RAM+1, y

    lda hero_sprite_flips, x
    sta sprite_RAM+2, y

    lda #hero_bottom_left    <span class="codecomment">;bottom left, sprite #</span>

    ....
    <span class="codecomment">;etc.  add 16 to hero_y for the bottom two sprites</span>

    rts
    </code>
</pre>
<p>And in the NMI:</p>
<pre>
<code>    <span class="codecomment">;sprite DMA transfer</span>
    bit $2002
    lda #$00
    sta $2003
    lda #&gt;sprite_RAM
    sta $4014
    </code>
</pre>
<p>And she&#8217;s on the screen!</p>
<div id="attachment_128" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_sprite.jpg" alt="She&#039;s wearing green today." title="explorer_sprite" width="400" height="351" class="size-full wp-image-128" /><p class="wp-caption-text">She's wearing green today.</p></div>
<h2>Conclusion</h2>
<p>Today&#8217;s post was short and sweet.  Getting the hero sprite on the screen was pretty easy.  My next step is to change her direction based on joypad input.  See you then!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/23/explorer-7-sprite-time/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Explorer: 6 &#8211; Navigation and Input</title>
		<link>http://www.tummaigames.com/blog/2009/07/21/explorer-6-navigation-and-input/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/21/explorer-6-navigation-and-input/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:24:35 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=115</guid>
		<description><![CDATA[Now that I have the ability to make some rooms, and connect them together into floors, it would be nice if I had some mechanism to go from one room to another.  To do this, I will need some subroutines that will change the room coordinates in RAM and then load the new room. [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have the ability to make some rooms, and connect them together into floors, it would be nice if I had some mechanism to go from one room to another.  To do this, I will need some subroutines that will change the room coordinates in RAM and then load the new room.  This is really easy to code:</p>
<pre>
<code>move_east:
    ldx floor_roomx
    inx
    ldy floor_roomy
    jsr floor_load_room <span class="codecomment">;this subroutine takes coords in x and</span>
                        <span class="codecomment">;y and loads the room at those</span>
                        <span class="codecomment">;coordinates (within the same floor).</span>
    rts

move_west:
    ldx floor_roomx
    dex
    ldy floor_roomy
    jsr floor_load_room
    rts
</code>
</pre>
<p>Subroutines for moving north and south look similar.  But there&#8217;s room for improvement here.  Notice that I load the new room coordinates into x and y in both subroutines.   I can save some bytes if I shorten it up a little bit:</p>
<pre>
<code>move_west:
    dec floor_roomx <span class="codecomment">;current room x coord for the floor</span>
    jmp :+
move_east:
    inc floor_roomx
:
    ldx floor_roomx
    ldy floor_roomy
    jsr floor_load_room
    rts
</code>
</pre>
<p>If I really wanted to I could probably replace that JMP instruction with a BPL (branch if positive) and save an extra byte.  I&#8217;ll leave it how it is for now for readability.  I&#8217;ll save optimizations for the very end if I need them.</p>
<h2>Changing Floors</h2>
<p>Changing floors isn&#8217;t much harder.  First I&#8217;ll have to load the new floor, and then I&#8217;ll have to load a room within that floor.  Good thing I have the load_floor and load_room subroutines already written.  Having a good foundation to build upon makes things easy:</p>
<pre>
<code>floor_down:
    dec map_floor <span class="codecomment">;this var holds the current floor.</span>
    jmp :+
floor_up:
    inc map_floor
:
    lda map_floor
    jsr load_floor <span class="codecomment">;loads the floor, setting up room ptrs, etc</span>
    ldy floor_roomy
    ldx floor_roomx
    jsr floor_load_room
    rts
</code>
</pre>
<h2>Floor Boundaries</h2>
<p>The thing I need to watch out for now is the <strong>floor boundaries</strong>.  I don&#8217;t want to call <strong>move_west</strong> when I&#8217;m currently at x=0 or my game will try to load a room at x=FF, which probably isn&#8217;t there.  When the game tries to move west, I will want to check if <strong>x==0</strong> or not.  If it is, I will skip the call.  If the game tries to move east, I will want to check if x is equal to floor&#8217;s <strong>x-dimension &#8211; 1</strong>.  If I&#8217;m in the eastern-most room, skip the call.  Likewise for moving downstairs or upstairs.  I will want to check the current floor number against 0 or the top floor number, respectively.  </p>
<h2>Triggering a Room Change</h2>
<p>I have everything set up to change rooms.  Now I need something to trigger the room changes.  Most games trigger room changes based on sprite position/collision.  If the user moves their character sprite to the edge of the screen, change the room.  I haven&#8217;t coded sprite-support in yet, so for testing purposes I&#8217;m going to trigger room changes directly to the input.  Pressing right will move east.  Pressing down will move south.  Pressing left will move west.  Pressing up will move north.  I&#8217;ll use B and A for going downstairs and upstairs. </p>
<h2>Reading Input</h2>
<p>First I need a joypad reading routine.  The one I&#8217;m using is based off a really cool one that <a href="http://nesdev.parodius.com/bbs/viewtopic.php?p=42155#42155">blargg posted on a nesdev thread</a>.  It preserves both x and y.</p>
<pre>
<code>update_joypad_data: <span class="codecomment">;thanks to blargg for this A-only joypad</span>
                    <span class="codecomment">;read routine.</span>
    lda joypad1
    sta joypad1_old  <span class="codecomment">;save previous joypad data</span>
    lda #%01111111
    sta joypad1
    sta $4016
    asl a
    sta $4016
@loop:
    lda $4016
    and #$03  <span class="codecomment">;props to Disch for Famicon support</span>
    cmp #$01
    ror joypad1 <span class="codecomment">;right, left, down, up, start, select, B, A</span>
    bcs @loop

    lda joypad1_old
    eor #$FF
    and joypad1
    sta joypad1_pressed <span class="codecomment">;this tracks off-to-on transitions.</span>

    lda joypad1
    eor #$FF
    and joypad1_old
    sta joypad1_released <span class="codecomment">;this tracks on-to-off transitions</span>
    rts
</code>
</pre>
<p>For changing rooms I will want to check <strong>joypad1_pressed</strong>.  This variable tracks off-to-on transitions for the buttons.  Using <strong>joypad1_pressed</strong> instead of <strong>joypad1</strong> ensures that I will only move once per button press.</p>
<p>The joypad reading routine is called once per frame.  There are many frames in a second.  If the player presses up for a second, the variable <strong>joypad1</strong> will report an up press for each frame the button was held.  That&#8217;s a lot of ups.   <strong>joypad1_pressed</strong> will only report one up press &#8211; the first one.  I only want to move once per button-press, so I&#8217;ll check my input using <strong>joypad1_pressed</strong>.</p>
<p>So I read the joypad, then I perform actions based on the input.  If left was pressed I&#8217;ll check to make sure that our room x-coord isn&#8217;t 0, and then I&#8217;ll call <strong>move_west</strong>.  If up was pressed I&#8217;ll check to make sure our room y-coord isn&#8217;t 0, then call <strong>move_north</strong> if it isn&#8217;t.  ETC..</p>
<h2>Take a look</h2>
<p>I made a demo video showing room navigation.  I hope to make several videos like this as I code the game.  I think it will be cool to document the making of an NES game like this.  Anyway, take a look:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/S5s8LmuIFS4&#038;hl=en&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/S5s8LmuIFS4&#038;hl=en&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<h2>Conclusion</h2>
<p>Room navigation works great.  The next step is to put a movable sprite into the game and have room changes triggered by that sprite&#8217;s coordinates.  Then it will start to look like a real game!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/21/explorer-6-navigation-and-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explorer: 5 &#8211; Walls Again</title>
		<link>http://www.tummaigames.com/blog/2009/07/17/explorer-5-walls-again/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/17/explorer-5-walls-again/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 14:30:41 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=102</guid>
		<description><![CDATA[In my first post about Explorer&#8217;s room data format, I said that I used 4 bytes to store the wall/gap information for each room.  After some thinking, I realized that this was wasteful, as rooms will share wall data with their neighboring rooms.  For example, look at these two rooms:
They share a wall. [...]]]></description>
			<content:encoded><![CDATA[<p>In my first <a href="http://www.tummaigames.com/blog/2009/07/08/explorer-3-room-data/">post about Explorer&#8217;s room data format</a>, I said that I used 4 bytes to store the wall/gap information for each room.  After some thinking, I realized that this was wasteful, as rooms will share wall data with their neighboring rooms.  For example, look at these two rooms:</p>
<div id="attachment_104" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_wall_redundancy.JPG" alt="These two rooms share a wall." title="explorer_wall_redundancy" width="400" height="625" class="size-full wp-image-104" /><p class="wp-caption-text">These two rooms share a wall.</p></div>
<p>They share a wall.  The south wall of the top room is the same as the north wall of the bottom room.  With my old format, I&#8217;d be storing the data for this wall twice: once in the data for the top room and once in the data for the bottom room.  Not very efficient.  If you imagine a 3&#215;3 (9-room) floor you can see that the room in the middle will share ALL of its walls!  Yet here I am wasting 4 bytes of ROM space to declare them for that room.  </p>
<p>I was going to hold off on fixing this until later in the project, but <a href="http://robertlbryant.com/gaming/dev.htm">Roth</a> left a comment with a great idea for a solution.  Here&#8217;s what he said:</p>
<blockquote source="Roth"><p>About the data redundancy deal, I’m not quite sure how this could be approached off the top of my head, but what about making a separate map? For instance, I would guess that you have an overall table map that describes what room is what:</p>
<p>.db $30,$31,$20</p>
<p>or whatever. What if there was a second map, but it was a mapping of the openings?</p>
<p>.db %00100100, %00011000, %00011000, %00011000</p>
<p>So when you go into whatever room, read from that offset and subtract/add to get to be able to get all four sides maybe? </p></blockquote>
<p>This idea of <strong>separating the wall data completely from the room data</strong> was just what I was looking for!  Each floor would have a lookup table of wall bytes, and I&#8217;d index into it based on my room coordinates.  I worked it out on paper to see what kind of savings I could get and the difference was huge.</p>
<div id="attachment_105" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_wall_savings.JPG" alt="Yes, these are my actual notes." title="explorer_wall_savings" width="400" height="300" class="size-full wp-image-105" /><p class="wp-caption-text">These are my actual notes.  Look at the savings!</p></div>
<p>God forbid I ever make a floor with 400 rooms, but if I did I&#8217;d save myself 840 bytes on the wall data!  Assuming a square floor where &#8220;x&#8221; is the length of each dimension, the old method uses 4x^2 bytes to store all of the wall data.  The new method uses 2x^2 &#8211; 2x.  In other words, take 4x^2 and <strong>cut it in half</strong>, then <strong>subtract more</strong>!  50%+ savings.  Thanks Roth!</p>
<p>This method saves me on bytes in two ways:</p>
<ol>
<li><strong>redundant wall bytes</strong> &#8211; each wall is declared one time instead of two times.</li>
<li><strong>perimeter walls</strong> &#8211; since lookups are based on room coordinates, I can assume a solid wall if x=0 or y=0 or x=max_x or y=max_y.  I don&#8217;t have to store any perimeter walls!</li>
</ol>
<p>My test data has 3 floors.  Each floor is 3&#215;3 rooms.  My wall data dropped from 108 bytes to 36 bytes! :)</p>
<h2>Implementation</h2>
<p>I found that it was less headache to calculate indexes if I separated East-West walls from North-South walls and made two lookup tables for each floor.</p>
<div id="attachment_106" class="wp-caption aligncenter" style="width: 310px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_wall_table_index-300x225.jpg" alt="Click to enlarge." title="explorer_wall_table_index" width="300" height="225" class="size-medium wp-image-106" /><p class="wp-caption-text">Click to enlarge.</p></div>
<p>The cost of this approach is that I have to store pointers to two tables per floor instead of one, but I think the tradeoff is worth it at this stage.</p>
<p>Implementing this couldn&#8217;t be easier.  First I add wall table pointers to my floor data:</p>
<pre>
<code><span class="codecomment">;----------------</span>
<span class="codecomment">; floor data</span>
floor_map0:
    .byte $03, $03 <span class="codecomment">;dimensions of floor</span>
    <strong>.word floor0_ew_walls <span class="codecomment">;ptr to ew wall lookup table</span>
    .word floor0_ns_walls <span class="codecomment">;ptr to ns wall lookup table</span></strong>
    .word f0_r00, f0_r10, f0_r20 <span class="codecomment">;ptrs to room data</span>
    .word f0_r01, f0_r11, f0_r21
    .word f0_r02, f0_r12, f0_r22
</code>
</pre>
<p>Next I update my <strong>load_floor</strong> routine to read these new pointers and store them in RAM:</p>
<pre>
<code><span class="codecomment">;----------------</span>
<span class="codecomment">; load_floor expects the floor number in A</span>
load_floor:
    sta map_floor   <span class="codecomment">;current floor</span>
    asl
    tay
    lda map_ptr   <span class="codecomment">;this is a pointer to the floor lookup table</span>
    sta temp_ptr2
    lda map_ptr+1
    sta temp_ptr2+1

    lda (temp_ptr2), y   <span class="codecomment">;get the pointers to the floor data</span>
    sta floor_ptr
    sta temp_ptr1
    iny
    lda (temp_ptr2), y
    sta floor_ptr+1
    sta temp_ptr1+1

    ldy #$00     <span class="codecomment">;now let's read and set the floor's dimensions</span>
    lda (temp_ptr1), y
    sta floor_dim_x
    iny
    lda (temp_ptr1), y
    sta floor_dim_y
    iny

   <strong> lda (temp_ptr1), y <span class="codecomment">;store the ptrs to the wall tables</span>
    sta ew_walls_ptr
    iny
    lda (temp_ptr1), y
    sta ew_walls_ptr+1
    iny

    lda (temp_ptr1), y
    sta ns_walls_ptr
    iny
    lda (temp_ptr1), y
    sta ns_walls_ptr+1
    iny</strong>

    tya  <span class="codecomment">;update floor_ptr to the first room after the header</span>
    clc
    adc floor_ptr
    bcc @done
    inc floor_ptr+1
 @done:
    sta floor_ptr
    rts
</code>
</pre>
<p>Then I modify the wall-building routine to calculate indexes and read from the wall tables.  The last step is to reorganize my data: remove wall bytes from the individual room data and stick them in tables.  Very quick fix.</p>
<h2>Conclusion</h2>
<p>Separating the wall data from the room data is going to save me a lot of ROM space.  It also prevents the possibility of non-matching shared walls (I&#8217;m still entering all the data by hand, and I mistype from time to time).  It&#8217;s sped up the map-building process too.</p>
<p>Come to think of it, I might try to implement something similar for stairs.  Stairs_up and stairs_down need to line up on the z-axis.  In a way the ceilings and floors are like walls themselves, just with fewer openings (stairs) across the whole map.  I&#8217;ll save that battle for another day.</p>
<p>Thanks again Roth!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/17/explorer-5-walls-again/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Explorer: 4 &#8211; Inner Room Data</title>
		<link>http://www.tummaigames.com/blog/2009/07/14/explorer-4-inner-room-data/</link>
		<comments>http://www.tummaigames.com/blog/2009/07/14/explorer-4-inner-room-data/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 14:18:36 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Explorer]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=78</guid>
		<description><![CDATA[Last time I talked about how I store walls in my map data for Explorer.  Today I&#8217;m going to talk about how I store tiles for the room interior.
After the walls are put down, there is a 12&#215;11 field of floor space for me to work with for the room interior.  This picture [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I talked about <a href="http://www.tummaigames.com/blog/2009/07/08/explorer-3-room-data/">how I store walls in my map data</a> for Explorer.  Today I&#8217;m going to talk about how I store tiles for the <strong>room interior</strong>.</p>
<p>After the walls are put down, there is a <strong>12&#215;11 field of floor space</strong> for me to work with for the room interior.  This picture should make it clear:<br />
<div id="attachment_79" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_interior_grid.jpg" alt="The room interior is 12x11 metatiles big" title="explorer_interior_grid" width="400" height="312" class="size-full wp-image-79" /><p class="wp-caption-text">The room interior is 12x11 metatiles big</p></div></p>
<p>The basic way I place a tile on the map interior is with a <strong>coordinate byte</strong>.  A coordinate byte has the x-coordinate in the left nibble and the y-coordinate in the right nibble.  For example, let&#8217;s say I want to place a tile in the spot designated by the blue square in the following screenshot:</p>
<div id="attachment_80" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_interior_blue_square.jpg" alt="The blue square is at coordinate (8, 7)" title="explorer_interior_blue_square" width="400" height="312" class="size-full wp-image-80" /><p class="wp-caption-text">The blue square is at coordinate (8, 7)</p></div>
<p>This spot is 8 to the right and 7 down, so the coordinates would be (8,7).  The byte I use to represent this position is <strong>$87</strong>.  If I wanted to place a tile in the very top-left square, I&#8217;d use the byte $00.  The bottom-right-most square is $BA.  So using the values $00-$BA, I can represent any single position on the map interior.</p>
<p>It would be wasteful if I declared each and every tile one byte at a time.  I should try to save bytes by somehow compressing repeating data.  I currently do this by drawing lines.  After a coordinate byte in the room data, there can be an optional <strong>run byte</strong>.  A run byte tells the map engine which direction to draw a line and how many tiles long that line should be.  The <strong>left nibble</strong> represents the <strong>direction</strong>:</p>
<blockquote><p>C=Right<br />
D=<strong>D</strong>own<br />
E=L<strong>e</strong>ft<br />
F=Up.   (That&#8217;s F&#8217;ed up.)</p></blockquote>
<p>The <strong>right nibble</strong> tells <strong>how long</strong> the line should be.</p>
<p>For example, let&#8217;s say we are drawing block tiles.  In our room data we encounter the bytes: <strong>$11, $CA</strong>.   The first byte says &#8220;place a tile at (1,1).&#8221;  The second byte says &#8220;draw a line to the right, 10 tiles long.&#8221;  This screenshot shows the result of these two bytes:</p>
<div id="attachment_81" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_interior_line.jpg" alt="2 bytes make a line of tiles" title="explorer_interior_line" width="400" height="312" class="size-full wp-image-81" /><p class="wp-caption-text">2 bytes make a line of tiles</p></div>
<p>Run bytes can be tagged onto the end of other run bytes.  In this case, the starting point of the new line is the ending point of the previous line.  Check out these five bytes: <strong>$11, $CA, $D9, $EA, $F8</strong>.  If you were to translate these bytes into English, they&#8217;d say:</p>
<blockquote><p>&#8220;Place a tile at (1,1), then draw a line to the right, 10 tiles long.  Then draw a line down, 9 tiles long.  Then go left 10 tiles, and finally up 8 tiles.&#8221;</p></blockquote>
<p>The result:</p>
<div id="attachment_82" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_interior_box.jpg" alt="5 bytes makes a box" title="explorer_interior_box" width="400" height="312" class="size-full wp-image-82" /><p class="wp-caption-text">5 bytes makes a box</p></div>
<h2>Implementation</h2>
<p>My test data currently has 7 possible tiles it can use in the room interior.  They are:</p>
<pre>
<code>.enum
    floor
    wall
    block
    water
    block_breakable
    stairs_up
    stairs_down
.endenum
</code>
</pre>
<p>I store my room data as a series of <strong>strings</strong>.  The first byte in the string tells which tile to use.  Next comes a series of coordinate bytes and run bytes.  Finally, a string is terminated with $FF.   A list of strings is also terminated with $FF.  Here&#8217;s are some example strings:</p>
<pre>
<code>    .byte block, $11, $CA, $D9, $EA, $F8, $FF
    .byte water, $22, $C8, $D7, $E8, $F6, $C7, $D5, $E6, $F4
        .byte $C5, $D3, $FF
    .byte stairs_up, $00, $45, $FF
    .byte block_breakable, $02, $20, $FF
    .byte stairs_down, $BA, $66, $FF
    .byte $FF  <span class="codecomment">;no more strings</span>
    </code>
</pre>
<p>That data will generate this room interior:</p>
<div id="attachment_83" class="wp-caption aligncenter" style="width: 410px"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2009/07/explorer_interior_room.jpg" alt="A full room.  Careful, those steps might be slippery." title="explorer_interior_room" width="400" height="312" class="size-full wp-image-83" /><p class="wp-caption-text">A full room.  Careful, those steps might be slippery.</p></div>
<p>Here is my code that parses the inner room data.</p>
<pre>
<code>    ldy #$ff
@mainloop:
    iny
    lda (temp_ptr1), y  <span class="codecomment">;which tile?</span>
    cmp #$FF
    beq @end            <span class="codecomment">;FF terminates the room</span>
    sta map_temp1     <span class="codecomment">;store tile number in a temp variable</span>
    iny
    lda (temp_ptr1), y <span class="codecomment">;coordinate byte</span>
@innerloop:
    iny
    jsr calc_room_position <span class="codecomment">;will take the coords in A and </span>
                           <span class="codecomment">;calculate an offset, output in X</span>
    lda map_temp1    <span class="codecomment">;our tile number</span>
    sta room, x

@run_check_loop:
    lda (temp_ptr1), y  <span class="codecomment">;peek at the next byte</span>
    cmp #$FF
    beq @mainloop   <span class="codecomment">;FF terminates a tile string, so loop to </span>
                    <span class="codecomment">;the next tile string</span>
    cmp #$C0
    bcc @innerloop  <span class="codecomment">;if less than $C0, there is no tile run, </span>
                    <span class="codecomment">;so loop back to get a new coordinate byte</span>
    jsr tile_run  <span class="codecomment">;else we have a run.  This will take the </span>
                  <span class="codecomment">;run byte in A and draw a line in our RAM </span>
                  <span class="codecomment">;copy of the room.  We still have x loaded</span>
                  <span class="codecomment">;with our offset.</span>
    iny

    jmp @run_check_loop  <span class="codecomment">;check for another run byte</span>

@end:
    rts
</code>
</pre>
<h2>Conclusion</h2>
<p>I don&#8217;t know if this is the best way to do it, but it works!  I&#8217;m always looking to improve, so if you have any better ideas for compressing the room data, let me know in the comments!</p>
<p>Speaking of better ideas, Roth left <a href="http://www.tummaigames.com/blog/2009/07/08/explorer-3-room-data/comment-page-1/#comment-8">a comment on my last post</a> with a cool idea for saving bytes on my wall data.  I&#8217;m talking hundreds of bytes.  I&#8217;ve already implemented it and I&#8217;ll talk about it next time.  In the meantime, feel free to subscribe to <a href="http://tummaigames.com/blog/feed/">the RSS feed</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2009/07/14/explorer-4-inner-room-data/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
