Skip to content

Commit

Permalink
libraries: Add libSceRazorCpu HLE skeleton. (shadps4-emu#1624)
Browse files Browse the repository at this point in the history
* Remove save migration code (shadps4-emu#1621)

* Kernel Fixes (shadps4-emu#1605)

* scePthreadSetprio Changes

FindThread uses posix error codes, so the function export should apply the ORBIS wrapper to convert these. Since it uses posix codes, I've also renamed the function to align with other posix functions. Lastly, this fixes a compile warning about ret sometimes not getting initialized.

* Implement posix_munmap

Used by Hatsune Miku Project Diva X during intros. May help with stability on Linux, probably won't change anything on Windows.

* Exports

Some missing function exports I've seen in my tests.
sceKernelAvailableFlexibleMemorySize export is used in Final Fantasy XV Episode Duscae
posix_pthread_setprio and posix_pthread_getschedparam are used by Spider-Man Miles Morales
scePthreadKeyDelete is used in UE4 games.

I've also added in a typo fix related to my previous PR.

* libScePosix export for posix_pthread_attr_setguardsize

Used in Hatsune Miku Project Diva X v1.02

* libraries: Add libSceRazorCpu HLE skeleton.

---------

Co-authored-by: ¥IGA <164882787+Xphalnos@users.noreply.github.com>
Co-authored-by: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 30, 2024
1 parent 7bf168e commit 99ac10a
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ set(SYSTEM_LIBS src/core/libraries/system/commondialog.cpp
src/core/libraries/remote_play/remoteplay.h
src/core/libraries/share_play/shareplay.cpp
src/core/libraries/share_play/shareplay.h
src/core/libraries/razor_cpu/razor_cpu.cpp
src/core/libraries/razor_cpu/razor_cpu.h
)

set(VIDEOOUT_LIB src/core/libraries/videoout/buffer.h
Expand Down
55 changes: 37 additions & 18 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

#include <fstream>
#include <string>
#include <common/version.h>
#include <fmt/core.h>
#include <fmt/xchar.h> // for wstring support
#include <toml.hpp>
#include "common/logging/formatter.h"

#include "common/path_util.h"
#include "config.h"
#include "logging/formatter.h"
#include "version.h"

namespace toml {
template <typename TC, typename K>
Expand Down Expand Up @@ -81,7 +82,8 @@ std::vector<std::string> m_pkg_viewer;
std::vector<std::string> m_elf_viewer;
std::vector<std::string> m_recent_files;
std::string emulator_language = "en";
// Settings

// Language
u32 m_language = 1; // english

bool isNeoMode() {
Expand Down Expand Up @@ -334,6 +336,7 @@ void setMainWindowGeometry(u32 x, u32 y, u32 w, u32 h) {
main_window_geometry_w = w;
main_window_geometry_h = h;
}

bool addGameInstallDir(const std::filesystem::path& dir) {
if (std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir) ==
settings_install_dirs.end()) {
Expand All @@ -342,47 +345,60 @@ bool addGameInstallDir(const std::filesystem::path& dir) {
}
return false;
}

void removeGameInstallDir(const std::filesystem::path& dir) {
auto iterator = std::find(settings_install_dirs.begin(), settings_install_dirs.end(), dir);
if (iterator != settings_install_dirs.end()) {
settings_install_dirs.erase(iterator);
}
}

void setAddonInstallDir(const std::filesystem::path& dir) {
settings_addon_install_dir = dir;
}

void setMainWindowTheme(u32 theme) {
mw_themes = theme;
}

void setIconSize(u32 size) {
m_icon_size = size;
}

void setIconSizeGrid(u32 size) {
m_icon_size_grid = size;
}

void setSliderPosition(u32 pos) {
m_slider_pos = pos;
}

void setSliderPositionGrid(u32 pos) {
m_slider_pos_grid = pos;
}

void setTableMode(u32 mode) {
m_table_mode = mode;
}

void setMainWindowWidth(u32 width) {
m_window_size_W = width;
}

void setMainWindowHeight(u32 height) {
m_window_size_H = height;
}

void setPkgViewer(const std::vector<std::string>& pkgList) {
m_pkg_viewer.resize(pkgList.size());
m_pkg_viewer = pkgList;
}

void setElfViewer(const std::vector<std::string>& elfList) {
m_elf_viewer.resize(elfList.size());
m_elf_viewer = elfList;
}

void setRecentFiles(const std::vector<std::string>& recentFiles) {
m_recent_files.resize(recentFiles.size());
m_recent_files = recentFiles;
Expand All @@ -395,55 +411,71 @@ void setEmulatorLanguage(std::string language) {
u32 getMainWindowGeometryX() {
return main_window_geometry_x;
}

u32 getMainWindowGeometryY() {
return main_window_geometry_y;
}

u32 getMainWindowGeometryW() {
return main_window_geometry_w;
}

u32 getMainWindowGeometryH() {
return main_window_geometry_h;
}

const std::vector<std::filesystem::path>& getGameInstallDirs() {
return settings_install_dirs;
}

std::filesystem::path getAddonInstallDir() {
if (settings_addon_install_dir.empty()) {
// Default for users without a config file or a config file from before this option existed
return Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "addcont";
}
return settings_addon_install_dir;
}

u32 getMainWindowTheme() {
return mw_themes;
}

u32 getIconSize() {
return m_icon_size;
}

u32 getIconSizeGrid() {
return m_icon_size_grid;
}

u32 getSliderPosition() {
return m_slider_pos;
}

u32 getSliderPositionGrid() {
return m_slider_pos_grid;
}

u32 getTableMode() {
return m_table_mode;
}

u32 getMainWindowWidth() {
return m_window_size_W;
}

u32 getMainWindowHeight() {
return m_window_size_H;
}

std::vector<std::string> getPkgViewer() {
return m_pkg_viewer;
}

std::vector<std::string> getElfViewer() {
return m_elf_viewer;
}

std::vector<std::string> getRecentFiles() {
return m_recent_files;
}
Expand All @@ -455,6 +487,7 @@ std::string getEmulatorLanguage() {
u32 GetLanguage() {
return m_language;
}

void load(const std::filesystem::path& path) {
// If the configuration file does not exist, create it and return
std::error_code error;
Expand Down Expand Up @@ -545,18 +578,6 @@ void load(const std::filesystem::path& path) {
m_window_size_W = toml::find_or<int>(gui, "mw_width", 0);
m_window_size_H = toml::find_or<int>(gui, "mw_height", 0);

// TODO Migration code, after a major release this should be removed.
auto old_game_install_dir = toml::find_fs_path_or(gui, "installDir", {});
if (!old_game_install_dir.empty()) {
addGameInstallDir(std::filesystem::path{old_game_install_dir});
} else {
const auto install_dir_array =
toml::find_or<std::vector<std::string>>(gui, "installDirs", {});
for (const auto& dir : install_dir_array) {
addGameInstallDir(std::filesystem::path{dir});
}
}

settings_addon_install_dir = toml::find_fs_path_or(gui, "addonInstallDir", {});
main_window_geometry_x = toml::find_or<int>(gui, "geometry_x", 0);
main_window_geometry_y = toml::find_or<int>(gui, "geometry_y", 0);
Expand All @@ -575,6 +596,7 @@ void load(const std::filesystem::path& path) {
m_language = toml::find_or<int>(settings, "consoleLanguage", 1);
}
}

void save(const std::filesystem::path& path) {
toml::value data;

Expand Down Expand Up @@ -655,9 +677,6 @@ void save(const std::filesystem::path& path) {

data["Settings"]["consoleLanguage"] = m_language;

// TODO Migration code, after a major release this should be removed.
data.at("GUI").as_table().erase("installDir");

std::ofstream file(path, std::ios::binary);
file << data;
file.close();
Expand Down
1 change: 1 addition & 0 deletions src/common/logging/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) {
SUB(Lib, Fiber) \
SUB(Lib, Vdec2) \
SUB(Lib, Videodec) \
SUB(Lib, RazorCpu) \
CLS(Frontend) \
CLS(Render) \
SUB(Render, Vulkan) \
Expand Down
1 change: 1 addition & 0 deletions src/common/logging/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ enum class Class : u8 {
Lib_Fiber, ///< The LibSceFiber implementation.
Lib_Vdec2, ///< The LibSceVideodec2 implementation.
Lib_Videodec, ///< The LibSceVideodec implementation.
Lib_RazorCpu, ///< The LibRazorCpu implementation.
Frontend, ///< Emulator UI
Render, ///< Video Core
Render_Vulkan, ///< Vulkan backend
Expand Down
2 changes: 2 additions & 0 deletions src/core/libraries/libs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "core/libraries/pad/pad.h"
#include "core/libraries/playgo/playgo.h"
#include "core/libraries/random/random.h"
#include "core/libraries/razor_cpu/razor_cpu.h"
#include "core/libraries/remote_play/remoteplay.h"
#include "core/libraries/rtc/rtc.h"
#include "core/libraries/save_data/dialog/savedatadialog.h"
Expand Down Expand Up @@ -87,6 +88,7 @@ void InitHLELibs(Core::Loader::SymbolsResolver* sym) {
Libraries::SharePlay::RegisterlibSceSharePlay(sym);
Libraries::Remoteplay::RegisterlibSceRemoteplay(sym);
Libraries::Videodec::RegisterlibSceVideodec(sym);
Libraries::RazorCpu::RegisterlibSceRazorCpu(sym);
}

} // namespace Libraries
Loading

0 comments on commit 99ac10a

Please sign in to comment.