Files
niklascfw 1dabe126ac Let Erista reboot to hekate
The entry was hidden on Erista whenever the SD card was not mounted while
the menu was built. When shown, it tried atmosphere/reboot_payload.bin
first; on OmniNX that is fusee, which is rejected as not hekate, and the
rejection unmounted the card, so bootloader/update.bin was never found.
Always offer the entry, try the hekate files first, mount the card before
each attempt and point to RCM if hekate cannot be loaded.
2026-11-30 22:41:02 +01:00

163 lines
5.8 KiB
C

#include "mainmenu.h"
#include "../gfx/gfx.h"
#include "../gfx/gfxutils.h"
#include "../gfx/menu.h"
#include "tools.h"
#include "../hid/hid.h"
#include "../fs/menus/explorer.h"
#include <utils/btn.h>
#include <storage/sd.h>
#include "tconf.h"
#include "../keys/keys.h"
#include "../storage/mountmanager.h"
#include "../storage/gptmenu.h"
#include "../storage/emummc.h"
#include <utils/util.h>
#include "../fs/fsutils.h"
#include <soc/fuse.h>
#include "../utils/utils.h"
#include "../config.h"
#include "../fs/readers/folderReader.h"
#include "../fs/fstypes.h"
#include "../fs/fscopy.h"
#include <utils/sprintf.h>
#include <stdlib.h>
#include <string.h>
#include "../apl/apl.h"
extern hekate_config h_cfg;
enum {
MainExplore = 0,
DeleteBootFlags,
FixArchiveBitA,
FixArchiveBitN,
// FixAll,
MainAMS,
DeleteThemes,
SysmoduleSelector,
MainConvenience,
FixMarikoWarmbootSleep,
FixMacSpecialFolders,
MainOther,
MainViewStillNoBootInfo,
MainViewCredits,
MainExit,
MainPowerOff,
MainRebootRCM,
// MainRebootNormal,
MainRebootHekate,
};
MenuEntry_t mainMenuEntries[] = {
[MainExplore] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "-- Behebe Start Probleme --"},
[DeleteBootFlags] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Automatisches starten der sysmodule deaktivieren"},
[FixArchiveBitA] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Behebe Archive Bit (alle Ordner ausser Nintendo)"},
[FixArchiveBitN] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Behebe Archive Bit (Nintendo Ordner)"},
// [FixAll] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Try everything"},
[MainAMS] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Atmosphere Fehlercodes --"},
[DeleteThemes] = {.optionUnion = COLORTORGB(COLOR_CYAN), .name = "Fix 0100000000001000 (Installiertes Theme)"},
[SysmoduleSelector] = {.optionUnion = COLORTORGB(COLOR_CYAN), .name = "Sysmodul deinstallieren (Fehlercode = Title ID)"},
[MainConvenience] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Bequemlichkeit --"},
[FixMarikoWarmbootSleep] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Mariko Sleep Fix (Warmboot)"},
[FixMacSpecialFolders] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Entferne spezielle MacOS Dateien"},
[MainOther] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Sonstiges --"},
[MainViewStillNoBootInfo] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Meine Switch startet nicht mehr"},
[MainViewCredits] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "Ueber"},
[MainExit] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Beenden --"},
[MainPowerOff] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Ausschalten"},
[MainRebootRCM] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Neustart in RCM-Modus"},
// [MainRebootNormal] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Normaler Neustart"},
[MainRebootHekate] = {.optionUnion = COLORTORGB(COLOR_PURPLE), .name = "Neustart in hekate"}
// [MainBrowseSd] = {.optionUnion = COLORTORGB(COLOR_GREEN), .name = "Browse SD"},
// [MainMountSd] = {.optionUnion = COLORTORGB(COLOR_YELLOW)}, // To mount/unmount the SD
// [MainBrowseEmmc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMMC"},
// [MainBrowseEmummc] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Browse EMUMMC"},
// [MainTools] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Tools --"},
// [MainPartitionSd] = {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Partition the sd"},
// [MainDumpFw] = {.optionUnion = COLORTORGB(COLOR_BLUE), .name = "Dump Firmware"},
// [MainViewKeys] = {.optionUnion = COLORTORGB(COLOR_YELLOW), .name = "View dumped keys"},
};
void HandleSD(){
gfx_clearscreen();
TConf.curExplorerLoc = LOC_SD;
if (!sd_mount() || sd_get_card_removed()){
gfx_printf("Sd is not mounted!");
hidWait();
}
else
FileExplorer("sd:/");
}
extern bool is_sd_inited;
void RebootToHekate(){
reboot_to_hekate_menu();
}
void MountOrUnmountSD(){
gfx_clearscreen();
if (sd_get_card_mounted())
sd_unmount();
else if (!sd_mount())
hidWait();
}
void archBitHelperA(){
m_entry_fixArchiveBit(0);
}
void archBitHelperN(){
m_entry_fixArchiveBit(1);
}
menuPaths mainMenuPaths[] = {
[DeleteBootFlags] = m_entry_deleteBootFlags,
[DeleteThemes] = m_entry_deleteInstalledThemes,
[FixArchiveBitA] = archBitHelperA,
[FixArchiveBitN] = archBitHelperN,
[SysmoduleSelector] = m_entry_sysmoduleSelector,
[FixMacSpecialFolders] = m_entry_fixMacSpecialFolders,
[FixMarikoWarmbootSleep] = m_entry_fixMarikoWarmbootSleep,
// [FixAll] = m_entry_fixAll,
[MainViewStillNoBootInfo] = m_entry_stillNoBootInfo,
[MainRebootHekate] = RebootToHekate,
[MainRebootRCM] = reboot_rcm,
[MainPowerOff] = power_off,
[MainViewCredits] = m_entry_ViewCredits,
};
void EnterMainMenu(){
int res = 0;
while (1){
if (sd_get_card_removed())
sd_unmount();
// // -- Exit --
// Always offered: on Erista, reboot_to_hekate_menu() mounts the SD card
// itself and says so if hekate is missing.
mainMenuEntries[MainRebootHekate].hide = false;
mainMenuEntries[MainRebootRCM].hide = h_cfg.t210b01;
mainMenuEntries[FixMarikoWarmbootSleep].hide = !h_cfg.t210b01;
gfx_clearscreen();
gfx_putc('\n');
Vector_t ent = vecFromArray(mainMenuEntries, ARR_LEN(mainMenuEntries), sizeof(MenuEntry_t));
res = newMenu(&ent, res, 79, 30, ALWAYSREDRAW, 0);
if (mainMenuPaths[res] != NULL)
mainMenuPaths[res]();
}
}