Back in November, the Zelda Reverse Engineering Team announced that it had completed its months-long project of decompiling The Legend of Zelda: The Ocarina of Time‘s ROM into fully human-readable C code. Now, a group building on that work says it is nearing the release of a fully moddable PC port of the game.
The Harbour Masters coding team (which shares some members with but is separate from the Zelda RET project) said its porting effort is currently about 90 percent complete. The project will hopefully be ready for release as a public repository by late February, lead developer Kenix told Ars Technica. But while the massive undertaking of decompiling the game provides a good base, getting from C code to a fully functional PC version of Nintendo’s 1998 classic isn’t simply a matter of telling a compiler to “build for PC.”
Actors and assets
When the Harbour Masters began to work in earnest on the PC port in December, Kenix said they “started by removing all of the actors [e.g., interactive objects like enemies, signposts, and bombable walls] and a lot of the game’s systems to simplify the build process and what needs to be changed to get it to load.” Those actors and systems were slowly added back once other problems with asset loading had been handled.
“This gave us great results after only a few hours of work due to what we learned on the ‘minibuild,'” Kenix said.
The reverse-engineered codebase—which deals with game logic, controls, etc.—is also completely separate from the in-game “assets” that make up the look and feel of The Ocarina of Time. That includes visual textures, music, and sound effects but also more basic building blocks like skeletal meshes, scenes, rooms, and even the 3D vertexes and “display lists” that describe in-game objects.
End users will have to use a tool to extract those assets from a separate Ocarina of Time ROM and into an external archive, which won’t be distributed with the final build of the coming PC port. “Our belief is that this will prevent a DMCA takedown from Nintendo on any .exe,” Kenix said. The release doesn’t offer a fully compiled executable, as a previous port of Super Mario 64 did. “This is completely separate from SM64, and we hope this is done better than how that one was released.”
But getting those external assets to play nice with the port’s executable wasn’t simple. Kenix told Ars the Ocarina of Time PC port “has an asset-loading pipeline much more similar to modern games” than to classic N64 titles. While the original ROM simply used memory pointers to reference the data, the port instead uses strings to tag assets at specific locations in the separate archived package.
“We came up with a system that will generate a header file that replaces the pointer symbols with a string reference to the path within the archive, and the symbol usage will use the string rather than the pointer,” Kenix said. “From there, we pass the string to the resource manager and it loads the asset on a separate thread on demand… Most of our work has gone into the process of importing/exporting different game asset types.”
Luckily, though, once one large class of assets had been converted to work under this system, everything just clicked into place without much additional manual work, Kenix said. “Our asset management system, including the import/export routines, have proven to be pretty robust.”
Even now, though, Kenix said certain asset types like skyboxes and pre-rendered rooms aren’t playing nice with the port. A few other rendering issues have popped up, too. The team is also still figuring out how to decompile the game’s music sequences, which are stored in a proprietary MIDI-like format, and encoded audio samples.
Despite all that hassle, the Harbour Masters team has a leg-up on the team that ported Super Mario 64 to the PC. That’s because Ocarina of Time can make use of the same “Fast3D” rendering engine that was coded from the ground up for the SM64 port. The engine converts N64 microcodes into OpenGL or DirectX calls for easy rendering on the PC.
While the OOT port requires support for a few “new” microcodes that weren’t used in Super Mario 64 (such as pre-rendered backgrounds), Kenix said about 80 percent of the rendering pipeline overlaps, saving a lot of porting time. Reusing Fast3D also means that much-requested widescreen support will be ready for the OOT port on day one, Kenix said.
For future N64 PC-porting efforts, Kenix said the Harbour Masters team is also developing a complete library that should “handle all required aspects of an N64 to PC conversion.” That should help speed up a future port of Majora’s Mask once that game is fully decompiled,” he said.