This doesn't really relate to
playing games, per se, (though I am going to need to test it

) but I've been in the process of porting MegaZeux, a mid-90s game creation system, to the PS Vita:
This was kind of an interesting project. On the surface it should be easy since the Vita has a reasonably complete SDL2 implementation (which MZX supports) and, like the PS3 and PS4, use a BSD-derived OS. Since MZX uses POSIX calls for file management you'd think you could just configure the package then build and package it with the Vita SDK toolchain. Noooooope.
Vita's OS lacks one crucal feature: the ability to traverse directories in userspace. This sounds like an odd omission, but when you think about it, it's not really something that a packaged game should need to do. MZX, however,
does need this feature. Luckily, functions that return file listings will still identify directories as expected, otherwise it would be impossible to actually do anything about it.
What I ultimately did was intercept all of the commands that open files by directory or change directories and writing my own reasonably-POSIX-compliant (they comply to the description given in the Linux man pages, anyway) functions that handle tracking the current directory and changing the directory, including throwing the expected errors when an invalid path is given. Here's a link to the black magic itself:
https://github.com/Spectere/megazeux/blob/viva_la_vita/arch/psvita/vitaio.cFor the sake of simplicity it uses some
linked list code I wrote for another project to track the directory chain. That also gives it a bit of inherit safety, as the list implementation's delete routines won't do anything if the list is empty, preventing ".." from root from working. This also acts as a sandbox, preventing MZX from accessing files outside of its root directory. The implementation is also OS-agnostic. I was able to use it on a Linux build with zero issues.

After all of that was written, all it took to replace the default functions was a bit of #define magic:
#define chdir(path) vitaio_chdir(path)
#define fopen(pathname, mode) vitaio_fopen(pathname, mode)
#define getcwd(buf, size) vitaio_getcwd(buf, size)
#define mkdir(path, mode) vitaio_mkdir(path, mode)
#define opendir(name) vitaio_opendir(name)
#define rmdir(path) vitaio_rmdir(path)
#define stat(path, buf) vitaio_stat(path, buf)
Hacky, yes, but it allowed everything to work without me having to #ifdef off every single I/O call in the MZX source.
There were some other considerations that needed to be made. setvbuf doesn't seem to do anything on the Vita, for example, which would cause saved games to take 20+ seconds to save on a good day. Since the Vita has plenty of memory, I changed it to
use a memory buffer instead, then dump the entire file in one pass. Now it takes less than a second.
The Vita also has the ability to use a Bluetooth keyboard, making it the only embedded platform that can feasibly use MZX's editor. The issue there is that the Vita's SDL2 implementation doesn't properly pass Unicode characters to the target program. I ended up
borrowing some code from the 3DS build's touchscreen keyboard implementation to translate the scancodes into Unicode. It isn't perfect, but it's a workable solution for now.
Lachesis (she posts on here as Alice once in a while) gave me a ton of pointers and assistance on the non-Vita stuff. Definitely couldn't have pulled this off so quickly without her help!
The next thing I want to take a crack at is using the front/rear touchpads to emulate a trackpad/mouse, since MZX can take advantage of those as well. We'll see how that goes.