1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-08 13:11:54 +00:00

I am speed

This commit is contained in:
Such Meme, Many Skill 2020-05-02 13:05:06 +02:00
parent 4aca6e5fcf
commit 83e6bf7090
6 changed files with 132 additions and 33 deletions

View file

@ -403,8 +403,6 @@ void gfx_vprintf(const char *fmt, va_list ap)
case '%':
gfx_putc('%');
break;
case 'j':
gfx_con.y = YLEFT - va_arg(ap, u32);
case '\0':
return;
default:

View file

@ -12,6 +12,7 @@
#define ISMB (1 << 6)
#define ISKB (1 << 5)
#define ISB (1 << 4)
#define ISNULL (1 << 3)
#define SETBIT(object, shift, value) ((value) ? (object |= shift) : (object &= ~shift))

View file

@ -60,6 +60,7 @@ void addobject(char* name, int spot, u8 attribs){
if (attribs & AM_DIR)
fsreader_files[spot].property |= (ISDIR);
else {
/*
size = fsutil_getfilesize(fsutil_getnextloc(currentpath, name));
while (size > 1024){
@ -72,6 +73,9 @@ void addobject(char* name, int spot, u8 attribs){
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)

View file

@ -66,7 +66,6 @@ u32 gfx_errDisplay(char *src_func, int err, int loc){
}
int gfx_makewaitmenu(char *hiddenmessage, int timer){
int res;
u32 start = get_tmr_s();
Inputs *input = NULL;
@ -132,3 +131,51 @@ void gfx_printfilesize(int size, char *type){
gfx_printf("\a%4d\e%s", size, type);
RESETCOLOR;
}
static u32 sideY = 0;
void _gfx_sideSetYAuto(){
u32 getX, getY;
gfx_con_getpos(&getX, &getY);
sideY = getY;
}
void gfx_sideSetY(u32 setY){
sideY = setY;
}
u32 gfx_sideGetY(){
return sideY;
}
void gfx_sideprintf(char* message, ...){
va_list ap;
va_start(ap, message);
gfx_con_setpos(800, sideY);
gfx_vprintf(message, ap);
_gfx_sideSetYAuto();
va_end(ap);
}
void gfx_sideprintandclear(char* message, int length){
gfx_con_setpos(800, sideY);
gfx_printandclear(message, length, 1279);
gfx_putc('\n');
_gfx_sideSetYAuto();
}
void gfx_drawScrollBar(int minView, int maxView, int count){
int curScrollCount = 1 + maxView - minView;
if (curScrollCount >= count)
return;
int barSize = (703 * (curScrollCount * 100 / count)) / 100;
int offsetSize = (703 * (minView * 100/ count)) / 100;
gfx_boxGrey(740, 16, 755, 702, 0x1B);
if ((16 + barSize + offsetSize) > 702)
gfx_boxGrey(740, 16 + offsetSize, 755, 702, 0x66);
else
gfx_boxGrey(740, 16 + offsetSize, 755, 16 + barSize + offsetSize, 0x66);
}

View file

@ -13,5 +13,10 @@ int gfx_makewaitmenu(char *hiddenmessage, int timer);
void gfx_printlength(int size, char *toprint);
void gfx_printandclear(char *in, int length, int endX);
void gfx_printfilesize(int size, char *type);
void gfx_sideSetY(u32 setY);
u32 gfx_sideGetY();
void gfx_sideprintf(char* message, ...);
void gfx_sideprintandclear(char* message, int length);
void gfx_drawScrollBar(int minView, int maxView, int count);
extern int printerrors;

View file

@ -8,13 +8,15 @@
#include "../../mem/minerva.h"
#include "../../soc/gpio.h"
#include "../../hid/hid.h"
#include "../fs/fsutils.h"
extern void sd_unmount();
extern bool sd_inited;
void _printentry(menu_entry entry, bool highlighted, bool refresh){
int size;
u32 color = (entry.property & ISMENU) ? entry.storage : ((entry.property & ISDIR) ? COLOR_WHITE : COLOR_VIOLET);
void _printentry(menu_entry *entry, bool highlighted, bool refresh, char *path){
u64 size;
u16 sizes = 0;
u32 color = (entry->property & ISMENU) ? entry->storage : ((entry->property & ISDIR) ? COLOR_WHITE : COLOR_VIOLET);
/*
if (entry.property & ISMENU)
SWAPCOLOR(entry.storage);
@ -25,9 +27,25 @@ void _printentry(menu_entry entry, bool highlighted, bool refresh){
}
*/
if (!(entry.property & ISMENU && entry.property & ISDIR)){
for (size = 4; size < 8; size++)
if ((entry.property & (1 << size)))
if (!(entry->property & ISMENU && entry->property & ISDIR)){
if (entry->property & ISNULL){
size = fsutil_getfilesize(fsutil_getnextloc(path, entry->name));
while (size > 1024){
size /= 1024;
sizes++;
}
if (sizes > 3)
sizes = 0;
entry->property |= (1 << (4 + sizes));
entry->storage = size;
SETBIT(entry->property, ISNULL, 0);
}
for (sizes = 4; sizes < 8; sizes++)
if ((entry->property & (1 << sizes)))
break;
}
@ -44,22 +62,22 @@ void _printentry(menu_entry entry, bool highlighted, bool refresh){
SWAPCOLOR((highlighted) ? COLOR_DEFAULT : color);
SWAPBGCOLOR((highlighted) ? color : COLOR_DEFAULT);
if (!(entry.property & ISMENU))
gfx_printf("%c ", (entry.property & ISDIR) ? 30 : 31);
if (!(entry->property & ISMENU))
gfx_printf("%c ", (entry->property & ISDIR) ? 30 : 31);
if (refresh)
gfx_printandclear(entry.name, 37, 720);
gfx_printandclear(entry->name, 37, 720);
else
gfx_printlength(37, entry.name);
gfx_printlength(37, entry->name);
if (entry.property & ISDIR || entry.property & ISMENU)
if (entry->property & ISDIR || entry->property & ISMENU)
gfx_printf("\n");
else {
SWAPCOLOR(COLOR_BLUE);
SWAPBGCOLOR(COLOR_DEFAULT);
gfx_printf("\a%4d", entry.storage);
gfx_printf("\a%4d", entry->storage);
gfx_con.fntsz = 8;
gfx_printf("\n\e%s\n", gfx_file_size_names[size - 4]);
gfx_printf("\n\e%s\n", gfx_file_size_names[sizes - 4]);
gfx_con.fntsz = 16;
}
}
@ -68,8 +86,8 @@ void _printentry(menu_entry entry, bool highlighted, bool refresh){
bool disableB = false;
int menu_make(menu_entry *entries, int amount, char *toptext){
int currentpos = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 39, calculatedamount = 0;
u32 scrolltimer, timer;
bool refresh = false;
u32 scrolltimer, timer, sideY;
bool refresh = true;
Inputs *input = hidRead();
input->buttons = 0;
@ -97,22 +115,28 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
gfx_printlength(42, toptext);
RESETCOLOR;
gfx_sideSetY(48);
char *currentfolder = strrchr(toptext, '/');
if (currentfolder != NULL){
gfx_con_setpos(800, 48);
if (calculatedamount)
gfx_printf("%d items in curr. folder\n%j", calculatedamount, 800);
gfx_printf("Current directory:\n%j", 800);
gfx_sideprintf("%d items in current dir\n\n", calculatedamount);
gfx_sideprintf("Current directory:\n");
if (*(currentfolder + 1) != 0)
currentfolder++;
SWAPCOLOR(COLOR_GREEN);
gfx_printlength(28, currentfolder);
gfx_sideprintandclear(currentfolder, 28);
gfx_sideprintf("\n\n\n");
}
gfx_drawScrollBar(minscreen, maxscreen, amount);
while (!(input->a)){
gfx_con_setpos(0, 48);
timer = get_tmr_ms();
refresh = false;
if (!currentpos){
while (currentpos < amount && entries[currentpos].property & (ISSKIP | ISHIDE))
@ -137,28 +161,46 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
refresh = true;
}
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
if (!(entries[i].property & ISHIDE))
_printentry(entries[i], (i == currentpos), refresh);
if (refresh || currentfolder == NULL){
for (int i = 0 + offset; i < amount && i < 40 + offset; i++)
if (!(entries[i].property & ISHIDE))
_printentry(&entries[i], (i == currentpos), refresh, toptext);
}
else {
if (currentpos - minscreen > 0){
gfx_con_setpos(0, 32 + (currentpos - minscreen) * 16);
_printentry(&entries[currentpos - 1], false, false, toptext);
}
else
gfx_con_setpos(0, 48 + (currentpos - minscreen) * 16);
_printentry(&entries[currentpos], true, false, toptext);
if (currentpos < amount - 1 && currentpos < maxscreen)
_printentry(&entries[currentpos + 1], false, false, toptext);
}
RESETCOLOR;
sideY = gfx_sideGetY();
if (!(entries[currentpos].property & ISMENU)){
gfx_con_setpos(800, 144);
gfx_printf("Current selection:\n%j", 800);
gfx_sideprintf("Current selection:\n");
SWAPCOLOR(COLOR_YELLOW);
gfx_printandclear(entries[currentpos].name, 28, 1279);
gfx_sideprintandclear(entries[currentpos].name, 28);
RESETCOLOR;
gfx_con_setpos(800, 175);
gfx_printf("Type: %s", (entries[currentpos].property & ISDIR) ? "Dir " : "File");
gfx_sideprintf("Type: %s", (entries[currentpos].property & ISDIR) ? "Dir " : "File");
gfx_sideSetY(sideY);
}
else
gfx_boxGrey(800, 144, 1279, 190, 0x1B);
gfx_boxGrey(800, sideY, 1279, sideY + 48, 0x1B);
gfx_con_setpos(0, 703);
SWAPCOLOR(COLOR_DEFAULT);
SWAPBGCOLOR(COLOR_WHITE);
gfx_printf("%s %s | Time taken for screen draw: %dms ", (offset + 40 < amount) ? "v" : " ", (offset > 0) ? "^" : " ", get_tmr_ms() - timer);
gfx_printf("Time taken for screen draw: %dms ", get_tmr_ms() - timer);
if (refresh)
gfx_drawScrollBar(minscreen, maxscreen, amount);
while ((input = hidRead())->buttons & (KEY_B | KEY_A));
@ -208,6 +250,8 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
currentpos = 0;
break;
}
refresh = false;
}
minerva_periodic_training();