Commit Graph

784 Commits

Author SHA1 Message Date
176a363996 Bump version to 1.0.0-alpha.35 in libaaruformat.nuspec 2026-03-25 16:49:46 +00:00
42c4febd98 Increase maximum number of plaintext regions from 32 to 64 in ps3_encryption_map.h 2026-03-25 16:49:24 +00:00
d3aea257ed Bump version to 1.0.0-alpha.34 in libaaruformat.nuspec v1.0.0-alpha.34 2026-03-22 21:48:54 +00:00
0b6f10e526 Merge pull request #14 from FakeShemp/fakeshemp/wii-long
Add long sector for Wii/GC
2026-03-19 20:07:18 +00:00
45a494e1a2 Merge pull request #13 from RomTholos/perf/lru-integer-keys
lru: use native uint64 keys instead of string conversion
2026-03-19 20:02:24 +00:00
Kevin Bortis
8a8a89450d lru: use native uint64 keys instead of string conversion
Replace string-keyed uthash lookups with HASH_FIND/HASH_ADD on native
uint64_t keys. This eliminates per-lookup malloc/snprintf/strlen/free
overhead from the block cache hot path (2 lookups per sector read).

Before: malloc(17) + snprintf hex + HASH_FIND_STR + free per lookup
After:  HASH_FIND with 8-byte integer key, zero allocations

Also removes the unused string-key API (find_in_cache/add_to_cache)
and the uint64_to_string helper — all callers use uint64 keys.

Fix off-by-one in eviction: >= caused cache to hold max_items-1
entries instead of max_items. Changed to > so the configured
capacity is honored exactly.
2026-03-19 20:35:42 +01:00
6dbd5f1bb2 Merge pull request #12 from RomTholos/fix/cross-compilation-arm-riscv
Fix cross-compilation for ARM FPU variants and add RISC-V support
2026-03-19 11:58:49 +00:00
c9cf1a42c0 Merge pull request #11 from RomTholos/fix/mode2-errored-suffix-read
Fix Mode 2 errored sector suffix not restored on read
2026-03-19 11:57:44 +00:00
Kevin Bortis
bd01e7d8a5 Fix cross-compilation for ARM FPU variants and add RISC-V support 2026-03-19 12:34:00 +01:00
65b00baf1a Merge pull request #10 from RomTholos/fix/calling-convention-pointer-order
Fix calling convention placement for pointer-returning functions
2026-03-19 09:50:02 +00:00
336934e2d5 Merge pull request #9 from RomTholos/feat/zstd-compression
Add Zstandard compression support
2026-03-19 09:49:30 +00:00
Kevin Bortis
48093ba779 Fix Mode 2 errored sector suffix not restored on read
When reading back Mode 2 sectors with errored ECC/EDC (SectorStatusErrored),
the else branch copied 2328 bytes from bare_data. However, bare_data only
contains the user data portion (2048 bytes for Form 1, 2324 for Form 2).
The EDC/ECC suffix was stored separately in sector_suffix during write but
never read back, causing the suffix area to contain stale data from adjacent
sectors in the decompressed block.

Fix both DDT v2 and v1 code paths to check the subheader form bit and copy
user data + suffix from their respective storage locations.

Affects any Mode 2 disc image (Dreamcast, PS1, PS2 CD, Saturn, Mega CD,
PC Engine CD, Neo Geo CD) where sectors have incorrect or zeroed ECC/EDC.
2026-03-19 10:11:06 +01:00
Kevin Bortis
981b54562e Fix calling convention placement for pointer-returning functions 2026-03-19 08:53:35 +01:00
Kevin Bortis
6be36b6bda Add Zstandard compression support
Implements zstd as an alternative to LZMA for data block and
subchannel compression using the allocated compression IDs 4
(kCompressionZstd) and 5 (kCompressionZstdCst).

Adds zstd v1.5.7 as a bundled submodule with a static library
build including x86_64 assembly fast path for decompression.

Write path selects zstd or LZMA based on the zstd option.
Subchannel blocks use zstd+CST instead of LZMA+CST when enabled.
LZMA properties header is only written for LZMA-based compression
types, preventing format corruption in zstd-compressed images.

Activated via options string: "zstd=true;zstd_level=19".
Default remains LZMA for backwards compatibility.

Tested: SHA-256 verified lossless roundtrips across 9 disc systems
(Dreamcast, Saturn, Mega CD, PC Engine CD, Neo Geo CD, PS1, PS2 CD,
PS2 DVD) and PS1 SBI subchannel preservation with zstd+CST.
2026-03-19 08:45:07 +01:00
a1cf319999 Merge pull request #8 from RomTholos/feat/reserve-zstd-compression-id
Reserve compression ID 4 for Zstandard (zstd)
2026-03-18 21:21:29 +00:00
Kevin Bortis
95908b328a Reserve compression IDs 4 and 5 for Zstandard (zstd)
Adds kCompressionZstd = 4 and kCompressionZstdCst = 5 to the
CompressionType enum, following the existing LZMA/LzmaCst pattern.

Ref: https://github.com/aaru-dps/libaaruformat/issues/5
2026-03-18 22:20:26 +01:00
1987d5898d Merge pull request #7 from RomTholos/cmake/build-shared-static
Support static and shared library builds via BUILD_SHARED_LIBS
2026-03-18 21:20:03 +00:00
0b47ee5730 Merge pull request #6 from RomTholos/fix/mode2-form2-nocrc-edc
Fix uninitialized EDC bytes for Mode 2 Form 2 NoCrc sectors
2026-03-18 21:18:54 +00:00
Kevin Bortis
c5f79a350f Support static and shared library builds via BUILD_SHARED_LIBS
Replace hardcoded SHARED in add_library() with the standard CMake
BUILD_SHARED_LIBS variable. Default remains shared for backwards
compatibility.

  -DBUILD_SHARED_LIBS=OFF → static library (libaaruformat.a)
  -DBUILD_SHARED_LIBS=ON  → shared library (libaaruformat.so, default)

Also define _POSIX_C_SOURCE=200809L on non-Windows platforms so that
POSIX functions (strdup, fseeko, ftello) are properly declared when
building with CMAKE_C_EXTENSIONS=OFF (strict C99 mode).

Tested: shared + static with GCC, static with musl cross-compiler.
2026-03-18 21:48:27 +01:00
Rebecca Wallander
91f24ae789 Add long sector for Wii/GC 2026-03-18 21:39:55 +01:00
Kevin Bortis
cf4b09b8b0 Fix uninitialized EDC bytes for Mode 2 Form 2 NoCrc sectors
When reading back Mode 2 Form 2 sectors with SectorStatusMode2Form2NoCrc,
the 4-byte EDC field at bytes 2348-2351 was left untouched. Since the
caller's buffer may contain arbitrary data, this results in non-deterministic
output for those bytes.

The NoCrc status indicates the original disc had no CRC (zeroed EDC).
The fix adds the missing else branch to zero the EDC field, matching
the behavior that Mode2Form2Ok already has via aaruf_ecc_cd_reconstruct.

Both DDT v1 and v2 code paths are fixed.
2026-03-18 21:36:44 +01:00
d841cbbafe Bump version to 1.0.0-alpha.33 in libaaruformat.nuspec v1.0.0-alpha.33 2026-03-18 09:13:19 +00:00
a9be6b51bc Return correct error status and expected buffer length when buffer is null in generated sectors. 2026-03-18 09:13:01 +00:00
c989ba6131 Reorder includes in helpers.c: move wincrypt.h after windows.h for better organization v1.0.0-alpha.31 2026-03-17 01:26:13 +00:00
5a744cad80 Bump version to 1.0.0-alpha.31 in libaaruformat.nuspec 2026-03-16 23:07:35 +00:00
694601cc63 Enhance Wii junk data handling: reconstruct junk in user data area during read and write operations 2026-03-16 22:54:53 +00:00
1956900b80 Add disc information display for GameCube/Wii: include game ID, title, maker code, disc number, version, region, and size 2026-03-16 19:30:29 +00:00
a15cc47b84 Fix stream position calculation for junk region: adjust to use block start for seed alignment 2026-03-16 19:30:07 +00:00
41efd51f5d Enhance progress display for GameCube/Wii conversion: add speed and progress bar visualization 2026-03-16 19:10:31 +00:00
58a78c795c Refactor include paths for PS3 tools: update headers to use the ps3 directory 2026-03-16 19:07:19 +00:00
7b05275c47 Add tests for Nintendo GameCube/Wii LFG PRNG and junk map serialization 2026-03-16 19:05:09 +00:00
39dff09653 Add implementation for GameCube/Wii disc image conversion: complete convert-ngcw function and related utilities 2026-03-16 19:02:02 +00:00
347e689ebc Add support for converting Nintendo GameCube/Wii images: implement convert-ngcw command and usage 2026-03-16 18:54:23 +00:00
ebf3fd3e85 Add support for Nintendo GameCube/WiiU: include additional source files for encryption and junk handling 2026-03-16 18:50:10 +00:00
bd10c2ea29 Free resources for Nintendo GameCube/Wii junk map and Wii encryption contexts: implement cleanup in close function 2026-03-16 18:49:33 +00:00
96cace1860 Add support for regenerating junk sectors and Wii re-encryption: implement lazy initialization and encryption handling 2026-03-16 18:47:18 +00:00
05e451d68e Add support for generable sectors in write process: implement DDT entry handling without data storage 2026-03-16 18:42:25 +00:00
dd23682c16 Disable checksums for unencrypted and generable sectors in write process 2026-03-16 18:41:54 +00:00
a128473f41 Add Wii disc encryption support: implement partition key map and group encrypt/decrypt functions 2026-03-16 18:39:18 +00:00
d5d6e036e4 Add junk map serialization and deserialization for Nintendo GameCube/Wii: implement functions for entry management and lazy initialization 2026-03-16 18:39:08 +00:00
5b93c56e7b Add support for Nintendo Wii and GameCube junk map and encryption: implement lazy initialization for NgcwJunkEntry and WiiPartitionRegion 2026-03-16 18:34:24 +00:00
b50f2e56b6 Add new media tag mappings for Wii and GameCube: include WiiPartitionKeyMap and NgcwJunkMap for improved data handling 2026-03-16 18:32:45 +00:00
53bbb3c7a6 Add new data types for Nintendo Wii and GameCube: introduce WiiPartitionKeyMap and NgcwJunkMap for enhanced region mapping 2026-03-16 18:31:27 +00:00
2ebe8127bd Add Lagged Fibonacci Generator for Nintendo GameCube/Wii: implement LFG context and functions for junk data generation 2026-03-16 18:28:22 +00:00
7ee97105b5 Add new sector status: introduce SectorStatusGenerable to indicate content that can be generated using a known algorithm 2026-03-16 17:28:54 +00:00
98ec0c4add Refactor file structure: rename and reorganize PS3 and Wii U source files for better clarity and maintainability 2026-03-16 17:21:58 +00:00
317ca23a3e Refactor file structure: rename and reorganize PS3 and Wii U source files for better clarity and maintainability 2026-03-16 17:21:48 +00:00
913d0508a2 Add recursion guard for Wii U re-encryption: implement flag to prevent recursive calls during sector processing 2026-03-16 13:28:16 +00:00
70b51ec38e Add Wii U conversion support: implement command and usage for converting WUD/WUX to AaruFormat 2026-03-16 12:01:38 +00:00
03a5a06888 Add WIIU disc image converter: implement conversion logic for WUD/WUX to AaruFormat 2026-03-16 11:55:07 +00:00