<?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>More pies</title>
	<atom:link href="http://blog.evildro.me.uk/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.evildro.me.uk</link>
	<description></description>
	<lastBuildDate>Wed, 13 Jul 2011 18:32:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Randomisation</title>
		<link>http://blog.evildro.me.uk/?p=44</link>
		<comments>http://blog.evildro.me.uk/?p=44#comments</comments>
		<pubDate>Wed, 13 Jul 2011 18:32:51 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=44</guid>
		<description><![CDATA[I&#8217;ve been having a play with C# under Mono 2.6.7 on Ubuntu natty and over the last day I&#8217;ve been trying to work out why I get this when I try and generate a set of 500 random points in the screen area. Eventually I figured out why I was seeing strange patterns of points [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been having a play with C# under Mono 2.6.7 on Ubuntu natty and over the last day I&#8217;ve been trying to work out why I get this</p>
<p><a href="http://blog.evildro.me.uk/wp-content/uploads/blog.evildro.me.uk/2011/07/randomise-inside-loop.png"><img src="http://blog.evildro.me.uk/wp-content/uploads/blog.evildro.me.uk/2011/07/randomise-inside-loop-300x225.png" alt="" title="randomise inside loop" width="300" height="225" class="alignnone size-medium wp-image-47" /></a></p>
<p>when I try and generate a set of 500 random points in the screen area. Eventually I figured out why I was seeing strange patterns of points on the screen. Instead of 500 random points I expected.</p>
<p>The code for the broken version looked like<br />
<code><br />
</a>Vector2[] v= new Vector2[500]<br />
for (int i = 0; i < v.Length; i++)<br />
{<br />
  Random r = new Random();<br />
  v = new Vector2((float)(r.NextDouble() * Width), (float)(r.NextDouble() *Height));<br />
}<br />
</code></p>
<p>and the fixed version</p>
<p><code><br />
Vector2[] v= new Vector2[500]<br />
Random r = new Random();<br />
for (int i = 0; i < v.Length; i++)<br />
{<br />
  v = new Vector2((float)(r.NextDouble() * Width), (float)(r.NextDouble() *Height));<br />
}<br />
</code></p>
<p>It looks to me like the initial randomisation of the random number generator is a bit suspect.</p>
<p>Now I get this<br />
<a href="http://blog.evildro.me.uk/wp-content/uploads/blog.evildro.me.uk/2011/07/randomise-outside-loop.png"><img src="http://blog.evildro.me.uk/wp-content/uploads/blog.evildro.me.uk/2011/07/randomise-outside-loop-300x225.png" alt="" title="randomise outside loop" width="300" height="225" class="alignnone size-medium wp-image-48" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=44</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HDMI between a TV and a linux PC</title>
		<link>http://blog.evildro.me.uk/?p=41</link>
		<comments>http://blog.evildro.me.uk/?p=41#comments</comments>
		<pubDate>Tue, 12 Jul 2011 17:27:29 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=41</guid>
		<description><![CDATA[I had some issues getting my Linux based laptop (with HDMI output) to display anything on my LG TV. The laptop is running Ubuntu 11.04 (Natty Narwhal) and is based the ION chipset by nvidia. It turns out that the TV was trying to be far too clever. The TV requires both audio and video [...]]]></description>
			<content:encoded><![CDATA[<p>I had some issues getting my Linux based laptop (with HDMI output) to display anything on my LG TV.<br />
The laptop is running Ubuntu 11.04 (Natty Narwhal) and is based the ION chipset by nvidia.</p>
<p>It turns out that the TV was trying to be far too clever.</p>
<p>The TV requires both audio and video signals over HDMI to detect that the laptop is plugged in. Pulse audio will close any audio output devices if no sound is currently being played. This caused the TV to assume that because there&#8217;s no audio device sending it data it should report no signal.</p>
<p>To work around this I modified /etc/pulse/default.pa so that the suspend on idle module does not load.</p>
<p>Original:<br />
### Automatically suspend sinks/sources that become idle for too long<br />
load-module module-suspend-on-idle</p>
<p>New:<br />
### Automatically suspend sinks/sources that become idle for too long<br />
#load-module module-suspend-on-idle</p>
<p>This increases the CPU load slightly but if I can actually see something on the screen I&#8217;ll take the hit</p>
<p>The other issue I noticed was that fonts looked really odd until I set the input label to PC. I&#8217;m guessing it was doing some input processing before.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=41</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cross platform MSMC compatible software</title>
		<link>http://blog.evildro.me.uk/?p=35</link>
		<comments>http://blog.evildro.me.uk/?p=35#comments</comments>
		<pubDate>Thu, 28 Oct 2010 21:55:18 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[GameBoyAdvance]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=35</guid>
		<description><![CDATA[I&#8217;ve written a tool which is compatible with MSMC GBA multiboot cables but unlike the MSMC tool is written in Java and works under both Windows and Linux and probably other platforms with minimal modification. It doesn&#8217;t currently support the use of a bootloader so uploading anything more than a few K is going to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a tool which is compatible with MSMC GBA multiboot cables but unlike the MSMC tool is written in Java and works under both Windows and Linux and probably other platforms with minimal modification. It doesn&#8217;t currently support the use of a bootloader so uploading anything more than a few K is going to be slow.</p>
<p>I&#8217;ve reimplemented the upload tool so I took the time to separate out the GBA encryption and CRC logic so they&#8217;re both a lot more readable.</p>
<p>Its all licensed under the GPL and you can download it <a href="http://www.evildro.me.uk/files/blogfiles/gba/gbaupload-1.0.tar.gz">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=35</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Low stack usage mod replacement</title>
		<link>http://blog.evildro.me.uk/?p=28</link>
		<comments>http://blog.evildro.me.uk/?p=28#comments</comments>
		<pubDate>Fri, 04 Jun 2010 22:42:49 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Microcontroller]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=28</guid>
		<description><![CDATA[I was using an ATTiny2313 (128 bytes of ram) and started to run out of ram right at the end of a project and I was in a rush to finish (and didn&#8217;t want to buy more parts) so I thought I&#8217;s have a go at reducing ram usage. First I tried building with O3, [...]]]></description>
			<content:encoded><![CDATA[<p>I was using an ATTiny2313 (128 bytes of ram) and started to run out of ram right at the end of a project and I was in a rush to finish (and didn&#8217;t want to buy more parts) so I thought I&#8217;s have a go at reducing ram usage.</p>
<p>First I tried building with O3, inline functions and packed structures. This didn&#8217;t gain me enough ram so I had a look at what nm said was going on in the binary. The one chunk of the output which stood out was the following.</p>
<p><code><br />
0000072a T __divmodhi4<br />
0000072a T _div<br />
0000073e t __divmodhi4_neg2<br />
00000744 t __divmodhi4_exit<br />
00000746 t __divmodhi4_neg1<br />
00000750 T __udivmodhi4<br />
00000758 t __udivmodhi4_loop<br />
00000766 t __udivmodhi4_ep<br />
</code></p>
<p>GCC was inserting a load of division routines into the code as the chip doesn&#8217;t have the hardware to do division. I wasn&#8217;t doing any division in my code as such but I was using the mod operator for calculations in a ring buffer implementation. These routines which were causing registers to be pushed onto the stack along with return addresses. One ISR was pushing 14 registers onto the stack (partly because of this) along with the return addresses for the division functions.</p>
<p>To reduce stack usage I created a replacement macro for doing mod operations to avoid having to use the built in functions. All values used are unsigned values. This would need to be adapted to work on signed values and only works in my implementation because a is guaranteed to be less than 2b.</p>
<p><code><br />
#ifdef LSMOD<br />
#define MOD(a,b) \<br />
	((a>=b) ? a-b : a)<br />
#else<br />
#define MOD(a,b) \<br />
	(a % b)<br />
#endif<br />
</code></p>
<p>The resulting binary was a few bytes bigger (as it was output in multiple places unlike the function which was just called in multiple places) but only caused the ISR mentioned before to push 9 bytes onto the stack and it doesn&#8217;t call any other functions so no return addresses need to be stored. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GameBoyAdvance Multiboot Cable</title>
		<link>http://blog.evildro.me.uk/?p=21</link>
		<comments>http://blog.evildro.me.uk/?p=21#comments</comments>
		<pubDate>Wed, 17 Mar 2010 20:46:19 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[GameBoyAdvance]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=21</guid>
		<description><![CDATA[I was looking at arm dev boards and thought they were a bit expensive then noticed that a GameBoyAdvance was arm based, £5 and supported uploading programs over a strange 16 bit serial connection referred to as multiboot (the GBA used this for multiplayer games). After spending a lot of time trying to find somewhere [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking at arm dev boards and thought they were a bit expensive then noticed that a GameBoyAdvance was arm based, £5 and supported uploading programs over a strange 16 bit serial connection referred to as multiboot (the GBA used this for multiplayer games).</p>
<p>After spending a lot of time trying to find somewhere that either still sells a multiboot cable or good diagrams / documentation on the multiboot protocol or even code for making a multiboot cable which doesn&#8217;t require dos / a parallel port to upload data I stumbled across Matt&#8217;s Multiboot Serial Cable (http://www.axio.ms/projects/GBA/) which was one of the few sites which wasnt full of dead links.</p>
<p>The MSMC implements a smart serial cable (serial &lt;-&gt; microcontroller &lt;-&gt; GBA) to convert between standard 8 bit serial and the the GBA&#8217;s strange 16 bit serial format. The only slight problem being that it was written in asm for the 8051 and I didn&#8217;t have anything 8051 based. I did however have an arduino and several bare ATMega168 ICs in my parts box (the microcontroller code is ~ 1.5k so this overkill to a silly extent).</p>
<p>To cut a long story short I ported his microcontroller code (mainly using the comments) to my Arduino prototype board and now have it running on a bare atmega168 using the internal oscillator. I have also made a few tweaks to the upload tool.</p>
<p>Download the microcontroller code and upload tool <a href="http://www.evildro.me.uk/files/blogfiles/gba/MSMCcable-1.01.tar.bz2">here</a></p>
<p>To upload a GBA multiboot image using an arduino</p>
<ul>
<li> wire the GBA pins up to the arduino (instructions at the top of the source in the arduinocable directory)</li>
<li> flash the code in the arduinocable directory onto an arduino / atmega168</li>
<li> compile the upload tool and run gbl -p/dev/ttyUSB0 -d1 ./image.gba</li>
</ul>
<p>(Note: I haven&#8217;t tried it on anything other than an x86 box running ubuntu 9.10 but it works for me)</p>
<p>I&#8217;m thinking about adding a way upload code directly from the microcontroller to the GBA without the PC getting in the way. It should have enough spare flash for at least a 10k gba binary / I could read it from an SD card and is a shedload easier to get hold of than a writable GBA cart.</p>
<p>A big thanks to Matt Evans (<a href="http://axio.ms">http://axio.ms</a>) for writing the original and keeping the source on his website for nearly 8 years.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=21</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Additional resolutions available in mw3</title>
		<link>http://blog.evildro.me.uk/?p=16</link>
		<comments>http://blog.evildro.me.uk/?p=16#comments</comments>
		<pubDate>Wed, 19 Aug 2009 20:54:32 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[Mechwarrior]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=16</guid>
		<description><![CDATA[While I was doing some hacking on Mechwarrior 3 I realised that MW3 supports resolutions over the standard maximum of 1024&#215;768. These aren&#8217;t accessible from the menu but can be enabled by running (start->run) regedit and setting HKEY_CURRENT_USER\Software\MicroProse\Mechwarrior 3\1.0\InGameVMode to the following values 7 for 1024&#215;768 8 for 1152&#215;864 9 for 1280&#215;1024 a for 1600&#215;1200 [...]]]></description>
			<content:encoded><![CDATA[<p>While I was doing some hacking on Mechwarrior 3 I realised that MW3 supports resolutions over the standard maximum of 1024&#215;768. These aren&#8217;t accessible from the menu but can be enabled by running (start->run) regedit and setting  HKEY_CURRENT_USER\Software\MicroProse\Mechwarrior 3\1.0\InGameVMode to the following values</p>
<p>7 for 1024&#215;768<br />
8 for 1152&#215;864<br />
9 for 1280&#215;1024<br />
a for 1600&#215;1200</p>
<p>These do make the targeting bug I posted a fix for much worse and the game will crash if you press escape during a mission.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=16</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MW3 Targeting fix</title>
		<link>http://blog.evildro.me.uk/?p=3</link>
		<comments>http://blog.evildro.me.uk/?p=3#comments</comments>
		<pubDate>Wed, 05 Aug 2009 22:01:34 +0000</pubDate>
		<dc:creator>eaterofpies</dc:creator>
				<category><![CDATA[Mechwarrior]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[Mechwarrior 3]]></category>

		<guid isPermaLink="false">http://blog.evildro.me.uk/?p=3</guid>
		<description><![CDATA[A while ago I created a patched EXE for Mechwarrior 3 which worked around a bug in the game where it would try and draw a targeting box off the edge of the screen and crash the game. This was completely unmaintainable and didn&#8217;t work for some people so I went back to the drawing [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I created a patched EXE for Mechwarrior 3 which worked around a bug in the game where it would try and draw a targeting box off the edge of the screen and crash the game.</p>
<p>This was completely unmaintainable and didn&#8217;t work for some people so I went back to the drawing board and created a loader which injects a DLL into the EXE and replaces the dodgy bit of code.</p>
<p>Sadly the loader still doesnt appear to work for everyone so heres the fixed exe, loader+dll and source code for the loader+dll. The code is fairly horrific so if anyone wants to have a play and fix it please do.<br />
<a href="http://www.evildro.me.uk/files/blogfiles/mechwarrior/mw3Loader0.06.zip"><br />
Loader + src</a></p>
<p><a href="http://www.evildro.me.uk/files/blogfiles/mechwarrior/mw31.2fix1.5.zip">Fixed exe</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.evildro.me.uk/?feed=rss2&#038;p=3</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

