mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 20:06:43 +00:00
remove memory(), add cwd(), #REQUIRE SD
This commit is contained in:
parent
40d8bb8ba4
commit
797a5f95b5
6 changed files with 23 additions and 20 deletions
|
@ -1,4 +1,5 @@
|
||||||
#REQUIRE KEYS
|
#REQUIRE KEYS
|
||||||
|
#REQUIRE SD
|
||||||
p=println
|
p=println
|
||||||
pe={pause() exit()}
|
pe={pause() exit()}
|
||||||
fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
|
fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
|
||||||
|
|
|
@ -73,6 +73,7 @@ void DeleteFile(char *path, FSEntry_t entry){
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunScriptString(char *str, u32 size){
|
void RunScriptString(char *str, u32 size){
|
||||||
|
TConf.scriptCWD = "sd:/";
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
ParserRet_t ret = parseScript(str, size);
|
ParserRet_t ret = parseScript(str, size);
|
||||||
setStaticVars(&ret.staticVarHolder);
|
setStaticVars(&ret.staticVarHolder);
|
||||||
|
@ -89,7 +90,8 @@ void RunScript(char *path, FSEntry_t entry){
|
||||||
char *thing = CombinePaths(path, entry.name);
|
char *thing = CombinePaths(path, entry.name);
|
||||||
u32 size;
|
u32 size;
|
||||||
char *script = sd_file_read(thing, &size);
|
char *script = sd_file_read(thing, &size);
|
||||||
free(thing);
|
TConf.scriptCWD = thing;
|
||||||
|
|
||||||
if (!script)
|
if (!script)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -97,19 +99,6 @@ void RunScript(char *path, FSEntry_t entry){
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
/*
|
|
||||||
scriptCtx_t ctx = createScriptCtx();
|
|
||||||
ctx.script = runLexer(script, size);
|
|
||||||
free(script);
|
|
||||||
|
|
||||||
dictVectorAdd(&ctx.varDict, newDict(CpyStr("_CWD"), (newVar(StringType, 0, .stringType = path))));
|
|
||||||
dictVectorAdd(&ctx.varDict, newDict(CpyStr("_EMU"), (newVar(IntType, 0, emu_cfg.enabled))));
|
|
||||||
|
|
||||||
printError(mainLoop(&ctx));
|
|
||||||
|
|
||||||
freeDictVector(&ctx.varDict);
|
|
||||||
lexarVectorClear(&ctx.script);
|
|
||||||
*/
|
|
||||||
|
|
||||||
ParserRet_t ret = parseScript(script, size);
|
ParserRet_t ret = parseScript(script, size);
|
||||||
free(script);
|
free(script);
|
||||||
|
@ -121,6 +110,7 @@ void RunScript(char *path, FSEntry_t entry){
|
||||||
exitFunction(ret.main.operations.data, ret.main.operations.count);
|
exitFunction(ret.main.operations.data, ret.main.operations.count);
|
||||||
vecFree(ret.staticVarHolder);
|
vecFree(ret.staticVarHolder);
|
||||||
vecFree(ret.main.operations);
|
vecFree(ret.main.operations);
|
||||||
|
free(thing);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenameFile(char *path, FSEntry_t entry){
|
void RenameFile(char *path, FSEntry_t entry){
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#include "../tegraexplorer/tconf.h"
|
#include "../tegraexplorer/tconf.h"
|
||||||
|
#include <storage/nx_sd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline int isValidWord(char c) {
|
static inline int isValidWord(char c) {
|
||||||
|
@ -123,6 +124,17 @@ u8 nextToken(char** inPtr, void** val) {
|
||||||
return Token_Fatal_Err;
|
return Token_Fatal_Err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (!memcmp(in + 9, "SD", 2)) {
|
||||||
|
#ifdef WIN32
|
||||||
|
u8 gotSd = 0;
|
||||||
|
#else
|
||||||
|
u8 gotSd = sd_mount();
|
||||||
|
#endif
|
||||||
|
if (!gotSd){
|
||||||
|
printScriptError(SCRIPT_LEXER_FATAL, "Sd required.");
|
||||||
|
return Token_Fatal_Err;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (*in && *in != '\n')
|
while (*in && *in != '\n')
|
||||||
|
|
|
@ -453,6 +453,10 @@ ClassFunction(stdEscPaths){
|
||||||
return newStringVariablePtr(EscapeFolder(args[0]->string.value), 0, 1);
|
return newStringVariablePtr(EscapeFolder(args[0]->string.value), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ClassFunction(stdGetCwd){
|
||||||
|
return newStringVariablePtr(CpyStr(TConf.scriptCWD), 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define STUBBED(name) ClassFunction(name) { return newIntVariablePtr(0); }
|
#define STUBBED(name) ClassFunction(name) { return newIntVariablePtr(0); }
|
||||||
|
|
||||||
|
@ -529,9 +533,9 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
|
||||||
{"setpixel", stdSetPixel, 3, threeIntsStd},
|
{"setpixel", stdSetPixel, 3, threeIntsStd},
|
||||||
{"setpixels", stdSetPixels, 5, threeIntsStd},
|
{"setpixels", stdSetPixels, 5, threeIntsStd},
|
||||||
{"emu", stdHasEmu, 0, 0},
|
{"emu", stdHasEmu, 0, 0},
|
||||||
|
{"cwd", stdGetCwd, 0, 0},
|
||||||
{"clear", stdClear, 0, 0},
|
{"clear", stdClear, 0, 0},
|
||||||
{"timer", stdGetMs, 0, 0},
|
{"timer", stdGetMs, 0, 0},
|
||||||
{"memory", stdGetMemUsage, 0, 0},
|
|
||||||
{"pause", stdPauseMask, 1, threeIntsStd},
|
{"pause", stdPauseMask, 1, threeIntsStd},
|
||||||
{"pause", stdPause, 0, 0},
|
{"pause", stdPause, 0, 0},
|
||||||
{"color", stdColor, 1, threeIntsStd},
|
{"color", stdColor, 1, threeIntsStd},
|
||||||
|
|
|
@ -126,11 +126,6 @@ void ViewCredits(){
|
||||||
if (hidRead()->r)
|
if (hidRead()->r)
|
||||||
gfx_printf("%k\"I'm not even sure if it works\" - meme", COLOR_ORANGE);
|
gfx_printf("%k\"I'm not even sure if it works\" - meme", COLOR_ORANGE);
|
||||||
|
|
||||||
heap_monitor_t a = {0};
|
|
||||||
heap_monitor(&a, false);
|
|
||||||
gfx_printf("\nUsed: %d\nTotal: %d\n", a.used, a.total);
|
|
||||||
|
|
||||||
|
|
||||||
hidWait();
|
hidWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ typedef struct {
|
||||||
};
|
};
|
||||||
const char *pkg1ID;
|
const char *pkg1ID;
|
||||||
u8 pkg1ver;
|
u8 pkg1ver;
|
||||||
|
char *scriptCWD;
|
||||||
} TConf_t;
|
} TConf_t;
|
||||||
|
|
||||||
extern TConf_t TConf;
|
extern TConf_t TConf;
|
||||||
|
|
Loading…
Reference in a new issue