Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Aspyr's Universal Binary Experience: Bringing Games to Intel-based Macs

When Apple began the transition to Intel-based Macintosh computers, and notified developers that they must convert their applications to universal binaries, Aspyr's developers immediately began thinking about what they would need to do to get their games ready.

Their first task was to decide how to prioritize titles for the conversion to universal binaries. Aspyr's products include many of the most popular in the Mac game market, and their large library of games—each with its own, often fanatical, user base—has been built over several years of Mac software and hardware releases. There was a lot they needed to consider in prioritizing and creating their transition plan.



Aspyr has always understood the benefits of keeping up with Apple's ongoing hardware and software improvements, so their response to the move to Intel-based Macintosh computers and universal binaries wasn't surprising.

As Director of Development Glenda Adams explains, “We have to be able to ship games in 2006 and beyond as universal binaries. We need to update some older games to run natively on Intel, so switching to Xcode, making the effort to build universal binaries, and then testing on both platforms is vital.”

With their commitment to the platform and clear understanding of the technologies, Adams and her developers began setting their transition priorities. They looked at a variety of criteria: the resources they had available, the revenue they forecast from the sales of each title, and finally, the time required to update each title. Another key factor was the release date of the game. The newest games were generally the highest priority, and there were some older games that could clearly be assigned a lower priority. The games in the "in-between" category were the hardest to prioritize. These they examined on a game-by-game basis, and prioritized by looking at each product's details.

Creating the First Universal Binaries

In general, it was the most recently released games that Aspyr has focused on first. These are not only among the most important to Aspyr as products, they also tend to require tremendous processor and system resources. These games had to be transitioned to universal binaries as soon as possible in order to be playable at top speed on Intel-based as well as on PowerPC-based Macintosh computers. The Aspyr team got a few of the Intel-based Macintosh computers from the Apple Developer Connection and set to work.

Some of the older games (more than two years or so) were created in the era of slower processors, and are less processor and resource intensive. The decisions about moving these to universal binaries could be deferred, since they should function reasonably well under the Rosetta translator. But Aspyr knew that only thorough testing will tell for sure, so the priority task for these older games is to test how well they run on an Intel-based Macintosh using Rosetta.

For the "in-between" category—games that are six months to two years old—Aspyr decided to focus first on the key titles. They looked at which games show the most promise in terms of sales, and considered factors like the game engine used, ease of porting (does the game use old Code Fragment Manager libraries, for example), customer support requirements, and continuity of the series (if any). Sometimes the transition path was clear and easy.

“We currently have Doom 3, The Sims 2, Star Wars Knights of the Old Republic, and Jedi Academy compiling under Xcode and GCC,” says Adams. “Doom 3 started its life under Xcode on the Mac, so that was fairly straightforward to move to GCC 4.0, although we did have to deal with template class issues.”

For games that are still selling sequels like The Sims, it makes sense to start work right away on developing the universal binaries, even for the older titles in the series.

“We chose to start with The Sims 2 to move over simply because it is our best selling game,” says Adams, “and one we really wanted to move to a universal binary as quickly as possible.”

For the other in-between titles, it depended on a number of factors, and each seemed to be somewhat unique.

For example, Glenda says, “Knights of the Old Republic had already had some initial work done moving to Xcode before the Intel announcement, so it was a natural to move all the way over. ”

For other games, the Quake 3 engine made the move to Xcode 2 and GCC 4.0 an obvious decision.

As Adams explains, “Jedi Academy we chose because it was a Quake 3 engine based game, We have several Quake 3-based games that have shipped over the past couple years, so moving that engine to Xcode and GCC 4.0 gives us a better chance at supporting Intel-based Macs with other Quake 3-based games.”

The Power of Xcode and Distributed Builds

For Aspyr, moving to Xcode was already a work in progress. In some cases, Aspyr's games were already building in Xcode before Apple's announcement. In others, the games still used some other build environment. Either way, the path to universal binaries clearly goes through Xcode.

So far, the transition to Xcode has gone smoothly and Glenda says that they are particularly excited about one of Xcode's more advanced capabilities: distributed builds.

According to Adams, “In some early tests with Doom 3, we've been able to shorten compile times for major recompiles significantly.”

Moving to GCC 4.0

The switch to GCC 4.0 has been a bit more of a challenge than the move to Xcode. Fortunately, the changes required have been relatively minor. For example, GCC 4.0 is more strict about C/C++ standards than the earlier version of the compiler (GCC 3.3), especially where C++ templates are concerned. In GCC 3.3, a method 'bar()' of a template child class could call their parent template's methods directly. For example, under GCC 3.3 a child function could call a parent's method 'foo' via a simple 'foo();' call. However, with GCC 4.0, that same call must explicitly specify the object, by calling 'this->foo();'.

Glenda comments that, “While this is a simple code change, when you have a large codebase with hundreds or even thousands of classes, it can mean a lot of one-line changes throughout the source.”

But moving to GCC 4.0 has brought many positive changes, and it has even identified at least one problem in the code that other compilers overlooked: void functions returning values. While this isn't something that you would do on purpose, in large code bases with many warnings it is easy to overlook such minor problems (often functions returning zero instead of nothing). GCC 3.3 would simply issue a warning but in GCC 4.0 such code generates an error that must be fixed. This means more solid code and fewer bugs in a shipping product.

Building Universal Binaries

Once a game is building in Xcode with GCC 4.0, it is time to “flip the switch” and build a universal binary. Since Aspyr primarily deals with games that were originally written for the Intel processor architecture, they had added a lot of byte-swapping code to handle the byte order differences with the PowerPC architecture. With the transition, those byte-swapping routines need to be pulled out of the code or surrounded with conditional compilation directives so that they only activate on PowerPC machines. For some of the games, the change was isolated to a single set of functions or macros. In others, Aspyr's engineers found multiple copies and different implementations of the byte-swapping code that needed to be updated.

In addition to the explicit byte-swapping code required by the Intel to PowerPC conversions, many OpenGL-based games rely on Apple-specific extensions that automatically byte-swap texture data in the video card and its driver.

According to Glenda, “it took a few tweaks to the rendering code to stop having everything drawn in red!” This is in reference to a frequent problem with byte-swapping errors in OpenGL texture handling code, where colors display incorrectly.

Some Background on Aspyr

Aspyr is the leading Mac game publisher and they are responsible for bringing some of the most popular games to the platform, including The Sims series, Call of Duty, Tiger Woods PGA Tour Golf 2005, Doom 3, and many others. The company is well known for providing tremendous support for their titles through frequent updates. Aspyr even releases occasional updates for older games, much to the delight of diehard fans, just because they can—and because their fans are grateful.

For more information about Aspyr and their products, see the Aspyr Media, Inc. webpage.