Friday 31 December 2010

Computus 3

After reminiscing with Dr J R Stockton about old computers, it got to converting my 16-bit algorithm for Easter to 8-bit Z80 assembly language. I spent quite some time hand-optimising it (which is an enjoyable past-time in itself, if there's no deadline involved!) and posted the code with a short commentary.

I had thought about writing a bespoke super-optimiser to try to find the "ultimate" Z80 code, but with just under 500 bytes of machine code, that's over 101000 permutations. I think I might have to divide and conquer!

Sunday 26 December 2010

Modulo Arithmetic in Z80 assembler

I've done a little 8-bit assembly coding in the past, mostly Z80 (on Sinclair machines) and 6502 (on BBC Micro), but I've never really thought about arithmetic optimisations for those platforms as much as I have the last couple of months.

Imagine that you are (in the 21st century) writing Z80 date manipulation functions where the day of the week was important. You'd naturally want to perform "modulo 7" arithmetic on 16-bit quantities. If you had a routine to perform integer division by 7, you might find "z = x mod 7" given "y = floor(x / 7)" for unsigned 16-bit values as follows:

; Z80 assembly to compute 'x mod 7' from 'x' and 'x div 7'
; 'x' in HL
; 'x div 7' in DE
LD B, D       ;  4T 1B -- Take a copy of DE
LD C, E       ;  4T 1B -- BC := x div 7 
EX DE, HL     ;  4T 1B -- DE := x, HL := x div 7 
ADD HL, HL    ; 11T 1B -- HL := (x div 7) * 2
ADD HL, HL    ; 11T 1B -- HL := (x div 7) * 4
ADD HL, HL    ; 11T 1B -- HL := (x div 7) * 8
AND A         ;  4T 1B -- Clear carry flag
SBC HL, BC    ; 15T 2B -- HL := (x div 7) * 7
EX DE, HL     ;  4T 1B -- HL := x, DE := (x div 7) * 7
AND A         ;  4T 1B -- Clear carry flag
SBC HL, BC    ; 15T 2B -- HL := x - (x div 7) * 7
LD A, L       ;  4T 1B -- A:= x mod 7
; 'x mod 7' in A

At first glance, this seems fairly fast, compact code (91 T-cycles and 14 code bytes), but notice that, by the end of it, one side-effect is setting H to zero. Not very surprising as "x mod 7" is clearly an 8-bit quantity. So why go to the trouble of computing full 16-bit intermediates that have only partial bearing on the final result? Providing that the upper eight bits don't "pollute" the lower eight (e.g. during division or change of sign), you need not compute them. Especially as 16-bit arithmetic is disproportionately expensive on Z80:

  • Obviously uses more precious registers,
  • Addition of 16-bit quantites takes at least 11 T-cycles compared to 4 T-cycles for 8-bit quantities,
  • Subtraction via 'SBC' requires worrying about the carry flag as there is no 16-bit 'SUB' instruction,
  • Shifting 16-bit quantities (multiplication and division by two) other than 'ADD HL, HL' requires two, long instructions.

So the 8-bit equivalent could be:


; Z80 assembly to compute 'x mod 7' from 'x' and 'x div 7'
; 'x' in HL
; 'x div 7' in DE
LD A, E       ;  4T 1B -- A := x div 7 [low bits]
ADD A, A      ;  4T 1B -- A := (x div 7) * 2 [low bits]
ADD A, A      ;  4T 1B -- A := (x div 7) * 4 [low bits]
ADD A, A      ;  4T 1B -- A := (x div 7) * 8 [low bits]
SUB E         ;  4T 1B -- A := (x div 7) * 7 [low bits]
NEG           ;  8T 2B -- A := (x div 7) * -7 [low bits]
ADD A, L      ;  4T 1B -- A := x mod 7
; 'x mod 7' in A 



This is both faster and smaller (32 T-cycles and 8 code bytes) with no loss of accuracy, so I'm a bit bemused that it's taken me nearly three decades to stumble across it. And a lot of good it will do me too!

P.S. Why is 'NEG' so expensive on Z80? Given that 'CPL' is only 4 T-cycles and 2 code bytes, it seems a waste to dedicate precious silicon on a similar instruction that can be represented with existing instructions ('CPL' then 'INC A') for the same cost. Bah humbug!

Friday 10 December 2010

Computus 2

Of course, if you're as old as I am, you'll remember programming on machines with no native division instruction (neither integer nor floating-point), so all those divisions and modulos aren't going to get you very far on a "old school" 16-bit computer. Using the information from Hacker's Delight, you can re-cast these operations to multiplications and shifts:

void easter_u16_nodiv(u16 year, u16* month, u16* day)
    u16 a = year >> 1;
    u16 b = year >> 2;
    u16 c = year >> 4;
    u16 d = b + c;
    u16 e = (a + d + (d >> 4) + (d >> 5) + (d >> 10)) >> 4;
    u16 f = year - e * 19;
    u16 g = f - ((f + 13) >> 5) * 19;
    d = (b >> 1) + (b >> 3);
    e = (d + (d >> 6) + (d >> 7)) >> 4;
    f = b - e * 25 + 39;
    d = e + (f >> 5);
    u16 h = (d * 3) >> 2;
    d = (d * 8) + 5;
    e = (d >> 1) + (d >> 3);
    e = (e + (e >> 6) + (e >> 7)) >> 4;
    f = d - (e * 25) + 7;
    d = (g * 19) + h - e - (f >> 5) + 15;
    e = ((d >> 1) + (d >> 5)) >> 4;
    f = d - (e * 30);
    d = f - ((f + 2) >> 5) * 30;
    g = d + ((29578 - g - (d * 32)) >> 10);
    f = b - h + g + 2;
    d = a + c + (f >> 1) + (f >> 4);
    e = (d + (d >> 6) + (d >> 12)) >> 2;
    f = year + f - (e * 7);
    e = g - f + ((f * 2341) >> 14) * 7;
    d = e >> 5;
    *day = e - d * 31;
    *month = d + 3;

Again, if you want to verify the algorithm (only valid for Gregorian years 0 to 65535), you can do so with Dr J R Stockton's test harness with the following Javascript snippet:

    var a, b, c, d, e, f, g, h;
    a = YR >>> 1;
    b = YR >>> 2;
    c = YR >>> 4;
    d = b + c;
    e = (a + d + (d >>> 4) + (d >>> 5) + (d >>> 10)) >>> 4;
    f = YR - e * 19;
    g = f - ((f + 13) >>> 5) * 19;
    d = (b >>> 1) + (b >>> 3);
    e = (d + (d >>> 6) + (d >>> 7)) >>> 4;
    f = b - e * 25 + 39;
    d = e + (f >>> 5);
    h = (d * 3) >>> 2;
    d = (d * 8) + 5;
    e = (d >>> 1) + (d >>> 3);
    e = (e + (e >>> 6) + (e >>> 7)) >>> 4;
    f = d - (e * 25) + 7;
    d = (g * 19) + h - e - (f >>> 5) + 15;
    e = ((d >>> 1) + (d >>> 5)) >>> 4;
    f = d - (e * 30);
    d = f - ((f + 2) >>> 5) * 30;
    g = d + ((29578 - g - (d * 32)) >>> 10);
    f = b - h + g + 2;
    d = a + c + (f >>> 1) + (f >>> 4);
    e = (d + (d >>> 6) + (d >>> 12)) >>> 2;
    f += YR - (e * 7);
    e = g - f + ((f * 2341) >>> 14) * 7;
    return e;

Computus 1

Computus is the calculation of Easter. Calendrical calculations being a bit of an obsession of mine, I've been looking at this with a view to an implementation using limited-range integer arithmetic. There's a lot of interesting stuff still being researched on this, but I haven't seen a good implementation for 16-bit unsigned arithmetic. So here's my attempt:

void easter_u16(u16 year, u16* month, u16* day)
    u16 a = year % 19;
    u16 b = year >> 2;
    u16 c = (b / 25) + 1;
    u16 d = (c * 3) >> 2;
    u16 e = ((a * 19) - ((c * 8 + 5) / 25) + d + 15) % 30;
    e += (29578 - a - e * 32) >> 10;
    e -= ((year % 7) + b - d + e + 2) % 7;
    d = e >> 5;
    *day = e - d * 31;
    *month = d + 3;

This is valid for all Gregorian years 0 to 65535. In fact, the core algorithm is valid for all non-negative years: just change the integer type to a wider, signed one.

If you want to test it using Dr J R Stockton's wonderful script tester, use the following Javascript snippet:

    var a = YR % 19;
    var b = YR >>> 2;
    var c = ((b / 25)|0) + 1;
    var d = (c * 3) >>> 2;
    var e = ((a * 19) - (((c * 8 + 5) / 25)|0) + d + 15) % 30;
    e += (29578 - a - (e << 5)) >>> 10;
    e -= ((YR % 7) + b - d + e + 2) % 7;
    return e; 

Sunday 14 November 2010


My present work has brought me into contact with HLSL pixel shaders. Many of these involve colour manipulations, so a fast and efficient conversions between RGB and HSV (or HSL) colour spaces would seem to be readily available and optimised to death. Strangely, this doesn't seem to be the case. Even shaders given as examples by NVIDIA and ATI are somewhat simplistic. The Wikipedia page's pseudo-code suggested the following HLSL code:

float3 HSVtoRGB(float3 HSV)
    float3 RGB = 0;
    float C = HSV.z * HSV.y;
    float H = HSV.x * 6;
    float X = C * (1 - abs(fmod(H, 2) - 1));
    if (HSV.y != 0)
        float I = floor(H);
        if (I == 0) { RGB = float3(C, X, 0); }
        else if (I == 1) { RGB = float3(X, C, 0); }
        else if (I == 2) { RGB = float3(0, C, X); }
        else if (I == 3) { RGB = float3(0, X, C); }
        else if (I == 4) { RGB = float3(X, 0, C); }
        else { RGB = float3(C, 0, X); }
    float M = HSV.z - C;
    return RGB + M;

float3 RGBtoHSV(float3 RGB)
    float3 HSV = 0;
    float M = min(RGB.r, min(RGB.g, RGB.b));
    HSV.z = max(RGB.r, max(RGB.g, RGB.b));
    float C = HSV.z - M;
    if (C != 0)
        HSV.y = C / HSV.z;
        float3 D = (((HSV.z - RGB) / 6) + (C / 2)) / C;
        if (RGB.r == HSV.z)
            HSV.x = D.b - D.g;
        else if (RGB.g == HSV.z)
            HSV.x = (1.0/3.0) + D.r - D.b;
        else if (RGB.b == HSV.z)
            HSV.x = (2.0/3.0) + D.g - D.r;
        if ( HSV.x < 0.0 ) { HSV.x += 1.0; }
        if ( HSV.x > 1.0 ) { HSV.x -= 1.0; }
    return HSV;

Even to my eyes, these looked far than optimal. However, a quick glance at the HSV graph on the Wiki page suggests an optimisation for 'HSVtoRGB' which doesn't involve branching or conditional predicates.

float3 Hue(float H)
    float R = abs(H * 6 - 3) - 1;
    float G = 2 - abs(H * 6 - 2);
    float B = 2 - abs(H * 6 - 4);
    return saturate(float3(R,G,B));

float3 HSVtoRGB(in float3 HSV)
    return ((Hue(HSV.x) - 1) * HSV.y + 1) * HSV.z;

This is particularly efficient because 'abs' and 'saturate' are "free" operations on a lot of GPU pipelines.

The reverse conversion is a bit more tricky, and if you're really obsessed with performance on Xbox360, or the like, you'll need to drop down into shader assembler to utilise the vector 'max4' instruction instead of the scalar alternatives:

float3 RGBtoHSV(in float3 RGB)
    float3 HSV = 0;
#if NO_ASM
    HSV.z = max(RGB.r, max(RGB.g, RGB.b));
    float M = min(RGB.r, min(RGB.g, RGB.b));
    float C = HSV.z - M;
    float4 RGBM = RGB.rgbr;
    asm { max4 HSV.z, RGBM };
    asm { max4 RGBM.w, -RGBM };
    float C = HSV.z + RGBM.w;
    if (C != 0)
        HSV.y = C / HSV.z;
        float3 Delta = (HSV.z - RGB) / C;
        Delta.rgb -= Delta.brg;
        Delta.rg += float2(2,4);
        if (RGB.r >= HSV.z)
            HSV.x = Delta.b;
        else if (RGB.g >= HSV.z)
            HSV.x = Delta.r;
            HSV.x = Delta.g;
        HSV.x = frac(HSV.x / 6);
    return HSV;

Although we haven't managed to get rid of the 'if' statements, they typically compile down to one conditionally predicated block and two conditional assignments.

Even against the startlingly successful optimisations produced by the current batch of HLSL compilers, these refactorings produce excellent results. The round-trip conversions (RGB-to-HSV-to-RGB) are typically three times faster than the simplistic implementations. For a pixel shader, that's not to be sneezed at.

Sunday 7 November 2010

SketchUp to Reality

Google's SketchUp is an amazing bit of tech; but how many people use it in anger? From drawing to real-life, instead of the other way round? The work-in-progress known as Pear Tree House has actually benefited from the application of SketchUp to produce working plans for the building of a cedar and glass "loggia" (a posh word for "a lean-to without sides"). The original technical drawings and load calcs were done professionally, but I transferred the plans to SketchUp to help us get a feel for how everything fits together, and, more importantly, getting the roof lines correct.

The real-life results are surprisingly close to the plans I put together back in March 2010:

Saturday 6 November 2010

ZX Spectrum Fine Art

I've been trawling through old demoscene, low-resolution art lately; in particular, images that can be displayed on a bog-standard Sinclair ZX Spectrum. These were limited to 256-by-192 pixels, with each 8-by-8 patch limited to only two colours from a very small palette. Most artwork of the 1980s was confined to loading screens, some very clever indeed:

But, even today, people still dabble in the arcane skills involved in getting something half-decent out of the huge constraints. As a quick exercise, I looked for an iconic painting to recreate in ZX Spectrum graphics. Something simplistic with blocks of solid colour would be ideal. I chose David Hockney's "A Bigger Splash":

Oh dear...

Sunday 26 September 2010

Gratuitous Aphorism #3

Patient: Doctor, doctor! It hurts when I do this [Waves arm unnaturally above head]
Doctor: Well, don't do it, then!

Saturday 4 September 2010

Samsung N220 Netbook

New hardware here at chez chilliant. I cute, little 10.1" netbook from Samsung. As is my wont, I researched the marketplace quite thoroughly, so I had to set myself a budget of £300 to prune the options. My requirements came down to:

  • Small size,
  • Good build quality,
  • Enough computing power to pursue hobby programming,
  • Ability to playback videos easily,
  • Good battery life.

The UK version of the Samsung N220 ticks all the right boxes, not least because it has a Broadcom CrystalHD Decoder built-in, unlike its foreign cousins, bizarrely. It means I can copy recorded programmes directly from my Topfield TF5800 PVR and play them back at native resolution (720x576 or 1024x576) with no lost frames and good (backlit LED) display.

The keyboard is a little under-size, so takes a lot of getting use to, particularly the tiny cursor keys, but I'm typing this (on a train) with not too much trouble.

With a battery life of supposedly up to 12 hours (I get about 7 hours with my usage profile), it's not disastrous if I forget to plug it back into the mains of an evening after a few days of commuting. Interestingly, after punting around in the Control Panel and settings, I came across a BIOS setting to only charge the 6-cell battery to 80% capacity in order to extend the lifetime of the battery pack. The very fact that this is a BIOS setting suggests that modern computers do a lot more when "switched off" than I ever imagined.

Thursday 8 July 2010

Thursday 17 June 2010


I've just added a new demo: Unifont. I've tried to compose as many useful bitmap glyphs from a single, small image (128-by-64 pixels) as possible. I'm up to almost one thousand.

I've found out a lot about character sets, code pages and Unicode in general. And I was pleased to see all the glyphs from the Sinclair ZX Spectrum character set have a one-to-one mapping to Unicode code-points. But bizarrely, this isn't the case for the Sinclair ZX81:

The half, grey-shaded block elements (two above "D" and "E") and their inverses have no Unicode equivalents. Shocking!

This is obviously just a clerical error on the part of the Unicode standards team; I can't imagine them knowingly missing out glyphs from such an important character set. But I'm going to start a petition to get them instated as soon as possible:
  1. Ian Taylor
  2. ...

Monday 14 June 2010

Gratuitous Aphorism #2

The black sheep of the family is still a sheep.

Romance in Games

As someone said somewhere sometime:
Romance in games is about as welcome as romance in war movies ... and it's far sadder
So far as I can work out romance (or sex) in video games serves at least three purposes:
  1. As a core element of gameplay,
  2. As an embellishment to gameplay, for the purpose of adding texture, depth or role-playing, or
  3. As titillation.
I suspect some Far East games manage to encapsulate all three at once!

The general media jump on any occurrence that they deem "suspect" and sometimes they're right to, but why do video games have such a bad track record when they try to represent romance. Other media don't seem to have the same problems: "rom-coms" in film, love songs in music, and just about any form of affection depicted in visual arts seem integral to our (Western) culture.
Manipulating characters' love lives in god games like The Sims is fun, probably because you're not one of the protagonists. As soon as you are actively participating, things get a little uncomfortable; "forced" at best, "sordid" at worst.
In Mass Effect, your character can romance a particular member of the opposite sex or a particular alien of a species with only one gender. The mechanic for progressing the romance is via the conversation system, which permits the designers to prevent liaisons with "unsuitable" partners by simply restricting the options. Although there is no requirement to pursue the romance subplot to complete the game, there is an Achievement reward if you "succeed". Up to this point, the script elements are fairly well written, if understandably a bit stilted, but the denouement is well into "titillation" territory. The game is "15" certificate in the UK so there's no point in being prudish, but the "passionate" finale looks more like a partial nudity scene gratuitously inserted into a bad movie to try to spice it up.
In Mass Effect 2, any romance achieved in the first game is carried over; a framed picture of your original love interest is shown in your cabin. Ah! They also appear in the game, although for reasons beyond your control, you cannot continue your relationship. There are, however, more romantic options than in the first game, including a lesbian fling with your personal assistant if your character is female. Interestingly, there's no same-sex option if your character is male. At least homosexuality isn't completely ignored, but your ability to order your personal assistant (and subordinate) to "dance for you" is a bit sordid, not to say unprofessional. Also, the lesbian relationship will not award you the romance Achievement, which also suggests it's firmly in the titillation sector.
In my opinion, the romance subplots in both Mass Effect games would have been greatly enhanced if the consummation had been implied, instead of rendered.
Of the games I've personally worked on, only Thrillville had any romantic component, where it's critical for some of the missions. The original design had a fairly abstract, Uno-style, pattern matching game where you had to string together topics of conversation for as long as possible. Pretty much like a real-life first date! I moved on to other aspects of the game, and by release the "Flirting Game" had morphed slightly, but it's a good fit for the target audience. Romance is limited to teen-boy with teen-girl.

Bonsai Barber almost had a matchmaking mechanic where you could indirectly influence the love lives of your customers. It never got beyond the early design phase though, probably because any offspring between Reg Wedge and Catnip is too horrific to contemplate!

Wednesday 9 June 2010

Scabby Donkeys

It's been a while since my last post; one of the reasons being a holiday to Sardinia.

I'm not sure that Sardinia knows how to position itself as a holiday destination. Yes, it has some great scenery, fine beaches and unique Bronze age buildings, but although tourism is now a major source of income, it has a relatively short "season" (we went just before the high season begins) and a distinct lack of tourist-friendly accommodation or restaurants. We traipsed around the centre of the second city, Sassari, one evening for over an hour looking for somewhere to eat, other than the ubiquitous bars and pizza takeaways.

One of our problems was that, as tourists, we didn't fit into the standard Sardinian schedule of a light, early breakfast followed by a large, midday meal and siesta, all rounded off by an informal snack (typically pizza) of an evening. Like many Mediterranean places, siesta is a standard part of life, but in Sardinia it seems to be fastidiously adhered to. Nothing stirs whatsoever between 2pm and 4pm, at least. Including some family-run restaurants.

The cuisine is Italian with a few local specialities. Two being horse and donkey. Janette has a saying when hungry (a not infrequent occurrence): "I could eat a scabby donkey!" which seems highly unlikely for a vegetarian. So I felt obliged to try the delicacy for lunch one day. And before you ask; it tastes like zebra.

Wednesday 28 April 2010

Thursday 22 April 2010

That's Where All the Power has Gone

Let's use more statistics to push our heads even further into the ground concerning energy efficiency in the home.

Flicking through our household bills, I discover that electricity only makes up a third of our billable energy usage. The remainder is natural gas which is significantly cheaper to the consumer per kilowatt-hour. The historical availability and economy of natural gas may explain why the UK has such a low per capita electricity consumption compared to the rest of the developed world.

The vast majority of our household heating and hot water is provided by gas, so we've installed a solar panel to heat water to help the environment. We also subscribe to a "green" tariff from our electricity provider which effectively means that 50% is from renewable energy. As discussed earlier, the majority (about 70%) of our per capita electricity footprint is controlled by others in the form of business usage, transportation, etc. I'll call that "Community Electricity" and note that, as householders, we only have indirect control as to its generation and consumption.

This all means that reducing our household electricity usage has an even smaller impact on the consumption of non-renewable (fossil) energy sources than I originally thought.

Surely, it would be far more effective for the government to tax natural gas heavily and invest the money in research and development of (subsidised) sustainable energy sources.

Monkey Want, Monkey Get

Based on an image by Matt Cioffi:

Where Has All The Power Gone?

My better half is a bit of a green eco-warrior and is constantly complaining about our energy usage, in particular, the plethora of devices we leave in standby mode.

One old chestnut is the amount of electricity used by a TV in standby mode. I've maintained that this "over-reaction" is a legacy from the days when television manufacturers used to push features to allow TVs to present a picture as soon as possible after "turning on". Indeed, Toshiba were still including such a feature in its LCD Regza range in 2008:
  • Power-on: 218.08 Watts
  • Stand-by: 0.58 Watts
  • Fast turn-on: 17.8 Watts
What were they thinking?

It turns out that most devices in this category consume less than 1W in standby and this includes appliances such as cookers and microwaves that have digital clocks. But that still potentially amounts to 8 or 9kWh per year.

Another chunk of energy is used by devices that are always on, such as security alarm systems, central heating controls, telephones and broadband modems. Of these, telephones and modems are "actively working" pretty much 24 hours a day, even if they aren't doing anything constructive for the majority of the time.

We recently borrowed an electricity monitor to try to put some concrete figures together. It turns out that our minimum, background energy usage is 200W, but this flicks up to 300W when a fridge/freezer compressor kicks in or we turn some lights on. Boiling water, washing clothes and watching television are definite no-nos, but alas, we do all these things, so our average daily consumption has been 12kWh. I'm sure it would be possible to get this figure below our (self-imposed) initial target of 10kWh, but not without significant behavioural changes. So I'll be lazy and use statistics instead.

The World Bank suggests that, per capital, Britons consumed 6120kWh of electrical power in 2007. That, of course, includes electricity used outside the home on our behalf. Our household usage of 12kWh per day equates to about 2200kWh per person, per year. So meeting our target by reducing our personal usage by 16⅔% would only reduce our total per capita usage by 6%. Well done, Amdahl!

To play devil's advocate, I propose a new metric which factors in the inconvenience of saving energy in the home: the kilowatt-hour-cumber.

Wednesday 21 April 2010

Gratuitous Aphorism #1

The only thing more dangerous than a software engineer with a screwdriver is a hardware engineer with a compiler.

Mass Effect 1 & 2

Whereas I knew exactly where I stood when I started playing the BioShock games, Mass Effect is a completely different kettle of alien fish.

Mass Effect (PC May 2008) and Mass Effect 2 (January 2010), both developed by BioWare, are classified as action role-playing games. This rather vague genre (or sub-genre) gives the classic FPS (or hack-and-slash) a bit of depth, as the player can participate in more meaningful choices regarding the progression and development of their protagonist(s). Perhaps.

A lot of RPGs are tainted with a stigma of micro-management of spells, potions, armour and arms. And this is certainly the case with the original Mass Effect game. However, I feel that the pendulum swung back too far the other way with Mass Effect 2.

The main problem with the original game's equipping is not the concept, it's the poor user-interface design. As a squad, you can only carry a total of 150 weapons and enhancements. Juggling this number of items (many of them duplicates) is just too unwieldy and a lot more thought should have gone into a simple (but precise) management scheme.

The developer's solution for Mass Effect 2 is to eradicate the vast majority of items completely. The only equipment choice is which of a series of weapons to kit out for each character. Even here, except for Shepard's heavy weapon, the choices are pretty clear-cut and linear. Also, unless you come across a weapons locker, you cannot modify your selections mid-mission.

In terms of character traits and development, Mass Effect 2 also has a more streamlined approach, but this seems to work much better than the predecessor's flabbier system. However, the new "loyalty" attribute is a little clunky and, in my eyes, only serves three purposes:
  1. To unlock a special power for each character;
  2. To add extra terms to the "final game score" calculations [see later]; and
  3. To add some missions (one per character) to the game's "critical path". These missions are rather unimaginative, usually relating to a character's long-lost father/sister/daughter, whilst trying, unsuccessfully, to add moral ambiguity to the mix. For me, the only one that stands out is Mordin's re-visiting of his work on the Krogan genophage, which truly is an interesting moral subject.
On the subject of Mordin, the eccentric Salarian scientist, my favourite line in either game is when he uses his "Incinerate" ability during combat:
"Flammable ... or inflammable ... can't remember which ... doesn't matter!"
The conversation and Paragon/Renegade system works very well, and the designers have been sensible not to change it at all between games. From a design point of view, it is very clever of them to maintain Paragon and Renegade as two scales instead of conflating them into a single Good/Bad spectrum (as I think I would have naively been tempted). At least no-one at BioWare thinks morality is just a number between zero and one!

In the original Mass Effect, you could recruit up to six squad members. This was increased to at least ten (more if you have downloadable content) in Mass Effect 2. There does seem to be a "dilution of concern" with the increase in squad size; I only felt attachment to Garrus and Tali (carried over from the original game), Grunt (the proxy for Wrex) and Mordin (the archetypal scatty scientist). Perhaps the problem is that choosing two team-mates from ten gives considerably more possibilities (forty-five) than two from six (fifteen), so you get lazy and just pick the same two over and over again.
One reason for the designers to increase the number of potential squad members is that they're used as part of an elaborate implicit scoring system at the end of the final mission. Depending on how "well" you played, more of your crew will survive. The precise computations as to who dies has been documented thoroughly in the online forums and wiki pages, but generally you lose crew members depending on:
  1. The loyalty rating of each squad member (whether you completed the character's personal mission);
  2. Upgrades you bought for your spaceship;
  3. The choices you make concerning which characters assume which roles in the final mission; and
  4. The choices you make concerning what to do with any surviving, non-squad, crew members such as Doctor Chakwas.
However, if, like me, you play RPGs and RTSs in a very Type-A manner, you will have pretty much maxed out your ship and squad's stats and been careful with your selections, so all your crew will survive (excluding the arbitrary Lilith, who's unsaveable!); you'll never see this "scoring" nuance. However, play "badly" and most of your squad could be wiped out, although you'll still save humanity, thank goodness.
The concept of Romance (along with the related Achievement) is carried over from the original game into Mass Effect 2. But whereas it was simply stilted and coy in the former, it is downright laughable in the latter. It's 90% of the way to being tongue-in-cheek, but not quite enough to stop me cringing at the dialogue. I've had some experience of this minefield when working on the Thrillville games, so I might revisit this topic in another post.

Finally, going back to the fuzziness of the ARPG sub-genre, you can "tune" the game to be more of an FPS by choosing the Soldier class for Shepard (which, tellingly, is the default). However, it quickly dawned on me whilst playing the first game, that your skills as a soldier are primarily a function of the player's FPS skills, as opposed to their character's in-game attributes. So I restarted with a character of the Adept class (analogous to a Wizard in hack-and-slash games) which gave me access to the Biotic powers, whilst leaving me sufficient in-game combat abilities and weapons to make me feel I was playing a pure FPS. This makes a bit of a mockery of one of the replayability promises of a fully-fledged RPG, which supposedly promotes restarting the same game as a different character class to get a subtly different experience. There really didn't feel like there was sufficient differentiation between the character classes to warrant a complete replay.

In my book, Mass Effect is an FPS with some good RPG elements. Mass Effect 2 is even more FPS, less RPG. The makers obviously don't see it that way, or they'd have concentrated more on the enemy AI to bring it up to 2010 standards. The player of a good FPS should not expect to be able to walk into a room full of frozen enemy characters that only respond when you reach a trigger point or fire the first shot. Even then, the unimaginative enemy reactions are a far cry from those in Half Life 2 or ... erm ... Far Cry. But perhaps you can get away with these substandard elements in an ARPG.

Monday 19 April 2010

BioShock 1 & 2

BioShock (August 2007) and BioShock 2 (February 2010) are first person shooters published by 2K Games.

According to Metacritic scores, the original game is perceived as better than the later release, and I've got to concur. BioShock 2 feels more like a mission pack and doesn't add enough to warrant the full-price retail cost of a PC game. If I was more into multiplayer (versus) modes, I may think differently, as this is only available in BioShock 2.

By far the strongest feature of the games is the setting and backstory: Rapture is a secret underwater city built immediately after the Second World War by business magnate Andrew Ryan, who is disillusioned with the new world order. Scientific breakthroughs by geneticists brought to Rapture by Ryan lead to the development of "plasmids": enhancements that give the users superhuman abilities, powered by substances named Adam and Eve. Civil war breaks out in 1959 as the city descends into chaos over control of these substances. You, the player, are apparently the sole survivor of a mid-Atlantic plane crash in 1960. Swimming to an isolated lighthouse, you descend to Rapture in a deserted bathysphere...

The gameplay is 90% classic first person shooter with an array of mid-twentieth century firearms, but also a collection of increasingly powerful plasmids such are Incinerate and Electrobolt. Use of environmental features are encouraged: electrically zapping enemies who are standing in water often results in an instant kill.

Games involve meaningful choice; and here, this includes what weapons, skills and plasmids to enhance with your limited resources. This, in turn, affects how you play various set pieces: do you go in guns ablazing, or hack security systems to attack enemies, or be more stealthy and keep your distance?

The story is very linear with few meaningful ethical choices that have substantial impact to the storyline. Any ethical decisions you do make (such as rescuing or harvesting Little Sisters) are tallied up to decide which of a limited set of end-of-game cut-scenes to play.

However, there is a great deal of ethical and philosophical discussion within the game, with much reference to Ayn Rand (c.f. Andrew Ryan). But this is mostly exposition, and listening to the various audio recordings may improve your mind, but won't improve your ability to head-shot a Splicer at thirty paces. There are obviously lots of oblique references to religion ("Rapture", "cult", "Adam" and "Eve") but they feel quite Matrix-esque in that they could just be labels and archetypes doled out by developers without much thought or depth.

The art design is superb, and the use of water effects (on high-spec hardware) masterful. It was a little disappointing that they didn't make more use of the "external" underwater sequences in the second game. I was expecting lots of outside floaty-floaty, shooty-shooty when the harpoon weapon cropped up. But no: just walk from A to B. Slowly.

Vita-Chambers are obviously a contentious feature with a certain section of the community: the makers released a software patch which allows them to be turned off. Essentially they are implicit save points. Every time you "die," you go back to the nearest Vita-Chamber with all your possessions and skills, but only partial health and a small ammo top-up. This means you can clear patches of difficult enemies even if you continually die just by chipping away at the proverbial block.

One thing that really jarred the first time I came across it was the hacking minigame in the first game. This is pretty much a level from Pipe Mania. The difficulty is controlled (by the game) via the water speed and by adding "bomb" tiles; but these can be mitigated by buying power-ups. It's just such a change of pace, and although the "water in pipes" theme fits in with the game world on paper, it still tends to jar. Maybe it's the sudden switch from 3D world to 2D abstraction. Even the game's creative director Ken Levine thinks "It's a little out there." For whatever reason, the minigame is replaced by a more twitchy "stop the swing-o-meter" alternative in BioShock 2.

Overall, BioShock is a good FPS that scores well on originality of setting. But it lacks the variety of Half Life 2 (which is a better game and scores more on Metacritic) and seems to be running out of steam in BioShock 2. Perhaps the novelty and courage of setting an FPS on Earth in 1960 cannot carry it much beyond a single incarnation. Having said that, BioShock 3 is supposedly in production.

Bestest PC Games Ever

Working on Wii for the last three years has left me a bit behind the times with more "next gen" gaming. Consequently, I've been catching up on recent games that have attained high scores on Metacritic for PC:
  1. Half-Life 2 (2004) - 96 points
  2. Out of the Park Baseball 2007 (2007) - 96 points
  3. Orange Box, The (2007) - 96 points
  4. Half-Life (1998) - 96 points
  5. BioShock (2007) - 96 points
  6. Baldur's Gate II: Shadows of Amn (2000) - 95 points
  7. Command & Conquer (1995) - 94 points
  8. Mass Effect 2 (2010) - 94 points
  9. Grand Theft Auto: Vice City (2003) - 94 points
  10. Civilization II (1996) - 94 points
The only two that grabbed my attention that I hadn't already played were BioShock and Mass Effect 2. Interestingly, both games have two incarnations:
  • BioShock (2007) - 96 points
  • BioShock 2 (2010) - 88 points
  • Mass Effect (2008) - 89 points
  • Mass Effect 2 (2010) - 94 points
Had BioShock really gone downhill with its second incarnation, whilst Mass Effect improved? I decided to play all four games...

Friday 16 April 2010

A Shed Load of Second Hand Watches

Listening to the radio traffic reports, one of their favourite phrases seems to be:
"a shed load of blanks"
This presumably refers to "a truckful of blanks that has fallen on to the carriageway." However, the ambiguity with the alternative meaning, "enough blanks to fill a shed," is witty and probably not totally accidental.

It reminds me of a phrase I had a similar problem with when I was young (in the distant past when analogue watches were the primary type). I dimly remember discussing watches with my classmates in the school playground, and being bemused that having a watch "bought second hand" was considered bad, but one "with a second hand" was considered good. Some poor, confused children had watches that fulfilled both criteria.

I quickly resolved to save up pocket money to buy my own, cheap, digital watch from the market, thereby circumventing the entire thorny issue.

Thursday 8 April 2010

We Come in Peace

Here's an idea I had a few years ago for a T shirt:

Bonsai Barber released in Japan

Bonsai Barber, the game I worked on at Zoonami, has finally been released in Japan, along with a very nifty mini-site (in Japanese only, alas).

I have a soft spot for this game as I coded the original prototype, though it's not my cup of tea, as a game. In fact, none of the games I've worked on that have actually made it to release, would induce me to part with my hard-earned pennies (if I hadn't actually worked on them).

Talking of pennies, the Japanese version sells for 800 Wii Points, instead of 1000 Wii Points in North America and Europe.

The game is pretty uncategorisable, with a little bit of something for everyone. For the hardcore gamers out there, try giving Prunella a five-star cut in under 10 seconds.

Thursday 18 March 2010

They Know Me Too Well

For no real reason, I clicked on the "Recommendations" link whilst logged in to today. Included in the first eight suggestions were:
  1. Philips NT9110 Nose Hair Trimmer - £7.99
  2. Develop Successful Relationships (Audio CD) by Glenn Harrold - £7.99
  3. Draper 69933 Safety Helmet with ear defenders and visor - £18.21
  4. Bosch AHS 63-16C Electric Hedge Trimmer - £45.95
  5. LEGO Star Wars 8017 Darth Vader's TIE Fighter - £29.98
I'm seriously worried that Amazon have been rifling through my waste paper bin or even spying on me with real-time satellite technology. Those suggestions are just too close to the bone.

But it's comforting to see that, after improving my relationship with my girlfriend via the first four suggestions (through various cunning means), our friends at Amazon have given me leave for some quality "personal" time building Lego. What more could you ask for from a benign totalitarian entity?

Monday 15 March 2010

How Difficult Can It Be?

For the last few months, I've been looking for a third example of the kind of pun that goes
"It's only cranial medicine; it's not brain surgery."
"It's only interplanetary flight; it's not rocket science."
But to no avail. The closest I can get is along the lines of
"Litho-phlebotomy. It's like getting blood out of a stone."
But that doesn't seem to be in quite the same vein.

However, the complementary version of these puns, where things are easy, not difficult, seems to be more fruitful:
"Baking. It's a piece of cake."
"Outdoor exercise. It's a walk in the park."
"Juvenile recreation. It's child's play."
Even Mitchell and Webb only came up with the two examples above. But then, they are only a double act. If they'd had another collaborator, they might have come up with a third example for that sketch. Surely with their considerable talent... I mean, how difficult could it be? It's not exactly...

Tuesday 9 March 2010

Moore's the Merrier

While at university in London in June 1992, I was looking to buy a cheap PC. I strolled up and down Tottenham Court Road getting quotes. The one I almost bought was from Morgan Computer Company (which is still operating in some guise):
  • Intel 80386SX 16MHz, 2MB RAM, 50MB hard disk
  • DOS 5.0, Windows 3, Microsoft Works
  • Keyboard and mouse
  • Hyundai colour VGA monitor
All for £685 plus VAT. I ended up sticking with my BBC Micro Model B.

Last month, I bought a new PC (for the first time in almost a decade) from Overclockers UK, an upgraded "Titan Raptor":
  • AMD Athlon II Quad Core 2.8GHz, 8GB RAM, 1TB hard disk, Sapphire ATI Radeon HD 5870 1GB graphics card
  • Windows 7 Professional 64-bit, Microsoft Office Home & Student 2007
  • Keyboard, mouse and 300Mbps Wi-fi card
  • Samsung P2350 23" LCD monitor
All for £1155 plus VAT.

So, in almost eighteen years, the CPU clock speed has grown 179-fold (716-fold if simplistically factoring in multiple cores), the RAM 4096-fold and the hard disk capacity over 20,000-fold. Inflation means that £685 in 1992 is worth about £1082 in today's terms. Wikipedia's entry on Moore's Law suggests that "bang for buck" doubles every two years, or about 500 times since June 1992.

At first glance, the CPU clock speed increase seems the least spectacular, but I guess you should factor in the additional co-processors: the on-chip FPU units and high-end GPU for a start.

But by far the largest increase has come in terms of storage. I started programming on a ZX81 in 1981 with a whopping 1KB of RAM (it could still play chess though!) I've just bought a computer with over nine million times more RAM and a terabyte of disk space. In 1981, a terabyte was just a hypothetical unit bandied about by futurists.

So, what's my new PC like? Well, the ZX81 booted more quickly.

Thursday 18 February 2010

The first of few...

Well, I've sold my soul to Google (again) and signed up to So let's see if URLs work. Ooh, spiffing.