Compare commits

..

4 Commits
1.5.0 ... 1.5.1

Author SHA1 Message Date
Such Meme, Many Skill
82a4d03985 Bump version 2020-04-12 22:22:40 +02:00
Such Meme, Many Skill
195d9797fe Add that inside functions no "" are required for <=>+-/* 2020-04-12 20:31:32 +02:00
Such Meme, Many Skill
15e1210179 [script] Remove jump list & add if_check that works like if(check()) 2020-04-12 19:21:09 +02:00
Such Meme, Many Skill
e892e69929 don't hardcode locations where info should be parsed from 2020-04-08 17:33:34 +02:00
7 changed files with 65 additions and 44 deletions

View File

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

View File

@@ -25,7 +25,7 @@ void gfx_clearscreen(){
gfx_box(0, 0, 719, 15, COLOR_WHITE);
gfx_con_setpos(0, 0);
gfx_printf("Tegraexplorer v1.5.0\n");
gfx_printf("Tegraexplorer v1.5.1\n");
RESETCOLOR;
}

View File

@@ -120,12 +120,10 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
res = 0;
while (!res){
if (!res){
if (sd_inited && !!gpio_read(GPIO_PORT_Z, GPIO_PIN_1)){
gfx_errDisplay("menu", ERR_SD_EJECTED, 0);
sd_unmount();
return -1;
}
if (sd_inited && !!gpio_read(GPIO_PORT_Z, GPIO_PIN_1)){
gfx_errDisplay("menu", ERR_SD_EJECTED, 0);
sd_unmount();
return -1;
}
res = btn_read();

View File

@@ -30,7 +30,7 @@ extern short currentlyMounted;
int parseIntInput(char *in, int *out){
if (in[0] == '@'){
if (str_int_find(argv[0], out))
if (str_int_find(in, out))
return -1;
}
else
@@ -38,10 +38,10 @@ int parseIntInput(char *in, int *out){
return 0;
}
/*
int parseJmpInput(char *in, u64 *out){
if (in[0] == '?'){
if (str_jmp_find(argv[0], out))
if (str_jmp_find(in, out))
return -1;
else
return 0;
@@ -49,6 +49,7 @@ int parseJmpInput(char *in, u64 *out){
else
return -1;
}
*/
int parseStringInput(char *in, char **out){
if (in[0] == '$'){
@@ -103,6 +104,29 @@ int part_Wait(){
return 0;
}
int part_Check(){
int left, right;
if (parseIntInput(argv[0], &left))
return -1;
if (parseIntInput(argv[2], &right))
return -1;
if (!strcmp(argv[1], "=="))
return (left == right);
else if (!strcmp(argv[1], "!="))
return (left != right);
else if (!strcmp(argv[1], ">="))
return (left >= right);
else if (!strcmp(argv[1], "<="))
return (left <= right);
else if (!strcmp(argv[1], ">"))
return (left > right);
else if (!strcmp(argv[1], "<"))
return (left < right);
else
return -1;
}
int part_if(){
int condition;
if (parseIntInput(argv[0], &condition))
@@ -125,6 +149,19 @@ int part_if(){
*/
}
int part_if_args(){
int condition;
if ((condition = part_Check()) < 0)
return -1;
getfollowingchar('{');
if (!condition)
skipbrackets();
return 0;
}
int part_Math(){
int left, right;
if (parseIntInput(argv[0], &left))
@@ -145,29 +182,6 @@ int part_Math(){
return -1;
}
int part_Check(){
int left, right;
if (parseIntInput(argv[0], &left))
return -1;
if (parseIntInput(argv[2], &right))
return -1;
if (!strcmp(argv[1], "=="))
return (left == right);
else if (!strcmp(argv[1], "!="))
return (left != right);
else if (!strcmp(argv[1], ">="))
return (left >= right);
else if (!strcmp(argv[1], "<="))
return (left <= right);
else if (!strcmp(argv[1], ">"))
return (left > right);
else if (!strcmp(argv[1], "<"))
return (left < right);
else
return -1;
}
int part_SetInt(){
int out;
parseIntInput(argv[0], &out);
@@ -200,8 +214,8 @@ int part_SetStringIndex(){
}
int part_goto(){
u64 target = 0;
if (parseJmpInput(argv[0], &target))
int target = 0;
if (parseIntInput(argv[0], &target))
return -1;
f_lseek(&scriptin, target);
return 0;
@@ -510,12 +524,17 @@ int part_clearscreen(){
return 0;
}
int part_getPos(){
return (int)f_tell(&scriptin);
}
str_fnc_struct functions[] = {
{"printf", part_printf, 1},
{"printInt", part_print_int, 1},
{"setPrintPos", part_setPrintPos, 2},
{"clearscreen", part_clearscreen, 0},
{"if", part_if, 1},
{"if", part_if_args, 3}, // function overloading
{"math", part_Math, 3},
{"check", part_Check, 3},
{"setInt", part_SetInt, 1},
@@ -542,6 +561,7 @@ str_fnc_struct functions[] = {
{"mmc_mount", part_MountMMC, 1},
{"mmc_dumpPart", part_mmc_dumpPart, 2},
{"mmc_restorePart", part_mmc_restorePart, 1},
{"getPosition", part_getPos, 0},
{"pause", part_Pause, 0},
{"wait", part_Wait, 1},
{"exit", part_Exit, 0},
@@ -552,12 +572,10 @@ int run_function(char *func_name, int *out){
for (u32 i = 0; functions[i].key != NULL; i++){
if (!strcmp(functions[i].key, func_name)){
if (argc != functions[i].arg_count)
return -2;
continue;
*out = functions[i].value();
if (*out < 0)
return -1;
return 0;
return (*out < 0) ? -1 : 0;
}
}
return -1;

View File

@@ -70,7 +70,7 @@ u32 splitargs(char* in) {
}
i--;
}
else if (in[i] >= '0' && in[i] <= '9')
else if ((in[i] >= '0' && in[i] <= '9') || (in[i] >= '<' && in[i] <= '>') || in[i] == '+' || in[i] == '-' || in[i] == '*' || in[i] == '/')
argv[curcount][current++] = in[i];
else if (in[i] == '"') {
i++;
@@ -201,6 +201,7 @@ void mainparser(){
getnextvalidchar();
}
/*
if (currentchar == '?'){
char *jumpname;
jumpname = readtilchar(';', ' ');
@@ -209,6 +210,7 @@ void mainparser(){
getfollowingchar('\n');
return;
}
*/
functionparser();
@@ -301,7 +303,7 @@ void runScript(char *path){
f_close(&scriptin);
str_int_clear();
str_jmp_clear();
//str_jmp_clear();
str_str_clear();
free(path_local);
//btn_wait();

View File

@@ -17,7 +17,7 @@
static dict_str_int *str_int_table = NULL;
static dict_str_str *str_str_table = NULL;
static dict_str_loc *str_jmp_table = NULL;
//static dict_str_loc *str_jmp_table = NULL;
int str_int_add(char *key, int value){
char *key_local;
@@ -91,7 +91,7 @@ void str_int_printall(){
temp = temp->next;
}
}
/*
int str_jmp_add(char *key, u64 value){
char *key_local;
dict_str_loc *keyvaluepair;
@@ -161,6 +161,7 @@ void str_jmp_clear(){
}
str_jmp_table = NULL;
}
*/
int str_str_add(char *key, char *value){
char *key_local, *value_local;

View File

@@ -23,9 +23,11 @@ int str_int_add(char *key, int value);
int str_int_find(char *key, int *out);
void str_int_clear();
void str_int_printall();
/*
int str_jmp_add(char *key, u64 value);
int str_jmp_find(char *key, u64 *out);
void str_jmp_clear();
*/
int str_str_add(char *key, char *value);
int str_str_find(char *key, char **out);
int str_str_index(int index, char **out);