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>
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>
- Implement CreateInterruptEvent SVC function to resolve panic
- Add proper resource management with KScopedResourceReservation
- Use regular KEvent as placeholder for interrupt events
- Add proper cleanup with SCOPE_EXIT
- Include debug logging for troubleshooting
- Implement GetLaunchRequiredVersionUpgrade in IApplicationFunctions service
- Fix "Unknown / unimplemented function" error for command 210
- Return event handle instead of boolean to match Nintendo Switch API
- Use state_changed_event as placeholder until dedicated event is implemented
- Add function declaration to header file
Tested with Hollow Knight: Silksong - successfully boots.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Replace stubbed ZBCSetTable with comprehensive implementation
- Add parameter validation for format and type fields
- Implement detailed logging of ZBC color values for debugging
- Add proper documentation explaining ZBC (Zero Bandwidth Clear) functionality
- Handle color_ds and color_l2 arrays for GPU memory clearing operations
- Validate format parameter range (0-0xFF) and type parameter (0-1)
- Provide clear error handling for invalid parameters
- Add ZBCManager singleton class for global ZBC table management
- Implement ZBCQueryTable with full table lookup functionality
- Add thread-safe ZBC table storage with proper mutex protection
- Create ZBC namespace helper functions for GPU clearing operations
- Fix IoctlGpuCharacteristics struct size (0xA0) by correcting field types
- Add comprehensive logging and error handling for ZBC operations
- Enable ZBC table integration with GPU memory management system
- Store ZBC entries in both local device table and global manager
- Implement reference counting for proper ZBC entry lifecycle management
ZBC (Zero Bandwidth Clear) allows the GPU to perform efficient memory
clearing operations without requiring CPU bandwidth by storing clear
values in a dedicated table that can be referenced during rendering.
This implementation provides the foundation for zero-bandwidth clear
operations, allowing the GPU to efficiently clear color and depth
buffers using pre-defined values stored in the ZBC table.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Replace stubbed ZBCSetTable with comprehensive implementation
- Add parameter validation for format and type fields
- Implement detailed logging of ZBC color values for debugging
- Add proper documentation explaining ZBC (Zero Bandwidth Clear) functionality
- Handle color_ds and color_l2 arrays for GPU memory clearing operations
- Validate format parameter range (0-0xFF) and type parameter (0-1)
- Provide clear error handling for invalid parameters
ZBC (Zero Bandwidth Clear) allows the GPU to perform efficient memory
clearing operations without requiring CPU bandwidth by storing clear
values in a dedicated table that can be referenced during rendering.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Replace stubbed QueryPointerBufferSize with comprehensive implementation
- Calculate pointer buffer size based on IPC message buffer requirements
- Account for all buffer descriptor types (X, A, B, W, C) and message headers
- Include proper alignment and overhead calculations
- Cap buffer size to reasonable maximum (64KB) to prevent excessive memory usage
- Use dynamic calculation instead of hardcoded 0x8000 value
- Add detailed comments explaining the buffer size calculation logic
This implementation properly handles the IPC marshalling requirements for
pointer buffers used in service communication, eliminating the frequent
stub warnings in the logs.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Changes:
- Add validation in BSD::SendToImpl to check for empty address buffers on
datagram sockets and return EINVAL instead of passing nullptr to sendto()
- Add null pointer check in ProxySocket::SendTo to prevent dereferencing
nullptr address parameters
- Improve error logging to help identify socket configuration issues
Fixes: Socket operation errors in HDR multiplayer sessions
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Accept SockAddrIn len in [6, sizeof] and warn instead of asserting to handle libnx/SSBU quirks
- Ensure TranslateFromSockAddrIn sets sin_port via htons(uint16_t) for consistent network byte-order
- Prevents assertion crashes and reduces “Broken pipe” error spam observed in Frozen's SSBU logs
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Fix LTO linking issues on CachyOS with GCC 15.x
- Add LTO support to all core library targets (input_common, frontend_common,
network, shader_recompiler, web_service) that were missing LTO configuration
- Create citron_configure_lto() helper function for consistent LTO handling
- Implement CachyOS-specific detection via /etc/os-release and kernel version
- Apply conservative LTO flags (-flto=auto -ffat-lto-objects) only for
CachyOS + GCC 15+ to resolve linking errors with newer toolchains
- Other distributions continue using aggressive LTO settings for maximum performance
- Disable LTO on executable targets to prevent main function optimization issues
This resolves "undefined symbol" errors when building with -DCITRON_ENABLE_LTO=ON
on CachyOS while maintaining optimal LTO performance on other distributions.
Fixes linking errors including:
- Core::Frontend::EmuWindow symbols
- Core::System methods
- Settings::values
- Common logging functions
Tested on CachyOS with GCC 15.1.1 + LLD 20.1.8
Signed-off-by: Boss.sfc <boss.sfc@citron-emu.org>
Fix multiple compilation errors preventing successful build:
* Add const qualifier to custom fmt formatter functions across codebase
- Updated formatters in logging, shader recompiler, texture cache, and other modules
- Ensures compatibility with newer fmt library versions
* Add missing fmt/ranges.h includes for fmt::join usage
- Fixed fmt::join calls in Vulkan renderer, GDB stub, NFC service, and main window
- Resolves "no member named 'join' in namespace 'fmt'" errors
* Exclude unsupported platforms from Boost.Process usage in debugger
- Extended conditional compilation to avoid Boost.Process where unavailable
* Fix type casting issues in AOC service manager
- Resolved std::min type mismatch with explicit casting
- Fix CMIF serialization alignment error in RequestSyncDeliveryCacheWithApplicationIdAndDirectoryName by reordering parameters (DirectoryName before u64)
- Implement missing INotifierService and IDeliveryTaskSuspensionService classes with proper kernel event handling
- Add missing source files to CMakeLists.txt to resolve linker errors
- Update IServiceCreator to properly implement CreateDeliveryCacheProgressService methods instead of leaving them stubbed
- Add ProgressServiceBackend support to IServiceCreator with proper friend class access
- Fix kernel event creation by using KernelHelpers::ServiceContext instead of direct system calls
- Add proper includes for kernel_helpers.h and event management
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Add implementation for the TMA service which provides file I/O
and debugging functionality for development tools.
Changes:
- Add TMA service with IFileManager, IFileAccessor, and IDirectoryAccessor
- Implement stubbed file operations (ReadFile, WriteFile, GetFileSize, etc.)
- Implement stubbed directory operations (ReadDirectory, GetEntryCount, etc.)
- Add TMA logging category for service debugging
- Fix parameter alignment in ReadFile function signature
All functions are provided as-is to allow games and development tools to initialize
without errors.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add IDeviceOperator interface with 49 functions for SD card, MMC, and game card operations
- Add IEventNotifier interface for filesystem event notifications
- Add ISaveDataTransferManager and related transfer interfaces (exporter/importer)
- Add IWiper interface for BIS partition wiping
- Enhance FSP_SRV with OpenDeviceOperator, OpenSdCardDetectionEventNotifier, OpenSaveDataTransferManager, and other missing functions
- Enhance FSP_LDR with OpenCodeFileSystem, IsArchivedProgram, and SetCurrentProcess implementations
- Enhance FSP_PR with RegisterProgram, UnregisterProgram, and verification functions
- Fix ServiceContext usage for proper event creation and management
- Fix function parameter alignment issues for CMIF serialization
- Update build system to include new source files
- Update copyright headers to 2025 citron
All functions are implemented with appropriate logging and parameter validation based on Nintendo Switch filesystem services documentation.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add Unknown39 and Unknown40 functions to BSD service for [20.0.0+]
- Implement bsd:nu service with ISfUserService and ISfAssignedNetworkInterfaceService
- Add dns:priv and ethc:c/ethc:i service stubs
- Update CMakeLists.txt to include new socket service files
- All new functions include basic stub implementations following existing patterns
This completes the socket services implementation based on switchbrew.org documentation.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add all missing function declarations and implementations for HID server
- Implement functions from 15.0.0+ through 20.0.1+ firmware versions
- Add proper command buffer IDs matching switchbrew documentation:
* 1010: SetForceSixAxisSensorFusedParameters [15.0.0+]
* 1011: GetForceSixAxisSensorFusedParameters [15.0.0+]
* 1012: GetFirmwareVersionStringForUserSupportPage [20.0.0+]
* 1420: GetAppletResourceProperty [19.0.0+]
* 533: SetPalmaDisallowedActiveApplications [20.0.0+]
* 410: GetNpadOfHighestBatteryLevelForJoyLeft
- Add comprehensive Unknown function stubs for gaps in documentation
- Update HID debug server with missing functions and fix duplicate entries
- Organize functions by firmware version with proper comments
- Update firmware version string to realistic Atmosphere 1.9.1 + NX 20.1.5
- Fix GetResourceManager to use Initialize() instead of UpdateControllers()
- Ensure all functions have proper stub implementations with logging
This brings Citron's HID service implementation to full parity with the
official Nintendo Switch HID service as documented on switchbrew.org.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Bumps HOS version from 20.1.1 to 20.1.5
- Updates the corresponding `VERSION_HASH`, `DISPLAY_VERSION`, and
`DISPLAY_TITLE` strings.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Adds implementation for the missing ActivateDebugMouse HID service function
that was causing crashes when games attempted to call it.
- Add ActivateDebugMouse declaration to IHidServer header
- Implement ActivateDebugMouse function following the same pattern as ActivateMouse
- Update function table to call the actual implementation instead of nullptr
- Add missing include for debug_mouse.h
Fixes crashes in games (GEX Trilogy) that use debug mouse functionality.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Change storage assignment from SetDataStorage() method to direct array indexing to prevent crashes when newer game updates are detected.
- The previous method was incorrectly handling storage info assignment for integrity verification layers.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add IContentsServiceManager class with RequestContentsAuthorizationToken function
- Add IAsyncData class for handling asynchronous authorization token operations
- Implement CreateContentsServiceManager in IAddOnContentManager (was previously stubbed)
- Add support for GetSize, Read, Cancel, and GetSystemEvent operations in IAsyncData
- Update CMakeLists.txt to include new source files
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Bumps HOS version from 20.0.1 to 20.1.1.
- Updates the corresponding `VERSION_HASH`, `DISPLAY_VERSION`, and
`DISPLAY_TITLE` strings.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Mark ResultNotImplemented and ResultNsdNotInitialized with
[[maybe_unused]] to avoid compiler warnings.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Extended MemoryLayout enum with new memory size options
- Added corresponding SMC memory size and arrangement constants
- Updated system control functions to handle new memory configurations
- Added appropriate application pool sizes for higher memory modes
- Updated UI translations to display new DRAM options as "Unsafe"
- Increased maximum memory layout setting from 8GB to 16GB
This allows users to configure higher memory amounts for games and
texture mods that require more than the standard 4-8GB configurations.
All new options are marked as "Unsafe" in the UI to indicate they
are experimental features beyond Nintendo's official specifications.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add complete IAudioController implementation with 32 missing functions:
* Volume control (GetTargetVolume, SetTargetVolume, etc.)
* Mute control (IsTargetMute, SetTargetMute, etc.)
* Target management (SetDefaultTarget, GetDefaultTarget, etc.)
* Play report functions (10000+ series command IDs)
* Hearing protection safeguard functions
* Debug and system functions
- Add new audio services:
* codecctl - Codec controller service with 13 functions
* auddebug - Audio debug service placeholder
* Device suspend/resume services (audout:d, audin:d, audrec:d, audren:d)
* System audio services (aud:a, aud:d)
* Applet audio services (audout:a, audin:a, audren:a)
- Update IAudioDevice with missing functions:
* GetAudioSystemMasterVolumeSetting
* GetActiveAudioOutputDeviceName
* Fix function ID mappings to match official documentation
- Register all services in main audio LoopProcess function
- Update CMakeLists.txt with new source files
All implementations follow the official Switch audio services documentation
from switchbrew.org and provide appropriate stub implementations with
sensible default values for enhanced game compatibility.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Add acc:e service with full account management functionality
- Add acc:e:u1 service (minimal implementation)
- Add acc:e:u2 service with extended functionality including PIN code support
- Add dauth:0 device authentication service
- Update acc_su function mappings to match newer firmware versions
- Move TrySelectUserWithoutInteraction from ID 51 to 52 with deprecated fallback
These services provide additional account management interfaces used by
newer Switch firmware versions and some games that require extended
account functionality.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
- Addition of all documented commands for `INpnsSystem` and `INpnsUser` as `nullptr` stubs. This includes newly added commands and ensures all known commands have a placeholder.
- Introduction of empty class definitions for `INotificationReceiver`, `ICreateTokenAsyncContext`, `ISubscriptionUpdateNotifier`, and `IFuture` interfaces as specified in the documentation.
- Reversion of the previous change that made `nullptr` stubs call an `UnimplementedMethod` that returned success. Stubs are now back to being `nullptr`.
- Update of the copyright year in `npns.cpp`.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit introduces support for a 32:9 aspect ratio throughout Citron.
Key changes include:
- **Enum Updates**: Added `R32_9` to `Settings::AspectRatio` and `Layout::AspectRatio` enums, ensuring consistent integer mapping for casting between them.
- **Core Logic**:
- Modified `UISettings::CalculateWidth` to correctly compute width for the 32:9 ratio.
- Updated `Layout::EmulationAspectRatio` to handle the new `R32_9` case and return the appropriate float value (9.0f / 32.0f).
- **Android Integration**:
- Updated `EmulationFragment.kt` and `EmulationActivity.kt` (for Picture-in-Picture) to recognize and apply the 32:9 aspect ratio (mapping setting value `4` to `Rational(32, 9)`).
- **UI Configuration**:
- Added "Force 32:9" to the aspect ratio selection in the graphics settings UI via `shared_translation.cpp`. This string is translatable.
This enhancement allows users to utilize ultra-widescreen 32:9 displays for a more immersive experience.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Adds implementations for missing nsd:u and nsd:a services
as documented in SwitchBrew. This includes:
- Defining necessary data structures (Url, SettingName, DeviceId, Fqdn,
NasServiceSetting, NasServiceName, SaveData, TestParameter, DeleteMode,
ImportMode) in nsd.cpp.
- Adding declarations for new service methods to nsd.h.
- Implementing basic stub logic for each new service method in nsd.cpp,
including logging, returning default success/error codes, and handling
output buffers where applicable.
- Implementing checks for nsd:a specific functions using a new
IsNsdA() helper.
- Updating the copyright year in nsd.h.
This provides a complete interface for the nsd service, allowing
further development and reducing unknown service calls.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Adds implementations for missing `sfdnsres` (nn::socket::resolver::IResolver) service functions and corrects command ID mappings to align with Switchbrew documentation.
Key changes:
- Implemented stubs for the following `sfdnsres` functions:
- `SetDnsAddresses` (Cmd 0)
- `GetDnsAddressList` (Cmd 1)
- `GetHostByAddrRequest` (Cmd 4, deprecated)
- `GetHostStringError` (Cmd 5)
- `CancelRequest` (Cmd 7)
- `GetOptions` (Cmd 9)
- `GetAddrInfoRequestRaw` (Cmd 11)
- Updated the command registration table in the `SFDNSRES` constructor to use correct Switchbrew command IDs and map them to the appropriate existing or new (stubbed) implementations.
- Retained and stubbed `GetNameInfoRequest` and `GetNameInfoRequestWithOptions` with placeholder IDs, as they were present in the previous command table.
- Corrected usage of `GetAddrInfoError` constants in stubs to use valid members (e.g., `GetAddrInfoError::AGAIN` instead of a non-standard `INTERNAL`).
This significantly expands the implemented interface for the `sfdnsres` service, bringing it closer to the documented functionality and resolving related compilation errors.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Adds implementations for all `bsdcfg` (aliased as `ifcfg`) service functions as listed in the existing codebase and supplemented by Switchbrew documentation.
The following functions have been added to the `BSDCFG` service:
- `SetIfUp` (Cmd 0)
- `SetIfUpWithEvent` (Cmd 1)
- `CancelIf` (Cmd 2)
- `SetIfDown` (Cmd 3)
- `GetIfState` (Cmd 4)
- `DhcpRenew` (Cmd 5)
- `AddStaticArpEntry` (Cmd 6)
- `RemoveArpEntry` (Cmd 7)
- `LookupArpEntry` (Cmd 8)
- `LookupArpEntry2` (Cmd 9)
- `ClearArpEntries` (Cmd 10)
- `ClearArpEntries2` (Cmd 11)
- `PrintArpEntries` (Cmd 12)
- `Unknown13` (Cmd 13)
- `Unknown14` (Cmd 14)
- `Unknown15` (Cmd 15)
These functions are initially stubbed to log a warning and return `EOPNOTSUPP`.
Command handlers have been updated in the `BSDCFG` constructor.
Additionally, this commit corrects the logging category in these new `BSDCFG` stubs from an undefined `Service_BSDCFG` to the existing `Service` category, resolving compilation errors.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Adds implementations for several previously unimplemented BSD socket service functions, as documented in Switchbrew. REF: https://switchbrew.org/wiki/Sockets_services#bsd:u.2C_bsd:s.2C_bsd:a
The following functions have been added to the `bsd:u`, `bsd:s`, and `bsd:a` services:
* `SocketExempt` (Cmd 3)
* `Open` (Cmd 4)
* `Sysctl` (Cmd 7)
* `Ioctl` (Cmd 19)
* `ShutdownAllSockets` (Cmd 23)
* `GetResourceStatistics` (Cmd 28)
* `RecvMMsg` (Cmd 29)
* `SendMMsg` (Cmd 30)
* `RegisterResourceStatisticsName` (Cmd 32)
* `RegisterClientShared` (Cmd 33) (replaces the placeholder `Initialize2`)
* `GetSocketStatistics` (Cmd 34)
* `NifIoctl` (Cmd 35)
* `SetThreadCoreMask` (Cmd 200)
* `GetThreadCoreMask` (Cmd 201)
These functions are initially set to log a warning and return an appropriate error code (typically `EOPNOTSUPP` or `ENOTTY`), or success in the case of registration-type functions.
The command handlers have been registered in the BSD service constructor.
This resolves various compilation errors encountered during the implementation process related to IPC response generation and enum usage.
Signed-off-by: Zephyron <zephyron@citron-emu.org>
Add an implementation for function 92 (SetGestureOutputRanges) in the HID service.
This fixes a crash in Donkey Kong Country Returns HD which occurs when the game
attempts to access this unimplemented function. The function is now properly
registered and returns success while logging the call.
The specific error that was occurring:
"Unknown / unimplemented function '92': port='hid'"
According to the official Switch documentation, this function was introduced in
firmware 18.0.0+ and is used for setting gesture output ranges for touch/gesture
controls.
Signed-off-by: Zephyron <zephyron@citron-emu.org>