This site may earn affiliate commissions from the links on this folio. Terms of use.

Emulating consoles on modern PCs is a complicated business. In that location are significant low-level differences between the architecture of a console and that of a PC. While some of these issues can be brute-forced by raw computational horsepower, others heavily resist this kind of solution. Dolphin, the pop emulator for GameCube and Wii titles, recently released a major update to its own source lawmaking that finally enables emulation on the last championship standing: Star Wars: The Clone Wars.

The team published a blog mail service detailing how information technology accomplished this chore. Information technology's an interesting example of how the original developer's determination to take reward of some rarely-used GameCube capabilities prevented their game from being emulated for over a decade. In this instance, the problem boiled down to the GC'south memory management unit, or MMU.

The MMU inside the GameCube provides games with virtual retention addresses that it maps internally to physical memory locations. The MMU is capable of providing either a Block Address Translation (BAT), which remaps a large clamper of retention, or with finer-grained page tables for minor amounts of retentiveness. The GameCube used an MMU in the first place because information technology allowed the CPU to cache retentiveness accesses, and because there'southward simply 24MB of RAM in the system, despite having a 4GB maximum addressable space. The diagram beneath shows how MMUs piece of work, in full general terms.

MMU_principle_updated

Image past Wikipedia

Dolphin was already capable of emulating the GameCube's MMU in several ways. Most games but utilize the default BAT mappings provided by Nintendo. Back up for this fashion is hard-coded into Dolphin. The emulated console doesn't "know" that its data requests are being filled from a very different retention subsystem than the one the GameCube shipped with. In this mode, the MMU isn't actually doing any accost translation — information technology knows where the GameCube expects to find memory based on the accost passed to it, and it retrieves the corresponding block of data from the PC's RAM.

The second form of emulation that Dolphin supports is predictable invalid retention requests. The GameCube included 16MB of RAM that was mapped to the audio DSP, merely many games apply this pool for additional memory. Provided they do so in predictable fashion, Dolphin tin can grab those addresses (even though they're invalid) and hand the game the information its requesting — provided it ever requests data from the aforementioned set of invalid memory addresses.

Only what happens when the addresses are both invalid and unpredictable? In the past, this killed game performance. Really emulating the MMU takes thousands of CPU cycles, and the pace of improvement in CPU clock speed has all only stopped. The GameCube CPU might accept only run at 485MHz, but our modern chips are just 10x faster in terms of raw clock speed — and there are functions that simply can't be emulated effectively when doing so costs thousands of CPU cycles.

BAT-Function

Custom-defined BATs are much harder to emulate.

From the Dolphin squad's blog post:

Handling memory checks (memchecks) is slower because information technology harms the performance optimization "fastmem". Fastmem maps the GameCube/Wii address infinite to host retentiveness and then marks all of the emulated invalid memory as allocated for the host PC. This allows Dolphin to employ the host CPU's exception handler to do the dirty work when communicable exceptions. When it does catch an exception, Dolphin has to fallback from fastmem to slowmem in society to handle the address, which tin be a huge performance dilemma.

Memchecks are the cadre of what Enable MMU does, and it's the key reason why MMU Enabled titles accept been and then slow in Dolphin. There are cases that require falling back to the interpreter, it doesn't work with fastmem, and they're even slower than normal memory accesses on console!

Recent code contributions by Fiora boosted operation in one MMU title (Star Wars: Rogue Squadron) by 10x and in most others by an average of 100%, but that wasn't enough to solve the problem of Star Wars: The Clone Wars. This particular title really divers its ain BAT — the only game known to exist that did so. Because Dolphin fundamentally relied on the thought of a hardcoded BAT, there was no way to address this border instance without rewriting the entire memory emulator subsystem, and mayhap non without ruining performance in a great many other games in the process.

One of the Dolphin contributors, magumagu, obviously came upward with a way to rewrite Dolphin to support The Clone Wars' custom BAT mapping without compromising operation in whatsoever other title. According to the Dolphin team, previous attempts to support the game had the side effect of reducing performance in other games past upwards to thirty%. While the team has taken an 8-xv% hit in other MMU titles, information technology believes it can recover this loss through further tweaks and improvements. Other games should really see improved performance and fewer bugs equally a result of the rewrite, then the gains should be well worth it in the longer term.

Panel emulation has actually moved a scrap more mainstream these days, thanks to high profile efforts from Microsoft to emulate the Xbox 360 on the Xbox One. Even Sony has dipped its toe in the waters with PS2 emulation on the PlayStation 4. Nintendo's upcoming console, the NX, reportedly won't be backwards-compatible — which could spur interest in emulating that platform every bit well.