gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Exit to Menu / Return to Firmware

#172916 - Stephanie - Thu Mar 11, 2010 4:25 pm

I'm trying to make my homebrew programs return to the firmware menu in a simple and elegant way.

I've read with great interest through the information about HBMenu, and that works very well, in that I can test to see if the exit to menu function exists (if bootcode->bootsig != 0) then I can call exit(0) and that works perfectly.

When there is no exit to menu though, I want to be able to load & execute the appropriate firmware file... for example I use an acekard so I want my program to be able to load/execute fat0:/akmenu4.nds

I've been able to use the directory example to learn how to scan the card's root directory, so I can look for the appropriate firmware files, but I don't know how to actually load or execute them. I know it can be done as I've seen other homebrews do this - like gbexploader, run it then hit B to cancel and it loads the firmware menu.

So I can figure out what is the correct file to return to the firmware, I just can't figure out what I need to do, to load/execute the desired file.

Is there a tutorial, or an example, on how to load&run an NDS from within another NDS?

Thanks!

-Stephanie

#172917 - wintermute - Thu Mar 11, 2010 4:47 pm

Don't test, just exit. We need to force the issue with card manufacturers rather than continue to implement workarounds. The signature stuff is intended only for use of launchers, not user code. I'm looking into a reset to DS firmware when the boot signature isn't present, not quite sure if that's possible yet.

AKAIO should support the exit to menu feature soon, Normmatt is also looking at pulling out the GUI for use with hbmenu.

The Homebrew Menu already does what you want.

PS: I'm off out to buy an LED to replace the bulb and switch in my fridge :p
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#172918 - Stephanie - Thu Mar 11, 2010 5:30 pm

Hi wintermute, thanks for the super-quick response!

I've tried just using exit(0) but when the appropriate code isn't there, it just hangs. If nothing else I'd rather power off the DS than have it hang...

Thanks again!

-Stephanie

#172945 - sverx - Fri Mar 12, 2010 10:26 am

I also think that turning off the DS would be a good idea if it's not possible to go back to the launcher... stating clearly in the homebrew webpage that the homebrew exits to the launcher if it's a good one and turns off the consolle if the launcher isn't a good one. With links to the good ones.

#172984 - wintermute - Sun Mar 14, 2010 12:05 pm

libnds 1.4.2 now powers off with no bootstub present. enjoy :)
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#172985 - headspin - Sun Mar 14, 2010 12:12 pm

wintermute wrote:
AKAIO should support the exit to menu feature soon, Normmatt is also looking at pulling out the GUI for use with hbmenu.


If they add exit support to AKAIO and you put the GUI from AKAIO into hbmenu what will be the difference between the two?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#172986 - vuurrobin - Sun Mar 14, 2010 12:31 pm

AFAIK, AKAIO can play commersial games, and it only works on a few acecard flashcards. there are probably some more things different.
_________________
my blog:
http://vuurrobin.100webcustomers.com/

#172987 - headspin - Sun Mar 14, 2010 12:33 pm

vuurrobin wrote:
AFAIK, AKAIO can play commersial games, and it only works on a few acecard flashcards. there are probably some more things different.


Do you think many people will use hbmenu if it doesn't support commercial games?
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game

#172989 - Stephanie - Sun Mar 14, 2010 4:04 pm

wintermute wrote:
libnds 1.4.2 now powers off with no bootstub present. enjoy :)


Sweet! Thanks very much!

-Stephanie

#172990 - fincs - Sun Mar 14, 2010 4:58 pm

I have found the following problems with the restart key combo (L+R+Sel+Start):
If I'm using VRAM_C (consoleDemoInit) the background is cleared and it hangs.
If no loader is present nothing happens. The latest version was supposed to power down the DS :\
If none of the previous conditions are met it does return to the loader, but it takes around 10 seconds (the program meanwhile freezes).

All of this doesn't happen if I use exit() on the ARM9. Maybe there's a problem in the hook9from7 code?

#172992 - wintermute - Sun Mar 14, 2010 8:48 pm

headspin wrote:
vuurrobin wrote:
AFAIK, AKAIO can play commersial games, and it only works on a few acecard flashcards. there are probably some more things different.


Do you think many people will use hbmenu if it doesn't support commercial games?


The basic point here is to encourage other card launchers to use the bootcode from hbmenu, extend hbmenu for their purposes, or add support for argv & bootstub. Our launcher has no memory limits, provides a standard way to find the nds path and allows return to menu.

fincs wrote:
I have found the following problems with the restart key combo (L+R+Sel+Start):
If I'm using VRAM_C (consoleDemoInit) the background is cleared and it hangs.
If no loader is present nothing happens. The latest version was supposed to power down the DS :\
If none of the previous conditions are met it does return to the loader, but it takes around 10 seconds (the program meanwhile freezes).

All of this doesn't happen if I use exit() on the ARM9. Maybe there's a problem in the hook9from7 code?


Yeah sorry, I messed up the shutdown on the arm7 side, the delay is something peculiar I haven't figured out yet. Basically the arm9 needs to give VRAM & slot1/slot2 access to the 7 which means that the 7 has to tell the 9 which then has to tell the 7, if that makes sense.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#172993 - wintermute - Sun Mar 14, 2010 8:52 pm

Stephanie wrote:
wintermute wrote:
libnds 1.4.2 now powers off with no bootstub present. enjoy :)


Sweet! Thanks very much!

-Stephanie


And thank you, much appreciated.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#172994 - fincs - Sun Mar 14, 2010 8:57 pm

wintermute wrote:
Yeah sorry, I messed up the shutdown on the arm7 side, the delay is something peculiar I haven't figured out yet. Basically the arm9 needs to give VRAM & slot1/slot2 access to the 7 which means that the 7 has to tell the 9 which then has to tell the 7, if that makes sense.

Ok, I'll keep an eye on SVN.

#172999 - elhobbs - Mon Mar 15, 2010 8:24 am

wintermute wrote:
libnds 1.4.2 now powers off with no bootstub present. enjoy :)
I think power off with a normal exit code is a good idea. however, under abnormal exit I think a hang is better solution. typically under an abnormal exit there is some sort of error code displayed. when the system shuts down it makes it hard to figure out what is going on. I could add a key press before calling exit... not sure how I feel about that though. any thoughts?

#173053 - wintermute - Thu Mar 18, 2010 12:53 am

You'll like this, libnds 1.4.3 has a weak systemErrorExit function you can override in user code like this :-

Code:

#include <nds.h>
#include <stdio.h>

void systemErrorExit(int rc) {
   printf("exit with code %d\n",rc);

   while(1) {
      swiWaitForVBlank();
      scanKeys();
      if (keysDown() & KEY_A) break;
   }
   
}

//---------------------------------------------------------------------------------
int main(int argc, char **argv) {
//---------------------------------------------------------------------------------
   int i;

   consoleDemoInit();
   
   if ( argc == 0 ) {
      printf("No arguments!\n");
   } else {
      for ( i = 0; i < argc; i++) {
         printf("arg %d, %s\n",i,argv[i]);
      }
   }
   while(1) {
      swiWaitForVBlank();
      scanKeys();
      if (keysDown() & KEY_X) break;
   }
   return 42;
}


exit(0) won't call the function & it's a no op if you don't override it. This allows for setting up a console if you didn't do it in the main code or any other customisation you like.
_________________
devkitPro - professional toolchains at amateur prices
devkitPro IRC support
Personal Blog

#173055 - elhobbs - Thu Mar 18, 2010 2:28 am

that works for me - thank you!