eden/src/core
PavelBARABANOV 815325ccec
[loader] add ZBIC (zstd variant) NSO decompression support for Switch 22.0+ (#4482)
- [x] I have read and followed the [Contribution Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/CONTRIBUTING.md#code-contributions).
- [x] I have read and followed the [AI Policy](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/AI.md)
- [x] I have read and followed the [Coding Guidelines](https://git.eden-emu.dev/eden-emu/eden/src/branch/master/docs/policies/Coding.md) to the best of my ability.

-------------------
A new NSO compression method was introduced in Switch 22.0.0. This is a
customized variant of zstd and is used when NSO flags have bit 7 set.

Key characteristics:
  - ZSTD_MAGICNUMBER is set to 0x4349425A (b'ZBIC') instead of 0xFD2FB528
  - ZSTD_LEGACY_SUPPORT is set to 0
  - ZSTD_TRACE is set to 1, zstd version used is 1.5.7 (10507)
  - FSE_readNCount is replaced with a BIC (Binary Interpolative Coding)
    version which improves compression of entropy tables significantly

Source: https://switchbrew.org/wiki/22.0.0

Implementation:
  - Detect ZBIC segments via NSO flag bit 7 (NsoFlags_UseZbicCompression)
    and/or ZBIC magic scan in nso.cpp
  - Fall back to LZ4 when ZBIC is not detected or returns unexpected size
  - Handle segment 0 alternate offset (0x100 vs 0x108) for both ZBIC and LZ4

References:
  - Atmosphère loader/strat zstd-zbic integration:
    082115187a
  - nxdumptool ZBIC segment compression support:
    441e5c0904
  - STORM_SWITCH ZBIC implementation:
    1e09eb82b7

Tested with firmware 23.0.0 and ZBIC-compressed NSOs.

Co-authored-by: xbzk <xbzk@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/4482
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: lizzie <lizzie@eden-emu.dev>
Reviewed-by: Maufeat <sahyno1996@gmail.com>
2026-09-27 12:48:45 +02:00
..
arm [dynarmic] Coalesce non-exclusive Write/Read fallback functions (#4158) 2026-09-19 01:39:46 +02:00
crypto [common] rework BitField and BitUtil, use concepts whenever possible (#4076) 2026-07-09 03:47:04 +02:00
debugger [cmake] Fix some macOS compilation errors (#4350) 2026-09-05 23:43:46 +02:00
file_sys [common] Use `std::make_unique_for_overwrite<T>` in ScratchBuffer, remove polyfill (#4432) 2026-09-25 07:54:49 +02:00
frontend [applet] ReconfigureControllers fallback unconditional disconnect fix (#4420) 2026-09-15 21:53:07 +02:00
hle [common] Use `std::make_unique_for_overwrite<T>` in ScratchBuffer, remove polyfill (#4432) 2026-09-25 07:54:49 +02:00
internal_network [internal_network] Fix WiFi scanner compilation on GCC 15.3.0 (#4279) 2026-08-21 23:29:24 +02:00
loader [loader] add ZBIC (zstd variant) NSO decompression support for Switch 22.0+ (#4482) 2026-09-27 12:48:45 +02:00
memory [core, hle, video_core, memory] Improve multi-process, display layers, dynamic shader cache and rework overlay (#4238) 2026-08-29 01:04:02 +02:00
tools [dynarmic] Coalesce non-exclusive Write/Read fallback functions (#4158) 2026-09-19 01:39:46 +02:00
CMakeLists.txt [frontend] Unify cmdline parsing (#4424) 2026-09-23 14:51:51 +02:00
constants.cpp [core] Use a eden profile picture instead of the default grey one. (#3350) 2026-01-20 18:32:08 +01:00
constants.h [core] Use a eden profile picture instead of the default grey one. (#3350) 2026-01-20 18:32:08 +01:00
core.cpp [fs] moved temp folder cleanup upstream (per-application level) to avoid per-program retrigger (#4375) 2026-09-10 22:30:07 +02:00
core.h [service, nvhost] added machinery to allow microsleep between nvdec read requests to avoid guest panic in some games (#4316) 2026-08-29 14:22:09 +02:00
core_timing.cpp [core, gpu, threads] Multithreading refactor (#4254) 2026-08-08 04:39:47 +02:00
core_timing.h [core/core_timing] better MWAITX and WAITPKG delays (#3984) 2026-05-30 21:59:10 +02:00
cpu_manager.cpp [core, gpu, threads] Multithreading refactor (#4254) 2026-08-08 04:39:47 +02:00
cpu_manager.h [video_core, hle] remove redundant parent references in system structs (#3908) 2026-06-23 06:31:25 +02:00
device_memory.cpp core: Define HAS_NCE macro 2023-11-25 00:47:36 -05:00
device_memory.h [common/core/dynarmic] Optimize page table allocations (#4219) 2026-09-09 21:35:49 +02:00
device_memory_manager.h [common/core/dynarmic] Optimize page table allocations (#4219) 2026-09-09 21:35:49 +02:00
device_memory_manager.inc [common/core/dynarmic] Optimize page table allocations (#4219) 2026-09-09 21:35:49 +02:00
game_settings.cpp [common/logging] Simplify logging logic and fix issues when logging before system is created (#3688) 2026-03-12 18:29:15 +01:00
game_settings.h [core] Add overridable game setting functionality (#2963) 2025-12-17 03:59:27 +01:00
gpu_dirty_memory_manager.h Core: Eliminate core/memory dependancies. 2024-01-18 21:12:30 -05:00
guest_memory.h Solves warning about GuestMemory having internal linkage. 2025-04-04 03:40:47 +02:00
hardware_properties.h [dynarmic] jit fix branch v2 (#203) 2025-08-27 06:49:50 +02:00
launch_params.cpp [frontend] Unify cmdline parsing (#4424) 2026-09-23 14:51:51 +02:00
launch_params.h [frontend] Unify cmdline parsing (#4424) 2026-09-23 14:51:51 +02:00
launch_timestamp_cache.cpp [common] Switch to boost::unordered_flat containers (#4326) 2026-08-31 02:58:09 +02:00
launch_timestamp_cache.h [tests] fix compile+linking issues with PlayTime (#3345) 2026-01-19 16:27:18 +01:00
memory.cpp [common/core/dynarmic] Optimize page table allocations (#4219) 2026-09-09 21:35:49 +02:00
memory.h Revert "[core/memory] Remove defered heap allocation on Linux." (#2974) 2025-11-09 22:42:09 +01:00
perf_stats.cpp [frontend] Slow and Turbo modes (#3525) 2026-02-12 01:31:55 +01:00
perf_stats.h chore: make yuzu REUSE compliant 2022-07-27 12:53:49 +02:00
reporter.cpp [core, hle, video_core, memory] Improve multi-process, display layers, dynamic shader cache and rework overlay (#4238) 2026-08-29 01:04:02 +02:00
reporter.h [prepo] Add support for missing PlayReport commands (#3674) 2026-03-06 15:02:59 +01:00