mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-30 12:25:49 +00:00
ProsperoEden declares the setter with the mode as its argument and the getter with an int output, and measured on a PS5 that modes 0 and 1 are accepted, 2 to 7 return 0x80020016 and 1 is the default. Both threw as discovered stubs. Other modes and a null output throw. Co-Authored-By: Claude Opus 5.5 <[email protected]>
43 lines
1.5 KiB
C++
43 lines
1.5 KiB
C++
#include "prx/libkernel_sys/include/Api.hpp"
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <exception>
|
|
|
|
namespace {
|
|
|
|
void Require(bool condition, const char* what) {
|
|
if (condition) return;
|
|
std::fprintf(stderr, "%s\n", what);
|
|
std::abort();
|
|
}
|
|
|
|
bool Throws(void (*action)()) {
|
|
try {
|
|
action();
|
|
} catch (const std::exception&) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|
|
|
|
int main() {
|
|
constexpr int invalid = static_cast<int>(0x80020016u);
|
|
int mode = -1;
|
|
Require(sceKernelGetCpumodeGame(&mode) == 0 && mode == 1, "the game CPU mode does not start at 1");
|
|
Require(sceKernelSetCpumodeGame(0) == 0, "mode 0 was refused");
|
|
Require(sceKernelGetCpumodeGame(&mode) == 0 && mode == 0, "mode 0 was not reported back");
|
|
for (int refused = 2; refused <= 7; ++refused) {
|
|
Require(sceKernelSetCpumodeGame(refused) == invalid, "a mode from 2 to 7 was not refused with EINVAL");
|
|
Require(sceKernelGetCpumodeGame(&mode) == 0 && mode == 0, "a refused mode changed the game CPU mode");
|
|
}
|
|
Require(sceKernelSetCpumodeGame(1) == 0, "mode 1 was refused");
|
|
Require(sceKernelGetCpumodeGame(&mode) == 0 && mode == 1, "mode 1 was not reported back");
|
|
Require(Throws([] { sceKernelSetCpumodeGame(8); }), "an unmeasured mode did not throw");
|
|
Require(Throws([] { sceKernelSetCpumodeGame(-1); }), "a negative mode did not throw");
|
|
Require(Throws([] { sceKernelGetCpumodeGame(nullptr); }), "a null output did not throw");
|
|
std::puts("game CPU mode tests passed");
|
|
return 0;
|
|
}
|