1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 05:42:07 +00:00

properly implement #REQUIRE (VER x.x.x, MINERVA, KEYS)

This commit is contained in:
suchmememanyskill 2021-07-19 16:25:32 +02:00
parent 2311c52ebf
commit e49f184f9b
5 changed files with 39 additions and 24 deletions

View file

@ -12,6 +12,7 @@ IPL_LOAD_ADDR := 0x40008000
LPVERSION_MAJOR := 3 LPVERSION_MAJOR := 3
LPVERSION_MINOR := 0 LPVERSION_MINOR := 0
LPVERSION_BUGFX := 6 LPVERSION_BUGFX := 6
LPVERSION := \"$(LPVERSION_MAJOR).$(LPVERSION_MINOR).$(LPVERSION_BUGFX)\"
################################################################################ ################################################################################
@ -40,7 +41,7 @@ FFCFG_INC := '"../$(SOURCEDIR)/libs/fatfs/ffconf.h"'
################################################################################ ################################################################################
CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR) CUSTOMDEFINES := -DIPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX) CUSTOMDEFINES += -DLP_VER_MJ=$(LPVERSION_MAJOR) -DLP_VER_MN=$(LPVERSION_MINOR) -DLP_VER_BF=$(LPVERSION_BUGFX) -DLP_VER=$(LPVERSION)
CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC) CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC)
# 0: UART_A, 1: UART_B. # 0: UART_A, 1: UART_B.

View file

@ -9,6 +9,7 @@
#define LP_VER_MJ 3 #define LP_VER_MJ 3
#define LP_VER_MN 0 #define LP_VER_MN 0
#define LP_VER_BF 5 #define LP_VER_BF 5
#define LP_VER "3.0.5"
#define FREE(x) if (x) free(x) #define FREE(x) if (x) free(x)
#define CpyStr(x) _strdup(x); #define CpyStr(x) _strdup(x);
#include "vector.h" #include "vector.h"

View file

@ -13,6 +13,10 @@
#include "scriptError.h" #include "scriptError.h"
#include "standardLibrary.h" #include "standardLibrary.h"
#ifndef WIN32
#include "../tegraexplorer/tconf.h"
#endif
static inline int isValidWord(char c) { static inline int isValidWord(char c) {
char r = c | 0x20; char r = c | 0x20;
return ((r >= 'a' && r <= 'z') || c == '_'); return ((r >= 'a' && r <= 'z') || c == '_');
@ -80,36 +84,42 @@ u8 nextToken(char** inPtr, void** val) {
if (*in == '#') { if (*in == '#') {
if (!memcmp(in + 1, "REQUIRE ", 8)) { if (!memcmp(in + 1, "REQUIRE ", 8)) {
if (!memcmp(in + 9, "VER ", 4)) { if (!memcmp(in + 9, "VER ", 4)) {
u8 vers[3] = { 0 };
char* verStart = in + 13; char* verStart = in + 13;
for (u8 i = 0; i < 3; i++) { char* verEnd = verStart;
while (isValidNum(*verStart)) {
vers[i] = vers[i] * 10 + *verStart++ - '0';
}
verStart++;
}
u8 outdated = 0; while (isValidNum(*verEnd) || *verEnd == '.')
if (vers[0] > LP_VER_MJ) verEnd++;
outdated = 1;
else if (vers[0] == LP_VER_MJ) { u8 outdated = (verEnd - verStart != strlen(LP_VER));
if (vers[1] > LP_VER_MN)
outdated = 1; if (!outdated){
else if (vers[1] == LP_VER_MN) { outdated = (memcmp(LP_VER, verStart, verEnd - verStart) < 0);
if (vers[2] > LP_VER_BF)
outdated = 1;
}
} }
if (outdated) { if (outdated) {
printScriptError(SCRIPT_FATAL, "Script requires TegraExplorer %d.%d.%d or up!", vers[0], vers[1], vers[2]); printScriptError(SCRIPT_LEXER_FATAL, "Script requires a newer TegraExplorer version!");
return Token_Fatal_Err; return Token_Fatal_Err;
} }
} }
else if (!memcmp(in + 9, "MINERVA", 7)) { else if (!memcmp(in + 9, "MINERVA", 7)) {
u8 minervaEnabled = 0; // TODO: Change this to the actual value #ifdef WIN32
u8 minervaEnabled = 0;
#else
u8 minervaEnabled = TConf.minervaEnabled;
#endif
if (!minervaEnabled) { if (!minervaEnabled) {
printScriptError(SCRIPT_FATAL, "Extended memory required.\nPut the bootloader folder from hekate on your sd!"); printScriptError(SCRIPT_LEXER_FATAL, "Extended memory required.\nPut the bootloader folder from hekate on your sd!");
return Token_Fatal_Err;
}
}
else if (!memcmp(in + 9, "KEYS", 4)) {
#ifdef WIN32
u8 gotKeys = 0;
#else
u8 gotKeys = TConf.keysDumped;
#endif
if (!gotKeys){
printScriptError(SCRIPT_LEXER_FATAL, "Keys required.\nMake sure you're on the latest version of TegraExplorer!");
return Token_Fatal_Err; return Token_Fatal_Err;
} }
} }

View file

@ -5,6 +5,7 @@ enum {
SCRIPT_FATAL = 0, SCRIPT_FATAL = 0,
SCRIPT_PARSER_FATAL, SCRIPT_PARSER_FATAL,
SCRIPT_WARN, SCRIPT_WARN,
SCRIPT_LEXER_FATAL,
SCRIPT_BREAK, SCRIPT_BREAK,
}; };

View file

@ -222,12 +222,14 @@ void EnterMainMenu(){
gfx_clearscreen(); gfx_clearscreen();
gfx_putc('\n'); gfx_putc('\n');
res = newMenu(&ent, res, 79, 30, ALWAYSREDRAW, 0); res = newMenu(&ent, res, 79, 30, (ent.count == ARRAY_SIZE(mainMenuEntries)) ? ALWAYSREDRAW : ALWAYSREDRAW | ENABLEPAGECOUNT, ent.count - ARRAY_SIZE(mainMenuEntries));
if (res < MainScripts && mainMenuPaths[res] != NULL) if (res < MainScripts && mainMenuPaths[res] != NULL)
mainMenuPaths[res](); mainMenuPaths[res]();
else if (hasScripts){ else if (hasScripts){
vecDefArray(FSEntry_t*, scriptFilesArray, scriptFiles); vecDefArray(MenuEntry_t*, entArray, ent);
RunScript("sd:/tegraexplorer/scripts", scriptFilesArray[res - ARRAY_SIZE(mainMenuEntries)]); MenuEntry_t entry = entArray[res];
FSEntry_t fsEntry = {.name = entry.name, .sizeUnion = entry.sizeUnion};
RunScript("sd:/tegraexplorer/scripts", fsEntry);
hidWait(); hidWait();
} }