Skip to content

main.cpp

Iason Papadopoulos edited this page Mar 25, 2018 · 5 revisions

I wrote main to be as lite as possible, however, we can start explaining the #includes from here.

#include <nds.h> Is going to be included in almost all files because, well, we are writing nds homebrew.

#include "device.h" This comes from flashcart_core and is needed to make a *cart object for the Flashcart class found over at device.h. We define this pointer here, and we will pass it along from function to function until the very end where it's needed (InjectFIRM() and DumpFlash(), I'll get to those in another part of the wiki)

The next two header files are custom made for the program.

#include "ui.h" is needed for calling ui.cpp functions. ui.cpp was written with a primary focus on graphics and drawing, and just in general, things that are (nearly) completely independent from anything ntrboot related. What this file includes is things like DrawString(), DrawHeader() (for drawing those blue rectangles at the top of the screen), and DrawInfo() (for drawing the grey rectangle at the bottom which shows the flashcart_core version and the ntrboot_flasher_nds version).

#include "menu.h" is where the two main loops are. As you know, the program is split up into two main parts; those are the main menu from where you select your flashcart, and the deeper menu from where you select what to do with your flashcart. I named these menu_lvl1() and menu_lvl2() appropriately, and menu_lvl1() will later call menu_lvl2() appropriately.

One last thing: You may have noticed the isDevMode variable. Basically, if you hold START, SELECT and X on bootup, dev mode will be enabled, and then if you wanted to do a dev FIRM flash to your flashcart, the program would detect this and insert the appropriate blowfish key for boot9. I bring no mention to this at all, and keep it as hidden away as possible, because almost no one cares about this and I don't want to introduce more mistakes that noobs could make. If you really want it, it's there, but other than that, we really don't care.

So with that out of the way, let's move on to the next file, which is going to be menu.cpp.

menu.cpp

Clone this wiki locally