Commit graph

753 commits

Author SHA1 Message Date
Stephen Miller
6277975bc4
Merge branch 'main' into filesystem_win 2025-06-22 19:48:29 -05:00
Stephen Miller
d9dac05db2
Core: MapMemory fixes (#3142)
* Validate requested dmem range in MapMemory

Handles a rare edge case that only comes up when modding Driveclub

* Specify type

auto has failed us once again.

* Types cleanup

Just some basic tidying up.

* Clang
2025-06-21 19:22:03 -07:00
kalaposfos13
54163ffaa5
Initialize system handle in HLE Ngs2 library (#3137) 2025-06-21 20:30:49 +03:00
kalaposfos13
2d335f436c
Stub out SetGPO and GetGPI (#3135) 2025-06-21 05:23:14 -07:00
Fire Cube
a62027d4c2
fix potential out of bound crash (#3132) 2025-06-21 10:03:10 +03:00
kalaposfos13
551751df3c
Emulate motion controls with a mouse (#3122)
* Rework framework to allow for more types of mouse-to-something emulation and hook up gyro to it

* Remove the unnecessary null check now that deltatime is handled differently

* Fix toggle key

* Basic gyro emulation working for two out of the three dimensions

* clang

* Added bindable key to hold for switching from looking to the sides to rolling

* documentation
2025-06-20 13:55:41 +03:00
georgemoralis
43321fb45a
QT save fixes II (#3119)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* added recentFiles save/load

* gui language

* fixups for language

* fixed language issue with savedata (it was saving based on gui language and not on console language)

* clang fix

* elf dirs added

* added theme
2025-06-20 12:28:32 +03:00
Stephen Miller
213ca72fa1
Filesystem: Fixes for posix_rename and write (#3099)
Some checks are pending
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
* Fix rename

We shouldn't be leaving a copy of the original filename laying around.
This fixes one of a few broken savedata checks in DRAGON BALL XENOVERSE (CUSA01341)

* sceKernelWrite hack

Seems like std::fwrite has some weird edge cases we aren't handling properly.
Until we get to the bottom of this issue, here's a hack that bypasses it.
This fixes saves in DRAGON BALL XENOVERSE (CUSA01341)

* hack fix

* Improved "hack"

* Fix rename for Windows users

Turns out, we're using copy instead of rename for a reason, and that same reason came up when adding the remove call.
Also adds a log for the sceKernelWrite issue, since that's definitely a hack that needs to be debugged.

* A real fix for the sceKernelWrite issue

Turns out, some data was just buffered.
Running Flush fixes that problem.

* Move fflush call to WriteRaw

To prevent future cases of this issue.
2025-06-15 22:43:39 +03:00
Fire Cube
de69f2b40b
Equeue: HrTimer fixes (#2987)
* initial changes

* tmp

* impl

* support wait for multiple timers

* cleanup
2025-06-15 19:03:57 +03:00
Stephen Miller
69a50fa713
Struct update fixes (#3087)
Neither sceVideodec2Decode or sceVideodec2Flush should be modifying the output's `thisSize`, doing so breaks older games now that we have the updated structs.
We should also only set frameFormat and framePitchInBytes if the game inputted the newer struct, since otherwise we're modifying memory the game never gave us.
These changes might fix the regression in Hatsune Miku Project Diva X, though it's hard to tell due to some weird caching issue with Windows, and the ancient regression this game had on Linux.
2025-06-11 22:22:34 +03:00
Stephen Miller
3e0ec9ebef
Core: Merge Direct Memory Areas (#3084)
* Merge dmem areas

* Fix DirectMemoryArea::CanMergeWith

Don't merge dmem areas if the memory types are different.

* Reduce some warnings to info

Both functions should behave properly now, there's no reason to warn about their use.

* Clang
2025-06-11 17:34:00 +03:00
Stephen Miller
fc4fd0107d
libSceNpTrophy: Change initial context and handle values (#3080)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Change default context and handle values

libSceNpToolkit internally uses context/handle values of zero to indicate NpTrophy calls failed.
This PR returns handle/context as index + 1 instead, avoiding this issue.

* Fix log message
2025-06-10 15:43:11 -07:00
Stephen Miller
b49340dff8
libSceVideodec2: Update structs to match newer firmwares (#3077)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Update file_system.cpp

* libSceVideodec2 struct fixes

Our code was based on an old version of the libSceVideodec2 library. Based on what I've decompiled, these structs changed somewhere around firmware 6.50, and newer versions of the library have these flexible checks to accommodate both variants of the structs.

* Static assert for AvcPictureInfo struct

All the other Videodec2 structs have static asserts, might as well use one here too.

* Initialize new values

Set proper values for frameFormat and framePitchInBytes.
`frame->linesize[0]` appears to be in bytes already, I'm not sure if that means framePitch is being set wrong though.
2025-06-10 13:22:50 -07:00
TheTurtle
d7051f15f4
texture_cache: Basic handling of partially resident images (#3066)
* texture_cache: Avoid gpu tracking assert on sparse image

At the moment just take the easy way of creating the entire image normally and uploading unmapped subresources are zero

* tile_manager: Downgrade assert to error

* fix macos
2025-06-09 01:26:10 -07:00
Stephen Miller
5edd9ff54b
Improved sceKernelMapNamedFlexibleMemory logging (#3050)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* More descriptive sceKernelMapNamedFlexibleMemory logging

* Misc exports

These functions are used by Overwatch: Origins Edition

* Clang

* Function parameter cleanup

Changes the parameters on our sceKernelMapNamedFlexibleMemory and sceKernelMapFlexibleMemory functions to better align with our current standards.
2025-06-08 00:17:45 +03:00
Stephen Miller
43bf4ed1bc
sceVideoOutGetResolutionStatus error behavior (#3044) 2025-06-05 12:14:34 -07:00
Stephen Miller
0e9420a7b2
Fix request queues in libSceZlib (#3041)
Queues are a FIFO data structure, so pop() removes the front, not the end.
2025-06-05 16:43:39 +03:00
georgemoralis
2c8a959acc
Merge branch 'main' into filesystem_win 2025-06-04 12:44:33 +03:00
Marcin Mikołajczyk
5b6fc788b3
Fix passing user data in user-triggered equeue events (#2948) 2025-06-03 11:42:20 -07:00
Stephen Miller
8cdd8dd725
Core: Pthread affinity fixups (#3021)
Some checks are pending
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / clang-format (push) Waiting to run
Build and Release / reuse (push) Waiting to run
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* posix_pthread_attr_getschedparam

* Fixes for scePthreadGetAffinity and scePthreadSetAffinity

Looking at FreeBSD source, and our other pthread functions, we should be using our FindThread function to get the appropriate thread if thread != g_curthread.
2025-06-03 03:43:56 -07:00
Stephen Miller
bb3f8af81a
Core: Protect fixes (#3029)
* Swap do-while to while

If we use a do-while loop, we waste time if `aligned_size = 0`.  This is also still accurate to FreeBSD behavior, where it returns success if `start == end` during mprotect.
This also effectively prevents the memory assert seen in updated versions of RESIDENT EVIL 2 (CUSA09193)

* Move prot validation outside loop

The prot variable shouldn't change during a mprotect call, so we can check the flags before protecting instead.
Also cleans up the code for prot validation.
This should improve performance, and is more accurate to FreeBSD code.

* Add logging for protect calls

This will help in debugging future problems
2025-06-03 09:29:25 +03:00
mailwl
eed99141b3
Network Play: set user signed in (#2944)
* Network Play: set user signed in

* get signedIn status from config

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-06-03 09:11:18 +03:00
Stephen Miller
6bdd83684b
Libs: libSceVoice stubs (#3022)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* voice lib stubs

Primarily for GTA V

* Clang
2025-06-01 19:30:03 +03:00
WujekFoliarz
b1af1334c9
Fix touchpad handling and change gyro calculation (#3006)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
* Change touchpad handling and orientation calculation

* remove unnecessary includes in pad.cpp

* remove the cmake command arguments

* remove the weird file

* try to fix formatting

* limit new gyro and touchpad logic to controller 1

* remove cout

* fix formatting and add the handle check to scePadRead

* swap y and z back
2025-06-01 19:13:02 +03:00
georgemoralis
a3e998b84d
Merge branch 'main' into filesystem_win 2025-05-30 09:56:07 +03:00
Stephen Miller
6cdc52cdde
Core: More Memory Cleanup & Fixes (#2997)
* Only perform GPU memory mapping when GPU can access it

This better aligns with hardware observations, and should also speed up unmaps and decommits, since they don't need to be compared with the GPU max address anymore.

* Reserve fixes

ReserveVirtualRange seems to follow the 0x200000000 base address like MemoryPoolReserve does.
Both also need checks in their flags Fixed path to ensure we're mapping in-bounds. If we're not in mapping to our address space, we'll end up reserving and returning the wrong address, which could lead to weird memory issues in games.

I'll need to test on real hardware to verify if such changes are appropriate.

* Better sceKernelMmap

Handles errors where we would previously throw exceptions. Also moves the file logic to MapFile, since that way all the possible errors are in one place.
Also fixes some function parameters to align with our current standards.

* Major refactor

MapDirectMemory, MapFlexibleMemory, ReserveVirtualRange, and MemoryPoolReserve all internally use mmap to perform their mappings. Naturally, this means that all functions have similar behaviors, and a lot of duplicate code.
This add necessary conditional behavior to MapMemory so MemoryPoolReserve and ReserveVirtualRange can use it, without disrupting the behavior of MapDirectMemory or MapFlexibleMemory calls.

* Accurate phys_addr for non-direct mappings

* Properly handle GPU access rights

Since my first commit restricts GPU mappings to memory areas with GPU access permissions, we also need to be updating the GPU mappings appropriately during Protect calls too.

* Update memory.cpp

* Update memory.h

* Update memory.cpp

* Update memory.cpp

* Update memory.cpp

* Revert "Update memory.cpp"

This reverts commit 2c55d014c0.

* Coalesce dmem map

Aligns with hardware observations, hopefully shouldn't break anything since nothing should change hardware-wise when release dmem calls and unmap calls are performed?
Either that or Windows breaks because Windows, will need to test.

* Implement posix_mprotect

Unity calls this
Also fixes the names of sceKernelMprotect and sceKernelMtypeprotect, though that's more of a style change and can be reverted if requested.

* Fix sceKernelSetVirtualRangeName

Partially addresses a "regression" introduced when I fixed up some asserts.
As noted in the code, this implementation is still slightly inaccurate, as handling this properly could cause regressions on Windows.

* Unconditional assert in MapFile

* Remove protect warning

This is expected behavior, shouldn't need any logging.

* Respect alignment

Forgot to properly do this when updating ReserveVirtualRange and MemoryPoolReserve

* Fix Mprotect on free memory

On real hardware, this just does nothing. If something did get protected, there's no way to query that information.
Therefore, it seems pretty safe to just behave like munmap and return size here.

* Minor tidy-up

No functional difference, but looks better.
2025-05-29 18:56:03 +03:00
Fire Cube
eb9f66c349
Libs: CompanionUtil (#2963)
* impl

* more

* move log

* cleanup type definitions

* error code cleanup and clang

* cleanup ugly RE code

* shame

* clang

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-05-29 12:33:56 +03:00
georgemoralis
7f0503bf8b
Implemented sceNetInetNtop in RE (#3003)
* implemented sceNetInetNtop in RE

* some logging

* added freebsd_inet_ntop4

* freebsd_inet_ntop6

* fixups based on reviews

* review fixes
2025-05-29 11:59:34 +03:00
squidbus
95f04b746d
equeue: Move small timer check to WaitForEvents. (#3000)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
2025-05-28 19:54:47 +03:00
Fire Cube
e0309a4b01
Equeue: fix WaitEqueue assert on nullptr (#2994)
Some checks are pending
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* fix

* fix infinite call of waitforsmalltimer

* fix wrong nullptr check

* add comment back

* fix discrepancy

* remove assert

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-05-27 14:47:54 -07:00
georgemoralis
b55c3f4555
Trophy fix (#2975)
* fixed invalid handle destroy

* removed log
2025-05-22 05:35:00 -07:00
squidbus
6935b24440
savedata: Fix missing uses of config based save data dir. (#2971) 2025-05-22 11:28:41 +03:00
georgemoralis
0289b99d69 -Remove trailing separator when opening dirs if exist (windows doesn't like it)
-Support for opening dirs in windows
2025-05-22 11:26:11 +03:00
Vinicius Rangel
5eb58799fe
SaveData: respect install dir in param.sfo to select the game save folder (#2951)
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
2025-05-17 12:00:35 -03:00
Vinicius Rangel
5f447a815e
SaveDataDialog: fix possible null access (#2947) 2025-05-17 10:41:16 -03:00
mailwl
ffd31589cf
Fix reading not existing savedata (#2941)
* Fix reading not existing savedata

* alloc save memory instead return error

* save memory saze to save slot instead of global

* remove unused enum

* remove unneeded memory clean
2025-05-16 13:22:47 -03:00
georgemoralis
7de6aec337
[Libs] Companion httpd (#2942)
* stubbed companion httpd

* sceCompanionHttpdGetEvent returns disconnected device

* more function definations

* added error codes file
2025-05-16 16:17:37 +03:00
Stephen Miller
18ff65efc8
Implement sceKernelMapDirectMemory2 (#2940)
* Implement sceKernelMapDirectMemory2

Behaves similarly to sceKernelMapDirectMemory, but has a type parameter.

* Simplify

No need to copy all the MapDirectMemory code over, can just call the function, then do the SetDirectMemoryType call

* Clang
2025-05-16 05:38:40 -07:00
squidbus
aeb4536988
externals: Remove winpthreads. (#2932) 2025-05-15 13:59:34 -07:00
Stephen Miller
6d38100a41
Avoid logging nulls in sceKernelIsStack (#2933)
Games would crash if providing nullptr to start or end.
Also don't need the :# part when logging pointers, as they're automatically formatted.
2025-05-14 17:09:23 +03:00
squidbus
26c965cf4a equeue: Fix timer cancel error code check.
Some checks failed
Build and Release / reuse (push) Has been cancelled
Build and Release / clang-format (push) Has been cancelled
Build and Release / get-info (push) Has been cancelled
Build and Release / windows-sdl (push) Has been cancelled
Build and Release / windows-qt (push) Has been cancelled
Build and Release / macos-sdl (push) Has been cancelled
Build and Release / macos-qt (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-qt (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / linux-qt-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
2025-05-13 17:31:23 -07:00
squidbus
1639640902 event_flag: Lower error logs to debug. 2025-05-13 14:46:59 -07:00
squidbus
3ab69e24db fix: Compiling with newer Boost 2025-05-13 14:22:44 -07:00
squidbus
0d127a82dd
equeue: Clean up timers implementation. (#2925) 2025-05-13 14:05:29 -07:00
Marcin Mikołajczyk
e5b675d607
Handle IT_WAIT_REG_MEM with Register argument (#2927) 2025-05-13 13:56:20 -07:00
Marcin Mikołajczyk
1832ec2ac2
Implement sceKernelIsStack (#2917) 2025-05-13 13:54:22 -07:00
Fire Cube
7334fb620b
sceKernelAddTimerEvent implementation (#2906)
* implementation

* add backend (WIP)

* now should be good
- fix implementation based on homebrew tests
- demote log to debug
- make squidbus happy (hopefully)

* fix moved m_name

* fix clang

* replace existing event when its same id and filter

* run timercallback after addEvent and remove useless code

* move KernelSignalRequest to the end

* clang (i hate you)
2025-05-13 12:16:53 -07:00
georgemoralis
f97c0deea9
ngs2: removed possible nullptr value from logging (#2924) 2025-05-13 11:29:47 -07:00
georgemoralis
e6a144ddb0
[Libs] sceNet IV (#2867)
* dummy returns in p2p sockets

* added logging for sceNetSetsockopt

* possible fix for ORBIS_NET_SO_LINGER set

* logging for getsockoption as well

* disable kernel getsockname (seems to create issues with cyberpunk)

* some fixes with SetSocketOptions

* arggg

* posix_getsockname try

* mutex protection

* removed duplicated include (diegolix29)

* posix_getsockname appears to have issues in cyberpunk , comment it for now
2025-05-13 08:54:38 +03:00
squidbus
3a10fda008 kernel: Simplify sceKernelUuidCreate 2025-05-12 22:15:04 -07:00