1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-23 04:12:04 +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 '%': case '%':
gfx_putc('%'); gfx_putc('%');
break; break;
case 'j':
gfx_con.y = YLEFT - va_arg(ap, u32);
case '\0': case '\0':
return; return;
default: default:

View file

@ -12,6 +12,7 @@
#define ISMB (1 << 6) #define ISMB (1 << 6)
#define ISKB (1 << 5) #define ISKB (1 << 5)
#define ISB (1 << 4) #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))

View file

@ -60,6 +60,7 @@ void addobject(char* name, int spot, u8 attribs){
if (attribs & AM_DIR) if (attribs & AM_DIR)
fsreader_files[spot].property |= (ISDIR); fsreader_files[spot].property |= (ISDIR);
else { else {
/*
size = fsutil_getfilesize(fsutil_getnextloc(currentpath, name)); size = fsutil_getfilesize(fsutil_getnextloc(currentpath, name));
while (size > 1024){ 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].property |= (1 << (4 + sizes));
fsreader_files[spot].storage = size; fsreader_files[spot].storage = size;
*/
fsreader_files[spot].storage = 0;
fsreader_files[spot].property = ISNULL;
} }
if (attribs & AM_ARC) 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 gfx_makewaitmenu(char *hiddenmessage, int timer){
int res;
u32 start = get_tmr_s(); u32 start = get_tmr_s();
Inputs *input = NULL; Inputs *input = NULL;
@ -132,3 +131,51 @@ void gfx_printfilesize(int size, char *type){
gfx_printf("\a%4d\e%s", size, type); gfx_printf("\a%4d\e%s", size, type);
RESETCOLOR; 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_printlength(int size, char *toprint);
void gfx_printandclear(char *in, int length, int endX); void gfx_printandclear(char *in, int length, int endX);
void gfx_printfilesize(int size, char *type); 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; extern int printerrors;

View file

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