Commit graph

670 commits

Author SHA1 Message Date
Joshua de Reeper
7533206d89
usbd: Implement libusb passthrough (#2271)
* usbd: Implement libusb passthrough

* clang-format

* only do kernel activities on non-windows

* use variable to represent "fake" windows kernel driver

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-03-31 18:55:21 +03:00
Stephen Miller
99b90cbd5c
Minor libkernel changes (#2721)
* sceKernelDebugOutText

Some homebrew use this for logging, and these logs do show up in console klogs.
I wasn't sure where the most suitable place for this function would be, so I made a separate file for these debug functions.

* Implement kernel exit

Some homebrew I have use this exit when an error occurs. Since actually closing the emulator isn't implemented yet, I've used an unreachable message that logs the status code.
I've placed it in process.cpp for now, let me know if I should change that.

* Improved implementations for sceKernelDebugRaiseException functions

These functions take in two parameters, an error code and some other value that I have no idea what is for. If that second parameter is not zero, they return ORBIS_KERNEL_ERROR_EINVAL before any calls to mdbg_service.
These improved implementations add the early error return and a message with the error code to the unreachable.

* Add missing exports

Homebrew apps like to use these kernel exports of posix functions instead.

* Clang
2025-03-30 01:27:33 +02:00
Lizardy
3abe5b0d57
[Libs] Ngs2 (#1604)
* [libSceNgs2] Logging & Structs

* clang

* clang

* stdarg incl

* proper logs

* ngs2 latest

* [libSceNgs2] Logging & Structs

* clang

* latest

* fix includes

* clang

* clang

---------

Co-authored-by: microsoftv <6063922+microsoftv@users.noreply.github.com>
2025-03-26 18:42:49 +02:00
Stephen Miller
d8204641fa
libkernel: Filesystem code cleanup (#2554)
* sceKernelOpen: Clean up flag handling

* sceKernelOpen: fix params

Based on decompilation, the second parameter of _open should be flags.
Additionally swaps the return and parameter types to align with our current standards.

* sceKernelOpen: Fix errors

Based on POSIX spec, if part of the path is missing, ENOENT is the correct return.
Additionally, decompilation suggests that open sets errno too.

* Fix exports

Fixes function exports to align with what they should be, based on what I've seen from decompilation and our module generator.

* Proper errno behavior on open

Since sceKernelOpen calls posix_open, errno should be set during this process.
Simplest way to handle that is to move the actual open code to posix_open and adjust error cases accordingly.

* Reorganize open calls, add error log

* Improve close

Removes the EPERM return, as it makes no sense, and swaps sceKernelClose with posix_close to properly emulate errno behavior.

* Fix log on close

* posix_open fixups

* Readd hack in posix_close

It's either this, or removing LLE DiscMap.
Or shadow implements posix sockets.

* Missing exports

Commented out while I gradually work through them all

* Remaining placeholder exports

* Swap some stuff around

I see nothing that suggests "open" only takes two parameters, so this should be completely safe.
It's also more accurate to how these are handled in libkernel, and means I won't need to reorganize anything for readv and writev.

* Update file_system.cpp

* Implement write and posix_write

* Oops

* Implement posix_readv and sceKernelReadv

Also fixes error behavior on readv, as that function shouldn't be returning any kernel error codes.

* Move sceKernelUnlink

Will deal with this one later, was just annoyed by how it's location doesn't align with the export order.

* Cleanup readv

* Implement posix_writev and sceKernelWritev

Also fixes error behavior on writev, since it shouldn't ever return kernel errors (since our device files return those)

* More cleanup on older functions

* Swap around sceKernelLseek and posix_lseek

This ensures that these have the correct error behavior, and makes their behavior align with the updated implementations for earlier functions.

* Update file_system.cpp

* Implement read

Also fixes error behavior

* Swap sceKernelMkdir and posix_mkdir

Fixes errno behavior on kernel calls, also fixed some incorrect error returns.

* Fix errno behavior on sceKernelRmdir

Also reduces function logging to bring it closer to the level of logging seen in other filesystem functions.

* Slight clean up of sceKernelStat

Fixes error behavior and changes some of the old data types.

* Refactor fstat

Fixes errno behavior, implements fstat, and shifts exports around based on file position.
Might reorganize function locations later though.

* Implement posix_ftruncate

Implements posix_ftruncate and fixes errno behavior for sceKernelFtruncate

* Add missing error conversions for more device functions

* Implement posix_rename, fix sceKernelRename errno behavior

* Add posix_preadv and posix_pread

Also fixes some incorrect error returns, fixes errno behavior, and removes an unnecessary hack.

* Fix compile

* Implement posix_getdents, getdirentries, and posix_getdirentries

Also fixes errno behavior for the kernel variants of these functions.

* Fix errno behavior of sceKernelFsync

* Implement posix_pwrite and posix_unlink

Also fixes errno behavior in related functions.

* Update file_system.cpp

* Remove SetPosixErrno

Ideally, we've handled all possible error conditions before calling these functions, so treat errors in platform-specific code as IO errors and return POSIX_EIO instead.

* Update header exports

Not sure where these get used, but might as well keep them consistent with the rest of this.

* Check if file exists before calling platform-specific code

Bloodborne checks if a file doesn't exist using open, checking if it specifically failed with error code ENOENT. To avoid working with platform-specific errnos, add a proper error return for if the file doesn't exist.
Fixes a regression in Bloodborne.

* Clang

Out of all the changes, this is apparently the only thing Clang-Format doesn't like.
I'm honestly surprised.

* Improve error checks on posix_unlink

Just because a file isn't opened doesn't mean the file doesn't exist.
Fixes the error returned if host_path.empty(), and removes the error return for when GetFile fails.

* Fix the Bloodborne fix

* Limit exports to tested functions

* More confirmed working exports

* Remaining stuff my games can test

* FS exports from firmware tests

* Bring back missing exports from main

I don't have any bootable things that call these, but since they were working well enough on main, they should be fine to readd.

* Add export for posix_pread

Spotted in Dreams a while back, might as well add it.

* Revert "Remove SetPosixErrno"

This reverts commit bdfc0c246c.

* Revert SetPosixErrno changes

shadow's using it for posix sockets, so significant modifications would introduce unnecessary merge conflicts.

* Update comment

* Add EACCES errno to SetPosixErrno

Seen in Gravity Rush.
Also reorganizes the switch case based on the posix errno value, since ordering by errno makes no sense on some OSes.

* More export fixups

Missed these during my initial pass through FS stuff because they were in kernel.cpp for some reason.

* Symbols from FS tests

Tested by messing around with firmware elfs, these atleast don't cause any crashes.

* Remove inaccurate error behavior

Seek can have offsets past the end of a file.
Also add logging for two valid whence values that are unsupported on Windows.
I'll need to verify that SEEK_HOLE and SEEK_DATA correspond to 3 and 4 respectively, I've yet to check source to verify.

* Fix error log

Oops

* Clang

Clang

* Remove close hack

Since LLE libSceDiscMap is no longer a concern, this hack shouldn't be needed.
Since sockets are still stubbed, and close can be used on sockets, I've added a warning log just in case this still occurs in some titles.

* Change SetPosixErrno unreachable to warning

I changed it to an unreachable in an earlier commit to make testing easier.
At this point, having an unreachable for this seems unnecessary, so change it to a warning instead.

* Remove Bloodborne hack

Games should be able to unlink files that aren't opened file descriptors. As far as I've tested, this doesn't break Bloodborne.
2025-03-26 18:03:35 +02:00
georgemoralis
5c72030fb8
HLE discmap (#2686)
* HLE discmap

* improved parameters naming

* fixed typo
2025-03-25 23:54:32 +02:00
mailwl
1908d26093
lseek: let the host OS set lseek errors (#2370)
* Fix lseek(fd, -1, SEEK_SET) for XNA

* be sure, if seek really return error

* refactoring

* let host os set lseek errors
2025-03-24 15:51:36 +02:00
Pavel
a80c4a7f48
Reset previous buffer label instead of current one (#2663)
* Reset previous buffer label

* Reset flip label also when registering buffer
2025-03-23 00:27:57 +02:00
Dmugetsu
b1885badda
clock_gettime fixes for windows (#2659)
* Using OrbisKernelTimespec under clock_gettime, orbis_clock_gettime, sceKernelClockGettime  to fix compatibility issues.

* final fix test

* Roamic suggestions
2025-03-20 22:24:47 +02:00
Vinicius Rangel
5691046dcc
Renderer fixes (Splash + Aspect Ratio) (#2645)
* rewrite splash

removed Splash class
rewrite using imgui texture manager
fix crashes & old validation error

* handle games with abnormal aspect ratios
2025-03-13 18:10:24 +02:00
Stephen Miller
4d0c03fd4a
Properly implement sceVideoOutGetBufferLabelAddress (#2642)
* Export sceVideoOutGetBufferLabelAddress

It's an exported function, used by red_prig's BLACKSQUAR2 homebrew sample.
This also fixes the function's return type accordingly.

* More sceVideoOutGetBufferLabelAddress fixups

Library decomp shows a hardcoded return 16 on success. Not sure why it does that, but it never hurts to be accurate.
Also needs to have an openOrbis-specific export to get it to work with the homebrew sample I'm testing.

* Final fixups

Removed the port assert and added asserts in libSceGnmDriver for when sceVideoOutGetBufferLabelAddress calls fail.
2025-03-12 20:36:01 +02:00
Vinicius Rangel
f663176a5d
FidelityFX FSR implementation (#2624)
* host_shaders: support for includes

* video_core: add a simpler vulkan asserts

* video_core: refactored post processing pipeline to another file

* renderer_vulkan: add define param to compile shader utility

* video_core: fsr implementation

* devtools: show resolution & fsr state
2025-03-12 20:33:30 +02:00
Pavel
8bcdd9c068
Fix sceKernelLoadStartModule (#2635) 2025-03-10 11:12:12 +02:00
panzone91
a711f4d86e
libkernel: improve module finding in sceKernelLoadStartModule (#2541)
* libkernel: improve module finding in sceKernelLoadStartModule

* clang-format

* asserts for system module

* fixes

* linting

* cleaning

* fix linker impl
2025-03-09 23:44:17 +02:00
Stephen Miller
20ea0ee190
Handle error behavior in sceSysmoduleGetModuleInfoForUnwind stub (#2629)
* Stubby implementation of sceSysmoduleGetModuleInfoForUnwind

* Update sysmodule.cpp

* Minor cleanup
2025-03-09 23:17:33 +02:00
Stephen Miller
0e315cbd8f
sceKernelReleaseDirectMemory fix (#2623)
* Fix error return on sceKernelMunmap

FreeBSD docs state that len <= 0 is a EINVAL return.

* Early return on ReleaseDirectMemory with len = 0

Calls to these two functions with len = 0 cause an assert in CarveDmemArea. Since there's no memory to release, an early return should be safe here.

* Remove check for negative length in munmap

Addresses review comment
2025-03-09 15:12:05 +02:00
Vladislav Mikhalin
6b3746f3a6
kernel: re-implement clock_gettime (#2615) 2025-03-07 21:42:25 +03:00
smiRaphi
eaa18d4e3c
load trophy from .wav (#2603)
Co-authored-by: smiRaphi <neogt404@gmail.com>
2025-03-06 16:20:55 +02:00
georgemoralis
951128389d
[Lib] libsceHttp (#2576)
* implemented sceHttpUriParse

* argg clang

* improved in case of file:////  (probably)

* rewrote httpuriparse to support file:////

* fixed uriparse
2025-03-02 23:09:38 +02:00
Dmugetsu
d59536a71c
Adding Top and Bottom trophy option for pop window + Trophy improvements (#2566)
* Adding top button option for trophy pop up

* Ui fix

* Clang format

* improvements to trophy pr 

* improvements

* Note: The sound will only work in QT versions

* -.

* Update path_util.cpp

* Update path_util.cpp

* centered text when using top and bottom option

* Clang

* trophy viewer now opens in window not fullscreen

---------

Co-authored-by: DanielSvoboda <daniel.svoboda@hotmail.com>
2025-03-02 21:36:12 +02:00
DanielSvoboda
f4110c43a7
Fix time - sceKernelClockGettime (#2582) 2025-03-02 21:32:28 +02:00
Randomuser8219
9061028ce5
Reduce some service ID log spam (#2578)
* Change systemserivce param ID calling to debug only

Some games, including Namco Museum Archives spam this.

* Update userservice.cpp

Also reduces log spam in Dysmantle.
2025-03-02 11:55:45 +02:00
georgemoralis
636a90386b
fix for ime (#2475)
* fix for ime

* typo
2025-03-01 20:02:29 +02:00
DanielSvoboda
5e5ca2138e
Custom Trophy images / sound | and improvements (#2539)
* Custom Trophy images

* text and button - settings

* Description

* +

* plural

* translation for 'Trophy earned!'

* Revert: translation for 'Trophy earned!'

* play audio

* fixes crash due to having too many trophies

The game 'My Name is Mayo' has so many trophies in sequence that when overlapping them, the emulator ended up crashing, so if there is something on the screen and a new trophies are achieved, it will clear and show the new one.

* Animations, config: position, duration

* -

* TR

* fix sdl/qt

* clang \O/

* Side menu with filter options. Sorting

* +TR

* fix showHiddenCheck

* Time Unlocked

* Fixes ghost text, larger image, black text in light theme

* Button - Delete Trophy

* limits the width of Description - showMaximized

* changing column positions

* useEuropeanDateFormat

en_US, zh_CN, zh_TW, ja_JP, ko_KR, lt_LT, nb_NO, nl_NL
useEuropeanDateFormat = false
2025-02-28 08:31:42 +02:00
jarred wilson
15d10e47ea
fix: move trophy pngs to src/images (#2519)
* fix: move trophy pngs to src/images

* Fix pointers to trophy files

---------

Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
2025-02-24 22:39:27 +02:00
kalaposfos13
b8aac357cb
Fix SDL gyro and acceleration sensor handling (#2532)
* Fix sensor handling if they are enabled but an error was thrown regardless

* Initialise orientation to a default value + clang
2025-02-24 22:38:06 +02:00
TheTurtle
76b4da6212
video_core: Various small improvements and bug fixes (#2525)
* ir_passes: Add barrier at end of block too

* vk_platform: Always assign names to resources

* texture_cache: Better overlap handling

* liverpool: Avoid resuming ce_task when its finished

* spirv_quad_rect: Skip default attributes

Fixes some crashes

* memory: Improve buffer size clamping

* liverpool: Relax binary header validity check

* liverpool: Stub SetPredication with a warning

* Better than outright crash

* emit_spirv: Implement round to zero mode

* liverpool: queue::pop takes the front element

* image_info: Remove obsolete assert

The old code assumed the mip only had 1 layer thus a right overlap could not return mip 0. But with the new path we handle images that are both mip-mapped and multi-layer, thus this can happen

* tile_manager: Fix size calculation

* spirv_quad_rect: Skip default attributes

---------

Co-authored-by: poly <47796739+polybiusproxy@users.noreply.github.com>
Co-authored-by: squidbus <175574877+squidbus@users.noreply.github.com>
2025-02-24 14:31:12 +02:00
smiRaphi
f975c0603c
change sizeof to TmpMount.size (#2523)
Co-authored-by: smiRaphi <neogt404@gmail.com>
2025-02-24 12:44:22 +02:00
rainmakerv2
47ac8b6c03
Fix and add back Trophy type icons for both the trophy pop-up and viewer (#2522)
* Add back fixed trophy type icons to trophy viewer

* Remove unused declaration until it is needed again

* Fix trophy pop-up icons

* Adjust size and alignment based on trophy name length

---------

Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
2025-02-24 12:41:57 +02:00
rainmakerv2
e1e697a3ff
Revert use of embedded icons (#2509)
Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
2025-02-23 17:00:26 +02:00
rainmakerv2
22ca57b1f2
Trophy pop-up and viewer enhancements (#2493)
* Include trophy rarity icons in pop up, remove newlines from viewer

Fix layout

Update platinum.png

Fix linux and apple

* Smaller type icons, center text vertically

* use original icons

* MacOS fixes

* Address Review comments

Update build.yml

Update build.yml

Update build.yml

Update build.yml

Update build.yml

Update build.yml

Update build.yml

test

* Move trophy type to leftmost and trophy art to rightmost

* Embed resources

* Revert packaging of resources with builds

---------

Co-authored-by: rainmakerv2 <30595646+jpau02@users.noreply.github.com>
2025-02-23 10:00:24 +02:00
Stephen Miller
4f1baece33
Avoid processing job buffers before codec initialization (#2507) 2025-02-23 06:47:44 +03:00
georgemoralis
0aaeea4837
libcInternal HLE fixes (#2491)
* internal_vprintf was wrong

* reducing the calls to only needed (and tested one) . Fixed strcpy_s

* clang fix

* Added snprintf
2025-02-22 10:56:35 +02:00
kalaposfos13
1cc9e0d37f
Initial implementation of controller color config (#2411) 2025-02-14 12:30:49 +02:00
georgemoralis
57bdb6cac2 hotfix: another typo.. 2025-02-14 10:24:12 +02:00
georgemoralis
1dca54c165 hotfix: typo 2025-02-14 10:12:43 +02:00
georgemoralis
67a74a9357 hotfix: removed questionable setjmp 2025-02-14 10:03:57 +02:00
kalaposfos13
7db30d12cb
Libraries: Update libcInternal (#2265)
* Added all stubs + logging

* Added back memory and math functions from the original code + added some more math functions

* More string functions, snprintf, memmove and setjmp

* Add longjmp + clang

* gmtime, __cxa_atexit and log what functions some games use

* Add Mspace unreachable

* Renaming

* Take out mspace functions to their own file

* Factor out io to a new file

* Empty str and memory files

* Overloaded functions be like:

* str

* memory + math +clang

* clang...

* adjustments :D

* longjmp is questionable

---------

Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
2025-02-14 09:58:38 +02:00
DanielSvoboda
4dfe05db24
language fix (#2421) 2025-02-13 20:01:35 +02:00
Stephen Miller
455b23c6f1
Update video_out.cpp (#2416) 2025-02-13 16:29:26 +02:00
squidbus
ebe2aadb4c
gnmdriver: Implement sceGnmUpdateHsShader (#2412) 2025-02-12 19:45:42 -08:00
squidbus
7624e9482c
memory: Log for sceKernelMapNamedDirectMemory in more cases. (#2404) 2025-02-12 19:04:58 +02:00
Stephen Miller
b51c767296
Better bounds checks for sceKernelDlsym (#2394)
Unity, being the awful game engine it is, checks for a return value of zero to determine if sceKernelLoadStartModule failed. This results in it throwing an error code into sceKernelDlsym's handle parameter when the module it's searching for doesn't exist.
2025-02-09 19:31:07 -08:00
Stephen Miller
22357f70c2
Improve parameter checks for posix_pthread_rename_np (#2391) 2025-02-09 13:50:59 -08:00
squidbus
214eab2c52
gnmdriver: Fill in functions stubbed on real firmware. (#2379) 2025-02-09 18:57:10 +02:00
psucien
8f2883a388
video_out: HDR support (#2381)
* Initial HDR support

* fix for crashes when debug tools used
2025-02-09 15:54:54 +01:00
Vladislav Mikhalin
fb0871dbc8
ajm: mark empty batches as finished immediately (#2385) 2025-02-09 16:11:24 +03:00
Stephen Miller
ecfc940381
libSceHmd Stubs (#2355)
* Add generated libSceHmd stubs

* Implement ReprojectionQuery functions

These constant returns come from decompiling libSceHmd.

* Clang

* Clang
2025-02-05 17:24:53 +02:00
Stephen Miller
e757063d31
Improved error handling in sceKernelAllocateDirectMemory (#2037)
* Handle errors in sceKernelAllocateDirectMemory

* Improve accuracy of error cases

Some of our existing cases are normally EAGAIN returns.

* Improve logging on errors

* Clang

* TEMPORARY HACK FOR NBA TESTS

This will be removed before this PR is marked as ready, and is only here to make sure the other NBA games (and perhaps DOA3) work if some missing init behavior is handled.

* Revert "TEMPORARY HACK FOR NBA TESTS"

This reverts commit a0e27b0229.

* Change error message
2025-02-05 17:21:05 +02:00
georgemoralis
e4598e8821
sceVideoOutDeleteFlipEvent (#2339) 2025-02-03 23:27:48 -08:00
Stephen Miller
8ad650582a
Fix VideoOut events (#2330)
* Fix event data for VideoOut events

Fix is based on some decompilation work shared by red_prig.

* Cleanup

* Oops

* Style fixes

* Clang

* Fix libSceVideoOut event idents

Based on some decompilation work, events coming from libSceVideoOut use a separate set of values for identifiers. These values are only converted to OrbisVideoOutEventId values during calls to sceVideoOutGetEventId.
For convenience, I've placed all relevant identifiers into a enum called OrbisVideoOutInternalEventId.
Thanks to @red_prig for the tips.

* Fix?

Seems like `static_cast<u32>(hint) & 0xFF == event.ident` here, and doing those right shifts on the event.ident winds up breaking stuff.
Without this change, the if always fails because event_id was getting set to 0 instead.

* Clang
2025-02-03 17:37:28 +02:00