Commit Graph

10629 Commits

Author SHA1 Message Date
Collecting
31d0bca2da fix: Cross-Platform Compiler Errors
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-16 09:13:45 +00:00
Collecting
bf17270fd6 Add Mod Installer Folder Logic
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-16 08:34:31 +00:00
Collecting
4f149e130c socket_proxy.cpp: Add Mutex & Flush for Socket Protection
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-14 19:37:29 +00:00
Collecting
5a7a9c9bb8 bsd.cpp: Add Guards & Mutex for Socket Protection
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-14 19:36:36 +00:00
Collecting
062f5e4794 bsd.h: Add Table Mutex
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-14 19:35:54 +00:00
Collecting
0bec953153 fix(sockets): Clear Socket Data Properly for Initialization
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-11 08:12:40 +00:00
Collecting
2311ed2bdf fix(sockets): SIGSEGV & Socket Handling
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-11 08:11:38 +00:00
Collecting
64a2e656f6 fix(msvc/android): Compiler Errors for core.cpp
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 05:31:18 +00:00
Collecting
e324c5b10f fix(core): Properly release memory when stopping emulation
Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-09 04:46:36 +00:00
Collecting
f6b8535bef fix(fs): prevent stack exhaustion in save mirroring recursion
- Moved the copy buffer to the heap via std::make_unique.

- Added explicit null-safety and system shutdown checks to mirroring logic.

- Hardened recursion guards during directory traversal to ensure stability.

Signed-off-by: Collecting <collecting@noreply.localhost>
2026-01-01 21:44:31 +00:00
Zephyron
d8c1cad245 fix(service/nvnflinger): implement GetBufferHistory to prevent game hangs
Return empty buffer history list instead of stubbing to allow games to
proceed past loading screens.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-31 16:58:05 +10:00
Collecting
678d6c095f feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:59:31 +00:00
Collecting
1ca62a0302 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:58:49 +00:00
Collecting
bbd74891fd feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:58:00 +00:00
Collecting
63e48d9191 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:57:15 +00:00
Collecting
4a81f4ff83 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:56:04 +00:00
Collecting
dee84bd8a3 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:55:03 +00:00
Collecting
4f4b3a9360 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:51:44 +00:00
Collecting
1820ed7815 feat(fs): Cross-Compatible Emulator Save Pathing w/ Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-31 03:50:58 +00:00
Collecting
2e8d5992a2 feat(fs): Implement Global Custom Save Path
Added a "Global Custom Save Path" configuration option in the Filesystem settings.

Implemented a prioritized save-loading hierarchy: Global Path (if enabled) > Per-Game Custom Path > Default NAND.

Introduced a non-destructive migration tool that allows users to consolidate their existing saves into the new global location.

The migration tool specifically prioritizes per-game custom saves over NAND saves to ensure the most up-to-date data is preserved during consolidation.

The migration process is copy-only; no data is deleted from the source directories, ensuring absolute user data safety.

Maintained compatibility with the existing "Backup Saves to NAND" feature, ensuring saves continue to be mirrored internally if configured.

Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-29 01:12:50 +00:00
Collecting
8506c7c394 fix: Strict Clang Rule
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-26 22:46:50 +00:00
Collecting
499a82d3fd fix: Strict Clang Rule
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-26 22:45:59 +00:00
Zephyron
cc60303b11 feat(core): Update HOS and NintendoSDK version constants
- Bumps HOS version from 20.1.5 to 21.0.0
- Updates the corresponding `VERSION_HASH`, `DISPLAY_VERSION`, and
  `DISPLAY_TITLE` strings.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-26 17:02:15 +10:00
Zephyron
aad942cf25 fix(network): revert to legacy packet format for emulator compatibility
Remove the 'reliable' boolean field from LDNPacket and ProxyPacket
structs and all associated serialization/deserialization logic.
All packets now use reliable delivery by default via ENet layer,
matching the legacy format for full backward compatibility.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-26 16:54:31 +10:00
Zephyron
14c97aebb7 fix(ldn): improve packet validation and debug logging
- Add size validation before memcpy for Connect/Disconnect packets
- Allow empty data for Scan packets (Type 0) which have no payload
- Add debug logging for ScanResp packets including BSSID and results
- Fix MacAddress indexing to use .raw[] instead of [] operator

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-26 16:53:26 +10:00
Zephyron
499b3c1a59 fix(fatal): handle unknown error module 359 gracefully
Handle error 2359-2618 (module 359, description 2618) gracefully
by logging a warning instead of crashing, similar to module 56.
This allows games like SSBU to continue execution when encountering
this error code.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-26 16:52:33 +10:00
Zephyron
38d4152021 fix(network): improve ZSTD compression/decompression error handling
- Add error checking after decompression to drop corrupted packets
- Add error checking after compression to prevent sending empty packets
- Allow ZSTD_CONTENTSIZE_UNKNOWN and use streaming decompression
- Only reject ZSTD_CONTENTSIZE_ERROR as a fatal error

Fixes network connectivity issues where corrupted/empty packets were
being processed, breaking the network protocol.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-26 16:51:33 +10:00
Collecting
3dee7e3015 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:40:51 +00:00
Collecting
9407a5ba94 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:40:29 +00:00
Collecting
625e1d3229 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:39:59 +00:00
Collecting
42c237dc4a fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:39:20 +00:00
Collecting
7ad7d8ada6 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:38:42 +00:00
Collecting
16f928df79 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:37:57 +00:00
Collecting
67bf3b53b7 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:37:21 +00:00
Collecting
ddddb28c54 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:36:49 +00:00
Collecting
f4d712d497 fs(feat): Add Backup Saves for Custom Save Paths
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-12-22 08:35:57 +00:00
Zephyron
5eed2b221b fix(nvdrv): prevent infinite loop and improve error handling when SMMU address space is exhausted
Fix crash in PinHandle when SMMU allocation fails and unmap queue is empty.
Previously, the code would log an error and continue looping indefinitely,
causing log spam and eventual crash.

- Free multiple handles from unmap queue (up to 100) before giving up
- Add maximum attempt counter to prevent infinite loops
- Return 0 gracefully when no more handles can be freed
- Add error handling in callers (Remap, MapBufferEx, MapBuffer) to check for
  PinHandle failure and return NvResult::InsufficientMemory instead of using
  invalid addresses

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-16 16:44:13 +10:00
Zephyron
dadf9d270c fix(nvdrv): prevent infinite loop when SMMU address space is exhausted
Fix crash in PinHandle when SMMU allocation fails and unmap queue is empty.
Previously, the code would log an error and continue looping indefinitely,
causing log spam and eventual crash. Now it returns 0 to fail gracefully.

Also fix incorrect handle check on line 219 - should check freeHandleDesc
instead of handle_description.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-16 16:24:15 +10:00
Zephyron
34800248cc fix(video_core): Replace assertions with warnings in Fermi2D and BSD sockets
- Fermi2D: Log warnings for unsupported operations, layers, depth, and clip
- BSD sockets: Return INVAL for unimplemented getsockopt optnames instead of SUCCESS

Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-12-08 17:03:51 +10:00
Zephyron
90eeee345c feat(filesystem): add custom save path support per game
- Add custom_save_paths map to Settings::Values
- Implement ReadCustomSavePathValues and SaveCustomSavePathValues in Config
- Update CreateSaveDataFactory to check for custom save paths
- Support per-game title ID save path overrides

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-28 16:11:07 +10:00
Zephyron
a1b317a15e fix: add Module 56 error support and improve error handling
- Add Module56 to ErrorModule enum for error code 2056-2306
- Add Module 56 error handling in fatal error reporting
- Define Module 56 error codes in ldn_results.h
- Improve error reporting for unknown modules

This allows the emulator to properly handle error code 2056-2306
reported by Minecraft and other games, preventing undefined
behavior when encountering unknown module errors.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-13 20:14:04 +10:00
Zephyron
19faff40cd fix: socket assertion crashes and add Nex service stub
- Replace socket option assertion failures with proper error returns
- Add WSAENOPROTOOPT/ENOPROTOOPT error handling
- Fix LINGER and option value size validation
- Add Network::Errno::OTHER translation
- Implement basic Nex service stub for error code 2306-0520

Fixes crashes in Minecraft and other games when encountering unsupported
socket operations or attempting to use Nintendo's online services.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-13 19:30:40 +10:00
Zephyron
69f3225fa8 fix: correct Little Nightmares 3 TitleID check for PC to LR recovery
The TitleID check was broken due to using || operator which evaluated
to 1 instead of a title ID value, preventing the recovery mechanism
from working.

- Fix title_ids.h: Replace incorrect || expression with proper
  LittleNightmares3Base constant (0x010066101A55A000)
- Update physical_core.cpp: Use GetBaseTitleID() to match both
  base and update title ID variants

This now correctly identifies Little Nightmares 3 and enables the
recovery mechanism that sets PC to LR when detecting null pointer
execution loops.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-11 20:05:07 +10:00
Zephyron
d59eb9a1a8 Add Firmware 20.0.0-21.0.0 IPC support and stubs
This commit implements comprehensive firmware 20.0.0 through 21.0.0
support for Citron, including:

- Updated firmware version constants to 21.0.0 in api_version.h
- Updated HID service firmware version string to 21.0.0
- Added IPC command stubs for firmware 20.0.0+ in:
  * ISystemSettingsServer (commands 263, 264, 282, 283, 289, 300, 301, 306, 307)
  * IFirmwareDebugSettingsServer (command 24)
  * IApplicationFunctions (command 330)
  * IOlscServiceForSystemService (command 914)
  * IRemoteStorageController (commands 28, 901)
  * IService (migration) (commands 2250, 2260)
  * IAudioController (command 10200)

- Created new service interfaces with proper stubs:
  * IContinuousRecorder (grcsrv) - command 5 [20.2.0+] with 0x20-byte input
  * IDownloadContext (news) - command 4 [20.0.0+]
  * INotifyService (pdm:ntfy) - commands 100, 101 [20.0.0+] returning outinterfaces

- Added all new source files to CMakeLists.txt build system
- Fixed logging tag usage (Service_Migration instead of Service_MIG)
- Added required CMIF serialization headers for proper template instantiation

All stubs return success explicitly, eliminating the need for auto-stubbing.
All implementations follow Switchbrew documentation as closely as possible.

Based on Switchbrew documentation:
- https://switchbrew.org/wiki/21.0.0
- https://switchbrew.org/wiki/20.5.0
- https://switchbrew.org/wiki/20.4.0
- https://switchbrew.org/wiki/20.3.0
- https://switchbrew.org/wiki/20.2.0
- https://switchbrew.org/wiki/20.1.5
- https://switchbrew.org/wiki/20.1.1
- https://switchbrew.org/wiki/20.1.0
- https://switchbrew.org/wiki/20.0.1
- https://switchbrew.org/wiki/20.0.0

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-11 18:52:10 +10:00
Zephyron
85a41cba46 Fix: Make PC return recovery title-specific for Little Nightmares 3
The PC < 0x1000 recovery mechanism introduced in commit fbb4f5c0
was causing issues for other games. This change restricts the recovery
to only apply when the title ID matches Little Nightmares 3.

- Add LittleNightmares3 title ID constant to title_ids.h
- Check program ID before applying PC return recovery in physical_core.cpp
- Recovery now only triggers for Little Nightmares 3 (010066101A55A800)
  to avoid affecting other games

Fixes issues caused by the general PC return recovery in other titles.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-10 20:00:55 +10:00
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