<?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>fydo.net &#187; Misc</title>
	<atom:link href="http://fydo.net/category/misc/feed" rel="self" type="application/rss+xml" />
	<link>http://fydo.net</link>
	<description>On the Internet, nobody knows you&#039;re a cat.</description>
	<lastBuildDate>Fri, 28 May 2010 16:38:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>An oldschool game review</title>
		<link>http://fydo.net/personal/an-oldschool-game-review</link>
		<comments>http://fydo.net/personal/an-oldschool-game-review#comments</comments>
		<pubDate>Thu, 12 Feb 2009 21:46:41 +0000</pubDate>
		<dc:creator>fydo</dc:creator>
				<category><![CDATA[Game Dev]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://fydo.net/?p=215</guid>
		<description><![CDATA[I was poking around on the internet, and to my surprise, I stumbled upon a very old review that I wrote. For a Commodore 64 game released in 1990, developed by Domark, called Badlands. I thought it was pretty funny, not just because I happened to be only 13 years old when I wrote it, [...]]]></description>
			<content:encoded><![CDATA[<p>I was poking around on the internet, and to my surprise, I stumbled upon a very old review that I wrote. For a <a href="http://en.wikipedia.org/wiki/Commodore_64">Commodore 64</a> game released in 1990, developed by <a href="http://en.wikipedia.org/wiki/Domark">Domark</a>, called <a href="http://en.wikipedia.org/wiki/Badlands_(video_game)">Badlands</a>.<br />
I thought it was pretty funny, not just because I happened to be only 13 years old when I wrote it, but apparently the review is dated December 25th. I guess I spent some time on Christmas Day reviewing Commodore 64 games. Crazy.</p>
<p>Here&#8217;s the review:</p>
<blockquote><p>This game is great!! It&#8217;s racing mixed with weapons, and the ability to upgrade both your car and your weapons makes this game one of the best ones I&#8217;ve played so far. The control takes some getting used to, and the system that it uses for upgrading is a little hard to understand, but those are minor problems compared to the fun you can have with this one! If you only get one C64 game, make it this one.</p></blockquote>
<p>If you&#8217;re curious, the review can still be found at the <a href="http://area64.classicgaming.gamespy.com/index.htm">Area64 website</a> (look for Badlands in the Games section)</p>
]]></content:encoded>
			<wfw:commentRss>http://fydo.net/personal/an-oldschool-game-review/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>a tutorial on &#8216;dynamic&#8217; arrays in C</title>
		<link>http://fydo.net/gamedev/dynamic-arrays</link>
		<comments>http://fydo.net/gamedev/dynamic-arrays#comments</comments>
		<pubDate>Fri, 01 Feb 2008 14:12:20 +0000</pubDate>
		<dc:creator>fydo</dc:creator>
				<category><![CDATA[Game Dev]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays</guid>
		<description><![CDATA[UPDATE: Thanks for all the great comments! Apparently I&#8217;m the #1 result for &#8220;C dynamic array&#8221; on Google. Pretty cool. It&#8217;s certainly taken me a while to get around to it, but I&#8217;ve updated this tutorial and sample code to incorporate some of your suggestions and comments. Thanks a bunch, especially to bbulkow and tinkertim! [...]]]></description>
			<content:encoded><![CDATA[<p>UPDATE: Thanks for all the great comments! Apparently I&#8217;m the #1 result for &#8220;C dynamic array&#8221; on Google. Pretty cool. <img src='http://fydo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  It&#8217;s certainly taken me a while to get around to it, but I&#8217;ve updated this tutorial and sample code to incorporate some of your suggestions and comments. Thanks a bunch, especially to <a href="http://bbulkow.blogspot.com/">bbulkow</a> and <a href="http://echoreply.us/">tinkertim</a>!</p>
<p>For the purposes of education and the prospect of writing a new game, I&#8217;ve been doing some poking around in C. I&#8217;ve certainly learned a few things (and expect to learn more in the future) Prior to this, I&#8217;ve only had experience with C++, which some would argue is a completely different beast altogether. However, this post is not intended to discuss the differences between C and C++.</p>
<p>Anyways, I figured I might share a few snippets and wisdom that I&#8217;ve picked up along the way, so here&#8217;s a quick (?) rundown of how to use structs and pointers to create &#8220;dynamic&#8221; arrays that will resize as you need them.</p>
<p><span id="more-110"></span>Right, so let&#8217;s suppose you&#8217;ve got a struct built that you&#8217;ll use to hold some data&#8230;</p>
<pre>typedef struct {
    char *name;
    int number;
} DATA;</pre>
<p>And we&#8217;ll also need to set up an array, along with some variables to track how many items are in the array and how large the array is&#8230;</p>
<pre>DATA    *the_array = NULL;
int     num_elements = 0; // Keeps track of the number of elements used
int     num_allocated = 0; // This is essentially how large the array is</pre>
<p>What&#8217;s this? I&#8217;m not using []&#8216;s to define the size of the array? That&#8217;s right; At this point, the array is just a pointer. We&#8217;ll need to allocate memory for each entry into the array.</p>
<p>So next, we need a way to add items to our array that will be mindful of the fact that it is dynamic. What is needed is a function that will do three things:
<ul>
<li>Initialize the array if it is not already initialized.</li>
<li>Resize the array if more space is needed.</li>
<li>Add new items to the array.</li>
</ul>
<p>Keeping that in mind, let&#8217;s take a look at the <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/realloc.html">realloc function</a>&#8216;s prototype:</p>
<pre>void * realloc ( void * ptr, size_t size );</pre>
<p>The purpose of this function is to re-allocate memory to a pointer that already has memory allocated to it. Of course, you&#8217;ll only want to use it to make memory allocations larger, otherwise you&#8217;ll risk losing data. The size parameter is the amount of memory that you want to allocate. And the other parameter, ptr, is where you&#8217;d like to allocate it to. In this case, it&#8217;ll be the TheArray pointer that we&#8217;ve defined above. What is great about realloc is that if the ptr is NULL, the function will act just like malloc. This will allow us to use this one call for both initializing and resizing the array. Check this <a href="http://www.cplusplus.com/reference/clibrary/cstdlib/realloc.html">realloc reference page</a> for more information.</p>
<p>Here is my AddToArray function &#8230;</p>
<pre>int AddToArray (DATA item)
{
        if(num_elements == num_allocated) // Are more refs required?
        {
                // Feel free to change the initial number of refs
                // and the rate at which refs are allocated.
                if (num_allocated == 0)
                        num_allocated = 3; // Start off with 3 refs
                else
                        num_allocated *= 2; // Double the number
                                                    // of refs allocated

                // Make the reallocation transactional
                // by using a temporary variable first
                void *_tmp = realloc(the_array, (num_allocated * sizeof(DATA)));

                // If the reallocation didn't go so well,
                // inform the user and bail out
                if (!_tmp)
                {
                        fprintf(stderr, "ERROR: Couldn't realloc memory!\n");
                        return(-1);
                }

                // Things are looking good so far
                the_array = (DATA*)_tmp;
        }

        the_array[num_elements] = item;
        num_elements++;

        return num_elements;
}</pre>
<p>You can see that it performs all three requirements listed above.<br />
You may ask, &#8216;why is the allocation size doubling each time a resize is needed?&#8217;. This is done mainly because realloc() can be an expensive call, and if you spend a lot of time resizing your array, it could slow down the execution of your application. This way, it&#8217;s only done once in a while. Of course, feel free to fiddle with the initial allocation as well.</p>
<p>Also, be careful when using realloc(), as you&#8217;ll need to remember to use the free() function later on to free the memory that you&#8217;ve allocated to your program. You&#8217;ll want to run this code when you&#8217;re done using the array &#8230;</p>
<pre>// Deallocate!
free(TheArray);</pre>
<p>I&#8217;ve got a little example available right here:</p>
<p><font size="+1">Download Example &#8211; (<a href="/programming/arrays.c">arrays.c &#8211; 2kb</a>)</font></p>
<p>It compiles and runs just fine using <a href="http://gcc.gnu.org">GCC</a>, but I haven&#8217;t tried it with anything else, so your mileage may vary. Also, a huge special thanks to <a href="http://www.cyd.liu.se/~tompe573/hp/">DrPetter</a> and <a href="http://xout.blackened-interactive.com/">X-0ut</a> for their help on this subject!</p>
<p>As always, comments are welcome! <img src='http://fydo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fydo.net/gamedev/dynamic-arrays/feed</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
		<item>
		<title>Star Wars and Nerdiness</title>
		<link>http://fydo.net/personal/star-wars-and-nerdiness</link>
		<comments>http://fydo.net/personal/star-wars-and-nerdiness#comments</comments>
		<pubDate>Fri, 24 Aug 2007 21:53:35 +0000</pubDate>
		<dc:creator>fydo</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://fydo.net/personal/star-wars-and-nerdiness</guid>
		<description><![CDATA[Today, in the middle of an otherwise normal IRC conversation, I had the amazing idea of mixing Star Wars character names with programming languages! I could only the imagine the possibilities. I first enlisted the help of Wikipedia&#8217;s Alphabetical List of Programming Languages and Wikipedia&#8217;s List of Star Wars Characters and then got to work. [...]]]></description>
			<content:encoded><![CDATA[<p>Today, in the middle of an otherwise normal IRC conversation, I had the <strong>amazing</strong> idea of mixing <a href="http://www.starwars.com">Star Wars</a> character names with programming languages! I could only the imagine the possibilities.</p>
<p>I first enlisted the help of <a href="http://en.wikipedia.org/wiki/Alphabetical_list_of_programming_languages">Wikipedia&#8217;s Alphabetical List of Programming Languages</a> and <a href="http://en.wikipedia.org/wiki/List_of_Star_Wars_characters">Wikipedia&#8217;s List of Star Wars Characters</a> and then got to work. I&#8217;ve tried to stick to the more well known languages and characters, but there are a few obscurities.<br />
A friend, <a href="http://www.infinitepackets.com/">thinko</a>, also contributed some of these. <img src='http://fydo.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here are my results:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Darth_Vader">Darth</a> <a href="http://en.wikipedia.org/wiki/Ada_%28programming_language%29">Ada</a> (my favorite thus far)</li>
<li><a href="http://en.wikipedia.org/wiki/Han_Solo">Han</a> <a href="http://en.wikipedia.org/wiki/COBOL">COBOL</a> (he flies in his <a href="http://en.wikipedia.org/wiki/Millenium_Falcon">Millenium</a> <a href="http://en.wikipedia.org/wiki/Fortran">FORTRAN</a>!)</li>
<li><a href="http://en.wikipedia.org/wiki/Boba_Fett">Boba</a> <a href="http://en.wikipedia.org/wiki/Forth_%28programming_language%29">Forth</a></li>
<li><a href="http://en.wikipedia.org/wiki/Luke_Skywalker">Luke</a> <a href="http://en.wikipedia.org/wiki/Smalltalk">Smalltalk</a><a href="http://en.wikipedia.org/wiki/Luke_Skywalker">er</a></li>
<li><a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> <a href="http://en.wikipedia.org/wiki/Jabba_the_Hutt">the Hutt</a></li>
<li><a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Python</a> <a href="http://en.wikipedia.org/wiki/Padm%C3%A9_Amidala">Amidala</a></li>
<li><a href="http://en.wikipedia.org/wiki/QuakeC">QuakeC</a> <a href="http://en.wikipedia.org/wiki/Queen_Amidala">Amidala</a></li>
<li><a href="http://en.wikipedia.org/wiki/Chewbacca">Chew</a><a href="http://en.wikipedia.org/wiki/BASIC">BASIC</a> (I laughed pretty hard at this one)</li>
<li><a href="http://en.wikipedia.org/wiki/Mesa_programming_language">Mesa</a> <a href="http://en.wikipedia.org/wiki/Mace_Windu">Windu</a></li>
<li><a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java Java</a> <a href="http://en.wikipedia.org/wiki/Jar_Jar_Binks">Binks</a></li>
<li><a href="http://en.wikipedia.org/wiki/Oberon_programming_language">Oberon</a> <a href="http://en.wikipedia.org/wiki/Obi-Wan_Kenobi">Kenobi</a></li>
<li><a href="http://en.wikipedia.org/wiki/Ruby_programming_language">Ruby<a /></a><a href="http://en.wikipedia.org/wiki/R2-D2">-D2</a></li>
<li><a href="http://en.wikipedia.org/wiki/Cg_%28programming_language%29">Cg</a><a href="http://en.wikipedia.org/wiki/C-3PO">PO</a></li>
<li><a href="http://en.wikipedia.org/wiki/General_Grievous">General</a> <a href="http://en.wikipedia.org/wiki/Groovy_%28programming_language%29">Groovy</a>-<a href="http://en.wikipedia.org/wiki/General_Grievous">ous</a></li>
</ul>
<p>Here are some more additions, thanks to some of my readers!</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Python_%28programming_language%29">Py-thon</a> <a href="http://en.wikipedia.org/wiki/Qui-Gon_Jinn">Jinn</a></li>
<li><a href="http://en.wikipedia.org/wiki/Ada_%28programming_language%29">Ada</a><a href="http://en.wikipedia.org/wiki/Anakin_Skywalker">kin Skywalker</a></li>
<li><a href="http://en.wikipedia.org/wiki/Logo_%28programming_language%29">Logo</a><a href="http://en.wikipedia.org/wiki/Obi-Wan_Kenobi">-wan Kenobi</a></li>
<li><a href="http://en.wikipedia.org/wiki/Palpatine">Chancellor </a><a href="http://en.wikipedia.org/wiki/Perl">Perl</a><a href="http://en.wikipedia.org/wiki/Palpatine">patine</a></li>
<li><a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> <a href="http://en.wikipedia.org/wiki/Boba_Fett">Fett</a></li>
<li><a href="http://en.wikipedia.org/wiki/DBASE">dBASE</a> <a href="http://en.wikipedia.org/wiki/Mace_Windu">Windu</a></li>
<li><a href="http://en.wikipedia.org/wiki/Princess_Leia">Princess</a> <a href="http://en.wikipedia.org/wiki/Lua_programming_language">Lua</a></li>
<li><a href="http://en.wikipedia.org/wiki/Erlang_programming_language">Erlang</a>-<a href="http://en.wikipedia.org/wiki/Lando_Calrissian">do Calrissian</a></li>
<li>Also, Luke Smalltalker blew up the <a href="http://en.wikipedia.org/wiki/Delphi_%28programming_language%29">Delphi</a>-<a href="http://en.wikipedia.org/wiki/Death_star">star</a>!</li>
</ul>
<p>If you have any more/better suggestions, I&#8217;d love to hear them!</p>
]]></content:encoded>
			<wfw:commentRss>http://fydo.net/personal/star-wars-and-nerdiness/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I&#8217;ve been WordPresserized!</title>
		<link>http://fydo.net/misc/ive-been-wordpresserized</link>
		<comments>http://fydo.net/misc/ive-been-wordpresserized#comments</comments>
		<pubDate>Sat, 18 Aug 2007 07:01:05 +0000</pubDate>
		<dc:creator>fydo</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hey there, As you may notice, things are looking a little different around here. I&#8217;ve decided to start using some sensible blog software, so now I&#8217;ve got http://fydo.net running with WordPress. I imagine it&#8217;ll take me a couple days to get all my old content moved over and to edit/update the theme so it at [...]]]></description>
			<content:encoded><![CDATA[<p>Hey there,</p>
<p>As you may notice, things are looking a little different around here. I&#8217;ve decided to start using some sensible blog software, so now I&#8217;ve got <a href="http://fydo.net" title="fydo.net">http://fydo.net</a> running with WordPress.  I imagine it&#8217;ll take me a couple days to get all my old content moved over and to edit/update the theme so it at least somewhat resembles my old website.</p>
<p>In other news, I&#8217;ve also purchased <a href="http://fluffymenace.com" title="fluffymenace.com">fluffymenace.com</a> and <a href="http://fluffymenace.ca" title="fluffymenace.ca">fluffymenace.ca</a>. Only time will tell what the future will bring in regards to these two domains. If you&#8217;d like a slight hint, Fluffy Menace is the name of the team that I was in for the April 2007 pyweek. You can <a href="http://www.pyweek.org/e/f-m/" title="Fluffy Menace">see our page</a> for proof.</p>
<p>Edit: Something interesting I wanted to add: It was exactly 11 months ago when I moved my website from my homebrew blog-like php webapp to SimplePHPBlog and now I&#8217;ve moved to WordPress. It&#8217;s been a journey. Phew <img src='http://fydo.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://fydo.net/misc/ive-been-wordpresserized/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Complete Blogification!</title>
		<link>http://fydo.net/misc/complete-blogification</link>
		<comments>http://fydo.net/misc/complete-blogification#comments</comments>
		<pubDate>Tue, 19 Sep 2006 03:05:11 +0000</pubDate>
		<dc:creator>fydo</dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://fydo.net/misc/complete-blogification</guid>
		<description><![CDATA[Well, what do you think? My website is now a blog! I hope this new format will encourage me to post more often, resulting in a totally less boring website. I&#8217;m using Simple PHP Blog with a few of my own tweaks thrown in. As you may or may not be able to tell, I [...]]]></description>
			<content:encoded><![CDATA[<p>Well, what do you think? My website is now a blog! I hope this new format will encourage me to post more often, resulting in a totally less boring website. <img src='http://fydo.net/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I&#8217;m using <a href="http://sourceforge.net/projects/sphpblog/" title="Simple PHP Blog">Simple PHP Blog</a> with a few of my own tweaks thrown in.</p>
<p>As you may or may not be able to tell, I still have to import a lot of my content from my old website. I have even preserved some of my old news entries from the earlier years of my website.</p>
<p>Have fun and explore! Be sure to <a href="feed://http//fydo.net/feed" title="RSS Feed">subscribe to my RSS feed</a>! (located on the lower right corner of page)</p>
]]></content:encoded>
			<wfw:commentRss>http://fydo.net/misc/complete-blogification/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

