The system's functions by NID

A game imports each system function by its NID, the 32-bit number that names it wherever it is imported from. The functions the runtime answers are declared as the Switch's hooks are (hooks), in the language of tools/hookgen, one spec for each module of src/vita/hle/ beside its .c (kernel.hook, kernel.c). A declaration gives the NID in brackets, then the function's name and signature, and the handler after =:

family io
[0x99ba173e] hook sceIoLseek(u32 fd, i64 offset, i32 whence) -> u64 = vita_io_lseek
[0x8cba03d5] hook sceClibSnprintf(u32 buffer, u32 size, u32 fmt, ...) -> u32 = vita_libc_clib_snprintf
[0x27eab8c1] hook acosf(f32 x) -> f32 = vita_libc_lm_acosf

hookgen --vita (snx_vita_hookgen in cmake/hookgen.cmake) reads every spec into one table, vita_hle_table, sorted by NID, which hle.c searches at an import's first call; two declarations of one NID are refused. Each entry's adapter reads the arguments where AAPCS32 with VFP arguments puts them: r0 to r3, a 64-bit one in an even pair of them, floats in the S and D registers, the rest on the caller's stack. A variadic function's ... ends its arguments, which are the base standard's (a float in core registers), and its handler reads the others itself (vita_arg). The adapter calls the handler, ret handler(VitaProcess* p, VitaThread* t, args...), which vita/hle/hle.hook.h declares, and returns its result in r0 (a 64-bit one's high word in r1, a float in S0 or D0). An addr is the guest's 4-byte address. A handler that waits (vita_wait) returns all the same, and its result is dropped: the thread's r0 is set when the wait is met.

tests/vita_hle_adapters.c checks the adapters of tests/hook/vita.hook, and the hookgen_refuses_vita_* tests the declarations that --vita refuses.

The twelve keys and the two sticks are on the screen too (On-screen controls), for fingers and the mouse's left button: shown on a touch screen while no gamepad is connected, or as --controls= says, their layout edited with F2. A finger or that button off them touches the front panel where it is on the picture, six at most (--touch=1 the fingers alone, --touch=0 neither), and the mouse's right button the rear panel, which no finger touches. Esc twice within 3 seconds ends the game, a first press warning on the terminal and in a line over the game, as a Switch game's notices show, and F11 or Alt+Return switches fullscreen: the runtime's keys, as a Switch game takes them (On-screen controls).

The driver's settings (--key=value) are the g_vita_debug_ini table of src/nx/runtime/settings.txt: vita_hle_trace prints each import call, vita_jit_trace each block compiled at run time, vita_gxm_trace each scene and draw (and why a draw was skipped). --shot-every=N (vita_shot_every, with --shot=PATH) saves a screenshot every N vblanks, as PATH_0000.ppm on. --vulkan-video=1 (the Switch runtime's setting) stops the game when it makes an AVC decoder: decoding the Vita's movies with Vulkan Video is not implemented yet, and FFmpeg decodes them on the CPU.


Made from docs/platforms/vita/README.md at 69237645142c. GPL-3.0-or-later.