JesseTG / melonds-ds

A remake of the libretro melonDS core that prioritizes standalone parity, reliability, and usability.
GNU General Public License v3.0
166 stars 19 forks source link

Add ability to direct-boot DSiWare #148

Open JesseTG opened 10 months ago

JesseTG commented 10 months ago

What would you like to see?

It turns out that direct-booting DSiWare is much easier than anyone expected. Hats off to CasualPokePlayer for discovering it. His implementation in the BizHawk core looks like this; I expect mine will be similar.

Terms

JesseTG commented 10 months ago

I will need to submit a PR upstream, as I'll need to access DSi_BPTWL::Registers, which is private.

JesseTG commented 9 months ago

From a conversation on Discord...

JesseTG: @CasualPokePlayer suggested an implementation for direct-booting DSi games, as he does in BizHawk. But is there a way to tell when DSiWare is exiting to the main menu? I'd like to implement this, but I'd also like to close the emulator if direct-booting DSiWare.

CasualPokePlayer: unless you're constantly monitoring memory, no

JesseTG: Well, is there a single section of RAM that unambigously tells me if I'm in the DSi menu? If so, then checking an integer at a certain offset every frame would be okay

CasualPokePlayer: there would be some memory location that says the current id of the loaded software iirc

JesseTG: That might be exactly what I need

...

JesseTG:https://mgba-emu.github.io/gbatek/#2000300h---nintendo-auto-load-feature-via-numeric-title-id Looks like I just need to know the Title ID of the DSi menu.

2000310h 8 AutoLoad New Title ID (new title to be started,0=none/launcher)

Oh, so the DSi menu's title ID is just 0?

CasualPokePlayer: no it's just the autoload feature has 0 to mean go back to launcher FFDFC0-FFE014 (and maybe some after that? idk) of main ram seems to have the currently loaded software image

CasualPokePlayer : image also at FFFE00-FFFE14 image image

CasualPokePlayer: actually, i guess too this is less "go back to launcher" and more "stay in the launcher" since at this point in the process you're at the launcher

JesseTG: Are those addresses listed in GBATek? I can't find them when searching

CasualPokePlayer: they arent, they're just something i found observing loading games

JesseTG: Ooh, neat.

CasualPokePlayer: (well, more i just ctrl+f'd for the title id and oop found them)

JesseTG: And what's the title ID for the DSi menu?

CasualPokePlayer: the exact title id depends on the region HNA? for the lower title id, 00030017 for the upper title id although the upper title id isnt listed unless you cound its string form in the .app path LAUNCHER is probably a better indicator anyways

CasualPokePlayer commented 9 months ago

Note that if the NAND user settings are invalid in any way (e.g. set to an unsupported language), the direct booting would just fail and it'd kick you to the initial NAND setup screen.