Dolphin Progress Report: March 2016

It's April Fool's day which means that the internet is full of fake articles, products, videos, and images meant to fool users into thinking they're real. We decided to do things a little differently here at the Dolphin Blog, instead of making the users our fool, we decided it would be JMC47. See, JMC47 has been going through the trouble of getting as many games possible to gain a stranglehold on the issue tracker/wiki help with testing and issue verification. In the past, he's made videos of the games he's come across upon his own will, which led to videos like the one on Speed Racer. delroth ended up finding a game so spectacularly weird that JMC47 not only had to play it, he had to record his experience. Welcome to Gummy Bears MiniGolf presented in glorious 1080p HD!

Gummy Bears Minigolf

If you're wondering what happened with a bigger April Fools day merge or idea, unfortunately we're still in a feature freeze. The team is getting down to the final dozen or so issues, but, as with any programming challenge, fixing one issue seems to bring up another. It's only a matter of time before things are sorted out and we can enter the final stages of release.

Notable Changes

4.0-9059 - Fix Savestates with Different Input Devices by Fog_TAS

Users may have noticed that savestates have been a bit volatile recently. Sometimes a savestate will work, then you go and play some other game, come back to the game you were playing and all the sudden that savestate crashes the emulator. What gives?

Turns out that some of cleanups that have been done on GameCube input made it so that savestates began glitching out. If you didn't have the same devices set before and after the savestate, that savestate would cease to function! Thankfully, this fix ends that silly bug and scratches off another Dolphin 5.0 blocker.

4.0-9113 - Fix many OS X Graphical Issues by endrift and 4.0-9158 - Workaround OS X video driver bug #2498307 by Sonicadvance1

Once again, we borrowed mGBA author endrift, mainly because they use OS X! So, since 4.0-1192 and Dolphin's switch to integer math within TEV emulation, EFB Copies haven't really worked well on OS X, especially on Intel integrated graphics cards. The developers have forever blamed this on OS X's sometimes tempermental drivers; every other driver works fine after all. This is definitely a driver issue, and could be a Dolphin bug on top of that; but regardless no one wants to see OS X left useless in Dolphin except Helios747.

The Legend of Zelda: Twilight Princess

GanonCorp has spilled oil into the Faron Springs!

The Legend of Zelda: Twilight Princess

Thanks to endrift, the Faron Springs are clean once again. And the settlement made Ordon the richest village in Hyrule!

Because endrift has graphics debugging knowledge AND OS X, they were able to solve the bug relatively easily once they were aware of it. Considering that Dolphin has work-arounds for almost every graphics driver, this isn't a particularly nasty hack. Some of the stuff that Dolphin Mobile has done to get around Adreno bugs in the past has been much, much crazier.

To balance out that, here is a definitive bug in the Apple OS X Graphics Drivers! Fixed in 4.0-9158, Sonicadvance1 addresses the fact the OS X shader compiler is bugged and don't properly inherit the layout qualifier from the interface block. He fixed this by explicitly stating the layout qualifier on both the interface block and every single member inside of that block. This allows users to use MSAA and SSAA in OS X again without issues. This broke AMD's graphics drivers in Dolphin, which required another fix from stenzek, 4.0-9179. Yay driver bugs!

4.0-9442 - Implement Partial Texture Updates into Store EFB Copies to Texture by mimimi

One of the problems with getting more accurate over time is that sometimes things accidentally work. In the case of Donkey Kong Country Returns, the main characters are rendered through an EFB Copy before being rendered onto the screen. This has worked with EFB Copies to Texture for a very long time. Then, when cleaning up EFB Copies, suddenly Donkey Kong stopped rendering.

Donkey Kong Country Returns

After learning the power of invinsibility, Donkey Kong takes on the latest of foes!

Donkey Kong Country Returns

Except, platforming while invisibile is a bit hard. So he changed his mind after one too many falls.

What happened? Donkey Kong Country Returns slightly modifies the size of the EFB Copy during Donkey Kong's rendering. Because the EFB Copy is so big and most of it is simply invisible, nothing! Both EFB Copies to RAM/Texture rendered it the same because only invisible edges of the EFB Copy were being effected at all. When phire added a bunch of safeguards to prevent EFB Copies to Texture breaking invisibly, well, for lack of a better explanation, Donkey Kong became invisible.

While EFB Copies to RAM still worked, the performance hit and the not being able to render Donkey Kong at high resolutions put many users into a fervor. For the past few months, mimimi has known how to fix this, but the problem was doing it cleanly, correctly, and making the fix work properly in D3D. Even with this build merged, the D3D backends have a bug causing Donkey Kong to flicker in and out of existence even though the actual EFB Copy code was working correctly. So why merge it now?

Stenzek found the bug in D3D meaning that this was good to go.

4.0-9154 - Instruction Slice Timing Issue Fixes by phire

Due to preexisting agreements, any change that fixes a Pokémon game is to be written in the style of a Pokémon episode. We apologize for the inconvenience.

Way back in May of 2015, our heroes faced off with one of the most nefarious issues they had ever encountered: Professor Oak had become so blind in his old age that he couldn't fairly judge photographs they had been taking of Pokémon. After working feverishly on depth bugs buying him a new pair of glasses, the world was safe from this threat for the time being. Dolphin Tester JMC47 was not satisfied with this result: so what if Pokémon Snap works, he mused. He set out to find an even more nefarious bug to baffle our brave heroes. He would find a bug that would break the very fabric of time itself! All he needed was his next victim: Time Trials and Tribulation.

JMC47's favorite puzzle game is Tetris Attack, also known as Panel De Pon and Puzzle League depending on which era and region you grew up in. So, it would only be fitting that Pokémon Puzzle League would be one of the games he'd unironically run in Dolphin and seriously play, even though he went through all the trouble of importing the Japanese GameCube version which is way better and not an Emulated N64 game. Unfortunately, the game has had serious issues with Dolphin since its inception. While the work of developers throughout many regions of the emulator, video, audio, and CPU, have helped ease the issues, one glaring problem remained. The game suffered from a time rift.

The timer decreases so fast that it never actually hits zero!

The timer moves as fast as it possibly can; which, in the Time Trial modes, causes the timer to freeze when it goes below zero. In other modes, the timer goes up incredibly fast before maxing out at 24 hours within 24 seconds!

The masses wow'd at JMC47's amazing Time Trial scores in Pokémon Puzzle League. Even tool assisted players could not top the scores he was able to create while time was frozen. Surely a developer would come and fix this, he thought to himself, they could not allow such tomfooler. Yet, with Pokémon Puzzle League being a N64 Virtual Console game that almost no one would use Dolphin to play, little interest was garnered. He pounded the table as none of the developers wanted to take their time from "more important" projects like ending shader cache stuttering, fixing up Virtual XFB, releasing Dolphin 5.0, and other insignificant tasks. What good is a Wii emulator that cannot run Pokemon Puzzle League correctly fumed the frustrated tester! To show them just how serious this problem truly was...

This timer bug in Pokémon Puzzle League isn't exactly uncommon among Virtual Console N64 games. The Legend of Zelda: Majora's Mask (PAL), Super Smash Bros. (PAL) and others run into similar problems where the game will simply run strangely. Majora's Mask, for instance, would run with a constant frameskip and at super speed. Super Smash Bros. would run uncapped and various timings would just be wrong, especially the timer.

Metroid Prime 2's menus lagged so much, the video didn't even get to finish

JMC47 connected these bugs early on, but for years there were no real leads on what could cause them. A normal person would report the bugs and leave, but JMC47's most notable quality, his stubbornness, came through. Despite no leads and little interest in fixing Virtual Console bugs, he found out that if you used VERY specific SyncGPU settings, the bugs would seemingly disappear. The default setting for SyncGPU's Max/Min Distance is 10000000 and -10000000 respectively. JMC47 managed to hit the exact values that worked around this bug: Max Distance = 100 and Min Distance = -100. Any other number in that range all the way up into the thousands crash the emulator; there was no reason for him to try a value this low other than the fact he had no idea what he was actually doing. (Writer's note: This is 100% true. Anyone who understood what these distances did would never try this and expect it to do anything but explode.)

This was an obvious hack, but it provided a slight clue into what was going on and allowed JMC47 to observe that other games were affected by this too; including The Legend of Zelda: Ocarina of Time (VC) randomly crashing. This bug piqued the curiosity of phire, who wondered what an N64 game could be doing to crash like this, and how JMC47's insane find could possibly placate it. So he shelved his project to end shader stuttering in Dolphin to fix a Virtual Console game. Thanks to JMC47.

Reluctantly roped into another of JMC47's quests, phire began to dig into the Virtual Console game to see what could possibly be going on. Despite previous attempts from both Fiora and delroth, nothing much had been learned about the bug. But they had been examining Pokémon Puzzle League with no clues; JMC47's finding with SyncGPU allowed phire something to work from. The first thing he did was try to find out what JMC47 actually did with these settings.

* *

Who's that Pokemon? Mouse over to find out! Template by amitlu89

Phire realized that by setting SyncGPU to 100/-100, in essence JMC47 made it so that CPU emulation was being interrupted every 100 cycles with a callback thanks to the extreme settings. From there, phire actually decided to do this manually without SyncGPU and it still fixed the bug, meaning that JMC47 had merely stumbled upon a completely random solution that pointed toward the real bug. More investigation led to the final, startling realization:

When an event was scheduled during a JIT block (or interpreter instruction), it could be triggered up to 20,000 cycles late! Dolphin never rechecked where the end of the slice was and kept powering on through. On top of that, a second bug was found in that the "time" register was returning times that were up to 20000 cycles old. These two bugs combined caused many of the N64 Virtual Console games to behave strangely because Dolphin was telling them the wrong information! A third bug was found as well later on where certain games were placing events far into the future (think 10+ seconds) and because it overflowed to negative, Dolphin was then firing them immediately.

These three bugs combined to affect a lot of games. The Legend of Zelda: Ocarina of Time (VC), Pokémon Puzzle League (VC), The Legend of Zelda: Majora's Mask (VC), Super Smash Bros. (VC), Ed, Edd n Eddy: The Mis-Edventures (GC), and Overlord Dark Legend (Wii) all were verified to have game breaking bugs fixed within them. Hundreds of other games responded to debug code saying that random crashes could be caused by this issue. Because the bugs are so random and rare, more testing is needed to verify that Yu-Gi-Oh! The Falsebound Kingdom, Mega Man Network Transmission and Mega Man X: Command Mission's random hangs and crashes are fixed.

Metroid fans in particular should be absolutely thrilled, as not only does it fix various FMV timings in Metroid Prime 1, 2, and Trilogy, but it also breaks Metroid: Other M due to a bug that was uncovered by the change. For now, using LLE audio or modifying the emulated CPU Clock Rate for Metroid: Other M will allow it to boot. Once in-game, the clock rate can be returned to normal. Other games with minor timing issues should be more accurate as well; especially ones that simply weren't explainable before.

And so, JMC47's insidious plan to get Pokemon Puzzle League fixed succeeded. Poor phire, drained by the efforts, vowed never to fix the shader generation stuttering. All was well in the world of Dolphin... at least until next time.

Last Month's Contributors...

Special thanks to all of the contributors that incremented Dolphin from 4.0-9052 through to 4.0-9177!

You can continue the discussion in the forum thread of this article.

Next entry

Previous entry

Similar entries