From cd8135406b0ac7b3d417f2d58ebe8678f1414bfe Mon Sep 17 00:00:00 2001 From: Matthew Stanley <1379tech@gmail.com> Date: Sat, 26 Sep 2026 06:43:12 -0700 Subject: [PATCH] mods: give the 8 MB RAM builtin a current-schema manifest and parse-test every builtin Co-Authored-By: Claude Opus 5.5 (1M context) --- .../1.0.0/manifest.toml | 13 +++- runtime/CMakeLists.txt | 12 ++++ runtime/tests/test_builtin_mod_manifests.cpp | 68 +++++++++++++++++++ 3 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 runtime/tests/test_builtin_mod_manifests.cpp diff --git a/mods/builtin/packages/psx.enhancement.8mb-ram/1.0.0/manifest.toml b/mods/builtin/packages/psx.enhancement.8mb-ram/1.0.0/manifest.toml index 1fc40d3f..f0f7f7c1 100644 --- a/mods/builtin/packages/psx.enhancement.8mb-ram/1.0.0/manifest.toml +++ b/mods/builtin/packages/psx.enhancement.8mb-ram/1.0.0/manifest.toml @@ -1,14 +1,23 @@ +format_version = 5 id = "psx.enhancement.8mb-ram" version = "1.0.0" name = "8 MB Main RAM" author = "psxrecomp" description = "Enables an opt-in 8 MB main RAM map for patches that require expanded PS1 memory. Disabled by default." +resolver = "declarative" +save_compatibility = "shared" + +# Main-RAM geometry is a property of the emulated machine, not of any one disc. +# Only patches written for an 8 MB (development-kit sized) RAM need it; stock +# games keep retail 2 MB mirroring with this off. +[[target]] +game_id = "*" [[feature]] id = "8mb-ram" name = "8 MB Main RAM" -description = "Use expanded 8 MB main RAM instead of stock 2 MB mirroring. Both netplay peers must use the same setting." -category = "enhancement" +description = "Use expanded 8 MB main RAM instead of stock 2 MB mirroring. Savestates record the active size, so states from one setting do not load under the other. Both netplay peers must use the same setting." +group = "Advanced" default_enabled = false hidden = true diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 13bc6e52..b3010845 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -429,6 +429,18 @@ if(BUILD_TESTING) ../recompiler/lib/toml11) add_test(NAME mod_packages_test COMMAND mod_packages_test) + add_executable(builtin_mod_manifests_test + tests/test_builtin_mod_manifests.cpp + src/mod_packages.cpp + src/crc32.c + src/psx_sha256.c) + target_include_directories(builtin_mod_manifests_test PRIVATE + include + ../recompiler/lib/toml11) + add_test(NAME builtin_mod_manifests_test + COMMAND builtin_mod_manifests_test + "${CMAKE_CURRENT_SOURCE_DIR}/../mods/builtin/packages") + add_executable(text_xlate_fix_only_test tests/test_text_xlate_fix_only.cpp src/text_xlate.cpp diff --git a/runtime/tests/test_builtin_mod_manifests.cpp b/runtime/tests/test_builtin_mod_manifests.cpp new file mode 100644 index 00000000..9c55ce36 --- /dev/null +++ b/runtime/tests/test_builtin_mod_manifests.cpp @@ -0,0 +1,68 @@ +/* Every framework-builtin mod package must parse under the current manifest + * schema. A builtin that fails to parse is silently dropped from the catalog + * at runtime ("mod manifest ignored"), which for an activation package such as + * psx.enhancement.8mb-ram makes the feature impossible to enable while every + * other test stays green. + * + * Usage: builtin_mod_manifests_test */ +#include "mod_packages.h" + +#include +#include +#include + +namespace fs = std::filesystem; +using namespace PSXRecompV4; + +static int failures; + +static void check(bool value, const std::string& message) { + if (!value) { + std::cerr << "FAIL: " << message << "\n"; + failures++; + } +} + +int main(int argc, char** argv) { + if (argc != 2) { + std::cerr << "usage: builtin_mod_manifests_test \n"; + return 2; + } + const fs::path root(argv[1]); + int parsed = 0; + bool saw_8mb = false; + for (const auto& entry : fs::recursive_directory_iterator(root)) { + if (!entry.is_regular_file() || entry.path().filename() != "manifest.toml") + continue; + ModPackage package; + std::string error; + const bool ok = ModPackageManager::read_manifest(entry.path(), package, &error); + check(ok, entry.path().string() + ": " + error); + if (!ok) continue; + parsed++; + const fs::path version_dir = entry.path().parent_path(); + check(package.version == version_dir.filename().string(), + entry.path().string() + ": version does not match its directory"); + check(package.id == version_dir.parent_path().filename().string(), + entry.path().string() + ": id does not match its directory"); + if (package.id == "psx.enhancement.8mb-ram") { + saw_8mb = true; + check(package.features.size() == 1 && package.features[0].id == "8mb-ram", + "8 MB package exposes exactly the 8mb-ram feature"); + check(!package.features.empty() && !package.features[0].default_enabled, + "8 MB RAM is opt-in (default disabled)"); + check(!package.features.empty() && package.features[0].hidden, + "8 MB RAM is hidden by default"); + check(package.plugins.size() == 1 && package.plugins[0].id == "psx.8mb-ram" && + package.plugins[0].feature_id == "8mb-ram", + "8 MB feature activates the psx.8mb-ram plugin"); + check(package.targets.size() == 1 && package.targets[0].game_id == "*", + "8 MB package applies to every game"); + } + } + check(parsed > 0, "no builtin manifests found under " + root.string()); + check(saw_8mb, "psx.enhancement.8mb-ram builtin package missing"); + if (failures == 0) + std::cout << "PASS builtin mod manifests (" << parsed << " packages)\n"; + return failures ? 1 : 0; +}