mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-12-26 03:16:03 +00:00
properly implement #REQUIRE (VER x.x.x, MINERVA, KEYS)
This commit is contained in:
parent
2311c52ebf
commit
e49f184f9b
5 changed files with 39 additions and 24 deletions
3
Makefile
3
Makefile
|
@ -12,6 +12,7 @@ IPL_LOAD_ADDR := 0x40008000
|
|||
LPVERSION_MAJOR := 3
|
||||
LPVERSION_MINOR := 0
|
||||
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 += -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)
|
||||
|
||||
# 0: UART_A, 1: UART_B.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#define LP_VER_MJ 3
|
||||
#define LP_VER_MN 0
|
||||
#define LP_VER_BF 5
|
||||
#define LP_VER "3.0.5"
|
||||
#define FREE(x) if (x) free(x)
|
||||
#define CpyStr(x) _strdup(x);
|
||||
#include "vector.h"
|
||||
|
|
|
@ -13,6 +13,10 @@
|
|||
#include "scriptError.h"
|
||||
#include "standardLibrary.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#include "../tegraexplorer/tconf.h"
|
||||
#endif
|
||||
|
||||
static inline int isValidWord(char c) {
|
||||
char r = c | 0x20;
|
||||
return ((r >= 'a' && r <= 'z') || c == '_');
|
||||
|
@ -80,36 +84,42 @@ u8 nextToken(char** inPtr, void** val) {
|
|||
if (*in == '#') {
|
||||
if (!memcmp(in + 1, "REQUIRE ", 8)) {
|
||||
if (!memcmp(in + 9, "VER ", 4)) {
|
||||
u8 vers[3] = { 0 };
|
||||
char* verStart = in + 13;
|
||||
for (u8 i = 0; i < 3; i++) {
|
||||
while (isValidNum(*verStart)) {
|
||||
vers[i] = vers[i] * 10 + *verStart++ - '0';
|
||||
}
|
||||
verStart++;
|
||||
}
|
||||
char* verEnd = verStart;
|
||||
|
||||
u8 outdated = 0;
|
||||
if (vers[0] > LP_VER_MJ)
|
||||
outdated = 1;
|
||||
else if (vers[0] == LP_VER_MJ) {
|
||||
if (vers[1] > LP_VER_MN)
|
||||
outdated = 1;
|
||||
else if (vers[1] == LP_VER_MN) {
|
||||
if (vers[2] > LP_VER_BF)
|
||||
outdated = 1;
|
||||
}
|
||||
while (isValidNum(*verEnd) || *verEnd == '.')
|
||||
verEnd++;
|
||||
|
||||
u8 outdated = (verEnd - verStart != strlen(LP_VER));
|
||||
|
||||
if (!outdated){
|
||||
outdated = (memcmp(LP_VER, verStart, verEnd - verStart) < 0);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ enum {
|
|||
SCRIPT_FATAL = 0,
|
||||
SCRIPT_PARSER_FATAL,
|
||||
SCRIPT_WARN,
|
||||
SCRIPT_LEXER_FATAL,
|
||||
SCRIPT_BREAK,
|
||||
};
|
||||
|
||||
|
|
|
@ -222,12 +222,14 @@ void EnterMainMenu(){
|
|||
gfx_clearscreen();
|
||||
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)
|
||||
mainMenuPaths[res]();
|
||||
else if (hasScripts){
|
||||
vecDefArray(FSEntry_t*, scriptFilesArray, scriptFiles);
|
||||
RunScript("sd:/tegraexplorer/scripts", scriptFilesArray[res - ARRAY_SIZE(mainMenuEntries)]);
|
||||
vecDefArray(MenuEntry_t*, entArray, ent);
|
||||
MenuEntry_t entry = entArray[res];
|
||||
FSEntry_t fsEntry = {.name = entry.name, .sizeUnion = entry.sizeUnion};
|
||||
RunScript("sd:/tegraexplorer/scripts", fsEntry);
|
||||
hidWait();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue