Skip to content

Commit b138a74

Browse files
committed
(WiiU) Support WFS-formatted USB drives
Some users like to use native-format drives to store their data alongside Wii U games. Use libmocha to support this. Note Mocha_MountFS claims success even if the mounted folder doesn't exist. Since Salamander only has a "minimal" version of libmocha without the MountFS functionality, undefine HAVE_LIBMOCHA in that build. Users may want to build without MountFS but can't reasonably build without RPX loading.
1 parent 4405bc4 commit b138a74

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

Makefile.wiiu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ OBJ += wiiu/system/exception_handler.o
4141
OBJ += wiiu/system/missing_libc_functions.o
4242

4343
ifeq ($(SALAMANDER_BUILD),1)
44-
DEFINES += -DRARCH_CONSOLE -DIS_SALAMANDER -DHAVE_LIBMOCHA
44+
DEFINES += -DRARCH_CONSOLE -DIS_SALAMANDER
4545

4646
INCDIRS += -Ideps/libmocha/include
4747

frontend/drivers/platform_wiiu.c

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,12 @@
6767
#endif
6868
#endif
6969

70-
#ifdef HAVE_LIBMOCHA
70+
// We always have a minimal version of libmocha for Salamander + core loading, so no #ifdef here
7171
#include <mocha/mocha.h>
7272
#ifdef HAVE_LIBFAT
7373
#include <fat.h>
7474
#include <gx2/display.h>
7575
#endif
76-
#endif
7776

7877
#include "wiiu_dbg.h"
7978
#include "system/exception_handler.h"
@@ -83,6 +82,7 @@
8382
#define WIIU_VOL_CONTENT_PATH "fs:/vol/content/"
8483
#define WIIU_SD_FAT_PATH "sd:/"
8584
#define WIIU_USB_FAT_PATH "usb:/"
85+
#define WIIU_USB_WFS_PATH "storage_usb:/"
8686

8787
/**
8888
* The Wii U frontend driver, along with the main() method.
@@ -92,6 +92,7 @@
9292
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
9393
static bool have_libfat_usb = false;
9494
static bool have_libfat_sdcard = false;
95+
static bool have_wfs_usb = false;
9596
#endif
9697
static bool in_exec = false;
9798

@@ -244,6 +245,12 @@ static int frontend_wiiu_parse_drive_list(void *data, bool load_content)
244245
enum_idx,
245246
FILE_TYPE_DIRECTORY, 0, 0, NULL);
246247

248+
if (have_wfs_usb)
249+
menu_entries_append(list, WIIU_USB_WFS_PATH,
250+
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
251+
enum_idx,
252+
FILE_TYPE_DIRECTORY, 0, 0, NULL);
253+
247254
#endif
248255
return 0;
249256
}
@@ -672,27 +679,42 @@ static void main_loop(void)
672679

673680
static void init_filesystems(void)
674681
{
675-
#if defined(HAVE_LIBMOCHA) && defined(HAVE_LIBFAT)
682+
#if defined(HAVE_LIBMOCHA)
676683
if (Mocha_InitLibrary() == MOCHA_RESULT_SUCCESS)
677684
{
685+
if (Mocha_MountFS("storage_usb", NULL, "/vol/storage_usb01") == MOCHA_RESULT_SUCCESS) {
686+
if (exists(WIIU_USB_WFS_PATH))
687+
have_wfs_usb = true;
688+
else /* Liar! */
689+
Mocha_UnmountFS("storage_usb");
690+
}
691+
692+
693+
#if defined(HAVE_LIBFAT)
678694
have_libfat_usb = fatMount("usb", &Mocha_usb_disc_interface, 0, 512, 128);
679695
/* Mounting SD card with libfat is unsafe under Aroma */
680696
if (!in_aroma)
681697
have_libfat_sdcard = fatMount("sd", &Mocha_sdio_disc_interface, 0, 512, 128);
698+
#endif /* HAVE_LIBFAT */
682699
}
683-
#endif
700+
#endif /* HAVE_LIBMOCHA */
684701
}
685702

686703
static void deinit_filesystems(void)
687704
{
688-
#if defined(HAVE_LIBMOCHA) && defined(HAVE_LIBFAT)
705+
#if defined(HAVE_LIBMOCHA)
706+
if (have_wfs_usb)
707+
Mocha_UnmountFS("storage_usb");
708+
709+
#if defined(HAVE_LIBFAT)
689710
if (have_libfat_usb)
690711
fatUnmount("usb");
691712
if (have_libfat_sdcard)
692713
fatUnmount("sd");
714+
#endif /* HAVE_LIBFAT */
693715

694716
Mocha_DeInitLibrary();
695-
#endif
717+
#endif /* HAVE_LIBMOCHA */
696718
}
697719

698720
static devoptab_t dotab_stdout =

0 commit comments

Comments
 (0)