The hero of Christopher Brookmyre's latest novel is a lethal, jittery cyborg called Ross, but it can seem like the author himself is the real machine. The former journalist has written 15 books since his debut novel Quite Ugly One Morning was published in 1996, chainsawing out a best-selling niche for his blackly comic crime fiction.
Brookmyre's gallery of anti-heroes crack wise and get cracked on the head for their trouble, and his villains - usually immoral business folk or corrupt officials of church and state - attest to an upbringing in a Scottish household where socialism wasn't a dirty word.
But for Bedlam, his 16th novel, Brookmyre has zigzagged into speculative fiction, taking the premise of Tron and dozens of other escapist techno-fantasies - "What would it be like to actually live inside a videogame?" - and rebooting it in his own distinctively dark way. In a world where our buying decisions hinge on being able to herd creators into clearly defined categories that are easy to browse online, gatecrashing a completely different genre might seem risky. In Brookmyre's case, though, it seems more like a logical progression. Levelling up, if you like.
"There's a prominent crime fiction critic called Barry Forshaw," explains Brookmyre. "And I was outlining the concept of Bedlam to him and suggested science fiction would be a bit of a change for me. And Barry said, 'there's an argument that all of your books are science fiction. They all take place in a world that sometimes looks like ours, but it isn't really our world.' And I kind of knew what he was getting at."
If you can detect the Nintendogs whistle, there have been hints of Brookmyre's love of videogames throughout his writing. Where Ian Rankin's Rebus would usually namedrop a Hawkwind album, a Brookmyre character might reference a vintage arcade game. In the 2001 novel A Big Boy Did It And Ran Away, Brookmyre's hero is the manager of a LAN café, a guy who spends a lot of time escaping into online worlds, possibly because an old student pal has become an international terrorist suddenly keen to reconnect.
"I didn't want to make it a fantasy. If you're sucked into a videogame, I wanted to explore how that could possibly happen."
Eventually, subtext becomes text. Describing Brookmyre's 2009 book Pandeaemonium as Doom 3 fanfic would be reductive - a better elevator pitch would be "tearaway Catholic schoolboys tool up and take on Hellspawn" - but one of the key characters, Adnan, is a hardcore gamer. And it's no coincidence that when we first meet him, he's playing a port of the original Doom on his DS.
"In Pandaemonium, Adnan is the guy who starts seeing things from a first-person shooter point of view," says Brookmyre. "He has this HUD in his mind. Towards the end, he reckons there must be some sort of final boss coming up because he's clocked there's lots of ammos and weapons just lying around in this underground bunker. Someone else points out that something really big and bad has probably just killed everybody so they dropped their stuff."
Pandaemonium was Brookmyre's brilliant, bloody love letter to FPS shooters, and it inspired Brighton-based indie developers RedBedlam to approach him about collaborating on a game. While RedBedlam's flagship title is a cute browser-based fantasy MMORPG called The Missing Ink, the Brookmyre project was always intended to be an FPS. And not just any FPS, but one that could potentially encompass all of them - a frag-filled mystery tour through the evolution of gaming's now-dominant genre.
"Working with RedBedlam started as something theoretical, because I wasn't sure I'd have enough time," says Brookmyre. "But I finished another book early and that gave me a window to come up with a game concept. The idea was to come up with a meta-FPS, where you could move through entirely different games from over the years, but keep the same weapons and skills. It's a way of acknowledging how these games have evolved over the years, from pure run'n'gun to the current trend for cover shooters."
If the kernel of the experience was the player's ability to straddle archetypal game worlds, Brookmyre soon realised it could also bestride formats. "I needed to come up with a fairly immersive storyline and if I was doing that anyway, I realised the exercise of writing a novel could be what would drew it out." He produced a 15,000-word design document of his vision for the game, and RedBedlam set out to secure investment to fund development, armed with concept art by illustrator Ben Hooley.
That was the birth of Bedlam, but with Brookmyre's formidable workrate, it was perhaps inevitable that the book would arrive first. "I think there was some amusement at how the speed of writing a novel compared to developing a game," he says. "I would check in with RedBedlam every few months, and I think they found it amusing and slightly alarming that I'd written three-quarters of a book since the last time I'd seen them." The hope is to have a beta version of the game ready to roll out alongside the paperback edition of the novel.
The book centres around Ross Baker, a computer programmer who is skilled with code but cannot parse his suddenly unpredictable girlfriend. Working for a large US tech company in a grim industrial estate on the outskirts of a bonny Scottish town, Ross undergoes an experimental brainscan - and wakes up to discover his body has been augmented by armour plating and upgraded with bleeding-edge tech. He's a cyborg killer trapped in a seemingly infinite combat loop that, when it's not absolutely terrifying, seems naggingly familiar.
"What if you're sucked into another world but instead of being the hero, or the villain, you realise you're actually just another grunt, that you're cannon fodder?"
"I didn't want to make it a fantasy," says Brookmyre. "If you're sucked into a videogame, I wanted to explore how that could possibly happen - and the idea of the brain scanner suddenly allowed me to write a story that was about so much more than the initial concept, because when you start thinking about the idea of digital consciousness, you're forced to consider so many implications and consequences."
Once Ross gets over the initial shock of his mangled, upgraded body, he interacts with his surroundings like any gamer would - working out the limits of the world and what exactly his avatar can do. There are pick-ups, and there are power-ups. But why is he actually there? Early on, another character makes an awed reference to "the prophecy" but this turns out to be a typical Brookmyre bait-and-switch.
"I wanted to get out from underneath the shadow of The Matrix," he says. "What if you're sucked into another world but instead of being the hero, or the villain, you realise you're actually just another grunt, that you're cannon fodder? That was my Eureka moment. Because when there's talk of a prophecy, there's a sense of things being predestined, of having to go along with a certain story. But when you're a grunt, there's actually more freedom."
After a few viscera-splattered false starts, Ross begins to acclimatise to his new reality, recognising it as Starfire, a fictional 1990s FPS that bears more than a passing resemblance to Quake 2. Then things get even weirder: Starfire is just one possible game world among hundreds and Ross has enough player agency to travel between them. There are encounters with an implacable empire - The Integrity - and a rebellion force - The Diasporados - framed against a rolling backdrop of recognisable games like Black And White, Grand Theft Auto and Assassin's Creed. There's also a good joke at the expense of Medieval 2: Total War.
"It wasn't really a diss on Total War," says Brookmyre. "I just wanted to have fun with the fact that people might recognise some of the glitches or idiosyncrasies of different games. For me, it was fun to imagine what it would be like to enter a strategy game from an FPS perspective, how it would affect what you saw."
For veteran gamers, there's a lovely moment when Ross finds himself in a 3D representation of an old Spectrum game. It takes only a few surreal signifiers for him to realise he's materialised inside Jet Set Willy. Now 44, Brookmyre has been a lifelong gamer - he got a Spectrum 16k for Christmas in 1982 - and can remember a time when games, like novels, could still be the work of a single authorial voice. "It seems incredible now, when every aspect of a game is parcelled off to different areas of expertise, that someone like Matthew Smith could do it all himself," he says.
Acknowledging the real-world history of games was always part of the plan. "I wanted to show the way that games have evolved," explains Brookmyre. "Guys who are of an age to appreciate the Spectrum or Amiga will bring their own memories to it, but I also wanted to let younger readers know that while old games might look fairly primitive, some of them were way ahead of their time. We wouldn't have a lot of the games we have now if it wasn't for those early pioneers."
There are various nods to the 8-bit, 16-bit and modern console eras, but you get the sense that Brookmyre identifies as a PC gamer first and foremost. "I got my first proper PC in early 1997, so not long after Quake was released," he remembers. "I think that was a golden era of gaming. Even as an adult, it was like being a child again - it really felt like the start of online gaming. With Quake and Quake 2 there was such a culture of modding things, adding your own skins and models to the game. It really encouraged you to look under the hood and start tinkering, trying to get a better ping on your crappy modem."
Modding becomes a key plot point in Bedlam, with Ross using his programming knowledge and FPS experience to his advantage. All those hours Brookmyre spent playing Quake 2 while nominally working to deadline could now retroactively be called research. "I would tell myself I had to keep buying components to stay up-to-date for work, but it was really games that meant I constantly upped the spec," he says. "I bought a PC in 1997 that I didn't get rid of it until 2002, by which time the only things I hadn't replaced were the keyboard and the actual case. It had a new motherboard, new soundboard, new graphics cards, a replacement processor - it was hard to argue it was the same computer that I'd originally bought."
Most gamers will have experienced a time when a particular title has taken over your existence, when you've been staring at a scrolling starfield for so long you can still see it with your eyes closed. That's obviously unhealthy, but where society at large used to condemn videogames as something childish, to be packed away before embarking on adulthood, Brookmyre detects a cultural shift.
"I think we're less inclined to draw that distinction and insist games are something strictly for the earlier part of your life," he says. "The majority of best-selling games have an 18 certificate, so I think in 10 or 20 years, we won't regard games as something just associated with youth. I think adults who play games make better parents - you have to retain that ability to understand the importance of play."
Brookmyre's son Jack turns 13 the day Bedlam is published, and the novel - the first in a planned trilogy - is dedicated to him. "I actually played Quake 3 against my son a few months ago and he annihilated me," says Brookmyre. "I honestly see more games over his shoulder now than actually playing them myself, which I'm hoping to rectify once my new crime book is finished. Jack has been playing a lot of Minecraft, which seems to take over weeks of his life in ways that I can relate to but still find a little disturbing."
As an author, can he point to any great examples of storytelling in videogames? "One of the greatest ever moments is in Portal, the first time you notice that tiny gap between the tiles and you get a glimpse behind the curtain. You see the famous graffiti and realise that there's more to this world than it first appears. You go from playing something pristine, hermetically sealed and therefore quite harmless to something utterly sinister in one beautifully turned and timed moment."
And what about actual writing when it appears in games, either as mythical backstory in RPGs or the frantic datalogs of doomed spacefarers? "I don't mind it in games, but I think it works best if you feel like there's a reward. A game that did it well was the [1998 PC FPS] Sin - you frequently had to break into places and hack computers to find a piece of info to proceed. It wasn't screeds of text but it was good storytelling, leading the player to seek something out and rewarding them for achieving it."
Other popular authors - from David Mitchell to Cory Doctorow - have incorporated gaming tropes and references into their fiction, but it feels like the great videogame novel is still waiting to be written. Brookmyre does have one further reading recommendation though. "I really enjoyed Mogworld, the novel by Yahtzee Croshaw," he says. "I liked the fact he took this World of Warcraft-esque setting and wrote it very directly from the point of view of a character who doesn't realise he's a character. It's a fairly simple idea, and he didn't overdo it, but it had the courage of his convictions and explored it in a very amusing way."
And, of course, there is another science fiction author currently stalking the same battleground as Brookmyre: Neal Stephenson, who as well as writing game-inflected novels, has also recently moved into games development, with his Kickstarter-powered, motion-sensing swordfighter sim Clang.
"There are clearly a lot of videogame references in Stephenson, but I sometimes think it's really the other way round: that videogames are aspiring to be Stephenson novels," says Brookmyre. "For a long time, they all seemed to want to be the Metaverse as described in Snow Crash. I'm very excited about Clang ... but there does seem to be some sort of strange crossover between science fiction writers and medieval weaponry."