PSP2: Access to ur0 and uma0 partitions
Vicki Pfau vi@endrift.com
Thu, 25 Jan 2018 18:39:24 -0800
4 files changed,
111 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -14,6 +14,7 @@ - AGBPrint support
- Debugger: Conditional breakpoints and watchpoints - Ability to select GB/GBC/SGB BIOS on console ports - Optional automatic state saving/loading + - Access to ur0 and uma0 partitions on the Vita Bugfixes: - GB Audio: Make audio unsigned with bias (fixes mgba.io/i/749) - GB Serialize: Fix audio state loading
M
include/mgba-util/vfs.h
→
include/mgba-util/vfs.h
@@ -87,7 +87,7 @@ #ifdef USE_LZMA
struct VDir* VDirOpen7z(const char* path, int flags); #endif -#if defined(__wii__) || defined(_3DS) +#if defined(__wii__) || defined(_3DS) || defined(PSP2) struct VDir* VDeviceList(void); #endif
M
src/platform/psp2/main.c
→
src/platform/psp2/main.c
@@ -89,7 +89,8 @@ struct GUIFont* font = GUIFontCreate();
struct mGUIRunner runner = { .params = { PSP2_HORIZONTAL_PIXELS, PSP2_VERTICAL_PIXELS, - font, "ux0:data", _drawStart, _drawEnd, + font, "", + _drawStart, _drawEnd, _pollInput, _pollCursor, _batteryState, 0, 0,
M
src/platform/psp2/sce-vfs.c
→
src/platform/psp2/sce-vfs.c
@@ -52,6 +52,16 @@
static const char* _vdesceName(struct VDirEntry* vde); static enum VFSType _vdesceType(struct VDirEntry* vde); +static bool _vdlsceClose(struct VDir* vd); +static void _vdlsceRewind(struct VDir* vd); +static struct VDirEntry* _vdlsceListNext(struct VDir* vd); +static struct VFile* _vdlsceOpenFile(struct VDir* vd, const char* path, int mode); +static struct VDir* _vdlsceOpenDir(struct VDir* vd, const char* path); +static bool _vdlsceDeleteFile(struct VDir* vd, const char* path); + +static const char* _vdlesceName(struct VDirEntry* vde); +static enum VFSType _vdlesceType(struct VDirEntry* vde); + struct VFile* VFileOpenSce(const char* path, int flags, SceMode mode) { struct VFileSce* vfsce = malloc(sizeof(struct VFileSce)); if (!vfsce) {@@ -148,6 +158,10 @@ return sceIoSyncByFd(vfsce->fd) >= 0;
} struct VDir* VDirOpen(const char* path) { + if (!path || !path[0]) { + return VDeviceList(); + } + SceUID dir = sceIoDopen(path); if (dir < 0) { return 0;@@ -250,3 +264,96 @@ return VFS_DIRECTORY;
} return VFS_FILE; } + +struct VDirEntrySceDevList { + struct VDirEntry d; + ssize_t index; + const char* name; +}; + +struct VDirSceDevList { + struct VDir d; + struct VDirEntrySceDevList vde; +}; + +static const char* _devs[] = { + "ux0:", + "ur0:", + "uma0:" +}; + +struct VDir* VDeviceList() { + struct VDirSceDevList* vd = malloc(sizeof(struct VDirSceDevList)); + if (!vd) { + return 0; + } + + vd->d.close = _vdlsceClose; + vd->d.rewind = _vdlsceRewind; + vd->d.listNext = _vdlsceListNext; + vd->d.openFile = _vdlsceOpenFile; + vd->d.openDir = _vdlsceOpenDir; + vd->d.deleteFile = _vdlsceDeleteFile; + + vd->vde.d.name = _vdlesceName; + vd->vde.d.type = _vdlesceType; + vd->vde.index = -1; + vd->vde.name = 0; + + return &vd->d; +} + +static bool _vdlsceClose(struct VDir* vd) { + struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd; + free(vdl); + return true; +} + +static void _vdlsceRewind(struct VDir* vd) { + struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd; + vdl->vde.name = NULL; + vdl->vde.index = -1; +} + +static struct VDirEntry* _vdlsceListNext(struct VDir* vd) { + struct VDirSceDevList* vdl = (struct VDirSceDevList*) vd; + while (vdl->vde.index < 3) { + ++vdl->vde.index; + vdl->vde.name = _devs[vdl->vde.index]; + SceUID dir = sceIoDopen(vdl->vde.name); + if (dir < 0) { + continue; + } + sceIoDclose(dir); + return &vdl->vde.d; + } + return 0; +} + +static struct VFile* _vdlsceOpenFile(struct VDir* vd, const char* path, int mode) { + UNUSED(vd); + UNUSED(path); + UNUSED(mode); + return NULL; +} + +static struct VDir* _vdlsceOpenDir(struct VDir* vd, const char* path) { + UNUSED(vd); + return VDirOpen(path); +} + +static bool _vdlsceDeleteFile(struct VDir* vd, const char* path) { + UNUSED(vd); + UNUSED(path); + return false; +} + +static const char* _vdlesceName(struct VDirEntry* vde) { + struct VDirEntrySceDevList* vdle = (struct VDirEntrySceDevList*) vde; + return vdle->name; +} + +static enum VFSType _vdlesceType(struct VDirEntry* vde) { + UNUSED(vde); + return VFS_DIRECTORY; +}