<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Coding Naked in a Box of Rats</title>
	<atom:link href="http://codingnaked.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://codingnaked.wordpress.com</link>
	<description>My thoughts on programming</description>
	<lastBuildDate>Tue, 17 Nov 2009 07:15:14 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='codingnaked.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/8e132180019f9265b58fe8446d2cada4?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Coding Naked in a Box of Rats</title>
		<link>http://codingnaked.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://codingnaked.wordpress.com/osd.xml" title="Coding Naked in a Box of Rats" />
		<item>
		<title>DMPP Cymus &#8211; CIA emulation library</title>
		<link>http://codingnaked.wordpress.com/2009/11/16/dmpp-cymus-cia-emulation-library/</link>
		<comments>http://codingnaked.wordpress.com/2009/11/16/dmpp-cymus-cia-emulation-library/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 08:35:34 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Amiga]]></category>
		<category><![CDATA[DMPP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[6526]]></category>
		<category><![CDATA[8520]]></category>
		<category><![CDATA[cia]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=222</guid>
		<description><![CDATA[Now that I have a somewhat working M68000 emulation, I can finally focus on the rest of the Amiga system. Currently most of the system is stubbed out with a couple of dummy functions so I can see when something interesting happens.
I have reached now reached a point, where I can&#8217;t fake out the CIA [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=222&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Now that I have a somewhat working <a href="http://sourceforge.net/projects/mahatma68k">M68000 emulation</a>, I can finally focus on the rest of the Amiga system. Currently most of the system is stubbed out with a couple of dummy functions so I can see when something interesting happens.</p>
<p>I have reached now reached a point, where I can&#8217;t fake out the CIA functionality anymore, because the Amiga OS tries to use the timers and the TOD (Time-of-Day clock). Apropos TOD &#8211; in german the word &#8220;TOD&#8221; means &#8220;death&#8221;, so using that abbreviation in the source code gives me the shivers. In UAE&#8217;s CIA source code, I even found the words &#8220;TOD Hack&#8221; &#8211; which sounds to me like &#8220;chop to death&#8221; &#8211; (brrr ! horrible !).</p>
<p>However, I&#8217;ll stick with that word since &#8220;tz&#8221; (for &#8220;Tageszeit&#8221;) does not seem to be any better. I grabbed the MOS CIA 6526 datasheet linked from the Wikipedia article and the information from the Amiga HRM. As an additional reference, I am also looking into the CIA implementation of the MAME project (as I have done for the M68000 implementation). MAME  is a pretty large project, but from what I have seen so far, I really like the overall code quality and the CIA implementation is no exception.</p>
<p>From the combined information, I created a first class design:</p>
<p><a href="http://codingnaked.files.wordpress.com/2009/11/ciaclassdesign1.png"><img class="aligncenter size-full wp-image-242" title="CIA Detail Design" src="http://codingnaked.files.wordpress.com/2009/11/ciaclassdesign1.png?w=744&#038;h=570" alt="" width="744" height="570" /></a></p>
<p>&nbsp;</p>
<p>I find creating UML diagrams during software development very useful. I can verify and review the software design on different levels. When designing, I first create a rough draft and then try to verify it with a prototype (usually written in Ruby or Python) to get quick feedback, so I can feel how well it works. I then iterate a couple of times until the design seems to meet the requirements.</p>
<p>A while ago, I had created the project <a href="http://sourceforge.net/projects/dmpp">&#8220;Dream Machine Preservation Project&#8221;</a>, which I currently use as an incubator to experiment with a couple of ideas, which will hopefully one day lead to a full Amiga emulation.</p>
<p>The CIA library is the first thing I checked into the public git repository on Sourceforge. The implementation is still incomplete, because features are added as they are needed in the Amiga emulator. It was originally written in Scala, but when I decided to make a separate library out of it, I changed the implementation language to Java. This was mainly because I did not want to force users of the CIA library (assuming that there could be someone else besides me) to have to add the Scala library or having to know Scala in order to compile it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/222/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/222/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/222/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=222&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/11/16/dmpp-cymus-cia-emulation-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>

		<media:content url="http://codingnaked.files.wordpress.com/2009/11/ciaclassdesign1.png" medium="image">
			<media:title type="html">CIA Detail Design</media:title>
		</media:content>
	</item>
		<item>
		<title>Introducing the DMPP Amiga debugger</title>
		<link>http://codingnaked.wordpress.com/2009/11/11/introducing-the-dmpp-amiga-debugger/</link>
		<comments>http://codingnaked.wordpress.com/2009/11/11/introducing-the-dmpp-amiga-debugger/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 07:58:53 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Amiga]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mahatma68k]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=200</guid>
		<description><![CDATA[I had this actually running for some time now: It is a graphical debugger which helps me understand how the 68000 instructions in the Kickstart ROM affect my Amiga emulator&#8217;s state. Here is a screen shot:

It is currently mainly a view to the Mahatma68k CPU, the two CIA-8520&#8217;s and the custom chip registers. It can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=200&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I had this actually running for some time now: It is a graphical debugger which helps me understand how the 68000 instructions in the Kickstart ROM affect my Amiga emulator&#8217;s state. Here is a screen shot:</p>
<p style="text-align:center;"><img class="aligncenter size-full wp-image-210" title="DMPP Debugger" src="http://codingnaked.files.wordpress.com/2009/11/debugger_screenshot12.jpg?w=800&#038;h=559" alt="DMPP Debugger" width="800" height="559" /></p>
<p>It is currently mainly a view to the Mahatma68k CPU, the two CIA-8520&#8217;s and the custom chip registers. It can execute a defined number of steps and any changes to the chip registers or CPU state will show there. I am currently implementing a function which displays a tooltip for each custom chip register to show a little more information than just its numerical value. The CIA&#8217;s and the CPU have only a few registers, so it is still feasible to display the role of each flag in the main view. The sheer amount of custom chip registers however, made it even hard to get them all in one frame.<br />
By the way, compliments to the developers of Scala Swing &#8211; these are very nice wrappers ! I started with conventional Java Swing components and then realized that Scala Swing makes programming user interfaces much easier. As a long time user,  Swing does really seem to be all that difficult to me, still I like it when the code looks as tidy as it does when using Scala Swing.</p>
<p>What else is new today ? I have made my second file release to Mahatma68k today. As its main addition, it now comes with the Javadocs the distribution archive and made sure only to have the methods and classes in there that matter to the user of the library.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/200/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/200/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/200/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=200&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/11/11/introducing-the-dmpp-amiga-debugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>

		<media:content url="http://codingnaked.files.wordpress.com/2009/11/debugger_screenshot12.jpg" medium="image">
			<media:title type="html">DMPP Debugger</media:title>
		</media:content>
	</item>
		<item>
		<title>First file release for Mahatma68k</title>
		<link>http://codingnaked.wordpress.com/2009/11/09/first-file-release-for-mahatma68k/</link>
		<comments>http://codingnaked.wordpress.com/2009/11/09/first-file-release-for-mahatma68k/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 05:29:46 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Amiga]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mahatma68k]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=193</guid>
		<description><![CDATA[I decided to build a package of the current code in the Mahatma68k repository and upload it with the little example program that comes with it. It can now be found on its project website. I am aware that not everyone likes or knows maven and so I provided an ant build file for the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=193&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I decided to build a package of the current code in the Mahatma68k repository and upload it with the little example program that comes with it. It can now be found on its <a href="http://sourceforge.net/projects/mahatma68k">project website</a>. I am aware that not everyone likes or knows maven and so I provided an ant build file for the binary distribution. I like Maven a lot, and have therefore standardized all my builds on it, but it has a steeper learning curve.</p>
<p>I could have provided projects for Netbeans, Eclipse and IDEA, but I guess that this task is simple enough. For Mahatma68k, I wrote everything in Emacs and Vim by the way.</p>
<p>Oh yes, and finally, I have the most important reference manuals together that I will need for my emulation project:</p>
<div id="attachment_195" class="wp-caption aligncenter" style="width: 589px"><img class="size-full wp-image-195" title="Amiga Reference Manuals" src="http://codingnaked.files.wordpress.com/2009/11/reference_manuals_5001.jpg?w=579&#038;h=271" alt="Amiga Reference Manuals" width="579" height="271" /><p class="wp-caption-text">Amiga Reference Manuals</p></div>
<p>Of these, the &#8220;Amiga Hardware Reference Manual&#8221; is the most important, of course. I got the Exec Manual and &#8220;Libraries and Devices&#8221; as well (DOS and Intuition are coming, too), because I might be able to clarify some details in case I get stuck.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/193/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/193/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/193/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=193&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/11/09/first-file-release-for-mahatma68k/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>

		<media:content url="http://codingnaked.files.wordpress.com/2009/11/reference_manuals_5001.jpg" medium="image">
			<media:title type="html">Amiga Reference Manuals</media:title>
		</media:content>
	</item>
		<item>
		<title>Birth of a New Amiga Emulator</title>
		<link>http://codingnaked.wordpress.com/2009/11/04/birth-of-a-new-amiga-emulator/</link>
		<comments>http://codingnaked.wordpress.com/2009/11/04/birth-of-a-new-amiga-emulator/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 07:05:04 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Amiga]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mahatma68k]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[emulation]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=170</guid>
		<description><![CDATA[Do not take the title serious. As long as there is no release, this is strictly Vaporware(TM). Or something like that&#8230;. However, with the release of Mahatma68k, the likeliness of such a release has become somewhat more probable.
When I started the project, which has the current working title &#8220;I Heart Amiga&#8221;, it actually started as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=170&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Do not take the title serious. As long as there is no release, this is strictly Vaporware(TM). Or something like that&#8230;. However, with the release of <a href="http://www.sourceforge.net/projects/mahatma68k">Mahatma68k</a>, the likeliness of such a release has become somewhat more probable.</p>
<p>When I started the project, which has the current working title &#8220;I Heart Amiga&#8221;, it actually started as an attempt to make WinUAE&#8217;s features available in Unix versions. I have to admit it, I do not like C when it comes to writing a virtual machine. The abstraction level is simply too low and I like to look at a virtual machine as a system of components (a job for an object-oriented language). There is no sense for me to write a lot of extra code that has nothing to do with the problem. You can get it done in pure C, but then you could also use <a href="http://blogs.msdn.com/oldnewthing/archive/2009/11/02/9915989.aspx">Notepad to create whole web sites</a>.</p>
<p>I then had this crazy idea that the JVM might actually be fast enough nowadays to at least reach the performance of an Amiga 500 (something that has yet to be proven) and so I just kind of started hacking together some code in Scala. The nice thing about doing side projects is that you can just choose what you think suits the problem and I wanted a static JVM language (for performance), which allows me to avoid writing tons of boilerplate and &#8220;syntactical noise&#8221;. Scala seemed to be much more difficult than Java at first, but when I saw that the &#8220;difficult parts&#8221; were actually in the library and not part of the language, I realized that it is actually simpler. I like functional languages, but after having done the <a href="http://code.google.com/p/schmalz/">Z-machine in Erlang</a>, using a object-oriented language to implement a VM feels more natural to me.</p>
<p>The emulator is still in its early stages and I do not know how fast I will progress. However, I wanted to share some details of my current design, that might be useful to anyone who is trying to implement an Amiga.</p>
<p>The Amiga is the most fascinating computer system ever created. That&#8217;s why I am trying to implement it in software. You might think differently, but ask yourself: can you think of any other system that was years (released in 1985) ahead of its competition and yet those competitors slowly incorporated all of its features and eventually surpassed it in the nineties. I have a feeling that if the Amiga would have been an Apple brand, it would have probably been much more successful, but then, the competition would also have tried harder to catch up quicker. The way the Amiga was marketed, it did not really pose a threat to the established competition. That&#8217;s sad, but there are lessons to learn from that. We see everyday that technological excellence is not everything, and great marketing and business development can make up for not having the best product.</p>
<p>I digressed. I actually wanted to show the current system design of my emulator. Here is an UML diagram of it:</p>
<div id="attachment_172" class="wp-caption aligncenter" style="width: 858px"><img class="size-full wp-image-172" title="System Design of &quot;I Heart Amiga&quot;" src="http://codingnaked.files.wordpress.com/2009/11/systemdesign.png?w=848&#038;h=485" alt="System Design of &quot;I Heart Amiga&quot;" width="848" height="485" /><p class="wp-caption-text">Current System Design</p></div>
<p>I like to keep it simple and my approach for this project is to only add new components when it seems to be necessary. On ZMPP I admittedly got a little overboard and created more classes than I actually wanted to, which has to do with the TDD approach I took and especially my inexperience with TDD when I started ZMPP. This time, I did not use TDD (I did use a couple of unit tests to enhance my confidence on some tricky parts, though), but entirely focussed on understanding the problem and keeping it simple.</p>
<p>As you can see, this is currently a CPU and an address space which maps to the various system components.The Amiga uses memory-mapped I/O, and one of the most important concepts I had to learn as a non-Hardware person was <a href="http://en.wikipedia.org/wiki/Memory-mapped_I/O#Incomplete_address_decoding">&#8220;incomplete address decoding&#8221;</a>. As I have documented in the diagram, some system components respond outside of the documented addresses (e.g. Chip Memory if you have less than 1 MB and the Custom Chips). You could learn this by looking at UAE&#8217;s memory map, but I actually found out by looking at a <a href="http://wandel.ca/homepage/execdis/exec_disassembly.txt">disassembled Amiga Exec</a>. Finding the disassembled (and commented !) Exec source code was almost like having found the Rosetta Stone for me and I am grateful to Markus Wandel (I noticed that a lot of Amiga fans seem to be german !) for doing this hard work. So far, this has been one of my most important tools (besides the Hardware Reference Manual). I just kind of progressed by stepping through the ROM listing. I currently reached a point where I am outside of the commented part (probably dos.library and graphics.library). Getting this far gives me some confidence that my CPU emulation seems to work pretty well and that my memory mappings are working.</p>
<p>Some time ago, I purchased the Cloanto DVD set: &#8220;Amiga Forever&#8221;. Looking at the videos, I am fascinated by the passion, enthusiasm and the incredible skill that the original Amiga team had and I am inspired by that. Reading through the Amiga OS assembly code is an exciting experience as well. This is the beginning of a wonderful journey into computing history, and into the internals of a computer system that is unlike any other that has come before or after it.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=170&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/11/04/birth-of-a-new-amiga-emulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>

		<media:content url="http://codingnaked.files.wordpress.com/2009/11/systemdesign.png" medium="image">
			<media:title type="html">System Design of &#34;I Heart Amiga&#34;</media:title>
		</media:content>
	</item>
		<item>
		<title>Emulating the Motorola 68000 on the JVM</title>
		<link>http://codingnaked.wordpress.com/2009/10/30/emulating-the-motorola-68000-on-the-jvm/</link>
		<comments>http://codingnaked.wordpress.com/2009/10/30/emulating-the-motorola-68000-on-the-jvm/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 07:33:33 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mahatma68k]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[motorola 68000]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=162</guid>
		<description><![CDATA[I am currently trying to write an emulator for the Amiga, which is powered by a Motorola 68000 CPU. I initially started in C++, but switched to the JVM, for various reasons:

development on the JVM is much faster than in C++ and the performance penalty might be acceptable here compared to other non-native platforms
the license [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=162&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am currently trying to write an emulator for the Amiga, which is powered by a Motorola 68000 CPU. I initially started in C++, but switched to the JVM, for various reasons:</p>
<ul>
<li>development on the JVM is much faster than in C++ and the performance penalty might be acceptable here compared to other non-native platforms</li>
<li>the license of the CPU emulation library I used was not flexible enough for me</li>
</ul>
<p>I actually expected that I would find a suitable M68K emulation library for Java, but there seemed to be nothing that really fit my requirements. Because there is at least one person with a strong need for such a library (me), I decided to create one myself with the main goals:</p>
<ul>
<li>very liberal license (BSD)</li>
<li>fast and simple to use</li>
<li>easy to maintain</li>
</ul>
<p>I have created that <a href="http://sourceforge.net/projects/mahatma68k">project on Sourceforge</a>, and did my first checkin today.</p>
<p>There are no released files and the source is available in a git repository. It is basically a generator written in Ruby with a database containing information about the instructions (decoding, timing, output, execution), which is mostly defined as Ruby hashes. This approach is inspired by the emulation libraries as they are found in UAE or Musashi. The advantage is that the step for decoding the instruction is replaced by a simple lookup in an array, so that the CPU only has to evaluate the parameters and execute the instruction.</p>
<p>Execution times (which are necessary for my emulation) are also mostly pre-calulated: Because addressing modes are available at generation time, the generator can simply calculate the number from the timing database and put it in the generated source code. There are only a couple of exceptions, which are related to conditional execution (e.g. Bcc, Dbcc, privileged instructions&#8230;)</p>
<p>Another nice feature is that the decoded instruction objects &#8220;know&#8221; how to print themselves, which can be used to disassemble sections of code. This feature is optional, because it makes the code much larger.</p>
<p>With a generator approach I also can reduce one of my main pain points with the Java language: boilerplate. Writing tons of structurally similar code would tire me out and I&#8217;d be exhausted (and bored to death) before I actually write my Amiga emulator.</p>
<p>Currently the emulation can emulate 58 of the 76 instructions and I am adding a couple each day. There is some exception handling and support for traps and supervisor mode, and interrupts will be added shortly (because I need them).</p>
<p>I love the 68000 CPU, I really do. I am not a hardware expert, but I think, when it was released (1979), this processor must have been quite revolutionary. I just love how easy it was to program it (assembly code that did not make you go &#8220;cuckoo&#8221;), with a flat 24 bit address space and working in 32 bit internally. It&#8217;s nice that this project gives me an opportunity to study its design and history.</p>
<p>It is my hope that other people find this emulator useful in some way, I have tried to provide some help to make it easy to integrate in projects (maven build, example program, simple public interface).</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/162/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/162/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/162/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=162&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/10/30/emulating-the-motorola-68000-on-the-jvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
		<item>
		<title>Snow Leopard and Java compatibility issues</title>
		<link>http://codingnaked.wordpress.com/2009/08/30/snow-leopard-and-java-issues/</link>
		<comments>http://codingnaked.wordpress.com/2009/08/30/snow-leopard-and-java-issues/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 08:16:51 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[compatibility]]></category>
		<category><![CDATA[java 5]]></category>
		<category><![CDATA[java 6]]></category>
		<category><![CDATA[snow leopard]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=156</guid>
		<description><![CDATA[Contrary to my regular habits, I bought the latest update to Mac OS X, &#8220;Snow Leopard&#8221; on the first day of release. Our local Apple store opened early (I think around 8-ish) on the 28th and I picked up my copy as soon as I saw the doors opened.
The truth is, since the days of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=156&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Contrary to my regular habits, I bought the latest update to Mac OS X, &#8220;Snow Leopard&#8221; on the first day of release. Our local Apple store opened early (I think around 8-ish) on the 28th and I picked up my copy as soon as I saw the doors opened.</p>
<p>The truth is, since the days of the Amiga, I have not been as excited for an operating system release. My confidence in the quality that comes out Apple is also almost limitless, so I just popped the DVD into my computer and waited about an hour for the install to finish, hoping that there would be 7 GB magically reclaimed from my hard disk. I was wrong &#8211; it turned out to be a whopping 14 GB, which I thought was pretty impressive.</p>
<p>The next thing was for me to look for apparent problems, but apart from my &#8220;A Lot of Water&#8221; screen saver stopping to work (some changes to OpenGL in Snow Leopard might have caused this *sniff*), I did not notice any problems, just the &#8220;it just works&#8221; that I am used to from Apple. Well &#8211; until I started to do some development in Java. The Snow Leopard installation seems to remove  an installation of Java SE 5 and instead link the Java SE 6 version to it.</p>
<p>So what&#8217;s the problem, Java SE 6 is compatible to Java SE 5, some would say. Yes, almost. Unfortunately there are some incompatible changes in JDBC (in my case, the Connection interface) that requires me to work on a Java SE 5.</p>
<p>Luckily <a href="http://wiki.oneswarm.org/index.php/OS_X_10.6_Snow_Leopard">someone</a> had the same problem and has published a solution for that problem: The bottom line is to download a Leopard version of Java 5 and redirect the symbolic links to that downloaded version.</p>
<p>After following the instructions, I could continue working on my Java project as before.</p>
<p><strong>Update:</strong> I had another issue with maven even though I had already changed the version in Java Preferences. This could be fixed by adding a line</p>
<p>JAVA_VERSION=1.5</p>
<p>to the  ~/.mavenrc file.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/156/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/156/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/156/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=156&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/08/30/snow-leopard-and-java-issues/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
		<item>
		<title>Setting up maven for Scala and ProGuard</title>
		<link>http://codingnaked.wordpress.com/2009/08/07/setting-up-maven-for-scala-and-proguard/</link>
		<comments>http://codingnaked.wordpress.com/2009/08/07/setting-up-maven-for-scala-and-proguard/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 06:22:35 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Maven]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=133</guid>
		<description><![CDATA[I have started to use Scala occasionally since last year, it is less scary than it initially looked to me and thanks to good tool support (specs comes to my mind), it is even a joy to program in Scala.
What I initially found irritating though was the fact that the Scala library (despite running on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=133&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have started to use Scala occasionally since last year, it is less scary than it initially looked to me and thanks to good tool support (specs comes to my mind), it is even a joy to program in Scala.</p>
<p>What I initially found irritating though was the fact that the Scala library (despite running on a platform with one of largest standard libraries in existence) is huge &#8211; almost 3 megabytes in size &#8211; reminds me of my first &#8220;Hello world&#8221; written in Eiffel 15 years ago (that was about 4 MB). For applications to be run on the server one could simply say: who cares ? Still, I do write quite a bit of applications that are distributed over the Internet, be it applets, Webstart or Android applications and I strongly believe Scala is good for the server as well as the client side. For downloadable client applications, actually size does matter (at least to me).</p>
<p>Fortunately, there are tools that can strip out unused code from class files and further optimize the size of the generated jar files. <a href="http://proguard.sourceforge.net/">ProGuard</a>, which is Open Source, is such a tool and it even works for Android. Since I plan to replace Java with Scala as my main static JVM language (haven&#8217;t settled on the dynamic one, but so far, it looks good for Clojure), I fiddled a bit with a maven POM, that I can use as a template for my projects and thought I might share the relevant pieces that took me a bit of experimentation to get working. Maven 2 has now become my standard Java build tool, simply because I can generalize my builds a lot when working with JVM languages and they integrate well into my Hudson/git/jira/Eclipse environment.</p>
<p>I like my Java applications to be started with a simple java -jar &lt;jarfile&gt;, so I configured the maven-assembly-plugin to set the main class into the manifest file and linked it to the package phase in order to avoid that the assembly plugin would add my class files to the jar file <strong>twice</strong> (ProGuard complains about this) &#8211; therefore the assembly:single phase is invoked.</p>
<pre class="brush: xml;">
...
      &lt;!-- Assembly: jar-with-dependencies --&gt;
&lt;plugin&gt;
	&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
	&lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt;
	&lt;version&gt;2.2-beta-4&lt;/version&gt;
	&lt;configuration&gt;
	  &lt;descriptorRefs&gt;
	    &lt;descriptorRef&gt;jar-with-dependencies&lt;/descriptorRef&gt;
	  &lt;/descriptorRefs&gt;
	  &lt;archive&gt;
	    &lt;manifest&gt;
	      &lt;mainClass&gt;com.boxofrats.App&lt;/mainClass&gt;
	    &lt;/manifest&gt;
	  &lt;/archive&gt;
	&lt;/configuration&gt;
	&lt;executions&gt;
	  &lt;execution&gt;
	    &lt;id&gt;make-assembly&lt;/id&gt;
&lt;phase&gt;package&lt;/phase&gt;
	    &lt;goals&gt;&lt;goal&gt;single&lt;/goal&gt;&lt;/goals&gt;
	  &lt;/execution&gt;
	&lt;/executions&gt;
      &lt;/plugin&gt;
...
</pre>
<p>ProGuard is linked to the package phase as well and runs after the assembly goal. &lt;includeDependency&gt; is set to false to avoid warnings about duplicates, because we have already pulled the dependencies into the jar file in the assembly goal:</p>
<pre class="brush: xml;">
...
      &lt;!-- ProGuard --&gt;
&lt;plugin&gt;
	&lt;groupId&gt;com.pyx4me&lt;/groupId&gt;
	&lt;artifactId&gt;proguard-maven-plugin&lt;/artifactId&gt;
	&lt;executions&gt;
	  &lt;execution&gt;
&lt;phase&gt;package&lt;/phase&gt;
	    &lt;goals&gt;&lt;goal&gt;proguard&lt;/goal&gt;&lt;/goals&gt;
	  &lt;/execution&gt;
	&lt;/executions&gt;
	&lt;configuration&gt;
	  &lt;includeDependency&gt;false&lt;/includeDependency&gt;
	  &lt;injar&gt;${project.build.finalName}-jar-with-dependencies.jar&lt;/injar&gt;
	  &lt;outjar&gt;${project.build.finalName}-small.jar&lt;/outjar&gt;
&lt;proguardInclude&gt;${basedir}/proguard.conf&lt;/proguardInclude&gt;
	&lt;/configuration&gt;
      &lt;/plugin&gt;
...
</pre>
<p>My proguard.conf looks like this, note that this is a setup, for Mac OS X, where the JDK&#8217;s jar files are at a different location than on Windows, Solaris and Linux (they should be in $JAVA_HOME/lib/rt.jar:$JAVA_HOME/lib/jsse.jar):</p>
<pre class="brush: bash;">
-dontwarn
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-libraryjars /System/Library/Frameworks/JavaVM.framework/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Classes/jsse.jar
-keep class com.boxofrats.App {
  public static void main(java.lang.String[]);
}
</pre>
<p>When building application with mvn package, there is a significant reduction in size of the resulting jar file, which is exactly what I wanted. &#8220;Hello world&#8221; is about 3-4 K, but that&#8217;s of course not representative. The bottom line is: we do not have to carry around 3 megs of dead baggage, we just take what we need. Being able to create smaller applications makes development in Scala much more reasonable for mobile platforms.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/133/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/133/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/133/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=133&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/08/07/setting-up-maven-for-scala-and-proguard/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
		<item>
		<title>Migrating ZMPP to git</title>
		<link>http://codingnaked.wordpress.com/2009/08/06/migrating-zmpp-to-git/</link>
		<comments>http://codingnaked.wordpress.com/2009/08/06/migrating-zmpp-to-git/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 06:24:30 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[ZMPP]]></category>
		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=126</guid>
		<description><![CDATA[I did it. Finally I moved from Subversion to git. Until today, ZMPP was the
only larger project that was still in a Subversion repository.
To be fair, in the two years I used it for my projects, I have never really experienced
larger problems. It felt exactly like it was intended to be: A better, more modern [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=126&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">I did it. Finally I moved from Subversion to git. Until today, ZMPP was the</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">only larger project that was still in a Subversion repository.</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">To be fair, in the two years I used it for my projects, I have never really experienced</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">larger problems. It felt exactly like it was intended to be: A better, more modern CVS,</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">and it has great tool support as well, something where git could still improve.</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">Still, after using git in parallel to svn and cvs for about a year now, nothing really</div>
<div id="_mcePaste" style="position:absolute;left:-10000px;top:0;width:1px;height:1px;">beats the comfort working with a DVCS.</div>
<p>I did it. Finally I moved from Subversion to git. Until today, ZMPP was the only larger project maintained by me that was still in a Subversion repository. To be fair, in the two years I used it for my projects, I have never really experienced larger problems. It felt exactly like it was intended to be: A better, more modern CVS, and it has great tool support as well, something where git could still improve.</p>
<p>Still, after using git in parallel to svn and cvs for about a year now, nothing really beats the joy working with a DVCS, even when used solely through the command line. Personally, the way git handles branching and merging is perfect for me: it really invites one to make wild experiments. Another nice thing is that due to its decentralized nature, it is much easier for me to add ZMPP to my Hudson setup, work on my local copy and just push the changes to Sourceforge when I think they are good enough.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/126/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/126/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/126/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=126&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/08/06/migrating-zmpp-to-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
		<item>
		<title>A template for building Scheme applications for iPhone/Mac OS X in Xcode</title>
		<link>http://codingnaked.wordpress.com/2009/07/23/building-scheme-applications-for-iphonemac-os-x-in-xcode/</link>
		<comments>http://codingnaked.wordpress.com/2009/07/23/building-scheme-applications-for-iphonemac-os-x-in-xcode/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 08:42:47 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Box of Rats]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Scheme]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[software development]]></category>
		<category><![CDATA[iphone macosx xcode scheme build phase objective-c c++]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=80</guid>
		<description><![CDATA[I have often played with the idea of writing Mac and iPhone applications in Scheme, but as a result of not knowing the right compiler to embed (and lack of experience in Scheme), I could not execute on it. While programming in Objective-C is definitely doable (and of course you can use Objective-C++), I like [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=80&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I have often played with the idea of writing Mac and iPhone applications in Scheme, but as a result of not knowing the right compiler to embed (and lack of experience in Scheme), I could not execute on it. While programming in Objective-C is definitely doable (and of course you can use Objective-C++), I like to have more options for native application development.</p>
<p>Luckily, this month, there was <a href="http://jlongster.com/blog/2009/06/17/write-apps-iphone-scheme/" target="_self">one blog entry</a> about Gambit-C on the iPhone which was a great starting point (and James has since put out more interesting posts on the topic). In addition to the fantastic advice found there, I wanted a better integration within Xcode, since for now, it seems impossible to develop (legally) for the iPhone outside of the IDE (personally, I prefer setting up builds based on cmake and make them as cross-platform as possible). In particular, I wanted a build phase to compile from Scheme to C without having to invoke the Scheme compiler manually. I have created a template for this purpose for later use and have <a href="http://github.com/weiju/xcode-gambitc-templates/tree/master">put it on github</a> in case other people might be interested to use it. The source is released under the new BSD license, so feel free to experiment !</p>
<p>The principle used is similar to the one described in James blog &#8211; all Scheme modules defined in the project are compiled to C files and linked into a single executable. When using the Gambit-C compiler, one has to pay attention to the code that it generates: when linking statically, we need to:</p>
<ul>
<li>provide the -link switch to the compiler command</li>
<li>include all the Scheme source files we want to link into the executable</li>
</ul>
<p>If we would compile each file separately with the link option there would be a flat link file for each Scheme module and we would get linker errors due to duplicate symbols. Calling gsc with all the needed Scheme modules provides it with the necessary information to generate a single flat link file. The template assumes that all the Scheme files are in the scheme sub directory. In order to invoke the compiler with the correct parameters, I added an external target (a small Ruby build script) that scans the scheme directory and feeds it to the gsc command and it also includes a clean action that removes the generated C files.</p>
<p>To use the template in a different environment, the user simply needs to set the variable <code>GAMBITC_BASEPATH</code>, which could be as simple as <code>/usr/local</code>. This can be set either in the .MacOSX/environment.plist or the bash .profile script in the home directory. After a change to these, <strong>the user needs to log out and log in again</strong> so Xcode can recognize the change to the user settings. I personally prefer to install development tools somewhere in my home directory, which has the advantage that I can use different configurations and don&#8217;t pollute my system directories.</p>
<p>The contents of my personal GAMBITC_BASEPATH look like this:<br />
<code><br />
$(GAMBITC_BASEPATH)/Debug<br />
$(GAMBITC_BASEPATH)/Release<br />
$(GAMBITC_BASEPATH)/Debug-iphonesim<br />
$(GAMBITC_BASEPATH)/Release-iphonesim<br />
$(GAMBITC_BASEPATH)/Debug-iphoneos<br />
$(GAMBITC_BASEPATH)/Release-iphoneos</code></p>
<p>These are the directories that are the parameters to the &#8211;prefix option in the configure call when compiling gambit-c (see James&#8217; blog). In fact, I simply built a version for each platform (Mac OS X, iPhone Simulator and iPhone Device) and symlink&#8217;ed the directories to reflect the layout above, since I do not need separate Debug and Release versions for Gambit-C.</p>
<p>In the build rules for the main target, I added a dummy rule which specifies the output files of the &#8220;compile scheme&#8221; target. This is the only part that I find a little ugly, because whenever the list of Scheme modules changes, this list needs to be changed, so the C compiler can include these files in the builds. I still find this solution better than checking in generated files into version control or including C files in the project tree which do not exist.</p>
<p>The github repository contains templates for a Mac command line tool and one for an OpenGL ES application on the iPhone. Since I am a game developer, the OpenGL ES template is most useful to me, but it is pretty easy to adapt the setup for other kinds of iPhone (or Mac OS X) applications. The initialization point in my template differs from the one described in James Long&#8217;s blog: the main.mm is unmodified, instead, the Scheme system is initialized when the view is initialized, because that is the place where I currently pull up my engine.</p>
<p>Happy Hacking <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/80/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/80/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/80/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=80&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/07/23/building-scheme-applications-for-iphonemac-os-x-in-xcode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
		<item>
		<title>A &#8220;great&#8221; game idea</title>
		<link>http://codingnaked.wordpress.com/2009/06/18/a-great-game-idea/</link>
		<comments>http://codingnaked.wordpress.com/2009/06/18/a-great-game-idea/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 04:54:51 +0000</pubDate>
		<dc:creator>Wei-ju Wu</dc:creator>
				<category><![CDATA[Box of Rats]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://codingnaked.wordpress.com/?p=77</guid>
		<description><![CDATA[I am currently working on the core mechanics for my current game project. I had the idea that it could be used as a base for a quick implementation of an air hockey game. A search for &#8220;air hockey&#8221; in AppStore returned 14 air hockey games. Oh well, that was too simple&#8230;
    [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=77&subd=codingnaked&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I am currently working on the core mechanics for my current game project. I had the idea that it could be used as a base for a quick implementation of an air hockey game. A search for &#8220;air hockey&#8221; in AppStore returned 14 air hockey games. Oh well, that was too simple&#8230;</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/codingnaked.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/codingnaked.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/codingnaked.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/codingnaked.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/codingnaked.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/codingnaked.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/codingnaked.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/codingnaked.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/codingnaked.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/codingnaked.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=codingnaked.wordpress.com&blog=3632166&post=77&subd=codingnaked&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://codingnaked.wordpress.com/2009/06/18/a-great-game-idea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8ff0c47bd952dcc4e930f6d39bfcad84?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wei-ju</media:title>
		</media:content>
	</item>
	</channel>
</rss>