bit-gamer.net

The Problem With Porting Games

Remixing and recompiling for different hardware

You don't need to be a 1970s stand-up comedian to know that there's a large lexicon of monosyllabic, four-letter words for describing something you don't like – but only PC gamers use the word “port” with such a fervent degree of repulsion. Common complaints about console ports include meagre graphics options, dodgy third-person camera angles, poorly thought-out controls and sparsely distributed save points.

Making games for multiple platforms can't be easy though. After all, each current gaming platform has radically different processor architecture, as well as completely different controllers and graphics APIs. That's before you've even considered storage, memory and online abilities. Just how do you develop a game for so many different types of hardware, and is it possible to make a great game across three consoles and the PC?

Let's start with the different CPU architectures. PCs use CPUs with Intel's x86 instruction set, the Xbox 360 and Wii use CPUs based on IBM's PowerPC architecture, and the PlayStation 3 uses the Cell architecture. You'd think that generating code for each CPU would be a job for master coders, but there's apparently little work involved here.

This is because a huge chunk of the code for a game is written using a high-level language, such as C or C++. This is where the core code for the actual game is written, often using a number of industry-standard tools, such as Microsoft's Visual Studio, or specifically developed in-house tools. A particularly popular language is Lua, which has a C API and is used by plenty of developers, including Bioware, LucasArts and Telltale.

The problem with porting games Remixing and recompiling for different hardware
The PS3's Cell CPU has a very different architecture from a 45nm Intel Core 2 Quad CPU (pictured), but getting a game to work on both CPUs is now just a job for a recompiler


In fact, the developers we spoke to estimated that around 90 per cent of the game code is shared between platforms, so what sort of game features are included in this huge block of code? Volition's Dave Baranec, the system architect on the PC version of Red Faction: Guerilla, explains that this includes “the key libraries for rendering, audio, file system and memory management. Any sane development process involves creating these libraries in such a way that there is a common abstract interface that can have the details filled in later”.

Once the basic code is written, it goes through an automated process of recompiling, which is often created in-house by a developer as a part of its tools pipeline, in order to make it run on other processor architectures. In this case, compiling refers to the process of transforming high-level source code into low-level code that can be understood by the processor. After that, there's usually a bit of tweaking in machine code (the native language of the processor architecture) or assembly code (a low-level, symbolic representation of numeric machine code), but this apparently occurs less frequently now.

“It's all done in C++,” explains Visceral's Colin 'Bozz' Boswell, technical director on Dead Space, adding that “we do write a very small amount of assembly code. Very occasionally, we'll go in and do spot optimisations on functions that are used a hell of a lot in the game, but we try not to do that because the compilers are pretty good at optimising now, and sometimes you can actually make matters worse by doing [it yourself]”.

As the game is written in C++ for all platforms, Bozz says that “the actual porting of code is generally just a matter of recompile. We've been doing this long enough to have developed a set of macros and header files that abstract-out all the other specific differences. So, from a pure source code point of view, you'll occasionally get the odd warning or error on one compiler that you don't get on another, but that's very low”. Telltale Games' co-founder Kevin Bruner describes a similar process for porting Telltale's recent episodic adventure games Sam & Max, Strong Bad and Wallace & Gromit from the PC to the Wii and the Xbox 360.

“Most of our code is written in C,” says Bruner, but adds, “We still have a machine code here and there. For those parts, we have [both] an x86 version and a PowerPC version.” However, the recompiling process is now so efficient that it's not a major issue.That said, even though the bulk of the code is shared, developers often have to hop between different tools for different platforms. “Any developer who is being honest will tell you that these days the act of writing engine level code for a game is the act of being a glorified data wrangler,” says Baranec.

“Taking source data, piping it through a complex series of source control, data processing and massaging tools, arranging it on disk, loading it at the right time and handing it out to completely different pieces of hardware, and then being able to test it is a really difficult dance. Ideally, you would write the code to do this once, but the reality is that each system has certain ways of operating, and unique tools provided by the manufacturers to enable this, so you end up having to modify your workflow for the different platforms.”