eden/externals
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
..
FidelityFX-FSR Update FSR to 1.0.2 2022-01-23 14:38:48 -06:00
bc_decoder video_core: Add BCn decoding support 2023-06-27 18:00:09 -07:00
cmake-modules [cmake] Simplify DetectPlatform and normalize platform names (#4183) 2026-08-10 04:57:38 +02:00
demangle [*] Re-fix clang-cl building (#3940) 2026-05-09 16:26:17 +02:00
ffmpeg [externals] Update CI packages to new format (#4341) 2026-09-01 06:40:52 +02:00
getopt chore: make yuzu REUSE compliant 2022-07-27 12:53:49 +02:00
glad cmake: apply defaults to all externals 2023-05-24 04:57:04 +02:00
libusb [cmake] Simplify DetectPlatform and normalize platform names (#4183) 2026-08-10 04:57:38 +02:00
nx_tzdb [tools] refactor, use #!/bin/sh, update license files (#3998) 2026-05-22 21:15:31 +02:00
renderdoc [externals] update renderdoc to 1.7.0 (#3751) 2026-03-22 04:00:57 +01:00
stb [meta] Discourage profanity usage (#4239) 2026-08-09 02:53:16 +02:00
tz/tz [ci] Fix macOS "no type named 'free' in namespace 'std' (#4347) 2026-09-04 13:32:36 +02:00
CMakeLists.txt [loader] add ZBIC (zstd variant) NSO decompression support for Switch 22.0+ (#4482) 2026-09-27 12:48:45 +02:00