Library:Psy-Q SDK
Appearance
| Developer | Sony Computer Entertainment (libraries), SN Systems (Psy-Q toolchain) |
|---|---|
| Platforms | Platform:PlayStation |
| Versions | library releases 3.x to 4.x (1995-1999); later releases shipped as the PlayStation Programmer Tool runtime |
| On this wiki | Facts · Code · Notes · Topics |
The official PlayStation development kit: SN Systems' Psy-Q toolchain (GCC 2.x for MIPS, the ASPSX assembler, the PSYLINK linker) bundled with Sony's runtime libraries (LIBAPI, LIBC, LIBETC, LIBGPU, LIBGTE, LIBGS, LIBCD, LIBSPU, LIBSND, LIBCARD, LIBPRESS and others). The libraries are statically linked into almost every commercial Platform:PlayStation boot executable, which makes their functions the first thing to name in a new game.
Overview
Each library is an archive of small object files (LIBGPU.LIB, LIBCD.LIB...), and the linker pulls in only the objects a game uses, in archive order. In a boot executable the library code therefore appears as runs of functions grouped by object file, usually after a short game-specific main.
| Library | Purpose |
|---|---|
| LIBAPI | kernel/BIOS wrappers: events, threads, root counters, file I/O (open, read), Exec
|
| LIBC | small C library (memcpy, sprintf, rand)
|
| LIBETC | pads, vsync, interrupts and callbacks (VSync, ResetCallback, PadInit)
|
| LIBGPU | display/draw environments, primitives, ordering tables, VRAM transfers (LoadImage, DrawOTag, FntPrint)
|
| LIBGTE | GTE wrappers and fixed-point math tables (rsin, rcos, ratan2, SquareRoot0)
|
| LIBGS | higher-level 3D graphics system |
| LIBCD | CD-ROM control, file search, reads, streaming (CdInit, CdSearchFile, CdRead)
|
| LIBSPU | sound processor: voices, reverb, transfers to sound RAM |
| LIBSND | sequenced sound (SEQ/SEP) and VAB sound banks on top of LIBSPU |
| LIBCARD | memory card access |
Identification
- Function name and object order inside a matched game: e.g. LIBGPU's
LoadTPage,LoadClut,SetDefDrawEnv,SetDefDispEnv, then the font functionsFntLoad,FntOpen,FntFlush,FntPrint, then the primitive helpersSetPolyF3...SetLineG4. - RCS
$Id:strings left in library data name the source file, revision and year (for example a LIBGPUsys.crevision string from 1995 in Software:Castlevania: Symphony of the Night); they help pick the library version. - LIBCD keeps a table of CD command names (
CdlNop,CdlSetloc,CdlReadS,CdlSeekP,CdlGetTD...) for its debug output; these strings mark the LIBCD objects. - The startup object (
__main,start, then the game'smain) is placed first in the text section of most executables. Some games link an object (2MBYTE.OBJ) that sets the heap and stack for 2 MB of RAM.
Pitfalls
- The library version differs per game and the code differs between versions; signatures or object files from the wrong version do not match. Use the
$Idstrings or a matched decompilation of a game from the same year to pick the version. - The assembler version matters for byte-exact rebuilds: the sotn-decomp build maps Psy-Q 3.5 to ASPSX 2.34 and Psy-Q 3.3 to ASPSX 2.21 (see facts).
- Unverified: the device prefix
sim:(as inopen("sim:c:\\bin\\dra.bin", 1)in the boot code of Software:Castlevania: Symphony of the Night) reads files from the host PC of a development kit through LIBAPI's file functions; on retail hardware the open fails and the game falls back to LIBCD. Test by tracing theopencall on an emulator: it should return -1.
Evidence & references
- Library and object names as split in the sotn-decomp configuration (
config/splat.us.main.yaml, segment namespsxsdk/libgpu/...,psxsdk/libcd/...). - psx-spx for BIOS and kernel functions.