* Fix isDevKit
Previously, isDevKit could increase the physical memory used above the length we reserve in the backing file.
* Physical backing for flexible allocations
I took the simple approach here, creating a separate map for flexible allocations and pretty much just copying over the logic used in the direct memory map.
* Various fixups
* Fix mistake #1
* Assert + clang
* Fix 2
* Clang
* Fix CanMergeWith
Validate physical base for flexible mappings
* Clang
* Physical backing for pooled memory
* Allow VMA splitting in NameVirtualRange
This should be safe, since with the changes in this PR, the only issues that come from discrepancies between address space and vma_map are issues related to vmas being larger than address space mappings. NameVirtualRange will only ever shrink VMAs by naming part of one.
* Fix
* Fix NameVirtualRange
* Revert NameVirtualRange changes
Seems like it doesn't play nice for Windows
* Clean up isDevKit logic
We already log both isNeo and isDevKit in Emulator::Run, so the additional logging in MemoryManager::SetupMemoryRegions isn't really necessary.
I've also added a separate constant for non-pro devkit memory, as suggested.
Finally I've changed a couple constants to use the ORBIS prefix we generally follow here, instead of the SCE prefix.
* Erase flexible memory contents from physical memory on unmap
Flexible memory should not be preserved on unmap, so erase flexible contents from the physical backing when unmapping.
* Expand flexible memory map
Some games will end up fragmenting the physical backing space used for flexible memory. To reduce the frequency of this happening under normal circumstances, allocate the entirety of the remaining physical backing to the flexible memory map.
This is effectively a workaround to the problem, but at the moment I think this should suffice.
* Clang
* ajm: handle ParseRiffheader flag
* small optimizations and cleanup
* allow uninitialized instances handle RIFF
* fixed audio cutoff and small refactoring
* small fix to the returned data
* fix gapless init, reset total samples on RIFF init
* warning reporting + consume input buffer on gapless loop
* avplayer: code improvements
* avplayer: implemented pause/resume
* avplayer: implemented sync modes
* avplayer: issue warning on loopback
* avplayer: sync on video ts in default mode when audio ts is not available
* avplayer: removed waits for the frame in Get*Data, replaced cv with sleep
* avplayer: removed all waits from GetVideoData
* avplayer: fix warning propagation + small fixes
* Using texture memory for video frames, dropped video frame cache, syncing audio to video
* do not sync to audio when audio is not enabled
* removed logs, fixed sync
* reverted the removal of pre-allocated buffers
* Logic update, no QT ui
* Fixing errors
* Gui boxes
* fixes
* prevent device list refreshing too fast when game not running
* Removed duplicate Socket declarations in kernel/file_system.cpp and fs.h
* Fixed clang-format and micDevice errors
* Ran clang-format and fixed rebase compiler issues
* Settings dialog fix
* Addressed squidbus' concerns
* Update config.cpp to adhere to clang-format
* Removed a space causing clang-format to complain
* Addressed squidbus' concerns and added fallbacks
Concerns:
- Changed dev_name construct to remove unnecessary cast
- Added an invalid AudioDeviceID macro to replace magic number
---------
Co-authored-by: rainmakerv2 <30595646+rainmakerv3@users.noreply.github.com>
* Fix: Add libbsd dependency for Linux builds
Adds conditional libbsd support to resolve strlcpy undefined reference
on Linux systems. Includes proper CMake detection and header includes.
* Fix: Use internal strlcpy implementation for Linux
- Extend existing Windows strlcpy implementation to Linux
- Remove libbsd dependency from CMakeLists.txt
- Resolves undefined reference to strlcpy on glibc systems
Uses the project's existing approach instead of adding external dependencies.
* Fix address formatting for invalid address asserts
* Reduce event flag message to trace
This log effectively contributes nothing to debugging.
* Remove excess logging in sceKernelBatchMap
Every one of these opcodes will just log from their individual function calls anyway, and if there were issues with batch map logic, we would've known for a while now.
* Log error return during sceKernelBatchMap
May help with debugging some unstable UE games?
* Use _mm_setcsr over assembly
Exists on all platforms, so might as well use it.
* Clang
* Missing include
* Unconditionally set FPUCW
As per review suggestions.
* Fix FPUCW and MXCSR registers on Windows
For some reason only Microsoft knows, settings these values in the context doesn't work.
Also their controlfp functions don't seem to work either, so I used assembly instead.
* Set MXCSR on all platforms
All three platforms use the same default MXCSR register value. Use an assembly instruction to set this for all platforms.
* 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.
Somehow I missed that we already had a IsValidAddress function that could be used for ensuring addresses is inside vma map (for non Mac platforms at least). This PR swaps my Contains(addr) checks for calls to IsValidAddress.
This should help with some weird inconsistent memory asserts and exceptions caused by inconsistent iterator behavior on Windows devices.
* Swap !IsFree() for IsMapped()
IsFree only checks if the VMAType == Free. As is, that means ClampRangeSize will include memory that is Reserved or PoolReserved, and neither of those types are GPU mapped.
This fixes this bug, may help with some non-GPU memory asserts.
* Apply ClampRangeSize to vertex buffers
Helps with some cases encountered by UE and Minecraft.
* 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
* 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
* 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
* 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>
* This works, but it's missing some hotkeys and the GUI isn't hooked up to anything now
* More hotkeys
* Remove debug log
* clang
* accidentally used the wrong value here
* gui changes for new backend (#10)
* gui changes for new backend
* fix lmeta
* don't erase non-hotkey lines
* do not erase hotkey configs in kbm or controller guis
* Fix repeated inputs
* Documentation
---------
Co-authored-by: rainmakerv2 <30595646+rainmakerv3@users.noreply.github.com>
* Qt: Add FSR settings to settings GUI
* Move FSR settings from Imgui.ini to main config
* move passing fsr settings to presenter constuctor
* cleanup: use struct instead of function call
* cleanup: make variable names consistent with others
* Update fsr settings real-time in qt, save button in Imgui
* Linux build fix, missing running game check
* syntax fix
* Change gamerunning checks to if (presenter)
* 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.
* 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
* 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