Permalink
Browse files

PSP2: Access to ur0 and uma0 partitions

  • Loading branch information...
endrift committed Jan 26, 2018
1 parent ed21eeb commit 3a9d77d9e0fe59d488a538474381a564b1c061d3
Showing with 111 additions and 2 deletions.
  1. +1 −0 CHANGES
  2. +1 −1 include/mgba-util/vfs.h
  3. +2 −1 src/platform/psp2/main.c
  4. +107 −0 src/platform/psp2/sce-vfs.c
View
@@ -14,6 +14,7 @@ Features:
- 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
View
@@ -87,7 +87,7 @@ struct VDir* VDirOpenZip(const char* path, int flags);
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
View
@@ -89,7 +89,8 @@ int main() {
struct mGUIRunner runner = {
.params = {
PSP2_HORIZONTAL_PIXELS, PSP2_VERTICAL_PIXELS,
- font, "ux0:data", _drawStart, _drawEnd,
+ font, "",
+ _drawStart, _drawEnd,
_pollInput, _pollCursor,
_batteryState,
0, 0,
View
@@ -52,6 +52,16 @@ static bool _vdsceDeleteFile(struct VDir* vd, const char* path);
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 @@ bool _vfsceSync(struct VFile* vf, const void* buffer, size_t size) {
}
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 @@ static enum VFSType _vdesceType(struct VDirEntry* vde) {
}
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;
+}

0 comments on commit 3a9d77d

Please sign in to comment.