Tuesday, August 11, 2009

Porting DeSmuME to Wii - Part 4 -

Now when we last left off, we needed to port over OGLRender.cpp to continue porting the core. And we're going to leave it off for a little while longer, so bare with me as I explain compiling the rest of the emulator under libogc. If you're following the compilation along with these blog posts, just move OGLRender.cpp and OGLRender.h out of the way for now.

Now, everything will compile fine up until commandline.cpp and it's friend commendline.h The commandline set of code is used to define paths used to load files and implements a very simple debugger which helps users and developers diagnose problems with the emulator. Commandline is powered by something called "GLib" (I couldn't find this library anywhere on the internet, so if you have any information on the library, please share it in comments). Since we don't have access to GLib, I used my commenting skills to basically render commandline useless. In code comments, the original authors strongly recommend NOT doing this, however, I plan to re-implement a debugger of my own in the form of printfs and if statements and the loading paths will initially be completely predefined (and then eventually there will be a GUI which is used to define them). Yes, I'm not entirely happy about killing the commandline, I'd really like to keep it implemented if possible. But for now, let's just keep moving, shall we?

Now everything else will compile fine until we get to ctrlssdl.cpp and ctrlssdl.h These two files use SDL to handle input into the emulator. If you install the SDL port of the SDL library, these files will compile just fine... But they will not work at runtime. Why? Look at the Joypad configuration. Most of those numbers don't have a corresponding Wii Button. Since the classic controller looks exactly like the DSs input nterface (minus the touch screen of course) I rewrote the JoyPad configuration to work with the classic controller. Now, moving on...

More perfect compilations up until fs-windows.cpp This file is simple to fix, just get rid of it. I'm pretty sure the Wii doesn't have use for the Windows file system (fs) ;-) (It probably doesn't have use for the linux file system either, but since it compiles, we'll leave it alone)

Now we got some errors in movie.h and movie.cpp I thought I had taken care of these before, but apparaently not. It's wstring acting up again. Just change std::wstring to std::string everywhere it appears to take care of these issues. It's not the most elegent solution, but since libogc lacks wstring support, it's the only option we have. I don't think we'll be needing the features of movie.cpp and movie.h anyways unless anyone here wants extremely laggy gameplay of course ;-)

The emulator uses SDL to output sound, so if you have the Wii port of SDL installed, the sound output portion of DeSMuME will compile just fine.

And now if we continue our compilation, the rest of the emulator's core will compile just fine up to a problem with the emulators addons. Since we're initially disabling addons in the emulator anyway, I just commented out 4 lines of code to get the addons compiled.

And now... Hey, look! The rest of the emulator's core compiled perfectly!!! But wait... We still need to compensate for OGLRender (I excluded it from compilation in beginning of the post, remember?) Perhaps it's best for me to explain things if I explain them this way:

The current state of the emulator: Except for OGLRender, the entire core of the emulator has compiled perfectly under libogc. To get the emulator launching NDS ROMs on the Wii, we need to first finish porting/rewriting OGLRender and then rewrite the GUI of the emulator (the GUI should be pretty simple to do). While it doesn't seem like much (and in reality, it's really not) we still have a bit of a way left to go before we get ROMs emulating with our DeSmuME port.

Profetylen and I would love a hand with OGLRender, so please contact either of us some way if you think you can help. Available below for download is the latest source revision for our port of DeSmuME (excluding our current state of OGLRender -- The included in the download below is the original OGLRender).

Click here to read the previous part of the port.


  1. Hi. I know a library called glib that handles a lot of data types and general stuff. It belongs to the GTK packet:
    Windows: http://www.gtk.org/download-windows.html
    Linux: http://www.gtk.org/download-linux.html

    You can find source code there.
    Good luck!

  2. Thank you! We'll check that out soon!

  3. Wow! You are so good with all of this!
    I'm a noob who just got Homebrew on my Wii and I don't know anything about any of this. I'm sorry!
    This is probably a really stupid question. I'm sorry... but is the download link at the end a download for a DS Emulator that would work with Homebrew? What does it mean that it doesnt have "OGLRender"?

    I'm sorry that this is a stupid question!

  4. No...

    We're porting a DS emulator called DeSmuME so it will eventually work on the Nintendo Wii.

    The link at the bottom was the source code to where we were at the port. If you compile it, it will not work.

    Anyways, the revision at the bottom of the page and the latest revision of our work can now be found here now http://code.google.com/p/desmumewii

    Still currently does not work but my goal is to have it working by the end of August. Stay tuned ...

  5. http://library.gnome.org/devel/glib/
    Sorry if this link is SHIT I don't understand spanish