Commit graph

317 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
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
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