Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf2c116240 | ||
|
|
502a246949 | ||
|
|
e98a3bba68 | ||
|
|
9447256934 | ||
|
|
7e2a672753 | ||
|
|
12136d9289 | ||
|
|
c9fdb650c3 | ||
|
|
e1491da4ad | ||
|
|
e0c62cbec4 | ||
|
|
e1f292fe0d | ||
|
|
b5c11a56c9 |
6
.github/workflows/builder.yml
vendored
6
.github/workflows/builder.yml
vendored
@@ -1,10 +1,6 @@
|
|||||||
name: TegraExplorer builder
|
name: TegraExplorer builder
|
||||||
|
|
||||||
on:
|
on: [push, pull_request]
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -46,7 +46,7 @@ CUSTOMDEFINES += -DGFX_INC=$(GFX_INC) -DFFCFG_INC=$(FFCFG_INC)
|
|||||||
#CUSTOMDEFINES += -DDEBUG
|
#CUSTOMDEFINES += -DDEBUG
|
||||||
|
|
||||||
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
ARCH := -march=armv4t -mtune=arm7tdmi -mthumb -mthumb-interwork
|
||||||
CFLAGS = $(ARCH) -Os -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall $(CUSTOMDEFINES)
|
CFLAGS = $(ARCH) -Os -nostdlib -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-inline -std=gnu11 -Wall -Wno-missing-braces $(CUSTOMDEFINES)
|
||||||
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
LDFLAGS = $(ARCH) -nostartfiles -lgcc -Wl,--nmagic,--gc-sections -Xlinker --defsym=IPL_LOAD_ADDR=$(IPL_LOAD_ADDR)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|||||||
@@ -89,6 +89,15 @@ void BoxRestOfScreen(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrCode_t FolderCopy(const char *locin, const char *locout){
|
ErrCode_t FolderCopy(const char *locin, const char *locout){
|
||||||
|
if (TConf.explorerCopyMode >= CMODE_CopyFolder){
|
||||||
|
if (strstr(locout, locin) != NULL)
|
||||||
|
return newErrCode(TE_ERR_PATH_IN_PATH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strcmp(locin, locout)){
|
||||||
|
return newErrCode(TE_ERR_SAME_LOC);
|
||||||
|
}
|
||||||
|
|
||||||
char *dstPath = CombinePaths(locout, strrchr(locin, '/') + 1);
|
char *dstPath = CombinePaths(locout, strrchr(locin, '/') + 1);
|
||||||
int res = 0;
|
int res = 0;
|
||||||
ErrCode_t ret = newErrCode(0);
|
ErrCode_t ret = newErrCode(0);
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "../../script/parser.h"
|
#include "../../script/parser.h"
|
||||||
#include "../../script/variables.h"
|
#include "../../script/variables.h"
|
||||||
#include <storage/nx_sd.h>
|
#include <storage/nx_sd.h>
|
||||||
|
#include "../../storage/emummc.h"
|
||||||
|
|
||||||
MenuEntry_t FileMenuEntries[] = {
|
MenuEntry_t FileMenuEntries[] = {
|
||||||
{.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "-- File menu --"},
|
{.optionUnion = COLORTORGB(COLOR_WHITE) | SKIPBIT, .name = "-- File menu --"},
|
||||||
@@ -77,17 +78,21 @@ void RunScript(char *path, FSEntry_t entry){
|
|||||||
if (!script)
|
if (!script)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (((entry.size >= 64 && entry.sizeDef == 1) || entry.sizeDef >= 2) && !TConf.minervaEnabled)
|
||||||
|
return;
|
||||||
|
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
scriptCtx_t ctx = createScriptCtx();
|
scriptCtx_t ctx = createScriptCtx();
|
||||||
ctx.script = runLexar(script, size);
|
ctx.script = runLexar(script, size);
|
||||||
free(script);
|
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));
|
printError(mainLoop(&ctx));
|
||||||
|
|
||||||
freeVariableVector(&ctx.varDict);
|
freeDictVector(&ctx.varDict);
|
||||||
lexarVectorClear(&ctx.script);
|
lexarVectorClear(&ctx.script);
|
||||||
gfx_printf("\nend of script");
|
|
||||||
hidWait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenameFile(char *path, FSEntry_t entry){
|
void RenameFile(char *path, FSEntry_t entry){
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void gfx_clearscreen(){
|
|||||||
gfx_boxGrey(0, 703, 1279, 719, 0xFF);
|
gfx_boxGrey(0, 703, 1279, 719, 0xFF);
|
||||||
gfx_boxGrey(0, 0, 1279, 15, 0xFF);
|
gfx_boxGrey(0, 0, 1279, 15, 0xFF);
|
||||||
gfx_con_setpos(0, 0);
|
gfx_con_setpos(0, 0);
|
||||||
gfx_printf("Tegraexplorer b%d.%d.%d | Battery: %3d%%\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8);
|
gfx_printf("Tegraexplorer %d.%d.%d | Battery: %3d%%\n", LP_VER_MJ, LP_VER_MN, LP_VER_BF, battery >> 8);
|
||||||
|
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
}
|
}
|
||||||
|
|||||||
51
source/keys/save.c
Normal file
51
source/keys/save.c
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
#include "save.h"
|
||||||
|
#include <utils/types.h>
|
||||||
|
#include <libs/fatfs/ff.h>
|
||||||
|
#include <sec/se.h>
|
||||||
|
#include <mem/heap.h>
|
||||||
|
#include "../err.h"
|
||||||
|
|
||||||
|
ErrCode_t saveCommit(const char *path){
|
||||||
|
FIL file;
|
||||||
|
int res;
|
||||||
|
u8 *buf, hash[0x20], *cmac_data, cmac[0x10];
|
||||||
|
const u32 hashed_data_size = 0x3D00, cmac_data_size = 0x200;
|
||||||
|
|
||||||
|
buf = malloc(hashed_data_size);
|
||||||
|
cmac_data = malloc(cmac_data_size);
|
||||||
|
|
||||||
|
if ((res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ | FA_WRITE))){
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
f_lseek(&file, 0x300);
|
||||||
|
if ((res = f_read(&file, buf, hashed_data_size, NULL))){
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
se_calc_sha256_oneshot(hash, buf, hashed_data_size);
|
||||||
|
|
||||||
|
f_lseek(&file, 0x108);
|
||||||
|
if ((res = f_write(&file, hash, sizeof(hash), NULL))){
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
f_lseek(&file, 0x100);
|
||||||
|
if ((res = f_read(&file, cmac_data, cmac_data_size, NULL))){
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
se_aes_cmac(8, cmac, 0x10, cmac_data, cmac_data_size);
|
||||||
|
|
||||||
|
f_lseek(&file, 0);
|
||||||
|
|
||||||
|
if ((res = f_write(&file, cmac, sizeof(cmac), NULL))){
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
out_free:;
|
||||||
|
free(buf);
|
||||||
|
free(cmac_data);
|
||||||
|
f_close(&file);
|
||||||
|
return newErrCode(res);
|
||||||
|
}
|
||||||
4
source/keys/save.h
Normal file
4
source/keys/save.h
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "../err.h"
|
||||||
|
|
||||||
|
ErrCode_t saveCommit(const char *path);
|
||||||
@@ -42,6 +42,10 @@ Vector_t extractVars(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len) {
|
|||||||
int distance = distanceBetweenTokens(&tokens[i + 1], len - i - 1, LSBracket, RSBracket);
|
int distance = distanceBetweenTokens(&tokens[i + 1], len - i - 1, LSBracket, RSBracket);
|
||||||
i += distance + 1;
|
i += distance + 1;
|
||||||
}
|
}
|
||||||
|
if (tokens[i].token == LBracket){
|
||||||
|
int distance = distanceBetweenTokens(&tokens[i + 1], len - i - 1, LBracket, RBracket);
|
||||||
|
i += distance + 1;
|
||||||
|
}
|
||||||
if (tokens[i].token == Seperator) {
|
if (tokens[i].token == Seperator) {
|
||||||
Variable_t res = solveEquation(ctx, &tokens[lastLoc], i - lastLoc, 0);
|
Variable_t res = solveEquation(ctx, &tokens[lastLoc], i - lastLoc, 0);
|
||||||
lastLoc = i + 1;
|
lastLoc = i + 1;
|
||||||
@@ -263,6 +267,10 @@ Variable_t solveEquation(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len, u8 sho
|
|||||||
res.integerType = res.integerType & val.integerType;
|
res.integerType = res.integerType & val.integerType;
|
||||||
ELIFT(OR)
|
ELIFT(OR)
|
||||||
res.integerType = res.integerType | val.integerType;
|
res.integerType = res.integerType | val.integerType;
|
||||||
|
ELIFT(BitShiftLeft)
|
||||||
|
res.integerType = res.integerType << val.integerType;
|
||||||
|
ELIFT(BitShiftRight)
|
||||||
|
res.integerType = res.integerType >> val.integerType;
|
||||||
else
|
else
|
||||||
return ErrValue(ERRBADOPERATOR);
|
return ErrValue(ERRBADOPERATOR);
|
||||||
}
|
}
|
||||||
@@ -343,6 +351,25 @@ Variable_t solveEquation(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len, u8 sho
|
|||||||
vecAddElement(&res.vectorType, in);
|
vecAddElement(&res.vectorType, in);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ELIFT(Minus){
|
||||||
|
if (val.integerType >= res.vectorType.count)
|
||||||
|
return ErrValue(ERRSYNTAX);
|
||||||
|
|
||||||
|
res.vectorType.count -= val.integerType;
|
||||||
|
Vector_t newV = vecCopy(&res.vectorType);
|
||||||
|
freeVariable(res);
|
||||||
|
res.vectorType = newV;
|
||||||
|
res.free = 1;
|
||||||
|
}
|
||||||
|
ELIFT(Selector){
|
||||||
|
if (val.integerType >= res.vectorType.count)
|
||||||
|
return ErrValue(ERRSYNTAX);
|
||||||
|
|
||||||
|
Vector_t newV = vecCopyOffset(&res.vectorType, val.integerType);
|
||||||
|
freeVariable(res);
|
||||||
|
res.vectorType = newV;
|
||||||
|
res.free = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (res.varType == StringType && val.varType == IntType){
|
else if (res.varType == StringType && val.varType == IntType){
|
||||||
if (localOpToken == Minus){
|
if (localOpToken == Minus){
|
||||||
@@ -377,7 +404,7 @@ Variable_t solveEquation(scriptCtx_t* ctx, lexarToken_t* tokens, u32 len, u8 sho
|
|||||||
res = val;
|
res = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (tokens[i].token >= Plus && tokens[i].token <= Selector) {
|
else if (tokens[i].token >= Plus && tokens[i].token <= BitShiftRight) {
|
||||||
lastToken = tokens[i].token;
|
lastToken = tokens[i].token;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,27 @@
|
|||||||
#include <mem/heap.h>
|
#include <mem/heap.h>
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
|
|
||||||
|
#include <storage/nx_sd.h>
|
||||||
|
#include "../fs/fsutils.h"
|
||||||
|
#include "../gfx/gfxutils.h"
|
||||||
|
#include "../hid/hid.h"
|
||||||
|
#include <utils/util.h>
|
||||||
|
#include "../fs/fscopy.h"
|
||||||
|
#include "../storage/mountmanager.h"
|
||||||
|
#include "../storage/emummc.h"
|
||||||
|
#include "../fs/readers/folderReader.h"
|
||||||
|
#include "../utils/utils.h"
|
||||||
|
#include "../keys/keys.h"
|
||||||
|
#include "../storage/emmcfile.h"
|
||||||
|
#include "../keys/nca.h"
|
||||||
|
#include "../keys/save.h"
|
||||||
|
#include "../tegraexplorer/tconf.h"
|
||||||
|
|
||||||
#define scriptFunction(name) Variable_t name(scriptCtx_t *ctx, Variable_t *vars, u32 varLen)
|
#define scriptFunction(name) Variable_t name(scriptCtx_t *ctx, Variable_t *vars, u32 varLen)
|
||||||
|
|
||||||
|
#define varInt(i) newVar(IntType, 0, i)
|
||||||
|
#define varStr(s) newVar(StringType, 1, .stringType = s)
|
||||||
|
|
||||||
scriptFunction(funcIf) {
|
scriptFunction(funcIf) {
|
||||||
setCurIndentInstruction(ctx, (vars[0].integerType == 0), 0, -1);
|
setCurIndentInstruction(ctx, (vars[0].integerType == 0), 0, -1);
|
||||||
return NullVar;
|
return NullVar;
|
||||||
@@ -76,10 +95,317 @@ scriptFunction(funcSetPixel){
|
|||||||
return NullVar;
|
return NullVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcFileExists){
|
||||||
|
return newVar(IntType, 0, FileExists(vars[0].stringType));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str (Path)
|
||||||
|
scriptFunction(funcReadFile){
|
||||||
|
u32 fSize = 0;
|
||||||
|
u8 *buff = sd_file_read(vars[0].stringType, &fSize);
|
||||||
|
if (buff == NULL)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
Vector_t vec = vecFromArray(buff, fSize, sizeof(u8));
|
||||||
|
return newVar(ByteArrayType, 1, .vectorType = vec);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str (Path), vector(Byte) (toWrite)
|
||||||
|
scriptFunction(funcWriteFile){
|
||||||
|
return newVar(IntType, 0, sd_save_to_file(vars[1].vectorType.data, vars[1].vectorType.count, vars[0].stringType));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: vector(Byte)
|
||||||
|
scriptFunction(funcByteToStr){
|
||||||
|
char *str = calloc(vars[0].vectorType.count + 1, 1);
|
||||||
|
memcpy(str, vars[0].vectorType.data, vars[0].vectorType.count);
|
||||||
|
return newVar(StringType, 1, .stringType = str);
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcReturn){
|
||||||
|
if (ctx->indentIndex > 0){
|
||||||
|
vecDefArray(indentInstructor_t*, instructors, ctx->indentInstructors);
|
||||||
|
for (int i = ctx->indentIndex - 1; i >= 0; i--){
|
||||||
|
indentInstructor_t ins = instructors[i];
|
||||||
|
if (ins.active && ins.jump && ins.function){
|
||||||
|
ctx->curPos = ins.jumpLoc - 1;
|
||||||
|
ins.active = 0;
|
||||||
|
ctx->indentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcExit){
|
||||||
|
return ErrVar(ERRESCSCRIPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
scriptFunction(funcContinue){
|
||||||
|
if (ctx->indentIndex > 0){
|
||||||
|
vecDefArray(indentInstructor_t*, instructors, ctx->indentInstructors);
|
||||||
|
for (int i = ctx->indentIndex - 1; i >= 0; i--){
|
||||||
|
indentInstructor_t ins = instructors[i];
|
||||||
|
if (ins.active && ins.jump && !ins.function){
|
||||||
|
ctx->curPos = ins.jumpLoc - 1;
|
||||||
|
ins.active = 0;
|
||||||
|
ctx->indentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Args: Int, Int
|
||||||
|
scriptFunction(funcSetPrintPos){
|
||||||
|
if (vars[0].integerType > 78 || vars[0].integerType < 0 || vars[1].integerType > 42 || vars[1].integerType < 0)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
gfx_con_setpos(vars[0].integerType * 16, vars[1].integerType * 16);
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcClearScreen){
|
||||||
|
gfx_clearscreen();
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
int validRanges[] = {
|
||||||
|
1279,
|
||||||
|
719,
|
||||||
|
1279,
|
||||||
|
719
|
||||||
|
};
|
||||||
|
|
||||||
|
// Args: Int, Int, Int, Int, Int
|
||||||
|
scriptFunction(funcDrawBox){
|
||||||
|
for (int i = 0; i < ARR_LEN(validRanges); i++){
|
||||||
|
if (vars[i].integerType > validRanges[i] || vars[i].integerType < 0)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx_box(vars[0].integerType, vars[1].integerType, vars[2].integerType, vars[3].integerType, vars[4].integerType);
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *name;
|
||||||
|
u32 color;
|
||||||
|
} ColorCombo_t;
|
||||||
|
|
||||||
|
ColorCombo_t combos[] = {
|
||||||
|
{"RED", COLOR_RED},
|
||||||
|
{"ORANGE", COLOR_ORANGE},
|
||||||
|
{"YELLOW", COLOR_YELLOW},
|
||||||
|
{"GREEN", COLOR_GREEN},
|
||||||
|
{"BLUE", COLOR_BLUE},
|
||||||
|
{"VIOLET", COLOR_VIOLET}
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 GetColor(char *color){
|
||||||
|
for (int i = 0; i < ARR_LEN(combos); i++){
|
||||||
|
if (!strcmp(combos[i].name, color)){
|
||||||
|
return combos[i].color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return COLOR_WHITE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str
|
||||||
|
scriptFunction(funcSetColor){
|
||||||
|
SETCOLOR(GetColor(vars[0].stringType), COLOR_DEFAULT);
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcPause){
|
||||||
|
return newVar(IntType, 0, hidWait()->buttons);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Int
|
||||||
|
scriptFunction(funcWait){
|
||||||
|
u32 timer = get_tmr_ms();
|
||||||
|
while (timer + vars[0].integerType > get_tmr_ms()){
|
||||||
|
gfx_printf("<Wait %d seconds> \r", (vars[0].integerType - (get_tmr_ms() - timer)) / 1000);
|
||||||
|
hidRead();
|
||||||
|
}
|
||||||
|
return NullVar;
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcGetVer){
|
||||||
|
int *arr = malloc(3 * sizeof(int));
|
||||||
|
arr[0] = LP_VER_MJ;
|
||||||
|
arr[1] = LP_VER_MN;
|
||||||
|
arr[2] = LP_VER_BF;
|
||||||
|
Vector_t res = vecFromArray(arr, 3, sizeof(int));
|
||||||
|
return newVar(IntArrayType, 1, .vectorType = res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Args: vec(str), int, (optional) vec(str)
|
||||||
|
scriptFunction(funcMakeMenu){
|
||||||
|
if (varLen == 3 && vars[2].vectorType.count != vars[0].vectorType.count)
|
||||||
|
return ErrVar(ERRSYNTAX);
|
||||||
|
|
||||||
|
Vector_t menuEntries = newVec(sizeof(MenuEntry_t), vars[0].vectorType.count);
|
||||||
|
vecDefArray(char**, names, vars[0].vectorType);
|
||||||
|
char **colors;
|
||||||
|
if (varLen == 3)
|
||||||
|
colors = vecGetArray(char**, vars[2].vectorType);
|
||||||
|
|
||||||
|
for (int i = 0; i < vars[0].vectorType.count; i++){
|
||||||
|
u32 color = COLORTORGB(((varLen == 3) ? GetColor(colors[i]) : COLOR_WHITE));
|
||||||
|
MenuEntry_t a = {.optionUnion = color, .name = names[i]};
|
||||||
|
vecAddElem(&menuEntries, a);
|
||||||
|
}
|
||||||
|
|
||||||
|
int res = newMenu(&menuEntries, vars[1].integerType, 78, 10, ENABLEB, menuEntries.count);
|
||||||
|
vecFree(menuEntries);
|
||||||
|
return varInt(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str, Str
|
||||||
|
scriptFunction(funcCombinePath){
|
||||||
|
if (varLen <= 1)
|
||||||
|
return NullVar;
|
||||||
|
|
||||||
|
for (int i = 0; i < varLen; i++){
|
||||||
|
if (vars[i].varType != StringType)
|
||||||
|
return ErrVar(ERRINVALIDTYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *res = CpyStr(vars[0].stringType);
|
||||||
|
|
||||||
|
for (int i = 1; i < varLen; i++){
|
||||||
|
char *temp = CombinePaths(res, vars[i].stringType);
|
||||||
|
free(res);
|
||||||
|
res = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return varStr(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str
|
||||||
|
scriptFunction(funcEscFolder){
|
||||||
|
return newVar(StringType, 1, .stringType = EscapeFolder(vars[0].stringType));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str, Str
|
||||||
|
scriptFunction(funcFileMove){
|
||||||
|
return varInt(f_rename(vars[0].stringType, vars[1].stringType));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str, Str
|
||||||
|
scriptFunction(funcFileCopy){
|
||||||
|
return varInt(FileCopy(vars[0].stringType, vars[1].stringType, COPY_MODE_PRINT).err);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str
|
||||||
|
scriptFunction(funcMmcConnect){
|
||||||
|
int res = 0;
|
||||||
|
if (!strcmp(vars[0].stringType, "SYSMMC"))
|
||||||
|
res = connectMMC(MMC_CONN_EMMC);
|
||||||
|
else if (!strcmp(vars[0].stringType, "EMUMMC") && emu_cfg.enabled)
|
||||||
|
res = connectMMC(MMC_CONN_EMUMMC);
|
||||||
|
else
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
return varInt(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str
|
||||||
|
scriptFunction(funcMmcMount){
|
||||||
|
if (!TConf.keysDumped)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
return varInt((mountMMCPart(vars[0].stringType).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: Str
|
||||||
|
scriptFunction(funcMkdir){
|
||||||
|
return varInt((f_mkdir(vars[0].stringType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcReadDir){
|
||||||
|
int res = 0;
|
||||||
|
Vector_t files = ReadFolder(vars[0].stringType, &res);
|
||||||
|
if (res){
|
||||||
|
clearFileVector(&files);
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
}
|
||||||
|
|
||||||
|
vecDefArray(FSEntry_t*, fsEntries, files);
|
||||||
|
|
||||||
|
Vector_t fileNames = newVec(sizeof(char*), files.count);
|
||||||
|
Vector_t fileProperties = newVec(sizeof(int), files.count);
|
||||||
|
|
||||||
|
for (int i = 0; i < files.count; i++){
|
||||||
|
vecAddElem(&fileNames, fsEntries[i].name);
|
||||||
|
int isFolder = fsEntries[i].isDir;
|
||||||
|
vecAddElem(&fileProperties, isFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
vecFree(files);
|
||||||
|
|
||||||
|
dictVectorAdd(&ctx->varDict, newDict(CpyStr("fileProperties"), (newVar(IntArrayType, 1, .vectorType = fileProperties))));
|
||||||
|
|
||||||
|
return newVar(StringArrayType, 1, .vectorType = fileNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcCopyDir){
|
||||||
|
return varInt((FolderCopy(vars[0].stringType, vars[1].stringType).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcDelDir){
|
||||||
|
return varInt((FolderDelete(vars[0].stringType).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcDelFile){
|
||||||
|
return varInt((f_unlink(vars[0].stringType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcMmcDump){
|
||||||
|
return varInt((DumpOrWriteEmmcPart(vars[0].stringType, vars[1].stringType, 0, 1).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcMmcRestore){
|
||||||
|
return varInt((DumpOrWriteEmmcPart(vars[0].stringType, vars[1].stringType, 1, vars[2].integerType).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcGetNcaType){
|
||||||
|
if (!TConf.keysDumped)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
return varInt((GetNcaType(vars[0].stringType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcSignSave){
|
||||||
|
if (!TConf.keysDumped)
|
||||||
|
return ErrVar(ERRFATALFUNCFAIL);
|
||||||
|
|
||||||
|
return varInt((saveCommit(vars[0].stringType).err));
|
||||||
|
}
|
||||||
|
|
||||||
|
scriptFunction(funcGetMs){
|
||||||
|
return varInt(get_tmr_ms());
|
||||||
|
}
|
||||||
|
|
||||||
u8 fiveInts[] = {IntType, IntType, IntType, IntType, IntType};
|
u8 fiveInts[] = {IntType, IntType, IntType, IntType, IntType};
|
||||||
u8 singleIntArray[] = { IntArrayType };
|
u8 singleIntArray[] = { IntArrayType };
|
||||||
u8 singleInt[] = { IntType };
|
u8 singleInt[] = { IntType };
|
||||||
u8 singleAny[] = { varArgs };
|
u8 singleAny[] = { varArgs };
|
||||||
|
u8 singleStr[] = { StringType };
|
||||||
|
u8 singleByteArr[] = { ByteArrayType };
|
||||||
|
u8 StrByteVec[] = { StringType, ByteArrayType};
|
||||||
|
u8 MenuArgs[] = { StringArrayType, IntType, StringArrayType};
|
||||||
|
u8 twoStrings[] = { StringType, StringType };
|
||||||
|
u8 mmcReadWrite[] = { StringType, StringType, IntType};
|
||||||
|
|
||||||
functionStruct_t scriptFunctions[] = {
|
functionStruct_t scriptFunctions[] = {
|
||||||
{"if", funcIf, 1, singleInt},
|
{"if", funcIf, 1, singleInt},
|
||||||
@@ -90,6 +416,39 @@ functionStruct_t scriptFunctions[] = {
|
|||||||
{"len", funcLen, 1, singleAny},
|
{"len", funcLen, 1, singleAny},
|
||||||
{"byte", funcMakeByteArray, 1, singleIntArray},
|
{"byte", funcMakeByteArray, 1, singleIntArray},
|
||||||
{"setPixel", funcSetPixel, 5, fiveInts},
|
{"setPixel", funcSetPixel, 5, fiveInts},
|
||||||
|
{"fileRead", funcReadFile, 1, singleStr},
|
||||||
|
{"fileWrite", funcWriteFile, 2, StrByteVec},
|
||||||
|
{"fileExists", funcFileExists, 1, singleStr},
|
||||||
|
{"bytesToStr", funcByteToStr, 1, singleByteArr},
|
||||||
|
{"return", funcReturn, 0, NULL},
|
||||||
|
{"exit", funcExit, 0, NULL},
|
||||||
|
//{"continue", funcContinue, 0, NULL},
|
||||||
|
{"printPos", funcSetPrintPos, 2, fiveInts},
|
||||||
|
{"clearscreen", funcClearScreen, 0, NULL},
|
||||||
|
{"drawBox", funcDrawBox, 5, fiveInts},
|
||||||
|
{"color", funcSetColor, 1, singleStr},
|
||||||
|
{"pause", funcPause, 0, NULL},
|
||||||
|
{"wait", funcWait, 1, singleInt},
|
||||||
|
{"version", funcGetVer, 0, NULL},
|
||||||
|
{"menu", funcMakeMenu, 2, MenuArgs}, // for the optional arg
|
||||||
|
{"menu", funcMakeMenu, 3, MenuArgs},
|
||||||
|
{"pathCombine", funcCombinePath, varArgs, NULL},
|
||||||
|
{"pathEscFolder", funcEscFolder, 1, singleStr},
|
||||||
|
{"fileMove", funcFileMove, 2, twoStrings},
|
||||||
|
{"fileCopy", funcFileCopy, 2, twoStrings},
|
||||||
|
{"fileDel", funcDelFile, 1, singleStr},
|
||||||
|
{"mmcConnect", funcMmcConnect, 1, singleStr},
|
||||||
|
{"mmcMount", funcMmcMount, 1, singleStr},
|
||||||
|
{"mkdir", funcMkdir, 1, singleStr},
|
||||||
|
{"dirRead", funcReadDir, 1, singleStr},
|
||||||
|
{"dirCopy", funcCopyDir, 2, twoStrings},
|
||||||
|
{"dirDel", funcDelDir, 1, singleStr},
|
||||||
|
{"mmcDump", funcMmcDump, 2, mmcReadWrite},
|
||||||
|
{"mmcRestore", funcMmcRestore, 3, mmcReadWrite},
|
||||||
|
{"ncaGetType", funcGetNcaType, 1, singleStr},
|
||||||
|
{"saveSign", funcSignSave, 1, singleStr},
|
||||||
|
{"timerMs", funcGetMs, 0, NULL},
|
||||||
|
// Left from old: keyboard(?)
|
||||||
};
|
};
|
||||||
|
|
||||||
Variable_t executeFunction(scriptCtx_t* ctx, char* func_name, lexarToken_t *start, u32 len) {
|
Variable_t executeFunction(scriptCtx_t* ctx, char* func_name, lexarToken_t *start, u32 len) {
|
||||||
|
|||||||
@@ -36,8 +36,6 @@ lexarTranslation_t lexarTranslations[] = {
|
|||||||
{'*', Multiply},
|
{'*', Multiply},
|
||||||
{'/', Division},
|
{'/', Division},
|
||||||
{'%', Mod},
|
{'%', Mod},
|
||||||
{'<', Smaller},
|
|
||||||
{'>', Bigger},
|
|
||||||
{'!', Not},
|
{'!', Not},
|
||||||
{':', Selector},
|
{':', Selector},
|
||||||
{')', RBracket},
|
{')', RBracket},
|
||||||
@@ -46,6 +44,8 @@ lexarTranslation_t lexarTranslations[] = {
|
|||||||
{'{', LCBracket},
|
{'{', LCBracket},
|
||||||
{'=', Equal},
|
{'=', Equal},
|
||||||
{'[', LSBracket},
|
{'[', LSBracket},
|
||||||
|
{'<', Smaller},
|
||||||
|
{'>', Bigger},
|
||||||
{'\0', 0},
|
{'\0', 0},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -102,16 +102,20 @@ Vector_t runLexar(const char* in, u32 len) {
|
|||||||
// maybe measure len between ( ) and [ ], so this doesn't have to be done during runtime?
|
// maybe measure len between ( ) and [ ], so this doesn't have to be done during runtime?
|
||||||
// We also have to support (()). maybe if '(' set indent level, then if ')' minus indent level, set len. indent level contains {u8 level, u16 token, u16 startoffset}
|
// We also have to support (()). maybe if '(' set indent level, then if ')' minus indent level, set len. indent level contains {u8 level, u16 token, u16 startoffset}
|
||||||
|
|
||||||
|
u32 lastAssignment = 0;
|
||||||
|
|
||||||
while ((in - start) < len) {
|
while ((in - start) < len) {
|
||||||
lexarToken_t* lx = vecGetArray(lexarToken_t*, vec);
|
lexarToken_t* lx = vecGetArray(lexarToken_t*, vec);
|
||||||
|
|
||||||
if ((lx[vec.count - 2].token == StrLit || lx[vec.count - 2].token == IntLit || lx[vec.count - 2].token == Variable || lx[vec.count - 2].token == RSBracket || lx[vec.count - 2].token == RBracket)
|
if ((lx[vec.count - 2].token == StrLit || lx[vec.count - 2].token == IntLit || lx[vec.count - 2].token == Variable || lx[vec.count - 2].token == RSBracket || lx[vec.count - 2].token == RBracket)
|
||||||
&& (lx[vec.count - 1].token == Variable || lx[vec.count - 1].token == LCBracket || lx[vec.count - 1].token == RCBracket)) {
|
&& (lx[vec.count - 1].token == Variable || lx[vec.count - 1].token == LCBracket || lx[vec.count - 1].token == RCBracket)) {
|
||||||
|
if (!(lx[lastAssignment].token == ArrayVariableAssignment && lx[vec.count - 1].token == Variable && lx[vec.count - 2].token == RSBracket)) {
|
||||||
lexarToken_t holder = lx[vec.count - 1];
|
lexarToken_t holder = lx[vec.count - 1];
|
||||||
lx[vec.count - 1] = makeLexarToken(EquationSeperator, 0);
|
lx[vec.count - 1] = makeLexarToken(EquationSeperator, 0);
|
||||||
vecAddElement(&vec, holder);
|
vecAddElement(&vec, holder);
|
||||||
lx = vecGetArray(lexarToken_t*, vec);
|
lx = vecGetArray(lexarToken_t*, vec);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isValidWord(*in)) {
|
if (isValidWord(*in)) {
|
||||||
char* startWord = in;
|
char* startWord = in;
|
||||||
@@ -158,6 +162,12 @@ Vector_t runLexar(const char* in, u32 len) {
|
|||||||
vecAddElement(&vec, makeLexarToken(LSBracket, 0));
|
vecAddElement(&vec, makeLexarToken(LSBracket, 0));
|
||||||
}
|
}
|
||||||
ELIFC('=') { // Do we need to keep = if the vars are assignments anyway?
|
ELIFC('=') { // Do we need to keep = if the vars are assignments anyway?
|
||||||
|
if (in[1] == '='){
|
||||||
|
vecAddElement(&vec, makeLexarToken(EqualEqual, 0));
|
||||||
|
in++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (lx[vec.count - 1].token == Variable)
|
if (lx[vec.count - 1].token == Variable)
|
||||||
lx[vec.count - 1].token = VariableAssignment;
|
lx[vec.count - 1].token = VariableAssignment;
|
||||||
|
|
||||||
@@ -170,8 +180,12 @@ Vector_t runLexar(const char* in, u32 len) {
|
|||||||
}
|
}
|
||||||
if (lx[vec.count - back].token == ArrayVariable) {
|
if (lx[vec.count - back].token == ArrayVariable) {
|
||||||
lx[vec.count - back].token = ArrayVariableAssignment;
|
lx[vec.count - back].token = ArrayVariableAssignment;
|
||||||
|
lastAssignment = vec.count - back;
|
||||||
|
in++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lastAssignment = 0;
|
||||||
}
|
}
|
||||||
ELIFC('{') {
|
ELIFC('{') {
|
||||||
if (lx[vec.count - 1].token == VariableAssignment) {
|
if (lx[vec.count - 1].token == VariableAssignment) {
|
||||||
@@ -232,6 +246,22 @@ Vector_t runLexar(const char* in, u32 len) {
|
|||||||
vecAddElement(&vec, makeLexarToken(OR, 0));
|
vecAddElement(&vec, makeLexarToken(OR, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ELIFC('>'){
|
||||||
|
if (in[1] == '>'){
|
||||||
|
vecAddElement(&vec, makeLexarToken(BitShiftRight, 0));
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vecAddElement(&vec, makeLexarToken(Bigger, 0));
|
||||||
|
}
|
||||||
|
ELIFC('<'){
|
||||||
|
if (in[1] == '<'){
|
||||||
|
vecAddElement(&vec, makeLexarToken(BitShiftLeft, 0));
|
||||||
|
in++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
vecAddElement(&vec, makeLexarToken(Smaller, 0));
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
int val = 0;
|
int val = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "../gfx/gfx.h"
|
#include "../gfx/gfx.h"
|
||||||
#include "../utils/utils.h"
|
#include "../utils/utils.h"
|
||||||
#include <mem/heap.h>
|
#include <mem/heap.h>
|
||||||
|
#include "../hid/hid.h"
|
||||||
|
|
||||||
#define scriptResultCreate(resCode, nearToken) (scriptResult_t) {resCode, nearToken, 1}
|
#define scriptResultCreate(resCode, nearToken) (scriptResult_t) {resCode, nearToken, 1}
|
||||||
#define scriptResultCreateLen(resCode, nearToken, len) (scriptResult_t) {resCode, nearToken, len}
|
#define scriptResultCreateLen(resCode, nearToken, len) (scriptResult_t) {resCode, nearToken, len}
|
||||||
@@ -77,13 +78,15 @@ scriptResult_t mainLoop(scriptCtx_t* ctx) {
|
|||||||
void printToken(lexarToken_t* token) {
|
void printToken(lexarToken_t* token) {
|
||||||
switch (token->token) {
|
switch (token->token) {
|
||||||
case Variable:
|
case Variable:
|
||||||
case VariableAssignment:
|
|
||||||
case Function:
|
|
||||||
case FunctionAssignment:
|
|
||||||
case ArrayVariable:
|
case ArrayVariable:
|
||||||
case ArrayVariableAssignment:
|
case Function:
|
||||||
gfx_printf("%s", token->text);
|
gfx_printf("%s", token->text);
|
||||||
break;
|
break;
|
||||||
|
case FunctionAssignment:
|
||||||
|
case VariableAssignment:
|
||||||
|
case ArrayVariableAssignment:
|
||||||
|
gfx_printf("%s=", token->text);
|
||||||
|
break;
|
||||||
case StrLit:
|
case StrLit:
|
||||||
//printf("%d: '%s'\n", vec.tokens[i].token, vec.tokens[i].text);
|
//printf("%d: '%s'\n", vec.tokens[i].token, vec.tokens[i].text);
|
||||||
gfx_printf("\"%s\"", token->text);
|
gfx_printf("\"%s\"", token->text);
|
||||||
@@ -99,11 +102,29 @@ void printToken(lexarToken_t* token) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *ErrorText[] = {
|
||||||
|
"Bad operator",
|
||||||
|
"Double not",
|
||||||
|
"Syntax err",
|
||||||
|
"Invalid type",
|
||||||
|
"No var",
|
||||||
|
"No func",
|
||||||
|
"Inactive indent",
|
||||||
|
"Div by 0",
|
||||||
|
"Func fail"
|
||||||
|
};
|
||||||
|
|
||||||
void printError(scriptResult_t res) {
|
void printError(scriptResult_t res) {
|
||||||
if (res.resCode) {
|
if (res.resCode) {
|
||||||
gfx_printf("Error %d found!\nNear: ", res.resCode);
|
if (res.resCode == ERRESCSCRIPT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gfx_printf("Error found! %s\nNear: ", ErrorText[res.resCode - 1]);
|
||||||
for (int i = 0; i < res.len; i++) {
|
for (int i = 0; i < res.len; i++) {
|
||||||
printToken(&res.nearToken[i]);
|
printToken(&res.nearToken[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx_printf("\nPress any key to exit");
|
||||||
|
hidWait();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,6 +38,8 @@ enum Tokens {
|
|||||||
AND,
|
AND,
|
||||||
OR,
|
OR,
|
||||||
Selector,
|
Selector,
|
||||||
|
BitShiftLeft,
|
||||||
|
BitShiftRight,
|
||||||
EquationSeperator,
|
EquationSeperator,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,7 +59,9 @@ enum Errors {
|
|||||||
ERRNOVAR,
|
ERRNOVAR,
|
||||||
ERRNOFUNC,
|
ERRNOFUNC,
|
||||||
ERRINACTIVEINDENT,
|
ERRINACTIVEINDENT,
|
||||||
ERRDIVBYZERO
|
ERRDIVBYZERO,
|
||||||
|
ERRFATALFUNCFAIL,
|
||||||
|
ERRESCSCRIPT,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Variables {
|
enum Variables {
|
||||||
@@ -130,7 +134,6 @@ typedef struct {
|
|||||||
} scriptResult_t;
|
} scriptResult_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define newDict(strName, var) (dict_t) {strName, var}
|
#define newDict(strName, var) (dict_t) {strName, var}
|
||||||
#define newVar(var, frii, value) (Variable_t) {.varType = var, .free = frii, value}
|
#define newVar(var, frii, value) (Variable_t) {.varType = var, .free = frii, value}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void freeVariable(Variable_t dv) {
|
|||||||
case StringArrayType:;
|
case StringArrayType:;
|
||||||
char** strArray = vecGetArray(char**, dv.vectorType);
|
char** strArray = vecGetArray(char**, dv.vectorType);
|
||||||
for (u32 i = 0; i < dv.vectorType.count; i++){
|
for (u32 i = 0; i < dv.vectorType.count; i++){
|
||||||
FREE(strArray[i]);
|
free(strArray[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
case IntArrayType:
|
case IntArrayType:
|
||||||
|
|||||||
@@ -125,6 +125,9 @@ ErrCode_t DumpOrWriteEmmcPart(const char *path, const char *part, u8 write, u8 f
|
|||||||
if (!sd_mount())
|
if (!sd_mount())
|
||||||
return newErrCode(TE_ERR_NO_SD);
|
return newErrCode(TE_ERR_NO_SD);
|
||||||
|
|
||||||
|
if (TConf.currentMMCConnected == MMC_CONN_None)
|
||||||
|
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
|
||||||
|
|
||||||
if (!memcmp(part, "BOOT0", 5)){
|
if (!memcmp(part, "BOOT0", 5)){
|
||||||
emummc_storage_set_mmc_partition(&emmc_storage, 1);
|
emummc_storage_set_mmc_partition(&emmc_storage, 1);
|
||||||
lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
|
||||||
|
|||||||
@@ -175,10 +175,7 @@ out:
|
|||||||
|
|
||||||
int emummc_storage_end(sdmmc_storage_t *storage)
|
int emummc_storage_end(sdmmc_storage_t *storage)
|
||||||
{
|
{
|
||||||
if (!emu_cfg.enabled || h_cfg.emummc_force_disable)
|
|
||||||
sdmmc_storage_end(storage);
|
sdmmc_storage_end(storage);
|
||||||
else
|
|
||||||
sd_end();
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ void GptMenu(u8 MMCType){
|
|||||||
DrawError(err);
|
DrawError(err);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (TConf.keysDumped){
|
||||||
if (TConf.curExplorerLoc > LOC_SD)
|
if (TConf.curExplorerLoc > LOC_SD)
|
||||||
ResetCopyParams();
|
ResetCopyParams();
|
||||||
|
|
||||||
@@ -125,6 +126,7 @@ void GptMenu(u8 MMCType){
|
|||||||
FileExplorer("bis:/");
|
FileExplorer("bis:/");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if (!sd_mount())
|
if (!sd_mount())
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ void SetKeySlots(){
|
|||||||
// Not for bis but whatever
|
// Not for bis but whatever
|
||||||
se_aes_key_set(6, dumpedKeys.header_key + 0x00, 0x10);
|
se_aes_key_set(6, dumpedKeys.header_key + 0x00, 0x10);
|
||||||
se_aes_key_set(7, dumpedKeys.header_key + 0x10, 0x10);
|
se_aes_key_set(7, dumpedKeys.header_key + 0x10, 0x10);
|
||||||
|
se_aes_key_set(8, dumpedKeys.save_mac_key, 0x10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,6 +62,9 @@ int connectMMC(u8 mmcType){
|
|||||||
}
|
}
|
||||||
|
|
||||||
ErrCode_t mountMMCPart(const char *partition){
|
ErrCode_t mountMMCPart(const char *partition){
|
||||||
|
if (TConf.currentMMCConnected == MMC_CONN_None)
|
||||||
|
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
|
||||||
|
|
||||||
unmountMMCPart();
|
unmountMMCPart();
|
||||||
|
|
||||||
emummc_storage_set_mmc_partition(&emmc_storage, 0); // why i have to do this twice beats me
|
emummc_storage_set_mmc_partition(&emmc_storage, 0); // why i have to do this twice beats me
|
||||||
|
|||||||
@@ -141,8 +141,7 @@ void EnterMainMenu(){
|
|||||||
// -- Explore --
|
// -- Explore --
|
||||||
mainMenuEntries[MainBrowseSd].hide = !sd_mounted;
|
mainMenuEntries[MainBrowseSd].hide = !sd_mounted;
|
||||||
mainMenuEntries[MainMountSd].name = (sd_mounted) ? "Unmount SD" : "Mount SD";
|
mainMenuEntries[MainMountSd].name = (sd_mounted) ? "Unmount SD" : "Mount SD";
|
||||||
mainMenuEntries[MainBrowseEmmc].hide = !TConf.keysDumped;
|
mainMenuEntries[MainBrowseEmummc].hide = (!emu_cfg.enabled || !sd_mounted);
|
||||||
mainMenuEntries[MainBrowseEmummc].hide = (!TConf.keysDumped || !emu_cfg.enabled || !sd_mounted);
|
|
||||||
|
|
||||||
// -- Tools --
|
// -- Tools --
|
||||||
mainMenuEntries[MainPartitionSd].hide = (!is_sd_inited || sd_get_card_removed());
|
mainMenuEntries[MainPartitionSd].hide = (!is_sd_inited || sd_get_card_removed());
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ char *ShowKeyboard(const char *toEdit, u8 alwaysRet){
|
|||||||
int posOnWord = 0;
|
int posOnWord = 0;
|
||||||
bool shift = 0;
|
bool shift = 0;
|
||||||
|
|
||||||
gfx_printf("* = exit | ~ = backspace | ^(left) = shift | _ = Space | + = add char\n\n");
|
gfx_printf("* = exit | ~ = backspace | ^(left) = shift | + = add char\n\n");
|
||||||
|
|
||||||
u32 x, y;
|
u32 x, y;
|
||||||
gfx_con_getpos(&x, &y);
|
gfx_con_getpos(&x, &y);
|
||||||
|
|||||||
@@ -47,9 +47,14 @@ bool vecAdd(Vector_t* v, void* elem, u32 sz)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector_t vecCopy(Vector_t* orig) {
|
Vector_t vecCopyOffset(Vector_t* orig, u32 offset) {
|
||||||
Vector_t dst = newVec(orig->elemSz, orig->count);
|
Vector_t dst = newVec(orig->elemSz, orig->count - offset);
|
||||||
memcpy(dst.data, orig->data, orig->count * orig->elemSz);
|
memcpy(dst.data, ((u8*)orig->data + orig->elemSz * offset), (orig->count - offset) * orig->elemSz);
|
||||||
dst.count = orig->count;
|
dst.count = orig->count - offset;
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector_t vecCopy(Vector_t* orig) {
|
||||||
|
return vecCopyOffset(orig, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,3 +27,4 @@ Vector_t newVec(u32 typesz, u32 preallocate);
|
|||||||
Vector_t vecFromArray(void* array, u32 count, u32 typesz);
|
Vector_t vecFromArray(void* array, u32 count, u32 typesz);
|
||||||
bool vecAdd(Vector_t* v, void* elem, u32 sz);
|
bool vecAdd(Vector_t* v, void* elem, u32 sz);
|
||||||
Vector_t vecCopy(Vector_t* orig);
|
Vector_t vecCopy(Vector_t* orig);
|
||||||
|
Vector_t vecCopyOffset(Vector_t* orig, u32 offset);
|
||||||
Reference in New Issue
Block a user