libgui 2.01
libgui is a GUI library for the GameCube, Wii, and Wii U
 
Loading...
Searching...
No Matches
GameCubeFileSystemDriver.cpp
1/****************************************************************************
2 * Platform Abstraction Layer (OGC driver)
3 * Daryl Borth 2026
4 * GameCubeFileSystemDriver.cpp
5 *
6 * GameCube storage device enumeration + mounting: SD Gecko slots A/B,
7 * SD2SP2 (port2), GC Loader, and DVD. Slots A/B and port2 are polled for
8 * hotplug via a real EXI presence probe; GC Loader and DVD are not
9 ***************************************************************************/
10#include <stdio.h>
11#include <sdcard/gcsd.h>
12#include <ogc/dvd.h>
13
14#include "GameCubeFileSystemDriver.h"
15
16static DISC_INTERFACE * GetDiscSlotA() { return get_io_gcsda(); }
17static DISC_INTERFACE * GetDiscSlotB() { return get_io_gcsdb(); }
18static DISC_INTERFACE * GetDiscPort2() { return get_io_gcsd2(); }
19static DISC_INTERFACE * GetDiscGcLoader() { return &__io_gcode; }
20
21// autoMountAtStartup: true for carda/cardb/port2 - all three go through
22// the same cheap, safe EXI presence probe. GC Loader is startup-only
23// (pollable=false) - see the descriptor field comment.
24static const OgcFatSlotDescriptor gameCubeFatSlots[] =
25{
26 { DEVICE_SD_SLOTA, GetDiscSlotA, "carda", "carda:/", "SD Gecko Slot A", "SD card not found!", false, true, true },
27 { DEVICE_SD_SLOTB, GetDiscSlotB, "cardb", "cardb:/", "SD Gecko Slot B", "SD card not found!", false, true, true },
28 { DEVICE_SD_PORT2, GetDiscPort2, "port2", "port2:/", "SD in SP2", "SD card not found!", false, true, true },
29 { DEVICE_SD_GCLOADER, GetDiscGcLoader, "gcloader", "gcloader:/", "GC Loader", "SD card not found!", false, false, false },
30};
31
33{
34 DVD_Init();
35
36 fatSlots = gameCubeFatSlots;
37 fatSlotCount = sizeof(gameCubeFatSlots) / sizeof(gameCubeFatSlots[0]);
38 dvdDisc = &__io_gcdvd;
39 unsupportedFormatMessage = "Unsupported format - please use FAT32/exFAT.";
40
41 smbDriver.init();
42
44}
45
46const int * GameCubeFileSystemDriver::getValidLoadDevices(int & outCount) const
47{
48 static const int devices[] = { DEVICE_AUTO, DEVICE_SD_SLOTA, DEVICE_SD_SLOTB, DEVICE_SD_PORT2, DEVICE_SD_GCLOADER, DEVICE_DVD, DEVICE_SMB };
49 outCount = sizeof(devices) / sizeof(devices[0]);
50 return devices;
51}
52
53const int * GameCubeFileSystemDriver::getValidSaveDevices(int & outCount) const
54{
55 static const int devices[] = { DEVICE_AUTO, DEVICE_SD_SLOTA, DEVICE_SD_SLOTB, DEVICE_SD_PORT2, DEVICE_SD_GCLOADER, DEVICE_SMB };
56 outCount = sizeof(devices) / sizeof(devices[0]);
57 return devices;
58}
const int * getValidSaveDevices(int &outCount) const override
Devices (Device enum values, in priority order) that are offered when choosing where to save to on th...
void init() override
Initializes the driver and auto-mounts devices flagged autoMountAtStartup.
const int * getValidLoadDevices(int &outCount) const override
Devices (Device enum values, in priority order) that are offered when choosing where to load from on ...
const OgcFatSlotDescriptor * fatSlots
Table of FAT slots this platform supports; set by the concrete driver.
void initFatSlotsAndAutoMount()
Runs the shared boot-time pass: probe every pollable fatSlots[] entry once for isPresentCache,...
const char * unsupportedFormatMessage
Text returned by mountResultMessage() when a present device fails to mount.
int fatSlotCount
Number of entries in fatSlots.
DISC_INTERFACE * dvdDisc
Disc interface used to mount the DVD drive, or nullptr if the platform has none.
OgcSmbDriver smbDriver
The network-share driver returned by getSmb()
@ DEVICE_SD_SLOTA
GameCube memory card slot A.
@ DEVICE_SD_SLOTB
GameCube memory card slot B.
@ DEVICE_SD_PORT2
GameCube SD Gecko in memory card slot B.
One hot-pluggable FAT-formatted slot, shared shape between GameCube (SD Gecko A/B/port2,...