mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 11:56:42 +00:00
Small optimizations
This commit is contained in:
parent
6681a35b2c
commit
9799e2b47e
19 changed files with 302 additions and 288 deletions
|
@ -1,7 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../utils/types.h"
|
#include "../utils/types.h"
|
||||||
|
|
||||||
#define BIT(n) (1 << n)
|
#define BIT(n) (1U << n)
|
||||||
#define KEY_A BIT(3)
|
#define KEY_A BIT(3)
|
||||||
#define KEY_B BIT(2)
|
#define KEY_B BIT(2)
|
||||||
#define KEY_Y BIT(0)
|
#define KEY_Y BIT(0)
|
||||||
|
|
|
@ -2,74 +2,74 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
menu_entry mainmenu_main[] = {
|
menu_entry mainmenu_main[] = {
|
||||||
{"[SD:/] SD CARD", COLOR_GREEN, ISMENU},
|
{"[SD:/] SD CARD", COLOR_GREEN, {ISMENU}},
|
||||||
{"[EMMC:/] EMMC", COLOR_ORANGE, ISMENU},
|
{"[EMMC:/] EMMC", COLOR_ORANGE, {ISMENU}},
|
||||||
{"[EMMC:/] EMUMMC", COLOR_BLUE, ISMENU},
|
{"[EMMC:/] EMUMMC", COLOR_BLUE, {ISMENU}},
|
||||||
{"\nMount/Unmount SD", COLOR_WHITE, ISMENU},
|
{"\nMount/Unmount SD", COLOR_WHITE, {ISMENU}},
|
||||||
{"Tools", COLOR_VIOLET, ISMENU},
|
{"Tools", COLOR_VIOLET, {ISMENU}},
|
||||||
{"SD format", COLOR_VIOLET, ISMENU},
|
{"SD format", COLOR_VIOLET, {ISMENU}},
|
||||||
{"\nCredits", COLOR_WHITE, ISMENU},
|
{"\nCredits", COLOR_WHITE, {ISMENU}},
|
||||||
{"Exit", COLOR_WHITE, ISMENU}
|
{"Exit", COLOR_WHITE, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry mainmenu_shutdown[] = {
|
menu_entry mainmenu_shutdown[] = {
|
||||||
{"Back", COLOR_WHITE, ISMENU},
|
{"Back", COLOR_WHITE, {ISMENU}},
|
||||||
{"\nReboot to RCM", COLOR_VIOLET, ISMENU},
|
{"\nReboot to RCM", COLOR_VIOLET, {ISMENU}},
|
||||||
{"Reboot normally", COLOR_ORANGE, ISMENU},
|
{"Reboot normally", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Power off\n", COLOR_BLUE, ISMENU},
|
{"Power off\n", COLOR_BLUE, {ISMENU}},
|
||||||
{"Reboot to Hekate", COLOR_GREEN, ISMENU},
|
{"Reboot to Hekate", COLOR_GREEN, {ISMENU}},
|
||||||
{"Reboot to Atmosphere", COLOR_GREEN, ISMENU}
|
{"Reboot to Atmosphere", COLOR_GREEN, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry mainmenu_tools[] = {
|
menu_entry mainmenu_tools[] = {
|
||||||
{"Back", COLOR_WHITE, ISMENU},
|
{"Back", COLOR_WHITE, {ISMENU}},
|
||||||
{"\nDisplay Console Info", COLOR_GREEN, ISMENU},
|
{"\nDisplay Console Info", COLOR_GREEN, {ISMENU}},
|
||||||
{"Display GPIO pins", COLOR_VIOLET, ISMENU},
|
{"Display GPIO pins", COLOR_VIOLET, {ISMENU}},
|
||||||
{"Dump Firmware", COLOR_BLUE, ISMENU},
|
{"Dump Firmware", COLOR_BLUE, {ISMENU}},
|
||||||
{"Dump User Saves", COLOR_YELLOW, ISMENU}
|
{"Dump User Saves", COLOR_YELLOW, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry mainmenu_format[] = {
|
menu_entry mainmenu_format[] = {
|
||||||
{"Back\n", COLOR_WHITE, ISMENU},
|
{"Back\n", COLOR_WHITE, {ISMENU}},
|
||||||
{"Format entire SD to FAT32", COLOR_RED, ISMENU},
|
{"Format entire SD to FAT32", COLOR_RED, {ISMENU}},
|
||||||
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, ISMENU}
|
{"Format for EmuMMC setup (FAT32/RAW)", COLOR_RED, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry utils_mmcChoice[] = {
|
menu_entry utils_mmcChoice[] = {
|
||||||
{"Back\n", COLOR_WHITE, ISMENU},
|
{"Back\n", COLOR_WHITE, {ISMENU}},
|
||||||
{"SysMMC", COLOR_ORANGE, ISMENU},
|
{"SysMMC", COLOR_ORANGE, {ISMENU}},
|
||||||
{"EmuMMC", COLOR_BLUE, ISMENU}
|
{"EmuMMC", COLOR_BLUE, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry fs_menu_file[] = {
|
menu_entry fs_menu_file[] = {
|
||||||
{NULL, COLOR_GREEN, ISMENU | ISSKIP},
|
{NULL, COLOR_GREEN, {ISMENU | ISSKIP}},
|
||||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||||
{"\n\n\nBack", COLOR_WHITE, ISMENU},
|
{"\n\n\nBack", COLOR_WHITE, {ISMENU}},
|
||||||
{"\nCopy to clipboard", COLOR_BLUE, ISMENU},
|
{"\nCopy to clipboard", COLOR_BLUE, {ISMENU}},
|
||||||
{"Move to clipboard", COLOR_BLUE, ISMENU},
|
{"Move to clipboard", COLOR_BLUE, {ISMENU}},
|
||||||
{"Rename file", COLOR_BLUE, ISMENU},
|
{"Rename file", COLOR_BLUE, {ISMENU}},
|
||||||
{"\nDelete file\n", COLOR_RED, ISMENU},
|
{"\nDelete file\n", COLOR_RED, {ISMENU}},
|
||||||
{"Launch Payload", COLOR_ORANGE, ISMENU},
|
{"Launch Payload", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Launch Script", COLOR_YELLOW, ISMENU},
|
{"Launch Script", COLOR_YELLOW, {ISMENU}},
|
||||||
{"View Hex", COLOR_GREEN, ISMENU},
|
{"View Hex", COLOR_GREEN, {ISMENU}},
|
||||||
{"\nExtract BIS", COLOR_YELLOW, ISMENU}
|
{"\nExtract BIS", COLOR_YELLOW, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry fs_menu_folder[] = {
|
menu_entry fs_menu_folder[] = {
|
||||||
{NULL, COLOR_VIOLET, ISMENU | ISSKIP},
|
{NULL, COLOR_VIOLET, {ISMENU | ISSKIP}},
|
||||||
{"\nBack", COLOR_WHITE, ISMENU},
|
{"\nBack", COLOR_WHITE, {ISMENU}},
|
||||||
{"Return to main menu\n", COLOR_BLUE, ISMENU},
|
{"Return to main menu\n", COLOR_BLUE, {ISMENU}},
|
||||||
{"Copy to clipboard", COLOR_VIOLET, ISMENU},
|
{"Copy to clipboard", COLOR_VIOLET, {ISMENU}},
|
||||||
{"Delete folder\n", COLOR_RED, ISMENU},
|
{"Delete folder\n", COLOR_RED, {ISMENU}},
|
||||||
{"Rename folder", COLOR_BLUE, ISMENU},
|
{"Rename folder", COLOR_BLUE, {ISMENU}},
|
||||||
{"Create folder", COLOR_BLUE, ISMENU}
|
{"Create folder", COLOR_BLUE, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry fs_menu_startdir[] = {
|
menu_entry fs_menu_startdir[] = {
|
||||||
{"Folder -> previous folder ", COLOR_ORANGE, ISMENU},
|
{"Folder -> previous folder ", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Clipboard -> Current folder", COLOR_ORANGE, ISMENU},
|
{"Clipboard -> Current folder", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Current folder menu ", COLOR_ORANGE, ISMENU}
|
{"Current folder menu ", COLOR_ORANGE, {ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
gpt_entry_rule gpt_fs_rules[] = {
|
gpt_entry_rule gpt_fs_rules[] = {
|
||||||
|
@ -81,15 +81,15 @@ gpt_entry_rule gpt_fs_rules[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry mmcmenu_start[] = {
|
menu_entry mmcmenu_start[] = {
|
||||||
{"Back", COLOR_ORANGE, ISMENU},
|
{"Back", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Dump File Partitions", COLOR_ORANGE, ISMENU},
|
{"Dump File Partitions", COLOR_ORANGE, {ISMENU}},
|
||||||
{"Clipboard -> Partition\n", COLOR_ORANGE, ISMENU},
|
{"Clipboard -> Partition\n", COLOR_ORANGE, {ISMENU}},
|
||||||
{"BOOT0/1", COLOR_BLUE, isBOOT | ISMENU}
|
{"BOOT0/1", COLOR_BLUE, {ISNULL | ISMENU}}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_entry mmcmenu_filemenu[] = {
|
menu_entry mmcmenu_filemenu[] = {
|
||||||
{"Part:", COLOR_ORANGE, ISSKIP | ISMENU},
|
{"Part:", COLOR_ORANGE, {ISSKIP | ISMENU}},
|
||||||
{NULL, COLOR_VIOLET, ISSKIP | ISMENU},
|
{NULL, COLOR_VIOLET, {ISSKIP | ISMENU}},
|
||||||
{"\nBack", COLOR_WHITE, ISMENU},
|
{"\nBack", COLOR_WHITE, {ISMENU}},
|
||||||
{"Dump to SD", COLOR_YELLOW, ISMENU}
|
{"Dump to SD", COLOR_YELLOW, {ISMENU}}
|
||||||
};
|
};
|
|
@ -1,18 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../../utils/types.h"
|
#include "../../utils/types.h"
|
||||||
|
|
||||||
#define ISDIR (1 << 0)
|
#define BIT(n) (1U << n)
|
||||||
#define ISARC (1 << 1)
|
|
||||||
|
|
||||||
#define ISHIDE (1 << 8)
|
#define ISDIR BIT(0)
|
||||||
#define ISMENU (1 << 9)
|
#define ISMENU BIT(1)
|
||||||
#define ISSKIP (1 << 10)
|
#define SETSIZE(x) (x << 2)
|
||||||
|
#define ISNULL BIT(4)
|
||||||
#define ISGB (1 << 7)
|
#define ISHIDE BIT(5)
|
||||||
#define ISMB (1 << 6)
|
#define ISSKIP BIT(6)
|
||||||
#define ISKB (1 << 5)
|
|
||||||
#define ISB (1 << 4)
|
|
||||||
#define ISNULL (1 << 3)
|
|
||||||
|
|
||||||
#define SETBIT(object, shift, value) ((value) ? (object |= shift) : (object &= ~shift))
|
#define SETBIT(object, shift, value) ((value) ? (object |= shift) : (object &= ~shift))
|
||||||
|
|
||||||
|
@ -43,7 +39,17 @@
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
u32 storage;
|
u32 storage;
|
||||||
u16 property;
|
union {
|
||||||
|
u8 property;
|
||||||
|
struct {
|
||||||
|
u8 isDir:1;
|
||||||
|
u8 isMenu:1;
|
||||||
|
u8 size:2;
|
||||||
|
u8 isNull:1;
|
||||||
|
u8 isHide:1;
|
||||||
|
u8 isSkip:1;
|
||||||
|
};
|
||||||
|
};
|
||||||
} menu_entry;
|
} menu_entry;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
#include "../../utils/list.h"
|
#include "../../utils/list.h"
|
||||||
#include "../../mem/heap.h"
|
#include "../../mem/heap.h"
|
||||||
#include "emmcmenu.h"
|
#include "emmcmenu.h"
|
||||||
#include "../fs/fsreader.h"
|
|
||||||
#include "../utils/utils.h"
|
#include "../utils/utils.h"
|
||||||
#include "../gfx/menu.h"
|
#include "../gfx/menu.h"
|
||||||
#include "../fs/fsmenu.h"
|
#include "../fs/fsmenu.h"
|
||||||
#include "emmcoperations.h"
|
#include "emmcoperations.h"
|
||||||
#include "../fs/fsutils.h"
|
#include "../fs/fsutils.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
menu_entry *mmcMenuEntries = NULL;
|
menu_entry *mmcMenuEntries = NULL;
|
||||||
extern sdmmc_storage_t storage;
|
extern sdmmc_storage_t storage;
|
||||||
|
@ -30,21 +30,18 @@ extern char *clipboard;
|
||||||
extern u8 clipboardhelper;
|
extern u8 clipboardhelper;
|
||||||
|
|
||||||
|
|
||||||
void addEntry(emmc_part_t *part, u8 property, int spot){
|
void addEntry(emmc_part_t *part, u8 property_GPT, int spot){
|
||||||
if (mmcMenuEntries[spot].name != NULL){
|
u32 storage = 0;
|
||||||
free(mmcMenuEntries[spot].name);
|
u8 property = 0;
|
||||||
}
|
|
||||||
|
|
||||||
utils_copystring(part->name, &mmcMenuEntries[spot].name);
|
if (property_GPT & isFS){
|
||||||
|
storage = (u32)(property_GPT & 0x7F);
|
||||||
if (property & isFS){
|
property = ISDIR;
|
||||||
mmcMenuEntries[spot].storage = (u32)(property & 0x7F);
|
|
||||||
mmcMenuEntries[spot].property = ISDIR;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
u64 size = 0;
|
u64 size = 0;
|
||||||
int sizes = 0;
|
u32 sizes = 0;
|
||||||
mmcMenuEntries[spot].property = 0;
|
|
||||||
size = (u64)(part->lba_end + 1 - part->lba_start);
|
size = (u64)(part->lba_end + 1 - part->lba_start);
|
||||||
size *= (u64)NX_EMMC_BLOCKSIZE;
|
size *= (u64)NX_EMMC_BLOCKSIZE;
|
||||||
|
|
||||||
|
@ -54,31 +51,30 @@ void addEntry(emmc_part_t *part, u8 property, int spot){
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizes > 3)
|
if (sizes > 3)
|
||||||
sizes = 0;
|
sizes = 3;
|
||||||
|
|
||||||
mmcMenuEntries[spot].property |= (1 << (4 + sizes));
|
property |= SETSIZE(sizes);
|
||||||
mmcMenuEntries[spot].storage = (u32)size;
|
storage = (u32)size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mu_copySingle(part->name, storage, property, &mmcMenuEntries[spot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fillMmcMenu(short mmcType){
|
int fillMmcMenu(short mmcType){
|
||||||
int count = 4, i;
|
int count = 4, i;
|
||||||
|
|
||||||
if (mmcMenuEntries != NULL)
|
if (mmcMenuEntries != NULL)
|
||||||
clearfileobjects(&mmcMenuEntries);
|
mu_clearObjects(&mmcMenuEntries);
|
||||||
|
|
||||||
link_t *gpt = selectGpt(mmcType);
|
link_t *gpt = selectGpt(mmcType);
|
||||||
|
|
||||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link)
|
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
createfileobjects(count, &mmcMenuEntries);
|
mu_createObjects(count, &mmcMenuEntries);
|
||||||
|
|
||||||
for (i = 0; i < 4; i++){
|
for (i = 0; i < 4; i++)
|
||||||
utils_copystring(mmcmenu_start[i].name, &mmcMenuEntries[i].name);
|
mu_copySingle(mmcmenu_start[i].name, mmcmenu_start[i].storage, mmcmenu_start[i].property, &mmcMenuEntries[i]);
|
||||||
mmcMenuEntries[i].property = mmcmenu_start[i].property;
|
|
||||||
mmcMenuEntries[i].storage = mmcmenu_start[i].storage;
|
|
||||||
}
|
|
||||||
|
|
||||||
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link){
|
LIST_FOREACH_ENTRY(emmc_part_t, part, gpt, link){
|
||||||
addEntry(part, checkGptRules(part->name), i++);
|
addEntry(part, checkGptRules(part->name), i++);
|
||||||
|
@ -99,10 +95,14 @@ int handleEntries(short mmcType, menu_entry part){
|
||||||
fileexplorer("emmc:/", 1);
|
fileexplorer("emmc:/", 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
/*
|
||||||
if (mmcmenu_filemenu[1].name != NULL)
|
if (mmcmenu_filemenu[1].name != NULL)
|
||||||
free(mmcmenu_filemenu[1].name);
|
free(mmcmenu_filemenu[1].name);
|
||||||
|
|
||||||
utils_copystring(part.name, &mmcmenu_filemenu[1].name);
|
utils_copystring(part.name, &mmcmenu_filemenu[1].name);
|
||||||
|
*/
|
||||||
|
|
||||||
|
mu_copySingle(part.name, mmcmenu_filemenu[1].storage, mmcmenu_filemenu[1].property, &mmcmenu_filemenu[1]);
|
||||||
|
|
||||||
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3)
|
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -112,7 +112,7 @@ int handleEntries(short mmcType, menu_entry part){
|
||||||
|
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
|
|
||||||
if (part.property & isBOOT){
|
if (part.isNull){
|
||||||
res = emmcDumpBoot("sd:/tegraexplorer/partition_dumps");
|
res = emmcDumpBoot("sd:/tegraexplorer/partition_dumps");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -146,7 +146,7 @@ int makeMmcMenu(short mmcType){
|
||||||
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
||||||
|
|
||||||
for (int i = 0; i < count; i++){
|
for (int i = 0; i < count; i++){
|
||||||
if (mmcMenuEntries[i].property & ISMENU || mmcMenuEntries[i].property & ISDIR)
|
if (mmcMenuEntries[i].property & (ISMENU | ISDIR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//gfx_printf("Dumping %s...\n", mmcMenuEntries[i].name);
|
//gfx_printf("Dumping %s...\n", mmcMenuEntries[i].name);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "../script/parser.h"
|
#include "../script/parser.h"
|
||||||
#include "../emmc/emmcoperations.h"
|
#include "../emmc/emmcoperations.h"
|
||||||
#include "../../hid/hid.h"
|
#include "../../hid/hid.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
extern char *currentpath;
|
extern char *currentpath;
|
||||||
extern char *clipboard;
|
extern char *clipboard;
|
||||||
|
@ -120,38 +121,42 @@ void copyfile(const char *src_in, const char *outfolder){
|
||||||
|
|
||||||
int filemenu(menu_entry file){
|
int filemenu(menu_entry file){
|
||||||
int temp;
|
int temp;
|
||||||
FILINFO attribs;
|
char *tempchar;
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
/*
|
||||||
|
for (int i = 0; i < 2; i++)
|
||||||
if (fs_menu_file[i].name != NULL)
|
if (fs_menu_file[i].name != NULL)
|
||||||
free(fs_menu_file[i].name);
|
free(fs_menu_file[i].name);
|
||||||
|
|
||||||
utils_copystring(file.name, &fs_menu_file[0].name);
|
utils_copystring(file.name, &fs_menu_file[0].name);
|
||||||
|
*/
|
||||||
|
mu_copySingle(file.name, fs_menu_file[0].storage, fs_menu_file[0].property, &fs_menu_file[0]);
|
||||||
|
|
||||||
|
|
||||||
|
if (fs_menu_file[1].name != NULL)
|
||||||
|
free(fs_menu_file[1].name);
|
||||||
|
|
||||||
fs_menu_file[1].name = malloc(16);
|
fs_menu_file[1].name = malloc(16);
|
||||||
fs_menu_file[2].name = malloc(16);
|
sprintf(fs_menu_file[1].name, "\nSize: %d %s", file.storage, gfx_file_size_names[file.size]);
|
||||||
|
|
||||||
for (temp = 4; temp < 8; temp++)
|
|
||||||
if ((file.property & (1 << temp)))
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
if ((tempchar = fsutil_formatFileAttribs(fsutil_getnextloc(currentpath, file.name))) == NULL)
|
||||||
sprintf(fs_menu_file[1].name, "\nSize: %d %s", file.storage, gfx_file_size_names[temp - 4]);
|
fs_menu_file[2].isHide = 1;
|
||||||
|
|
||||||
if (f_stat(fsutil_getnextloc(currentpath, file.name), &attribs))
|
|
||||||
SETBIT(fs_menu_file[2].property, ISHIDE, 1);
|
|
||||||
else {
|
else {
|
||||||
SETBIT(fs_menu_file[2].property, ISHIDE, 0);
|
fs_menu_file[2].isHide = 0;
|
||||||
sprintf(fs_menu_file[2].name, "Attribs: %c%c%c%c",
|
mu_copySingle(tempchar, fs_menu_file[2].storage, fs_menu_file[2].property, &fs_menu_file[2]);
|
||||||
(attribs.fattrib & AM_RDO) ? 'R' : '-',
|
|
||||||
(attribs.fattrib & AM_SYS) ? 'S' : '-',
|
|
||||||
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
|
||||||
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs_menu_file[6].isHide = !hidConnected();
|
||||||
|
fs_menu_file[8].isHide = (!(strstr(file.name, ".bin") != NULL && file.size == 1) && strstr(file.name, ".rom") == NULL);
|
||||||
|
fs_menu_file[9].isHide = (strstr(file.name, ".te") == NULL);
|
||||||
|
fs_menu_file[11].isHide = (strstr(file.name, ".bis") == NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
SETBIT(fs_menu_file[6].property, ISHIDE, !hidConnected());
|
SETBIT(fs_menu_file[6].property, ISHIDE, !hidConnected());
|
||||||
SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.property & ISKB) && strstr(file.name, ".rom") == NULL);
|
SETBIT(fs_menu_file[8].property, ISHIDE, !(strstr(file.name, ".bin") != NULL && file.size == 1) && strstr(file.name, ".rom") == NULL);
|
||||||
SETBIT(fs_menu_file[9].property, ISHIDE, strstr(file.name, ".te") == NULL);
|
SETBIT(fs_menu_file[9].property, ISHIDE, strstr(file.name, ".te") == NULL);
|
||||||
SETBIT(fs_menu_file[11].property, ISHIDE, strstr(file.name, ".bis") == NULL);
|
SETBIT(fs_menu_file[11].property, ISHIDE, strstr(file.name, ".bis") == NULL);
|
||||||
|
*/
|
||||||
|
|
||||||
temp = menu_make(fs_menu_file, 12, "-- File Menu --");
|
temp = menu_make(fs_menu_file, 12, "-- File Menu --");
|
||||||
switch (temp){
|
switch (temp){
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "../../utils/sprintf.h"
|
#include "../../utils/sprintf.h"
|
||||||
#include "../utils/utils.h"
|
#include "../utils/utils.h"
|
||||||
#include "../../hid/hid.h"
|
#include "../../hid/hid.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
extern char *currentpath;
|
extern char *currentpath;
|
||||||
extern char *clipboard;
|
extern char *clipboard;
|
||||||
|
@ -42,21 +43,23 @@ void copyfolder(char *in, char *out){
|
||||||
int foldermenu(){
|
int foldermenu(){
|
||||||
int res, hidConn;
|
int res, hidConn;
|
||||||
char *name;
|
char *name;
|
||||||
FILINFO attribs;
|
|
||||||
|
|
||||||
if (fs_menu_folder[0].name != NULL)
|
|
||||||
free(fs_menu_folder[0].name);
|
|
||||||
|
|
||||||
fs_menu_folder[0].name = malloc(16);
|
|
||||||
|
|
||||||
hidConn = hidConnected();
|
hidConn = hidConnected();
|
||||||
|
|
||||||
res = strlen(currentpath);
|
res = strlen(currentpath);
|
||||||
|
|
||||||
|
fs_menu_folder[3].isHide = (*(currentpath + res - 1) == '/');
|
||||||
|
fs_menu_folder[4].isHide = (*(currentpath + res - 1) == '/');
|
||||||
|
fs_menu_folder[5].isHide = (*(currentpath + res - 1) == '/' || !hidConn);
|
||||||
|
fs_menu_folder[6].isHide = !hidConn;
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
SETBIT(fs_menu_folder[3].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
SETBIT(fs_menu_folder[3].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
||||||
SETBIT(fs_menu_folder[4].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
SETBIT(fs_menu_folder[4].property, ISHIDE, (*(currentpath + res - 1) == '/'));
|
||||||
SETBIT(fs_menu_folder[5].property, ISHIDE, (*(currentpath + res - 1) == '/') || !hidConn);
|
SETBIT(fs_menu_folder[5].property, ISHIDE, (*(currentpath + res - 1) == '/') || !hidConn);
|
||||||
SETBIT(fs_menu_folder[6].property, ISHIDE, !hidConn);
|
SETBIT(fs_menu_folder[6].property, ISHIDE, !hidConn);
|
||||||
|
|
||||||
if (f_stat(currentpath, &attribs))
|
if (f_stat(currentpath, &attribs))
|
||||||
SETBIT(fs_menu_folder[0].property, ISHIDE, 1);
|
SETBIT(fs_menu_folder[0].property, ISHIDE, 1);
|
||||||
else {
|
else {
|
||||||
|
@ -67,6 +70,17 @@ int foldermenu(){
|
||||||
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
||||||
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ((name = fsutil_formatFileAttribs(currentpath)) == NULL){
|
||||||
|
fs_menu_folder[0].isHide = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fs_menu_folder[0].isHide = 0;
|
||||||
|
mu_copySingle(name, fs_menu_folder[0].storage, fs_menu_folder[0].property, &fs_menu_folder[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
res = menu_make(fs_menu_folder, 7, currentpath);
|
res = menu_make(fs_menu_folder, 7, currentpath);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../common/common.h"
|
#include "../common/common.h"
|
||||||
#include "../../libs/fatfs/ff.h"
|
#include "../../libs/fatfs/ff.h"
|
||||||
#include "entrymenu.h"
|
#include "entrymenu.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
extern char *currentpath;
|
extern char *currentpath;
|
||||||
extern char *clipboard;
|
extern char *clipboard;
|
||||||
|
@ -35,7 +36,7 @@ void fileexplorer(const char *startpath, int type){
|
||||||
*/
|
*/
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
res = menu_make(fsreader_files, fsutil_getfileobjamount(fsreader_files), currentpath);
|
res = menu_make(fsreader_files, mu_countObjects(fsreader_files, 0), currentpath);
|
||||||
switch (res){
|
switch (res){
|
||||||
case FILEMENU_RETURN:
|
case FILEMENU_RETURN:
|
||||||
if (!strcmp(startpath, currentpath))
|
if (!strcmp(startpath, currentpath))
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "../gfx/gfxutils.h"
|
#include "../gfx/gfxutils.h"
|
||||||
#include "../utils/utils.h"
|
#include "../utils/utils.h"
|
||||||
#include "../../mem/heap.h"
|
#include "../../mem/heap.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
menu_entry *fsreader_files = NULL;
|
menu_entry *fsreader_files = NULL;
|
||||||
char *currentpath = NULL;
|
char *currentpath = NULL;
|
||||||
|
@ -29,59 +30,16 @@ void fsreader_writeclipboard(const char *in, u8 args){
|
||||||
utils_copystring(in, &clipboard);
|
utils_copystring(in, &clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearfileobjects(menu_entry **menu){
|
|
||||||
if ((*menu) != NULL){
|
|
||||||
for (int i = 0; (*menu)[i].name != NULL; i++){
|
|
||||||
free((*menu)[i].name);
|
|
||||||
(*menu)[i].name = NULL;
|
|
||||||
}
|
|
||||||
free((*menu));
|
|
||||||
(*menu) = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void createfileobjects(int size, menu_entry **menu){
|
|
||||||
(*menu) = calloc (size + 1, sizeof(menu_entry));
|
|
||||||
(*menu)[size].name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void addobject(char* name, int spot, u8 attribs){
|
void addobject(char* name, int spot, u8 attribs){
|
||||||
/*
|
u8 property = 0;
|
||||||
u64 size = 0;
|
|
||||||
int sizes = 0;
|
|
||||||
*/
|
|
||||||
fsreader_files[spot].property = 0;
|
|
||||||
|
|
||||||
if (fsreader_files[spot].name != NULL){
|
|
||||||
free(fsreader_files[spot].name);
|
|
||||||
fsreader_files[spot].name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
utils_copystring(name, &(fsreader_files[spot].name));
|
|
||||||
|
|
||||||
if (attribs & AM_DIR)
|
if (attribs & AM_DIR)
|
||||||
fsreader_files[spot].property |= (ISDIR);
|
property |= ISDIR;
|
||||||
else {
|
else
|
||||||
/*
|
property |= ISNULL;
|
||||||
size = fsutil_getfilesize(fsutil_getnextloc(currentpath, name));
|
|
||||||
|
|
||||||
while (size > 1024){
|
|
||||||
size /= 1024;
|
|
||||||
sizes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sizes > 3)
|
mu_copySingle(name, 0, property, &fsreader_files[spot]);
|
||||||
sizes = 0;
|
|
||||||
|
|
||||||
fsreader_files[spot].property |= (1 << (4 + sizes));
|
|
||||||
fsreader_files[spot].storage = size;
|
|
||||||
*/
|
|
||||||
fsreader_files[spot].storage = 0;
|
|
||||||
fsreader_files[spot].property = ISNULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attribs & AM_ARC)
|
|
||||||
fsreader_files[spot].property |= (ISARC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int fsreader_readfolder(const char *path){
|
int fsreader_readfolder(const char *path){
|
||||||
|
@ -89,14 +47,13 @@ int fsreader_readfolder(const char *path){
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
int folderamount, res;
|
int folderamount, res;
|
||||||
|
|
||||||
clearfileobjects(&fsreader_files);
|
mu_clearObjects(&fsreader_files);
|
||||||
createfileobjects(fsutil_getfolderentryamount(path) + 3, &fsreader_files);
|
mu_createObjects(fsutil_getfolderentryamount(path) + 3, &fsreader_files);
|
||||||
|
|
||||||
for (folderamount = 0; folderamount < 3; folderamount++){
|
|
||||||
utils_copystring(fs_menu_startdir[folderamount].name, &(fsreader_files[folderamount].name));
|
|
||||||
fsreader_files[folderamount].storage = fs_menu_startdir[folderamount].storage;
|
for (folderamount = 0; folderamount < 3; folderamount++)
|
||||||
fsreader_files[folderamount].property = fs_menu_startdir[folderamount].property;
|
mu_copySingle(fs_menu_startdir[folderamount].name, fs_menu_startdir[folderamount].storage, fs_menu_startdir[folderamount].property, &fsreader_files[folderamount]);
|
||||||
}
|
|
||||||
|
|
||||||
if ((res = f_opendir(&dir, path))){
|
if ((res = f_opendir(&dir, path))){
|
||||||
gfx_errDisplay("readfolder", res, 0);
|
gfx_errDisplay("readfolder", res, 0);
|
||||||
|
|
|
@ -47,15 +47,6 @@ char *fsutil_getprevloc(char *current){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fsutil_getfileobjamount(menu_entry *entries){
|
|
||||||
int amount = 0;
|
|
||||||
|
|
||||||
while (entries[amount].name != NULL)
|
|
||||||
amount++;
|
|
||||||
|
|
||||||
return amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool fsutil_checkfile(char* path){
|
bool fsutil_checkfile(char* path){
|
||||||
FRESULT fr;
|
FRESULT fr;
|
||||||
FILINFO fno;
|
FILINFO fno;
|
||||||
|
@ -87,4 +78,21 @@ int fsutil_getfolderentryamount(const char *path){
|
||||||
|
|
||||||
f_closedir(&dir);
|
f_closedir(&dir);
|
||||||
return folderamount;
|
return folderamount;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *fsutil_formatFileAttribs(char *path){
|
||||||
|
FILINFO attribs;
|
||||||
|
char *out;
|
||||||
|
out = malloc(16);
|
||||||
|
|
||||||
|
if (f_stat(path, &attribs))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
sprintf(out, "Attribs: %c%c%c%c",
|
||||||
|
(attribs.fattrib & AM_RDO) ? 'R' : '-',
|
||||||
|
(attribs.fattrib & AM_SYS) ? 'S' : '-',
|
||||||
|
(attribs.fattrib & AM_HID) ? 'H' : '-',
|
||||||
|
(attribs.fattrib & AM_ARC) ? 'A' : '-');
|
||||||
|
|
||||||
|
return out;
|
||||||
}
|
}
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
char *fsutil_getnextloc(const char *current, const char *add);
|
char *fsutil_getnextloc(const char *current, const char *add);
|
||||||
char *fsutil_getprevloc(char *current);
|
char *fsutil_getprevloc(char *current);
|
||||||
int fsutil_getfileobjamount(menu_entry *entries);
|
|
||||||
bool fsutil_checkfile(char* path);
|
bool fsutil_checkfile(char* path);
|
||||||
u64 fsutil_getfilesize(char *path);
|
u64 fsutil_getfilesize(char *path);
|
||||||
int fsutil_getfolderentryamount(const char *path);
|
int fsutil_getfolderentryamount(const char *path);
|
||||||
int extract_bis_file(char *path, char *outfolder);
|
int extract_bis_file(char *path, char *outfolder);
|
||||||
|
char *fsutil_formatFileAttribs(char *path);
|
|
@ -41,7 +41,7 @@ u32 gfx_message(u32 color, const char* message, ...){
|
||||||
return hidWait()->buttons;
|
return hidWait()->buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 gfx_errDisplay(char *src_func, int err, int loc){
|
u32 gfx_errDisplay(const char *src_func, int err, int loc){
|
||||||
if (!printerrors)
|
if (!printerrors)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ u32 gfx_errDisplay(char *src_func, int err, int loc){
|
||||||
if (loc)
|
if (loc)
|
||||||
gfx_printf("Loc: %d\n", loc);
|
gfx_printf("Loc: %d\n", loc);
|
||||||
|
|
||||||
gfx_printf("\nPress any button to return");
|
gfx_printf("\nPress any button to return\n");
|
||||||
|
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
|
|
||||||
return hidWait()->buttons;
|
return hidWait()->buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
int gfx_makewaitmenu(const char *hiddenmessage, int timer){
|
||||||
u32 start = get_tmr_s();
|
u32 start = get_tmr_s();
|
||||||
Inputs *input = NULL;
|
Inputs *input = NULL;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ int gfx_makewaitmenu(char *hiddenmessage, int timer){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_printlength(int size, char *toprint){
|
void gfx_printlength(int size, const char *toprint){
|
||||||
char *temp;
|
char *temp;
|
||||||
temp = (char*) malloc (size + 1);
|
temp = (char*) malloc (size + 1);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ void gfx_printlength(int size, char *toprint){
|
||||||
free(temp);
|
free(temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_printandclear(char *in, int length, int endX){
|
void gfx_printandclear(const char *in, int length, int endX){
|
||||||
u32 x, y;
|
u32 x, y;
|
||||||
|
|
||||||
gfx_printlength(length, in);
|
gfx_printlength(length, in);
|
||||||
|
@ -126,12 +126,6 @@ void gfx_printandclear(char *in, int length, int endX){
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_printfilesize(int size, char *type){
|
|
||||||
SWAPCOLOR(COLOR_VIOLET);
|
|
||||||
gfx_printf("\a%4d\e%s", size, type);
|
|
||||||
RESETCOLOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
static u32 sideY = 0;
|
static u32 sideY = 0;
|
||||||
void _gfx_sideSetYAuto(){
|
void _gfx_sideSetYAuto(){
|
||||||
u32 getX, getY;
|
u32 getX, getY;
|
||||||
|
@ -147,7 +141,7 @@ u32 gfx_sideGetY(){
|
||||||
return sideY;
|
return sideY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_sideprintf(char* message, ...){
|
void gfx_sideprintf(const char* message, ...){
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, message);
|
va_start(ap, message);
|
||||||
|
|
||||||
|
@ -158,7 +152,7 @@ void gfx_sideprintf(char* message, ...){
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfx_sideprintandclear(char* message, int length){
|
void gfx_sideprintandclear(const char* message, int length){
|
||||||
gfx_con_setpos(800, sideY);
|
gfx_con_setpos(800, sideY);
|
||||||
gfx_printandclear(message, length, 1279);
|
gfx_printandclear(message, length, 1279);
|
||||||
gfx_putc('\n');
|
gfx_putc('\n');
|
||||||
|
@ -180,7 +174,7 @@ void gfx_drawScrollBar(int minView, int maxView, int count){
|
||||||
gfx_boxGrey(740, 16 + offsetSize, 755, 16 + barSize + offsetSize, 0x66);
|
gfx_boxGrey(740, 16 + offsetSize, 755, 16 + barSize + offsetSize, 0x66);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gfx_defaultWaitMenu(char *message, int time){
|
int gfx_defaultWaitMenu(const char *message, int time){
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
SWAPCOLOR(COLOR_ORANGE);
|
SWAPCOLOR(COLOR_ORANGE);
|
||||||
gfx_printf("\n%s\n\nPress B to return\n", message);
|
gfx_printf("\n%s\n\nPress B to return\n", message);
|
||||||
|
|
|
@ -4,20 +4,20 @@
|
||||||
|
|
||||||
#define SWAPCOLOR(color) gfx_printf("%k", color)
|
#define SWAPCOLOR(color) gfx_printf("%k", color)
|
||||||
#define SWAPBGCOLOR(color) gfx_printf("%K", color)
|
#define SWAPBGCOLOR(color) gfx_printf("%K", color)
|
||||||
|
#define SWAPALLCOLOR(fg, bg) gfx_printf("%k%K", fg, bg)
|
||||||
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
|
#define RESETCOLOR gfx_printf("%k%K", COLOR_WHITE, COLOR_DEFAULT)
|
||||||
|
|
||||||
void gfx_clearscreen();
|
void gfx_clearscreen();
|
||||||
u32 gfx_message(u32 color, const char* message, ...);
|
u32 gfx_message(u32 color, const char* message, ...);
|
||||||
u32 gfx_errDisplay(char *src_func, int err, int loc);
|
u32 gfx_errDisplay(const char *src_func, int err, int loc);
|
||||||
int gfx_makewaitmenu(char *hiddenmessage, int timer);
|
int gfx_makewaitmenu(const char *hiddenmessage, int timer);
|
||||||
void gfx_printlength(int size, char *toprint);
|
void gfx_printlength(int size, const char *toprint);
|
||||||
void gfx_printandclear(char *in, int length, int endX);
|
void gfx_printandclear(const char *in, int length, int endX);
|
||||||
void gfx_printfilesize(int size, char *type);
|
|
||||||
void gfx_sideSetY(u32 setY);
|
void gfx_sideSetY(u32 setY);
|
||||||
u32 gfx_sideGetY();
|
u32 gfx_sideGetY();
|
||||||
void gfx_sideprintf(char* message, ...);
|
void gfx_sideprintf(const char* message, ...);
|
||||||
void gfx_sideprintandclear(char* message, int length);
|
void gfx_sideprintandclear(const char* message, int length);
|
||||||
void gfx_drawScrollBar(int minView, int maxView, int count);
|
void gfx_drawScrollBar(int minView, int maxView, int count);
|
||||||
int gfx_defaultWaitMenu(char *message, int time);
|
int gfx_defaultWaitMenu(const char *message, int time);
|
||||||
|
|
||||||
extern int printerrors;
|
extern int printerrors;
|
|
@ -9,81 +9,59 @@
|
||||||
#include "../../soc/gpio.h"
|
#include "../../soc/gpio.h"
|
||||||
#include "../../hid/hid.h"
|
#include "../../hid/hid.h"
|
||||||
#include "../fs/fsutils.h"
|
#include "../fs/fsutils.h"
|
||||||
|
#include "../utils/menuUtils.h"
|
||||||
|
|
||||||
extern void sd_unmount();
|
extern void sd_unmount();
|
||||||
extern bool sd_inited;
|
extern bool sd_inited;
|
||||||
|
|
||||||
void _printentry(menu_entry *entry, bool highlighted, bool refresh, char *path){
|
#pragma GCC push_options
|
||||||
u64 size;
|
#pragma GCC optimize ("O2")
|
||||||
u16 sizes = 0;
|
|
||||||
u32 color = (entry->property & ISMENU) ? entry->storage : ((entry->property & ISDIR) ? COLOR_WHITE : COLOR_VIOLET);
|
|
||||||
/*
|
|
||||||
if (entry.property & ISMENU)
|
|
||||||
SWAPCOLOR(entry.storage);
|
|
||||||
else if (entry.property & ISDIR)
|
|
||||||
SWAPCOLOR(COLOR_WHITE);
|
|
||||||
else {
|
|
||||||
SWAPCOLOR(COLOR_VIOLET);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!(entry->property & ISMENU && entry->property & ISDIR)){
|
void _printentry(menu_entry *entry, bool highlighted, bool refresh, const char *path){
|
||||||
if (entry->property & ISNULL){
|
u32 color = (entry->isMenu) ? entry->storage : ((entry->isDir) ? COLOR_WHITE : COLOR_VIOLET);
|
||||||
size = fsutil_getfilesize(fsutil_getnextloc(path, entry->name));
|
|
||||||
|
|
||||||
while (size > 1024){
|
|
||||||
size /= 1024;
|
|
||||||
sizes++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sizes > 3)
|
SWAPALLCOLOR((highlighted) ? COLOR_DEFAULT : color, (highlighted) ? color : COLOR_DEFAULT);
|
||||||
sizes = 0;
|
|
||||||
|
|
||||||
entry->property |= (1 << (4 + sizes));
|
if (!(entry->isMenu))
|
||||||
entry->storage = size;
|
gfx_printf("%c ", (entry->isDir) ? 30 : 31);
|
||||||
SETBIT(entry->property, ISNULL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (sizes = 4; sizes < 8; sizes++)
|
|
||||||
if ((entry->property & (1 << sizes)))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (highlighted){
|
|
||||||
SWAPBGCOLOR(COLOR_WHITE);
|
|
||||||
if ((entry.property & ISMENU) ? entry.storage == COLOR_WHITE : entry.property & ISDIR)
|
|
||||||
SWAPCOLOR(COLOR_DEFAULT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
SWAPBGCOLOR(COLOR_DEFAULT);
|
|
||||||
*/
|
|
||||||
SWAPCOLOR((highlighted) ? COLOR_DEFAULT : color);
|
|
||||||
SWAPBGCOLOR((highlighted) ? color : COLOR_DEFAULT);
|
|
||||||
|
|
||||||
if (!(entry->property & ISMENU))
|
|
||||||
gfx_printf("%c ", (entry->property & ISDIR) ? 30 : 31);
|
|
||||||
|
|
||||||
if (refresh)
|
if (refresh)
|
||||||
gfx_printandclear(entry->name, 37, 720);
|
gfx_printandclear(entry->name, 37, 720);
|
||||||
else
|
else
|
||||||
gfx_printlength(37, entry->name);
|
gfx_printlength(37, entry->name);
|
||||||
|
|
||||||
if (entry->property & ISDIR || entry->property & ISMENU)
|
if (entry->property & (ISMENU | ISDIR))
|
||||||
gfx_printf("\n");
|
gfx_printf("\n");
|
||||||
else {
|
else {
|
||||||
SWAPCOLOR(COLOR_BLUE);
|
if (entry->isNull){
|
||||||
SWAPBGCOLOR(COLOR_DEFAULT);
|
u64 totalSize;
|
||||||
|
u32 sizeType = 0;
|
||||||
|
totalSize = fsutil_getfilesize(fsutil_getnextloc(path, entry->name));
|
||||||
|
|
||||||
|
while (totalSize > 1024){
|
||||||
|
totalSize /= 1024;
|
||||||
|
sizeType++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sizeType > 3)
|
||||||
|
sizeType = 3;
|
||||||
|
|
||||||
|
entry->size = sizeType;
|
||||||
|
entry->storage = totalSize;
|
||||||
|
SETBIT(entry->property, ISNULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWAPALLCOLOR(COLOR_BLUE, COLOR_DEFAULT);
|
||||||
gfx_printf("\a%4d", entry->storage);
|
gfx_printf("\a%4d", entry->storage);
|
||||||
gfx_con.fntsz = 8;
|
gfx_con.fntsz = 8;
|
||||||
gfx_printf("\n\e%s\n", gfx_file_size_names[sizes - 4]);
|
gfx_printf("\n\e%s\n", gfx_file_size_names[entry->size]);
|
||||||
gfx_con.fntsz = 16;
|
gfx_con.fntsz = 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool disableB = false;
|
bool disableB = false;
|
||||||
int menu_make(menu_entry *entries, int amount, char *toptext){
|
int menu_make(menu_entry *entries, int amount, const char *toptext){
|
||||||
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 39, calculatedamount = 0;
|
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 39, calculatedamount = 0;
|
||||||
u32 scrolltimer, timer, sideY;
|
u32 scrolltimer, timer, sideY;
|
||||||
bool refresh = true;
|
bool refresh = true;
|
||||||
|
@ -92,23 +70,9 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||||
|
|
||||||
gfx_clearscreen();
|
gfx_clearscreen();
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++)
|
calculatedamount = mu_countObjects(entries, ISMENU);
|
||||||
if (!(entries[i].property & ISMENU))
|
|
||||||
calculatedamount++;
|
|
||||||
|
|
||||||
gfx_con_setpos(0, 16);
|
gfx_con_setpos(0, 16);
|
||||||
/*
|
|
||||||
if (calculatedamount){
|
|
||||||
SWAPCOLOR(COLOR_DEFAULT);
|
|
||||||
SWAPBGCOLOR(COLOR_WHITE);
|
|
||||||
gfx_printf("%3d entries\n", calculatedamount);
|
|
||||||
RESETCOLOR;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
gfx_printf("\n");
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SWAPCOLOR(COLOR_GREEN);
|
SWAPCOLOR(COLOR_GREEN);
|
||||||
gfx_printlength(42, toptext);
|
gfx_printlength(42, toptext);
|
||||||
|
@ -162,7 +126,7 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||||
|
|
||||||
if (refresh || currentfolder == NULL || !calculatedamount){
|
if (refresh || currentfolder == NULL || !calculatedamount){
|
||||||
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
|
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
|
||||||
if (!(entries[i].property & ISHIDE))
|
if (!(entries[i].isHide))
|
||||||
_printentry(&entries[i], (i == currentpos), refresh, toptext);
|
_printentry(&entries[i], (i == currentpos), refresh, toptext);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -182,12 +146,12 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
|
|
||||||
sideY = gfx_sideGetY();
|
sideY = gfx_sideGetY();
|
||||||
if (!(entries[currentpos].property & ISMENU)){
|
if (!(entries[currentpos].isMenu)){
|
||||||
gfx_sideprintf("Current selection:\n");
|
gfx_sideprintf("Current selection:\n");
|
||||||
SWAPCOLOR(COLOR_YELLOW);
|
SWAPCOLOR(COLOR_YELLOW);
|
||||||
gfx_sideprintandclear(entries[currentpos].name, 28);
|
gfx_sideprintandclear(entries[currentpos].name, 28);
|
||||||
RESETCOLOR;
|
RESETCOLOR;
|
||||||
gfx_sideprintf("Type: %s", (entries[currentpos].property & ISDIR) ? "Dir " : "File");
|
gfx_sideprintf("Type: %s", (entries[currentpos].isDir) ? "Dir " : "File");
|
||||||
gfx_sideSetY(sideY);
|
gfx_sideSetY(sideY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -256,4 +220,6 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
|
||||||
minerva_periodic_training();
|
minerva_periodic_training();
|
||||||
//return (mode) ? currentpos : entries[currentpos].property;
|
//return (mode) ? currentpos : entries[currentpos].property;
|
||||||
return currentpos;
|
return currentpos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC pop_options
|
|
@ -1,4 +1,4 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../common/types.h"
|
#include "../common/types.h"
|
||||||
|
|
||||||
int menu_make(menu_entry *entries, int amount, char *toptext);
|
int menu_make(menu_entry *entries, int amount, const char *toptext);
|
|
@ -114,7 +114,7 @@ void MainMenu_Exit(){
|
||||||
}
|
}
|
||||||
|
|
||||||
res = menu_make(mainmenu_shutdown, 6, "-- Shutdown Menu --");
|
res = menu_make(mainmenu_shutdown, 6, "-- Shutdown Menu --");
|
||||||
|
|
||||||
switch(res){
|
switch(res){
|
||||||
case SHUTDOWN_REBOOT_RCM:
|
case SHUTDOWN_REBOOT_RCM:
|
||||||
reboot_rcm();
|
reboot_rcm();
|
||||||
|
@ -131,6 +131,7 @@ void MainMenu_Exit(){
|
||||||
case SHUTDOWN_AMS:
|
case SHUTDOWN_AMS:
|
||||||
launch_payload("/atmosphere/reboot_payload.bin");
|
launch_payload("/atmosphere/reboot_payload.bin");
|
||||||
} //todo declock bpmp
|
} //todo declock bpmp
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func_void_ptr mainmenu_functions[] = {
|
func_void_ptr mainmenu_functions[] = {
|
||||||
|
@ -153,27 +154,31 @@ void RunMenuOption(int option){
|
||||||
void te_main(){
|
void te_main(){
|
||||||
int setter;
|
int setter;
|
||||||
|
|
||||||
|
//gfx_printf("Initing controller\n");
|
||||||
|
hidInit();
|
||||||
|
|
||||||
|
//gfx_printf("Getting biskeys\n");
|
||||||
if (dump_biskeys() == -1){
|
if (dump_biskeys() == -1){
|
||||||
gfx_errDisplay("dump_biskey", ERR_BISKEY_DUMP_FAILED, 0);
|
gfx_errDisplay("dump_biskey", ERR_BISKEY_DUMP_FAILED, 0);
|
||||||
//mainmenu_main[1].property |= ISHIDE;
|
//mainmenu_main[1].property |= ISHIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
//gfx_message(COLOR_ORANGE, "%d %d %d", sd_mount(), sd_mounted, sd_inited);
|
//gfx_printf("Mounting SD\n");
|
||||||
sd_mount();
|
sd_mount();
|
||||||
|
|
||||||
|
//gfx_printf("Loading possible EMU\n");
|
||||||
if (emummc_load_cfg()){
|
if (emummc_load_cfg()){
|
||||||
mainmenu_main[2].property |= ISHIDE;
|
mainmenu_main[2].property |= ISHIDE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//gfx_printf("Dumping gpt\n");
|
||||||
dumpGpt();
|
dumpGpt();
|
||||||
|
|
||||||
|
//gfx_printf("Disconnecting EMMC\n");
|
||||||
disconnect_mmc();
|
disconnect_mmc();
|
||||||
|
|
||||||
hidInit();
|
//gfx_printf("Entering main menu\n");
|
||||||
|
|
||||||
while (1){
|
while (1){
|
||||||
//fillmainmenu();
|
|
||||||
|
|
||||||
setter = sd_mounted;
|
setter = sd_mounted;
|
||||||
|
|
||||||
if (emu_cfg.enabled){
|
if (emu_cfg.enabled){
|
||||||
|
|
|
@ -64,6 +64,9 @@ int parseStringInput(char *in, char **out){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma GCC push_options
|
||||||
|
#pragma GCC optimize ("Os")
|
||||||
|
|
||||||
u32 currentcolor = COLOR_WHITE;
|
u32 currentcolor = COLOR_WHITE;
|
||||||
int part_printf(){
|
int part_printf(){
|
||||||
SWAPCOLOR(currentcolor);
|
SWAPCOLOR(currentcolor);
|
||||||
|
@ -584,6 +587,8 @@ str_fnc_struct functions[] = {
|
||||||
{NULL, NULL, 0}
|
{NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#pragma GCC pop_options
|
||||||
|
|
||||||
int run_function(char *func_name, int *out){
|
int run_function(char *func_name, int *out){
|
||||||
for (u32 i = 0; functions[i].key != NULL; i++){
|
for (u32 i = 0; functions[i].key != NULL; i++){
|
||||||
if (!strcmp(functions[i].key, func_name)){
|
if (!strcmp(functions[i].key, func_name)){
|
||||||
|
|
|
@ -64,13 +64,14 @@ u32 splitargs(char* in) {
|
||||||
curcount++;
|
curcount++;
|
||||||
current = 0;
|
current = 0;
|
||||||
}
|
}
|
||||||
else if (in[i] == '@' || in[i] == '$' || in[i] == '?') {
|
else if (in[i] == '@' || in[i] == '$') {
|
||||||
while (in[i] != ',' && in[i] != ' ' && in[i] != ')' && i < len) {
|
while (strrchr(", )", in[i]) == NULL && i < len) {
|
||||||
argv[curcount][current++] = in[i++];
|
argv[curcount][current++] = in[i++];
|
||||||
}
|
}
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
else if ((in[i] >= '0' && in[i] <= '9') || (in[i] >= '<' && in[i] <= '>') || in[i] == '+' || in[i] == '-' || in[i] == '*' || in[i] == '/')
|
//else if ((in[i] >= '0' && in[i] <= '9') || (in[i] >= '<' && in[i] <= '>') || in[i] == '+' || in[i] == '-' || in[i] == '*' || in[i] == '/')
|
||||||
|
else if (strrchr("0123456789<=>+-*/", in[i]) != NULL)
|
||||||
argv[curcount][current++] = in[i];
|
argv[curcount][current++] = in[i];
|
||||||
else if (in[i] == '"') {
|
else if (in[i] == '"') {
|
||||||
i++;
|
i++;
|
||||||
|
|
44
source/tegraexplorer/utils/menuUtils.c
Normal file
44
source/tegraexplorer/utils/menuUtils.c
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include "menuUtils.h"
|
||||||
|
#include "../../utils/types.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
#include "../../mem/heap.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
void mu_clearObjects(menu_entry **menu){
|
||||||
|
if ((*menu) != NULL){
|
||||||
|
for (int i = 0; (*menu)[i].name != NULL; i++){
|
||||||
|
free((*menu)[i].name);
|
||||||
|
(*menu)[i].name = NULL;
|
||||||
|
}
|
||||||
|
free((*menu));
|
||||||
|
(*menu) = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mu_createObjects(int size, menu_entry **menu){
|
||||||
|
(*menu) = calloc (size + 1, sizeof(menu_entry));
|
||||||
|
(*menu)[size].name = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mu_countObjects(menu_entry *entries, u8 propertyMask){
|
||||||
|
int amount = 0;
|
||||||
|
|
||||||
|
for (u32 i = 0; entries[i].name != NULL; i++){
|
||||||
|
if (!(entries[i].property & propertyMask))
|
||||||
|
amount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (entries[amount].name != NULL)
|
||||||
|
amount++;
|
||||||
|
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
void mu_copySingle(char *name, u32 storage, u8 property, menu_entry *out){
|
||||||
|
if (out->name != NULL)
|
||||||
|
free(out->name);
|
||||||
|
|
||||||
|
utils_copystring(name, &out->name);
|
||||||
|
out->storage = storage;
|
||||||
|
out->property = property;
|
||||||
|
}
|
8
source/tegraexplorer/utils/menuUtils.h
Normal file
8
source/tegraexplorer/utils/menuUtils.h
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
#include "../../utils/types.h"
|
||||||
|
#include "../common/types.h"
|
||||||
|
|
||||||
|
void mu_createObjects(int size, menu_entry **menu);
|
||||||
|
void mu_clearObjects(menu_entry **menu);
|
||||||
|
int mu_countObjects(menu_entry *entries, u8 propertyMask);
|
||||||
|
void mu_copySingle(char *name, u32 storage, u8 property, menu_entry *out);
|
Loading…
Reference in a new issue