Commit Graph

10584 Commits

Author SHA1 Message Date
Zephyron
be5c2f772c fix: Multiplayer network fixes and airplane mode
- Auto-select network interface for direct connect/host room
- Always recreate ENet client on join for fresh bindings
- Add airplane mode toggle (Desktop & Android)
- Fix JWT verification with empty verify_uid
- Improve content-type handling for JWT endpoints

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-10 17:16:45 +10:00
Zephyron
09f8c3a643 feat(ui): add per-game cheat management tab with bulk toggle controls
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-07 19:17:07 +10:00
Zephyron
5117ff3702 feat: implement multiplayer networking improvements for reduced latency
Major networking enhancements to improve multiplayer performance and
reduce desync issues in games like Mario Kart 8 Deluxe:

Network Performance:
- Add socket connection pooling in BSD service to reduce overhead
- Implement unreliable packet delivery for latency-sensitive game data
- Add packet reliability control for both ProxyPacket and LDNPacket
- Use ENET_PACKET_FLAG_UNSEQUENCED for small UDP packets (<1200 bytes)

Monitoring & Debugging:
- Add PacketStatistics struct to track sent/received/dropped packets
- Enhanced logging for proxy packet handling and socket lifecycle
- Periodic stats logging every 100 packets for diagnostics

Configuration:
- Update lobby_api_url and web_api_url to https://api.ynet-fun.xyz
- Add lobby API URL configuration support

Socket Management:
- Implement SocketPoolKey for efficient socket reuse
- Store domain/type/protocol info in FileDescriptor
- Max pool size limit (8 sockets per type) to prevent memory bloat
- Return closed sockets to pool when room is still connected

Protocol Updates:
- Add 'reliable' field to ProxyPacket and LDNPacket structures
- Update room.cpp packet handlers to respect reliability flags
- Maintain backward compatibility with default reliable=true

These changes significantly reduce packet latency for real-time game
traffic while maintaining reliability for control packets.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-05 18:52:06 +10:00
Zephyron
4211689683 fix(set): stub ISettingsServer function 12 to fix AVGN 8-bit crash
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-04 17:43:52 +10:00
Zephyron
a5024bb218 kernel: Use CheckMemoryStateContiguous in UnmapCodeMemory
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-03 16:19:46 +10:00
Zephyron
5af5ba2d0e chore(CMake): Remove
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 22:10:50 +10:00
Zephyron
3d0ccc1db1 Fix Windows auto updater with deferred update helper and TLS support
Windows auto updater failed due to:
1. File locking - can't overwrite running .exe files
2. Missing Qt 6 TLS plugins - can't connect via HTTPS

Solution:
- Implement helper batch script that applies updates after app exits
- Automate TLS plugin copying in CMake (qschannelbackend.dll, qopensslbackend.dll)
- Add enhanced SSL debugging and error messages

Windows updates now work. Linux continues to work as before.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 21:56:37 +10:00
Zephyron
ec670d881c hle: Improve network service implementations and add newer firmware stubs
AM (Application Manager):
- Implement GetPseudoDeviceId with deterministic UUID generation
- Generate persistent device ID based on program ID for online play

LDN (Local Network):
- Implement stub for Reject (cmd 205)
- Implement stub for ClearAcceptFilter (cmd 209)
- Implement stub for ConnectPrivate (cmd 303)

NIFM (Network Interface):
- Fix RequestState enum values (Invalid=0, Free=1) per switchbrew
- Add ConnectionConfirmationOption enum
- Update NotSubmitted references to Free state
- Implement 13 new stub functions for firmware 18.0.0-20.0.0+
- Reduce log verbosity for frequently-called functions

BSD (Sockets):
- Improve RegisterClient to parse LibraryConfigData structure
- Enhance socket operation logging (Socket, Bind, Connect)
- Add detailed error logging for bind/connect failures
- Implement stubs for Unknown36-38 (18.0.0+)
- Add firmware version comments for commands

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 18:47:15 +10:00
Zephyron
76e963bfe7 kernel: Implement code address offset for Skyline compatibility
Add support for the Skyline 32-bit modding framework by implementing
a code address offset and improving memory state verification.

Changes:
- Add CodeStartOffset constant (0x500000) applied to 32-bit code
  address space types (Is32Bit and Is32BitNoMap) in KProcess::LoadFromMetadata
- Add debug logging for 32-bit syscall argument tracking in
  SetProcessMemoryPermission, MapProcessCodeMemory, and
  UnmapProcessCodeMemory wrapper functions
- Replace CheckMemoryStateContiguous with CheckMemoryState in
  KPageTableBase::UnmapCodeMemory for more flexible memory state
  verification

This implementation enables compatibility with:
- Skyline 32-bit modding framework
- CTGP-DX (Mario Kart 8 Deluxe mod)
- Other homebrew using 32-bit Skyline

Based on similar fixes in Ryujinx (commit 5e9678c8fe) and Eden emulator.

Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Co-authored-by: JPikachu <jpikachu@eden-emu.dev>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 15:44:21 +10:00
Zephyron
68a8b07f78 feat(ldn): Implement missing Account and LDN services from SwitchBrew documentation
Implements 150+ missing functions across Account (acc:*) and LDN (ldn:*, lp2p:*)
services based on official SwitchBrew documentation.

Account Services (acc:su, acc:e, acc:u0, acc:u1, acc:e:u1, acc:e:u2, dauth:0):
- Add 70+ missing functions including notifiers, async operations, and OAuth procedures
- Implement GetUserRegistrationNotifier, GetUserStateChangeNotifier, GetProfileUpdateNotifier
- Add thumbnail management (LoadSaveDataThumbnail, GetSaveDataThumbnailExistence)
- Implement user management (DeleteUser, SetUserPosition, CancelUserRegistration)
- Add Nintendo Account procedures (CreateFloatingRegistrationRequest, etc.)
- Implement device migration functions (19.0.0+, 20.0.0+)
- Add debug functions for user qualification and token cache management

IManagerForApplication/SystemService (19.0.0+ compatibility):
- Rename LoadIdTokenCache (cmd 3) to LoadIdTokenCacheDeprecated
- Add new LoadIdTokenCache (cmd 4) with updated signature
- Add GetNintendoAccountUserResourceCache (cmd 136)

LDN Services (ldn:m, ldn:s, ldn:u):
- Add 80+ missing functions across all LDN interfaces
- Implement CreateClientProcessMonitor (cmd 1) for ldn:s and ldn:u (18.0.0+)
- Create IClientProcessMonitor service with RegisterClient function
- Implement IMonitorService functions (GetNetworkInfoForMonitor, GetIpv4AddressForMonitor, etc.)
- Implement ISystemLocalCommunicationService (GetState, Scan, Connect, Initialize, etc.)

LP2P Services (lp2p:app, lp2p:sys, lp2p:m):
- Implement ISfService functions (Initialize, Scan, CreateGroup, etc.)
- Implement ISfServiceMonitor (GetGroupInfo, GetMembers, AttachJoinEvent, etc.)
- Implement ISfMonitorService (GetLinkLevel)

Technical Changes:
- Change non-domain (C<>) to domain (D<>) functions in LDN to fix crashes
- Add enhanced error messaging to cmif_serialization.h for debugging
- Create client_process_monitor.cpp/.h for IClientProcessMonitor
- Add concrete async context implementations (EnsureSignedDeviceIdentifierCacheAsyncInterface, etc.)
- Add Kernel::KReadableEvent forward declarations

All functions properly stubbed with appropriate logging for future implementation.

References:
- https://switchbrew.org/wiki/Account_services
- https://switchbrew.org/wiki/LDN_services

Fixes 'Pokemon: Legends Z-A' LDN initialization crashes and improves compatibility
with games using Account and Local Network services.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-30 19:32:07 +10:00
Zephyron
20250c3e31 fix: add missing NCA encryption type support and patch handling
Changes:
- Add missing encryption type cases to all switch statements
- Only call CreatePatchMetaStorage() when both tables are present
- Update assertions to allow partial table combinations

Fixes loading for Hades II, Pokémon Legends: Z-A, and other games
with newer NCA structures.

Reported-by: Dr.Stug@citron-emu.org
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-24 16:25:38 +10:00
Zephyron
4c7ee4ac3b fix: BSD socket assertion failure in PollImpl
Initialize PollFD.revents field to prevent assertion failures when
copying from read buffer. The assertion was failing because revents
contained uninitialized data from the buffer.

Thanks to Dr.Stug for providing the logs that identified this issue.

Fixes assertion failure at core\hle\service\sockets\bsd.cpp:564

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-22 20:47:24 +10:00
Zephyron
9c13799b49 kernel: Add 12 GiB heap support
- Increased heap region from 8 GiB to 12 GiB
- Fixed memory manager page reference count allocation
- Made resource region sizing dynamic for >8GB DRAM
- Increased physical address space bits to support 16GB

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-22 15:06:47 +10:00
Zephyron
8cc5aa143f fix: implement DeleteCacheStorage stub to prevent TOTK crashes
- Add stubbed DeleteCacheStorage function to FSP_SRV service
- Return success instead of causing assertion failure
- Prevents userspace PANIC when games attempt to delete cache storage

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-22 13:25:16 +10:00
collecting
c3492232c1 Fix patch_manager.cpp 2025-10-22 01:21:16 +00:00
collecting
bde2434956 Fix savedata_factory.cpp 2025-10-22 01:20:49 +00:00
collecting
cd742e7633 feat(fs): Implement Autoloader (W.I.P.) 2025-10-21 20:55:16 +00:00
collecting
ab39e75ac1 feat(fs): Implement Autoloader (W.I.P.) 2025-10-21 20:54:17 +00:00
collecting
4db51f9353 feat(fs): Implement Autoloader (W.I.P.) 2025-10-21 20:52:26 +00:00
Zephyron
543dc05008 am: Implement missing ILibraryAppletCreator and ILibraryAppletAccessor commands
Adds support for newer firmware commands:
- ILibraryAppletCreator::CreateLibraryAppletEx (cmd 3) - Added in firmware 20.0.0+
  Takes an additional thread_id parameter compared to CreateLibraryApplet
- ILibraryAppletAccessor::Unknown90 (cmd 90) - Unknown command from newer firmware
  Stubbed with generic parameter logging

Fixes assertion: Unknown / unimplemented function '3': port='ILibraryAppletCreator'
Fixes assertion: Unknown / unimplemented function '90': port='ILibraryAppletAccessor'

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-21 18:01:05 +10:00
Zephyron
98c6ac8961 core/filesystem: Implement accurate SaveData system
- Add transactional ExtraData with journaling (6 service functions)
- Implement atomic commit with crash recovery
- Add HOS-compliant path normalization
- Fix all ResultUnknown returns and add 9 HOS error codes
- Add directory journaling with /0 (committed) and /1 (working)
- Implement cross-tree directory moves

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-21 17:49:59 +10:00
Zephyron
df14b96c6b feat: Add romfslite mod folder support (Atmosphere 1.9.5)
Support the romfslite folder type introduced in Atmosphere 1.9.5 for
memory-optimized mod loading. The emulator now detects and loads
romfslite folders the same way as romfs folders.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-11 20:24:18 +10:00
Zephyron
fbb4f5c015 Fix: Recover from null pointer execution crashes
Add proper recovery mechanism for null pointer execution (PC < 0x1000)
by returning from invalid function calls using the Link Register instead
of blindly continuing execution.

Fixes infinite crash loop in games like Little Nightmares III.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-11 17:02:28 +10:00
Zephyron
8b830b310b fix(dynarmic): Remove MSVC-specific fastmem_pointer assignments
Unify fastmem_pointer handling by using reinterpret_cast<uintptr_t>()
and std::nullopt consistently across all platforms, fixing MSVC
compilation errors with std::optional<uintptr_t> assignment.

Fixes: C2679 binary '=' operator errors on MSVC
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-07 15:45:56 +10:00
collecting
791718ea7f fix: string for Citron compilation error 2025-10-07 05:10:41 +00:00
collecting
32ea5f0fd0 fix: MSVC Compiler Error 2025-10-07 02:36:00 +00:00
collecting
20e594ca46 fix: MSVC Compiler Error 2025-10-07 02:35:03 +00:00
collecting
6491a53e72 fix: Clang Compiler 2025-10-05 02:25:57 +00:00
collecting
5a87a11917 fix: Clang Compiler 2025-10-05 02:25:14 +00:00
Zephyron
fa595ebe5a Merge branch 'boost_process_fixes' into 'main'
fix: boost_process Linux issue

See merge request citron/emulator!67
2025-10-02 17:15:52 +10:00
collecting
50da0bcca6 fix: boost_process Linux issue 2025-10-01 16:53:13 +00:00
collecting
964df7ef38 fix: boost_process Linux issue 2025-10-01 16:51:05 +00:00
Zephyron
26f93ad8ad hle: service: Complete SSL/TLS service implementation
ISslConnection (36/36 commands now implemented):
- Added Peek, Poll for connection state monitoring
- Implemented GetVerifyCertError and GetVerifyCertErrors for certificate validation
- Added GetNeededServerCertBufferSize for buffer management
- Implemented session cache functions: GetSessionCacheMode, FlushSessionCache
- Added renegotiation support: SetRenegotiationMode, GetRenegotiationMode
- Implemented GetOption and GetCipherInfo for connection information
- Added ALPN support: SetNextAlpnProto, GetNextAlpnProto
- Implemented DTLS functions: SetDtlsSocketDescriptor, GetDtlsHandshakeTimeout
- Added SetPrivateOption for extended options
- Implemented SRTP functions: SetSrtpCiphers, GetSrtpCipher
- Added ExportKeyingMaterial for external key usage
- Implemented timeout functions: SetIoTimeout, GetIoTimeout

ISslService:
- Added GetContextCount, SetDebugOption, GetDebugOption, ClearTls12FallbackFlag

ISslContext:
- Implemented GetOption, RemoveServerPki, RemoveClientPki, RegisterInternalPki,
  AddPolicyOid, ImportCrl, RemoveCrl, ImportClientCertKeyPki, GeneratePrivateKeyAndCert

ISslContextForSystem:
- Fully implemented all 15 commands (CreateConnectionEx and all base functions)

ISslConnection getter functions:
- Added GetSocketDescriptor, GetHostName, GetVerifyOption, GetIoMode

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 23:00:47 +10:00
Zephyron
40464551ed hle: service: Properly implement SSL services
Implements comprehensive SSL/TLS services based on Switch Brew documentation.

Changes:
- ISslService: Added GetContextCount, SetDebugOption, GetDebugOption,
  and ClearTls12FallbackFlag
- ISslContext: Implemented GetOption, RemoveServerPki, RemoveClientPki,
  RegisterInternalPki, AddPolicyOid, ImportCrl, RemoveCrl,
  ImportClientCertKeyPki, and GeneratePrivateKeyAndCert
- ISslContextForSystem: Fully implemented all 15 commands (was all stubs)
- ISslConnection: Added GetSocketDescriptor, GetHostName, GetVerifyOption,
  and GetIoMode

All SSL-related services now have complete command coverage with proper
stub implementations for emulator compatibility.

Reference: https://switchbrew.org/wiki/SSL_services
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 22:46:31 +10:00
Zephyron
33a7836d4f hle: service: Properly implement NIM services
Implements comprehensive NIM (Network Install Manager) services based on
the official Switch Brew documentation.

Changes:
- Added async interface classes: IAsyncValue, IAsyncResult,
  IAsyncProgressResult, and IAsyncData for handling asynchronous operations
- Updated main nim service with all proper command names (commands 0-154)
  - Replaced "Unknown" placeholders (84-134) with correct function names
  - Added newer firmware commands (135-154) including download tasks,
    application icon requests, and delivery info operations
  - Fixed command 36: ListApplyDeltaTaskContentMeta (was duplicate name)
- Extended nim:shp service with Nintendo Account linking commands (600-601)
- Added nim:ecas command 5: GetCommonEcasSystemEventForReceivingBackgroundDownloadTask
- All services (nim, nim:eca, nim:shp, nim:ecas, ntc) verified and properly registered

This implementation accounts for all NIM-related functions across firmware
versions, providing proper stub handlers for emulator compatibility.

Reference: https://switchbrew.org/wiki/NIM_services
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 22:28:17 +10:00
Zephyron
9090a24c2e feat: add Low GPU Accuracy setting for maximum performance
Implements a new "Low" GPU accuracy level that prioritizes performance
over accuracy by aggressively cutting corners in GPU emulation.

Changes:
- Add GpuAccuracy::Low enum and setting infrastructure
- Implement IsGPULevelNormal() helper function
- Skip texture cache checks and query operations
- Use unsafe memory reads for DMA operations
- Disable fence delays and query precision
- Add UI support for desktop (Qt) and Android

Performance optimizations:
- Skips texture cache coherency checks (vk/gl_rasterizer.cpp)
- Non-blocking query synchronization (query_cache.h)
- Unsafe memory operations (dma_pusher.cpp)
- No macro parameter refresh (maxwell_3d.cpp)
- Immediate fence signaling (fence_manager.h)
- Non-precise Vulkan queries (vk_query_cache.cpp)

Ideal for lower-end hardware and users prioritizing FPS over accuracy.
Works on both desktop and Android platforms.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 21:45:23 +10:00
Zephyron
746f748973 nim: Add CreateServerInterface2
- As Seen Via Logs "[  46.275081] Debug <Critical> core\hle\service\service.cpp:operator ():78: Assertion Failed!
Unknown / unimplemented function '5': port='nim:eca' cmd_buf={[0]=0x6, [1]=0x8000000C, [2]=0x3, [3]=0x0, [4]=0x4F434653, [5]=0x2001C4, [6]=0x0, [7]=0x0, [8]=0x49434653}"
- Thankyou Dr.Stug <dr.stug@citron-emu.org>

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-10-01 21:00:31 +10:00
Zephyron
d627962408 cmake: exclude Boost::process on Android
Boost::process is not available on Android, causing build failures.
Conditionally link it only on non-Android platforms.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-27 21:39:28 +10:00
Zephyron
0ca82d134c feat(acc): implement missing acc:u0 functions per SwitchBrew spec
- Add function 52 (TrySelectUserWithoutInteraction)
- Implement stubbed functions with proper async context classes
- Fix constructor arguments and type conversion warnings

Resolves assertion failure for unimplemented function 52.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-27 21:21:17 +10:00
Zephyron
23352d4a3f fix(dynarmic): resolve fastmem_pointer type compatibility issues
- Convert fastmem_pointer assignments from raw pointers to uintptr_t
- Replace nullptr comparisons with std::optional::has_value()
- Use std::nullopt instead of nullptr for optional types
- Update Dynarmic submodule to commit 9d4582339

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-27 20:22:04 +10:00
Zephyron
f75cf14c1f fix(hid): Add SixAxis sensor validation and error handling
- Add parameter validation for joy_xpad_id, device_index, and npad_id
- Implement proper SixAxis resource manager integration with null checks
- Add safe fallback values to prevent crashes in motion sensor games
- Enhance error handling and logging for SixAxis sensor operations
- Address crashes in games like TOTK 1.4.2 that use motion sensors

Resolves SixAxis sensor crashes by following SwitchBrew HID service
specifications and adding proper parameter validation.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-27 10:17:44 +10:00
collecting
c6a2a2a728 fix: create a Service::Set::SerialNumber object 2025-09-26 13:56:09 +00:00
collecting
f99fc514df Crash-on-Exit from ServiceManager Null Pointer 2025-09-26 04:24:23 +00:00
collecting
f18c6f09e1 Crash-on-Exit from ServiceManager Null Pointer 2025-09-26 03:33:32 +00:00
Zephyron
af223e445f feat: Enhance audio renderer with new features and simplify Android UI indicators
Audio Core:
- Add support for splitter previous volume reset (REV 13+)
- Implement new audio processing time limits (REV 14-15)
- Add voice channel resource limits and effect processing v3
- Support float biquad filters for improved audio quality
- Enhance error handling to prevent audio system crashes

Android UI:
- Simplify FPS, RAM, and thermal indicator views
- Remove complex backgrounds and icons for cleaner display
- Reduce view sizes and improve text-based rendering
- Maintain color-coded status indicators for performance metrics

Core System:
- Improve file system save data space handling
- Enhance kernel synchronization error handling
- Add new error modules and result codes
- Fix potential infinite loops in handle operations

These changes improve audio processing capabilities while providing a cleaner,
more performant Android UI experience.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-23 21:26:59 +10:00
collecting
bb874dc09f Add Boost::process @ 1224 2025-09-23 01:06:41 +00:00
collecting
09ef525ef2 Fix null pointer dereference in patch_manager.cpp line 362 2025-09-22 08:54:03 +00:00
Boss.sfc
056e6bf951 chore(core/debugger): modernize Boost.Process include path to v1
Signed-off-by: Boss.sfc <boss.sfc@citron-emu.org>
2025-09-15 21:59:01 +07:00
Zephyron
94119302ec feat: Add OpenGL ZBC clear support and refactor ZBC management
Moved ZBCManager to `video_core/zbc_manager.cpp/h` for modularity. Added
`gl_zbc_clear.cpp/h` for efficient OpenGL color, depth, and stencil clears.
Updated `RasterizerOpenGL::Clear` to use ZBC with fallback. Added stencil
type validation. Fixed color mask and logging. Updated `CMakeLists.txt`.
Enhances performance and code organization.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-09-14 20:28:39 +10:00
Zephyron
12c3e4b92c Revert "fix: resolve X11 macro conflicts with enum values and Qt constants"
This reverts commit c32ac3b3c1.
2025-09-14 20:15:29 +10:00