Skip to content

Commit 0129039

Browse files
Add reboot normally option, hide reboot to rcm on mariko
On mariko, rebooting normally will bypass fuses
1 parent 7862a15 commit 0129039

5 files changed

Lines changed: 35 additions & 23 deletions

File tree

source/gfx/menu.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,34 +41,22 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted, u32 bg){
4141
gfx_putc('\n');
4242
}
4343

44-
void FunctionMenuHandler(MenuEntry_t *entries, int entryCount, menuPaths *paths, u8 options){
45-
Vector_t ent = vecFromArray(entries, entryCount, sizeof(MenuEntry_t));
46-
gfx_clearscreen();
47-
gfx_putc('\n');
48-
int res = newMenu(&ent, 0, 79, 30, options, entryCount);
49-
if (paths[res] != NULL)
50-
paths[res]();
51-
}
52-
5344
int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 options, int entryCount) {
5445
vecPDefArray(MenuEntry_t*, entries, vec);
5546
u32 selected = startIndex;
5647

57-
while (entries[selected].skip || entries[selected].hide)
48+
while (entries[selected].skip || entries[selected].hide){
5849
selected++;
50+
if (selected >= vec->count)
51+
selected = 0;
52+
}
5953

6054
u32 lastIndex = selected;
6155
u32 startX = 0, startY = 0;
6256
gfx_con_getpos(&startX, &startY);
6357

6458
u32 bgColor = (options & USELIGHTGREY) ? COLOR_DARKGREY : COLOR_DEFAULT;
6559

66-
/*
67-
if (options & ENABLEPAGECOUNT){
68-
screenLenY -= 2;
69-
startY += 32;
70-
}
71-
*/
7260

7361
bool redrawScreen = true;
7462
Input_t *input = hidRead();

source/gfx/menu.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ typedef struct _menuEntry {
4444

4545
#define ARR_LEN(x) (sizeof(x) / sizeof(*x))
4646

47-
int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 options, int entryCount);
48-
void FunctionMenuHandler(MenuEntry_t *entries, int entryCount, menuPaths *paths, u8 options);
47+
int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 options, int entryCount);

source/tegraexplorer/mainmenu.c

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "../fs/fsutils.h"
1717
#include <soc/fuse.h>
1818
#include "../utils/utils.h"
19+
#include "../config.h"
20+
21+
extern hekate_config h_cfg;
1922

2023
enum {
2124
MainExplore = 0,
@@ -31,6 +34,7 @@ enum {
3134
MainExit,
3235
MainPowerOff,
3336
MainRebootRCM,
37+
MainRebootNormal,
3438
MainRebootHekate,
3539
MainRebootAMS
3640
};
@@ -49,6 +53,7 @@ MenuEntry_t mainMenuEntries[] = {
4953
[MainExit] = {.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "\n-- Exit --"},
5054
[MainPowerOff] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Power off"},
5155
[MainRebootRCM] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot to RCM"},
56+
[MainRebootNormal] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot normally"},
5257
[MainRebootHekate] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot to bootloader/update.bin"},
5358
[MainRebootAMS] = {.optionUnion = COLORTORGB(COLOR_VIOLET), .name = "Reboot to atmosphere/reboot_payload.bin"}
5459
};
@@ -99,7 +104,10 @@ void ViewKeys(){
99104

100105
void ViewCredits(){
101106
gfx_clearscreen();
102-
gfx_printf("\nTegraexplorer v%d.%d.%d\nBy SuchMemeManySkill\n\nBased on Lockpick_RCM & Hekate, from shchmue & CTCaer", LP_VER_MJ, LP_VER_MN, LP_VER_BF);
107+
gfx_printf("\nTegraexplorer v%d.%d.%d\nBy SuchMemeManySkill\n\nBased on Lockpick_RCM & Hekate, from shchmue & CTCaer\n\n\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF);
108+
109+
if (hidRead()->r)
110+
gfx_printf("%k\"I'm not even sure if it works\" - meme", COLOR_ORANGE);
103111
hidWait();
104112
}
105113

@@ -132,9 +140,11 @@ menuPaths mainMenuPaths[] = {
132140
[MainRebootRCM] = reboot_rcm,
133141
[MainPowerOff] = power_off,
134142
[MainViewCredits] = ViewCredits,
143+
[MainRebootNormal] = reboot_normal,
135144
};
136145

137146
void EnterMainMenu(){
147+
int res = 0;
138148
while (1){
139149
if (sd_get_card_removed())
140150
sd_unmount();
@@ -152,8 +162,15 @@ void EnterMainMenu(){
152162
// -- Exit --
153163
mainMenuEntries[MainRebootAMS].hide = (!sd_mounted || !FileExists("sd:/atmosphere/reboot_payload.bin"));
154164
mainMenuEntries[MainRebootHekate].hide = (!sd_mounted || !FileExists("sd:/bootloader/update.bin"));
155-
156-
FunctionMenuHandler(mainMenuEntries, ARR_LEN(mainMenuEntries), mainMenuPaths, ALWAYSREDRAW);
165+
mainMenuEntries[MainRebootRCM].hide = h_cfg.t210b01;
166+
167+
gfx_clearscreen();
168+
gfx_putc('\n');
169+
170+
Vector_t ent = vecFromArray(mainMenuEntries, ARR_LEN(mainMenuEntries), sizeof(MenuEntry_t));
171+
res = newMenu(&ent, res, 79, 30, ALWAYSREDRAW, 0);
172+
if (mainMenuPaths[res] != NULL)
173+
mainMenuPaths[res]();
157174
}
158175
}
159176

source/utils/utils.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,24 @@
99
#include "../gfx/menu.h"
1010
#include "../hid/hid.h"
1111
#include "../fs/fsutils.h"
12+
#include "../config.h"
13+
14+
extern hekate_config h_cfg;
1215

1316
extern int launch_payload(char *path);
1417

1518
void ALWAYS_INLINE power_off(){
16-
power_set_state(POWER_OFF);
19+
power_set_state(POWER_OFF_RESET);
1720
}
1821

1922
void ALWAYS_INLINE reboot_rcm(){
2023
power_set_state(REBOOT_RCM);
2124
}
2225

26+
void ALWAYS_INLINE reboot_normal(){
27+
power_set_state((h_cfg.t210b01) ? REBOOT_BYPASS_FUSES : POWER_OFF_REBOOT);
28+
}
29+
2330
void RebootToPayloadOrRcm(){
2431
if (FileExists("sd:/atmosphere/reboot_payload.bin"))
2532
launch_payload("sd:/atmosphere/reboot_payload.bin");

source/utils/utils.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ void RebootToPayloadOrRcm();
1111
char *ShowKeyboard(const char *toEdit, u8 alwaysRet);
1212

1313
void power_off();
14-
void reboot_rcm();
14+
void reboot_rcm();
15+
void reboot_normal();

0 commit comments

Comments
 (0)