diff --git a/source/fs/menus/explorer.c b/source/fs/menus/explorer.c index adf6972..14210d9 100644 --- a/source/fs/menus/explorer.c +++ b/source/fs/menus/explorer.c @@ -10,6 +10,7 @@ #include MenuEntry_t topEntries[] = { + {.optionUnion = COLORTORGB(COLOR_GREEN) | SKIPBIT}, {.optionUnion = COLORTORGB(COLOR_ORANGE), .name = "Back"}, {.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Clipboard -> Current folder"}, {.optionUnion = COLORTORGB(COLOR_GREY) | SKIPBIT, .name = "Current folder options"} @@ -23,8 +24,6 @@ MenuEntry_t MakeMenuOutFSEntry(FSEntry_t entry){ return out; } -#define maxYOnScreen 42 - void clearFileVector(Vector_t *v){ vecPDefArray(FSEntry_t*, entries, v); for (int i = 0; i < v->count; i++) @@ -40,21 +39,25 @@ void FileExplorer(char *path){ while (1){ gfx_clearscreen(); gfx_printf("Loading...\r"); + //gfx_printf(" "); Vector_t fileVec = ReadFolder(storedPath); vecDefArray(FSEntry_t*, fsEntries, fileVec); - Vector_t entries = newVec(sizeof(MenuEntry_t), maxYOnScreen); - entries.count = 3; - memcpy(entries.data, topEntries, sizeof(MenuEntry_t) * 3); + topEntries[0].name = storedPath; + Vector_t entries = newVec(sizeof(MenuEntry_t), fileVec.count + ARR_LEN(topEntries)); + entries.count = ARR_LEN(topEntries); + memcpy(entries.data, topEntries, sizeof(MenuEntry_t) * ARR_LEN(topEntries)); for (int i = 0; i < fileVec.count; i++){ MenuEntry_t a = MakeMenuOutFSEntry(fsEntries[i]); vecAddElem(&entries, a); } - res = newMenu(&entries, res, 50, maxYOnScreen, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count); + gfx_con_setpos(144, 16); + gfx_boxGrey(0, 16, 160, 31, 0x1B); + res = newMenu(&entries, res, 60, 42, ENABLEB | ENABLEPAGECOUNT, (int)fileVec.count); - if (res < 3) { + if (res < ARR_LEN(topEntries)) { if (!strcmp(storedPath, path)){ clearFileVector(&fileVec); return; @@ -64,9 +67,9 @@ void FileExplorer(char *path){ storedPath = EscapeFolder(copy); free(copy); } - else if (fsEntries[res - 3].isDir) { + else if (fsEntries[res - ARR_LEN(topEntries)].isDir) { char *copy = CpyStr(storedPath); - storedPath = CombinePaths(copy, fsEntries[res - 3].name); + storedPath = CombinePaths(copy, fsEntries[res - ARR_LEN(topEntries)].name); free(copy); } diff --git a/source/fs/menus/explorer.h b/source/fs/menus/explorer.h index b7ecbfe..840f4d8 100644 --- a/source/fs/menus/explorer.h +++ b/source/fs/menus/explorer.h @@ -1,9 +1,4 @@ #pragma once #include "../../utils/vector.h" -typedef struct { - char *curPath; - Vector_t *files; -} ExplorerCtx_t; - void FileExplorer(char *path); \ No newline at end of file diff --git a/source/fs/menus/filemenu.c b/source/fs/menus/filemenu.c new file mode 100644 index 0000000..e69de29 diff --git a/source/fs/menus/filemenu.h b/source/fs/menus/filemenu.h new file mode 100644 index 0000000..e69de29 diff --git a/source/gfx/gfx.c b/source/gfx/gfx.c index d12d3b8..5104e9f 100644 --- a/source/gfx/gfx.c +++ b/source/gfx/gfx.c @@ -362,16 +362,22 @@ static void _gfx_putn(u32 v, int base, char fill, int fcnt) v /= base; } while (v); + if (minus){ + *--p = '-'; + c--; + } + if (fill != 0) { + gfx_con.y -= c * 16; + /* while (c > 0) { *--p = fill; c--; } + */ } - if (minus) - gfx_putc('-'); gfx_puts(p); } diff --git a/source/gfx/menu.c b/source/gfx/menu.c index 2480e82..c7f8f1e 100644 --- a/source/gfx/menu.c +++ b/source/gfx/menu.c @@ -27,9 +27,9 @@ void _printEntry(MenuEntry_t entry, u32 maxLen, u8 highlighted){ u32 curX = 0, curY = 0; gfx_con_getpos(&curX, &curY); - gfx_puts_limit(entry.name, maxLen - 8); + gfx_puts_limit(entry.name, maxLen - ((entry.showSize) ? 8 : 0)); if (entry.showSize){ - SETCOLOR(COLOR_BLUE, COLOR_DEFAULT); + (highlighted) ? SETCOLOR(COLOR_DEFAULT, COLOR_BLUE) : SETCOLOR(COLOR_BLUE, COLOR_DEFAULT); gfx_con_setpos(curX + (maxLen - 6) * 16, curY); gfx_printf("%4d", entry.size); gfx_puts_small(sizeDefs[entry.sizeDef]); @@ -77,7 +77,7 @@ int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 op if (options & ENABLEPAGECOUNT){ gfx_con_setpos(startX, startY - 32); RESETCOLOR; - gfx_printf("Page %d / %d | Total %d entries\n", (selected / screenLenY) + 1, (vec->count / screenLenY) + 1, entryCount); + gfx_printf("Page %d / %d | Total %d entries ", (selected / screenLenY) + 1, (vec->count / screenLenY) + 1, entryCount); } gfx_con_setpos(startX, startY); @@ -86,8 +86,11 @@ int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 op gfx_boxGrey(startX, startY, startX + screenLenX * 16, startY + screenLenY * 16, 0x1B); int start = selected / screenLenY * screenLenY; - for (int i = start; i < MIN(vec->count, start + screenLenY); i++) + for (int i = start; i < MIN(vec->count, start + screenLenY); i++){ + gfx_con_setpos(startX, startY + ((i % screenLenY) * 16)); _printEntry(entries[i], screenLenX, (i == selected)); + } + } else if (lastIndex != selected) { u32 minLastCur = MIN(lastIndex, selected); diff --git a/source/gfx/menu.h b/source/gfx/menu.h index fd1dece..e6a4a19 100644 --- a/source/gfx/menu.h +++ b/source/gfx/menu.h @@ -38,5 +38,7 @@ typedef struct _menuEntry { #define ENABLEPAGECOUNT BIT(1) #define ALWAYSREDRAW BIT(2) +#define ARR_LEN(x) (sizeof(x) / sizeof(*x)) + int newMenu(Vector_t* vec, int startIndex, int screenLenX, int screenLenY, u8 options, int entryCount); void FunctionMenuHandler(MenuEntry_t *entries, int entryCount, menuPaths *paths, u8 options); \ No newline at end of file diff --git a/source/main.c b/source/main.c index eb7cdaf..fc0da49 100644 --- a/source/main.c +++ b/source/main.c @@ -46,6 +46,7 @@ #include "utils/vector.h" #include "gfx/gfxutils.h" #include "tegraexplorer/mainmenu.h" +#include "tegraexplorer/tconf.h" hekate_config h_cfg; @@ -174,8 +175,11 @@ void ipl_main() // Mount SD Card. h_cfg.errors |= !sd_mount() ? ERR_SD_BOOT_EN : 0; + TConf.minervaEnabled = !minerva_init(); + TConf.FSBuffSize = (TConf.minervaEnabled) ? 0x400000 : 0x10000; + // Train DRAM and switch to max frequency. - if (minerva_init()) //!TODO: Add Tegra210B01 support to minerva. + if (TConf.minervaEnabled) //!TODO: Add Tegra210B01 support to minerva. h_cfg.errors |= ERR_LIBSYS_MTC; minerva_change_freq(FREQ_1600); diff --git a/source/tegraexplorer/tconf.c b/source/tegraexplorer/tconf.c new file mode 100644 index 0000000..d7d004c --- /dev/null +++ b/source/tegraexplorer/tconf.c @@ -0,0 +1,2 @@ +#include "tconf.h" +TConf_t TConf = {0}; \ No newline at end of file diff --git a/source/tegraexplorer/tconf.h b/source/tegraexplorer/tconf.h new file mode 100644 index 0000000..ff5de1d --- /dev/null +++ b/source/tegraexplorer/tconf.h @@ -0,0 +1,37 @@ +#pragma once +#include + +enum { + LOC_SD = 0, + LOC_EMMC, + LOC_EMUMMC +}; + +enum { + CMODE_None = 0, + CMODE_Copy, + CMODE_Move +}; + +enum { + M_None = 0, + M_EMMC, + M_EMUMMC +}; + +typedef struct { + u32 FSBuffSize; + char *srcCopy; + union { + struct { + u8 minervaEnabled:1; + u8 lastExplorerLoc:2; + u8 explorerCopyMode:2; + u8 currentlyMounted:2; + }; + u8 optionUnion; + }; + // Add keys here +} TConf_t; + +extern TConf_t TConf; \ No newline at end of file