Commit graph

61 commits

Author SHA1 Message Date
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
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
gdkchan
5ab5b0e709
Close ILibraryAppletAccessor handles on disposal (#2094) 2021-03-10 21:36:38 +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
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
Ac_K
71e2a00221
am: stub PresetLibraryAppletGpuTimeSliceZero (#1876) 2021-01-08 23:43:36 -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
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
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
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
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
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
riperiperi
e00ca92063
Return "NotAvailable" when no UserChannel data is present. (#1569)
* Return "NotAvailable" when no UserChannel data is present.

* Return ObjectInvalid for undefined parameter kinds.

* No need to specify which, there's only one.

* Just works as a literal string.
2020-09-23 18:57:18 -03:00
Mary
33f8284bc0
hle/ui: Basic multi programs support (#1560)
* hos/gui: Add a check of NCA program index in titleid

This add a check to `ApplicationLoader` for the last 2 digits of the game TitleId who seems to be the NCA program index.
We currently return the last index, instead of the lower one.
Same check is added to ApplicationLibrary in the UI.

I've cleaned up both file too.

* hle: implement partial relaunch logic

TODO: make the emulator auto relauch.

* Handle auto relaunch

* hle: Unify update usage system

* hle: Implement support of multi programs in update system

* Add some documentation

* Address rip's comment

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2020-09-21 13:45:30 +10:00
Ac_K
ac04cfa96c
am: Stub Begin/EndBlockingHomeButton (#1553) 2020-09-20 13:40:10 +10:00
Alex Barney
1bb7fdaca4
Update to LibHac 0.12.0 (#1485)
* Update to LibHac 0.12.0

* Auto-formatting. Fixed a bug in SetApplicationCopyrightImage
2020-09-01 17:08:59 -03:00
mageven
a33dc2f491
Improved Logger (#1292)
* Logger class changes only

Now compile-time checking is possible with the help of Nullable Value
types.

* Misc formatting

* Manual optimizations

PrintGuestLog
PrintGuestStackTrace
Surfaceflinger DequeueBuffer

* Reduce SendVibrationXX log level to Debug

* Add Notice log level

This level is always enabled and used to print system info, etc...
Also, rewrite LogColor to switch expression as colors are static

* Unify unhandled exception event handlers

* Print enabled LogLevels during init

* Re-add App Exit disposes in proper order

nit: switch case spacing

* Revert PrintGuestStackTrace to Info logs due to #1407

PrintGuestStackTrace is now called in some critical error handlers
so revert to old behavior as KThread isn't part of Guest.

* Batch replace Logger statements
2020-08-04 01:32:53 +02:00
mageven
c11855565e
Implement Software Keyboard GTK frontend (#1434)
* Implement SwKbd GUI

* Relocate UI handler to Emu Context from Config

Also create a common interface for UI handlers in the context and specialize for Gtk

Add basic input length validation in InputDialog

* Add Transfer Memory support to AppletCreator

Read Initial Text for SwKbd using Transfer Memory

* Improve InputDialog widget

Improve length validation
Has extra label to show validition info
Handle potential errors and log them

* Misc improvements

* Improve string validation
* Improve error handling
* Remove tuple in struct
* Address formatting nits

* Add proper Cancel functionality

Also handle GUI errors in UI handler

* Address jD's comments

* Fix _uiHandler init

* Address AcK's comments
2020-08-03 03:30:58 +02:00
Ac_K
c6e12949e5
Add multiple calls to am service (#1411)
* Add multiple calls to am service

This implement/stub some am calls:

- SetAutoSleepDisabled
- IsAutoSleepDisabled
- SetAlbumImageTakenNotificationEnabled
- EnableApplicationCrashReport
- GetPreviousProgramIndex
- NeedsToExitProcess
- RequestForAppletToGetForeground
- GetIndirectLayerConsumerHandle

All checked by RE.
Additionnaly to that, there is some cleanup here and there.

Fix #1387, #1324, #1165, #1163, #1065

* Fix casting

* Thread safe assign
2020-07-22 14:56:00 +10:00
mageven
b663cd22c8
Fix GetDesiredLanguage (#1275)
* Fix GetDesiredLanguage

* Correct tzcnt slip-up

* Address gdkchan's comments
2020-05-27 10:40:23 +02:00
mageven
6b55cedd73
Fix GetDisplayVersion (#1276) 2020-05-27 18:22:50 +10:00
mageven
ba4830293e
Refactor out Application details from Horizon (#1236)
* Initial Application refactor

* Misc typo and access modifier fixes

* Clean unused namespaces

* Address gdkchan's comments

* Move ticket reading to common method

* Change IParentalControlService to use ApplicationLoader.ControlData
2020-05-15 03:16:46 -03:00
Ac_K
76e1a162dd
am: Implement GetFriendInvitationStorageChannelEvent (#1220)
* am: Implement GetFriendInvitationStorageChannelEvent

This implement GetFriendInvitationStorageChannelEvent according to RE, needed by Streets of Rage 4

* Fix handle name

* add GetNotificationStorageChannelEvent
2020-05-12 16:52:27 +02:00
gdkchan
15d1cc806b
Move kernel state out of the Horizon class (#1107)
* Move kernel state from Horizon to KernelContext

* Merge syscalls partial classes, split 32 and 64-bit variants

* Sort usings
2020-05-04 13:41:29 +10:00
gdkchan
f77694e4f7
Implement a new physical memory manager and replace DeviceMemory (#856)
* Implement a new physical memory manager and replace DeviceMemory

* Proper generic constraints

* Fix debug build

* Add memory tests

* New CPU memory manager and general code cleanup

* Remove host memory management from CPU project, use Ryujinx.Memory instead

* Fix tests

* Document exceptions on MemoryBlock

* Fix leak on unix memory allocation

* Proper disposal of some objects on tests

* Fix JitCache not being set as initialized

* GetRef without checks for 8-bits and 16-bits CAS

* Add MemoryBlock destructor

* Throw in separate method to improve codegen

* Address PR feedback

* QueryModified improvements

* Fix memory write tracking not marking all pages as modified in some cases

* Simplify MarkRegionAsModified

* Remove XML doc for ghost param

* Add back optimization to avoid useless buffer updates

* Add Ryujinx.Cpu project, move MemoryManager there and remove MemoryBlockWrapper

* Some nits

* Do not perform address translation when size is 0

* Address PR feedback and format NativeInterface class

* Remove ghost parameter description

* Update Ryujinx.Cpu to .NET Core 3.1

* Address PR feedback

* Fix build

* Return a well defined value for GetPhysicalAddress with invalid VA, and do not return unmapped ranges as modified

* Typo
2020-05-04 08:54:50 +10:00
VolcaEM
8a7c00c39a
Add various error codes to AM (#1183)
* Add various error codes to AM

The error codes were taken from Switchbrew (https://switchbrew.org/wiki/Error_codes)

* TitleID -> TitleId
2020-05-02 13:45:45 +02:00
Thog
a0c06103c9
am: add IsVrModeEnabled (#1189)
* am: stub IsVrMode

Needed by SSBU 7.0.0

* Address Ac_K's comments
2020-05-01 18:51:00 +02:00
Thog
cdbb689b80
Add support for dynamic docking/undocking (#1147)
* Add support for dynamic docking/undocking

As SurfaceFlinger is now working more accurately, we can now support
dynamic configuration of docking mode :)

* Simplify a bt the code

* Fix import ordering

* Remove unused argument
2020-04-23 13:59:11 +02:00
Alex Barney
6052aa17f2
Print the result name in SetTerminateResult if possible (#1105) 2020-04-12 22:13:23 +10:00
Ac_K
25c3b8b356
Implement some calls of ISelfController (#965)
* Implement some calls of ISelfController

This PR implement some calls of ISelfController:

- EnterFatalSection
- LeaveFatalSection
- GetAccumulatedSuspendedTickValue (close #937)

According to RE of the 8.1.0 am service.

* thread safe increment/decrement

* Fix thread safe

* remove unused using
2020-03-04 00:41:41 -03:00
Alex Barney
165e658f02
Actually use the dummy NACP for EnsureApplicationSaveData (#939) 2020-02-18 22:35:47 +11:00
Thog
c464e1ec52
Stub the application copyright framebuffer api (#921)
* Stub the application copyright framebuffer api

As we currently don't support multi layers on vi/nvnflinger, this PR
implement a stub of this API.

* Address Cyuubi's comments

* Add IPC checks and comments for future reversing

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

Co-authored-by: Ac_K <Acoustik666@gmail.com>
2020-02-12 00:07:13 +01:00
Thog
ea14a95524
Fix inconsistencies with UserId (#906)
* Fix inconsistencies with UserId

The account user id isn't an UUID. This PR adds a new UserId type with
the correct value ordering to avoid mismatch with LibHac's Uid. This also fix
an hardcoded value of the UserId.

As the userid has been invalid for quite some time (and to avoid forcing
users to their recreate saves), the userid has been changed to "00000000000000010000000000000000".

Also implement a stub for IApplicationFunctions::GetSaveDataSize. (see
the sources for the reason)

Fix #626

* Address jd's & Ac_k's comments
2020-02-02 14:24:17 +11:00
Thog
d6b9babe1d Keep the GUI alive when closing a game (#888)
* Keep the GUI alive when closing a game

Make HLE.Switch init when starting a game and dispose it when closing
the GlScreen.

This also make HLE in charge of disposing the audio and gpu backend.

* Address Ac_k's comments

* Make sure to dispose the Discord module and use GTK quit method

Also update Discord Precense when closing a game.

* Make sure to dispose MainWindow

* Address gdk's comments
2020-01-21 23:23:11 +01:00
Alex Barney
63b24b4af2 Rename "RyuFs" directory to "Ryujinx" and use the same savedata system the Switch uses (#801)
* Use savedata FS commands from LibHac

* Add EnsureSaveData. Use ApplicationControlProperty struct

* Add a function to migrate to the new directory layout

* LibHac update

* Change backup structure

* Don't create UI files in the save path

* Update RyuFs paths

* Add GetProgramIndexForAccessLog

Ryujinx only runs one program at a time, so always return values reflecting that

* Load control NCA when loading from an NSP

* Skip over UI stats when exiting

* Set TitleName and TitleId in more cases. Fix TitleID naming style

* Completely comment out GUI play stats code

* rebase

* Update LibHac

* Update LibHac

* Revert UI changes

* Do migration automatically at startup

* Rename RyuFs directory to Ryujinx

* Update RyuFs text

* Store savedata paths in the GUI

* Make "Open Save Directory" work

* Use a dummy NACP in EnsureSaveData if one is not loaded

* Remove manual migration button

* Respond to feedback

* Don't read the installer config to get a version string

* Delete nuget.config

* Exclude 'sdcard' and 'bis' during migration

Co-authored-by: Thog <thog@protonmail.com>
2020-01-05 12:49:44 +01:00
jduncanator
ee81ab547e Initial swkbd implementation (#826)
* am: Initial swkbd implementation

Currently only implements the full screen keyboard, inline keyboard will come later.

* Remove unnecessary logging

* Miscellaneous tidy up

* am: Always pop incoming interactive session data

* am: Add a reminder to implement the full config struct

* am: Check for a max length of zero

We should only limit/truncate text when the max length is set to a non-zero value.

* Add documentation

* am: Return IStorage not available when queue is empty

We should be returning the appropriate error code when the FIFO is empty, rather than just throwing an exception and killing the emulator.

* Fix typo

* Code style changes
2019-11-18 12:16:26 +01:00
Ac_K
79abc6ed93 Implement IApplicationFunctions & IQueryService commands (#823)
* Implement IApplicationFunctions & IQueryService commands

- Fix some nits in `IApplicationFunctions`
- Implement `QueryApplicationPlayStatistics` and `QueryApplicationPlayStatisticsByUid` checked by RE.
- Implement `QueryApplicationPlayStatisticsForSystem` and `QueryApplicationPlayStatisticsByUserAccountIdForSystem` checked by RE.
- Implement `QueryPlayStatisticsManager` to get/set played games statistics. We currently don't store any statistics because it's handled by qlaunch (or maybe am service?) on Switch.
We can add support later if games use returned statistics for something.

* Fix reviews
2019-11-15 01:25:22 +01:00
jduncanator
35e5612766 Implement a rudimentary applets system (#804)
* Implement Player Select applet

* Initialize the Horizon system reference

* Tidy up namespaces

* Resolve nits

* Resolve nits

* Rename stack to queue

* Implement an applet FIFO

* Remove debugging log

* Log applet creation events

* Reorganise AppletFifo

* More reorganisation

* Final changes
2019-11-14 06:18:44 +01:00
Ac_K
92e5e3c505 am: IApplicationFunctions GetGpuErrorDetectedSystemEvent implementation (#775) 2019-09-20 14:42:32 +10:00
Ac_K
a0720b5681 Refactoring HOS folder structure (#771)
* Refactoring HOS folder structure

Refactoring HOS folder structure:

- Added some subfolders when needed (Following structure decided in private).
- Added some `Types` folders when needed.
- Little cleanup here and there.
- Add services placeholders for every HOS services (close #766 and #753).

* Remove Types namespaces
2019-09-19 10:45:11 +10:00
Ac_K
6b8fb8a4e3 Implement am ICommonStateGetter::SetCpuBoostMode (#743)
- Implement am ICommonStateGetter::SetCpuBoostMode according to the RE:

```
signed __int64 __fastcall nn::ICommonStateGetter::SetCpuBoostModeImpl(__int64 this, unsigned int cpu_boost_mode)
{
  if ( cpu_boost_mode > 1 )
  {
    return 0x3F480LL;
  }

  __int64 v2 = *(_QWORD *)(this + 0x38);
  __int64 v3 = *(_QWORD *)(*(_QWORD *)(v2 + 8) + 0x298LL);

  nnLock((_DWORD *)(v3 + 0x104));

  __int64 v5 = *(_QWORD *)(v2 + 0x18);
  bool unk_bool = *(unsigned __int8 *)(v5 + 0x7C);

  *(_DWORD *)(v5 + 0x80) = cpu_boost_mode;

  if (!unk_bool)
  {
    *(_BYTE *)(v5 + 0x7C) = 1;
  }

  wait_condvar(v3 + 0xA8);
  nnUnlock((_DWORD *)(v3 + 0x104));

  return 0LL;
}
```

- Add enum for apm CpuBoostMode
- Add missing values in apm PerformanceConfiguration with some comments.
2019-08-28 13:02:50 +02:00
Ac_K
4ad3936afd Refactoring result codes (#731)
* refactoring result codes

- Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one.
- Add sub-enum by services when it's needed.
- Remove some empty line.
- Recast all service calls to ResultCode.
- Remove some unneeded static declaration.
- Delete unused `NvHelper` class.

* NvResult is back

* Fix
2019-07-14 16:04:38 -03:00
Ac_K
560ccbeb2d Refactoring commands handling (#728)
* Refactoring commands handling

- Use Reflection to handle commands ID.
- Add all symbols (from SwIPC so not all time accurate).
- Re-sort some services commands methods.
- Some cleanup.
- Keep some empty constructor for consistency.

* Fix order in IProfile
2019-07-11 22:13:43 -03:00
Ac_K
596b61ce1f IPC services refactoring (#726)
* IPC services refactoring

- Use custom Attributes to handle services.
- Add a way to set the permissions and fix the bsd service to use it.
- Little cleanup.
- C#7.1 is required.

* fix var name

* fix syntax

* Change Permission to Parameter

* Delete BsdServicePermissionLevel.cs

* Fix Linq
2019-07-10 12:59:54 -03:00
Alex Barney
b2b736abc2 Misc cleanup (#708)
* Fix typos

* Remove unneeded using statements

* Enforce var style more

* Remove redundant qualifiers

* Fix some indentation

* Disable naming warnings on files with external enum names

* Fix build

* Mass find & replace for comments with no spacing

* Standardize todo capitalization and for/if spacing
2019-07-02 04:39:22 +02:00
Ac_K
5084164cd9 Implement GetAccumulatedSuspendedTickChangedEvent to ISelfController (#702)
* Implement GetAccumulatedSuspendedTickChangedEvent to ISelfController

- Add all IPC call to the Dictionary.
- Rename _libraryAppletLaunchableEvent.
- Implement GetAccumulatedSuspendedTickChangedEvent according to the RE:
```
undefined8 GetAccumulatedSuspendedTickChangedEvent (struct this, uint *ouput_event_handle)
{
    svcArbitrateLock(&this->tag_location);

    if (this->event_created == 0)
    {
        if (CreateEvent(&this->event_object, 0, 1) != 0)
        {
            Assert(&DAT_710018f73b, &DAT_710018f73b, &DAT_710018f73b, 0, result, &DAT_710018f73b);
        }

        this->event_created = 1;

        svcSignalEvent(&this->event_object);
    }

    svcArbitrateUnlock(&this->tag_location);

    uint event_handle = GetEventHandle(&this->event_object);

    uint uVar1 = *ouput_event_handle;
    *ouput_event_handle = event_handle;

    char cVar2 = *(char *)(ouput_event_handle + 1);
    *(undefined *)(ouput_event_handle + 1) = 0;

    if (cVar2 != 0)
    {
        svcCloseHandle((ulonglong)uVar1);
    }

    return 0;
}
```

* Fix the handle leak
2019-06-15 22:58:22 -03:00