Archive for October, 2008

JSSpeccy: A ZX Spectrum emulator in Javascript

Sunday, October 19th, 2008

I’m really typecasting myself here. If there were an international “Person most likely to write a Spectrum emulator in Javascript” award, I’d have taken it for the last five years running. So here it is – probably the most stereotypical project I’ll ever come up with.

Writing this wasn’t actually such a big deal – the Z80 core was ported from the one in Fuse, with the Perl-and-C-preprocessor-munging trickery still intact, and Javascript is syntactically close enough to C that that wasn’t a mammoth task. (I got 90% of it done on the train journey back from International Vodka Party alongside recording silly songs about tube stations.) The one fiddly bit was working around the places where the Fuse code used low-level C constructs to its advantage: using unions to chop and change between individual registers and 16-bit register pairs, and relying on limited-size C data types (often in pretty subtle ways) to truncate 8-bit and 16-bit values at the right time, whereas Javascript only has integers. (Actually, the really time-consuming bit was debugging it all… luckily, Fuse has a rather excellent test suite too.)

The rest is just creative abuse of the <canvas> element, as usual… it’ll take advantage of the putImageData interface to do the pixel pushing if available (on my machine Firefox has it, Safari doesn’t) and fall back on drawing 1×1 pixel rectangles otherwise. This time I’ve thrown in Google’s ExplorerCanvas as a nod to those poor unfortunates still stuck with Internet Explorer. Incidentally, I’d be curious to know how it rates on Google Chrome (I don’t have an XP/Vista box to test on) – if the hype is true (and it implements the putImageData interface like all good up-to-date browsers should) then I’d expect it to comfortably reach 100% Spectrum speed on modest hardware.

The Model (unplugged cover version)

Friday, October 10th, 2008

Another month, another musical challenge bandwagon to jump on. For October the FAWM / 50/90 crowd is turning its attention to cover versions. So here’s a not-very-Kraftwerk-like instrumental version of Kraftwerk’s The Model.
Download matt_westcott_-_the_model.mp3

Download The Model (MP3, 4.7Mb)


Thursday, October 9th, 2008

This is it then… my big comeback to the Javascript demo scene after a two year absence, and also the moment when my demo coding muse returned from a long holiday, I guess. Ladies and gentlemen, I give you… Antisocial, a biting satire on social networking phenomena.

Visit the Antisocial microsite…

With my characteristic lack of organisation, I found myself with two weeks to go to the Sundown party, having promised a demo release, and with nothing specific in the pipeline. So, I decided to take a chance and run with an idea that had been sitting on top of my “demos to write when I have more free time than I do right now” pile for the best part of a year. I had it all planned out in my head, right down to the soundtrack: a mysterious track from an unlabelled CD I picked up at a ZX Spectrum Orchestra gig in 2005 (which turned out to be Round, from their Clive Live^3 EP). A quick bit of permission-getting later, and I was at the point of no return.

I knew it would be an ambitious job, and a bit of a leap artistically and technically from my usual stuff. I pencilled in a rough project plan in my diary. I drew up storyboards. I read up on the maths that was too nasty to contemplate on previous projects. And shockingly enough, I actually enjoyed all of the above.


50/90 2008: somewhat fewer than 50 songs

Monday, October 6th, 2008

50/90, or 50 Songs In 90 Days, is the less photogenic and slightly more intimidating cousin of February Album Writing Month, running throughout July, August and September. The idea is to write fif- oh, you worked that bit out already. This year FAWM supremo Burr Settles donated the song-posting infrastructure to 50/90 (previous years were run through a Yahoo group) so it became a natural off-season hangout for FAWM veterans. Me, I wasn’t planning on taking part, but since I ended up writing a couple of songs over that time period for one reason or another, it would have been silly not to crash the party late on and participate in a laid-back, not-letting-it-take-over-your-life sort of way. And here are the results.

Everything Is Relative

Download matt_westcott_-_everything_is_relative.mp3
This started out as an instrumental track laid down at Shucon 2008 on TDM’s GarageBand / MIDI setup, which came back to bite me as a nasty bit of vendor lock-in. (I figured that since GarageBand took MIDI input and stored it as MIDI-like note events, I’d be able to export it to a .mid file, right? Silly me.) Luckily I managed to salvage / re-record enough of it to work on it some more and develop it into a proper song. Spurred on by some particularly eclectic music competitions at Assembly, I decided to try my luck at entering it at Evoke, just to see what would happen when it was thrown in against a whole load of D+B and trance tracks. Not surprisingly, it failed to qualify. But having done the rounds of more or less the entire summer demo party season, it found a home at Sundown 2008, where it got 4th place. Score!

The lyrics were actually sparked by the train journey back from Shucon – at the seat in front of me, I saw that someone had drawn some initials in a heart on the window. This made me think “eww, that’s a bit tacky. Oh, hang on – whoever did that drew it on the outside of the window but did it in mirror writing so his girlfriend on the train could read it. Aww, that’s like the most romantic thing ever!”

Edgware Road

Download matt_westcott_-_edgware_road.mp3
A slightly more obviously train-related song, written to immortalise that enigma of the London Underground where time stands still, and add to the repertoire of songs about tube stations. Lyrics were mostly written on the Eurostar (hence the namecheck in the bridge) and the recording was done a-cappella stylee in the cabin of a sleeper train on the way back from International Vodka Party. Naturally, this was a horrible painstaking process of waiting for the moments when the train wasn’t making an absolute racket, but it had to be done for posterity. How many other songs have been written and recorded entirely on public transport, eh?

Cabbage Soup For The Soul

Download matt_westcott_-_cabbage_soup_for_the_soul.mp3
Written for Hoopshank as part of intense negotiations (not really) over contributing to another as yet unannounced musical project. He demanded songs of cabbage… I answered the call. I added a self-imposed constraint that the song had to have a mostly-serious message, so I came up with the idea of cabbage soup for the soul, as being something like Chicken Soup for the Soul but not as pleasant, and better for you. And suitable for vegans. And with that, the song just wrote itself. Or, more accurately, was written on my behalf by my alter ego, fictional Scottish indie band Glencoe Horse.

At The River (slight return)

Download matt_westcott_-_at_the_river_slight_return.mp3
OK, scraping the barrel a bit here. But you can’t really blame me for having a sudden bout of obsessive-compulsive disorder on realising that the lyrics to At The River by Groove Armada consist entirely of a half-sentence that trails off unsettlingly without completing its train of thought. “If you’re fond of sand dunes and salty air, quaint little villages here and there,” – then… what exactly? Clearly, this had to be fixed. So I did.

(All songs downloadable from the not-very-pretty – lyrics available from my 50/90 profile)

The Ninja Milkman Conspiracy (and Maze)

Sunday, October 5th, 2008

I’m a bit behind in my blogging, so I’ve got a bit of a “what I did this summer” catchup to do. First up is The Ninja Milkman Conspiracy, a cheap and cheerful oldskool scrolly Speccy demo made for this August’s International Vodka Party, featuring the classic circle interference effect, some creative use of dithering, and a dancing robot. What more could you ask for? The title, incidentally, was just something random and irrelevant to save it from being called ‘IVP 2008 demo’ (which is just as well, because there were already 2 other demos in the competition called that) but is actually a reference to the milkman at one of our offices who is able to deliver the milk and disappear without making a sound.

…All of which is ordinary enough, but the exciting thing (if you’re the sort of person to get excited about build scripts) is, um, the build script. I’ve been happily using makefiles for ages, but this time I finally flipped at the amount of redundant boilerplate you need to shove in there for a typical Spectrum project, even a small one like this – having to remember command line syntax, having to explicitly set up dependencies even though they’re all clearly marked as ‘include’ lines in the assembler file – so I came up with Maze, a Spectrum-oriented replacement for Make written in Ruby. Inevitably, being a scratch-my-own-itch sort of program, it’s a bit more hard-coded (and tuned towards my own way of working) than I’d like, but I reckon it’s enough of an improvement over bog-standard makefiles that it could conceivably be useful to other people. And if it is, maybe I’ll be encouraged to rewrite it in a more open-ended way some time…