This is the second of two parts on OS X and gaming on the Mac.
focused on how games are ported to the Mac. This installment covers OS X’s impact on gaming development.
When it comes to bringing PC games over to the Mac platform, software developers and publishers have to consider everything from a game’s popularity to how quickly it can be rewritten to work on the Mac OS.
But now the Mac has an entirely new operating system — Mac OS X began shipping in March. It now comes preinstalled on every new Mac. OS X features a Unix foundation, multiprocessor support, greater stability, and new Application Programming Interfaces, or APIs. But will any of that convince game developers to bring more products over to the Mac?
In the long run, probably. For now, OS X’s biggest accomplishment may be to tackle some long-standing complaints developers have had about the Mac’s operating system.
Ask game developers to list their beefs with the operating system that has powered the Mac for more than a decade, and problems with memory allocation will almost certainly top the list. “Memory bugs in Mac OS 9 are a real bastard to find,” says Richard Vincent, president of education software maker Kutoka Interactive. The company has only three coders on staff, Vincent says, so an OS that fixes the memory issue will greatly help development at Kutoka.
Developers also take issue with the old Mac OS’s practice of fixing the amount of memory an application uses. “PC games have huge memory requirements,” says Westlake Interactive Vice President Ken Cobb. “On the PC, the Windows Virtual Memory scheme allows the game to use memory more efficiently. However, on the Mac this can be wasteful.” Cobb suggests that the Virtual Memory system of the classic Mac OS hurts performance — a problem in the gaming world where performance is king.
What’s more, the classic Mac OS has a great deal of legacy 68K code, a remnant from the early Macs that used Motorola 680X0 processors, or 68K processors. The 68K processors were replaced when Apple began using the PowerPC chip in the Mac. But the Mac OS continued to use code specifically written for 68K processors. PowerPC processors can emulate that code, but at the cost of a small performance penalty.
The old Mac OS also doesn’t use preemptive multithreading. The lack of multithreading support largely affects performance on multiprocessor systems. But Mac users with single processor systems can enjoy performance benefits if they have an application that’s coded to support preemptive multithreading. Games on the PC are commonly multithreaded; adding this capability to the Mac OS should help game performance on the platform.
Some Classic Changes
Mac OS X tackles all of the gripes about the old Mac operating system. OS X’s new protected memory feature allows developers to debug memory problems that would have crashed the system previously. OS X also allocates memory dynamically and uses a far more sophisticated Virtual Memory system than its predecessor. The result? PC games ported to the new OS will use memory more efficiently.
OS X finally does away with all the 68K code that was written into the Mac’s operating system more than a decade ago. And developers couldn’t be more thrilled. “We expect a major performance boost from a fully Power PC system,” says Philip Sulak, vice president of Westlake Interactive. “Already, file loads are noticeably faster under Mac OS X.”
Finally, OS X adds symmetric multithreading support. “About half of the games we are getting from the PC developers are threaded for ease of coding,” Sulak says. “Even without another processor, the threading system in Mac OS X is much better.”
Take games played over a network. They commonly create a program thread to handle network data for the game. When running in the old Mac OS, that thread often needs to resolve before the game can resume playing. In Mac OS X, however, that thread can be preempted. The processor is allowed to work on the important task of playing the game instead of waiting on the network data.
Cocoa or Carbon?
But while OS X brings numerous advantages to game developers, it also raises its own set of challenges. Many of these issues are growing pains for an operating system in its infant stages and will be addressed over time. Other challenges arise from a lack of experience among developers with the new OS.
OS X gives developers two routes to the desktop — Carbon and Cocoa. A Carbon application uses programming interfaces derived from the way that the old Mac OS did things. So, a Carbon application will run on both Mac OS X and any version of the Mac OS later than 8.1. Cocoa applications are developed using a set of frameworks with programming interfaces in Java and Objective-C.
Carbon acts as the bridge between the classic Mac OS and Mac OS X. “We’re going the Carbon route for now” Westlake’s Cobb says. “Users of Mac OS 8 and 9 are still going to be our biggest customers.”
Trey Smith, technical director for GraphSim Entertainment, suggests that it will be easier for developers to ship one CD with the Carbon application that will work on both OS X and earlier versions of the Mac OS which will still be in use for some time.
Apple has no problem with developers using Carbon for Mac games. “Carbon is a first-class citizen, and Apple is telling developers to choose the API that fits their knowledge best,” says Mac OS X Product Manager Chris Bourdon.
Developers at Westlake and GraphSim both believe that Carbon will increase time for porting and developing games, but only because they have to learn how to work with the new OS. “In time, Mac OS X will reduce port time,” Cobb says.
Cocoa poses a trickier challenge for developers who are unfamiliar with that API. Developers typically write PC games in C++. But Cocoa requires the use of Java or Objective-C.
While C++ and Objective-C share common traits, the two languages are not identical; there’s no one-to-one correlation between the two. As a result, translating C++ to Objective-C adds one more hoop for game developers to jump through when bringing PC games to Cocoa.
The Case for Cocoa
So why go Cocoa? Because developing in that API will improve the overall performance of games — or at least, that’s what game companies believe. “I have not done any Cocoa development yet, but I have a suspicion that Cocoa may provide better performance,” says GraphSim’s Smith, echoing a sentiment expressed by other developers.
Besides, companies such as The Omni Group that have more experience working OpenStep — the NeXT OS that Mac OS X is based on — know Cocoa better than they do the classic Mac OS. Various Cocoa games ported by The Omni Group were on display at last month’s Worldwide Developers Conference in San Jose, CA.
Likewise, a Cocoa version of Id Software’s Quake III Team Arena was on display in Apple’s meeting room at the Electronic Entertainment Exposition in May. Id’s Graeme Devine says that the latest Doom engine is being created in C++, with an Objective-C interface translating that code for Cocoa.
The Omni Group is working on a few ports to Cocoa. “Everything we have done so far was written with C++,” said Executive Vice President Tim Wood.
The first step the company takes is to abstract out any platform- or language-specific code into C, the predecessor of C++ and Objective-C. Since both languages have a foundation in C, code written in either C++ or Objective-C can be rewritten in C. This abstract is then run through a vanilla C compiler to allow The Omni Group to develop a one-to-one correlation between the different languages. The process isn’t that difficult, Wood says. “There aren’t that many pieces of API that are different between the two languages,” he adds.
After The Omni Group takes care of the translation, it tackles byte-swapping issues. “After that, the game should at least launch,” Wood says. “At that point, it is typically clear where the bugs are. Then it’s on to optimization and testing.”
Wood thinks that porting to the Mac is faster with Cocoa. And some of the issues surrounding the differences between C++ and Objective-C might be rooted in Mac developers’ lack of experience with the new API. “I think a lot of this needs to be addressed through education of what Cocoa is, why it’s wonderful, and how things like runtime in Objective C can make your days a whole lot nicer,” Id’s Devine says.
Apple’s Work Is Never Done
As with any brand-new operating system, some of the APIs in Mac OS X still need a little polish. Many Mac developers worried about OS X’s Human Interface Device APIs, which allow a game to use joysticks or game pads. Apple is working on the issue, releasing a new software development kit at its developers conference.
The Sound API also needs a few improvements so that it can include features such as Dolby 5.1 and 3D surround sound. Since these features are common on the PC, games coming over from that platform have them built-in already.
Many developers are looking for a better implementation of OpenGL, an industry-standard 3D graphics API. “More companies use Direct 3D than OpenGL,” Smith says. “The biggest thing that Apple could do to get more Mac game titles is to convince Microsoft to port DirectX and MS Foundation class libs to the Mac.”
While that is unlikely, it’s possible that Apple could look into a new OpenGL implementation that deviates less from the DirectX standard. DirectX and OpenGL use similar concepts and similar APIs.
Apple says it’s doing what it can to make the Mac a more attractive platform for games. The biggest step? Selling more Macs. “The best thing we can do is to get more Macs into the hands of consumers,” says Bard Williams, senior manager of worldwide markets at Apple.
By embracing open standards and top-tier graphics hardware, Apple has made moving games to the platform far easier than at any point in the Mac’s history. “We are helping developers find the tools they need to make great games,” Bourdon says. “Also, improving the overall portability of code is a goal at Apple.”
Only time will tell if OS X will boost the number of games ported over to the Mac. OS X has certainly removed some of the obstacles in porting a game to the Mac. But developers will need time to gain experience with the new OS. They also need Apple to bring Mac OS X’s drivers to the same level as that of the classic Mac OS.
Still, developers like what they’ve seen from Apple so far. “Apple’s rate of progress is stunning,” Wood says.