mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 05:32:47 +00:00
This is now in proof-of-concept-stage
This commit is contained in:
parent
f13a89d809
commit
7f6bc707fb
@ -10,6 +10,7 @@
|
|||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "draw.h"
|
#include "draw.h"
|
||||||
// #include "fs.h"
|
// #include "fs.h"
|
||||||
|
#include "hid.h"
|
||||||
|
|
||||||
void ClearScreen(u8* screen, int width, int color)
|
void ClearScreen(u8* screen, int width, int color)
|
||||||
{
|
{
|
||||||
@ -133,6 +134,8 @@ void ShowError(const char *format, ...)
|
|||||||
|
|
||||||
ClearScreenFull(true, false, COLOR_BLACK);
|
ClearScreenFull(true, false, COLOR_BLACK);
|
||||||
DrawStringF(true, 80, 80, COLOR_WHITE, COLOR_BLACK, str);
|
DrawStringF(true, 80, 80, COLOR_WHITE, COLOR_BLACK, str);
|
||||||
|
|
||||||
|
// InputWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*void ShowProgress(u64 current, u64 total)
|
/*void ShowProgress(u64 current, u64 total)
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
DWORD offset;
|
DWORD offset;
|
||||||
DWORD subtype;
|
|
||||||
BYTE type;
|
BYTE type;
|
||||||
|
DWORD subtype;
|
||||||
} FATpartition;
|
} FATpartition;
|
||||||
|
|
||||||
FATpartition DriveInfo[28] = {
|
FATpartition DriveInfo[28] = {
|
||||||
|
@ -19,7 +19,6 @@ bool InitFS()
|
|||||||
*(u32*)0x10000020 = 0;
|
*(u32*)0x10000020 = 0;
|
||||||
*(u32*)0x10000020 = 0x340;
|
*(u32*)0x10000020 = 0x340;
|
||||||
#endif
|
#endif
|
||||||
u32 emunand_state = CheckEmuNand();
|
|
||||||
for (numfs = 0; numfs < 16; numfs++) {
|
for (numfs = 0; numfs < 16; numfs++) {
|
||||||
char fsname[8];
|
char fsname[8];
|
||||||
snprintf(fsname, 8, "%lu:", numfs);
|
snprintf(fsname, 8, "%lu:", numfs);
|
||||||
@ -59,10 +58,10 @@ bool GetRootDirContentsWorker(DirStruct* contents)
|
|||||||
for (u32 pdrv = 0; (pdrv < numfs) && (pdrv < MAX_ENTRIES); pdrv++) {
|
for (u32 pdrv = 0; (pdrv < numfs) && (pdrv < MAX_ENTRIES); pdrv++) {
|
||||||
memset(contents->entry[pdrv].path, 0x00, 16);
|
memset(contents->entry[pdrv].path, 0x00, 16);
|
||||||
snprintf(contents->entry[pdrv].path + 0, 4, "%lu:", pdrv);
|
snprintf(contents->entry[pdrv].path + 0, 4, "%lu:", pdrv);
|
||||||
snprintf(contents->entry[pdrv].path + 4, 16, "[%lu:] (%s)", pdrv, drvname[pdrv]);
|
snprintf(contents->entry[pdrv].path + 4, 16, "[%lu:] %s", pdrv, drvname[pdrv]);
|
||||||
contents->entry[pdrv].name = contents->entry[pdrv].path + 4;
|
contents->entry[pdrv].name = contents->entry[pdrv].path + 4;
|
||||||
contents->entry[pdrv].size = 0;
|
contents->entry[pdrv].size = 0;
|
||||||
contents->entry[pdrv].type = T_FAT_ROOT;
|
contents->entry[pdrv].type = T_FAT_DIR;
|
||||||
}
|
}
|
||||||
contents->n_entries = numfs;
|
contents->n_entries = numfs;
|
||||||
|
|
||||||
@ -92,8 +91,8 @@ bool GetDirContentsWorker(DirStruct* contents, char* fpath, int fsize, bool recu
|
|||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
DirEntry* entry = &(contents->entry[contents->n_entries]);
|
DirEntry* entry = &(contents->entry[contents->n_entries]);
|
||||||
snprintf(entry->path, 256, "%s", fpath);
|
strncpy(entry->path, fpath, 256);
|
||||||
entry->name = entry->path + (fpath - fname);
|
entry->name = entry->path + (fname - fpath);
|
||||||
if (fno.fattrib & AM_DIR) {
|
if (fno.fattrib & AM_DIR) {
|
||||||
entry->type = T_FAT_DIR;
|
entry->type = T_FAT_DIR;
|
||||||
entry->size = 0;
|
entry->size = 0;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "hid.h"
|
#include "hid.h"
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
|
|
||||||
void DrawDirContents(DirStruct* contents, u32 offset, u32 cursor) {
|
void DrawDirContents(DirStruct* contents, u32* offset, u32 cursor) {
|
||||||
const int str_width = 40;
|
const int str_width = 40;
|
||||||
const u32 stp_y = 12;
|
const u32 stp_y = 12;
|
||||||
const u32 pos_x = 0;
|
const u32 pos_x = 0;
|
||||||
@ -11,7 +11,7 @@ void DrawDirContents(DirStruct* contents, u32 offset, u32 cursor) {
|
|||||||
|
|
||||||
for (u32 i = 0; pos_y < SCREEN_HEIGHT; i++) {
|
for (u32 i = 0; pos_y < SCREEN_HEIGHT; i++) {
|
||||||
char tempstr[str_width + 1];
|
char tempstr[str_width + 1];
|
||||||
u32 offset_i = offset + i;
|
u32 offset_i = *offset + i;
|
||||||
u32 color_font;
|
u32 color_font;
|
||||||
u32 color_bg;
|
u32 color_bg;
|
||||||
if (offset_i < contents->n_entries) {
|
if (offset_i < contents->n_entries) {
|
||||||
@ -35,18 +35,41 @@ void DrawDirContents(DirStruct* contents, u32 offset, u32 cursor) {
|
|||||||
|
|
||||||
u32 GodMode() {
|
u32 GodMode() {
|
||||||
u32 exit_mode = GODMODE_EXIT_REBOOT;
|
u32 exit_mode = GODMODE_EXIT_REBOOT;
|
||||||
|
char current_path[256] = { 0x00 };
|
||||||
DirStruct* contents;
|
DirStruct* contents;
|
||||||
|
u32 cursor = 0;
|
||||||
|
u32 offset_disp = 0;
|
||||||
|
|
||||||
ClearScreenFull(true, true, COLOR_BLACK);
|
ClearScreenFull(true, true, COLOR_BLACK);
|
||||||
if (!InitFS()) {
|
if (!InitFS()) return exit_mode;
|
||||||
// ShowError("Could not initialize fs!");
|
|
||||||
InputWait();
|
|
||||||
return exit_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
contents = GetDirContents("");
|
contents = GetDirContents("");
|
||||||
DrawDirContents(contents, 0, 0);
|
while (true) { // this is the main loop
|
||||||
InputWait();
|
DrawDirContents(contents, &offset_disp, cursor);
|
||||||
|
u32 pad_state = InputWait();
|
||||||
|
if (pad_state & BUTTON_DOWN) {
|
||||||
|
cursor++;
|
||||||
|
if (cursor >= contents->n_entries)
|
||||||
|
cursor = contents->n_entries - 1;
|
||||||
|
} else if ((pad_state & BUTTON_UP) && cursor) {
|
||||||
|
cursor--;
|
||||||
|
} else if ((pad_state & BUTTON_A) && (contents->entry[cursor].type == T_FAT_DIR)) {
|
||||||
|
strncpy(current_path, contents->entry[cursor].path, 256);
|
||||||
|
contents = GetDirContents(current_path);
|
||||||
|
cursor = offset_disp = 0;
|
||||||
|
ShowError(current_path);
|
||||||
|
} else if (pad_state & BUTTON_B) {
|
||||||
|
char* last_slash = strrchr(current_path, '/');
|
||||||
|
if (last_slash) *last_slash = '\0';
|
||||||
|
else *current_path = '\0';
|
||||||
|
contents = GetDirContents(current_path);
|
||||||
|
cursor = offset_disp = 0;
|
||||||
|
}
|
||||||
|
if (pad_state & BUTTON_START) {
|
||||||
|
exit_mode = (pad_state & BUTTON_LEFT) ? GODMODE_EXIT_POWEROFF : GODMODE_EXIT_REBOOT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
DeinitFS();
|
DeinitFS();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user