<?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>All Things IT Blog &#187; General Programming</title>
	<atom:link href="http://www.enusbaum.com/blog/category/general-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.enusbaum.com/blog</link>
	<description>My little nerded out corner of the Internets!</description>
	<lastBuildDate>Tue, 18 Oct 2011 20:22:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>ApocBot v0.0 &#8212; Open Source Magic Online Automated Trade Bot Released!</title>
		<link>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/</link>
		<comments>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/#comments</comments>
		<pubDate>Sat, 11 Dec 2010 16:05:10 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[General Software]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Magic Online]]></category>
		<category><![CDATA[ApocBot]]></category>
		<category><![CDATA[Automated Trading]]></category>
		<category><![CDATA[Magic The Gathering Online]]></category>
		<category><![CDATA[MTGO]]></category>
		<category><![CDATA[MTGO Trading Bot]]></category>
		<category><![CDATA[Trade Bot]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=407</guid>
		<description><![CDATA[For everyone who&#8217;s been waiting and searching, here it is: ApocBot v0.0 &#8212; The First (not completely working) Open Source MTGO Trade Bot written in C#/.NET! Now that the fanfare is over, let&#8217;s get down to the nitty-gritty. What was with the delay? The truth of the matter is that life just has a way [...]]]></description>
			<content:encoded><![CDATA[<p>For everyone who&#8217;s been waiting and searching, here it is:</p>
<div id="attachment_409" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/1389_ApocExpSymbol.jpg"><img class="size-medium wp-image-409" title="ApocBot" src="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/1389_ApocExpSymbol-300x279.jpg" alt="ApocBot" width="300" height="279" /></a><p class="wp-caption-text">ApocBot v0.0</p></div>
<h1>ApocBot v0.0 &#8212; The First (not completely working) Open Source MTGO Trade Bot written in C#/.NET!</h1>
<p>Now that the fanfare is over, let&#8217;s get down to the nitty-gritty.</p>
<h2>What was with the delay?</h2>
<p>The truth of the matter is that life just has a way of happening. My desire to play Magic The Gathering: Online waxes and wanes through the years and I started this project shortly after moving across the country. So you can say it was the product of my being bored in the evenings <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Over the course of a few months my interest in this project started to fade as I settled into my new job and had to travel a bit.</p>
<p>I had debated in my mind on how to handle the bot. I know over time it would be a maintenance nightmare as people would require support and updates, which is honestly why I decided to go Open Source with it. For some reason people feel that paying for software implies some form of support! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  In the end, I just stopped working on it because (a) MTGO is just a hobby, so I wasn&#8217;t looking to make money off the bot and (b) I didn&#8217;t want to have to constantly maintain and update the code to work with new versions/UI changes as they come out. That&#8217;s just the lazy bastard I am <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>That being said, I still feel this is an important project because it gives the community at large the ability to finally be more open about automation on MTGO (and possibly other games).</p>
<h2>So what shape is the code currently in?</h2>
<p>Out of the box, the code isn&#8217;t going to work. I&#8217;ll go into the details below on why/what needs to be updated to get it in running shape.</p>
<p>Other than updating some of the code to work with any UI/screen changes, it should still work pretty well! I know it worked the last time I tried to use it (six months ago?).. so I&#8217;m sure with some TLC, someone can get it up and running again.</p>
<h2>And it&#8217;s free?!</h2>
<p>Yep! Anyone is free to download and use the code for ApocBot in their own Magic Online Trading Bots as long as they adhere to the BSD License terms. If anyone is feeling giving, links back to my blog and some Magic Online gratitude would be appreciated! (My MTGO user name is &#8220;<strong>WndrBr3d</strong>&#8220;)</p>
<h1>Download:</h1>
<h4><em>ApocBot and the source code are released under the<strong> BSD License</strong>. Please review the included &#8220;<span style="text-decoration: underline;"><strong>license.txt</strong></span>&#8221; file for terms and conditions. For more information on the <strong>BSD Licenses</strong>, click <a title="OSI -- The BSD License" href="http://www.opensource.org/licenses/bsd-license.php" target="_self">here</a>.</em></h4>
<h1><strong><a href="http://www.enusbaum.com/blog/wp-content/uploads/2010/12/ApocBot.zip">ApocBot v0.0 (Source)</a></strong></h1>
<p><span style="text-decoration: underline;"><strong>Requirements:</strong></span> <strong>Visual Studio 2010</strong> and<strong> .NET 4.0</strong></p>
<p>And now.. the very rough technical details on how it works&#8230;</p>
<p><span id="more-407"></span></p>
<h2>How does it even work?!</h2>
<p>I followed the same basic idea as a lot of the <a title="Homepage -- AutoIT" href="http://www.autoitscript.com/autoit3/index.shtml" target="_blank">AutoIT</a> bots that are out there in the sense that I&#8217;m snapping screen shots and determining what&#8217;s on the screen by creating checksums of specified areas. I figured, <em>&#8220;Hey, if they can make it work in AutoIT, I&#8217;m sure I can make it work in C# even better!&#8221;</em></p>
<p>So using the idea of area checksums, ApocBot can identify what is currently being displayed on the screen and act appropriately.</p>
<p>The basic configuration for ApocBot to run was WindowsXP (Classic Theme) running at 1024&#215;768 (32-bit color depth).</p>
<h2>The Classes/Controllers</h2>
<h3>MTGOController.cs</h3>
<p>The MTGOController class holds the primary logic for ApocBot including the main program loop and all MTGO Object definitions.</p>
<p>On start up, all the MTGO Objects are defined. Currently these are all hard coded but I had planned to eventually move them all to an XML file and just have them <a title="MSDN -- XMLSerializer" href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.deserialize%28v=VS.100%29.aspx" target="_blank">deserialized</a> on start up (any takers on this? <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).. but for now, they&#8217;re all hard-coded.</p>
<p>After everything is setup, the main program loop will start. The basic function is this:</p>
<ol>
<li>Grab a screen shot</li>
<li>Determine the state of the bot (switch statement)</li>
<li>Based upon the state, check the screen for any known events/items to act upon</li>
<li>Sleep 250ms (to avoid CPU spike caused by constant screen polling)</li>
</ol>
<h3>ScreenController.cs</h3>
<p>The ScreenController class holds all the logic required to grab the screen shots and calculate the area checksums.</p>
<h3>MouseKeyboardController.cs</h3>
<p>The MouseKeyboardController class holds all the logic required to make mouse movements and send keys to the program. Hooks into the Windows API are used to simulate the mouse events to the OS.</p>
<h2>The Objects</h2>
<p>There are really three main objects used by ApocBot to know what&#8217;s going on:</p>
<ol>
<li><strong>MTGOScreen </strong>- Represents a screen in MTGO, such as the &#8220;Home&#8221; or &#8220;Trade&#8221; screens (Multiple Areas, Multiple Points)</li>
<li><strong>MTGOArea </strong>- Represents an area on a screen, such as a pop-up dialogue, card graphic or window (Multiple Points)</li>
<li><strong>MTGOPoint </strong>- Represents a point on the screen, such as an &#8220;OK&#8221; or &#8220;Cancel&#8221; button</li>
</ol>
<p>Objects are referenced in the system to main properties: <strong>Name </strong>and <strong>Checksum</strong>.</p>
<p>The checksums that are currently hard-coded might be out of date. You can generate new checksums using the AreaChecksum() method in the ScreenController.</p>
<hr />That&#8217;s it! I&#8217;ll be more than happy to answer any technical questions people might have about the code in the comments area of this post.</p>
<p>Almost forgot! It&#8217;s named &#8220;ApocBot&#8221; because Apocalypse was my favorite Magic: The Gathering expansion! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers!</p>
<div class="su-linkbox" id="post-407-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/&quot;&gt;ApocBot v0.0 &#8212; Open Source Magic Online Automated Trade Bot Released!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2010/12/apocbot-v0-0-magic-online-bot-released/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>.NET StringBuilder &#8212; Fast, but not as fast as you think!</title>
		<link>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/</link>
		<comments>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/#comments</comments>
		<pubDate>Thu, 28 May 2009 20:18:47 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft .NET 3.0 / WinFX]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[.NET Optimization]]></category>
		<category><![CDATA[.NET Profiler]]></category>
		<category><![CDATA[.NET Profiling]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[C# Optimization]]></category>
		<category><![CDATA[C# String Concatenation]]></category>
		<category><![CDATA[C# String Manipulation]]></category>
		<category><![CDATA[C# Strings]]></category>
		<category><![CDATA[StringBuilder]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=294</guid>
		<description><![CDATA[StringBuilder: Friend or Foe?]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a situation where I was tasked to profile some .NET code and do some optimizations anywhere hot spots popped up. I was amazed to find out that one of the BIGGEST offenders in our code block was a simple call to <strong>StringBuilder.Append(char)</strong>. I had to take a step back and scratch my head and wonder if my profiler was confused.</p>
<p>I re-ran some tests using the <strong>StopWatch</strong> class to hard code some metrics into the application and they also confirmed the findings. What&#8217;s up? How could a class that everyone says you can use to your hearts content when it came to string concatenation was failing me?</p>
<p>Turns out, it was a mix of misuse and a common misconception about the <a title="MSDN Documentation -- StringBuilder Class" href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" target="_blank">StringBuilder Class</a>.</p>
<p><span id="more-294"></span></p>
<p>One of the first things you learn while picking up .NET is that the <a title="MSDN Documentation -- StringBuilder Class" href="http://msdn.microsoft.com/en-us/library/system.text.stringbuilder.aspx" target="_blank">StringBuilder Class</a> is your friend when it comes to concatenating large strings in memory. It beats the pants off of <a title="MSDN Documentation -- String.Concat Method" href="http://msdn.microsoft.com/en-us/library/system.string.concat.aspx" target="_blank">String.Concat</a> and <a title="MSDN Documentation -- String.Format Method" href="http://msdn.microsoft.com/en-us/library/system.string.format.aspx" target="_blank">String.Format</a>, while also being a mutable object in the Framework utilizing an in-memory buffer.</p>
<p>I used <a title="Homepage -- JetBrains dotTrace Profiler" href="http://www.jetbrains.com/profiler/" target="_blank">JetBrains dotTrace</a> to help profile the application and it was very evident from the get-go that StringBuilder was causing the whole process to slow down.</p>
<p>The nature of my application was basically reading in a text buffer 1 character as a time, and using the <strong>StringBuilder</strong> as an output buffer. So for a 1k file, The method <strong>Append(char)</strong> would be called 1024 times. A 600k file would call <strong>Append(char)</strong> 614,400 times.</p>
<p>So why was I getting burned in execution time? The issue turned out to be two fold.</p>
<p>First, there&#8217;s overhead cost to the call. I don&#8217;t care how lightweight your method is, if you&#8217;re calling it <span style="text-decoration: underline;"><strong>SIX HUNDRED THOUSAND TIMES</strong></span>, it&#8217;s going to take a bit. Let alone a method who handles a string buffer in memory and string manipulation. So basically, no matter how fast StringBuilder actually is, it&#8217;s not a free call and you should consider the fact that the call still has overhead when architecting your solution.</p>
<p>Architecture brings me to my second point. While writing each character individually made sense initally, it seems that it was just lazy <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  The optimized route would have been calling Append with a SUBSTRING of the input buffer, this way we avoid the overhead of multiple calls by writing all the neccisary data in one big blob.</p>
<p>So 600,000 calls to <strong>StringBuilder.Append(char)</strong> becomes only a few hundred calls to <strong>StringBuilder.Append(string.Substring(start, count))</strong>. Sure, the Substring Virtual Method itself has overhead, but it&#8217;s still less than the thousands of calls to <strong>Append(char)</strong> that we&#8217;re saving ourself <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Conclusion?</p>
<p>StringBuilder is fast, but it&#8217;s not free. Take this into consideration when utilizing it while appending large data sets in small chunks. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Cheers!</p>
<div class="su-linkbox" id="post-294-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/&quot;&gt;.NET StringBuilder &#8212; Fast, but not as fast as you think!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/05/net-stringbuilder-fast-but-not-as-fast-as-you-think/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Example Huffman Compression Routine in C#</title>
		<link>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/</link>
		<comments>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/#comments</comments>
		<pubDate>Fri, 22 May 2009 21:17:04 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Data Compression]]></category>
		<category><![CDATA[Deflate]]></category>
		<category><![CDATA[GZip]]></category>
		<category><![CDATA[Huffman Coding]]></category>
		<category><![CDATA[Huffman Compression]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=285</guid>
		<description><![CDATA[This last week I decided to sit down and hash out a simple Huffman compression routine using C#. I&#8217;d never created a compression routine before from scratch (my past implementations were static for the sake of time savings), so I fleshed one out. I know that many examples exist elsewhere on the net&#8230;. but they [...]]]></description>
			<content:encoded><![CDATA[<p>This last week I decided to sit down and hash out a simple Huffman compression routine using C#. I&#8217;d never created a compression routine before from scratch (my past implementations were static for the sake of time savings), so I fleshed one out. I know that many examples exist elsewhere on the net&#8230;. but they all seemed overly complicated and up their own ass <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I had a couple goals in mind while creating my routine:</p>
<p><strong>1. KEEP IT SIMPLE</strong> &#8212; A lot of routines out there WORK, but their code is too overly complicated for their own good. This over complication leads to slowness which brings me to my next goal <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  It should be a simple class that accepts input data, with simple public accessors that are easy to understand even for the novice developer (sorry folks, no asynchronous delegates). <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p><strong>2. MAKE IT FAST</strong> &#8212; When dealing with large amounts of data in C#, especially when running it through an algorithm, it&#8217;s all too easy to use all the handy built in virtual methods or using other build in tools which make coding easier with speed being the sacrifice. Die hard C++ developers will point to these routines as C#&#8217;s downfall as a legitimate language when it comes to data intensive tasks.</p>
<p><span id="more-285"></span></p>
<p>The class I came up with is pretty simple. I use a Generic List to store a collection of &#8220;Leaf&#8221; objects, which have several basic attributes that help not only identify its value but also its place in the tree. Using this method, I was able to utilize the built in methods of the List object (I know, for shame&#8230;. but it&#8217;s easier in this instance) by firing off anonymous delegates for searches and comparators. I&#8217;m not terribly worried about using these virtual methods here only because the creation and encoding of the tree is usually the smallest task in the process <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The encoding and decoding is where I decided to focus on optimizations since this is where the BULK of the work is done. The .NET Framework has several methods that make working with binary data easy. You can use the Convert.ToString() method which allows you to pass in a BASE option, thus allowing you to convert any character to it&#8217;s binary representation. My original implementation used that method and the end result as embarrassingly slow <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>I went back to the drawing board and thought to myself, &#8220;If I had to re-write this in C++, how would I handle the encoding?&#8221; Duh, I&#8217;d be using bitwise operators up the wazoo! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>After some recoding and pulling my hair out for a couple of hours, I was able to re-write the routine using bit operations and it works! On top of all that, it&#8217;s fast as all get out! My current benchmarks had it encoding a 1MB data set in under 1 second with ~50% compression. Not too shabby! Of course, compression ratios will vary depending on how normalized the input data set is.</p>
<p>Now I&#8217;m sure there&#8217;s some question you have on your mind and I&#8217;ll try to address them now:</p>
<p><strong>Q: Does it use a lot of memory?</strong></p>
<p><strong>A:</strong> You bet your sweet ass it does! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Seriously though, it&#8217;s only the method in which I setup the class that requires the memory. I establish an input buffer within the class that you can write the &#8216;raw&#8217; data to, which is then read from during encoding. In addition, during encoding I create an output buffer in memory where the &#8216;encoded&#8217; data is written. So it stands to reason that if you&#8217;re encoding 100MB of data, this routine can easily gobble up 200MB of RAM or more. The rule of thumb I found was File Size * 4 would be the memory requirement. There&#8217;s optimizations you can make that would lower the memory footprint (like, build the frequency table without buffering then read the input 1 byte at a time, say from a file), but I felt that would over complicate the solution and make it too focused for one specific instance. The current implementation is kept general for a reason <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Q: Could this be done faster in C++?</strong></p>
<p><strong>A:</strong> Yes, probably&#8230;. but not much faster. Although the code is written in C#, at run time the IL is compiled to x86. The bit operations we&#8217;re using would compile the exact same as a C++ routine (XOR is XOR, I don&#8217;t care what language you&#8217;re using). In addition, the encoding of the data itself is only using primitive native types which limits any cross language differences. In fact, you can paste the encode and decode routines into C++ and they work! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Your only speed improvement might be in the generation of the tree itself&#8230; but even then, that&#8217;s super small overhead when compared with the amount of data you&#8217;re probably compressing.</p>
<p>Of course, all that applied to the Encoding (Compression) side of the house, the decompression routine is pretty slow (about 3 seconds per 1MB of decompressed data) and could probably use some more optimizations.</p>
<p><strong>Q: Is this any better than using the built in GZip or Deflate classes available in System.IO.Compression?</strong></p>
<p><strong>A:</strong> It&#8217;s not even close to being in competition with those routines <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' />  This is really just a proof of concept for BASIC Huffman Coding, which doesn&#8217;t take into account advanced features of modern compression routines such as pattern or content mapping. This routine is slower (especially in decompression), so I wouldn&#8217;t go making anything like this your #1 choice for a compression routine if others are available <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  So use this for educational purposes only.</p>
<p><strong>Q: What version of the .NET Framework will this work with?</strong></p>
<p><strong>A:</strong> The code here was written in Visual Studio 2008 targeting .NET 3.5. I use some Framework 3.5 specific things (such as object initializers), but nothing that would make conversion difficult. I avoided LINQ only because I&#8217;m not entirely sold on the idea and I still like using anonymous delegates. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  This code could be converted to Framework 2.0 with minor changes and possibly Framework 1.1, but that might require a little more effort.</p>
<p><strong>Q: What is the format used to store the compressed data?</strong></p>
<p><strong>A:</strong> I encode the decompression information within the final output stream. The output format is like this:</p>
<p>Bytes 0 &#8211; 8: Final Output Size (Not used, but there as a checksum if needed in the future)</p>
<p>Byte 9: Number of Bytes in the Decode Dictionary</p>
<p>Bytes 10 &#8211; n: Decode Dictionary</p>
<p>Between the Decode Dictionary and the actual data I add the characters &#8220;BCD&#8221; (which stands for <strong>B</strong>inary <strong>C</strong>oded <strong>D</strong>ata). This lets me know where the dictionary ends and the actual coded data begins. It helped during debugging and I figure it&#8217;d help anyone else out there as well while working with this routine <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Q: What&#8217;s with the essay? Just give me the code!</strong></p>
<p><strong>A:</strong> Fine! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Seriously though, the only reason I&#8217;m doing such a long write-up on the code is to help people who are perhaps beginning to look into this sort of code for the first time and might have questions on why I did things a certain way. Understanding WHY the code was written helps understand how it operates.</p>
<p>So that&#8217;s the high and low of it! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Hope this helps someone out and if you have any questions, please feel free to leave a comment!</p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Huffman.zip</strong> &#8211; <a title="Huffman Coding in C#" href="http://www.enusbaum.com/blog/wp-content/uploads/Huffman.zip">Download</a> (3k)</p>
<div class="su-linkbox" id="post-285-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/&quot;&gt;Example Huffman Compression Routine in C#&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2009/05/example-huffman-compression-routine-in-c/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>XBox 360 freezing while watching a DVD movie == SAD PANDA!</title>
		<link>http://www.enusbaum.com/blog/2008/09/xbox-360-freezing-while-watching-a-dvd-movie-sad-panda/</link>
		<comments>http://www.enusbaum.com/blog/2008/09/xbox-360-freezing-while-watching-a-dvd-movie-sad-panda/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 19:38:13 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=137</guid>
		<description><![CDATA[I&#8217;ve been on a minimalist kick recently regarding my home theater upgrading my receiver to an upscaling Denon AVR-2308CI receiver and then removing all components I never really use. Part of this process was eliminating a DVD player when my XBox 360 is (or at least should be!) capable of playing standard DVD movies. Sure, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been on a minimalist kick recently regarding my home theater upgrading my receiver to an upscaling Denon AVR-2308CI receiver and then removing all components I never really use. Part of this process was eliminating a DVD player when my XBox 360 is (or at least should be!) capable of playing standard DVD movies. Sure, it only puts out a 480p signal but the Denon handily upscales the incoming video to 720p for output to my TV.</p>
<p>Sounds simple, right? <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>So of course now when my wife and I actually sit down to play a DVD movie, randomly it&#8217;ll just freeze the picture and appear to lock up. It&#8217;s not a hard lock as my XBox still responds to IR commands (open/close the tray, power on/off). At first I suspected the Denon receiver as it is taking the video from the XBox in using component and scaling it out via HDMI. Multiple restarts and power on/offs of the receiver and the picture wouldn&#8217;t unfreeze meaning the XBox 360 itself had locked up.</p>
<p>What the hell! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>I&#8217;m sure there are some who are at this point thinking, &#8220;Your XBox is defective!&#8221;&#8230; I would completely and 100% agree (as I&#8217;m on my 3rd one), but I can play titles like Bad Company and Arcade games for hours with no problems, so I doubt it&#8217;s a hardware defect within the machine itself.</p>
<p>I suppose I&#8217;ll swallow a big ole&#8217; slice of humble pie tonight and call Microsoft Support, BUT, just in case they find nothing wrong I&#8217;m curious if anyone else has had this issue! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Thanks!</p>
<div class="su-linkbox" id="post-137-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/09/xbox-360-freezing-while-watching-a-dvd-movie-sad-panda/&quot;&gt;XBox 360 freezing while watching a DVD movie == SAD PANDA!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/09/xbox-360-freezing-while-watching-a-dvd-movie-sad-panda/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s take a dive into XCode and Objective-C!</title>
		<link>http://www.enusbaum.com/blog/2008/08/lets-take-a-dive-into-xcode-and-objective-c/</link>
		<comments>http://www.enusbaum.com/blog/2008/08/lets-take-a-dive-into-xcode-and-objective-c/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 02:46:29 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[General Software]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[iPhone SDK]]></category>
		<category><![CDATA[iTunes]]></category>
		<category><![CDATA[MacBook]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[Powerbook]]></category>
		<category><![CDATA[Winamp]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[XCode]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/?p=133</guid>
		<description><![CDATA[So, I&#8217;m diving into the pool! I recently purchased a MacBook Pro for the sole purpose of developing software for the Mac/iPhone platform. It&#8217;s completely unknown to me and currently the XCode IDE looks nothing if not completely confusing compared to the friently intuitive interface of Microsoft Visual Studio that I&#8217;m used to What brought [...]]]></description>
			<content:encoded><![CDATA[<p>So, I&#8217;m diving into the pool!</p>
<p>I recently purchased a MacBook Pro for the sole purpose of developing software for the Mac/iPhone platform. It&#8217;s completely unknown to me and currently the XCode IDE looks nothing if not completely confusing compared to the friently intuitive interface of Microsoft Visual Studio that I&#8217;m used to <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>What brought me to this point? Well, two things.</p>
<p>First, I&#8217;ve been wanting to dive into Objective-C for a little over a year now and started dabbling with it a while back on my old G4 Powerbook. I was impressed with the coolness of it, but being that I was developing on a G4 Powerbook, I was limited as by this time Apple had begun the mass migration to Intel based systems.</p>
<p>Second is that I want to develop applications for the iPhone. Not to make a mint or anything, more or less because I think I have some good ideas on programs people would use. Like how Apple provided the iTunes controller, well, hows about a WWWinamp controller for the iPhone? Perhaps one that lets you search your library locally on the iPhone without even connecting to WWWinamp?</p>
<p>I started down this path because there&#8217;s currently a program for sale on the iTunes App Store that lets you control your instance of WinAmp remotely&#8230; for $4.99!!! What the crap?! I was floored that the author would expect that kinda money for a program when there are PLENTY of other FREE alternatives out on the web (like WinAmp Remote, AjaxAmp or WWWinamp). I made it my mission to release a comparable program <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>It&#8217;s just going to take a month or so to ramp up on the new IDE and learn how to do SOAP calls and whatnot. Should be a fun adventure though! My wife begins the final semester of her Teaching Credential program in a couple weeks, so I&#8217;ll have four nights a week alone to myself to nerd out and gorge on Hot Pockets! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>I have another version of WWWinamp in the works as well. This is basically some code modernization for sections that I wrote over a year ago. Updating things to use Generic Methods and whatnot. You know, fun .NET stuff <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-133-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/08/lets-take-a-dive-into-xcode-and-objective-c/&quot;&gt;Let&#8217;s take a dive into XCode and Objective-C!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/08/lets-take-a-dive-into-xcode-and-objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WWWinamp v4.2 Build 2990</title>
		<link>http://www.enusbaum.com/blog/2008/03/wwwinamp-v42-build-2990/</link>
		<comments>http://www.enusbaum.com/blog/2008/03/wwwinamp-v42-build-2990/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 04:20:36 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[General Software]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[Shoutcast]]></category>
		<category><![CDATA[Winamp]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2008/03/09/wwwinamp-v42-build-2990/</guid>
		<description><![CDATA[Well, after about a week of off and on work the latest version of WWWinamp is ready! I&#8217;ve taken the &#8220;beta&#8221; tag off of it as it seems the recode of the HTTP request processing seemed to work without issue and no bugs were reported (other than the &#8216;paging&#8217; issue, which really was a defect [...]]]></description>
			<content:encoded><![CDATA[<p>Well, after about a week of off and on work the latest version of WWWinamp is ready!</p>
<p>I&#8217;ve taken the &#8220;beta&#8221; tag off of it as it seems the recode of the HTTP request processing seemed to work without issue and no bugs were reported (other than the &#8216;paging&#8217; issue, which really was a defect in the script parser).</p>
<p>Changes for this version are:</p>
<ul>
<li>[HTTP] Daemon will now start if a WinAmp instance is not found</li>
<li>[HTTP] Able to specify max number of HTTP threads to process (Default 25)</li>
<li>[Script Parser] Fixed &#8220;Paging&#8221; issue when searching through the Libary</li>
<li>[Script Parser] Script Files (*.wwa) will be run from the same folder as the file requesting them</li>
<li>WinAmp Handles will be updated if a new instance is detected</li>
</ul>
<p>Be sure to use the latest config file included with this release as it has a new key value, <strong>WWWinamp.HTTP.ListeningThreads</strong>, which tells the HTTP daemon how many threads to use max. This is set to 25 by default if no key is found, but it will throw an error. So if you don&#8217;t want to use the packaged configuration file because you&#8217;ve hacked together your own, you can manually add this key with any value you&#8217;d like.</p>
<p>This value isn&#8217;t a huge addition but it can help maintain system stability under heavy load. This way WWWinamp won&#8217;t spin up an infinite amount of threads if there&#8217;s heavy resource contention or there&#8217;s a problem that is causing threads to hang.</p>
<p>Also, the other &#8216;fixes&#8217; were requests made by? &#8216;dawolf&#8217; here in my blog so I suggest more people get involved and we can make WWWinamp better!</p>
<p>In addition, if you&#8217;ve made your own skin and want to share it, please feel free to contact me and I can post it here to my blog for others to use.</p>
<p>As for future releases, they may be a little slow in the coming month. I&#8217;m going to be diving into the iPhone SDK and Objective-C programming using XCode on my Apple. I think a remote media interface would be totally awsome if I can have a native WWWinamp application on the iPhone talk to the WWWinamp server using WCF/SOAP. It&#8217;d be way easier than using the webkit crap and I could make it have a lot more functionality (perhaps tuning in to a shoutcast stream VIA the iPhone?). Anyways, just thought I&#8217;d give you guys a little bit of information on that.</p>
<p>Cheers! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>WWWinamp v4.2 Build 2990</strong> &#8211; <a href="http://www.enusbaum.com/wwwinamp/WWWinamp42_build2990.zip" title="Download WWWinamp v4.2 Build 2990">Download</a> (56k)</p>
<div class="su-linkbox" id="post-95-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/03/wwwinamp-v42-build-2990/&quot;&gt;WWWinamp v4.2 Build 2990&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/03/wwwinamp-v42-build-2990/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>WWWinamp iPhone Compatible Skin &#8212; COMING SOON!</title>
		<link>http://www.enusbaum.com/blog/2008/02/wwwinamp-iphone-compatible-skin-coming-soon/</link>
		<comments>http://www.enusbaum.com/blog/2008/02/wwwinamp-iphone-compatible-skin-coming-soon/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 01:20:02 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[Webkit]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2008/02/01/wwwinamp-iphone-compatible-skin-coming-soon/</guid>
		<description><![CDATA[Ever since the Apple iPhone was released last year, I was blown away by the multimedia and browser capabilities of it. I started wondering from the get-go about the actual usefulness of a software development kit that only allowed for development of applications in a mobile browser. It was then announced that the official iPhone [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.enusbaum.com/blog//blog/wp-content/uploads/2008/02/wwwinamp_iphone1.thumbnail.jpg" alt="WWWinamp on the iPhone" align="left" height="123" width="91" />Ever since the Apple iPhone was released last year, I was blown away by the multimedia and browser capabilities of it. I started wondering from the get-go about the actual usefulness of a software development kit that only allowed for development of applications in a mobile browser.</p>
<p>It was then announced that the official iPhone SDK which runs natively on the iPhone will be released later this month. So soon you&#8217;ll have a host of local applications which will most likely include 3rd party media players. It then dawned on me, if a user could use WWWinamp from the iPhone with an interface that interacted nicely on the iPhone, then someone&#8217;s iPhone could act as a remote control from ANYWHERE allowing them access to their home media library.</p>
<p>Well, this is just a heads up that I&#8217;m currently working on a skin for WWWinamp that will let it work on the iPhone (better)! Soon you all will be able to control your media center or home copy of WWWinamp from anywhere using your Apple iPhone!</p>
<p>I&#8217;m still working on the organizing the data on the screen in a manner that makes sense and is easy to use. All the functionality that comes with the default skin will be included in the iPhone version, including cover art and all the Winamp Playlist functions.</p>
<p>It&#8217;s actually pretty sweet controlling Winamp from an Apple iPhone and I hope I can polish this up and put out a beta version this weekend. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I&#8217;m still trying to fish up some resources on the WebKit API and the WebKit specific tags to make things integrate nicely.</p>
<p>Keep your browsers posted here for updates in the coming days! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-86-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/02/wwwinamp-iphone-compatible-skin-coming-soon/&quot;&gt;WWWinamp iPhone Compatible Skin &#8212; COMING SOON!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/02/wwwinamp-iphone-compatible-skin-coming-soon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A new version of WWWinamp is coming&#8230; I SWEAR!</title>
		<link>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/</link>
		<comments>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 04:00:42 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft .NET 3.0 / WinFX]]></category>
		<category><![CDATA[WWWinamp]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2008/01/21/a-new-version-of-wwwinamp-is-coming-i-swear/</guid>
		<description><![CDATA[Hello Everyone! I&#8217;m currently working on the latest version of WWWinamp after taking another hiatus from the project in order to clear my head and work on some other fun things such as the previously mentioned XNA projects The next version of WWWinamp will be targeted for the .NET 3.5 Framework and you will need [...]]]></description>
			<content:encoded><![CDATA[<p>Hello Everyone!</p>
<p>I&#8217;m currently working on the latest version of WWWinamp after taking another hiatus from the project in order to clear my head and work on some other fun things such as the <a href="http://www.enusbaum.com/blog/2007/12/28/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/" title="2D WndrPong! using the Microsoft XNA Game Studio v2.0!" target="_blank">previously mentioned</a> XNA projects  <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The next version of WWWinamp will be targeted for the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=333325FD-AE52-4E35-B531-508D977D32A6&amp;displaylang=en" title="Microsoft .NET Framework 3.5" target="_blank">.NET 3.5 Framework</a> and you will need to have it installed on your machine in order to run WWWinamp. Most of the changes in this version are behind the scenes and will probably be transparent to you, the user. BUT, some visible changes in the upcoming version of WWWinamp 4.2 will be:</p>
<ul>
<li><strong>Automatic Version Checking for new releases of WWWinamp </strong></li>
<li><strong>Ability to enable or disable Automatic Version Checking  </strong></li>
<li><strong>Ability to enable or disable Windows Vista warning message<br />
</strong></li>
<li><strong>Improved performance under load</strong></li>
</ul>
<p>I know, nothing earth shattering on the horizon. &#8220;Why is this?&#8221; you might as. Well, the honest reason is that I haven&#8217;t received any bug reports with issues that weren&#8217;t related to a misconfiguration or user error. This is a good thing! It means that WWWinamp is stable and there aren&#8217;t any horrible bugs that continue to nag users. The downside to this is that because WWWinamp is pretty feature rich as is, I&#8217;m running low on ideas that could be implemented.</p>
<p>An idea I&#8217;ve tossed about and am thinking about trying out is creating a WWWinamp .NET assembly for user within your own Windows or ASP.NET applications developed using the .NET framework. The assembly would handle the media library and searching of the library so you wouldn&#8217;t have to code your own database and file searching routines, as well as handling the unmanaged code required to interface with <a href="http://www.winamp.com/" title="WinAmp -- It really whips the llamas ass!" target="_blank">Winamp</a> (if it&#8217;s running locally on the WWWinamp machine) or communicating via WCF to a remote instance of WWWinamp running the WCF daemon.</p>
<p>I think that between the WWWinamp Server and my proposed WWWinamp Assembly, that&#8217;d give both advanced and novice users full control over their setup. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>As I mentioned in a <a href="http://www.enusbaum.com/blog/2007/12/05/wwwinamp-is-being-converted-to-net-framework-v35/" title="WWWinamp is being converted to .NET Framework v3.5!" target="_blank">previous post</a>, I&#8217;ve moved WWWinamp into Visual Studio 2008 with Team Foundation Server. Within the latest version of Visual Studio 2008 there is a set of <a href="http://blogs.msdn.com/fxcop/archive/2007/02/28/announcing-visual-studio-code-metrics.aspx" title="Announcing Visual Studio Code Metrics!" target="_blank">code analysis tools</a> which calculate such items as Code Maintainability and Cyclomatic Complexity. I ran it on WWWinamp and it scored the following:</p>
<p><strong>Maintainability Index:</strong> 83 (out of 100)</p>
<p><strong>Cyclomatic Complexity:</strong> 636</p>
<p><strong>Depth of Inheritance:</strong> 7</p>
<p><strong>Class Coupling:</strong> 151</p>
<p><strong>Lines of Code:</strong> 1,829 (!!)</p>
<p>After over a year, I think WWWinamp has gotten better and continues to improve with every version!</p>
<p>Big thanks to everyone for their support and keep your eyes peeled here for the latest version of WWWinamp!</p>
<div class="su-linkbox" id="post-73-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/&quot;&gt;A new version of WWWinamp is coming&#8230; I SWEAR!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2008/01/a-new-version-of-wwwinamp-is-coming-i-swear/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>2D WndrPong! using the Microsoft XNA Game Studio v2.0!</title>
		<link>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/</link>
		<comments>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/#comments</comments>
		<pubDate>Sat, 29 Dec 2007 00:28:04 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[Gaming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[Microsoft XNA]]></category>
		<category><![CDATA[2D Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Game Programming]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Pong!]]></category>
		<category><![CDATA[XNA]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/12/28/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/</guid>
		<description><![CDATA[I decided to take some time this weekend to sit down and learn what I could about the latest release of Microsoft&#8217;s XNA Game Studio. I started out with a book I purchased called Microsoft XNA Game Studio Creators Guide, which turned out to be a terrible book. Most of the examples in this book [...]]]></description>
			<content:encoded><![CDATA[<p>I decided to take some time this weekend to sit down and learn what I could about the latest release of Microsoft&#8217;s <a href="http://www.xna.com/" title="Link -- Microsoft XNA Game Studio Website" target="_blank">XNA Game Studio</a>. I started out with a book I purchased called <a href="http://www.amazon.com/Microsoft%C2%AE-Game-Studio-Creators-Guide/dp/007149071X/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1198886266&amp;sr=8-1" title="Link to the worst book on XNA ever printed, ever." target="_blank">Microsoft XNA Game Studio Creators Guide</a>, which turned out to be a terrible book. Most of the examples in this book assume that you&#8217;re starting with a project the book provides on a Website, which already has hundreds of lines of code, custom shaders and everything built in&#8230; without even explaining how the code is working in the background.</p>
<p>After fumbling around with that for an hour or so an only succeeding in creating a small square on the screen, I headed over to Microsoft.com to see if any MSDN articles might exist to help me along in my &#8216;ground up&#8217; learning of XNA.  I was pleasantly surprised when I found a great article titled &#8220;<a href="http://msdn2.microsoft.com/en-us/library/bb203893.aspx" title="Best Starter Article ever for XNA :)" target="_blank">Your First Game: Microsoft XNA Game Studio in 2D</a>&#8220;. This was EXACTLY what I was looking for as it starts from the ground up, assuming the reader has never done game programming before, let alone 3D game programming. <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The example provided my Microsoft in this article is a simple 2D Texture of a cat that bounces around the window. I was so pleased with the ease of coding this, I thought to myself, &#8220;Heck, how hard could it be to recreate Pong?&#8221; <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  So I set upon my task.</p>
<p>Several hours and many Coca-Cola bottles later I had not only my first XNA game <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/wndrpong.thumbnail.gif" title="2D WndrPong! running in Windows" target="_blank">running in Windows</a>, but after purchasing the XNA Creators Club annual subscription from the XBox Live! marketplace for $99, I had it <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/wndrpong_tv.jpg" title="2D WndrPong! running on the XBox 360!" target="_blank">running on my XBox 360</a> as well <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  I decided to take a little extra time and add a debug information screen as well as a small welcome screen <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Controls (PC):</strong></p>
<p>Up/Down for Player 1 Paddle (Left): Q/A</p>
<p>Up/Down for Player 2 Paddle (Right): Up Arrow/Down Arrow</p>
<p>Debug Information: F1</p>
<p><strong>Controls (XBox 360):</strong></p>
<p>Up/Down for Player 1 Paddle (Left): Left Thumbstick on Player 1 Remote</p>
<p>Up/Down for Player 2 Paddle (Right): Left Thumbstick on Player 2 Remote</p>
<p>I did run into a couple of &#8216;gotchas!&#8217; while working with Game Studio. The major one I had trouble with was when you&#8217;re developing for the XBox 360 you have to account for <a href="http://en.wikipedia.org/wiki/Overscan" title="Link -- Wikipedia Article on Overscan" target="_blank">overscan</a> on the Television and have your game render within the &#8216;<a href="http://en.wikipedia.org/wiki/Safe_area" title="Link -- Wikipedia Article on Safe Area" target="_blank">Safe Area</a>&#8216;. I noticed that when I was playing my Pong! game on my LCD TV at 720p, the edges of the game were cut off and it looked like it was stretched past the borders of my TV. After asking the fine folks in #XNA on IRC about this issue, they were able to help me out. Now I have my Pong! game account for this by setting up an XBox 360 macro which pads the edges of the play area by 50 pixels.</p>
<p>I&#8217;m including the Source Code for my version of Pong! which I&#8217;ve titled, &#8220;2D WndrPong!&#8221;. You can work in XNA Game Studio for free using <a href="http://msdn2.microsoft.com/en-us/express/aa975050.aspx" title="Link -- Microsoft.com Visual C# 2005 Express Edition" target="_blank">Visual C# 2005 Express Edition</a> along with <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=DF80D533-BA87-40B4-ABE2-1EF12EA506B7&amp;displaylang=en" title="Link -- Microsoft.com XNA Game Studio 2.0 Install" target="_blank">XNA Game Studio 2.0</a> <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  To deploy your games to an XBox 360, you must pair your XBox with your PC  (using the &#8220;XNA Game Studio Device Center&#8221; tool)  then you must purchase an XNA Creators Club Membership from the XBox 360 Marketplace. I believe the prices are $49.99 for 3 Months, $99.99 for a year. I opted for the entire year since I know it&#8217;s going to take me some time to learn <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Baby Steps <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>2D WndrPong! Source Code</strong> &#8211; <a href="http://www.enusbaum.com/blog//blog/wp-content/uploads/2007/12/2d_wndrpong.zip" title="Link -- Download Link to 2D WndrPong!" target="_blank">Download</a> (36k)</p>
<div class="su-linkbox" id="post-69-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/&quot;&gt;2D WndrPong! using the Microsoft XNA Game Studio v2.0!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/12/2d-wndrpong-using-the-microsoft-xna-game-studio-v20/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WWWinamp is being converted to .NET Framework v3.5!</title>
		<link>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/</link>
		<comments>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/#comments</comments>
		<pubDate>Thu, 06 Dec 2007 05:17:32 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[C# Programming]]></category>
		<category><![CDATA[General Programming]]></category>
		<category><![CDATA[WWWinamp]]></category>
		<category><![CDATA[.NET 2008]]></category>
		<category><![CDATA[.NET 3.5]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Team Foundation Server 2008]]></category>
		<category><![CDATA[Visual Studio 2008]]></category>

		<guid isPermaLink="false">http://www.enusbaum.com/blog/2007/12/05/wwwinamp-is-being-converted-to-net-framework-v35/</guid>
		<description><![CDATA[Yep, it&#8217;s true! I&#8217;ve spent the last week or so playing around with the .NET Framework v3.5 and I really like what I see. Microsoft has also put a lot of work into Team Foundation Server 2008 as well. I&#8217;ve setup a Virtual Machine using Virtual PC here running Team Foundation Server 2008 on Windows [...]]]></description>
			<content:encoded><![CDATA[<p>Yep, it&#8217;s true!</p>
<p>I&#8217;ve spent the last week or so playing around with the .NET Framework v3.5 and I really like what I see. Microsoft has also put a lot of work into Team Foundation Server 2008 as well. I&#8217;ve setup a Virtual Machine using Virtual PC here running Team Foundation Server 2008 on Windows 2003 Server R2 and was able to get WWWinamp imported + converted without issue!</p>
<p>[zoomer]66|450|0|WWWinamp in Team Foundation Server 2008|1|0[/zoomer]</p>
<p>One thing I have noticed is that TFS does take up quite a bit of resources. I had to kick my VM up to 2GB of RAM in order for it to handle and build WWWinamp without hitting the swap file. Something to keep in mind moving forward I suppose. I&#8217;d imagine a large installation of TFS would require something along the lines of a Quad Core CPU with at least 4GB RAM.</p>
<p>There are several features in .NET 3.5 that I plan on implementing in WWWinamp right off the bat:</p>
<ul>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb384062(VS.90).aspx" title="MSDN -- Article on C# Object Initializers in .NET 3.5" target="_blank">Object Initializers</a> &#8211; This will really help clean up the already massive code base. It&#8217;ll also speed things up a bit <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb545961(VS.90).aspx" title="MSDN Article -- Embedded Manifests in C# .NET 3.5" target="_blank">Embedded Manifest</a> &#8211; A feature I&#8217;m surprised they didn&#8217;t implement with the release of .NET 3.0. Now the .manifest file will be embedded into WWWinamp, so you won&#8217;t have the extra file handing around if you run Windows Vista <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://msdn2.microsoft.com/en-us/library/bb383977(VS.90).aspx" title="MSDN Article -- Extension Methods in C# .NET 3.5" target="_blank">Extension Methods</a> &#8211; Again, this will help clean up the code base and make things faster. I imagine it&#8217;ll take up a little more memory, but these days RAM is abundant <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
</ul>
<p>Now, I see LinQ and I&#8217;m trying to figure out it&#8217;s role in everything. I think it&#8217;ll make DB communication easier but I&#8217;m not a fan of the anonymous data types and implicit local variables. I think it could lead to some sloppy coding methodology if not kept in check.</p>
<p>I think it&#8217;s handy that you can now run a SQL like statement on a generic, but I&#8217;m wondering what sets this apart from the <a href="http://msdn2.microsoft.com/en-us/library/fh1w7y8z.aspx" title="MSDN Article -- FindAll method in C# .NET 2.0" target="_blank">FindAll</a> method that already exists in <a href="http://msdn2.microsoft.com/en-us/library/system.collections.generic.aspx" title="MSDN Article -- System.Collections.Generics in C# .NET 2.0" target="_blank">System.Collection.Generics</a>. It does make it easier though to search through a Generic Collection for a developer who doesn&#8217;t have a solid grasp on delegates.</p>
<p>So, all that said, things are moving along. I&#8217;ll keep you all updated on the progress and please, send in those feature requests! <img src='http://www.enusbaum.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="su-linkbox" id="post-67-linkbox"><div class="su-linkbox-label">Link to this post!</div><div class="su-linkbox-field"><input type="text" value="&lt;a href=&quot;http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/&quot;&gt;WWWinamp is being converted to .NET Framework v3.5!&lt;/a&gt;" onclick="javascript:this.select()" readonly="readonly" style="width: 100%;" /></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.enusbaum.com/blog/2007/12/wwwinamp-is-being-converted-to-net-framework-v35/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

