Skip to content

Commit 863d5e7

Browse files
Merge branch 'main' into avplayer-improvements
2 parents 991e3de + b0a12c0 commit 863d5e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+168
-321
lines changed

CMakeLists.txt

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ git_branch_name(GIT_BRANCH)
114114
string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S")
115115

116116
message("start git things")
117+
117118
# Try to get the upstream remote and branch
118119
message("check for remote and branch")
119120
execute_process(
@@ -123,6 +124,7 @@ execute_process(
123124
ERROR_QUIET
124125
OUTPUT_STRIP_TRAILING_WHITESPACE
125126
)
127+
126128
# If there's no upstream set or the command failed, check remote.pushDefault
127129
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
128130
message("check default push")
@@ -134,15 +136,48 @@ if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
134136
OUTPUT_STRIP_TRAILING_WHITESPACE
135137
)
136138
endif()
139+
137140
# If running in GitHub Actions and the above fails
138141
if (GIT_REMOTE_RESULT OR GIT_REMOTE_NAME STREQUAL "")
139142
message("check github")
140143
set(GIT_REMOTE_NAME "origin")
141144

142-
if (DEFINED ENV{GITHUB_HEAD_REF}) # PR branch name
143-
set(GIT_BRANCH "pr-$ENV{GITHUB_HEAD_REF}")
144-
elseif (DEFINED ENV{GITHUB_REF}) # Normal branch name
145-
string(REGEX REPLACE "^refs/[^/]*/" "" GIT_BRANCH "$ENV{GITHUB_REF}")
145+
# Retrieve environment variables
146+
if (DEFINED ENV{GITHUB_HEAD_REF} AND NOT "$ENV{GITHUB_HEAD_REF}" STREQUAL "")
147+
message("github head ref: $ENV{GITHUB_HEAD_REF}")
148+
set(GITHUB_HEAD_REF "$ENV{GITHUB_HEAD_REF}")
149+
else()
150+
set(GITHUB_HEAD_REF "")
151+
endif()
152+
153+
if (DEFINED ENV{GITHUB_REF} AND NOT "$ENV{GITHUB_REF}" STREQUAL "")
154+
message("github ref: $ENV{GITHUB_REF}")
155+
string(REGEX REPLACE "^refs/[^/]*/" "" GITHUB_BRANCH "$ENV{GITHUB_REF}")
156+
string(REGEX MATCH "refs/pull/([0-9]+)/merge" MATCHED_REF "$ENV{GITHUB_REF}")
157+
if (MATCHED_REF)
158+
set(PR_NUMBER "${CMAKE_MATCH_1}")
159+
set(GITHUB_BRANCH "")
160+
message("PR number: ${PR_NUMBER}")
161+
else()
162+
set(PR_NUMBER "")
163+
endif()
164+
else()
165+
set(GITHUB_BRANCH "")
166+
set(PR_NUMBER "")
167+
endif()
168+
169+
if (NOT "${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_HEAD_REF}" STREQUAL "")
170+
set(GIT_BRANCH "pr-${PR_NUMBER}-${GITHUB_HEAD_REF}")
171+
elseif (NOT "${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_BRANCH}" STREQUAL "")
172+
set(GIT_BRANCH "pr-${PR_NUMBER}-${GITHUB_BRANCH}")
173+
elseif (NOT "${PR_NUMBER}" STREQUAL "")
174+
set(GIT_BRANCH "pr-${PR_NUMBER}")
175+
elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_HEAD_REF}" STREQUAL "")
176+
set(GIT_BRANCH "${GITHUB_HEAD_REF}")
177+
elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_BRANCH}" STREQUAL "")
178+
set(GIT_BRANCH "${GITHUB_BRANCH}")
179+
elseif ("${PR_NUMBER}" STREQUAL "" AND NOT "${GITHUB_REF}" STREQUAL "")
180+
set(GIT_BRANCH "${GITHUB_REF}")
146181
else()
147182
message("couldn't find branch")
148183
set(GIT_BRANCH "detached-head")
@@ -299,6 +334,8 @@ set(KERNEL_LIB src/core/libraries/kernel/sync/mutex.cpp
299334
src/core/libraries/kernel/threads/thread_state.h
300335
src/core/libraries/kernel/process.cpp
301336
src/core/libraries/kernel/process.h
337+
src/core/libraries/kernel/debug.cpp
338+
src/core/libraries/kernel/debug.h
302339
src/core/libraries/kernel/equeue.cpp
303340
src/core/libraries/kernel/equeue.h
304341
src/core/libraries/kernel/file_system.cpp

src/common/config.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ static double trophyNotificationDuration = 6.0;
7575
static bool useUnifiedInputConfig = true;
7676
static bool overrideControllerColor = false;
7777
static int controllerCustomColorRGB[3] = {0, 0, 255};
78-
static bool separateupdatefolder = false;
7978
static bool compatibilityData = false;
8079
static bool checkCompatibilityOnStartup = false;
8180
static std::string trophyKey;
@@ -352,10 +351,6 @@ void setVkGuestMarkersEnabled(bool enable) {
352351
vkGuestMarkers = enable;
353352
}
354353

355-
bool getSeparateUpdateEnabled() {
356-
return separateupdatefolder;
357-
}
358-
359354
bool getCompatibilityEnabled() {
360355
return compatibilityData;
361356
}
@@ -517,10 +512,6 @@ void setIsMotionControlsEnabled(bool use) {
517512
isMotionControlsEnabled = use;
518513
}
519514

520-
void setSeparateUpdateEnabled(bool use) {
521-
separateupdatefolder = use;
522-
}
523-
524515
void setCompatibilityEnabled(bool use) {
525516
compatibilityData = use;
526517
}
@@ -781,7 +772,6 @@ void load(const std::filesystem::path& path) {
781772
isAutoUpdate = toml::find_or<bool>(general, "autoUpdate", false);
782773
isAlwaysShowChangelog = toml::find_or<bool>(general, "alwaysShowChangelog", false);
783774
isSideTrophy = toml::find_or<std::string>(general, "sideTrophy", "right");
784-
separateupdatefolder = toml::find_or<bool>(general, "separateUpdateEnabled", false);
785775
compatibilityData = toml::find_or<bool>(general, "compatibilityEnabled", false);
786776
checkCompatibilityOnStartup =
787777
toml::find_or<bool>(general, "checkCompatibilityOnStartup", false);
@@ -977,7 +967,6 @@ void save(const std::filesystem::path& path) {
977967
data["General"]["autoUpdate"] = isAutoUpdate;
978968
data["General"]["alwaysShowChangelog"] = isAlwaysShowChangelog;
979969
data["General"]["sideTrophy"] = isSideTrophy;
980-
data["General"]["separateUpdateEnabled"] = separateupdatefolder;
981970
data["General"]["compatibilityEnabled"] = compatibilityData;
982971
data["General"]["checkCompatibilityOnStartup"] = checkCompatibilityOnStartup;
983972
data["Input"]["cursorState"] = cursorState;
@@ -1150,7 +1139,6 @@ void setDefaultValues() {
11501139
emulator_language = "en_US";
11511140
m_language = 1;
11521141
gpuId = -1;
1153-
separateupdatefolder = false;
11541142
compatibilityData = false;
11551143
checkCompatibilityOnStartup = false;
11561144
backgroundImageOpacity = 50;

src/common/config.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ bool getPlayBGM();
3535
int getBGMvolume();
3636
bool getisTrophyPopupDisabled();
3737
bool getEnableDiscordRPC();
38-
bool getSeparateUpdateEnabled();
3938
bool getCompatibilityEnabled();
4039
bool getCheckCompatibilityOnStartup();
4140
int getBackgroundImageOpacity();
@@ -105,7 +104,6 @@ void setNeoMode(bool enable);
105104
void setUserName(const std::string& type);
106105
void setUpdateChannel(const std::string& type);
107106
void setChooseHomeTab(const std::string& type);
108-
void setSeparateUpdateEnabled(bool use);
109107
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config);
110108
void setAllGameInstallDirs(const std::vector<GameInstallDir>& dirs_config);
111109
void setSaveDataPath(const std::filesystem::path& path);

src/core/libraries/kernel/debug.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
2+
// SPDX-License-Identifier: GPL-2.0-or-later
3+
4+
#include "common/assert.h"
5+
#include "core/libraries/kernel/file_system.h"
6+
#include "core/libraries/kernel/orbis_error.h"
7+
#include "core/libraries/libs.h"
8+
9+
namespace Libraries::Kernel {
10+
11+
void PS4_SYSV_ABI sceKernelDebugOutText(void* unk, char* text) {
12+
sceKernelWrite(1, text, strlen(text));
13+
return;
14+
}
15+
16+
void RegisterDebug(Core::Loader::SymbolsResolver* sym) {
17+
LIB_FUNCTION("9JYNqN6jAKI", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugOutText);
18+
}
19+
20+
} // namespace Libraries::Kernel

src/core/libraries/kernel/debug.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
2+
// SPDX-License-Identifier: GPL-2.0-or-later
3+
4+
#pragma once
5+
6+
namespace Core::Loader {
7+
class SymbolsResolver;
8+
}
9+
10+
namespace Libraries::Kernel {
11+
12+
void RegisterDebug(Core::Loader::SymbolsResolver* sym);
13+
14+
} // namespace Libraries::Kernel

src/core/libraries/kernel/kernel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "common/va_ctx.h"
1313
#include "core/file_sys/fs.h"
1414
#include "core/libraries/error_codes.h"
15+
#include "core/libraries/kernel/debug.h"
1516
#include "core/libraries/kernel/equeue.h"
1617
#include "core/libraries/kernel/file_system.h"
1718
#include "core/libraries/kernel/kernel.h"
@@ -219,6 +220,7 @@ void RegisterKernel(Core::Loader::SymbolsResolver* sym) {
219220
Libraries::Kernel::RegisterProcess(sym);
220221
Libraries::Kernel::RegisterException(sym);
221222
Libraries::Kernel::RegisterAio(sym);
223+
Libraries::Kernel::RegisterDebug(sym);
222224

223225
LIB_OBJ("f7uOxY9mM1U", "libkernel", 1, "libkernel", 1, 1, &g_stack_chk_guard);
224226
LIB_FUNCTION("PfccT7qURYE", "libkernel", 1, "libkernel", 1, 1, kernel_ioctl);

src/core/libraries/kernel/process.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ int PS4_SYSV_ABI sceKernelGetModuleInfoFromAddr(VAddr addr, int flags,
127127
return ORBIS_OK;
128128
}
129129

130+
s32 PS4_SYSV_ABI exit(s32 status) {
131+
UNREACHABLE_MSG("Exiting with status code {}", status);
132+
return 0;
133+
}
134+
130135
void RegisterProcess(Core::Loader::SymbolsResolver* sym) {
131136
LIB_FUNCTION("WB66evu8bsU", "libkernel", 1, "libkernel", 1, 1, sceKernelGetCompiledSdkVersion);
132137
LIB_FUNCTION("WslcK1FQcGI", "libkernel", 1, "libkernel", 1, 1, sceKernelIsNeoMode);
@@ -136,6 +141,7 @@ void RegisterProcess(Core::Loader::SymbolsResolver* sym) {
136141
LIB_FUNCTION("LwG8g3niqwA", "libkernel", 1, "libkernel", 1, 1, sceKernelDlsym);
137142
LIB_FUNCTION("RpQJJVKTiFM", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfoForUnwind);
138143
LIB_FUNCTION("f7KBOafysXo", "libkernel", 1, "libkernel", 1, 1, sceKernelGetModuleInfoFromAddr);
144+
LIB_FUNCTION("6Z83sYWFlA8", "libkernel", 1, "libkernel", 1, 1, exit);
139145
}
140146

141147
} // namespace Libraries::Kernel

src/core/libraries/kernel/threads/exception.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-License-Identifier: GPL-2.0-or-later
33

44
#include "common/assert.h"
5+
#include "core/libraries/kernel/orbis_error.h"
56
#include "core/libraries/kernel/threads/exception.h"
67
#include "core/libraries/kernel/threads/pthread.h"
78
#include "core/libraries/libs.h"
@@ -148,13 +149,19 @@ int PS4_SYSV_ABI sceKernelRaiseException(PthreadT thread, int signum) {
148149
return 0;
149150
}
150151

151-
int PS4_SYSV_ABI sceKernelDebugRaiseException() {
152-
UNREACHABLE();
152+
s32 PS4_SYSV_ABI sceKernelDebugRaiseException(s32 error, s64 unk) {
153+
if (unk != 0) {
154+
return ORBIS_KERNEL_ERROR_EINVAL;
155+
}
156+
UNREACHABLE_MSG("error {:#x}", error);
153157
return 0;
154158
}
155159

156-
int PS4_SYSV_ABI sceKernelDebugRaiseExceptionOnReleaseMode() {
157-
UNREACHABLE();
160+
s32 PS4_SYSV_ABI sceKernelDebugRaiseExceptionOnReleaseMode(s32 error, s64 unk) {
161+
if (unk != 0) {
162+
return ORBIS_KERNEL_ERROR_EINVAL;
163+
}
164+
UNREACHABLE_MSG("error {:#x}", error);
158165
return 0;
159166
}
160167

@@ -163,7 +170,7 @@ void RegisterException(Core::Loader::SymbolsResolver* sym) {
163170
LIB_FUNCTION("WkwEd3N7w0Y", "libkernel_unity", 1, "libkernel", 1, 1,
164171
sceKernelInstallExceptionHandler);
165172
LIB_FUNCTION("Qhv5ARAoOEc", "libkernel_unity", 1, "libkernel", 1, 1,
166-
sceKernelRemoveExceptionHandler)
173+
sceKernelRemoveExceptionHandler);
167174
LIB_FUNCTION("OMDRKKAZ8I4", "libkernel", 1, "libkernel", 1, 1, sceKernelDebugRaiseException);
168175
LIB_FUNCTION("zE-wXIZjLoM", "libkernel", 1, "libkernel", 1, 1,
169176
sceKernelDebugRaiseExceptionOnReleaseMode);

src/core/libraries/kernel/threads/pthread_spec.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ void RegisterSpec(Core::Loader::SymbolsResolver* sym) {
147147
LIB_FUNCTION("0-KXaS70xy4", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_getspecific);
148148
LIB_FUNCTION("WrOLvHU0yQM", "libScePosix", 1, "libkernel", 1, 1, posix_pthread_setspecific);
149149

150+
// Posix-Kernel
151+
LIB_FUNCTION("mqULNdimTn0", "libkernel", 1, "libkernel", 1, 1, posix_pthread_key_create);
152+
LIB_FUNCTION("0-KXaS70xy4", "libkernel", 1, "libkernel", 1, 1, posix_pthread_getspecific);
153+
LIB_FUNCTION("WrOLvHU0yQM", "libkernel", 1, "libkernel", 1, 1, posix_pthread_setspecific);
154+
150155
// Orbis
151156
LIB_FUNCTION("geDaqgH9lTg", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_create));
152157
LIB_FUNCTION("PrdHuuDekhY", "libkernel", 1, "libkernel", 1, 1, ORBIS(posix_pthread_key_delete));

src/core/linker.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ void Linker::Execute(const std::vector<std::string> args) {
101101

102102
memory->SetupMemoryRegions(fmem_size, use_extended_mem1, use_extended_mem2);
103103

104+
// Simulate sceKernelInternalMemory mapping, a mapping usually performed during libkernel init.
105+
// Due to the large size of this mapping, failing to emulate it causes issues in some titles.
106+
// This mapping belongs in the system reserved area, which starts at address 0x880000000.
107+
static constexpr VAddr KernelAllocBase = 0x880000000ULL;
108+
static constexpr s64 InternalMemorySize = 0x1000000;
109+
void* addr_out{reinterpret_cast<void*>(KernelAllocBase)};
110+
111+
const s32 ret = Libraries::Kernel::sceKernelMapNamedFlexibleMemory(
112+
&addr_out, InternalMemorySize, 3, 0, "SceKernelInternalMemory");
113+
ASSERT_MSG(ret == 0, "Unable to perform sceKernelInternalMemory mapping");
114+
104115
main_thread.Run([this, module, args](std::stop_token) {
105116
Common::SetCurrentThreadName("GAME_MainThread");
106117
LoadSharedLibraries();
@@ -372,7 +383,8 @@ void* Linker::AllocateTlsForThread(bool is_primary) {
372383

373384
// If sceKernelMapNamedFlexibleMemory is being called from libkernel and addr = 0
374385
// it automatically places mappings in system reserved area instead of managed.
375-
static constexpr VAddr KernelAllocBase = 0x880000000ULL;
386+
// Since the system reserved area already has a mapping in it, this address is slightly higher.
387+
static constexpr VAddr KernelAllocBase = 0x881000000ULL;
376388

377389
// The kernel module has a few different paths for TLS allocation.
378390
// For SDK < 1.7 it allocates both main and secondary thread blocks using libc mspace/malloc.

src/qt_gui/gui_context_menus.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ class GuiContextMenus : public QObject {
140140
QString open_update_path;
141141
Common::FS::PathToQString(open_update_path, m_games[itemID].path);
142142
open_update_path += "-UPDATE";
143-
if (!std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) {
143+
if (std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) {
144144
QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path));
145145
} else {
146146
Common::FS::PathToQString(open_update_path, m_games[itemID].path);
147147
open_update_path += "-patch";
148-
if (!std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) {
148+
if (std::filesystem::exists(Common::FS::PathFromQString(open_update_path))) {
149149
QDesktopServices::openUrl(QUrl::fromLocalFile(open_update_path));
150150
} else {
151151
QMessageBox::critical(nullptr, tr("Error"),

src/qt_gui/main_window.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ MainWindow::~MainWindow() {
4545
bool MainWindow::Init() {
4646
auto start = std::chrono::steady_clock::now();
4747
// setup ui
48+
LoadTranslation();
4849
AddUiWidgets();
4950
CreateActions();
5051
CreateRecentGameActions();
5152
ConfigureGuiFromSettings();
52-
LoadTranslation();
5353
CreateDockWindows();
5454
CreateConnects();
5555
SetLastUsedTheme();

src/qt_gui/settings_dialog.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,6 @@ SettingsDialog::SettingsDialog(std::span<const QString> physical_devices,
318318
// General
319319
ui->consoleLanguageGroupBox->installEventFilter(this);
320320
ui->emulatorLanguageGroupBox->installEventFilter(this);
321-
ui->separateUpdatesCheckBox->installEventFilter(this);
322321
ui->showSplashCheckBox->installEventFilter(this);
323322
ui->discordRPCCheckbox->installEventFilter(this);
324323
ui->userName->installEventFilter(this);
@@ -450,8 +449,6 @@ void SettingsDialog::LoadValuesFromConfig() {
450449
QString translatedText_FullscreenMode =
451450
screenModeMap.key(QString::fromStdString(Config::getFullscreenMode()));
452451
ui->displayModeComboBox->setCurrentText(translatedText_FullscreenMode);
453-
ui->separateUpdatesCheckBox->setChecked(
454-
toml::find_or<bool>(data, "General", "separateUpdateEnabled", false));
455452
ui->gameSizeCheckBox->setChecked(toml::find_or<bool>(data, "GUI", "loadGameSizeEnabled", true));
456453
ui->showSplashCheckBox->setChecked(toml::find_or<bool>(data, "General", "showSplash", false));
457454
QString translatedText_logType = logTypeMap.key(QString::fromStdString(Config::getLogType()));
@@ -600,8 +597,6 @@ void SettingsDialog::updateNoteTextEdit(const QString& elementName) {
600597
text = tr("Console Language:\\nSets the language that the PS4 game uses.\\nIt's recommended to set this to a language the game supports, which will vary by region.");
601598
} else if (elementName == "emulatorLanguageGroupBox") {
602599
text = tr("Emulator Language:\\nSets the language of the emulator's user interface.");
603-
} else if (elementName == "separateUpdatesCheckBox") {
604-
text = tr("Enable Separate Update Folder:\\nEnables installing game updates into a separate folder for easy management.\\nThis can be manually created by adding the extracted update to the game folder with the name \"CUSA00000-UPDATE\" where the CUSA ID matches the game's ID.");
605600
} else if (elementName == "showSplashCheckBox") {
606601
text = tr("Show Splash Screen:\\nShows the game's splash screen (a special image) while the game is starting.");
607602
} else if (elementName == "discordRPCCheckbox") {
@@ -760,7 +755,6 @@ void SettingsDialog::UpdateSettings() {
760755
Config::setVblankDiv(ui->vblankSpinBox->value());
761756
Config::setDumpShaders(ui->dumpShadersCheckBox->isChecked());
762757
Config::setNullGpu(ui->nullGpuCheckBox->isChecked());
763-
Config::setSeparateUpdateEnabled(ui->separateUpdatesCheckBox->isChecked());
764758
Config::setLoadGameSizeEnabled(ui->gameSizeCheckBox->isChecked());
765759
Config::setShowSplash(ui->showSplashCheckBox->isChecked());
766760
Config::setDebugDump(ui->debugDump->isChecked());

src/qt_gui/settings_dialog.ui

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,6 @@
135135
<property name="spacing">
136136
<number>10</number>
137137
</property>
138-
<item>
139-
<widget class="QCheckBox" name="separateUpdatesCheckBox">
140-
<property name="text">
141-
<string>Enable Separate Update Folder</string>
142-
</property>
143-
</widget>
144-
</item>
145138
<item>
146139
<widget class="QCheckBox" name="showSplashCheckBox">
147140
<property name="text">

0 commit comments

Comments
 (0)