diff --git a/AGENTS.md b/AGENTS.md index 2e866443fc..73140563c0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -262,7 +262,8 @@ writing BMPs (and when reading BMP references). `TranslateDebugBufferToCompare` HLE module implementations live in `Core/HLE/sce.cpp` / `.h`, as a `const HLEFunction []` table registered via `RegisterHLEModule()`. Both the function table and the `Register_*()` calls are append-only - see Core Safety Checks above, which is what breaks old savestates silently -if ignored. +if ignored. A kernel/driver function whose NID differs between firmware versions gets one entry +(the 6.60 NID) plus a row in `hleKernelNids` in `HLETables.cpp`, never one duplicate entry per NID. Also: a new `.cpp`/`.c` file has to be added to **seven** build files (CMake, Core.vcxproj + filters, the two UWP projects, `android/jni/Android.mk`, `libretro/Makefile.common`); headers to the first five. diff --git a/docs/HLEModules.md b/docs/HLEModules.md index 297fba8497..d4dfc4f454 100644 --- a/docs/HLEModules.md +++ b/docs/HLEModules.md @@ -17,6 +17,13 @@ small examples to copy from). A module is a `const HLEFunction []` table o `I` = s64, `v` = void. - For functions of genuinely unknown purpose (only known by NID), name them `_` and stub them with `return hleLogError(Log::HLE, 0, "UNIMPL");` - an established pattern (see `scePauth.cpp`, `sceOpenPSID.cpp`). +- **A function with a different NID in each firmware version gets one table entry, with the 6.60/6.61 NID.** + Kernel and driver NIDs were renumbered at several releases, so an XMB or firmware module from another version + imports the same function under another NID. Don't add a duplicate table entry per NID: put a row in + `hleKernelNids` in `Core/HLE/HLETables.cpp`, which `GetHLENidAlias()` uses to map each generation's NID to the + first column when an import is resolved. To find a function's NID in each version, disassemble the exporting + module from each firmware dump (`--re-module`, see [reverse-engineering.md](reverse-engineering.md)) and match the + function by its body. A full set of dumps is in `D:\PSP ISO\FirmwareVersions` on the main dev machine. - **New modules must be registered at the very end** of the registration function in `Core/HLE/HLETables.cpp` (look for the `// add new modules here.` comment near the end of that function) - not inserted alphabetically/logically among the existing `Register_*()` calls. Module registration order affects numeric IDs used in savestates, so inserting a