Wednesday, October 27, 2010

Stairways to Starways

For over ten years now, one of my favourite web-sites has been "The Stairway To Hell".  This web-site has been an invaluable resource to anyone who ever had a BBC Microcomputer or Acorn Electron in their youth. As well as being a fascinating site in its own right, it was also bolstered by a lively and interesting forum.

At the end of March this year Dave Moore, the web-master, decided it was time for a change. His initial plan was to replace the site with a new one - BBCMicro.com - that would be less focused on gaming.

He asked if I could provide an image to close the site down, and thought something similar to the kind of screen you got when you completed one of the Repton games might be nice.

I completed Repton 2 in the GNU/Linux port of the BBC Microcomputer emulator B-Em, screen grabbed the final screen:

Once was enough Tim!

I loaded the BBC Micro version Repton 1 into the screen memory in B-Em so I could cut and paste from the Repton1/2 font:

Repton 1 loaded into the screen memory

Now I used the letters from the Repton 1 screen to edit the Repton 2 screen in The GIMP to say what Dave wanted:

Pristine Screen

However, this didn't really look "retro" enough. The look I was going for was BBC B on badly tuned domestic telly with some interference.

So I ran this image through my own simulated PAL filter which I wrote in Python for The GIMP. Then I used some VHS noise that I extracted from a old recording of ATV Today using Grain Extract and then added it to the image using Grain Merge. I also added a Lens Distortion in The GIMP and desaturated the colours slightly.

Click to enlarge

I was delighted to find out that some people thought the image was actually a real screenshot.

A few months after this picture went up, Dave shelved his plans for BBCMicro.com. His work with the CGEU with organising shows such as R3PLAY and Acorn World meant that he no longer had the time to devote to creating a new site.

However, this wasn't the end, as Peter Edwards stepped in to carry on the good work with a new site called stardot.org.uk. He asked me to amend my image accordingly:

Click to enlarge

Sadly I didn't do such a good job on this image as I was in a hurry - it's a bit dark. But the most important thing is that the on-line Acorn community is thriving and stardot.org.uk looks destined for great things.

Saturday, October 23, 2010

Totally Bazaar

Well, after promising myself I'd get around to doing this long, long ago I've finally put my house (or should that be home?) in order and submitted my Projects folder to the discipline of a version control system.

Nautilus, but nice

I create a huge amount of work on various projects in the course of a year - much of which I blog about here. And I often go back and revisit files numerous times. But to err is human and sometimes I mess things up or find that my new version wasn't the improvement I'd hoped. Therefore I tend to create large numbers of back-ups just in case.

Up until now I've been using an ad hoc system of either backup folders or appending version numbers to the end of file-names. However this is messy, wasteful on disc space and prone to error. That's where a version control system comes in.

Even though version control systems are usually seen as a collaboration tool, they are also a really good idea for personal projects.

I'd actually chosen the version control system I wanted to use a couple of years ago - it's the extremely elegant Bazaar (or BZR), a free software project started by Canonical. The Bazaar project not only encourages personal use of version control - they even provide instructions especially for personal users.

There were three big attractions of Bazaar for me. The first is that it has a single command - bzr. The second is that it puts everything in a single folder /.bzr. I don't need a database or a server or anything like that. And the third is that it takes five minutes to learn. I actually use it from the command line, but there are graphical front ends for it too.

As most of my work these days is either in Python or Inkscape - which are both based on text files - there was no excuse for not using a version control system earlier.

Monday, October 18, 2010

Anchor Revisitation

A little while ago Gareth Randall dropped me a line to let me know he was going to use my Anchor typeface for one of his projects.

Gareth is an award winning promo maker, who I first got to know when was making trails and promotions for ITV.  He was one of the masterminds behind the final London Weekend Television start-up routine.

I was delighted to discover that the project Gareth had in mind was a promotion for the Doctor Who Revisitation Box set. Being a bit of a fan of Terrance Dicks and Robert Holmes this was a huge honour. So, here is Sharaz Jek trying to get Peri to suck his finger. I like to think it was my rather foxy typeface that got him in the mood...

Tight wad won't pay for a colour licence

Thursday, October 07, 2010

Lost In Translation

I've blogged a few times about ClapTraps, the ingenious free software puzzle game written in PyGame and Python by testpilotmonkey. The last time I blogged about it, I mentioned I was planning to add i18n (internationalisation) and a bit of l10n (localisation) to the game.

Claptraps in British English

In terms of internationalisation, what I wanted to do was to make the game multi-lingual so that on my daughters' computer, where they use Hungarian rather than English, they would be able to play the game in Hungarian.

I had been under the mistaken impression that all I needed to do to prepare a Python script for i18n was to import the gettext library and then surround all translatable strings with the function _().

It turned out to be a little bit more complicated than that. The reason was that I wanted ClapTraps to stay self contained in a single folder rather than force the user to install it.

ClapTraps' self-contained folder structure

Normally when GNU/Linux programs are installed on a computer, the compiled translation scripts are copied to a central location for access by all users of the computer. On Fedora GNU/Linux, that location is /usr/share/locale. Python always expects the compiled translation files to be stored there. However, I wanted my translations to remain in the ClapTraps folder.

It would have taken me quite some time to work out what to do if Mark Mruss had not already solved all the problems for me in his excellent blog post on translating Python/PyGTK programs. There's a fantastic snippet of code there called "Translation stuff" that magically does it all!

The next step, now I had the Python script prepared, was to generate a POT (Portable Object Template) file. The POT file is the template file from which individual translations can be prepared.

The POT file for ClapTraps

It contains a header, then a list which shows the line a translatable string appears in, the id of the translatable string, and a space for the translation.

I found one problem when first creating my POT file was that it only had five strings in it! The reason was that testpilotmonkey had used single quotes for most of his strings but xgettext, the tool you use to create a POT file, only recognises double quotes.

From my POT file, I used the msginit tool to create two PO (Portable Object) files - one for en_GB (British English), the other for hu (Hungarian). Now came the really hard part - the Hungarian translation! I did this myself, but it took me three days until I was happy. The main problem was my difficulty with the imperative mood in Hungarian. Fortunately the excellent website HungarianReference.com helped enormously. My Hungarian is still a bit dodgy, but I like to think that adds to the charm.

Finished PO file with Hungarian translation

Now all I needed to do was compile my PO files in MO files and I could see if it worked. To test the game I used the LANG variable from the command language.

To force the game to run in Hungarian whilst running Fedora 13 in British English I typed LANG=hu python claptraps and....

Magyar and testpilotmonkey - a tricky combination!

Success! That was a lovely feeling. Now the next challenge was a bit of l10n. The problem I faced was that ClapTraps regularly asks the user to press Y for Yes or N for No. But in Hungarian that should be I for Igen or N for Nem. So I needed some way of changing the keys that you need to press to suit the current language.

This turned out to be quite easy - first I had to import the locale library. Next, I just needed to ask the locale class for the initial letters used for "yes" and "no" in a language like this:

# Make lists of "yes" and "no" keys for current language
locale.setlocale(locale.LC_ALL, '')
yes_keys=list(locale.nl_langinfo(locale.YESEXPR)[2:-3]);
no_keys=list(locale.nl_langinfo(locale.NOEXPR)[2:-3]);

The nl_langinfo function returns a regular expression string with the acceptable keys for Yes or No for the current locale. For English it would be:

^[yY].*
^[nN].*

For Hungarian it would be:

^[IiyY].*
^[nN].*

Note that Y is also acceptable for Hungarian. I used the Python slice operator to slice off the bits I didn't want and then bunged the result in a variable. So now, when I want the user to press yes or no I simply do this:

while(1):
    wait_event = pygame.event.wait()
    if wait_event.type == pygame.KEYDOWN:
        if pygame.key.name(wait_event.key) in yes_keys:
        return False
    elif pygame.key.name(wait_event.key) in no_keys:
        program_quit = False
        break 
    else:
        pass

And that solves it. Since I made these changes to ClapTraps my daughters have both had hours of fun out of the game. It's a tribute to the genius of testpilotmonkey - and Richard Stallman. For, without the GPL, I wouldn't have been free to make these changes which allowed my children to enjoy this fantastic piece of software.

Wednesday, October 06, 2010

Per ardua, ad astra

Recently I wrote about the flyers I created for the R3PLAY Arcade, Retro and Video Gaming Expo that's going to be held in Blackpool on the 6th and 7th November 2010. Here's Doris Speed holding an example:

Some people are so easily pleased

At the same time as I put flyers together, I also prepared two half page magazine advertisements to appear in retroGAMER and gamesTM magazines.

This was a very exciting job for me, as I've always wanted some of my work to appear in a computer magazine, and retroGAMER was a magazine I used to buy regularly when I lived in the UK.

The fliers were produced as large uncompressed TIFF files. I exported large PNG files from the Inkscape source file and then converted them into TIFFs using The GIMP.

I was delighted this morning when Dave Moore, one of the organisers of R3PLAY, sent me a picture of the adverts appearing in the magazines themselves.

In retroGAMER...

Click to enlarge

 ...and in gamesTM.

Click to enlarge

The R3PLAY Arcade, Retro and Video Gaming Expo is going to be held in Norbreck Castle, Blackpool on the 6th and 7th of November 2010. You can order tickets from www.r3play.info, in-store at WHO, 30-32 Coronation Street, Blackpool or by phone on 01253 291188.

Sunday, October 03, 2010

The Ultimate Seventies Cliché

Well, I had to do this in Inkscape sooner or later, and this morning I had three quarters of an hour spare and I couldn't resist it any longer.

I only ever used to get Spangles in that netting Christmas stocking that Mars used to do. It always had a board game on the back with a hexagonal spinner thing you had to cut out and put a match through to use instead of a dice.

Click to Enlarge

I used to find the Old English Spangles absolutely disgusting as a child - trying to eat a whole packet was probably the closest I'll ever get to a bush-tucker trial - but I'm sure I'd love them now.

PNG to PNG Sequences

When I'm putting videos together, one thing I often find handy is being able to turn a single PNG image into a PNG sequence. That means I can import the resulting sequence straight into Avidemux or VirtualDub and to add filters to it.

#!/bin/bash
#
# Convert png file into a png sequence for video use

for i in {1..150}; do
    j=$(printf "%04d" $i)
    cp "input.png" "pngs"$j".png"
done

The Bash script above does that - it takes a file called input.png, and creates copies of it to make a PNG sequence of 150 frames numbered from png0001.png to png0150.png.