mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #238 from adriadam10/feat/playgo-language-todo
feat(libScePlayGo): fix error codes, implement the language mask and to-do list
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
add_library(libScePlayGo SHARED EXCLUDE_FROM_ALL Export.cpp)
|
||||
target_include_directories(libScePlayGo PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
configure_windows_unwind(libScePlayGo)
|
||||
|
||||
if(MINGW)
|
||||
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
|
||||
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_test_executable(guest_playgo_tests ${LIBS_INCLUDE_DIR}/tests/GuestPlayGo.cpp)
|
||||
target_include_directories(guest_playgo_tests PRIVATE ${LIBS_INCLUDE_DIR})
|
||||
target_link_libraries(guest_playgo_tests PRIVATE libScePlayGo libc)
|
||||
configure_windows_unwind(guest_playgo_tests)
|
||||
add_test(NAME guest_playgo COMMAND guest_playgo_tests)
|
||||
if(WIN32)
|
||||
set_tests_properties(guest_playgo PROPERTIES ENVIRONMENT_MODIFICATION
|
||||
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libScePlayGo>")
|
||||
endif()
|
||||
endif()
|
||||
@@ -9,16 +9,20 @@
|
||||
#include <string>
|
||||
|
||||
// The game is fully installed on the host, so every chunk is local and nothing is pending.
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_POINTER = static_cast<int>(0x80B20004);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_HANDLE = static_cast<int>(0x80B20005);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_POINTER = static_cast<int>(0x80B2000A);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_HANDLE = static_cast<int>(0x80B20009);
|
||||
static constexpr int PLAYGO_HANDLE = 1;
|
||||
static constexpr int8_t PLAYGO_LOCUS_NOT_DOWNLOADED = 0;
|
||||
static constexpr int8_t PLAYGO_LOCUS_LOCAL_SLOW = 2;
|
||||
static constexpr int8_t PLAYGO_LOCUS_LOCAL_FAST = 3;
|
||||
static constexpr uint64_t PLAYGO_LANGUAGE_MASK_ALL = ~0ull;
|
||||
static constexpr int32_t PLAYGO_INSTALL_SPEED_FULL = 2;
|
||||
|
||||
static int32_t g_installSpeed = PLAYGO_INSTALL_SPEED_FULL;
|
||||
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_CHUNK_ID = static_cast<int>(0x80B2000C);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_SIZE = static_cast<int>(0x80B2000D);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_SIZE = static_cast<int>(0x80B2000B);
|
||||
static constexpr int SCE_PLAYGO_ERROR_BAD_LOCUS = static_cast<int>(0x80B20010);
|
||||
|
||||
// The package's chunk table is not part of the dump, so the chunk set comes from the title's
|
||||
// playgo-chunkdefs.xml: every listed chunk plus chunks 0 through the default chunk. Games probe
|
||||
@@ -96,10 +100,10 @@ int APS5_VABI scePlayGoGetInstallSpeed(int handle, int32_t* out_speed) {
|
||||
}
|
||||
|
||||
int APS5_VABI scePlayGoGetLanguageMask(int handle, uint64_t* out_language_mask) {
|
||||
(void)handle;
|
||||
(void)out_language_mask;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
if (handle != PLAYGO_HANDLE) return SCE_PLAYGO_ERROR_BAD_HANDLE;
|
||||
if (!out_language_mask) return SCE_PLAYGO_ERROR_BAD_POINTER;
|
||||
*out_language_mask = PLAYGO_LANGUAGE_MASK_ALL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI scePlayGoGetLocus(int handle, const uint16_t* chunk_ids, uint32_t number_of_entries, int8_t* out_loci) {
|
||||
@@ -176,11 +180,16 @@ int APS5_VABI scePlayGoSetInstallSpeed(int handle, int32_t speed) {
|
||||
}
|
||||
|
||||
int APS5_VABI scePlayGoSetToDoList(int handle, const PlayGoToDo* todo_list, uint32_t number_of_entries) {
|
||||
(void)handle;
|
||||
(void)todo_list;
|
||||
(void)number_of_entries;
|
||||
NotImplemented_nid_no_patch(__func__);
|
||||
return 0;
|
||||
if (handle != PLAYGO_HANDLE) return SCE_PLAYGO_ERROR_BAD_HANDLE;
|
||||
if (!todo_list) return SCE_PLAYGO_ERROR_BAD_POINTER;
|
||||
if (number_of_entries == 0) return SCE_PLAYGO_ERROR_BAD_SIZE;
|
||||
const auto& valid = ValidChunks();
|
||||
for (uint32_t index = 0; index < number_of_entries; ++index) {
|
||||
if (!valid.contains(todo_list[index].chunk_id)) return SCE_PLAYGO_ERROR_BAD_CHUNK_ID;
|
||||
const int8_t locus = todo_list[index].locus;
|
||||
if (locus != PLAYGO_LOCUS_NOT_DOWNLOADED && locus != PLAYGO_LOCUS_LOCAL_SLOW && locus != PLAYGO_LOCUS_LOCAL_FAST) return SCE_PLAYGO_ERROR_BAD_LOCUS;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int APS5_VABI scePlayGoTerminate(void) {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
#include "SceTypes.hpp"
|
||||
#include "prx/libc/include/general/VabiMacros.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" {
|
||||
int APS5_VABI scePlayGoInitialize(const PlayGoInitParams*);
|
||||
int APS5_VABI scePlayGoOpen(int*, const void*);
|
||||
int APS5_VABI scePlayGoClose(int);
|
||||
int APS5_VABI scePlayGoGetLanguageMask(int, std::uint64_t*);
|
||||
int APS5_VABI scePlayGoSetToDoList(int, const PlayGoToDo*, std::uint32_t);
|
||||
int APS5_VABI scePlayGoGetToDoList(int, PlayGoToDo*, std::uint32_t, std::uint32_t*);
|
||||
int APS5_VABI scePlayGoGetLocus(int, const std::uint16_t*, std::uint32_t, std::int8_t*);
|
||||
}
|
||||
|
||||
static void Require(bool value) { if (!value) std::abort(); }
|
||||
|
||||
int main() {
|
||||
constexpr int badHandle = static_cast<int>(0x80B20009);
|
||||
constexpr int badPointer = static_cast<int>(0x80B2000A);
|
||||
constexpr int badSize = static_cast<int>(0x80B2000B);
|
||||
constexpr int badChunkId = static_cast<int>(0x80B2000C);
|
||||
constexpr int badLocus = static_cast<int>(0x80B20010);
|
||||
|
||||
PlayGoInitParams init{};
|
||||
int handle = 0;
|
||||
Require(scePlayGoInitialize(nullptr) == badPointer);
|
||||
Require(scePlayGoInitialize(&init) == 0);
|
||||
Require(scePlayGoOpen(nullptr, nullptr) == badPointer);
|
||||
Require(scePlayGoOpen(&handle, nullptr) == 0);
|
||||
|
||||
std::uint64_t mask = 0;
|
||||
Require(scePlayGoGetLanguageMask(handle + 1, &mask) == badHandle);
|
||||
Require(scePlayGoGetLanguageMask(handle, nullptr) == badPointer);
|
||||
Require(scePlayGoGetLanguageMask(handle, &mask) == 0 && mask == ~0ull);
|
||||
|
||||
PlayGoToDo todo[2] = {{0, 3, 0}, {0, 0, 0}};
|
||||
Require(scePlayGoSetToDoList(handle + 1, todo, 2) == badHandle);
|
||||
Require(scePlayGoSetToDoList(handle, nullptr, 2) == badPointer);
|
||||
Require(scePlayGoSetToDoList(handle, todo, 0) == badSize);
|
||||
Require(scePlayGoSetToDoList(handle, todo, 2) == 0);
|
||||
todo[1].locus = 1;
|
||||
Require(scePlayGoSetToDoList(handle, todo, 2) == badLocus);
|
||||
todo[1] = {0xFFFF, 3, 0};
|
||||
Require(scePlayGoSetToDoList(handle, todo, 2) == badChunkId);
|
||||
|
||||
std::uint32_t entries = 1;
|
||||
Require(scePlayGoGetToDoList(handle, todo, 2, &entries) == 0 && entries == 0);
|
||||
const std::uint16_t chunk = 0;
|
||||
std::int8_t locus = 0;
|
||||
Require(scePlayGoGetLocus(handle, &chunk, 0, &locus) == badSize);
|
||||
Require(scePlayGoGetLocus(handle, &chunk, 1, &locus) == 0 && locus == 3);
|
||||
Require(scePlayGoClose(handle + 1) == badHandle);
|
||||
Require(scePlayGoClose(handle) == 0);
|
||||
}
|
||||
Reference in New Issue
Block a user