<?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; slots</title>
	<atom:link href="http://www.tummaigames.com/blog/tag/slots/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>Mon, 29 Nov 2010 15:32:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Ramses Game: 3 &#8211; Monster Sequences</title>
		<link>http://www.tummaigames.com/blog/2010/02/15/ramses-game-3-monster-sequences/</link>
		<comments>http://www.tummaigames.com/blog/2010/02/15/ramses-game-3-monster-sequences/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 15:59:06 +0000</pubDate>
		<dc:creator>Thomas</dc:creator>
				<category><![CDATA[Ramses Game]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[art]]></category>
		<category><![CDATA[attributes]]></category>
		<category><![CDATA[noise]]></category>
		<category><![CDATA[sequences]]></category>
		<category><![CDATA[slots]]></category>
		<category><![CDATA[sound effects]]></category>

		<guid isPermaLink="false">http://www.tummaigames.com/blog/?p=224</guid>
		<description><![CDATA[I wasn&#8217;t planning to post an update so soon, but this morning when I came into work I was told that my classes were cancelled for the day. This happens occasionally at the end of the school year and generally means that I have a full day at my desk to do whatever I want. [...]]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t planning to post an update so soon, but this morning when I came into work I was told that my classes were cancelled for the day.  This happens occasionally at the end of the school year and generally means that I have a full day at my desk to do whatever I want.  I was up late last night writing my <a href="http://www.tummaigames.com/blog/2010/02/14/ramses-game-2-reading-nes-button-combinations/">last post</a>, so NES programming was on my mind when I woke up in the morning.</p>
<h2>Sequences</h2>
<p>Today&#8217;s mission was to get <strong class="red">Sequences</strong> up and running.  A Sequence is a series of monster images at the top of the screen that indicates to the player what they should whack next.  I want the Sequence engine done before I start work on monsters.  It doesn&#8217;t make sense to do the monsters first.  The Sequence engine is like the backbone of the game.</p>
<p>Here&#8217;s what I needed for Sequences:</p>
<ul>
<li>An init routine that selects a starting Sequence based on Level/Sublevel.</li>
<li>A routine to draw a sequence to the screen</li>
<li>A routine to close an individual Slot and advance the engine to the next monster in the Sequence.  This includes some helper routines to update graphics.</li>
<li>A routine to select a (random) new Sequence after all Slots in the current Sequence are closed.</li>
</ul>
<h3>Graphics</h3>
<p>I decided to start by drawing a 16&#215;16 <strong>metatile</strong> to represent a closed slot.  I had time, so I took my time and ended up redrawing a lot of the dummy graphics for the Sequence Indicator:</p>
<div id="attachment_225" class="wp-caption alignleft" style="width: 266px"><a href="http://www.tummaigames.com/blog/wp-content/uploads/2010/02/unrom-0.png"><img src="http://www.tummaigames.com/blog/wp-content/uploads/2010/02/unrom-0.png" alt="Ramses Game - Sequence Indicator Graphics" title="Ramses Game - Sequence Indicator Graphics" width="256" height="224" class="size-full wp-image-225" /></a><p class="wp-caption-text">new graphics for the Sequence Indicator.</p></div>
<p>I went for a metal look to start because it is the easiest for me to draw.  For the final game I want to have several tilesets for different Level themes.  I&#8217;ve always sucked at art, so I was quite surprised and happy that my tiles ended up looking so good (to my eyes anyway).  I&#8217;m especially proud of my keyhole.</p>
<h3>Loading Sequences</h3>
<p>Loading a Sequence was pretty straight forward to code.  I have a table of pointers to tables of pointers to tables of pointers: Levels->Sublevels->Sequences.  Once I get down to the Sequences, I choose one randomly.  My random number generator is extremely basic: I merely increment a variable once per frame.  So far it does the job.</p>
<p>Each sequence is a series of bytes representing a monster ID.  Since Sequences can be of variable size (4, 5 or 6 monsters), I have a terminator ($FF) to signal to the engine when the Sequence ends.  Loading a sequence copies this series of bytes (including the terminator) to an array in RAM and sets an index variable to 0.</p>
<p>Drawing the sequence was pretty straight-forward too.  I cleverly designed the game board so that each Slot location corresponds to a 16&#215;16 square in the bottom-right quadrant of an attribute block.  This means that the only thing that differs between the 6 Slots as far as drawing is concerned is the low byte of the target PPU address.  Code is so much cleaner when everything lines up like this.</p>
<h3>Closing Slots</h3>
<p>Since there are no monsters yet, I have the game close a Slot every time a hole is whacked.  On the game logic level, all I have to do is increment the sequence index variable and check for the terminator.</p>
<p>Graphically it is no more complicated than drawing a monster image into a Slot.  At least it shouldn&#8217;t have been, but I got greedy and added a 3-frame animation.  It took me all day to finish as I had never done background animation before today, but it was good to get my hands dirty and figure it out.  I learned a lot.  As a final touch, I added a door-slam sound effect at the end of the animation, which incidentally forced me to code pitch envelopes for the <strong>noise channel</strong> into my sound engine.  Here&#8217;s the latest video:</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/7pArurZj3Ic&#038;hl=en_US&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7pArurZj3Ic&#038;hl=en_US&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<h2>Conclusion</h2>
<p>There are still some things I want to add the the Sequence engine.  I want to animate the Slots opening when a new Sequence is displayed.  I also need to add in some mechanism to advance Levels/Sublevels after a specified number of Sequences are cleared.  What I mean is if the player is on Level 1-1, and they knock off, say 8 Sequences, it sends them to level 1-2, which would have a different set of Sequences for the engine to choose from.  These features can wait for another day though, as I&#8217;m all Nintendo&#8217;d out for today.  </p>
<p>(BTW, Google is the ultimate word-usage authority: it&#8217;s &#8220;Nintendo&#8217;d out&#8221;, not &#8220;Nintendoed out&#8221;)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tummaigames.com/blog/2010/02/15/ramses-game-3-monster-sequences/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

