eden/src
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
..
android [buffer_cache] Simplify GPU fence synchronization and remove GPU buffer readback (#4477) 2026-09-26 05:01:27 +02:00
audio_core Revert "[audio] Replace libopus with FFmpeg (#4169)" (#4419) 2026-09-14 14:34:24 +02:00
common [loader] add ZBIC (zstd variant) NSO decompression support for Switch 22.0+ (#4482) 2026-09-27 12:48:45 +02:00
core [loader] add ZBIC (zstd variant) NSO decompression support for Switch 22.0+ (#4482) 2026-09-27 12:48:45 +02:00
dedicated_room [common] remove DetachedTasks object usage (#4096) 2026-07-09 03:46:06 +02:00
dynarmic [dynarmic] fix bad arm codegen on relocations (#4458) 2026-09-20 00:29:28 +02:00
frontend_common [settings] move program_args and debug_knobs back to debugging category and make them pergameable (#4378) 2026-09-08 20:05:56 +02:00
hid_core [hid_core] Code cleanup (#4461) 2026-09-26 02:21:45 +02:00
input_common [input] Fix mouse drift on Qt/SDL frontends (#4352) 2026-09-14 03:26:22 +02:00
network [cmake] Simplify DetectPlatform and normalize platform names (#4183) 2026-08-10 04:57:38 +02:00
qt_common [buffer_cache] Simplify GPU fence synchronization and remove GPU buffer readback (#4477) 2026-09-26 05:01:27 +02:00
shader_recompiler [glsl] fix clang 23 build error for unused function `SetDefinition` (#4389) 2026-09-23 14:51:18 +02:00
tests [common] Switch to boost::unordered_flat containers (#4326) 2026-08-31 02:58:09 +02:00
video_core [buffer_cache] Simplify GPU fence synchronization and remove GPU buffer readback (#4477) 2026-09-26 05:01:27 +02:00
web_service [common] remove DetachedTasks object usage (#4096) 2026-07-09 03:46:06 +02:00
yuzu [frontend] Unify cmdline parsing (#4424) 2026-09-23 14:51:51 +02:00
yuzu_cmd [frontend] Unify cmdline parsing (#4424) 2026-09-23 14:51:51 +02:00
yuzu_room_standalone [cmake] add a `YUZU_STATIC_ROOM` option (#3411) 2026-01-28 23:54:49 +01:00
.clang-format chore: make yuzu REUSE compliant 2022-07-27 12:53:49 +02:00
CMakeLists.txt [cmake] Simplify DetectPlatform and normalize platform names (#4183) 2026-08-10 04:57:38 +02:00
dep_hashes.h.in [cmake, frontend] feat: CPMUtil + dependency viewer (#238) 2025-08-11 22:27:29 +02:00