Commit Graph

888 Commits

Author SHA1 Message Date
kalaposfos13
4abc6b3010 Implement getargc and getargv (#3562)
* Implement getargc and getargv

* update copyright year

* the loathsome clang-formatter
2025-09-09 14:58:22 -07:00
squidbus
ac318b56ac equeue: Few fixes for sceKernelWaitEqueue (#3548) 2025-09-08 19:47:12 -07:00
Stephen Miller
f4531fd927 Core: Remove checks for symbol version_major and version_minor (#3540)
* Remove checks for module version_major and version_minor

Following this rule broke linking for some libraries, and introduced extra effort needed to get some homebrew running.

* Clang

* Fix rebase

* Disable libSceSsl HLE

Real hardware uses a title workaround to determine if base libSceSsl is needed. Currently, this title workaround applies to absolutely nothing.
2025-09-08 19:30:03 -07:00
squidbus
ce6681b991 externals: Update libusb to fix more ABI issues. (#3551) 2025-09-07 14:39:16 -07:00
Stephen Miller
b5d8426db7 Libraries: Implement sceKernelIsInSandbox, update OrbisSysModule enum (#3546)
* Implement sceKernelIsInSandbox

libSceSysmodule uses this to determine if it should use sceKernelGetFsSandboxRandomWord or just hardcode "system" for retrieving modules.
Also changes some function types to use our types.

* Update OrbisSysModule enum

Adds missing values based on library testing.

* Clang
2025-09-07 13:11:15 -07:00
georgemoralis
d34ae8ce08 Net Fixes (#3468)
* Fix handling of ORBIS_NET_SO_ONESBCAST to support proper broadcast address translation on send.
    Fix setsockopt for SO_(RCV/SND)TIMEO on Windows/Linux.

* fixed suggestion

* fixes
2025-09-07 18:02:02 +03:00
UltraDaCat
5e3ffeafbe Replace Vblank Divider with Vblank Frequency (#3532) 2025-09-06 15:00:26 -07:00
Stephen Miller
0e7e100a7e Libraries: Np libraries cleanup (#3535)
* Np library cleanup

Moved all Np libraries to a Np folder, created files for Np error codes and structs shared between the libraries, removed empty auto-generated stubs from NpCommon and NpManager, and more things of that nature.

Also implemented sceNpGetAccountCountry, since we already had sceNpGetAccountCountryA anyway.

* Cleanup NpManager signed_out checks

The PR that introduced the PSN signed in status reverted some of the changes I'd previously made to improve accuracy.
Also they missed sceNpHasSignedUp, which just uses an internal variant of sceNpGetState for it's own check.

* Copyright dates

* Move signin check to NpManager RegisterLib

Hardcoding it the way I did caused it to read signin status before config was read.

* Fix RegisterLib names

Not sure why these weren't adjusted yet, so I've adjusted them myself.

* Fix NpCommon exports

* Basic parameter validation in sceNpDeleteRequest and sceNpCreateRequest

* More thorough request logic

Created an enum to capture the current state of each request, using a vector to store them.
I've made 3 states, none represents deleted requests, active represents requests that were made, but haven't been used yet, and complete represents used requests (a request cannot be used for multiple functions).

* Functions

sceNpCheckAvailability, sceNpCheckAvailabilityA, sceNpCheckNpReachability, sceNpGetAccountDateOfBirth, sceNpGetAccountDateOfBirthA added.

* sceNpGetAccountLanguage, sceNpGetAccountLanguageA

* sceNpGetGamePresenceStatus, sceNpGetGamePresenceStatusA

Also reduced debug logging for functions with early signed out returns, since those should behave identically to real hardware so long as you keep PSN emulation disabled.

* Fix sceNpGetAccountLanguage parameters

Oops

* sceNpGetNpReachabilityState

* sceNpGetParentalControlInfo, sceNpGetParentalControlInfoA

* Move OrbisNpState back to np_manager.h

Until this sees use elsewhere, this doesn't need to be with np-wide things.

* Clang
2025-09-06 14:32:22 -07:00
kalaposfos13
72e00e5d91 Add missing export (#3538) 2025-09-06 22:10:59 +03:00
Marcin Mikołajczyk
90f6bf0516 AF_UNIX preliminary support (#3506)
* AF_UNIX preliminary support

* fixed windows

* added windows implemenation for socketpair

* More gotos

* added sys_socketpair for libkernel_ps2emu

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-09-06 19:49:21 +03:00
Marcin Mikołajczyk
53181b005c Handle null event flags in cancel and clear (#3530) 2025-09-06 00:05:43 +03:00
squidbus
43b72b59a2 rtc: Fix date parsing detection. (#3524) 2025-09-05 06:50:54 -07:00
georgemoralis
e06667d307 SaveData fixes IXXXXXX (#3511)
* fixed possible savepath issue

* one more fix
2025-09-04 15:16:50 -03:00
Stephen Miller
bcea7a02c3 Return EINVAL if mmap is called with length 0 (#3496)
Hit by some multimedia apps
2025-08-31 16:14:51 -07:00
Marcin Mikołajczyk
be8c35eef1 Implement send/recvmsg (#3487)
* Implement send/recvmsg

* Windows

* fixed windows

* cleanups

* updated

* suggestions

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-09-01 01:02:26 +03:00
squidbus
af9947a862 semaphore: Fix determining wait status when canceled/deleted (#3490) 2025-08-31 14:39:57 -07:00
squidbus
52d2c4ddc1 semaphore: Invert priority order. (#3488)
* semaphore: Invert priority order.

* playgo: Lower logs for some spammed functions.
2025-08-30 19:24:58 -07:00
Loong
ed3f9ee626 Fix error compiling with certain math functions in std namespace (#3383)
e.g. error: no member named 'atan2f' in namespace 'std'
2025-08-29 21:22:34 -07:00
Stephen Miller
e172323dd0 Libraries: libSceVrTracker stubs (#3462)
* libSceVrTracker stubs, structs, enums, and errors

* sceVrTrackerQueryMemory

* Clang and slight struct cleanup

* Implement sceVrTrackerInit

* Store memory pointers and sizes

Mainly for future developers, since I doubt these memory areas will be particularly useful for these stubs.

* sceVrTrackerRegisterDevice

I haven't really identified the difference between the two register device functions, but I do know that they both internally call the internal function with slightly different parameters.

* sceVrTrackerUnregisterDevice

Also changes Hmd and Move handles to be values closer to what real hardware returns, since this function seemingly relies on handles being different for all these device types.

* sceVrTrackerTerm

* Additional error checks in sceVrTrackerRegisterDeviceInternal

* sceVrTrackerGetTime

* sceVrTrackerRecalibrate

Recalibration succeeds on real hardware (at least for some device types), so I've left the stub log intact.

* Update vr_tracker.cpp

* sceVrTrackerSetDurationUntilStatusNotTracking stub

Only handled the error checks, so I left the stub log intact.

* sceVrTrackerGpu* functions

Most of these can't succeed without a camera attached.
2025-08-26 17:16:10 -07:00
Stephen Miller
dcb256c930 libSceHmdSetupDialog stubs (#3460)
Basic stubs designed to get some VR-optional titles further.
2025-08-25 18:11:35 -07:00
Stephen Miller
1b2ac916f1 Filesystem: Abstract handling of directory files (#3455)
* Rename SceKernelIovec to OrbisKernelIovec

Fixes the naming scheme to match the rest of the project.

* Type fixups

Noticed this while working on the actual thing this PR is about.

* More type fixups

* Update file_system.cpp

* Abstract directory handling

* Clang

* Directory fstat

* Fix dirent loading logic

* PfsDirectory size

Seemed to be hardcoded when I ran tests, so I've hardcoded it here.
Also fixed up the reclen-aligning logic based on hardware observations.

* GetDents cleanup

Bring back the bytes < 512 error return from before, as that's still something that can be checked for out here.
I've also swapped the file type stuff to run from a switch case, so that the check for invalid file type can be used as the default case

* Support reading directories

* getdents

For PfsDirectory, getdents behaves like read does on normal directories. Since dirents are stored internally with a different struct, this means getdents has to convert the dirents before returning data.
For NormalDirectory, getdents is identical to read, so it can just call read and set the basep output.

* Directory readv

* Directory preadv

Since the file mutex is locked before these calls, messing with dirents_index like this shouldn't cause any weird side effects.

* return ORBIS_OK instead of 0

to better align with our coding standards.

* Directory lseek

* Un-modify CMakePresets.json

I keep this modified locally for Linux, but accidentally pushed it.

* Clang

* Fix mac compile

* Potential windows compile fix?

* Filename fix

* Fix normal directory d_reclen

* Comment cleanup

* Remove unnecessary dirent conversion logic

On real hardware, the records are still returned with the same reclen, despite the change in structure.

* PfsDirectory dirents_index fixes

Some weird stuff happens once you reach eof on directories.
Thankfully, PfsDirectories are rather tame in this regard.

* Change comment

* Rewrite normal directory reads

The logic for these seems to behave like a normal file, so instead of tracking a dirents_index, keep an internal buffer representing the file contents, and copy that to output buffers as needed.

* Update pfs_directory.cpp

* Clang

* Fix normal dirents

When rewriting the code, I forgot to account for the increased reclen value for the last dirent in the buffer.

* PfsDirectory::lseek fixes

Based on some additional tests, it seems like lseek unconditionally returns dirents_index, not the actual file position.
Also fixed some bugs with the logic for calculating the proper offset when games do wonky things, and fixed a potential area where games could crash.

* Downgrade stat and fstat log to debug

These functions can get pretty spammy.

* PfsDirectory: Properly track if end of file is reached

Using the metric `dirents_index < directory_content_size` fails when `directory_content_size` is larger than the actual directory size we report.
Since, from what I can tell, PfsDirectories shouldn't ever report more than 0x10000 bytes for size, this change is necessary.

* Revert "PfsDirectory: Properly track if end of file is reached"

I need to do some hardware tests to see if all this excess logic is actually necessary.

* Fix PfsDirectory directory_size

Turns out, if your game has over 1000 files in a folder, it will actually cause the size to increase.

* Update copyright date

* Move devices and directories into file_sys

I've also updated the copyright dates on all these files.

* C++ style type casts

* Remove unnecessary memset

* Use a vector for the data buffer

Simplifies logic for freeing the buffer, based on review suggestions.

* Fix potential oob array access

* Change type casts in Create function

* Clang

* std::memcpy instead of memcpy

* NormalDirectory::lseek cleanup

* Create constants for directory alignment values.

* Use const wherever possible

* Includes cleanup
2025-08-25 23:41:24 +03:00
Stephen Miller
709a9ac0c8 Libraries: Improved libSceHmd stubs (#3442)
* Initial work

* More work

* More stuff

* Update hmd.cpp

* Separate Reprojection and Distortion functions

Mainly doing this to clean up the code, since these sub-libraries are fairly self-contained.

* Fix weird Git issue

* Improve error documentation

After thorough decompilation, it seems clear that Sony didn't really put much thought into how libSceHmd behaves with no headset connected.

* Fix sceHmdGet2DEyeOffset

* Update hmd.cpp

* Add sceHmdInternalGetDeviceInformation and sceHmdInternalGetDeviceInformationByHandle

Based entirely off decompilation, these two functions are internally the cause of much of my trouble with this library.
They're also called by libSceVrTracker, but I don't think we'll be LLE'ing that anytime soon.

* Cleanup

* sceHmdGetAssyError

Struct isn't fully decompiled, but since it goes entirely unused when PSVR is disconnected, it doesn't matter too much.
I'm pretty certain it's 4 floats though, based on what I've decompiled of this function.

* More organization and fixes

* sceHmdGetInertialSensorData

Behavior should be fully accurate, but I've left the stub log since I haven't decompiled the parameters properly.
Also gave NID aTg7K0466r8 a proper name, based on what I've seen while decompiling. It behaves identically to sceHmdGetInertialSensorData, but with a slight difference in the params used for an internal function call.

* Update hmd.cpp

* Revert name change

* Organizational changes

These two functions modify internal variables used exclusively by reprojection functions.

* Remove internal device information calls

* Log PSVR-related attributes from param.sfo

Would mainly be helpful for compatibility list moderation, since these notices will be much more reliable for games that crash instantly.

* Remove unnecessary includes
2025-08-22 01:49:05 +03:00
Missake212
630fba2822 Dropping "SDL audio queue backed up..." to INFO (#3437)
* Update sdl_audio.cpp

* clang (I hope)

* clang
2025-08-21 04:47:43 -07:00
kalaposfos13
8e8f359b56 Implement ORBIS_NET_SO_ERROR_EX in GetSocketOptions (#3365) 2025-08-20 18:36:08 -07:00
Stephen Miller
07bae57a16 Libraries: Better libSceCamera stubs (#3434)
* Initial work on improved stubs

Simulates library behaviors for when a camera is not connected.

* Get* functions complete

I ended up leaving some stubs behind, but most of what I didn't do seem to be internal functions called by other libraries we'd be running HLE anyway.

* Finished stubs

Everything I can reasonably confirm the behavior of should behave as expected, emulating the behavior of a PS4 with no camera attached.

* sceCameraStart firmware check

This check only applies to higher eboot firmwares, since my previous test eboots used firmware 1.00 I completely missed this.

* sceCameraGetAutoExposureGain fix

When option is provided and valid, size is also set to 0.

* Track opened handles

Extremely basic for now, if the library was ever properly implemented this could be swapped for a map of some kind instead.

* Fix errors for sceCameraStart

The firmware-related parameter checks come after the library opened check.

* Promote sceCameraIsAttached log to info

Since you don't need to initialize the library to call this function, some games will call sceCameraIsAttached before anything else.
2025-08-19 18:36:07 -07:00
Stephen Miller
68e35d57d2 Libraries: Better libSceMove stubs (#3433)
* Improved libSceMove stubs

These should more accurately represent how an actual PS4 behaves when a game calls libSceMove functions while no move controllers are connected.

* Clang

* Change sceMoveGetExtensionPortInfo stub

Not entirely sure the ExtensionPortData struct is for this one, but the struct itself isn't exactly important for now anyway.

* Fix sceMoveTerm

* Update move.cpp
2025-08-18 17:41:50 -07:00
Stephen Miller
1c0a5c60ea Memory: Align size and address in posix_munmap (#3418)
* Properly align address and size in munmap

Based on observations of FreeBSD source code, fixes a Windows-related memory issue in War Thunder (CUSA00224)

* Format len and phys_addr in mmap

This should make logs slightly easier to understand, since we format these parameters in other memory calls.

* Update memory.cpp
2025-08-15 12:21:59 +03:00
Stephen Miller
a285543134 Filesystem: Directory-related fixes (#3416)
* Various GetDents fixes

Fixed return and parameter types, and made the function return all the entries that will fit in nbytes during one call.

* Fstat dir stub changes

Changes the returned statistics to match what my PS4 tests generally show.

* Stat dir stub changes

To match my fstat changes
2025-08-14 14:50:20 +03:00
kalaposfos13
1b621e4b1d Add stubbed libSceNpProfileDialog library (#3411)
* Stubbed library

* Silence sceNpProfileDialogUpdateStatus

* the loathsome clang-formatter
2025-08-10 20:05:50 +03:00
Stephen Miller
d6b2845dcc Stub NOT_IN_PARTY behavior (#3409)
From what I can tell, this is valid behavior since a user could choose not to enter a party.
This fixes a potential crash on boot in Grand Theft Auto V.
2025-08-10 20:05:38 +03:00
kalaposfos13
ff6ab9444a Fix handling of RFC 3339 formatted dates (#3410) 2025-08-10 20:04:50 +03:00
DanielSvoboda
54de156e1e Fix sceVoicePortInfo (#3408)
The VoicePortInfo 'state' was changed from 3-RUNNING to 0-IDLE. This prevents it from getting into a loop.
2025-08-10 20:04:15 +03:00
Stephen Miller
d1f9594b9d libSceAppContent: Determine entitlement labels from additional content param.sfo (#3405)
* Update app_content.cpp

* Use hyphenation to determine entitlement id from folder name

The original approach I took had two limitations: it relied on entitlement ids being 16 characters long, and it relied on the end of the folder name containing the entitlement. If the former wasn't the case, my code would throw an exception, while the latter would cause the DLC to not detect.
To resolve both issues, I've created a more robust algorithm based on observations from the most commonly used PS4 dumpers for modern firmware.

* Use DLC param.sfo to determine entitlement id

While the logic ends up slightly more complex, this makes the code more robust for other dumping methods/weird DLC folder names from people installing DLC manually.

* Update sceAppContentAddcontMount to properly detect additional content folders

Based on what I've done in sceAppContentInitialize, I've added code for detecting the correct folder to mount.
I've also removed the redundant check for addcont_info status, since we're marking all additional content as installed during sceAppContentInitialize
2025-08-10 00:19:08 +03:00
DanielSvoboda
c5aed0873f SystemGesture - Rename files to match naming convention (#3403) 2025-08-08 15:51:30 -03:00
DanielSvoboda
adef2ff231 SystemGesture (#3382)
* SystemGesture

* only STUBBED
2025-08-08 15:44:54 +03:00
Marcin Mikołajczyk
befc5ec17b select (#3353)
* select

* select for windows

* fixed windows only function

* windows error converts

* fixed up

* fixed compile

* another implementation for windows

* draft rewrite for windows

* implementation for windows

* added some debugging info

* more debugging

* extensive log

* Windows: Add device files to output fd_sets

Cyberpunk 2077 breaks without this.
Also added some formatting changes, to bring the implementation closer to our typical coding standards.

* Clang

* Formatting + cleanup

Removed some excessive logging used for debugging, and did some cleanup on the non-Windows implementation.

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
Co-authored-by: Stephen Miller <millerste004@gmail.com>
2025-08-08 00:20:49 +03:00
Valdis Bogdāns
f9ab6c48e3 Ime fixes (#3399)
* Changes
-Added support for OrbisImeParamExtended (extended IME parameters) in ImeHandler, ImeState, and ImeUi
-Updated all relevant constructors and logic to propagate and store the extended parameter
- Now fully supports passing extended options from sceImeOpen to the IME UI and backend

* Potential CUSA00434 [Debug] <Critical> assert.cpp:30 assert_fail_debug_msg: Assertion Failed!
buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?" at C:/VS/shadPS4-ime-fixes/externals/dear_imgui/imgui_widgets.cpp:4601 fix

* Attempting to resolve an assertion failure in Diablo III:
- Adjusted buffer sizes
- Updated the calculation of text‑length values

* ime-lib another hotfix

Fixed incorrect param->title validation, which caused the IME dialog to fail to appear in Stardew Valley. Need to be checked.

* Clang fix

* FF9 ImeDialog Hotfix

* Removed the validation that disallowed null text and null placeholder, since using null values is valid in `ImeDialog`.
* Added additional debug logs to aid troubleshooting.

* IME Fixes
- Add missing flags to `OrbisImeExtOption`
- Improve debug logging
- Resolve nonstop `sceImeKeyboardOpen` calls in Stardew Valley (MonoGame engine) for `userId = 254`

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-08-07 19:24:14 +03:00
marecl
f83619e313 Fixed green artifacts in movies/animations (ffmpeg) (#3398)
* Fixed green artifacts in movies/animations (ffmpeg)

* cleanup&clang

* Avoid for-loop when source and target widths are equal
2025-08-06 22:08:59 +03:00
kalaposfos13
5b46216bae Make libSceRtc fully HLE (#3330)
* Add stubbed libkernel time functions

* Implement remaining stubbed Rtc functions

* Move Rtc from the optionally HLE loading part to the always loaded part

* Remove Rtc from the README list of LLE modules

* Mfw last second hotfix I noticed while double checking that everything's good before opening the PR
2025-08-06 20:08:26 +03:00
Marcin Mikołajczyk
2f701311f2 Sockets fixes (#3392)
* Print errnos as decimal

* SetSocketOptions: prevent setting SO_TYPE

* Extract net error handler

* Change the local IP retrieval method

* Fix windows
2025-08-06 08:00:29 +03:00
Stephen Miller
074dfe2571 Update file_system.cpp (#3388) 2025-08-05 19:58:23 +03:00
Valdis Bogdāns
7dd64f889f FF9 ImeDialog Hotfix (#3386)
* Changes
-Added support for OrbisImeParamExtended (extended IME parameters) in ImeHandler, ImeState, and ImeUi
-Updated all relevant constructors and logic to propagate and store the extended parameter
- Now fully supports passing extended options from sceImeOpen to the IME UI and backend

* Potential CUSA00434 [Debug] <Critical> assert.cpp:30 assert_fail_debug_msg: Assertion Failed!
buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?" at C:/VS/shadPS4-ime-fixes/externals/dear_imgui/imgui_widgets.cpp:4601 fix

* Attempting to resolve an assertion failure in Diablo III:
- Adjusted buffer sizes
- Updated the calculation of text‑length values

* ime-lib another hotfix

Fixed incorrect param->title validation, which caused the IME dialog to fail to appear in Stardew Valley. Need to be checked.

* Clang fix

* FF9 ImeDialog Hotfix

* Removed the validation that disallowed null text and null placeholder, since using null values is valid in `ImeDialog`.
* Added additional debug logs to aid troubleshooting.

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-08-05 19:57:31 +03:00
Stephen Miller
7ec3a38b89 libSceAppContent: Use last 16 characters of DLC folder to determine entitlement label (#3375)
* Use last 16 characters of DLC folder name to determine entitlement label

Code comments and commit name say it all.

* Clang

* Adjust comment

ftpdump appends -ac at the end of the entitlement label, so my comment was partially incorrect.
2025-08-05 11:52:53 +03:00
psucien
afb9e220aa libkernel: more network functions for OpenOrbis compatibility (#3373) 2025-08-05 11:25:18 +03:00
Marcin Mikołajczyk
77410fd228 Stub remaining netctl properties (#3385) 2025-08-04 23:20:39 +03:00
Marcin Mikołajczyk
b53bda852d Fix get/setsockopt levels (#3384) 2025-08-04 22:48:56 +03:00
Valdis Bogdāns
012b01d81f Another ImeDialog hotfix (#3371)
* Changes
-Added support for OrbisImeParamExtended (extended IME parameters) in ImeHandler, ImeState, and ImeUi
-Updated all relevant constructors and logic to propagate and store the extended parameter
- Now fully supports passing extended options from sceImeOpen to the IME UI and backend

* Potential CUSA00434 [Debug] <Critical> assert.cpp:30 assert_fail_debug_msg: Assertion Failed!
buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?" at C:/VS/shadPS4-ime-fixes/externals/dear_imgui/imgui_widgets.cpp:4601 fix

* Attempting to resolve an assertion failure in Diablo III:
- Adjusted buffer sizes
- Updated the calculation of text‑length values

* ime-lib another hotfix

Fixed incorrect param->title validation, which caused the IME dialog to fail to appear in Stardew Valley. Need to be checked.

* Clang fix

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-08-03 12:51:26 +03:00
kalaposfos13
a362f20dae Implement ORBIS_NET_CTL_INFO_HTTP_PROXY_CONFIG (#3366) 2025-08-03 11:15:13 +03:00
Valdis Bogdāns
1e7c4bb69c ime-changes (#3348)
* Changes
-Added support for OrbisImeParamExtended (extended IME parameters) in ImeHandler, ImeState, and ImeUi
-Updated all relevant constructors and logic to propagate and store the extended parameter
- Now fully supports passing extended options from sceImeOpen to the IME UI and backend

* Potential CUSA00434 [Debug] <Critical> assert.cpp:30 assert_fail_debug_msg: Assertion Failed!
buf_len + 1 <= buf_size && "Is your input buffer properly zero-terminated?" at C:/VS/shadPS4-ime-fixes/externals/dear_imgui/imgui_widgets.cpp:4601 fix

* Attempting to resolve an assertion failure in Diablo III:
- Adjusted buffer sizes
- Updated the calculation of text‑length values

---------

Co-authored-by: w1naenator <valdis.bogdans@hotmail.com>
2025-07-31 12:24:36 +03:00
Marcin Mikołajczyk
78936f31fc sys_getpeername (#3354) 2025-07-31 00:28:09 +03:00