Compare commits

..

6 Commits
1.3.0 ... 1.3.2

Author SHA1 Message Date
Such Meme, Many Skill
7c7dd7178f Bump version 2020-03-06 12:26:54 +01:00
Such Meme, Many Skill
d93b50205a Add battery indicator 2020-03-03 15:19:42 +01:00
Such Meme, Many Skill
405cb46b77 (Potentially) Fix file based emummc's not mounting 2020-02-22 19:49:25 +01:00
Such Meme, Many Skill
7f7c2e65ee Fix freeing errors in copy-recursive 2020-02-22 19:05:50 +01:00
Such Meme, Many Skill
c2df3d80dd Clean up main menu 2020-02-11 17:18:29 +01:00
Such Meme, Many Skill
a3b876ea3e [Scripting] Add <VERSION>, <WAIT>, <COLOR> + cleanup + version bump 2020-02-10 14:16:17 +01:00
8 changed files with 221 additions and 173 deletions

View File

@@ -11,7 +11,7 @@ include $(DEVKITARM)/base_rules
IPL_LOAD_ADDR := 0x40003000 IPL_LOAD_ADDR := 0x40003000
LPVERSION_MAJOR := 2 LPVERSION_MAJOR := 2
LPVERSION_MINOR := 3 LPVERSION_MINOR := 3
LPVERSION_BUGFX := 0 LPVERSION_BUGFX := 2
################################################################################ ################################################################################

View File

@@ -84,6 +84,7 @@ int mount_mmc(const char *partition, const int biskeynumb){
void connect_mmc(short mmctype){ void connect_mmc(short mmctype){
if (mmctype != currentlyMounted){ if (mmctype != currentlyMounted){
disconnect_mmc(); disconnect_mmc();
h_cfg.emummc_force_disable = 0;
switch (mmctype){ switch (mmctype){
case SYSMMC: case SYSMMC:
sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4); sdmmc_storage_init_mmc(&storage, &sdmmc, SDMMC_4, SDMMC_BUS_WIDTH_8, 4);

View File

@@ -8,6 +8,7 @@
#include "gfx.h" #include "gfx.h"
#include "fs.h" #include "fs.h"
#include "../mem/minerva.h" #include "../mem/minerva.h"
#include "../power/max17050.h"
#include <stdarg.h> #include <stdarg.h>
const char fixedoptions[3][50] = { const char fixedoptions[3][50] = {
@@ -24,10 +25,22 @@ const char sizevalues[4][3] = {
}; };
void clearscreen(){ void clearscreen(){
int battery = 0;
max17050_get_property(MAX17050_RepSOC, &battery);
gfx_clear_grey(0x1B); 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_box(0, 0, 719, 15, COLOR_WHITE);
gfx_con_setpos(0, 0); gfx_con_setpos(0, 0);
gfx_printf("%k%KTegraexplorer v1.3.0%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT); gfx_printf("Tegraexplorer v1.3.2\n");
RESETCOLOR;
} }
int message(u32 color, const char* message, ...){ int message(u32 color, const char* message, ...){

View File

@@ -3,6 +3,7 @@
#include "fs.h" #include "fs.h"
#define SWAPCOLOR(color) gfx_printf("%k", color) #define SWAPCOLOR(color) gfx_printf("%k", color)
#define SWAPBGCOLOR(color) gfx_printf("%K", color)
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT) #define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
int makemenu(menu_item menu[], int menuamount); int makemenu(menu_item menu[], int menuamount);

View File

@@ -166,7 +166,7 @@ int del_recursive(char *path){
makestring(path, &localpath); makestring(path, &localpath);
if ((res = f_opendir(&dir, localpath))){ if ((res = f_opendir(&dir, localpath))){
message(COLOR_RED, "Error during f_opendir: %d", res); //message(COLOR_RED, "Error during f_opendir: %d", res);
return -1; return -1;
} }
@@ -240,9 +240,6 @@ int copy_recursive(char *path, char *dstpath){
} }
f_closedir(&dir); f_closedir(&dir);
free(startpath);
free(destpath);
free(destfoldername);
if (f_stat(startpath, &fno)) if (f_stat(startpath, &fno))
return 22; return 22;
@@ -250,6 +247,9 @@ int copy_recursive(char *path, char *dstpath){
if ((res = f_chmod(destpath, fno.fattrib, 0x3A))) if ((res = f_chmod(destpath, fno.fattrib, 0x3A)))
return res; return res;
free(startpath);
free(destpath);
free(destfoldername);
return 0; return 0;
} }

View File

@@ -13,79 +13,115 @@
#include "../storage/emummc.h" #include "../storage/emummc.h"
#include "script.h" #include "script.h"
#include <stdlib.h>
char func[11] = "", args[2][128] = {"", ""}; char func[11] = "", args[2][128] = {"", ""};
int res, errcode; int res, errcode;
const int scriptver = 131;
bool forceExit = false;
u32 currentcolor;
int Part_Move(){ void Part_SetColor(){
if (strcmpcheck(args[0], "RED"))
currentcolor = COLOR_RED;
else if (strcmpcheck(args[0], "ORANGE"))
currentcolor = COLOR_ORANGE;
else if (strcmpcheck(args[0], "YELLOW"))
currentcolor = COLOR_YELLOW;
else if (strcmpcheck(args[0], "GREEN"))
currentcolor = COLOR_GREEN;
else if (strcmpcheck(args[0], "BLUE"))
currentcolor = COLOR_BLUE;
else if (strcmpcheck(args[0], "VIOLET"))
currentcolor = COLOR_VIOLET;
else if (strcmpcheck(args[0], "WHITE"))
currentcolor = COLOR_WHITE;
}
void Part_Wait(){
int waitamount, begintime;
SWAPCOLOR(currentcolor);
waitamount = atoi(args[0]);
begintime = get_tmr_s();
while (begintime + waitamount > get_tmr_s()){
gfx_printf("\r<Wait %d seconds> ", (begintime + waitamount) - get_tmr_s());
}
gfx_printf("\r \r");
}
void Part_VersionCheck(){
int givenversion = atoi(args[0]);
if (givenversion > scriptver){
gfx_printf("Script required version is too high\nUpdate TegraExplorer!");
btn_wait();
forceExit = true;
}
}
void Part_Move(){
errcode = f_rename(args[0], args[1]); errcode = f_rename(args[0], args[1]);
f_rename(args[0], args[1]); if (errcode)
return errcode; f_rename(args[0], args[1]);
} }
int Part_Delete(){ void Part_Delete(){
errcode = f_unlink(args[0]); errcode = f_unlink(args[0]);
f_unlink(args[0]); if (errcode)
return errcode; f_unlink(args[0]);
} }
int Part_DeleteRecursive(){ void Part_DeleteRecursive(){
errcode = del_recursive(args[0]); errcode = del_recursive(args[0]);
return errcode;
} }
int Part_Copy(){ void Part_Copy(){
errcode = copy(args[0], args[1], true, false); errcode = copy(args[0], args[1], true, false);
return errcode;
} }
int Part_RecursiveCopy(){ void Part_RecursiveCopy(){
errcode = copy_recursive(args[0], args[1]); errcode = copy_recursive(args[0], args[1]);
return errcode;
} }
int Part_MakeFolder(){ void Part_MakeFolder(){
errcode = f_mkdir(args[0]); errcode = f_mkdir(args[0]);
f_mkdir(args[0]); if (errcode)
return errcode; f_mkdir(args[0]);
} }
int Part_ConnectMMC(){ void Part_ConnectMMC(){
if (strcmpcheck(args[0], "SYSMMC")) if (strcmpcheck(args[0], "SYSMMC"))
connect_mmc(SYSMMC); connect_mmc(SYSMMC);
if (strcmpcheck(args[0], "EMUMMC")) if (strcmpcheck(args[0], "EMUMMC"))
connect_mmc(EMUMMC); connect_mmc(EMUMMC);
return 0;
} }
int Part_MountMMC(){ void Part_MountMMC(){
errcode = mount_mmc(args[0], 2); errcode = mount_mmc(args[0], 2);
return errcode;
} }
int Part_Print(){ void Part_Print(){
RESETCOLOR; RESETCOLOR;
gfx_printf(args[0]); SWAPCOLOR(currentcolor);
gfx_printf("\n"); gfx_printf("%s\n", args[0]);
return 0;
} }
int Part_ErrorPrint(){ void Part_ErrorPrint(){
RESETCOLOR; RESETCOLOR;
SWAPCOLOR(COLOR_RED);
gfx_printf("Errorcode: %d\n", errcode); gfx_printf("Errorcode: %d\n", errcode);
return 0;
} }
bool forceExit = false; void Part_Exit(){
int Part_Exit(){
forceExit = true; forceExit = true;
return 0;
} }
u8 buttons_pressed = 0; u8 buttons_pressed = 0;
int Part_WaitOnUser(){ void Part_WaitOnUser(){
buttons_pressed = btn_wait(); buttons_pressed = btn_wait();
return (buttons_pressed & BTN_POWER);
} }
script_parts parts[] = { script_parts parts[] = {
@@ -101,6 +137,9 @@ script_parts parts[] = {
{"DEL", Part_Delete, 1}, {"DEL", Part_Delete, 1},
{"DEL-R", Part_DeleteRecursive, 1}, {"DEL-R", Part_DeleteRecursive, 1},
{"MOVE", Part_Move, 2}, {"MOVE", Part_Move, 2},
{"VERSION", Part_VersionCheck, 1},
{"WAIT", Part_Wait, 1},
{"COLOR", Part_SetColor, 1},
{"NULL", NULL, -1} {"NULL", NULL, -1}
}; };
@@ -110,6 +149,8 @@ int ParsePart(){
if (strcmpcheck(func, parts[i].name)) if (strcmpcheck(func, parts[i].name))
return i; return i;
} }
gfx_printf("Parsing error...\nPress any key to continue");
btn_wait();
forceExit = true; forceExit = true;
return -1; return -1;
} }
@@ -132,6 +173,7 @@ void ParseScript(char* path){
int strlength; int strlength;
bool inifstatement = false; bool inifstatement = false;
forceExit = false; forceExit = false;
currentcolor = COLOR_WHITE;
clearscreen(); clearscreen();

View File

@@ -1,7 +1,7 @@
#pragma once #pragma once
#define strcmpcheck(x, y) (!strcmp(x, y)) #define strcmpcheck(x, y) (!strcmp(x, y))
typedef int (*part_handler)(); typedef void (*part_handler)();
typedef struct _script_parts { typedef struct _script_parts {
char name[11]; char name[11];
part_handler handler; part_handler handler;

View File

@@ -9,6 +9,7 @@
#include "../utils/btn.h" #include "../utils/btn.h"
#include "emmc.h" #include "emmc.h"
#include "../storage/emummc.h" #include "../storage/emummc.h"
#include "script.h"
extern bool sd_mount(); extern bool sd_mount();
extern void sd_unmount(); extern void sd_unmount();
@@ -68,6 +69,130 @@ const char emmc_entries[3][8] = {
"USER" "USER"
}; };
int res = 0;
void MainMenu_SDCard(){
fileexplorer("SD:/");
}
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)){
connect_mmc(SYSMMC);
if (!mount_mmc(emmc_entries[res - 2], res - 1))
fileexplorer("emmc:/");
else
message(COLOR_RED, "EMMC failed to mount!");
}
}
void MainMenu_EMUMMC(){
connect_mmc(EMUMMC);
if (!mount_mmc(emmc_entries[res - 5], res - 4))
fileexplorer("emmc:/");
else
message(COLOR_RED, "EMUMMC failed to mount!");
}
void MainMenu_MountSD(){
if (return_sd_mounted(1))
sd_unmount();
else
sd_mount();
}
void MainMenu_Tools(){
res = makemenu(toolsmenu, 6);
switch(res){
case DISPLAY_INFO:
displayinfo();
break;
case DISPLAY_GPIO:
displaygpio();
break;
case DUMPFIRMWARE:
dumpfirmware(SYSMMC);
break;
case DUMPUSERSAVE:
if (mainmenu[4].property >= 0){
if ((res = makemenu(mmcChoice, 3)) >= 0)
dumpusersaves(res);
}
else
dumpusersaves(SYSMMC);
break;
}
}
void MainMenu_SDFormat(){
res = makemenu(formatmenu, 4);
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 (format(res)){
sd_unmount();
}
}
}
}
void MainMenu_Credits(){
message(COLOR_WHITE, CREDITS_MESSAGE);
}
void MainMenu_Exit(){
if (return_sd_mounted(1)){
shutdownmenu[5].property = (checkfile("/bootloader/update.bin")) ? 1 : -1;
shutdownmenu[6].property = (checkfile("/atmosphere/reboot_payload.bin")) ? 1 : -1;
}
else {
shutdownmenu[5].property = -1;
shutdownmenu[6].property = -1;
}
res = makemenu(shutdownmenu, 7);
switch(res){
case REBOOT_RCM:
reboot_rcm();
case REBOOT_NORMAL:
reboot_normal();
case POWER_OFF:
power_off();
case HEKATE:
launch_payload("/bootloader/update.bin");
case AMS:
launch_payload("/atmosphere/reboot_payload.bin");
} //todo declock bpmp
}
part_handler mainmenu_functions[] = {
MainMenu_SDCard,
MainMenu_EMMC,
MainMenu_EMMC,
MainMenu_EMMC,
MainMenu_EMUMMC,
MainMenu_EMUMMC,
MainMenu_EMUMMC,
MainMenu_MountSD,
MainMenu_Tools,
MainMenu_SDFormat,
MainMenu_Credits,
MainMenu_Exit,
};
void RunMenuOption(int option){
if (option > 0)
mainmenu_functions[option - 1]();
}
void fillmainmenu(){ void fillmainmenu(){
int i; int i;
@@ -100,7 +225,6 @@ void fillmainmenu(){
} }
void te_main(){ void te_main(){
int res;
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!");
@@ -120,139 +244,6 @@ void te_main(){
while (1){ while (1){
fillmainmenu(); fillmainmenu();
res = makemenu(mainmenu, MAINMENU_AMOUNT); res = makemenu(mainmenu, MAINMENU_AMOUNT);
RunMenuOption(res);
switch(res){
case SD_CARD:
fileexplorer("SD:/");
break;
case EMMC_SAF:
case EMMC_SYS:
case EMMC_USR:
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);
if (!mount_mmc(emmc_entries[res - 2], res - 1)){
fileexplorer("emmc:/");
}
else
message(COLOR_RED, "EMMC failed to mount!");
}
break;
case EMUMMC_SAF:
case EMUMMC_SYS:
case EMUMMC_USR:
connect_mmc(EMUMMC);
if (!mount_mmc(emmc_entries[res - 5], res - 4)){
fileexplorer("emmc:/");
}
else
message(COLOR_RED, "EMUMMC failed to mount!");
break;
case MOUNT_SD:
if (return_sd_mounted(1))
sd_unmount();
else
sd_mount();
break;
case TOOLS:
res = makemenu(toolsmenu, 6);
switch(res){
case DISPLAY_INFO:
displayinfo();
break;
case DISPLAY_GPIO:
displaygpio();
break;
case DUMPFIRMWARE:
/*
if (mainmenu[4].property >= 0){
res = makemenu(mmcChoice, 3);
if (res >= 0)
dumpfirmware(res);
}
else
*/
dumpfirmware(SYSMMC);
break;
case DUMPUSERSAVE:
if (mainmenu[4].property >= 0){
res = makemenu(mmcChoice, 3);
if (res >= 0)
dumpusersaves(res);
}
else
dumpusersaves(SYSMMC);
break;
}
break;
case SD_FORMAT:
res = makemenu(formatmenu, 4);
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 (format(res)){
sd_unmount();
}
}
}
break;
case CREDITS:
message(COLOR_WHITE, CREDITS_MESSAGE);
break;
case EXIT:
if (return_sd_mounted(1)){
if (checkfile("/bootloader/update.bin"))
shutdownmenu[5].property = 1;
else
shutdownmenu[5].property = -1;
if (checkfile("/atmosphere/reboot_payload.bin"))
shutdownmenu[6].property = 1;
else
shutdownmenu[6].property = -1;
}
else {
shutdownmenu[5].property = -1;
shutdownmenu[6].property = -1;
}
res = makemenu(shutdownmenu, 7);
switch(res){
case REBOOT_RCM:
reboot_rcm();
case REBOOT_NORMAL:
reboot_normal();
case POWER_OFF:
power_off();
case HEKATE:
launch_payload("/bootloader/update.bin");
case AMS:
launch_payload("/atmosphere/reboot_payload.bin");
} //todo declock bpmp
break;
}
} }
} }