Commit graph

606 commits

Author SHA1 Message Date
Mary 305f06eb71
HLE: Fix integer sign inconcistency accross the codebase (#2222)
* Make all title id instances unsigned

* Replace address and size with ulong instead of signed types

Long overdue change.
Also change some logics here and there to optimize with the new memory
manager.

* Address Ac_K's comments

* Remove uneeded cast all around

* Fixes some others misalignment
2021-04-24 12:16:01 +02:00
Ac_K c46f6879ff
account: add Custom User Profiles support (#2227)
* Initial Impl

* Fix names

* remove useless ContentManager

* Support backgrounds and improve avatar loading

* Fix firmware checks

* Addresses gdkchan feedback
2021-04-23 22:26:31 +02:00
Ac_K 3e61fb0268
mm: Cleaned up the service a bit (#2233) 2021-04-22 23:35:01 +02:00
riperiperi dc8c781d7a
Return focus from controller applet after completion (#2218)
* Return focus from controller applet after completion

This fixes controller applet related in Mario Kart 8 Deluxe, in 2 player mode or when opening the applet in character select.

* Return focus for player select
2021-04-17 18:57:03 +02:00
Ac_K e520eecb5b
am: Stub ExtendSaveData (#2209) 2021-04-14 14:55:11 +02:00
Ac_K 9575a7638a
nsd/ssl: Fix Resolve/ResolveEx and stub GetConnectionCount (#2208) 2021-04-14 14:47:19 +02:00
VocalFan 978b69b706
[ImgBot] Optimize images (#2205)
*Total -- 555.93kb -> 486.47kb (12.49%)

/Ryujinx/Ui/Resources/Logo_GitHub.png -- 26.25kb -> 15.48kb (41.04%)
/Ryujinx/Ui/Resources/Logo_Discord.png -- 13.29kb -> 7.89kb (40.63%)
/Ryujinx/Ui/Resources/Logo_Patreon.png -- 15.12kb -> 9.79kb (35.27%)
/Ryujinx/Ui/Resources/Icon_NRO.png -- 13.58kb -> 11.06kb (18.5%)
/Ryujinx/Ui/Resources/Icon_NCA.png -- 13.35kb -> 10.96kb (17.92%)
/Ryujinx/Ui/Resources/Icon_NSO.png -- 13.62kb -> 11.20kb (17.76%)
/Ryujinx/Ui/Resources/Icon_XCI.png -- 12.79kb -> 10.53kb (17.61%)
/Ryujinx/Ui/Resources/Icon_NSP.png -- 12.89kb -> 10.66kb (17.32%)
/Ryujinx/Ui/Resources/Logo_Twitter.png -- 16.54kb -> 14.40kb (12.93%)
/Ryujinx/Ui/Resources/Controller_JoyConPair.svg -- 74.83kb -> 65.64kb (12.28%)
/Ryujinx/Ui/Resources/Controller_ProCon.svg -- 66.51kb -> 58.83kb (11.55%)
/Ryujinx/Ui/Resources/Controller_JoyConRight.svg -- 87.82kb -> 80.99kb (7.77%)
/Ryujinx.HLE/HOS/Services/Account/Acc/DefaultUserImage.jpg -- 51.73kb -> 47.85kb (7.49%)
/Ryujinx/Ui/Resources/Controller_JoyConLeft.svg -- 73.68kb -> 68.34kb (7.25%)
/Ryujinx/Ui/Resources/Logo_Amiibo.png -- 11.40kb -> 11.08kb (2.82%)
/Ryujinx/Ui/Resources/Logo_Ryujinx.png -- 52.52kb -> 51.76kb (1.45%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>

Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2021-04-14 01:20:30 +02:00
Mary 0746b83edf
Initial support for the new 12.x IPC system (#2182)
* Rename CommandAttribute as CommandHIpcAttribute to prepare for 12.x changes

* Implement inital support for TIPC and adds SM command ids

* *Ipc to *ipc

* Missed a ref in last commit...

* CommandAttributeTIpc to CommandAttributeTipc

* Addresses comment and fixes some bugs around

TIPC doesn't have any padding requirements as buffer C isn't a thing
Fix for RegisterService inverting two argument only on TIPC
2021-04-14 00:01:24 +02:00
Mark Araujo faa654dbaf
Improves logging to console. (#2146)
* Restore removed text

* Adds more items to logs:

- Remove #1942

* Further removal of changes from #1942

* Removes hardcoded config state variables for logging
- Adds Configuration logging

* Decoupled logging from ReactiveObject
- Event handler added to Configuration state to handle logging of value changes

* Decoupled logging from ReactiveObject
- Event handler added to Configuration state to handle logging of value changes
2021-04-13 21:58:47 +02:00
Ac_K 7344dee475
account: Adds AccountManager (#2184)
* account: Adds Account Manager

In a way to have Custom User Profiles merged in master faster, this PR adds a `AccountManager` class (based on `AccountUtils` class) and the following changes have been made:
- Adds a "default profile values" which were the old hardcoded ones.
- The image profile is moved to the Account service folder.
- The hardcoded UserId for the savedata is now using the `AccountManager` last opened one.
- The DeviceId in Mii service is changed to the right value (checked by REd sys:set call).

* Fix csproj

* Addresses gdkchan's comments

* Fix UserProfile fields

* Fix mii GetDeviceId()

* Update Ryujinx.HLE.csproj
2021-04-13 03:16:43 +02:00
Ac_K b662a26c7e
nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service (#2186)
* nifm/ssl: Implement GetCurrentNetworkProfile and stub Ssl Service

* remove InterfaceVersion
2021-04-13 03:04:18 +02:00
Mary 73881fad19
Surface Flinger: Fix an oversight when closing a layer (#2192)
* Surface Flinger: Fix an oversight when closing a layer

As the title say.
I also took the liberty of changing the logic on how we select the
current layer being rendered to make it more explicit when opening and
creating layers.

NOTE: Found by Ac_k.

* check for RenderLayerId and not the dictionary size

This fix a possible race condition between the time you create a layer and set the one currently used for rendering
2021-04-13 02:56:16 +02:00
Ac_K 58660c8536
friend: Fixes PermissionLevel names (#2185)
This PR fixes the permission level names, nothing more.
2021-04-08 00:42:06 +02:00
gdkchan 874540bb5c
Allow DRAM size to be increased from 4GB to 6GB (#2174)
* Allow DRAM size to be increased from 4GB to 6GB

* Add option on the UI
2021-04-04 14:06:59 +02:00
Caian Benedicto 9ae60207c4
Fix Tamper Machine crash and timings (#2159)
* Add missing return

* Change TamperMachine sleep to 83ms

* Change constant name to PascalCase
2021-04-02 15:42:25 +02:00
mageven 4443e18909
Patch up DNS Blacklist (#2153)
Make the regex patterns case insensitive for robustness
2021-03-30 00:55:53 +02:00
mageven 0ee314fb3b
Optimize PrintRoSectionInfo (#2151) 2021-03-29 18:31:16 +02:00
Ac_K 0d984f61b2
am: Stub ILibraryAppletAccessor RequestExit (#2142)
This PR stub ILibraryAppletAccessor (20) RequestExit call which is needed by Monster Hunter Rise when you press "Private Policy" at the beginning.
The game try to run the `WebApplet` which is already partially stubbed, then call `RequestExit` to know when the applet exits. If the call does nothing, the game just hang forever. If you signals the event, you can interracts with the menu again.
2021-03-28 01:13:01 +01:00
Ac_K e60bae1a94
misc: Add credit to AmiiboAPI properly and fix a wrong warning code (#2150)
* misc: Add credit to AmiiboAPI properly and fix a warning disable

This PR adds a properly credit to AmiiboAPI which is used in our Amiibo emulation in the Readme and in the about window.
I've changed a wrong warning code added in a recent PR too.

* Update README.md

* Fix aligment
2021-03-27 15:41:09 +01:00
Caian Benedicto 0c1ea1212a
Add the TamperMachine module for runtime mods and cheats (#1928)
* Add initial implementation of the Tamper Machine

* Implement Atmosphere opcodes 0, 4 and 9

* Add missing TamperCompilationException class

* Implement Atmosphere conditional and loop opcodes 1, 2 and 3

* Inplement input conditional opcode 8

* Add register store opcode A

* Implement extended pause/resume opcodes FF0 and FF1

* Implement extended log opcode FFF

* Implement extended register conditional opcode C0

* Refactor TamperProgram to an interface

* Moved Atmosphere classes to a separate subdirectory

* Fix OpProcCtrl class not setting process

* Implement extended register save/restore opcodes C1, C2 and C3

* Refactor code emitters to separate classes

* Supress memory access errors from the Tamper Machine

* Add debug information to tamper register and memory writes

* Add block stack check to Atmosphere Cheat compiler

* Add handheld input support to Tamper Machine

* Fix code styling

* Fix build id and cheat case mismatch

* Fix invalid immediate size selection

* Print build ids of the title

* Prevent Tamper Machine from change code regions

* Remove Atmosphere namespace

* Remove empty cheats from the list

* Prevent code modification without disabling the tampering

* Fix missing addressing mode in LoadRegisterWithMemory

* Fix wrong addressing in RegisterConditional

* Add name to the tamper machine thread

* Fix code styling
2021-03-27 15:12:05 +01:00
Ac_K 32be8caa9d
caps: Implement SaveScreenShot calls and cleanup (#2140)
* caps: Implement SaveScreenShot calls and cleanup

This PR implement:
- caps:u IAlbumApplicationService (32) SetShimLibraryVersion
- caps:c IAlbumControlService (33) SetShimLibraryVersion
- caps:su IScreenShotApplicationService (32) SetShimLibraryVersion
- caps:su IScreenShotApplicationService (203/205/210) SaveScreenShotEx0/SaveScreenShotEx1/SaveScreenShotEx2

ImageSharp is used to save the raw screenshot data as a JPG file following what the service does.
All screenshots are save in: `%AppData%\Ryujinx\sdcard\Nintendo\Album` folder. (as example a screenshot file path will be `%AppData%\Ryujinx\sdcard\Nintendo\Album\2021\03\26\2021032601020300-0123456789ABCDEF0123456789ABCDEF.jpg`

This is needed by Animal Crossing: New Horizon where screenshots looks like this:

And this is needed in Monster Hunter Rise but screenshots are currently empty due to another issue.

* remove useless comment

* Addresses gdkchan feedback

* Addresses gdkchan feedback 2

* remove useless comment 2

* Fix nits
2021-03-26 01:16:08 +01:00
Ac_K 53b9267b47
am/ectx: Implement SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled and add service placeholder (#2136)
* am/ectx: Implement SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled and add service placeholder

This PR implements `am` service call `SetRequestExitToLibraryAppletAtExecuteNextProgramEnabled` (closes #2028) accordingly to RE and adds placeholder for the `ectx` service. Both were added in 11.0.0+ firmware and are needed to boots games which needs this version.
Some games are now playable/bootable:

* Remove unused warning
2021-03-25 23:25:49 +01:00
Ac_K e5741fae2d
sfdnsres: Cleanup service and implements some calls (#2130)
* sfdnsres: Cleanup service and implements some calls

This PR is a big cleanup to our current implementation of `sfdnsres` service.
Additionnaly to that, some calls and fix have been done by @Thog (PRd with approval, thanks to her).
- Implementation of `GetAddrInfoRequest` (Fixes #637).
- Partial implementation of `GetHostByNameRequestWithOptions`, `GetHostByAddrRequestWithOptions` and `GetAddrInfoRequestWithOptions` (Fixes #642, Fixes #1233).

A DNS Blacklist have been done by @riperiperi (which is currently used in LDN build, then that reduces code differences between the LDN build and master.

Now a lot of games are playable or are blocked to the menu because it needs online service:

Co-Authored-By: Mary <1760003+Thog@users.noreply.github.com>
Co-Authored-By: riperiperi <6294155+riperiperi@users.noreply.github.com>

* Addressed gdkchan's comments

* IPAddress[] to IEnumerable

* Nits

Co-authored-by: Mary <1760003+Thog@users.noreply.github.com>
Co-authored-by: riperiperi <6294155+riperiperi@users.noreply.github.com>
2021-03-24 18:43:23 +01:00
Ac_K 39899c0407
IPC: Remove IIpcService interface (#2121)
This PR remove the IIpcService.cs interface usage which isn't needed anymore since the interface is only used by IpcService class. We can use it directly.
2021-03-19 00:31:08 +01:00
Joshi234 a8c945f35f
Add items to standard logs (#1942)
* Added more items to log

* Update MainWindow.cs

* Added log when changing settings

* fix formating and add log when toggling vsync and docked

* Update Ryujinx/Ui/MainWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx/Ui/MainWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx/Ui/Windows/SettingsWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Fix formating

* Change Location according to suggestion

* Implemented OpenDataStorageWithProgramIndex

* Update IFileSystemProxy.cs

* Update IFileSystemProxy.cs

* Commited that file on accidant

* Revert "Merge branch 'master' of https://github.com/Joshi234/Ryujinx"

This reverts commit 375f430455, reversing
changes made to 672e2c8f7d.

* Revert "Update IFileSystemProxy.cs"

This reverts commit 672e2c8f7d.

* Update IFileSystemProxy.cs

* Update ISystemSettingsServer.cs

* removed accidantel addition of IFileSystemProxy.OpenDataStorageWithProgramIndex

* Fix formating and add missing stub

* Update ISystemSettingsServer.cs

* Added more items to log

* Update MainWindow.cs

* Added log when changing settings

* fix formating and add log when toggling vsync and docked

* Fix formating

* Update Ryujinx/Ui/MainWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx/Ui/MainWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx/Ui/Windows/SettingsWindow.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Change Location according to suggestion

* Fix Rebase stuff

* Change Logger.Notice to Loger.Info

* Update ISystemSettingsServer.cs

* Update ISystemSettingsServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2021-03-19 00:09:33 +01:00
Ac_K db56b2166d
ErrorApplet: Implement ApplicationErrorArg (#2123)
This PR implement `ApplicationErrorArg` to the Error Applet. It's used by the guest to throw some specific error messages.
The code was done for (and merged) LDN2 build since long time ago and have been tested a bunch of times because of that! In a way to reduce the differences between LDN and master build it's fine to add it to master.
2021-03-19 00:04:49 +01:00
Ac_K a56423802c
nfp: Amiibo scanning support (#2006)
* Initial Impl.

* You just want me cause I'm next

* Fix some logics

* Fix close button
2021-03-18 21:40:20 +01:00
mageven e44850fed4
Implement friendlier portable mode (#1885)
* Implement friendlier portable mode

* Remove first run dialog

* Disable updates in portable mode for now

* Convert relative custom paths to absolute ones

Also, fix a regression when custom path doesn't exist
2021-03-15 22:10:36 +01:00
gdkchan 5ab5b0e709
Close ILibraryAppletAccessor handles on disposal (#2094) 2021-03-10 21:36:38 +01:00
Billy Laws bab6eedccf
Fix SetStandardSteadyClockInternalOffset permission check (#2076)
I happened to notice this when checking Ryu's IPC structures. After double checking with RE it seems the current check is incorrect so use the correct member to fix that.
2021-03-04 11:58:21 +01:00
Caian Benedicto 8b4e4fc076
Improve heuristic for showing the keyboard (#2066) 2021-02-28 11:26:00 +01:00
Mary f556c80d02
Haydn: Part 1 (#2007)
* Haydn: Part 1

Based on my reverse of audio 11.0.0.

As always, core implementation under LGPLv3 for the same reasons as for Amadeus.

This place the bases of a more flexible audio system while making audout & audin accurate.

This have the following improvements:
- Complete reimplementation of audout and audin.
- Audin currently only have a dummy backend.
- Dramatically reduce CPU usage by up to 50% in common cases (SoundIO and OpenAL).
- Audio Renderer now can output to 5.1 devices when supported.
- Audio Renderer init its backend on demand instead of keeping two up all the time.
- All backends implementation are now in their own project.
- Ryujinx.Audio.Renderer was renamed Ryujinx.Audio and was refactored because of this.

As a note, games having issues with OpenAL haven't improved and will not
because of OpenAL design (stopping when buffers finish playing causing
possible audio "pops" when buffers are very small).

* Update for latest hexkyz's edits on Switchbrew

* audren: Rollback channel configuration changes

* Address gdkchan's comments

* Fix typo in OpenAL backend driver

* Address last comments

* Fix a nit

* Address gdkchan's comments
2021-02-26 01:11:56 +01:00
Ac_K 8cdb50d703
appletAE: Implement SetLcdBacklighOffEnabled (#2037)
This PR implement `appletAE ICommonStateGetter SetLcdBacklighOffEnabled` accordingly to RE.

Closes #2021
2021-02-21 09:21:32 +01:00
mageven 65eb9901f1
Allow modding AddOnContent RomFS (#2024)
Simplify some misc logic
2021-02-20 01:25:01 +01:00
mageven d9b3f3fa3a
Allow reconfiguring "Ignore Missing Services" during emulation (#2034) 2021-02-19 20:31:57 +01:00
Ac_K b93fe5979a
nifm: Fix returned buffer size of GetClientId (#2036)
This PR fix an issue introduced on last IPC rewrite PRs where some returned buffer size have to be explicit now.
`GetClientId` without an explicit buffer size return some garbage to the guest and then `nifm` service crashes because of a wrong ClientId. It's fixed now.

Horizon Chase Turbo and Doom regression are fixed now.  (Probably some other games too)
2021-02-19 20:18:13 +01:00
Ac_K c6d3c4207a
settings: Fix returned buffer size of GetFirmwareVersion (#2029) 2021-02-17 21:10:53 +01:00
Ac_K 80ed8596c1
prepo: Implement GetSystemSessionId and add perms (#2014)
* prepo: Implement GetSystemSessionId and add perms

* address feedbacks
2021-02-11 20:24:54 +01:00
Caian Benedicto f16d7f91f1
Improve inline keyboard compatibility (#1959)
* Improve compatibility of the inline keyboard with some games

* Send an empty first text to avoid crashing some games

* Implement SetCustomizedDictionaries and fix SetCustomizeDic

* Expand Bg and Fg –abbreviations in the swkbd applet

* Fix variable names and add comments to software keyboard
2021-02-11 01:28:44 +01:00
Joshi234 51f7cc1483
Implemented ISystemSettingsServer.IsUserSystemClockAutomaticCorrectionEnabled (#1932)
* Added IsUserSystemClockAutomaticCorrectionEnabled

This is used when a game want to check if you game is synced with a server

* Update ISystemSettingsServer.cs

* Implemented OpenDataStorageWithProgramIndex

* Update IFileSystemProxy.cs

* Commited that file on accidant

* Update IFileSystemProxy.cs

* Revert "Merge branch 'master' of https://github.com/Joshi234/Ryujinx"

This reverts commit 375f430455, reversing
changes made to 672e2c8f7d.

* Revert "Update IFileSystemProxy.cs"

This reverts commit 672e2c8f7d.

* Update IFileSystemProxy.cs

* Update ISystemSettingsServer.cs

* removed accidantel addition of IFileSystemProxy.OpenDataStorageWithProgramIndex

* Update Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Update Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Fix formating and add missing stub

* Update ISystemSettingsServer.cs

* Update ISystemSettingsServer.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2021-02-09 09:41:31 +01:00
gdkchan 5ea7d77981
Fix inter-process data copy on non-contiguous physical regions (#1988) 2021-02-08 10:54:49 +11:00
mageven d1e24ba5c2
Initial Setup: Reload keys before verifying firmware (#1955)
* Initial Setup: Reload keys before verifying firmware

Also, display the NoKeys dialog if keyset is empty when verifying
firmware.

* LoadApplications: Remove the lone debug log and print the error directly
2021-01-26 18:45:07 +01:00
mageven 6982282cc8
TZ: Fix loop condition in GetTZName (#1950)
Closes #1949
2021-01-23 13:29:14 +01:00
Caian Benedicto 3b20080637
Fix inverted read only flag in transfer memory creation (#1945) 2021-01-23 13:48:03 +11:00
gdkchan 6a95a3b01a
Fix alignment on CreateTransferMemoryStorage (#1937) 2021-01-19 21:48:27 -03:00
Ac_K 1364f36161
am: Implement CreateHandleStorage and fixes (#1929) 2021-01-19 13:28:35 +11:00
Bruno Macabeus 996e6905ba
android-fence: call callback when fence is invalid (#1881) 2021-01-13 10:53:13 +01:00
Caian Benedicto e57b140429
Add support for inline software keyboard (#1868)
* Add background mode configuration to SoftwareKeyboardApplet

* Add placeholder text generator for Software Keyboard in background mode

* Add stub for GetIndirectLayerImageMap

* Fix default state of DecidedCancel response

* Add GUI text input to Software Keyboard in background mode

* Fix graphical glitch when Inline Software Keyboard appears

* Improve readability of InlineResponses class

* Improve code styling and fix compiler warnings

* Replace ServiceDisplay log class by ServiceVi

* Replace static readonly by const

* Add proper finalization to the keyboard applet in inline mode

* Rename constants to start with uppercase

* Fix inline keyboard not working with some games

* Improve code readability

* Fix code styling
2021-01-11 19:27:55 +01:00
Steven Smith 5117b21c52
Only attempt to import common tickets. (#1886) 2021-01-11 14:47:13 +11:00
Ac_K 3c09abf9e6
pctl: Stub IsFreeCommunicationAvailable (#1893)
* pctl: Stub IsFreeCommunicationAvailable

This PR stub call IsFreeCommunicationAvailable since it's the same as call CheckFreeCommunicationPermission without a sets of an internal field.
I've fixed a wrong logic found while I'm checked the call by RE.

This fix #1883.

* Fix comments
2021-01-10 21:26:59 +01:00
gdkchan 8e0a421264
Fix remap when handle is 0 (#1882)
* Nvservices cleanup and attempt to fix remap

* Unmap if remap handle is 0

* Remove mapped pool add from Remap
2021-01-10 10:11:31 +11:00
Ac_K 71e2a00221
am: stub PresetLibraryAppletGpuTimeSliceZero (#1876) 2021-01-08 23:43:36 -03:00
mageven acf3a3f837
Update missing sample timestamp in DebugPad (#1873) 2021-01-07 19:43:33 +01:00
Somebody Whoisbored a03ab0c4a0
Fix exefs mod loading with unpacked games (#1857)
* Add the ability to layeredfs individual exefs with mod loader

* Address code style issues

* Further adjustments to the mod loading

* Update Ryujinx.HLE/HOS/ModLoader.cs

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Apply suggestions from code review

Co-authored-by: Ac_K <Acoustik666@gmail.com>

* Address issue with checking for NSO existence (and code style fixes)

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2021-01-03 12:30:31 +01:00
Ac_K b001040c2f
account: Services Refactoring (#1833)
* account: Services Refactoring

* Remove extra empty space

* Fix IProfile::Get

* address gdkchan feedback
2021-01-02 23:34:28 +01:00
Ac_K 4f01c13f50
surfaceflinger: Fix fence callback issue (#1839)
This PR fixes a regression introduced in #1741. The actual implementation do the assumption of fences always exist and then registering the callback.
Homebrews may not use fences, so the code crashes when it try to register the callback.
2021-01-02 23:21:44 +01:00
Bruno Macabeus 3e7383b3fd
services: add "apm:p" (#1854)
* services: add "apm:p"

* review: change amp:p version range

* review: remove uneeded calls

* review: fix ImanagerPrivileged
2021-01-02 16:11:38 +01:00
Bruno Macabeus b9fd7c8b23
Remove long <-> ulong casts from Nvservices code (#1848)
* Remove long <-> ulong casts from Nvservices code

* review: fix lint
2021-01-01 19:03:33 -03:00
gdkchan 532b8cad13
Update KAddressArbiter implementation to 11.x kernel (#1851)
* Update KAddressArbiter implementation to 11.x kernel

* InsertSortedByPriority is no longer needed
2021-01-01 14:59:26 -03:00
Somebody Whoisbored fb0db32338
Add the ability to add individual files exefs with mod loader (#1766)
Co-authored-by: Ac_K <Acoustik666@gmail.com>
2020-12-29 20:54:32 +01:00
LDj3SNuD b5c215111d
PPTC Follow-up. (#1712)
* Added support for offline invalidation, via PPTC, of low cq translations replaced by high cq translations; both on a single run and between runs.

Added invalidation of .cache files in the event of reuse on a different user operating system.

Added .info and .cache files invalidation in case of a failed stream decompression.

Nits.

* InternalVersion = 1712;

* Nits.

* Address comment.

* Get rid of BinaryFormatter.

Nits.

* Move Ptc.LoadTranslations().

Nits.

* Nits.

* Fixed corner cases (in case backup copies have to be used). Added save logs.

* Not core fixes.

* Complement to the previous commit. Added load logs. Removed BinaryFormatter leftovers.

* Add LoadTranslations log.

* Nits.

* Removed the search and management of LowCq overlapping functions.

* Final increment of .info and .cache flags.

* Nit.

* GetIndirectFunctionAddress(): Validate that writing actually takes place in dynamic table memory range (and not elsewhere).

* Fix Ptc.UpdateInfo() due to rebase.

* Nit for retrigger Checks.

* Nit for retrigger Checks.
2020-12-17 20:32:09 +01:00
riperiperi 10aa11ce13
Interrupt GPU command processing when a frame's fence is reached. (#1741)
* Interrupt GPU command processing when a frame's fence is reached.

* Accumulate times rather than %s

* Accurate timer for vsync

Spin wait for the last .667ms of a frame. Avoids issues caused by signalling 16ms vsync. (periodic stutters in smo)

* Use event wait for better timing.

* Fix lazy wait

Windows doesn't seem to want to do 1ms consistently, so force a spin if we're less than 2ms.

* A bit more efficiency on frame waits.

Should now wait the remainder 0.6667 instead of 1.6667 sometimes (odd waits above 1ms are reliable, unlike 1ms waits)

* Better swap interval 0 solution

737 fps without breaking a sweat. Downside: Vsync can no longer be disabled on games that use the event heavily (link's awakening - which is ok since it breaks anyways)

* Fix comment.

* Address Comments.
2020-12-17 19:39:52 +01:00
Ac_K eae39f80e7
nim: Implement IsLargeResourceAvailable (#1821)
* nim: Implement IsLargeResourceAvailable

* Fix comments
2020-12-17 05:19:28 +01:00
gdkchan f5d64b4d68
Terminate application before services (#1812)
* Terminate application before services

* Use flags instead of title ID
2020-12-17 01:44:06 +01:00
Ac_K 11222516c4
gui/gpu: Implement setting and toggle for Aspect Ratio (#1777)
* gui/gpu: Implement setting and toggle for Aspect Ratio

* address gdkchan feedback and add 16:10

* fix config.json file

* Fix rebase

* Address gdkchan feedback

* Address rip feedback

* Fix aspectWidth
2020-12-15 23:19:07 -03:00
Ac_K 808380690c
am/gui: Implement Wake-up message (#1750)
* am/gui: Implement Wake-up message.

This implement the ability to send a Wake-up (Resume) message to the guest.
Sometime games needs to Sleep and Wake-up the switch to unlock some ingame features.

* Address gdkchan feedback
2020-12-15 21:41:42 -03:00
gdkchan 19d18662ea
Correct type of executable sizes (#1802) 2020-12-13 08:30:27 +01:00
gdkchan ef157bbe26
Remove inexistent buffer from GetNintendoAccountUserResourceCacheForApplication (#1809) 2020-12-12 22:10:12 +11:00
gdkchan 74aa7b20be
Rewrite size for fixed size buffers (#1808) 2020-12-12 14:06:20 +11:00
sharmander 8a6607540e
GPU: Improve unnecessary return value in Map function. (#1799)
* Implement VFNMA.F<32/64>

* Update PTC Version

* Update Implementation & Renames & Correct Order

* Add Logging

* Additional logging

* Add additional check to restart loop from beginning if address goes beyond maximum allowed.

* Additional Check that the total range required doesn't exceed capacity of allocator addresses.

* Improve logging

* Ensure hex output

* Update Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Remove extra page at end

* Remove unnecessary return val in Map function.

* Remove incorrect description

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2020-12-11 06:05:53 +01:00
sharmander d9ec2b3a81
GPU: Resolve Memory Allocation Issues (#1797)
* Implement VFNMA.F<32/64>

* Update PTC Version

* Update Implementation & Renames & Correct Order

* Add Logging

* Additional logging

* Add additional check to restart loop from beginning if address goes beyond maximum allowed.

* Additional Check that the total range required doesn't exceed capacity of allocator addresses.

* Improve logging

* Ensure hex output

* Update Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Remove extra page at end

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2020-12-10 21:32:23 +01:00
Ac_K c0b9ac6653
ngct: Fix services and stub calls (#1756) 2020-12-10 03:08:28 +01:00
sharmander 06aa8a7578
GPU - Improve Memory Allocation (#1722)
* Implement TreeMap from scratch.

Begin implementation of MemoryBlockManager

* Implement GetFreePosition using MemoryBlocks

* Implementation of Memory Management using a Tree.

Still some issues to work around, but promising thus far.

* Resolved invalid mapping issue.

Performance appears promising.

* Add tick metrics

* Use the logger instead

* Use debug loggin instead of info.

* Remove unnecessary code. Add descriptions of added functions.

* Improve memory allocation even further. As well as improve speed of position fetching.

* Add TreeDictionary to Ryujinx Commons

Removed Unnecessary  Usigns

* Add a Performance Profiler + Improve ReserveFixed

* Begin transition to allocation in nvdrv

* Create singleton nvmemallocator

* Moved Allocation into Nv Related Files

As requested by gdkchan, any allocation of memory has been moved into the driver files.

Mapping remains in the GPU MemoryManager.

* Remove unnecessary usings

* Add missing descriptions

* Correct descriptions

* Fix formatting.

* Remove unnecessary whitespace

* Formatting / Convention Updates

* Changes / Fixes

Made syntax and convention changes as requested by gdkchan.

Fixed an issue where IsRegionUsed would return the wrong boolean.

Fixed an issue where GetFreePosition was asked for an address instead of a size.

* Undo commenting of Assert in shader cache

* Update Ryujinx.Common/Collections/TreeDictionary.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Resolved many suggestions

* Implement Improved TreeDictionary

Based off of Pseudo code and custom implementations.

* Rename _set to _dictionary

* Remove unused code

* Remove unused code.

* Remove unnecessary MapLow function.

* Resolve data-structure based issues

* Make adjustments to memory management.

Deactive de-allocation for now, it causes more harm than good.

* Minor refactorings + Re-implement deallocation

Also cleaned up unnecessary code.

* Add Tests for TreeDictionary

* Update data structure to properly balance the tree

* Experimental Implementation:

1. Reduce Time to Next Node to O(1) Runtime
2. Reduce While Loop Ct To 2 (In Most Cases)

* Address issues w/ Deallocating Memory

* Final Build

+ Fully Implement Dictionary Interface for new Data Structure
+ Cover All Memory Allocation Edge Cases, particularly w/ Games that De-Allocate a lot.

* Minor Corrections

Give TreeDictionary its own count (do not depend on inner dictionary)

Properly remove adjacent allocations

* Add AsList

* Fix bug where internal dictionary wasn't being updated w/ new node for overwritten key.

* Address comments in review.

* Fix issue where block wouldn't break out (Fixes UE4 issues)

* Update descriptions

* Update descriptions

* Reduce Node visibility to protect TreeDictionary Integrity + Remove usage of struct.

* Update tests to use new TreeDictionary implementation.

* Remove usage of dictionary in TreeDictionary

* Refactoring / Renaming

* Remove unneeded memoryblock class.

* Add space for while

* Add space for if

* Formatting / descriptions

* Clarified some descriptions

* Reduce visibility of memory allocator

* Edit method names to make more sense as memory blocks are no longer in use.

* Make names consistent.

* Protect against npe when sucessorof is called against keys that don't exist. (Not in use by memory manager, this is for other prs that might use this data structure)

* Possible edge-case resolve

* Update Ryujinx.Common/Collections/TreeDictionary.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Update Ryujinx.HLE/HOS/Services/Nv/NvMemoryAllocator.cs

Co-authored-by: gdkchan <gab.dark.100@gmail.com>

* Reduce # of unnecessary duplicate variables / Reduce visibility of variables only internally used.

* Rename count to _count

* Update Description of Add method.

* Fix copypasta

* Address comments

* Address comments

* Remove whitespace

* Address comments, condense variables.

* Consolidate vars

* Fix whitespace.

* Nit

* Fix exception msg

* Fix arrayIndex check

* Fix arrayIndex check + indexer

* Remove whitespace from cast

Co-authored-by: gdkchan <gab.dark.100@gmail.com>
2020-12-09 19:26:05 -03:00
gdkchan 48278905d1
Rewrite scheduler context switch code (#1786)
* Rewrite scheduler context switch code

* Fix race in UnmapIpcRestorePermission

* Fix thread exit issue that could leave the scheduler in a invalid state

* Change context switch method to not wait on guest thread, remove spin wait, use SignalAndWait to pass control

* Remove multi-core setting (it is always on now)

* Re-enable assert

* Remove multicore from default config and schema

* Fix race in KTimeManager
2020-12-09 19:20:05 -03:00
Ac_K 3484265d37
am: Implement GetHealthWarningDisappearedSystemEvent (#1788)
This implement IApplicationFunctions GetHealthWarningDisappearedSystemEvent call which is needed by Mario Kart 8 in Chinese version. Call was checked by RE.
We still have to determine where to signals some AM events.

Thanks to Kakasita on our Discord to reported this and confirm this works fine!
2020-12-09 00:08:36 +01:00
riperiperi 4594c3b310
Signal memory tracking before/after mapping into another process (#1785)
* Signal memory tracking before/after mapping into another process

* Wording.

* Add missing method.
2020-12-07 21:42:17 -03:00
Mary 0ab1c42eea
Make sure to not leak copy handles passed in request (#1772)
* Make sure to not leak copy handles passed in request

Following last gdkchan's PR this make sure to close copy handles that
are passed by guest when it should.

* fix comment copy pasta
2020-12-03 19:19:10 +01:00
gdkchan 1b053d2222
Close audio WorkBuffer transfer memory handle (#1770) 2020-12-02 21:58:20 +01:00
gdkchan f7617cae12
Create a single guest process per IPC message processor (#1769) 2020-12-02 13:14:44 +01:00
gdkchan cf6cd71488
IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel (#1458)
* IPC refactor part 2: Use ReplyAndReceive on HLE services and remove special handling from kernel

* Fix for applet transfer memory + some nits

* Keep handles if possible to avoid server handle table exhaustion

* Fix IPC ZeroFill bug

* am: Correctly implement CreateManagedDisplayLayer and implement CreateManagedDisplaySeparableLayer

CreateManagedDisplaySeparableLayer is requires since 10.x+ when appletResourceUserId != 0

* Make it exit properly

* Make ServiceNotImplementedException show the full message again

* Allow yielding execution to avoid starving other threads

* Only wait if active

* Merge IVirtualMemoryManager and IAddressSpaceManager

* Fix Ro loading data from the wrong process

Co-authored-by: Thog <me@thog.eu>
2020-12-02 00:23:43 +01:00
Ac_K 7b66cb0d90
audio: Cleanup Ryujinx.Audio and fix OpenAL issue (#1746)
* audio: Cleanup SoundIO and fix OpenAL issue

* fix tabs by spaces

* Fix extra spaces

* Fix SoundIO.cs

* Fix ContainsAudioOutBuffer
2020-11-27 20:55:00 +01:00
Ac_K 632a84155b
pctl: Implement IsRestrictionEnabled and fix CheckFreeCommunicationPermission (#1747)
* pctl: Implement IsRestrictionEnabled and fix CheckFreeCommunicationPermission

* fix comment
2020-11-24 21:19:06 +01:00
Ac_K 44c1f16280
am: Fix GetSaveDataSize stub (#1748) 2020-11-24 20:45:23 +01:00
Ac_K fd0b9d1926
am: Cleaning and stub TryPopFromFriendInvitationStorageChannel (#1738) 2020-11-21 23:38:34 +01:00
Ac_K 3dc9bab91f
audin: fix wrong id ListAudioInsAuto call (#1737) 2020-11-21 21:43:36 +01:00
Ac_K 57c4e6ef21
audout: Implement and fix some calls (#1725)
* audout: Implement GetAudioOutBufferCount, GetAudioOutPlayedSampleCount and FlushAudioOutBuffers

This PR implement audout service calls:
- GetAudioOutBufferCount
- GetAudioOutPlayedSampleCount
- FlushAudioOutBuffers

The RE calls just give some hints about no extra checks.
Since we use a totally different implementation because of our backend, I can't do something better for now.

SetAudioOutVolume and GetAudioOutVolume are fixed too by set/get the volume of the current opened track, previous implementation was wrong.

This fix #1133, fix #1258 and fix #1519.

Thanks to @jduncanator for this help during the implementation and all his precious advices.

* Fix some debug leftovers

* Address jD feedback
2020-11-20 21:59:01 +01:00
Ac_K c2356a7653
olsc: Add service olsc:u and stub some calls (#1734) 2020-11-20 09:56:23 +11:00
Ac_K 7c3b559830
loaders: Fix possible parsing errors of informations on some NSO (#1724)
This fix possible parsing errors of informations on some NSO where the "zero" field don't exist introduced by #1661 leading to crashes at start.

References:
https://github.com/Atmosphere-NX/Atmosphere/blob/master/stratosphere/creport/source/creport_modules.cpp#L202
https://github.com/Thog/oss-rtld/blob/master/source/main.cpp#L14
2020-11-18 19:04:42 +01:00
Mary 863edae328
shader cache: Fix Linux boot issues (#1709)
* shader cache: Fix Linux boot issues

This rollback the init logic back to previous state, and replicate the
way PTC handle initialization.

* shader cache: set default state of ready for translation event to false

* Fix cpu unit tests
2020-11-17 22:40:19 +01:00
Ac_K fcc9cbf816
am: Fix VR enabled by default (#1715)
This PR fix an issue I've made in #1688 which is enabled VR as default.
It could cause rendering issues in games when VR mode isn't used, as users have reported in Smash:
2020-11-15 22:38:11 -03:00
Ac_K 313f8d2eb6
am/lbl/hid/pctl: Enabled VR Rendering (#1688)
* am/lbl/hid/pctl: Enabled VR Rendering

This PR enable VR rendering on games which support it through the Toy-Con VR Goggles.

Please remember Ryujinx currently don't support console SixAxis sensor and for now, in some games, the view can't be moved.

Everything is implemented accordingly to RE:
- am: ICommonStateGetter: SetVrModeEnabled, BeginVrModeEx, EndVrModeEx.
- lbl: ILblController: SetBrightnessReflectionDelayLevel, GetBrightnessReflectionDelayLevel, SetCurrentAmbientLightSensorMapping, GetCurrentAmbientLightSensorMapping, SetCurrentBrightnessSettingForVrMode, GetCurrentBrightnessSettingForVrMode, EnableVrMode, DisableVrMode, IsVrModeEnabled.
- pctl: IParentalControlService: ConfirmStereoVisionPermission, ConfirmStereoVisionRestrictionConfigurable, GetStereoVisionRestriction, SetStereoVisionRestriction, ResetConfirmedStereoVisionPermission, IsStereoVisionPermitted.
- hid: IHidServer: ResetSevenSixAxisSensorTimestamp is stubbed because we don't support console SixAxisSensor for now.

Maybe we could add a setting later to enable or disable VR. But I think it's fine to keep this always available since you have to enable it in games.

* Fix permission flag check

* Address gdkchan feedback
2020-11-15 22:30:20 +01:00
Mary aa129fdbdf
infra: Migrate to .NET 5 (#1694)
* infra: Migrate to .NET 5

This migrate projects and CI to .NET 5

* Remove language version restrictions (now on 9.0 by default)

* infra: pin .NET 5 to avoid later issues

* infra: Cleanup csproj files

* infra: update dependencies

* infra: Add temporary workaround for a bug in Vector128.Create

see https://github.com/dotnet/runtime/issues/44704 for more informations
2020-11-15 19:27:15 +01:00
mageven 8d0d299792
IPSwitch: Quick fix to patch sets toggling (#1668)
* IPSwitch: Quick fix to patch sets toggling

* fmt fix: newlines before continue and return
2020-11-13 02:35:49 +01:00
Mary 48f6570557
Salieri: shader cache (#1701)
Here come Salieri, my implementation of a disk shader cache!

"I'm sure you know why I named it that."
"It doesn't really mean anything."

This implementation collects shaders at runtime and cache them to be later compiled when starting a game.
2020-11-13 00:15:34 +01:00
riperiperi 7166e82c3c
Update performance mode when docked mode changes. (#1696) 2020-11-12 16:59:18 +11:00
Ac_K eda6b78894
apm/am: Refactoring/Unstub services (#1662)
* apm: Refactoring/Unstub service

This PR implement some IPC calls of apm service:
- nn::apm::IManager is fully implemented.
- nn::apm::ISession is fully implemented (close #1633).
- nn::apm::ISystemManager is partially implemented.

nn::appletAE::ICommonStateGetter have some calls which are just a layer of apm IPC calls. What we did in some calls was wrong, it's fixed now!

Everything is checked with RE.

* abstract Apm *Server as Thog requested

* abstract ISession and fix other classes

* Address gdkchan feedback

* Fix class

* Fix Logging
2020-11-08 17:00:54 -03:00
Ac_K b677e44300
Loaders: Log extra NSO informations (#1661)
NSO files can contains useful informations who aren't currently logged.
This PR fix that by logging Module name, Libraries and SDK Version when they are available.
2020-11-06 19:58:57 +01:00
emmauss 9f13f957af
Motion Fixes (#1589)
* fix stalling when server is offline

* add retry timer to fail server connections, fix alt slot number

* fix alt slot key issue

* fix crash when saving controller config with empty fields

* code fixes

* add index check in motion hid update, made HandleResponse async

Co-authored-by: Emmanuel <nhv3@localhost.localdomain>
2020-10-28 20:52:07 +01:00
riperiperi aec8177850
Replace Host FPS with GPU command queue load ("Fifo %") (#1585)
* Replace Host FPS with FIFO%

* Change measurement order. Improve calculation.

Now at 100% when FIFO is blocking game exectution, rather than "0".

* Address feedback (1)

* Remove Host FPS

* FIFO rather than Fifo

* Address Ac_k feedback

* Rebase
2020-10-14 07:54:42 +11:00
Mary c482718d2e
surfaceflinger: Disable async buffer (#1603)
This fix a mistake I made during my original reimplementation of SurfaceFlinger by disabling async buffer.

This fix a memory corruption on Super Mario All-Stars 3D (Super Mario Sunshine & Super
Mario Galaxy now go ingame).

Thanks to @gdkchan for tracing the memory corruption.
2020-10-10 21:45:49 +11:00