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>
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>
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>
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>
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>
- 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>
- 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>
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>