In modern times, preservation efforts are running on an ever dwindling timer. Every year, it seems as though more and more games lose their online components. And with games increasingly relying on interactivity and other online features, even a single player game can lose a sizable portion of its content when servers go down. While the Wii mostly dodged that bullet by having a relatively lackluster online infrastructure, we too have seen experiences disappear before our eyes.
Four years ago, Wii Network was merged into Dolphin after over two years of work. It was one of the most anticipated features and was thought to be unthinkable. Wii Network's success represented a massive achievement in an era where parts of Dolphin were still only capable of basic Wii emulation. Despite multiple developers and a concerted effort, one of the games used for testing Wii Network had shut down by the time of its merge: Monster Hunter Tri.
In the case of Monster Hunter Tri, its Wii servers went down even before the official Nintendo servers. A lot of the game's content and value was suddenly gone with the publisher's only response to buy the shiny new Wii U version. It seems as though the same may be happening yet again. Late into the Wii's lifecycle, Dragon Quest X was released on the Wii as a full-fledged MMO that pushed the console beyond its natural limitations. And with the deadline of server shutdown looming, we decided that we were going to make it on before it was too late, come hell or high water.
The Most Peculiar of Wii Titles¶
Dragon Quest X defies much of what it means to be a Wii game. When you open the box, you will immediately notice two things. First of all, it is the only Wii game to use two discs for a single game. But these two discs are merely for installation: along with the game discs comes a 16GB USB drive that plugs into the back of the Wii and is required to play the game. That's right: Dragon Quest X installs itself to USB on the Wii! Even though this is common practice on recent consoles like the PS4, this is the only title with this behavior on the Nintendo Wii.
Released by Square Enix in 2012, Dragon Quest X was already a fairly big game. But like most MMORPGs, the game has received frequent updates and several content patches over the years. To stay up to date with all the new features in the game, Dragon Quest X is also the only commercial Wii game that supports downloadable patches. In fact, going from version 1.0 on the original game DVDs to the latest version 3.5.7 requires downloading nearly 10 gigabytes from the internet! That latest patch was released August 16th, 2017, making Dragon Quest X one of the last Wii games still under active development. But that's not all: if you want to enjoy the full game, you'll also want to acquire the two game expansions, each released as an independent physical Wii release with unique case artwork!
Why haven't you heard of this crazy Wii game? Despite the massive amount of content and huge aspirations, it never saw a western release. Despite being limited to Japan, the Wii version alone sold over 700,000 copies and is currently active with a subscription service. Including copies released on other platforms, Dragon Quest X should be considered a commercial success with over one million units sold and a very active player base. While the game may look better on the Wii U or Switch, there's no denying that Dragon Quest X on the Wii is a masterpiece of working within limited hardware. So let's dive into how they made this thing work, and how close we came to never getting a chance to emulate it.
Using Every Last Resource Available¶
Square Enix heavily collaborated with Nintendo on this title in order to make the impossible a reality. As such, not only does Dragon Quest X rely on many obscure internal features of the Wii, but some features had to be added to the Wii Internal Operating System (IOS) exclusively for this game. This list of features shares a lot in common with what a Dolphin developer in 2008 might write when coming up with a list of "Features that will be a total pain in the ass."
Wii networking¶
As Dragon Quest X connects to both Nintendo's infrastructure over HTTPS and to Square Enix's servers, a complete implementation of IOS's network functionality is required to get online.
Fortunately, Dolphin master has had support for connecting to the Wi-Fi Connection since the exact day Nintendo announced when the WFC servers would be going down! While emulation back then wasn't nearly good enough to accomplish what is needed for Dragon Quest X, the foundation was solid enough to handle most network functionality and much of the code remains intact to this day. Without all of that done while the servers were still up, there's a good chance Dolphin never gets any online support. These days it may seem par for the course to try to emulate everything, back then Wii Networking seemed like a pipe dream, and it's still incredible to have footage of Dolphin playing alongside real Wiis in games like Mario Kart Wii and Super Smash Bros. Brawl from before the shutdown.
Compared to some of the stuff that would follow, these achievements would seem like par for the course, but back then, luxury features like this weren't the name of the game. Wii Networking's initial implementation hasn't actually changed much; improvements since then have mostly come from better emulation elsewhere and a better understanding of how the Wii works in general.
Proper Wii Menu functionality¶
Unlike most other titles, Dragon Quest X requires proper Wii System Menu functionality to even have a chance of getting into the game.
System updates¶
Dragon Quest X is a very special title. While most games don't care about the IOS version, both the installer and the online updater will check for it and refuse to work if the system software is too old. In fact, not only do they check whether the IOS is installed, they will even make sure the revision is new enough! This behaviour is so unique that this even caught developers off guard, as they tried to figure out why the installer would mysteriously fail.
It is possible to manually install required system titles and updates, but this was a hassle; one that did not exist on an actual console because the Wii Menu would force users to update before launching the game.
Thankfully, months before work on Dragon Quest X resumed, updating from discs and from the Internet was implemented in Dolphin. It is now possible to simply insert the game disc and rely on the Wii Menu to update everything, just like on a console. With all of the updates that Dragon Quest X demands, this was an important usability fix.
Channels¶
Mario Kart Wii, Wii Fit, and other games install channels to the Wii Menu to provide optional extra features. But as with everything else, Dragon Quest X does things differently: the small channel it installs to the NAND is not optional, but required in order to play the game.
Basic channel installation was implemented with Dragon Quest X in mind several months ago. While the initial implementation in January 2017 was enough to install the Dragon Quest X launcher channel, more related features had to be implemented to support the game's update system.
Advanced E-Ticket Services (ES) functionality¶
Born as a GameCube emulator, Dolphin made a very reasonable assumption for a GameCube emulator to make: that the active title wouldn't change in the middle of emulation. With the Wii, not only is it possible to launch a game/channel from the Wii System Menu, users can go back to the menu, and any arbitrary title can be launched at any moment.
The Wii accomplishes this with E-Ticket Services, a part of IOS that has been mostly broken in Dolphin for a decade and only started receiving plenty of fixes lately. ES is a large module that plays an essential role on console: it is responsible for booting up the Wii System Menu, for importing titles, system updates, etc.
While most of the fixes to ES emulation were made before anyone imagined even running Dragon Quest X, it turns out they were all necessary for getting into the game, and particularly its online mode.
ES_Launch and IOS resets¶
As its name indicates, ES_Launch is a command that enables emulated software to launch another title. This feature has been broken in so many ways and fixed so many times that we've literally lost count.
Dolphin has historically had a lot of trouble with it, both because of regressions and because the Wii's behaviour wasn't always understood well enough. For a very long time, we didn't know that the same command is used for launching both ARM titles and PowerPC titles such as channels, nor the differences between these two types of launches. To make things even more complicated, launching an IOS resets its whole state, and launching a PowerPC title automatically triggers an IOS reload — both behaviours that Dolphin did not emulate either.
In fact, at one point, ES_Launch itself wasn't emulated; instead, functions that would trigger a launch were hooked and replaced with high-level reimplementations. While this did make many games playable for the first time, this resulted in various issues, from the launch straight up failing (if the functions weren't detected) to the disc channel being broken. As another example of how touchy ES_Launch was, fixing it once broke connecting four Wii remotes!
Even though Dolphin stalwart magumagu fixed lots of problems that were inherent with Dolphin's old implementation and IPC code back in June 2014, Dolphin's ES_Launch implementation was still incorrect even for common cases.
Note that this video is from 2014, and we were touting that ES_Launch was finally fixed. Then it broke again in 2015 and was fixed. Again in 2016. We're now in 2017, and again very confident that the implementation is now correct. This time, developers finally got around to replacing the hardcoded numbers with actual values that depended on the active IOS thanks to booto's work. And thanks to leoetlino implementing the different reload behaviours in Dolphin, we're fairly certain that ES_Launch's implementation is actually correct now... for real, this time. Oops, not that time, this time.
ES_Launch and IOS resets being handled correctly are absolutely required for Dragon Quest X, as it uses ES_Launch more than any other title. Even when just going online the game does at least three consecutive launches:
- Wii Menu → Channel on NAND (ES_Launch)
- Channel on NAND → Main menu application on USB drive (WFSILaunchDol, default.dol)
- Main menu application on USB drive → Channel on NAND (ES_Launch)
- Channel on NAND → Updater application on Wii File System (WFSILaunchDol, extension1.dol)
- Updater application on USB drive → Channel on NAND (ES_Launch)
- Steps 4 and 5 are repeated until the game is up-to-date.
- Channel on NAND → Login screen & game (WFSILaunchDol, extension2.dol)
Title tracking¶
Even though ES functionality was implemented in Dolphin years ago, it did not keep track of the titles during the switch. This created a few problems, such as GameINI settings not changing after a switch, but it wasn't a high priority since why would people using Dolphin go through the System Menu anyway? A lot of the assumptions and hardcoded values back in the day made it hard to do things properly even if it was necessary.
In 2017, some developers realised that it didn't really make sense to be lacking this ability. After all, IOS was designed to enforce separation between titles, so it had to track title changes. And if it could track them, Dolphin would need to as well. Thanks to years of improving code, by the time we actually needed title tracking most of the work had already been done. As an unexpected bonus, this allowed on-disc updates to install correctly from various games. In the case of Dragon Quest X, this is the easiest way to get IOS59!
More important than that, title tracking was paramount for getting the file system that Dragon Quest X relies on to function properly. We'll be saving that for later: there are a few other key pieces to get through first!
Title information requests¶
Dolphin already had basic support for telling the emulated software what is installed on the NAND, giving TMD and ticket views, but the implementation was woefully incomplete and even plain wrong in some instances. Thanks to proper title tracking and cleanups that made it much less painful to work on IOS, fixing these issues didn't take too much effort.
Soon after DQX's online updater booted for the first time, it quickly became very obvious that the accuracy boost was in fact required.
Wii shopping (EC)¶
One of the biggest reactions to Wii Shop Support when we announced it back in March was Why?? It seemed like a very pointless luxury without much use. After all, who would be insane enough to buy a game directly from Nintendo's servers from within an emulator? Other than JMC4789, at least.
But, Wii Shop support wasn't due to some magical, localized fix. Rather, it was a bunch of fixes to how Dolphin emulates ES, so, those fixes actually affected anything that uses its more advanced features and ended up being useful for much more than just the Wii Menu: homebrew compatibility was improved, and a huge part of getting shop functionality to work was done.
After nearly a hundred commits dedicated to better IOS and Wii Menu emulation, all that remained to be implemented was support for personalised tickets.
Personalised tickets¶
As a quick primer, Wii software (system software, channels, games) are organised by titles and encrypted using AES-128 CBC using a per-title key, known as the title key, that is itself encrypted with a shared secret (the "common key"). The encrypted key is found in a signed file called a ticket.
There are two kinds of tickets: common tickets (or cetk), which are the same for everyone, and personalised tickets. Unlike the former, personalised tickets are issued for a specific console: the encrypted title key is itself encrypted using asymmetrical cryptography and can only be decrypted by the console to which the ticket was issued.
All system titles and games use common tickets, whereas all titles that can be downloaded from the Wii Shop — even items that are free to download — use the latter. This was likely done to make piracy harder. Handling personalized tickets correctly in Dolphin involved a lot of reverse engineering on how the Wii decrypted titles and other quirks that were never thought to be important. With help from ace reverse engineer booto and a mythical Starlet emulator that may or may not exist, leoetlino was able to figure out how personalised tickets worked and taught a Dolphin how to shop.
Bringing patches to a system that didn't support them¶
The Wii is well known for not having any kind of patching system for disc games. When a bad bug was discovered in a game, all Nintendo could do was print new versions of the game disc, and perhaps also release a channel to fix affected save data. Fundamentally, the Wii was not designed with patching games in mind, so they were unable to fix any bugs once a game was released.
So, how does Dragon Quest X, an online MMORPG that requires regular online updates, solve this problem?
As it turns out, the game gets its updates from the Wii Shop infrastructure and uses the exact same EC (E-Commerce) library as the Wii Shop Channel! Suddenly, all of those fixes turned from luxury to necessity.
That's right, one of the prerequisites to getting Dragon Quest X to work is getting the Wii Shop to work. Without leoetlino's work on the IOS emulation throughout the year, it'd been much harder to get online before the game's servers went down.
New USB modules¶
One IOS subsystem that has received major changes over the Wii's lifetime is USB. No less than five different interfaces exist, and a lot of them can be used by software running on the PowerPC:
- OH0: This is the earliest interface. It is used in a lot of homebrew and in commercial titles for Wii Speak and Microphone support.
- OH1: A trimmed down version of the OH0 interface used for the internal Bluetooth adapter.
- HIDv4: Used to interact with Human Interface Devices, such as keyboards and other input devices.
- VEN: In late IOS versions, this is a replacement for the old OH0 interface. It's a more complex interface that supports USB 2.0 (in IOS58 and IOS59) and handles devices that have the same ID better.
- HIDv5: Just like VEN, this replaces the HIDv4 interface in some IOS versions.
While Dolphin already supported the first four of them since February, HIDv5 wasn't implemented, as it didn't seem to be used by anything. ...Of course Dragon Quest X used it.
Dragon Quest X makes use of this rare USB interface for USB keyboard support, and is the only official title to do so. However supporting this has turned out to be mostly optional, as stubbing it out works well enough for the game, and the keyboard is only optional for players. Until a complete implementation is finished, players on Dolphin will just have to use the Wii Remote IME that the developers provided, as clunky as it is.
The real challenge came from another unique feature of the game.
Wii File System¶
Wii File System, or WFS, is the custom, encrypted file system that was designed for the Wii U. So what's it doing here on the Wii? At some point during Dragon Quest X's development, they decided that they wanted to tap into the Wii's massive userbase to try and get a boost for their new game. As such, developers feverishly worked on Dragon Quest X to backport the IOSU (Internal Operating System for the Wii U) features it needed to Wii. Because the Wii only had 512MB of NAND, there was no way Dragon Quest X could install there, so developers had to make use of the USB ports on the back of the Wii for expandable storage much like they could on Wii U. This is where WFS comes into play.
One of the main challenges with WFS is the amount of reverse engineering that was required to understand how it operates. Its IOS module is several megabytes large, containing both high-level features (title management, package installation, ...) and low-level features (block cache, USB device management, ...). Since it was only released in 2012, long after the glory days of the Wii, nobody really looked at it in detail until Dolphin needed it for Dragon Quest X. We had to do everything from scratch, and we couldn't rely on prior research, since there was none!
Late last year, delroth took on the goal of making Dragon Quest X run in Dolphin. However, this kind of reverse engineering project is tricky to combine with a demanding full time job. Being efficient at reverse engineering new systems requires keeping a lot of context in your mind, something that is hard to do when interrupted for nine hours every day by pesky IRL requirements! Work started at the end of 2016 during the 33c3 conference in Hamburg, Germany and continued during the beginning in January during a one week visit in a hackerspace in Lübeck with several console hackers and emulation developers. Even though Dolphin wasn't close to launching Dragon Quest X Online at this point, its installer was working. More importantly, research was done on WFS that was essential for future endeavors to complete WFS emulation.
The nice thing with emulating WFS in Dolphin is that we can afford taking shortcuts. For example, Dolphin does not care in the slightest about how the filesystem on USB looks like as implemented by Nintendo. The only important part is that game can communicate with the WFS modules as if they were real. Instead of emulating at a low level a USB drive with sectors and storage blocks, we instead operate at a higher level -- emulating file descriptors, open/read/write/close operations, etc.
Work started again during the SHA2017 hackercamp in Zeewolde, Netherlands two weeks ago. During this event, several European emulation developers and Dolphin contributors assembled to work together on their passion. After a few more days of work on WFS, a patched version of Dolphin managed to boot the game to its main menu. Just one day later and it was the first time anyone was ever able to play the offline mode of Dragon Quest X in an emulator!
Unfortunately, by the end of the event, delroth was still stuck on the last wall between Dolphin and the online mode: getting the game to upgrade to its latest version. Working with leoetlino, IOS and Wii Shop expert, and with marcan, console hacker extraordinaire who owns an NTSC-J Wii with the game installed, the team continued to make progress until they got to the login screen. Strangely enough, some of the last hurdles for getting Dolphin in had less to do with emulation issues and more to do with language barriers and restrictions that would even hit console. Despite Wikipedia claiming that the geoblocking was removed in 2014, we can confidently say the Wii version still requires you to be a on a Japanese IP address.
With that taken care of, on August 18th, 2017, delroth logged onto Dragon Quest X within Dolphin.
Legacy¶
Dragon Quest X is a massive achievement on the Wii, and was a huge challenge to emulate in Dolphin. We're happy to announce that Dragon Quest X is fully playable in version 5.0-5291 thanks to an incredible effort by delroth, leoetlino, along with many others over the course of this project. Features that were thought to be pointless for games came into play in spectacular ways and validated work that was originally just done for "accuracy's sake." With the Wii version of the game scheduling to shut down in November of 2017 (just a couple months away), users looking to get into this game should stick to one of the other releases. With Playstation 4 and Nintendo Switch releases coming out soon, the game should be around for many more years and be allowed to change without having to cater to the Wii's limitations.
We're thankful to have gotten the chance to play this game from within Dolphin; it is bittersweet that our time together will be so short. We're hopeful that Dolphin's ability to emulate it will help preservationists get a better look at how the game works and maybe some of the functionality necessary to play the game could be restored in the future. Beyond that, Dragon Quest X was extremely important to Dolphin as well, as it let us test and verify features that were used nowhere else. While the online portion of this game may be disappearing, Dragon Quest X does have an offline mode and unique story that will at least show some of what this strange, strange game could do.
For a few days this November, past and future will collide, as players on the newly released Nintendo Switch version will be able to play alongside Wii (and Emulated Wii) players before service ends for the original version of the game. With the last month of the game being free for Wii users, we expect the console's userbase to show its strength for one last hurrah.