Commit Graph

3714 Commits

Author SHA1 Message Date
Stephen Miller
cc6af03adf
Lib.SysModule: Proper HLE implementation (#4102)
* Replace sysmodule enums with table

Dumped this from the 12.52 module, using a script I created.

* Better documentation

* Separate from system libraries

That system folder is going to be getting quite large if I left all the sysmodule stuff in there.

* More arrays from library

* Found another preload list

Ghidra really hates decompiling libSceSysmodule, so I didn't notice this one at first.
Also documented specific versions tied to each preload list.

* Start work on implementation

* Some basic implementations

* Initial stub for module loading

Just enough to see if the logic functions appropriately.

* Clang

* sceSysmoduleLoadModule

Now I need to get sceSysmodulePreloadModuleForLibkernel done so that we don't have bugs from not loading internal LLEs.

* sceSysmoduleLoadModuleInternal

* sceSysmodulePreloadModuleForLibkernel

I have successfully broken quite literally everything.
I shall debug this tomorrow.

* Slight fix

* Maybe fix?

* Change log

Enjoy the log spam 😄

* Increased defined stub count

Now that libc and libSceLibcInternal loads later, all the auto stubs are getting consumed by it.

* sceSysmoduleUnloadModule stub

Also a couple fixes. Sysmodule does pass argc and argv to game modules, but only after loading them once to check  binaries.
Shouldn't matter for the most part.

* Clang

* Less stubs

2 thousand is seemingly enough.

* sceSysmoduleLoadModuleInternalWithArg

Doesn't hurt to have, since Apex Legends calls it.

* Oops

* Oops 2

* Rename isModuleLoaded to getModuleHandle

Review comment

* Remove debug game module loads

These cases only trigger when specific sceRegMgr key values are set, and for our purposes, we can treat that case as false.

* Allow preloading to fail

For kalaposfos

* Clang
2026-03-08 21:48:03 +02:00
Stephen Miller
014b11e9da
Return an empty certificate (#4104)
This is enough to get past initialization checks in Rise of the Tomb Raider.
2026-03-07 09:15:32 +02:00
georgemoralis
50d5ce9a83
fixed an issue in sceKernelRemoveExceptionHandler (#4086)
* fixed an issue in sceKernelRemoveExceptionHandler

* fixed comment
2026-03-07 08:55:17 +02:00
Pavel
89e74828e6
fixup r128 (#4100) 2026-03-05 22:44:37 +02:00
georgemoralis
14450d330f
CopyImage stencil fixes (#4095)
* stencil fixes hope it fixes driveclub

* revert image copy to the one that had driveclub worked

* reverted texture cache change

* some more fixes and reverts

* added logging for overlap again
2026-03-03 08:52:12 +02:00
Stephen Miller
1f5430e4c2
More targeted fix (#4096)
Cyberpunk's issue seems to actually come from the incrementing in the loop. It wasn't clear while debugging, but the problem is that the pattern the game supplies causes match to fail when str_wild_it hits the end, and then tries iterating past end due to the loop condition.
Our pattern matching code seems broken for the case Cyberpunk triggers, but since I'm not aware of the intricacies of how real hardware behaves, best to just revert the loop condition change and instead break the loop before the broken iteration.
2026-03-02 20:35:58 +02:00
Niram7777
fc949a7449
CI wget linuxdeploy retries (#4093) 2026-03-02 20:32:28 +02:00
georgemoralis
e5d7dc4090
the uber fix (#4092) 2026-03-01 21:02:21 +02:00
georgemoralis
636efaf2b5
changed readbacks mode to Relaxed,Precised (#4091) 2026-03-01 20:49:55 +02:00
Stephen Miller
dbf23a66af
fix (#4088) 2026-03-01 07:30:19 +02:00
rainmakerv2
6a8c50c3a2
Low readbacks mode (#4085) 2026-02-28 17:17:11 +02:00
Stephen Miller
49c2a4999b
Lib.Net: Misc fixes (#4082)
* Fix Windows-specific incorrect error in PosixSocket::Connect

* Hide typical non-blocking errors

* Also hide EWOULDBLOCK from recvfrom

* Fix the resolver fix
2026-02-28 09:09:01 +02:00
Stephen Miller
aae10ecdf7
Lib.GnmDriver: Implement sceGnmDrawIndirectMulti (#4083) 2026-02-27 21:32:32 -08:00
Stephen Miller
8bb29695ed
Lib.Net: Proper resolver errors when isConnectedToNetwork is disabled (#4081)
* Force resolver errors when not connected to network

Error values are based on real hardware testing.
sceNetResolverGetError is based on libSceNet decompilation.

* Update net_resolver.h
2026-02-28 00:50:41 +02:00
evill33t
19d2027105
skipped guest/host marker parsing/calls when disabled (#4078)
* skipped guest/host marker parsing/calls when disabled

* clang-format

---------

Co-authored-by: Ronny Stiftel <ronny.stiftel@tomcom.de>
2026-02-26 17:02:14 +02:00
georgemoralis
f91b8410fd
SDL Audio3d (#4077)
* implemented dummy audio3d for sdl

* removed sdl::free
2026-02-26 15:31:50 +02:00
Vladislav Mikhalin
e1ecd8e98c
threads: initialize tls on thread creation (take 2) (#4070) 2026-02-24 20:35:05 +03:00
kalaposfos13
af9cbb8e8a
Fix some logic bugs in sceHttpUriParse (#4067) 2026-02-24 09:00:17 +02:00
ElBread3
407d287fb1
tweak LoadFigure and RemoveFigure (#4071) 2026-02-23 21:30:57 +02:00
kalaposfos13
c265a39227 fix typo 2026-02-23 09:08:39 +01:00
Stephen Miller
6cbab87745
Kernel.Event: Implement kqueue and kevent (#4065)
* Remove dead code from EqueueInternal::WaitForEvents

No longer necessary now that we avoid using small timers when falling back on equeue logic.

* Refactor type names

Might as well

* Properly define OrbisKernelEqueue as a handle

Most of the functions using an "OrbisKernelEqueue" call directly into kevent. Therefore, OrbisKernelEqueue should be a equeue handle.

* Clang

* Widen OrbisKernelEqueue type

On real hardware, it's some value that contains the handle, as opposed to just the handle itself.

* kqueue implementation

The easy part

* Hardware-accurate timer data

Needed to make kevent simpler for these uses.

* Move callback scheduling to EqueueInternal::AddEvent

kevent would become excessively bloated if I needed to deal with that in there.

* posix_kevent

kevent is a bit of a pain, for now I've implemented as much as libkernel actually uses for it's wrappers, and left error logs to skip behavior when necessary.

* Log calls

* Apple, why are you calling fstat on an equeue?
2026-02-22 23:41:05 +02:00
kalaposfos13
607d704707
Mount /data to <userdir>/data instead of <userdir>/data/gameid (#4066) 2026-02-22 19:10:55 +02:00
kalaposfos13
fb5c36fa11
Implement guest signal handlers (#4064)
* Change thread pausing to use SIGTRMIN on UNIX

* Allow handling of the rest of the signals

* Add orbis-native signal number conversion and fix a few bugs

* ifdefing away the issues

* add check for mac for the signal that's used for thread pausing there

* Add a few more registers

* Don't break HLE memory tracking
Now, if a guest app installs a handler for SIGSEGV/SIGBUS/SIGILL, that'll be handled by keeping the original signal handler, and if we can't handle the signal ourselves (as in it didn't come from HLE memory tracking), we pass it on to the guest

* copyright 2026

* +
2026-02-22 18:56:54 +02:00
kalaposfos13
b37e0a6ea6
Miscallenous function exports and implementations (#4068)
* _nanosleep

* pthread_mutexattr_setpshared

* pthread_attr_setschedpolicy

* getuid

* copyright 2026
2026-02-22 17:08:06 +02:00
Vladislav Mikhalin
9241ebd4dd
Revert "threads: initialize TLS on thread creation (#4048)" (#4062)
This reverts commit f6d71646c0.
2026-02-21 14:10:25 +03:00
Stephen Miller
248b3e2d30
Core: Force logging of critical errors (#4061)
* Ignore enabled flag on critical log entries

This ensures critical errors (asserts and unreachables) are logged when the log file exceeds 100MB, or when logging is disabled.

* I apparently need sleep
2026-02-21 09:53:28 +02:00
Stephen Miller
1eb09ab440
Kernel.Equeue: Various event fixes (#4059)
* Fix vblank event data

* Various logical fixes for timer events

Store timer timeouts in nanoseconds now, properly handle event "replacement", avoid employing small timers when adding events to equeues, fix stored timer data

* Clang
2026-02-21 09:37:59 +02:00
georgemoralis
06b901a47b
Gpu fixes misc (#4050)
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 / macos-sdl (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
* fixed image copy to ignore stencil aspect

* Added logging for "Encountered unresolvable image overlap with equal memory address."

* fixed overlap issues with different pitch , added more detailed logging for rest of overlap issues

* improved log error

* maybe mipmaps ?

* array layers or different mip map range

* rewrote case  new image has fewer mip levels than cached image

* array with 2 layers?

* last case

* improved

* no it didn't work
2026-02-19 21:11:33 +02:00
Vladislav Mikhalin
f6d71646c0
threads: initialize TLS on thread creation (#4048)
* initialize TLS on thread creation
* initialize tls in dimensions toypad writer thread
* clear most of the stack on thread init with some black magic
2026-02-19 21:26:33 +03:00
georgemoralis
a99c814739
Image copy Enhancement (#4041)
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 / macos-sdl (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
* copy image handle 2d->3d copies and opossite now

* make gcc happy

* fixed colouring issue
2026-02-17 22:41:18 +02:00
kalaposfos13
3a99051df9
filesystem: fix crashes caused by returning a pointer from an std::vector (#4043)
Co-authored-by: Stephen Miller <56742918+StevenMiller123@users.noreply.github.com>
2026-02-16 22:56:35 +02:00
Stephen Miller
547198af6f
Lib.VideoOut: Fix pending flips limit (#4039)
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 / macos-sdl (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
* Hardcoded limit to pending flips

Real hardware has a fixed-size queue, and doesn't depend on the number of registered buffers.
While the kernel supposedly uses an array of 18 elements, my tests suggest the cap is 16 pending flips.

* Assert on trying to flip unregistered buffer

I haven't seen anything do this intentionally yet, but I do have cases where games do this unintentionally (do to unimplemented functions).
2026-02-16 08:31:35 +02:00
Stephen Miller
4a370519a5
Lib.GnmDriver: Fix flip arg for sceGnmSubmitAndFlipCommandBuffers (#4038)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* There is a mountain of evidence suggesting that flip_arg for these functions should be a 64-bit integer.

This fixes "memory" errors in some Unity titles.

* oops

* Fix sceVideoOutGetEventData

This bug went unnoticed for a while because the selection of Unity games I had at the time didn't actually care.
This + the prior fix is needed for Unity titles.
2026-02-15 09:29:33 +02:00
Alexandre Bouvier
fba7304d62
cmake: prefer more system libs (#4037) 2026-02-15 09:12:52 +02:00
Valdis Bogdāns
0f92285e50
GR2-win-crash-fix (#4033)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Improve stack clearing logic in ExecuteGuest

Added a check for fiber stacks before clearing the stack in ExecuteGuest.
That fixes Gravity Rush 2 crash on Windows.

* Refactor ExecuteGuest to simplify stack clearing logic

This enough for GR2

* Recover thread initialization in ExecuteGuest function

* Enhance null check for thread control block

* Fix condition to check tcb before clearing stack
2026-02-14 23:30:09 +02:00
Stephen Miller
98af227a8d
More hotfixes (#4036)
User events don't increment fflags, so don't increment it.
Also added a bugfix for dce events, as static_cast wasn't properly unpacking event.data.
2026-02-14 22:47:28 +02:00
Niram7777
8d4cbdbca9
Log actually not always compact (#4035) 2026-02-14 22:31:19 +02:00
Stephen Miller
e0850d5cfc
Kernel.Equeue: Only reset trigger state on events that clear. (#4032)
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 / macos-sdl (push) Has been cancelled
Build and Release / linux-sdl (push) Has been cancelled
Build and Release / linux-sdl-gcc (push) Has been cancelled
Build and Release / pre-release (push) Has been cancelled
* Don't clear events that don't need clearing

Unless the event has the clear flag, it will be returned multiple times after triggering.

* Fix event flags

As older code suggests, the PS4 kernel does append the clear flag to various event types internally. This is visible when observing the returned event data from sceKernelWaitEqueue (or kevent, if you're feeling ambitious)

Add flag is also removed from events internally.
2026-02-14 01:59:23 +02:00
kalaposfos13
d189b0cc29
up is not down (#4031)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
2026-02-13 11:37:28 +02:00
Stephen Miller
1a06020f70
Core: Mount system fonts (#4028)
* Mount system fonts

Now that font LLE works, these are necessary for some titles.

* Make fonts path configurable

By user request.
2026-02-13 09:02:30 +02:00
Stephen Miller
50130a6b7c
Prevent protects during unmaps (#4029)
Some games fail in this VirtualProtectEx call because they unmapped on one thread while another thread is hitting exception handling.
2026-02-13 08:34:24 +02:00
Stephen Miller
cdafdb7443
Better handle check in scePadRead, scePadReadState (#4027) 2026-02-12 22:34:43 +02:00
georgemoralis
b4daf37662
Submodules update (#4026)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* added openal-soft , cpp-httplib

* CLI11,sdl3 update
2026-02-12 16:17:40 +02:00
Stephen Miller
0435ada3a5
Update np_web_api_internal.cpp (#4025)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
2026-02-11 23:22:38 +02:00
kalaposfos13
7bdb5eb7e1
improved motion controls emulation (#4022) 2026-02-11 18:09:34 +02:00
kalaposfos13
c2a47d2a99
Handle operand fields execlo and exechi for S_MOV (#4023)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Co-authored-by: TheTurtle <geoster3d@gmail.com>
2026-02-11 16:00:13 +02:00
Vladislav Mikhalin
8c59571961
pad: refactoring (#4016)
* pad: refactoring

* clang is not my friend
2026-02-11 11:15:33 +02:00
Stephen Miller
68679b24aa
Fix log errors (#4020)
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 / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Just a typical day of me pushing something a month ago, nobody testing/reviewing it, then finding out it's broken when that code inevitably makes it into production.
2026-02-11 08:31:23 +02:00
Stephen Miller
6a7f8a9e5a
Libs.LibcInternal: _Fofind, _Lockfilelock, _Unlockfilelock, _Foprep, _Fopen, fopen, fflush, _Nnl, _Fspos, fseek, _Frprep, fread, _Fofree, fclose, _Mtxinit, _Mtxlock, _Mtxunlock, _Mtxdst implementations (#4019)
* Initial definitions

* internal__Fofind

* Libcinternal threads

fopen stores a valid pthread mutex in the FILE struct. Since this is exposed to the game/app, we need to handle this accurately.

* internal__Foprep (and various other functions called in it)

* Actual fopen implementation

At long last, an actual function I'm supposed to implement.

* fflush + compile fixes

* fseek implementation

Comes with functions fseek calls, aside from fflush which I pushed earlier.

* fread, _Frprep

Also changed some parameter names a tad to match how I named things in my decomp.
And fixed some bugs with how I was handling the weird offseted mode thing

* fclose, _Fofree

Not confident on this one, but we'll see I guess.

* Bug fixing

No more crashes at least, fread seems to be broken though.

* fopen bugfixes

Behavior now matches LLE, at least in how LLE font seems to use it.

* Fix _Frprep

Seems like everything works now?

* Logging

Probably going to need to swap lseek and read logs to debug/trace later but this is for debugging.

* Remove alignment check

Seems I must've misinterpreted some of what Ghidra spat out, since libSceNgs2 is calling with size 1, nmemb 4.

* Reduce fseek, fread logs to trace

* Clang
2026-02-11 08:13:28 +02:00
Marcin Mikołajczyk
99661aa6b3
RE encountered NpTus functions (#4018) 2026-02-10 23:59:07 +02:00