Porting Virtual Paradise to the 3DS (part 2)

In part 1 I was able to build most of VP’s code for the Nintendo 3DS target using the homebrew SDK, but only a small part of it was running: just enough to make it log in.

At the end of the previous article I mentioned that other parts of the code need a functioning renderer. Actually, it just needs to have a renderer that pretends to be functioning. For situations like this VP has a fake renderer. It doesn’t render anything, it just tell the rest of the code that it did and that everything is fine. Let’s use that and see what happens when running it in a 3DS emulator.

It enters the world! You can tell from the screenshot above that the user count for testworld went from 2 to 3. And on the PC the avatar can be seen as well:

Unfortunately, when I tried this on the real 3DS it just crashed. After some online searching I found out that it is possible to enable a remote debugger on the (softmodded) 3DS through the Rosalina menu, which can be accessed by pressing L + Down + Select. I enabled the debugger attached to it using GDB:

(gdb) target remote
Remote debugging using
0x00100000 in _start ()
(gdb) c
[New Thread 216]
[New Thread 219]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x00320328 in strlen ()
(gdb) bt
#0  0x00320328 in strlen ()
#1  0x001bd75c in ObjectPath::getCachePath[abi:cxx11]() ()
... more stack frames

Something appears to be going wrong when trying to find where to put cache files. It’s running the code path that is also used on Linux systems. This code path uses getenv("HOME") to find the home directory and because the 3DS most likely doesn’t have this it returns a null pointer. Adding some 3DS-specific code to determine the cache location fixed this.

There were also some easier to fix issues before it would work. Here it is running on a real 3DS:

After this I started working on a renderer implementation for the 3DS. I managed to make it clear the screen with a color, but it’s not rendering anything yet.