mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-26 18:25:35 -04:00
2ad2725548
Adapted from the original feature commits, retaining their author credit: [82695b75](https://github.com/FractalEngineer/psxrecomp/commit/82695b75d79610ca7a99783adf9dd5195edfcdd0) [5633e868](https://github.com/FractalEngineer/psxrecomp/commit/5633e86878611a14d3a78e8f9708452a07bc7238) [bbd01ccf](https://github.com/FractalEngineer/psxrecomp/commit/bbd01ccfc91c1d9ebe199dad071df64e5b13d06d) [39d478db](https://github.com/FractalEngineer/psxrecomp/commit/39d478db83132815c2c8c593fc719c4bf67301b0) Source scope and current-master validation: docs/internal/upstream/gte-projection-distance-scale.md Co-authored-by: Yves <calibratedbeats@gmail.com>
34 lines
1.3 KiB
C++
34 lines
1.3 KiB
C++
#include "projection_scale_config.hpp"
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <cstdio>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
|
|
int main() {
|
|
const auto file = std::filesystem::temp_directory_path() /
|
|
("psx-projection-" + std::to_string(std::chrono::steady_clock::now().time_since_epoch().count()) + ".toml");
|
|
struct Cleanup {
|
|
std::filesystem::path path;
|
|
~Cleanup() { std::error_code ec; std::filesystem::remove(path, ec); }
|
|
} cleanup{file};
|
|
auto load = [&](const char* text) {
|
|
{ std::ofstream out(file); out << text; }
|
|
return psx_projection_scale_load_config(file);
|
|
};
|
|
if (load("[game]\nname='fixture'\n") != 1.0 ||
|
|
load("[video]\naspect='4:3'\n") != 1.0 ||
|
|
load("[video]\nfov_scale=1.0\n") != 1.0 ||
|
|
load("[video]\nfov_scale=2.0\n") != 2.0 ||
|
|
load("[video]\nfov_scale=8.0\n") != 8.0) return 1;
|
|
for (const char* value : {"0.0", "-1.0", "9.0", "nan", "inf", "'wide'"}) {
|
|
bool rejected = false;
|
|
const std::string text = std::string("[video]\nfov_scale=") + value + "\n";
|
|
try { load(text.c_str()); }
|
|
catch (const std::exception&) { rejected = true; }
|
|
if (!rejected) { std::fprintf(stderr, "accepted invalid scale %s\n", value); return 1; }
|
|
}
|
|
return 0;
|
|
}
|