Start rewrite

- Rewrite everything
- Starting with up-to-date lockpickrcm
This commit is contained in:
Such Meme, Many Skill
2019-11-21 16:02:45 +01:00
parent e8ddc9cf2f
commit ff062a232b
95 changed files with 7043 additions and 1844 deletions

View File

@@ -0,0 +1,51 @@
#include "../gfx/gfx.h"
#include "te.h"
#include "../utils/btn.h"
#include "gfx.h"
void clearscreen(){
gfx_clear_grey(0x1B);
gfx_box(0, 0, 719, 15, COLOR_WHITE);
gfx_con_setpos(0, 0);
gfx_printf("%k%KTegraexplorer%k%K\n", COLOR_DEFAULT, COLOR_WHITE, COLOR_WHITE, COLOR_DEFAULT);
}
void message(char* message, u32 color){
clearscreen();
gfx_printf("%k%s%k", color, message, COLOR_DEFAULT);
return btn_wait();
}
int makemenu(menu_item menu[], int menuamount){
int currentpos = 1, i, res;
clearscreen();
while (1){
gfx_con_setpos(0, 31);
for (i = 0; i < menuamount; i++){
if (menu[i].property < 0) {
i--;
continue;
}
if (i == currentpos - 1)
gfx_printf("%k%K%s%K\n", COLOR_DEFAULT, COLOR_WHITE, menu[i].name, COLOR_DEFAULT);
else
gfx_printf("%k%s\n", menu[i].color, menu[i].name);
}
gfx_printf("\n%k%s", COLOR_WHITE, menuamount);
res = btn_wait();
if (res & BTN_VOL_UP)
currentpos--;
else if (res & BTN_VOL_DOWN)
currentpos++;
else if (res & BTN_POWER)
return menu[currentpos - 1].internal_function;
if (currentpos > menuamount)
currentpos = menuamount;
else if (currentpos < 1)
currentpos = 1;
}
}

View File

@@ -0,0 +1,4 @@
#pragma once
int makemenu(menu_item menu[], int menuamount);
void message(char* message, u32 color);

77
source/tegraexplorer/te.c Normal file
View File

@@ -0,0 +1,77 @@
#include <stdio.h>
#include <string.h>
#include "te.h"
#include "gfx.h"
#include "../utils/util.h"
extern bool sd_mount();
extern void sd_unmount();
menu_item mainmenu[MAINMENU_AMOUNT] = {
{"[SD:/] SD CARD", COLOR_GREEN, 1, 0},
{"[EMMC:/] ?\n", COLOR_GREEN, 2, 0},
{"Mount/Unmount SD", COLOR_WHITE, 3, 0},
{"Tools\n", COLOR_VIOLET, 4, 0},
{"Credits", COLOR_WHITE, 5, 0},
{"Exit", COLOR_WHITE, 6, 0}
};
menu_item shutdownmenu[4] = {
{"Reboot to RCM", COLOR_VIOLET, 1, 0},
{"Reboot normally", COLOR_ORANGE, 2, 0},
{"Power off\n", COLOR_BLUE, 3, 0},
{"Back", COLOR_WHITE, 4, 0}
};
int calcmenuitems(){
int amount = 0, i;
for (i = 0; i < MAINMENU_AMOUNT; i++)
if (mainmenu[i].property >= 0)
amount++;
return amount;
}
void fillmainmenu(){
int i;
for (i = 0; i < MAINMENU_AMOUNT; i++){
switch (i + 1) {
case 1:
if (sd_mount)
mainmenu[i].property = 1;
else
mainmenu[i].property = -1;
break;
case 3:
if (sd_mount)
mainmenu[i].property = 1;
else
mainmenu[i].property = -1;
break;
}
}
}
void te_main(){
int res;
while (1){
fillmainmenu();
res = makemenu(mainmenu, calcmenuitems());
if (res == 5)
message(CREDITS_MESSAGE, COLOR_GREEN);
if (res == 6){
res = makemenu(shutdownmenu, 4);
if (res == 1)
reboot_rcm();
else if (res == 2)
reboot_normal();
else if (res == 3)
power_off();
}
}
}

16
source/tegraexplorer/te.h Normal file
View File

@@ -0,0 +1,16 @@
#pragma once
#include "../utils/types.h"
#define MAINMENU_AMOUNT 6
#define CREDITS_MESSAGE "Tegraexplorer, made by:\nSuch Meme, Many Skill\n\nProject based on:\nLockpick_RCM\nHekate\n\nCool people:\nshchmue\ndennthecafebabe\nDax"
typedef struct _menu_item {
char name[50];
u32 color;
short internal_function;
short property;
} menu_item;
menu_item mainmenu[MAINMENU_AMOUNT];
void te_main();