Commit Graph

24317 Commits

Author SHA1 Message Date
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
57e6141d4a Fix QJsonValue conversion ambiguity in game_list_worker.cpp
Explicitly cast modification_time to qint64 to resolve Linux build
error where std::int64_t conversion to QJsonValue is ambiguous.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-11 19:11:15 +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
1127d30fd8 Fix: Restrict PC return recovery to Little Nightmares 3 with adjusted threshold
Only applies to Little Nightmares 3 (title ID: 010066101A55A800).

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-10 20:55:54 +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
d78c598927 ui: Add modern toolbar to game list with view controls and sorting
Add a toolbar to the game list with:
- List/Grid view toggle buttons with icons and rounded corners
- Icon size slider for adjusting game icon sizes in real-time
- A-Z sort button that toggles between ascending/descending order
- Rounded corners styling throughout for a modern appearance

Key improvements:
- Fix games vanishing when adjusting slider during filtered search by
  updating icons in-place instead of recreating the model
- Preserve scroll position and selection when updating icon sizes
- Reuse filtered model instead of deleting/recreating to prevent view flicker
- Ensure consistent rounded icon rendering at exact target sizes
- Sync sort button state with Name column header sort order
- Preserve active filters when repopulating the game list

The toolbar uses themed icons with Qt standard icon fallbacks for
cross-platform compatibility.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-10 19:54:57 +10:00
Zephyron
9a64d5d072 perf: Add game metadata caching to speed up library loading
Implement a comprehensive caching system for game title metadata to
significantly improve game list loading performance for large libraries.

- Add CachedGameMetadata structure to store program ID, file type,
  size, title, icon, and modification time
- Implement LoadGameMetadataCache() and SaveGameMetadataCache() to
  persist cache to disk as JSON
- Integrate cache into ScanFileSystem() to skip expensive ReadIcon()
  and ReadTitle() operations when cached data is available
- Add automatic cache invalidation based on file modification time
- Cache respects existing UISettings::values.cache_game_list setting

The cache is stored in the game_list directory and automatically
invalidates entries when files are modified, ensuring data accuracy
while providing substantial performance improvements for subsequent
library scans.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-10 18:14:33 +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
652a6a56ef feat: add Snapdragon 8 Elite support and implement shader features
- Add device detection for Snapdragon 8 Elite (device ID 0x43052c01)
- Disable shader float controls and 64-bit integer atomics on Qualcomm
  proprietary drivers to work around driver limitations
- Enable native BGR format support on S8 Elite (similar to S8 Gen 2)
- Implement VOTE_vtg instruction for vertex/tessellation/geometry shaders
  with proper single-thread semantics
- Replace stub warnings with detailed comments for FCSM_TR flow test and
  SR_WSCALEFACTOR special registers to document expected behavior

These changes improve compatibility with Qualcomm Snapdragon 8 Elite
devices and reduce spurious warnings by documenting shader features
that are correctly handled as conservative defaults.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-04 20:41:13 +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
Collecting
b8021fa7e7 fix: Make Multiplayer Room Work even out of Game
Annoyed a few people that the Overlay was non-functional unless they were in-game. Now it works when not in-game.

Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-04 00:42:18 +00:00
Zephyron
a5024bb218 kernel: Use CheckMemoryStateContiguous in UnmapCodeMemory
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-03 16:19:46 +10:00
Collecting
e097974a66 fix: Race Condition when Updating UI/OS Theme
Testing and fiddling with our recent overhaul for changing OS/UI themes and updating on the fly resulting in a segmentation fault that also would not allow you to re-open the emulator unless changing back to the theme previously known by Citron, which obviously we don't want. Grabbed the core dump.

The backtrace pointed to a race condition in GMainWindow::UpdateUITheme, where a QTextStream was reading from a Qt resource stylesheet (.qss) that was being simultaneously reloaded by the theme change event. This led to an attempt to read from a dangling pointer.

This change resolves the issue by reading the entire stylesheet into memory in a single, atomic operation using f.readAll(). This prevents the underlying resource from becoming invalid during the read. The resulting QByteArray is explicitly converted to a QString via QString::fromUtf8 to satisfy Qt 6's stricter type requirements.

Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-03 03:05:28 +00:00
Collecting
73094cdcdb fix/re-enable-updates
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-03 00:54:08 +00:00
Collecting
56ec56aa37 fix/re-enable-updates
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-03 00:53:37 +00:00
Collecting
d1d93b7629 fix/check-for-updates
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-03 00:15:42 +00:00
Collecting
6aa483a9d2 fix/check-for-updates
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-03 00:14:47 +00:00
Collecting
6d9e18eb3a fix/adjusted-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 05:15:49 +00:00
Collecting
1a07eb4ad1 fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:39:05 +00:00
Collecting
3413912a94 fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:37:27 +00:00
Collecting
c4fcf0dfc7 fix/dynamic-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:36:42 +00:00
Collecting
fbaa366065 fix/dynamic-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:35:43 +00:00
Collecting
f8bb1c70b0 fix/multiplayer-overlay-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:35:00 +00:00
Collecting
49bc7e0c38 fix/dynamic-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:33:58 +00:00
Collecting
bcf3dd36b8 fix/dynamic-themes
Helps change theme to update during emulation.

Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:32:21 +00:00
Collecting
c42a8ed7b8 fix/light-dark-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:31:15 +00:00
Collecting
c48744092d fix/light-dark-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:30:38 +00:00
Collecting
e4c1a003e3 fix/light-dark-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:29:43 +00:00
Collecting
02dec9f461 fix/light-dark-themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 04:28:51 +00:00
Zephyron
988f294e94 chore: bump version to 0.10.0
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-02 13:38:49 +10:00
Collecting
bccddc82b5 fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 02:06:08 +00:00
Collecting
755286cbbc fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 02:05:39 +00:00
Collecting
3f3956ed8a fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 02:04:42 +00:00
Collecting
7410c760e6 fix/themes
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-02 02:04:10 +00:00
Zephyron
bd17537b93 chore(updater): Add logging to diagnose update helper script creation
Helps debug why apply_update.bat may not be created in update_staging.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-02 11:27:59 +10:00
Collecting
ac777fabd9 fix/controller-overlay-toggle
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 21:06:32 +00:00
Collecting
60f314daef add/controller-overlay-toggle
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 21:03:34 +00:00
Collecting
0d5506030b fix/hotkey-memory
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 21:02:55 +00:00
Collecting
45cfbbeb6b fix/hotkeys
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 21:02:21 +00:00
Collecting
e495ef5148 fix/hotkeys
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 21:01:39 +00:00
Zephyron
d2f2d50e28 build: add Qt6 TLS plugin copying to CopyCitronQt6Deps
- Configure Qt6_TLS_DIR and TLS destination paths
- Copy TLS plugins using windows_copy_files utility
- Support Debug and Release configurations

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 23:17:54 +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
0ce89925a2 Fix Windows auto updater file locking issue
Implement deferred update mechanism using a helper batch script that applies
updates after the application exits, avoiding Windows file locking issues.

On Windows, the updater now:
- Stages update files and creates a helper batch script
- Launches the script as a detached process
- Exits the application
- The script waits for app closure, applies updates, and restarts Citron

Linux AppImage updates continue to work as before with the existing method.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 19:19:02 +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
9a5b75db83 video_core: Add mip level clamping for CTGP-DX compatibility
Fixes crashes when games/mods request more than MAX_MIP_LEVELS (14).

Implements defensive clamping at four critical points in the texture
cache (CalculateLevelSizes, CalculateMipLevelOffsets,
CalculateMipLevelSizes, CalculateLevelBytes) to gracefully handle
excessive mip level requests.

When >14 mip levels are requested:
- Logs informative warning (debug builds)
- Clamps to MAX_MIP_LEVELS
- Continues execution safely

This improves upon Eden's solution by adding actual bounds checking
instead of just converting ASSERT to ASSERT_MSG.

Fixes: CTGP-DX (Mario Kart 8 Deluxe mod)

Co-authored-by: JPikachu <jpikachu.eden@gmail.com>
Co-authored-by: JPikachu <jpikachu@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
2025-11-01 16:22:25 +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
Collecting
84035e9bc2 fix/configuration-light-dark
Signed-off-by: Collecting <collecting@noreply.localhost>
2025-11-01 03:06:31 +00:00