mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2025-01-27 03:33:15 -03:00
Start gfx rewrite & reorganize TE
This commit is contained in:
parent
761ceb7dbe
commit
6aed4ad7b3
16 changed files with 570 additions and 62 deletions
58
source/tegraexplorer/common/common.h
Normal file
58
source/tegraexplorer/common/common.h
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#pragma once
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
extern const char *gfx_file_size_names[];
|
||||||
|
extern const char *menu_sd_states[];
|
||||||
|
extern const char *emmc_fs_entries[];
|
||||||
|
|
||||||
|
enum mainmenu_main_return {
|
||||||
|
MAIN_SDCARD = 0,
|
||||||
|
MAIN_EMMC_SAF,
|
||||||
|
MAIN_EMMC_SYS,
|
||||||
|
MAIN_EMMC_USR,
|
||||||
|
MAIN_EMUMMC_SAF,
|
||||||
|
MAIN_EMUMMC_SYS,
|
||||||
|
MAIN_EMUMMC_USR,
|
||||||
|
MAIN_MOUNT_SD,
|
||||||
|
MAIN_TOOLS,
|
||||||
|
MAIN_SD_FORMAT,
|
||||||
|
MAIN_CREDITS,
|
||||||
|
MAIN_EXIT
|
||||||
|
};
|
||||||
|
|
||||||
|
extern menu_entry mainmenu_main[];
|
||||||
|
|
||||||
|
enum mainmenu_shutdown_return {
|
||||||
|
SHUTDOWN_REBOOT_RCM = 1,
|
||||||
|
SHUTDOWN_REBOOT_NORMAL,
|
||||||
|
SHUTDOWN_POWER_OFF,
|
||||||
|
SHUTDOWN_HEKATE,
|
||||||
|
SHUTDOWN_AMS
|
||||||
|
};
|
||||||
|
|
||||||
|
extern menu_entry mainmenu_shutdown[];
|
||||||
|
|
||||||
|
enum mainmenu_tools_return {
|
||||||
|
TOOLS_DISPLAY_INFO = 1,
|
||||||
|
TOOLS_DISPLAY_GPIO,
|
||||||
|
TOOLS_DUMPFIRMWARE,
|
||||||
|
TOOLS_DUMPUSERSAVE,
|
||||||
|
TOOLS_DUMP_BOOT,
|
||||||
|
TOOLS_RESTORE_BOOT
|
||||||
|
};
|
||||||
|
|
||||||
|
extern menu_entry mainmenu_tools[];
|
||||||
|
|
||||||
|
enum mainmenu_format_return {
|
||||||
|
FORMAT_EMUMMC = 1,
|
||||||
|
FORMAT_ALL_FAT32
|
||||||
|
};
|
||||||
|
|
||||||
|
extern menu_entry mainmenu_format[];
|
||||||
|
|
||||||
|
enum mmc_types {
|
||||||
|
SYSMMC = 1,
|
||||||
|
EMUMMC
|
||||||
|
};
|
||||||
|
|
||||||
|
extern menu_entry utils_mmcChoice[];
|
19
source/tegraexplorer/common/strings.c
Normal file
19
source/tegraexplorer/common/strings.c
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include "common.h"
|
||||||
|
|
||||||
|
const char *gfx_file_size_names[] = {
|
||||||
|
"B ",
|
||||||
|
"KB",
|
||||||
|
"MB",
|
||||||
|
"GB"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *menu_sd_states[] = {
|
||||||
|
"\nUnmount SD",
|
||||||
|
"\nMount SD"
|
||||||
|
};
|
||||||
|
|
||||||
|
const char *emmc_fs_entries[] = {
|
||||||
|
"SYSTEM",
|
||||||
|
"USER",
|
||||||
|
"SAFE"
|
||||||
|
};
|
48
source/tegraexplorer/common/structs.c
Normal file
48
source/tegraexplorer/common/structs.c
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#include "common.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
menu_entry mainmenu_main[] = {
|
||||||
|
{"[SD:/] SD CARD\n", COLOR_GREEN, ISMENU},
|
||||||
|
{"[SYSTEM:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||||
|
{"[USER:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||||
|
{"[SAFE:/] EMMC", COLOR_ORANGE, ISMENU},
|
||||||
|
{"\n[SYSTEM:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||||
|
{"[USER:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||||
|
{"[SAFE:/] EMUMMC", COLOR_BLUE, ISMENU},
|
||||||
|
{"\nMount/Unmount SD", COLOR_WHITE, ISMENU},
|
||||||
|
{"Tools", COLOR_VIOLET, ISMENU},
|
||||||
|
{"SD format", COLOR_VIOLET, ISMENU},
|
||||||
|
{"\nCredits", COLOR_WHITE, ISMENU},
|
||||||
|
{"Exit", COLOR_WHITE, ISMENU}
|
||||||
|
};
|
||||||
|
|
||||||
|
menu_entry mainmenu_shutdown[] = {
|
||||||
|
{"Back", COLOR_WHITE, ISMENU},
|
||||||
|
{"\nReboot to RCM", COLOR_VIOLET, ISMENU},
|
||||||
|
{"Reboot normally", COLOR_ORANGE, ISMENU},
|
||||||
|
{"Power off\n", COLOR_BLUE, ISMENU},
|
||||||
|
{"Reboot to Hekate", COLOR_GREEN, ISMENU},
|
||||||
|
{"Reboot to Atmosphere", COLOR_GREEN, ISMENU}
|
||||||
|
};
|
||||||
|
|
||||||
|
menu_entry mainmenu_tools[] = {
|
||||||
|
{"Back", COLOR_WHITE, ISMENU},
|
||||||
|
{"\nDisplay Console Info", COLOR_GREEN, ISMENU},
|
||||||
|
{"Display GPIO pins", COLOR_VIOLET, ISMENU},
|
||||||
|
{"Dump Firmware", COLOR_BLUE, ISMENU},
|
||||||
|
{"Dump User Saves", COLOR_YELLOW, ISMENU},
|
||||||
|
{"[DEBUG] Dump bis", COLOR_RED, ISMENU},
|
||||||
|
{"[DEBUG] Restore bis", COLOR_RED, ISMENU}
|
||||||
|
};
|
||||||
|
|
||||||
|
menu_entry mainmenu_format[] = {
|
||||||
|
{"Back\n", COLOR_WHITE, ISMENU},
|
||||||
|
{"Format entire SD to FAT32", COLOR_RED, ISMENU},
|
||||||
|
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, ISMENU}
|
||||||
|
};
|
||||||
|
|
||||||
|
menu_entry utils_mmcChoice[] = {
|
||||||
|
{"Back\n", COLOR_WHITE, ISMENU},
|
||||||
|
{"SysMMC", COLOR_ORANGE, ISMENU},
|
||||||
|
{"EmuMMC", COLOR_BLUE, ISMENU}
|
||||||
|
};
|
31
source/tegraexplorer/common/types.h
Normal file
31
source/tegraexplorer/common/types.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../../utils/types.h"
|
||||||
|
|
||||||
|
#define ISDIR (1 << 0)
|
||||||
|
#define ISARC (1 << 1)
|
||||||
|
|
||||||
|
#define ISHIDE (1 << 8)
|
||||||
|
#define ISMENU (1 << 9)
|
||||||
|
#define ISSKIP (1 << 10)
|
||||||
|
|
||||||
|
#define ISGB (1 << 7)
|
||||||
|
#define ISMB (1 << 6)
|
||||||
|
#define ISKB (1 << 5)
|
||||||
|
#define ISB (1 << 4)
|
||||||
|
|
||||||
|
#define SETBIT(object, shift, value) ((value) ? (object |= shift) : (object &= ~shift))
|
||||||
|
|
||||||
|
/* Bit table for property as a file:
|
||||||
|
0000 0001: Directory bit
|
||||||
|
0000 0010: Archive bit (or hideme)
|
||||||
|
0001 0000: Size component is a Byte
|
||||||
|
0010 0000: Size component is a KiloByte
|
||||||
|
0100 0000: Size component is a MegaByte
|
||||||
|
1000 0000: Size component is a GigaByte : note that this won't surpass gigabytes, but i don't expect people to have a single file that's a terrabyte big
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
u32 storage;
|
||||||
|
u16 property;
|
||||||
|
} menu_entry;
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../mem/sdram.h"
|
#include "../mem/sdram.h"
|
||||||
#include "../storage/emummc.h"
|
#include "../storage/emummc.h"
|
||||||
#include "../config/config.h"
|
#include "../config/config.h"
|
||||||
|
#include "common/common.h"
|
||||||
|
|
||||||
sdmmc_storage_t storage;
|
sdmmc_storage_t storage;
|
||||||
emmc_part_t *system_part;
|
emmc_part_t *system_part;
|
||||||
|
|
|
@ -50,7 +50,9 @@ static const u8 bis_key_source[3][0x20] = {
|
||||||
0x4D, 0x12, 0xE1, 0x4B, 0x2A, 0x47, 0x4C, 0x1C, 0x09, 0xCB, 0x03, 0x59, 0xF0, 0x15, 0xF4, 0xE4}
|
0x4D, 0x12, 0xE1, 0x4B, 0x2A, 0x47, 0x4C, 0x1C, 0x09, 0xCB, 0x03, 0x59, 0xF0, 0x15, 0xF4, 0xE4}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
enum mmc_types {
|
enum mmc_types {
|
||||||
SYSMMC = 0,
|
SYSMMC = 0,
|
||||||
EMUMMC
|
EMUMMC
|
||||||
};
|
};
|
||||||
|
*/
|
|
@ -58,6 +58,24 @@ int message(u32 color, const char* message, ...){
|
||||||
return btn_wait();
|
return btn_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
int gfx_errprint(u32 color, int func, int err, int add){
|
||||||
|
clearscreen();
|
||||||
|
SWAPCOLOR(COLOR_ORANGE);
|
||||||
|
gfx_printf("\nAn error occured:\n\n");
|
||||||
|
gfx_printf("Function: %s\nErrcode: %d\nDesc: %s\n");
|
||||||
|
|
||||||
|
if (add)
|
||||||
|
gfx_printf("Additional info: %d");
|
||||||
|
|
||||||
|
gfx_printf("\nPress any button to return");
|
||||||
|
|
||||||
|
|
||||||
|
RESETCOLOR;
|
||||||
|
return btn_wait();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// Change makemenu to combine makefilemenu to save space + make nagivation more consistant
|
||||||
int makemenu(menu_item menu[], int menuamount){
|
int makemenu(menu_item menu[], int menuamount){
|
||||||
int currentpos = 1, i, res;
|
int currentpos = 1, i, res;
|
||||||
clearscreen();
|
clearscreen();
|
||||||
|
@ -216,7 +234,7 @@ void printfsentry(fs_entry file, bool highlight, bool refresh){
|
||||||
|
|
||||||
int makefilemenu(fs_entry *files, int amount, char *path){
|
int makefilemenu(fs_entry *files, int amount, char *path){
|
||||||
int currentpos = -2, i, res = 0, offset = 0, quickoffset = 300;
|
int currentpos = -2, i, res = 0, offset = 0, quickoffset = 300;
|
||||||
u32 timer;
|
u32 timer, scrolltimer;
|
||||||
bool refresh = false;
|
bool refresh = false;
|
||||||
clearscreen();
|
clearscreen();
|
||||||
gfx_con_setpos(544, 0);
|
gfx_con_setpos(544, 0);
|
||||||
|
@ -237,17 +255,28 @@ int makefilemenu(fs_entry *files, int amount, char *path){
|
||||||
refresh = false;
|
refresh = false;
|
||||||
gfx_printf("\n%k%K %s %s\n\nTime taken for screen draw: %dms ", COLOR_BLUE, COLOR_DEFAULT, (offset + 60 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
gfx_printf("\n%k%K %s %s\n\nTime taken for screen draw: %dms ", COLOR_BLUE, COLOR_DEFAULT, (offset + 60 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
||||||
|
|
||||||
if (quickoffset == 300)
|
while (btn_read() & BTN_POWER);
|
||||||
res = btn_wait();
|
|
||||||
else {
|
res = 0;
|
||||||
msleep(quickoffset);
|
while (!res){
|
||||||
|
res = btn_read();
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
quickoffset = 300;
|
||||||
|
|
||||||
|
if (quickoffset < 300){
|
||||||
|
scrolltimer = get_tmr_ms();
|
||||||
|
while (res){
|
||||||
|
if (scrolltimer + quickoffset <= get_tmr_ms())
|
||||||
|
break;
|
||||||
|
|
||||||
res = btn_read();
|
res = btn_read();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (res == 0)
|
if (quickoffset > 46 && res)
|
||||||
quickoffset = 300;
|
|
||||||
else if (quickoffset > 46)
|
|
||||||
quickoffset -= 45;
|
quickoffset -= 45;
|
||||||
|
}
|
||||||
|
|
||||||
if ((res & BTN_VOL_UP) && currentpos > -2){
|
if ((res & BTN_VOL_UP) && currentpos > -2){
|
||||||
currentpos--;
|
currentpos--;
|
||||||
|
|
112
source/tegraexplorer/gfx/gfxutils.c
Normal file
112
source/tegraexplorer/gfx/gfxutils.c
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
#include "gfxutils.h"
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include "menu.h"
|
||||||
|
#include "../../gfx/gfx.h"
|
||||||
|
#include "../../power/max17050.h"
|
||||||
|
#include "../../utils/btn.h"
|
||||||
|
#include "../../utils/util.h"
|
||||||
|
#include "../../mem/heap.h"
|
||||||
|
|
||||||
|
|
||||||
|
void gfx_clearscreen(){
|
||||||
|
int battery = 0;
|
||||||
|
max17050_get_property(MAX17050_RepSOC, &battery);
|
||||||
|
|
||||||
|
gfx_clear_grey(0x1B);
|
||||||
|
SWAPCOLOR(COLOR_DEFAULT);
|
||||||
|
SWAPBGCOLOR(COLOR_WHITE);
|
||||||
|
|
||||||
|
gfx_box(0, 1263, 719, 1279, COLOR_WHITE);
|
||||||
|
gfx_con_setpos(0, 1263);
|
||||||
|
gfx_printf("Move: Vol+/- | Select: Pow | Battery: %3d%%", battery >> 8);
|
||||||
|
|
||||||
|
gfx_box(0, 0, 719, 15, COLOR_WHITE);
|
||||||
|
gfx_con_setpos(0, 0);
|
||||||
|
gfx_printf("Tegraexplorer v1.3.3\n");
|
||||||
|
|
||||||
|
RESETCOLOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
int gfx_message(u32 color, const char* message, ...){
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, message);
|
||||||
|
|
||||||
|
gfx_clearscreen();
|
||||||
|
SWAPCOLOR(color);
|
||||||
|
|
||||||
|
gfx_vprintf(message, ap);
|
||||||
|
|
||||||
|
va_end(ap);
|
||||||
|
return btn_wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
int gfx_errprint(u32 color, int func, int err, int add){
|
||||||
|
gfx_clearscreen();
|
||||||
|
SWAPCOLOR(COLOR_ORANGE);
|
||||||
|
gfx_printf("\nAn error occured:\n\n");
|
||||||
|
gfx_printf("Function: %s\nErrcode: %d\nDesc: %s\n");
|
||||||
|
|
||||||
|
if (add)
|
||||||
|
gfx_printf("Additional info: %d");
|
||||||
|
|
||||||
|
gfx_printf("\nPress any button to return");
|
||||||
|
|
||||||
|
|
||||||
|
RESETCOLOR;
|
||||||
|
return btn_wait();
|
||||||
|
}
|
||||||
|
|
||||||
|
int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
||||||
|
int res;
|
||||||
|
u32 start = get_tmr_s();
|
||||||
|
|
||||||
|
while (btn_read() != 0);
|
||||||
|
|
||||||
|
while(1){
|
||||||
|
res = btn_read();
|
||||||
|
|
||||||
|
if (res & BTN_VOL_DOWN || res & BTN_VOL_UP)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (start + timer > get_tmr_s())
|
||||||
|
gfx_printf("\r<Wait %d seconds> ", timer + start - get_tmr_s());
|
||||||
|
|
||||||
|
else if (res & BTN_POWER)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
else
|
||||||
|
gfx_printf("\r%s", hiddenmessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_printlength(int size, char *toprint){
|
||||||
|
char *temp;
|
||||||
|
temp = (char*) malloc (size + 1);
|
||||||
|
|
||||||
|
if (strlen(toprint) > size){
|
||||||
|
strlcpy(temp, toprint, size);
|
||||||
|
memset(temp + size - 3, '.', 3);
|
||||||
|
memset(temp + size, '\0', 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
strcpy(temp, toprint);
|
||||||
|
|
||||||
|
gfx_printf("%s", temp);
|
||||||
|
free(temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_printandclear(char *in, int length){
|
||||||
|
u32 x, y;
|
||||||
|
|
||||||
|
gfx_printlength(length, in);
|
||||||
|
gfx_con_getpos(&x, &y);
|
||||||
|
|
||||||
|
gfx_box(x, y, 719, y + 16, COLOR_DEFAULT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfx_printfilesize(int size, char *type){
|
||||||
|
SWAPCOLOR(COLOR_VIOLET);
|
||||||
|
gfx_printf("\a%4d\e%s", size, type);
|
||||||
|
RESETCOLOR;
|
||||||
|
}
|
15
source/tegraexplorer/gfx/gfxutils.h
Normal file
15
source/tegraexplorer/gfx/gfxutils.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../../gfx/gfx.h"
|
||||||
|
#include "../../utils/types.h"
|
||||||
|
|
||||||
|
#define SWAPCOLOR(color) gfx_printf("%k", color)
|
||||||
|
#define SWAPBGCOLOR(color) gfx_printf("%K", color)
|
||||||
|
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
|
||||||
|
|
||||||
|
void gfx_clearscreen();
|
||||||
|
int gfx_message(u32 color, const char* message, ...);
|
||||||
|
int gfx_errprint(u32 color, int func, int err, int add);
|
||||||
|
int gfx_makewaitmenu(char *hiddenmessage, int timer);
|
||||||
|
void gfx_printlength(int size, char *toprint);
|
||||||
|
void gfx_printandclear(char *in, int length);
|
||||||
|
void gfx_printfilesize(int size, char *type);
|
123
source/tegraexplorer/gfx/menu.c
Normal file
123
source/tegraexplorer/gfx/menu.c
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
#include "menu.h"
|
||||||
|
#include "gfxutils.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include "../../utils/btn.h"
|
||||||
|
#include "../common/common.h"
|
||||||
|
#include "../../utils/util.h"
|
||||||
|
#include "../../mem/minerva.h"
|
||||||
|
|
||||||
|
void _printentry(menu_entry entry, bool highlighted, bool refresh){
|
||||||
|
int size;
|
||||||
|
|
||||||
|
if (entry.property & ISMENU)
|
||||||
|
SWAPCOLOR(entry.storage);
|
||||||
|
else if (entry.property & ISDIR)
|
||||||
|
SWAPCOLOR(COLOR_WHITE);
|
||||||
|
else {
|
||||||
|
SWAPCOLOR(COLOR_VIOLET);
|
||||||
|
|
||||||
|
for (size = 4; size < 8; size++)
|
||||||
|
if ((entry.property & (1 << size)))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (highlighted){
|
||||||
|
SWAPBGCOLOR(COLOR_WHITE);
|
||||||
|
if ((entry.property & ISMENU) ? entry.storage == COLOR_WHITE : entry.property & ISDIR)
|
||||||
|
SWAPCOLOR(COLOR_DEFAULT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SWAPBGCOLOR(COLOR_DEFAULT);
|
||||||
|
|
||||||
|
|
||||||
|
if (refresh)
|
||||||
|
gfx_printandclear(entry.name, 37);
|
||||||
|
else
|
||||||
|
gfx_printlength(37, entry.name);
|
||||||
|
|
||||||
|
if (entry.property & ISDIR || entry.property & ISMENU)
|
||||||
|
gfx_printf("\n");
|
||||||
|
else {
|
||||||
|
SWAPCOLOR(COLOR_BLUE);
|
||||||
|
gfx_printf("\a%d\e%s", entry.storage, gfx_file_size_names[size - 4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||||
|
int currentpos = 0, i, res = 0, offset = 0, delay = 300;
|
||||||
|
u32 scrolltimer, timer;
|
||||||
|
bool refresh = false;
|
||||||
|
|
||||||
|
gfx_clearscreen();
|
||||||
|
|
||||||
|
gfx_con_setpos(512, 0);
|
||||||
|
SWAPCOLOR(COLOR_DEFAULT);
|
||||||
|
SWAPBGCOLOR(COLOR_WHITE);
|
||||||
|
gfx_printf("%3d entries\n", amount);
|
||||||
|
RESETCOLOR;
|
||||||
|
|
||||||
|
SWAPCOLOR(COLOR_GREEN);
|
||||||
|
gfx_printlength(42, toptext);
|
||||||
|
RESETCOLOR;
|
||||||
|
|
||||||
|
while (!(res & BTN_POWER)){
|
||||||
|
gfx_con_setpos(0, 47);
|
||||||
|
timer = get_tmr_ms();
|
||||||
|
|
||||||
|
if (!currentpos){
|
||||||
|
while (currentpos < amount && entries[currentpos].property & (ISSKIP | ISHIDE))
|
||||||
|
currentpos++;
|
||||||
|
}
|
||||||
|
if (currentpos == amount - 1){
|
||||||
|
while (currentpos >= 1 && entries[currentpos].property & (ISSKIP | ISHIDE))
|
||||||
|
currentpos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0 + offset; i < amount && i < 60 + offset; i++)
|
||||||
|
if (!(entries[i].property & ISHIDE))
|
||||||
|
_printentry(entries[i], (i == currentpos), refresh);
|
||||||
|
|
||||||
|
gfx_printf("\n%k%K %s %s\n\nTime taken for screen draw: %dms ", COLOR_BLUE, COLOR_DEFAULT, (offset + 60 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
|
||||||
|
|
||||||
|
while (btn_read() & BTN_POWER);
|
||||||
|
|
||||||
|
res = 0;
|
||||||
|
while (!res){
|
||||||
|
res = btn_read();
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
delay = 300;
|
||||||
|
|
||||||
|
if (delay < 300){
|
||||||
|
scrolltimer = get_tmr_ms();
|
||||||
|
while (res){
|
||||||
|
if (scrolltimer + delay <= get_tmr_ms())
|
||||||
|
break;
|
||||||
|
|
||||||
|
res = btn_read();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delay > 46 && res)
|
||||||
|
delay -= 45;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res & BTN_VOL_UP && currentpos >= 1){
|
||||||
|
currentpos--;
|
||||||
|
while(entries[currentpos].property & (ISSKIP | ISHIDE) && currentpos >= 1)
|
||||||
|
currentpos--;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (res & BTN_VOL_DOWN && currentpos < amount - 1){
|
||||||
|
currentpos++;
|
||||||
|
while(entries[currentpos].property & (ISSKIP | ISHIDE) && currentpos < amount - 1)
|
||||||
|
currentpos++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
minerva_periodic_training();
|
||||||
|
//return (mode) ? currentpos : entries[currentpos].property;
|
||||||
|
return currentpos;
|
||||||
|
}
|
4
source/tegraexplorer/gfx/menu.h
Normal file
4
source/tegraexplorer/gfx/menu.h
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../common/types.h"
|
||||||
|
|
||||||
|
int menu_make(menu_entry *entries, int amount, char *toptext);
|
|
@ -11,11 +11,17 @@
|
||||||
#include "../storage/emummc.h"
|
#include "../storage/emummc.h"
|
||||||
#include "script.h"
|
#include "script.h"
|
||||||
|
|
||||||
|
#include "common/common.h"
|
||||||
|
#include "gfx/menu.h"
|
||||||
|
|
||||||
|
#include "utils/utils.h"
|
||||||
|
|
||||||
extern bool sd_mount();
|
extern bool sd_mount();
|
||||||
extern void sd_unmount();
|
extern void sd_unmount();
|
||||||
extern bool return_sd_mounted(int value);
|
extern bool return_sd_mounted(int value);
|
||||||
extern int launch_payload(char *path);
|
extern int launch_payload(char *path);
|
||||||
|
|
||||||
|
/*
|
||||||
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
||||||
{"[SD:/] SD CARD\n", COLOR_GREEN, SD_CARD, 1},
|
{"[SD:/] SD CARD\n", COLOR_GREEN, SD_CARD, 1},
|
||||||
{"[SYSTEM:/] EMMC", COLOR_ORANGE, EMMC_SYS, 1},
|
{"[SYSTEM:/] EMMC", COLOR_ORANGE, EMMC_SYS, 1},
|
||||||
|
@ -64,12 +70,9 @@ menu_item mmcChoice[3] = {
|
||||||
{"SysMMC", COLOR_ORANGE, SYSMMC, 1},
|
{"SysMMC", COLOR_ORANGE, SYSMMC, 1},
|
||||||
{"EmuMMC", COLOR_BLUE, EMUMMC, 1}
|
{"EmuMMC", COLOR_BLUE, EMUMMC, 1}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
const char emmc_entries[3][8] = {
|
|
||||||
"SAFE",
|
|
||||||
"SYSTEM",
|
|
||||||
"USER"
|
|
||||||
};
|
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
|
@ -81,7 +84,7 @@ void MainMenu_EMMC(){
|
||||||
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){
|
if (makewaitmenu("You're about to enter EMMC\nModifying anything here\n can result in a BRICK!\n\nPlease only continue\n if you know what you're doing\n\nPress Vol+/- to return\n", "Press Power to enter", 4)){
|
||||||
connect_mmc(SYSMMC);
|
connect_mmc(SYSMMC);
|
||||||
|
|
||||||
if (!mount_mmc(emmc_entries[res - 2], res - 1))
|
if (!mount_mmc(emmc_fs_entries[res - 2], res - 1))
|
||||||
fileexplorer("emmc:/");
|
fileexplorer("emmc:/");
|
||||||
else
|
else
|
||||||
message(COLOR_RED, "EMMC failed to mount!");
|
message(COLOR_RED, "EMMC failed to mount!");
|
||||||
|
@ -91,7 +94,7 @@ void MainMenu_EMMC(){
|
||||||
void MainMenu_EMUMMC(){
|
void MainMenu_EMUMMC(){
|
||||||
connect_mmc(EMUMMC);
|
connect_mmc(EMUMMC);
|
||||||
|
|
||||||
if (!mount_mmc(emmc_entries[res - 5], res - 4))
|
if (!mount_mmc(emmc_fs_entries[res - 5], res - 4))
|
||||||
fileexplorer("emmc:/");
|
fileexplorer("emmc:/");
|
||||||
else
|
else
|
||||||
message(COLOR_RED, "EMUMMC failed to mount!");
|
message(COLOR_RED, "EMUMMC failed to mount!");
|
||||||
|
@ -105,52 +108,46 @@ void MainMenu_MountSD(){
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu_Tools(){
|
void MainMenu_Tools(){
|
||||||
res = makemenu(toolsmenu, 8);
|
//res = makemenu(toolsmenu, 8);
|
||||||
|
res = menu_make(mainmenu_tools, 7, "-- Tools Menu --");
|
||||||
|
|
||||||
switch(res){
|
switch(res){
|
||||||
case DISPLAY_INFO:
|
case TOOLS_DISPLAY_INFO:
|
||||||
displayinfo();
|
displayinfo();
|
||||||
break;
|
break;
|
||||||
case DISPLAY_GPIO:
|
case TOOLS_DISPLAY_GPIO:
|
||||||
displaygpio();
|
displaygpio();
|
||||||
break;
|
break;
|
||||||
case DUMPFIRMWARE:
|
case TOOLS_DUMPFIRMWARE:
|
||||||
dumpfirmware(SYSMMC);
|
dumpfirmware(SYSMMC);
|
||||||
break;
|
break;
|
||||||
case DUMPUSERSAVE:
|
case TOOLS_DUMPUSERSAVE:
|
||||||
if (mainmenu[4].property >= 0){
|
if ((res = utils_mmcMenu()) > 0)
|
||||||
if ((res = makemenu(mmcChoice, 3)) >= 0)
|
|
||||||
dumpusersaves(res);
|
dumpusersaves(res);
|
||||||
}
|
|
||||||
else
|
|
||||||
dumpusersaves(SYSMMC);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case DUMP_BOOT:
|
case TOOLS_DUMP_BOOT:
|
||||||
dump_emmc_parts(PART_BOOT | PART_PKG2, SYSMMC);
|
dump_emmc_parts(PART_BOOT | PART_PKG2, SYSMMC);
|
||||||
break;
|
break;
|
||||||
case RESTORE_BOOT:
|
case TOOLS_RESTORE_BOOT:
|
||||||
if (makewaitmenu(
|
if (makewaitmenu(
|
||||||
"WARNING!\nThis will mess with your switch boot files\nMake a nand backup beforehand!\n\nThis will pull from path:\nsd:/tegraexplorer/boot.bis\n\nVol +/- to cancel\n",
|
"WARNING!\nThis will mess with your switch boot files\nMake a nand backup beforehand!\n\nThis will pull from path:\nsd:/tegraexplorer/boot.bis\n\nVol +/- to cancel\n",
|
||||||
"Power to confirm",
|
"Power to confirm",
|
||||||
5
|
5
|
||||||
))
|
))
|
||||||
{
|
{
|
||||||
if (emu_cfg.enabled){
|
if ((res = utils_mmcMenu()) > 0)
|
||||||
if ((res = makemenu(mmcChoice, 3)) >= 0)
|
|
||||||
restore_bis_using_file("sd:/tegraexplorer/boot.bis", res);
|
restore_bis_using_file("sd:/tegraexplorer/boot.bis", res);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
restore_bis_using_file("sd:/tegraexplorer/boot.bis", SYSMMC);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainMenu_SDFormat(){
|
void MainMenu_SDFormat(){
|
||||||
res = makemenu(formatmenu, 4);
|
//res = makemenu(formatmenu, 4);
|
||||||
|
res = menu_make(mainmenu_format, 3, "-- Format Menu --");
|
||||||
|
|
||||||
if (res >= 0){
|
if (res > 0){
|
||||||
if(makewaitmenu("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10)){
|
if(makewaitmenu("Are you sure you want to format your sd?\nThis will delete everything on your SD card\nThis action is irreversible!\n\nPress Vol+/- to cancel\n", "Press Power to continue", 10)){
|
||||||
if (format(res)){
|
if (format(res)){
|
||||||
sd_unmount();
|
sd_unmount();
|
||||||
|
@ -165,30 +162,36 @@ void MainMenu_Credits(){
|
||||||
|
|
||||||
void MainMenu_Exit(){
|
void MainMenu_Exit(){
|
||||||
if (return_sd_mounted(1)){
|
if (return_sd_mounted(1)){
|
||||||
|
/*
|
||||||
shutdownmenu[5].property = (checkfile("/bootloader/update.bin")) ? 1 : -1;
|
shutdownmenu[5].property = (checkfile("/bootloader/update.bin")) ? 1 : -1;
|
||||||
shutdownmenu[6].property = (checkfile("/atmosphere/reboot_payload.bin")) ? 1 : -1;
|
shutdownmenu[6].property = (checkfile("/atmosphere/reboot_payload.bin")) ? 1 : -1;
|
||||||
|
*/
|
||||||
|
|
||||||
|
SETBIT(mainmenu_shutdown[4].property, ISHIDE, !checkfile("/bootloader/update.bin"));
|
||||||
|
SETBIT(mainmenu_shutdown[5].property, ISHIDE, !checkfile("/atmosphere/reboot_payload.bin"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
shutdownmenu[5].property = -1;
|
for (int i = 4; i <= 5; i++)
|
||||||
shutdownmenu[6].property = -1;
|
SETBIT(mainmenu_shutdown[i].property, ISHIDE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = makemenu(shutdownmenu, 7);
|
//res = makemenu(shutdownmenu, 7);
|
||||||
|
res = menu_make(mainmenu_shutdown, 6, "-- Shutdown Menu --");
|
||||||
|
|
||||||
switch(res){
|
switch(res){
|
||||||
case REBOOT_RCM:
|
case SHUTDOWN_REBOOT_RCM:
|
||||||
reboot_rcm();
|
reboot_rcm();
|
||||||
|
|
||||||
case REBOOT_NORMAL:
|
case SHUTDOWN_REBOOT_NORMAL:
|
||||||
reboot_normal();
|
reboot_normal();
|
||||||
|
|
||||||
case POWER_OFF:
|
case SHUTDOWN_POWER_OFF:
|
||||||
power_off();
|
power_off();
|
||||||
|
|
||||||
case HEKATE:
|
case SHUTDOWN_HEKATE:
|
||||||
launch_payload("/bootloader/update.bin");
|
launch_payload("/bootloader/update.bin");
|
||||||
|
|
||||||
case AMS:
|
case SHUTDOWN_AMS:
|
||||||
launch_payload("/atmosphere/reboot_payload.bin");
|
launch_payload("/atmosphere/reboot_payload.bin");
|
||||||
} //todo declock bpmp
|
} //todo declock bpmp
|
||||||
}
|
}
|
||||||
|
@ -213,6 +216,7 @@ void RunMenuOption(int option){
|
||||||
mainmenu_functions[option - 1]();
|
mainmenu_functions[option - 1]();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
void fillmainmenu(){
|
void fillmainmenu(){
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -232,38 +236,81 @@ void fillmainmenu(){
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if (return_sd_mounted(1)){
|
if (return_sd_mounted(1)){
|
||||||
mainmenu[i].property = 2;
|
//mainmenu[i].property = 2;
|
||||||
strcpy(mainmenu[i].name, "\nUnmount SD");
|
//strcpy(mainmenu[i].name, "\nUnmount SD");
|
||||||
|
mainmenu_main[7].name = (menu_sd_states[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mainmenu[i].property = 1;
|
//mainmenu[i].property = 1;
|
||||||
strcpy(mainmenu[i].name, "\nMount SD");
|
//strcpy(mainmenu[i].name, "\nMount SD");
|
||||||
|
mainmenu_main[7].name = (menu_sd_states[1]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
void te_main(){
|
void te_main(){
|
||||||
|
int setter;
|
||||||
|
|
||||||
if (dump_biskeys() == -1){
|
if (dump_biskeys() == -1){
|
||||||
message(COLOR_RED, "Biskeys failed to dump!\nEmmc will not be mounted!");
|
message(COLOR_RED, "Biskeys failed to dump!\nEmmc will not be mounted!");
|
||||||
mainmenu[1].property = -1;
|
for (int i = 1; i <= 3; i++)
|
||||||
mainmenu[2].property = -1;
|
mainmenu_main[i].property |= ISHIDE;
|
||||||
mainmenu[3].property = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emummc_load_cfg()){
|
if (emummc_load_cfg()){
|
||||||
mainmenu[4].property = -2;
|
for (int i = 4; i <= 6; i++)
|
||||||
mainmenu[5].property = -2;
|
mainmenu_main[i].property |= ISHIDE;
|
||||||
mainmenu[6].property = -2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect_mmc();
|
disconnect_mmc();
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
fillmainmenu();
|
//fillmainmenu();
|
||||||
res = makemenu(mainmenu, MAINMENU_AMOUNT);
|
|
||||||
|
setter = return_sd_mounted(1);
|
||||||
|
|
||||||
|
if (emu_cfg.enabled){
|
||||||
|
for (int i = 4; i <= 6; i++)
|
||||||
|
SETBIT(mainmenu_main[i].property, ISHIDE, !setter);
|
||||||
|
}
|
||||||
|
SETBIT(mainmenu_main[0].property, ISHIDE, !setter);
|
||||||
|
mainmenu_main[7].name = (menu_sd_states[!setter]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (return_sd_mounted(1)){
|
||||||
|
if (emu_cfg.enabled){
|
||||||
|
for (int i = 4; i <= 6; i++)
|
||||||
|
SETBIT(mainmenu_main[i], ISHIDE, 0);
|
||||||
|
}
|
||||||
|
SETBIT(mainmenu_main[0], ISHIDE, 0);
|
||||||
|
mainmenu_main[7].name = (menu_sd_states[0]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (emu_cfg.enabled){
|
||||||
|
for (int i = 4; i <= 6; i++)
|
||||||
|
SETBIT(mainmenu_main[i], ISHIDE, 1);
|
||||||
|
}
|
||||||
|
SETBIT(mainmenu_main[0], ISHIDE, 1);
|
||||||
|
mainmenu_main[7].name = (menu_sd_states[1]);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
setter = return_sd_mounted(10);
|
||||||
|
SETBIT(mainmenu_main[9].property, ISHIDE, !setter);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (return_sd_mounted(10))
|
||||||
|
SETBIT(mainmenu_main[0], ISHIDE, 0);
|
||||||
|
else
|
||||||
|
SETBIT(mainmenu_main[0], ISHIDE, 1);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
//res = makemenu(mainmenu, MAINMENU_AMOUNT);
|
||||||
|
res = menu_make(mainmenu_main, 12, "-- Main Menu --") + 1;
|
||||||
RunMenuOption(res);
|
RunMenuOption(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@ typedef struct _menu_item {
|
||||||
short property;
|
short property;
|
||||||
} menu_item;
|
} menu_item;
|
||||||
|
|
||||||
|
/*
|
||||||
enum mainmenu_return {
|
enum mainmenu_return {
|
||||||
SD_CARD = 1,
|
SD_CARD = 1,
|
||||||
EMMC_SAF,
|
EMMC_SAF,
|
||||||
|
@ -47,5 +48,6 @@ enum formatmenu_return {
|
||||||
FORMAT_EMUMMC = 0,
|
FORMAT_EMUMMC = 0,
|
||||||
FORMAT_ALL_FAT32
|
FORMAT_ALL_FAT32
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
void te_main();
|
void te_main();
|
|
@ -13,6 +13,7 @@
|
||||||
#include "emmc.h"
|
#include "emmc.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "common/common.h"
|
||||||
|
|
||||||
extern bool sd_mount();
|
extern bool sd_mount();
|
||||||
extern void sd_unmount();
|
extern void sd_unmount();
|
||||||
|
@ -188,7 +189,7 @@ int format(int mode){
|
||||||
timer = get_tmr_s();
|
timer = get_tmr_s();
|
||||||
totalsectors = sd_storage.csd.capacity;
|
totalsectors = sd_storage.csd.capacity;
|
||||||
|
|
||||||
if (mode == 0){
|
if (mode == FORMAT_EMUMMC){
|
||||||
if (totalsectors < 83886080){
|
if (totalsectors < 83886080){
|
||||||
gfx_printf("%kYou seem to be running this on a <=32GB SD\nNot enough free space for emummc!", COLOR_RED);
|
gfx_printf("%kYou seem to be running this on a <=32GB SD\nNot enough free space for emummc!", COLOR_RED);
|
||||||
fatalerror = true;
|
fatalerror = true;
|
||||||
|
|
13
source/tegraexplorer/utils/utils.c
Normal file
13
source/tegraexplorer/utils/utils.c
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include "utils.h"
|
||||||
|
#include "../common/common.h"
|
||||||
|
#include "../gfx/menu.h"
|
||||||
|
#include "../../storage/emummc.h"
|
||||||
|
|
||||||
|
int utils_mmcMenu(){
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (emu_cfg.enabled)
|
||||||
|
return menu_make(utils_mmcChoice, 3, "-- Choose MMC --");
|
||||||
|
else
|
||||||
|
return SYSMMC;
|
||||||
|
}
|
3
source/tegraexplorer/utils/utils.h
Normal file
3
source/tegraexplorer/utils/utils.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
int utils_mmcMenu();
|
Loading…
Add table
Reference in a new issue