Becoming Almost Usable
Well, the past week I was away and didn’t have a lot of time to work on NooDS, but even still, a lot of important things have been done since the last progress update. As the title suggests, we almost have a usable DS emulator on our hands! Emphasis on the “almost”, though.
First up, we have the usual collection of fixes. Compatability was improved, thanks to even more pipelining fixes, and a few ARM9-exclusive CPU instructions being implemented. There were also various graphical fixes and improvements. Cases where the wrong palette was being used were taken care of, fixing things like missing graphics in the intros of the generation 4 Pokémon games. Object priority was properly implemented, meaning the firmware’s date selector now properly displays behind the selected calendar number. Object coordinate wrapping was also added, allowing objects that are partially off-screen to the left or top of the screen to be displayed. Object rendering also got support for 2D tile mapping, allowing, for example, the menu of New Super Mario Bros. to be displayed. And finally, some mistakes in the text background implementation were corrected, getting rid of some weird issues with scrolling backgrounds, such as improperly rendered edge tiles. The 2D engine is still missing things like rotated/scaled sprites and blending effects, but it’s coming along nicely, and at this point some 2D games like Digimon World Dusk and Yoshi’s Island DS are able to be displayed mostly correctly.
Now, you might not be able to tell just by looking, but New Super Mario Bros. and Yoshi’s Island DS are of particular interest in these screenshots. This is because to get either of them as far as they are in the screenshots, they need save support. So yeah, NooDS now has save support! DS saves are a little tricky though. You see, there are a few different types of save memory that might be in a DS cartridge. The most common types are EEPROM and FLASH, and both of these types come in different sizes as well. If you try to emulate one type of save for a game that uses a different type, saving won’t work properly. Unfortunately, the save type isn’t stored anywhere in a ROM dump, so it needs to be determined by other means. The two possibilities I’m considering are either some sort of detection code, which would probably end up being a hacky mess, or the use of a premade save database. The problem is, neither of these methods will be 100% accurate. Either way, I’ll probably add a manual override as well. For now though, NooDS relies on a save file already being present in order to determine the correct save type. If there’s no save file present, saving won’t work.
Another must-have feature for any DS emulator is touchscreen support. So of course, I’ve implemented that as well! This was a bit trickier than button input, since touchscreen values are read through the ARM7’s SPI. Providing the values through the SPI wasn’t too difficult, since the SPI was already set up to send values from the firmware, though the formatting of the bits tripped me up a bit. After I had the SPI set up, I had to get touch coordinates from the UI and convert them to the raw values that the DS expects. This involved some math using calibration values from the firmware, but it wasn’t too hard to get working either. For the most part, the touchscreen works great! However, there are a few games where it doesn’t work at all… There’s probably either an SPI bug or a FIFO bug causing this, and I plan on looking into it soon.
Finally, we have direct boot support for commercial games. As cool as booting games from the firmware is, I feel like I’ve seen the health and safety screen thousands of times from testing games! So now NooDS can boot commercial games directly, like it could do with homebrew before. This was actually surprisingly easy to achieve, and I feel silly for not doing it earlier. I just had to copy a few more things into memory and set a few more values, and games were willing to boot.
Oh, and one last thing! If you didn’t notice in the screenshots, I added an FPS counter. And the emulator is running at a beautiful 60 FPS, at least on my system. Don’t let that fool you though; NooDS is still slower than the competition. I still need to optimize and clean up my code a lot more, but looking back on my last progress post, I pretty much did everything else that I had planned for the immediate future. So what’s next? Well, finally tackling rotated/scaled sprites will probably be the next thing on my list, and then I might have to finally start looking into 3D and audio support. And after all that, a formal release of some sort might be in order? Well, as always, thanks a ton for your support and interest in my project, and I look forward to continuing this journey with you! Until next time~