Conversation
the code worked before because some sdk5 games have a routine that checks if scfg7 is unlocked, and in case automatically populated these values themselves, by disabling it according to the header in the previous commit, this was no longer the case
9898a30 to
877a635
Compare
|
After the initial commit, I noticed that retail games failed to boot, this came down to the fact that before they were being booted with unlocked scfg, and sdk5 games have a routine that checks for that, and, if it's unlocked, automatically populate the ram values used by the sdk to determine the environment it's being run on, which should instead be taken care of by the launcher. Specifically the games seems to only need the values of SCFG_ROM to be placed in ram so that they can detect if they're run on a ds or on a dsi |
|
Also, this branch fixes a hang that I get in the examples of BlocksDS that initialize NAND, like. https://codeberg.org/blocksds/sdk/src/branch/master/examples/filesystem/all_filesystems |
The current location of this code isn't the right one. The idea of this code is to enable access to the SD/NAND in loaders that don't set the right SCFG bits, which confuses libnds. However, the ARM7 version of irqInit() calls TMIO_init() much earlier than SDMMC_init() is called, which means TMIO has already decided that it can't access SD/NAND and it hangs when nandInit() is called. This has been discovered thanks to Edoardo Lolletti <edoardo762@gmail.com> and his work on a potential fix for melonDS [1]. The fix hasn't been merged yet and, even if it gets merged, there will be many users of melonDS with buggy versions of the emulator, so it's important to add a workaround to libnds. [1] melonDS-emu/melonDS#2701
|
I've ended up adding a workaround to libnds because, even if this PR gets merged, there will be lots of people with old versions of melonDS and I'd rather have a workaround for them: https://codeberg.org/blocksds/libnds/commit/8d80f2a7aeed7ff0440bc9bc8b46f92756a48fcb |
The current location of this code isn't the right one. The idea of this code is to enable access to the SD/NAND in loaders that don't set the right SCFG bits, which confuses libnds. However, the ARM7 version of irqInit() calls TMIO_init() much earlier than SDMMC_init() is called, which means TMIO has already decided that it can't access SD/NAND and it hangs when nandInit() is called. This has been discovered thanks to @edo9300 and his work on a potential fix for melonDS [1]. The fix hasn't been merged yet and, even if it gets merged, there will be many users of melonDS with buggy versions of the emulator, so it's important to add a workaround to libnds. [1] melonDS-emu/melonDS#2701
With the scfg permissions update, melonds changed the default scfg flags when direct booting, but as default it disabled access to the scmc registers, breaking direct booting homebrews and software that required nand access.
Properly handle this case by using the appropriate dsi header field in the rom containing the arm7 scfg settings (as stated on gbatek, only bit 0,1,2,10,18 and 31 are to be considered).