|
| Home | Downloads | Screenshots | Forums | Source code | RSS | Donate |
| Register | Log in |
| < Windows OpenGL issues fixed, finally!Let's Golf: the horseman of apocalypse that wasn't one > |
|
More camera trouble... Jul 6th 2025, by Arisotura |
|
So I had made a nice post about Let's Golf and how it was fixed... But, obviously, as far as DSi camera support is concerned, it wasn't all. I looked at another game that was running into issues with the camera: Assassin's Creed II. The Wanted feature in the menu uses the camera, if you're playing the game on a DSi, but on melonDS, it just showed nothing at all. Quick investigation showed why. Normally, when using the camera, games will set up the DMA with a block length of N scanlines, and a total length matching the length of the full camera picture. The DMA channel will also be set to trigger an IRQ when it's done. However, this game does things differently. The DMA channel has no total length setting, and is just set to repeat infinitely. It transfers picture data to a small temporary buffer, from which the game reads when needed. No idea why they did it this way, but regardless, shows why it's good to emulate things accurately. Anyway, a NDMA channel that is set to "repeat infinitely" will trigger an IRQ after each block, but due to an oversight, melonDS never triggered any IRQ. After fixing this, I did have the camera feed showing up in the game's UI thing, but it was rolling. Heh. Couldn't have been so simple. This turned out to be because of the timings for the camera transfer. The timings melonDS used were a big fat guess, and were way too fast for that game. I dug up my old camera test homebrew and modified it to track camera timings from the DSi. Took some time to figure out the logic behind the numbers I was getting -- there was more time between camera DMA transfers when running in 256x192 mode, than in 640x480 mode. In fact, it makes sense: internally, the camera always runs at 640x480, and the HSync/VSync are the same, but when told to output a 256x192 picture, the camera simply skips some of the scanlines. Once I understood that fact, I was able to put together a timing model that more closely resembled the real deal. And this fixed Assassin's Creed II -- the camera preview thing was working flawlessly. I then checked Let's Golf, and... it was rolling, again. Welcome to emulation whack-a-mole. But, that's the thing. I have researched this bug long and hard, and I can't figure it out. The basic issue is as follows: the game uses NDMA1 to transfer camera picture data to main RAM, but it also periodically (every 2 frames) transfers video data from main RAM to VRAM, to be displayed on the top screen, and does so using DMA3 (the old DMA, not NDMA). Camera output isn't synchronized to the LCD framerate. This means that the DMA3 transfer may occur while a camera transfer is in progress. In melonDS, it meant that the NDMA1 transfer couldn't run because DMA3 was already running. This highlighed a bug with how melonDS handled camera DMA: it assumed that the "try to fire a DMA transfer" operation would result in a DMA transfer effectively starting, but when that wasn't the case, things went south. I remodeled the camera FIFO to fix this problem (and raise a data overrun error instead of skipping a chunk). Let's Golf was no longer rolling, but it was just getting stuck on the same camera frame. So clearly there was more to it... But I can't figure it out. I ran hardware tests, thinking that maybe NDMA1 should have priority over DMA3. But nope. NDMA can't preempt old DMA, no matter the settings. I modified my camera homebrew to reproduce what Let's Golf does, and it gets stuck after a couple camera frames or less, with a camera data overrun error. So I can't understand why the game works fine. I even modified the game itself, to track things like when the camera IRQ occurs, or whether data overrun errors happen, and it revealed nothing. So, yeah. I'm absolutely stumped. Who would have thought that a camera thing in a golf game would become a new horseman of apocalypse... It feels weird after the last post, but I might ship melonDS 1.0 with this broken. But hey, the fixes do fix a bunch of other DSi games. |
| 4 comments have been posted. |
| < Windows OpenGL issues fixed, finally!Let's Golf: the horseman of apocalypse that wasn't one > |
|
lucaspltn says: Jul 7th 2025 |
| This sounds like suffering π Very fair to wait till a 1.1 release or smthn to fix it. I'm looking forward to what 1.0 is gonna have in store π |
|
Klauserus says: Jul 7th 2025 |
| Does this mean that Relase 1.0 is coming or only when you have solved the problem? |
|
Arisotura says: Jul 7th 2025 |
|
actually I started figuring it out shortly after writing this post (heh) I'll keep you guys updated |
|
jiink says: Aug 7th 2025 |
| Arisotura λΉμ μ μμν©λλ€ |