We can finally mount SysNAND and EmuNAND, horray!

This commit is contained in:
d0k3 2016-02-26 17:03:25 +01:00
parent 6adf9d254d
commit f13a89d809
5 changed files with 36 additions and 28 deletions

View File

@ -15,6 +15,7 @@
#define COLOR_BLACK RGB(0x00, 0x00, 0x00)
#define COLOR_WHITE RGB(0xFF, 0xFF, 0xFF)
#define COLOR_GREY RGB(0x7F, 0x7F, 0x7F)
#define COLOR_TRANSPARENT RGB(0xFF, 0x00, 0xEF) // otherwise known as 'super fuchsia'
#ifdef EXEC_GATEWAY

View File

@ -122,7 +122,7 @@ DRESULT disk_read (
/*-----------------------------------------------------------------------*/
/* Write Sector(s) */
/*-----------------------------------------------------------------------*/
#undef _USE_WRITE
#if _USE_WRITE
DRESULT disk_write (
__attribute__((unused))
@ -181,11 +181,12 @@ DRESULT disk_ioctl (
return RES_OK;
case GET_BLOCK_SIZE:
*((DWORD*) buff) = 0x2000;
return (DriveInfo[pdrv].type == TYPE_SDCARD) ? RES_OK : RES_PARERR;
// return (DriveInfo[pdrv].type == TYPE_SDCARD) ? RES_OK : RES_PARERR;
return RES_OK;
case CTRL_SYNC:
// nothing to do here - the disk_write function handles that
return RES_OK;
}
return RES_PARERR;
return RES_OK;
}
#endif

View File

@ -16,7 +16,7 @@
/ data transfer. */
#define _FS_READONLY 0
#define _FS_READONLY 1
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
@ -141,7 +141,7 @@
/ Drive/Volume Configurations
/---------------------------------------------------------------------------*/
#define _VOLUMES 1
#define _VOLUMES 7
/* Number of volumes (logical drives) to be used. */

View File

@ -4,7 +4,7 @@
#include "fatfs/nandio.h"
// don't use this area for anything else!
static FATFS* fs = (FATFS*) 0x20316000;
static FATFS* fs = (FATFS*)0x20316000;
// reserve one MB for this, just to be safe
static DirStruct* curdir_contents = (DirStruct*)0x21000000;
// this is the main buffer
@ -22,15 +22,16 @@ bool InitFS()
u32 emunand_state = CheckEmuNand();
for (numfs = 0; numfs < 16; numfs++) {
char fsname[8];
snprintf(fsname, 7, "%lu:", numfs);
if ((numfs >= 4) && (emunand_state >> (2*((numfs-4)/3)) != EMUNAND_GATEWAY))
break;
if (f_mount(fs, fsname, 0) != FR_OK) {
ShowError("Initialising failed! (%lu/%s)", numfs, fsname);
snprintf(fsname, 8, "%lu:", numfs);
int res = f_mount(fs + numfs, fsname, 1);
if (res != FR_OK) {
if (numfs >= 4) break;
ShowError("Initialising failed! (%lu/%s/%i)", numfs, fsname, res);
DeinitFS();
return false;
}
}
ShowError("Mounted: %i partitions", numfs);
return true;
}
@ -47,23 +48,23 @@ void DeinitFS()
bool GetRootDirContentsWorker(DirStruct* contents)
{
static const char* drvname[16] = {
"sdcard",
"sysctrn", "systwln", "systwlp",
"emu0ctrn", "emu0twln", "emu0twlp",
"emu1ctrn", "emu1twln", "emu1twlp",
"emu2ctrn", "emu2twln", "emu2twlp",
"emu3ctrn", "emu3twln", "emu3twlp"
"SDCARD",
"SYSCTRN", "SYSTWLN", "SYSTWLP",
"EMU0CTRN", "EMU0TWLN", "EMU0TWLP",
"EMU1CTRN", "EMU1TWLN", "EMU1TWLP",
"EMU2CTRN", "EMU2TWLN", "EMU2TWLP",
"EMU3CTRN", "EMU3TWLN", "EMU3TWLP"
};
for (u32 pdrv = 0; (pdrv < numfs) && (pdrv < MAX_ENTRIES); pdrv++) {
memset(contents->entry[pdrv].path, 0x00, 16);
snprintf(contents->entry[pdrv].path + 0, 4, "%lu:", pdrv);
snprintf(contents->entry[pdrv].path + 4, 4, "%s", 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].size = 0;
contents->entry[pdrv].type = T_FAT_ROOT;
contents->n_entries = pdrv;
}
contents->n_entries = numfs;
return contents->n_entries;
}

View File

@ -4,10 +4,10 @@
#include "fs.h"
void DrawDirContents(DirStruct* contents, u32 offset, u32 cursor) {
const int str_width = 38;
const u32 stp_y = 10;
const u32 pos_x = 10;
u32 pos_y = 10;
const int str_width = 40;
const u32 stp_y = 12;
const u32 pos_x = 0;
u32 pos_y = 2;
for (u32 i = 0; pos_y < SCREEN_HEIGHT; i++) {
char tempstr[str_width + 1];
@ -15,12 +15,17 @@ void DrawDirContents(DirStruct* contents, u32 offset, u32 cursor) {
u32 color_font;
u32 color_bg;
if (offset_i < contents->n_entries) {
if (cursor != offset_i) {
color_font = COLOR_GREY;
color_bg = COLOR_BLACK;
} else {
color_font = COLOR_WHITE;
color_bg = COLOR_BLACK;
}
snprintf(tempstr, str_width + 1, "%-*.*s", str_width, str_width, contents->entry[offset_i].name);
} else {
color_font = COLOR_BLACK;
color_bg = COLOR_WHITE;
color_font = COLOR_WHITE;
color_bg = COLOR_BLACK;
snprintf(tempstr, str_width + 1, "%-*.*s", str_width, str_width, "");
}
DrawStringF(false, pos_x, pos_y, color_font, color_bg, tempstr);