About

I'm Nicholas FitzRoy-Dale, a software developer from Sydney, Australia. I'm interested in embedded systems and operating system research, code optimisation, 8-bit music, rock climbing, shiny things...

Personal blog

Contact

Fri
Jan 27

UK keyboard layout with Swedish character support for Windows

I'm learning Swedish, but my keyboard doesn't have keys for å, ä, and ö. Most of the time I use a Mac and can get these letters relatively easily using the option key. On Windows it's not nearly so easy -- the common advice to get a å, for example, is to hold down alt and type 134. Might be okay if you only have to do it once, ludicrous otherwise.

Microsoft includes an alternative keyboard layout for international use, called UK Extended. UK Extended, it turns out, has been cleverly designed so as to be able to produce two-thirds of the letters I need.

So I built my own keyboard layout using Microsoft Keyboard Layout Creator. I just took the standard UK English keyboard and mapped Swedish keys to it, as follows:

  • å: AltGr + a
  • ä: AltGr + q
  • ö: AltGr + o

I'm not too happy about AltGr + q. If you've got a better suggestion let me know.

Here is the installer -- just run it, and then select the new keyboard layout from control panel (it's in the keyboard portion of regional settings):

UK keyboard with Swedish letters: sweuk.zip (248k)

Here is the keyboard source file for MKLC if you would like to build your own:

Source code for UK keyboard with Swedish letters: UK-Swe keyboard.klc (13k)

Lycka till!

Mon
Jan 2

A couple of things I learnt from Chaos Communication Congress #28 videos

  1. The key to sucess with cartesian genetic programming is a subtlety: the chosen child from the set of mutants should be as good as, or better than, its parent. You would think that it would be more efficient to always choose children which are better than their parents. This turns out not to be the case. By choosing children which are at least as good as their parents, we are allowing mutations to accumulate. This allows us to perform neutral search, in which we investigate several areas on the flat spot of the "fitness hill". If we don't do this, then we are relying on a single magic mutation to push us upwards. If instead we allow mutations to accumulate we don't have to rely on a single magic mutation, but instead can allow one mutation to activate several other accumulated mutations. (Automatic Algorithm Invention with a GPU)
  2. In Commodore 64 demos, you can use a counter to keep track of frame-by-frame jitter. However, in your interrupt service routine, you would normally have to examine the counter and then perform a computed jump, or do some other calculation, to perform different actions depending on the jitter value. This consumes a lot of cycles. Instead, you can set the interrupt service routine vector to be the jitter counter itself. When an interrupt occurs, the C64 will use the current value of the jitter counter as the location of the interrupt service routine. You can then put code in all locations in memory corresponding to the possible values of the jitter counter. (Behind the scenes of a C64 demo).
Thu
Dec 22

Jailbreak the Patriarchy

I ported Danielle Sucher's Jailbreak the Patriarchy to Safari.

You can download it here: Jailbreak the Patriarchy, version 1.

Please let me know if there are any issues: wzdd.code@lardcave.net. One known problem is that the toolbar icon doesn't change when you click it. I don't think you can actually do that in Safari.

Sat
Nov 19

Compiling clisp with Homebrew on Mac OS X Lion with XCode 4

LLVM in XCode 4 apparently doesn't define HAVE_STDBOOL_H. So, edit /usr/local/Library/Formula/clisp.rb and add the following line:

ENV['CFLAGS'] += ' -DHAVE_STDBOOL_H'

Put it somewhere after ENV.j1 in the install function.

Thu
Jul 7

Python: Throwing an exception into a generator

EDIT: Thanks to Andrew Bennets, this problem is solved -- Python supports exactly the feature I am after using the "throw" method of generator objects. Original post below for interest's sake.

I'm writing some code that uses an asynchronous coding style, using generators.

Here's how the code works:

def rpcClient():
    initialisation()

    result = yield someBlockingFunction
    doSomethingWith(result)

    result = yield someOtherBlockingFunction
    doSomethingWith(result)

Here, rpcClient does some initialisation. After initialisation, it would like to call someBlockingFunction, but it doesn't want to block. So, instead, it passes the name of the function to its caller, via yield. The function is then called somehow (details later). When the function returns, its return value is passed back to rpcClient as "result".

The problem with this scheme is: what happens if someBlockingFunction() raises an exception? What I would like to do is throw the exception back into rpcClient, so that (from the perspective of rpcClient) it looks like the yield itself generated the exception.

As far as I can tell, there isn't a way to do that. It's kind of unfortunate, because the method above is otherwise a very neat (as in, few LOC, relatively comprehensible) to handle blocking functions without "stack smashing" or introducing extra threads.

I can't even do something like define a function to do the yield for me, because in Python the decision about whether a function is a generator or not is made at compile time and is based on the presence of specific syntax (i.e. the word "yield").

(In my code, someBlockingFunction is actually an RPC call. When you call it, you pass a callback, which is then called when the function returns. So the code calling rpcClient can handle all that detail behind-the-scenes, without requiring the complexity of the RPC to "escape" into all RPC clients.)

Mon
Jun 20

Automating Quicktime Player 7's audio conversion

Here is a little AppleScript to use Quicktime Player 7 (on a Mac) to mass-convert a directory full of audio files from one format to another.

To use it, open it in Script Editor, change the "basedir" setting to whatever your directory of files is, and change "*.spx" to whatever glob pattern matches your input format.

It's based on http://ldopa.net/2008/05/23/batch-export-for-quicktime-pro/, but adds support for globbing and doesn't require you to move your files around.

Sun
Jun 19

King Battle!

I'm pleased to announce my first Gamejam game, King Battle!

King Battle is a split-screen platform game for 2 players. You and your friend must race your respective kings across a short scrolling platformer-like level to get the crown. Simultaneously, you must prevent your friend from getting to the crown before you do. In order to stop him, you can fire bullets at him. It turned out pretty well!

You start out in the level selection screen -- jump on a crown to select a level. You can return to this screen at any time by hitting ESC.

As you kill the other king, or when you get the crown, your score (upper right hand side) increases. When you get shot, or when you fall into a pit of razor-sharp spikes, your score decreases -- but it never goes below 0. A king's gotta have some pride.

Player 1 keys: A and D to move left and right; W to jump, left shift to accelerate / shoot bullets.

Player 2 keys: Arrow keys to move; up arrow to jump, right shift to accelerate / shoot bullets.

If it's easier, you can also use left alt and right alt to accelerate or shoot.

Download!

License

There are no restrictions on what you can do with King Battle's code and sound. You can do anything you like, up to and including selling it yourself without crediting me or providing source code (and good luck to you :). Some of the graphic files, however, require credit and links. Check the credits file (see below) for details.

Technical stuff

I wrote most of this game last weekend for a game jam. Unfortunately, I didn't finish it in time, so I spent this weekend polishing it up. This was my first gamejam, my first "real" game, my first use of the Love 2D framework, and my first real use of Lua (the language of Love). There are still lots of bugs and clunky sections, which I probably now won't have time to fix.

Even though I didn't finish in time, it's not that easy to come up with a game jam moral, such as "know your limitations" or "plan a very simple game". I already knew these things, and still didn't make it. Writing a game to a very tight deadline is not something you are going to know how to do in advance. My advice is just to try it, to (probably) fail, and to do it again.

Most of the problems I had were due to my being new to writing games, and new to the Love 2D framework, but I developed a legitimate dislike for Lua. It seems like it was developed by well-meaning people who then never actually used it. For example, retrieval from a dictionary always succeeds with the special value "nil". I never want this. Another interesting choice is that, in Lua, arrays start from 1. This is really silly, especially when you are dealing with, say, screen co-ordinates, which start from 0. Using 1-based indices also defies a fairly well-established convention for no good reason. Adding to the annoyance is that using a zero index works, and returns -- wait for it -- nil. There are various syntactic inconsistencies, especially around array construction. There is a special "length of array" operator, which works unless you want to store "nil" in your arrays -- if you want to do that, you have to use a special function instead. OO is very messy. And so on.

Credits

Here is a full list of credits. Thanks especially to Catie for level writing and play testing.

Feedback

I'd love to hear from you. If you want to tell me anything about King Battle, send email to wzdd lardcave net.

Fri
Jun 10

DIY USB-Serial Cable

Ever since I saw Minty Boost I knew that I wanted to make a small electronic device and put it in a funky case. Well, tonight I can finally sleep the untroubled sleep of one whose desires are fulfilled. Behold, the Tic Tac USB-Serial cable, Cherry Passion edition!

  1. Eat all the Tic Tacs.
  2. Assemble a USB Serial cable.
  3. Place the cable circuit board in the Tic Tac box. Add hot glue and masking tape for authenticity.

This uses the famous FTDI FT232RL chip to present a USB serial interface to a computer at one end, while presenting TTL-level serial lines on the other. I made mine mimic FTDI's standard cable, with a 6-socket header at the TTL end. (It contains transmit, receive, power, and flow control lines.)

The chip itself is only available in various surface-mount formats, so I prudently circumvented a fine-wire-soldering nightmare (and ensuing insanity) by purchasing a a 28-pin SSOP breakout.

Soldering surface mount components is easier than people claim as long as you douse the area in flux first, a technique I learnt from electronics wizard Dave Snowdon.

Speaking of dousing things in other things, I hope you are appreciating the hot glue job I did here.

Here is the device programming a Nanode.

Click images for larger versions.

Tue
Jan 25

The Huawei Ascend M860 Uses A Qualcomm MSM7625 System-On-Chip

I am working with this phone, also known as the Huawei Ascend, and it's been very hard to get good information about it. It is claimed to use at least three separate SOCs -- the MSM7201, the MSM7625, and the MSM7627.

Of course only of these can be true, and the truth is that it uses an MSM7625. This is the CDMA version of the MSM7225. Unlike the MSM7627, which has an Adreno 200 GPU onboard, the 7625 does not have an onboard GPU.

I suspected the M860 had the 7625 SOC because the onboard kernel configuration (in /proc/config.gz) indicates it, and because the only configuration that builds without modification in the Huawei-released kernel sources is for the 7625. But of course I couldn't be sure without taking the phone apart and photographing the chips, so that's what I did. I don't recommend you do this if you don't have to.

Part of the problem is that the phone is apparently overclocked to 600MHz from the standard 528MHz.

More photos: The whole board; The SOC (each file is around 1.5MB)

Fri
Jan 14

D-Link antenna boost


I recently hacked a beefier antenna into our D-Link DSL-2640R router, following this guide here. There was nothing complicated about it but I had to buy two things:

  1. A "U.FL to RP-SMA female" pigtail cable. I bought this one (ebay) for £2
  2. A beefier antenna. I bought this one (ebay) for £7.

Benefits: I can now watch Youtube videos on my iPad while lying in bed, I don't have to string cables into my study, and (hopefully) the XBox won't randomly stop streaming МУХА (video) songs from my desktop machine while I'm trying to beat da police.

More pics: 1: Look, it still works! 2: The back.

D-Link equipment sucks, but I made it suck less!

Newer entries | Older entries