diff --git a/README.md b/README.md index 0d1ad03..4310382 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ Measured on a real device (iPhone 17 Pro Max): The install package is only a little over 100 MB. The game resources (about 5.6 GB) are placed on the phone separately, and updating the app touches neither your saves nor the resources. -Why it is this fast: the program executes natively, and not a single instruction goes through emulation; graphics go straight to Metal; every shader is translated offline and compiled ahead of time, so nothing is compiled when you enter a new scene. Older chips such as the A16 do not support the game's original compressed texture format, so we built a supplementary texture pack for them, and they run at full frame rate too. +Why it is this fast: the program executes natively, and not a single instruction goes through emulation; graphics go straight to Metal; every shader is translated offline and compiled ahead of time, so nothing is compiled when you enter a new scene. Older chips (A16 and earlier, such as the iPhone 14 family and iPhone 15) do not support the game's original compressed texture format; they need an extra texture pack made from your own game files, and then run at full frame rate too — see [docs/LEGACY_DEVICES.md](docs/LEGACY_DEVICES.md). ## Redesigned for fingers @@ -254,6 +254,7 @@ Download our prebuilt "shell" package (`D2RMobile-shell.ipa`), which contains no | `.nsp` / `.xci` game packages | The tools only check the version of the main program and do not distinguish package formats; we ran the whole path with an `.xci` ourselves, and users have reported that `.nsp` packages work perfectly as well | | Signing and installing with a sideloading tool (Sideloadly, AltStore and the like) | Not verified; open an issue and tell us how it went | | Making the package on Linux | Not verified (verified on Windows and Mac) | +| A16 and earlier devices (iPhone 14 family, iPhone 15 / 15 Plus and so on) | Playable; they need a Legacy Device Pack and an App built with it: [docs/LEGACY_DEVICES.md](docs/LEGACY_DEVICES.md). "Device Not Supported" in the App means this step is missing | | The "one-line verdict" and "legacy Chinese name" entries in item notes | These two content tables are not shipped with the repository; you can supply your own, see `dm/ios/tools/annot/README.md` | ## Contributing and feedback @@ -276,6 +277,7 @@ Download our prebuilt "shell" package (`D2RMobile-shell.ipa`), which contains no | [docs/DEPENDENCIES.md](docs/DEPENDENCIES.md) | Dependencies and third-party licenses | | [docs/NO_XCODE.md](docs/NO_XCODE.md) | Building without Xcode and without a Mac | | [docs/MAC.md](docs/MAC.md) | Playing on a Mac: building the macOS App, key mapping, known gaps | +| [docs/LEGACY_DEVICES.md](docs/LEGACY_DEVICES.md) | Older devices (A16 and earlier): making the texture pack and putting it on the phone | | [docs/DERIVED.md](docs/DERIVED.md) | Game-related material in this repository: what is here, what is not, and why | ## Legal diff --git a/README.zh-CN.md b/README.zh-CN.md index 0ef3122..0a06f17 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -73,7 +73,7 @@ iPhone 与 iPad 共用一个安装包。 安装包只有一百多 MB;游戏资源(约 5.6 GB)单独放进手机,升级 App 时存档和资源都不动。 -之所以能这么快:程序是原生执行的,没有一条指令经过模拟;图形直接走 Metal;着色器全部离线翻译、预先编好,进新场景不用现编。旧机型(如 A16)不支持游戏原本的贴图压缩格式,我们为它们另做了一份补充贴图包,同样满帧。 +之所以能这么快:程序是原生执行的,没有一条指令经过模拟;图形直接走 Metal;着色器全部离线翻译、预先编好,进新场景不用现编。旧机型(A16 及更早,如 iPhone 14 系列、iPhone 15)不支持游戏原本的贴图压缩格式,要用你自己的游戏文件另做一份贴图包,同样满帧——做法见 [docs/LEGACY_DEVICES.zh-CN.md](docs/LEGACY_DEVICES.zh-CN.md)。 ## 为手指重新设计 @@ -254,6 +254,7 @@ dm/tools/mac_app.sh # 产出 ~/dm-work/out/macapp/D2R Mobile.app | `.nsp` / `.xci` 两种游戏包 | 工具只核对主程序的版本,不区分包的格式;我们自己用 `.xci` 走过全程,有网友反馈 `.nsp` 格式的游戏包也完美兼容 | | 用自签工具(Sideloadly、AltStore 等)签名装机 | 没验过,欢迎开 Issue 告诉我们结果 | | Linux 上做包 | 没验过(Windows 与 Mac 上验过) | +| A16 及更早的机型(iPhone 14 系列、iPhone 15 / 15 Plus 等) | 可以玩,要多做一份老机型贴图包并带着它构建 App:[docs/LEGACY_DEVICES.zh-CN.md](docs/LEGACY_DEVICES.zh-CN.md)。App 提示「暂不支持本机型」就是缺这一步 | | 物品注释里的「一句点评」与「旧译名对照」 | 两张内容表不随仓库提供,可自备,见 `dm/ios/tools/annot/README.zh-CN.md` | ## 参与与反馈 @@ -276,6 +277,7 @@ dm/tools/mac_app.sh # 产出 ~/dm-work/out/macapp/D2R Mobile.app | [docs/DEPENDENCIES.zh-CN.md](docs/DEPENDENCIES.zh-CN.md) | 依赖清单与第三方许可证 | | [docs/NO_XCODE.zh-CN.md](docs/NO_XCODE.zh-CN.md) | 不用 Xcode、不用 Mac 的做法 | | [docs/MAC.zh-CN.md](docs/MAC.zh-CN.md) | 在 Mac 上玩:构建 macOS App、键位、已知不足 | +| [docs/LEGACY_DEVICES.zh-CN.md](docs/LEGACY_DEVICES.zh-CN.md) | 老机型(A16 及更早):怎么做贴图包、怎么放进手机 | | [docs/DERIVED.zh-CN.md](docs/DERIVED.zh-CN.md) | 仓库里与游戏有关的东西:有什么、没有什么、为什么 | ## 声明 diff --git a/dm/tools/astc_pack.py b/dm/tools/astc_pack.py index ec5acb9..6548ccb 100644 --- a/dm/tools/astc_pack.py +++ b/dm/tools/astc_pack.py @@ -127,7 +127,7 @@ def finalize(packdir): for b in iter(lambda: f.read(64 << 20), b''): h.update(b) info = {'name': name, 'size': os.path.getsize(src), 'sha256': h.hexdigest()} json.dump(info, open(os.path.join(packdir, 'pack.json'), 'w'), ensure_ascii=False, indent=1) - root = os.path.join(packdir, '老机型补充包'); os.makedirs(os.path.join(root, 'data'), exist_ok=True) + root = os.path.join(packdir, 'Legacy Device Pack'); os.makedirs(os.path.join(root, 'data'), exist_ok=True) dst = os.path.join(root, 'data', name) if os.path.exists(dst): os.remove(dst) os.link(src, dst) diff --git a/docs/DEPENDENCIES.md b/docs/DEPENDENCIES.md index ebddd09..625073b 100644 --- a/docs/DEPENDENCIES.md +++ b/docs/DEPENDENCIES.md @@ -39,7 +39,7 @@ All at once: `python3 -m pip install pillow numpy lz4 capstone unicorn` (`./setu | Tool | Used for | Official site | |---|---|---| -| astcenc | Converting textures for older devices without BC texture support | | +| astcenc | Converting textures for older devices without BC texture support (A16 and earlier); built from source — how to build it and the whole procedure are in [LEGACY_DEVICES.md](LEGACY_DEVICES.md). We use v5.2.0 | | | hactool | Needed by `dm/tools/extract_game.sh` to extract files from your game package; not needed if your game files are already prepared some other way. We tested with upstream commit `1d64a83` | | ## Extra tools for on-device and verification scripts diff --git a/docs/DEPENDENCIES.zh-CN.md b/docs/DEPENDENCIES.zh-CN.md index 2433f43..01600cf 100644 --- a/docs/DEPENDENCIES.zh-CN.md +++ b/docs/DEPENDENCIES.zh-CN.md @@ -39,7 +39,7 @@ English: [DEPENDENCIES.md](DEPENDENCIES.md) | 工具 | 用来做什么 | 官方地址 | |---|---|---| -| astcenc | 给不支持 BC 贴图格式的旧机型转换贴图 | | +| astcenc | 给不支持 BC 贴图格式的旧机型(A16 及更早)转换贴图;从源码编,编法与整条做法见 [LEGACY_DEVICES.zh-CN.md](LEGACY_DEVICES.zh-CN.md)。我们用的是 v5.2.0 | | | hactool | 用 `dm/tools/extract_game.sh` 从你的游戏包取文件时要用;游戏文件已经用别的办法备好时不用装。我们实测用的是上游提交 `1d64a83` | | ## 真机与验证脚本额外需要 diff --git a/docs/LEGACY_DEVICES.md b/docs/LEGACY_DEVICES.md new file mode 100644 index 0000000..2a234d3 --- /dev/null +++ b/docs/LEGACY_DEVICES.md @@ -0,0 +1,75 @@ +# Older devices (A16 and earlier chips): making the texture pack + +中文:[LEGACY_DEVICES.zh-CN.md](LEGACY_DEVICES.zh-CN.md) + +The iPhone 14 family, iPhone 15 / 15 Plus and earlier models can play; they just need one more step: a **Legacy Device Pack** made from your own game files and placed on the phone. This page covers it from start to finish. + +## Why the extra step + +Almost all of the game's textures use BC compression. Apple GPUs support that format only from the A17 Pro (iPhone 15 Pro) on; earlier chips cannot read it. The answer is to convert those textures offline, on a computer, into ASTC, which these devices do support — the picture is the same picture. Textures are game content, so we cannot provide this pack; it can only be generated on your own computer from your own game files. + +**Which devices need it**: the App decides this itself at launch, so there is no table to consult. A device that needs it shows "Supplementary Pack Required"; if it shows "Device Not Supported" instead, the App was built without the part that goes with the pack — rebuild it as in step 4 below. + +## What you need + +- The "with a Mac" route (see "Getting started" on the front page), with `./setup.sh` finished. +- The **astcenc** encoder (Arm's open-source texture encoder, Apache 2.0). Build it from source, which takes a minute or two: + + ```bash + brew install cmake + git clone https://github.com/ARM-software/astc-encoder + cmake -S astc-encoder -B astc-encoder/b -DASTCENC_ISA_NEON=ON -DCMAKE_BUILD_TYPE=Release + cmake --build astc-encoder/b -j + export ASTCENC=$PWD/astc-encoder/b/Source/astcenc-neon + ``` + + We use v5.2.0. +- Disk: about 3 GB (1.6 GB of intermediate files, 1.0 GB for the pack). + +## Steps + +Run these from the repository root, inside the Python environment that setup prepared. `D` is an output directory of your choice and `R` is the game resource directory: + +```bash +source ~/dm-work/build/cache/dm/venv/bin/activate +R=~/dm-work/data/switch/3.3.94012/Update/RomFS +D=~/dm-work/out/legacy_pack + +python3 dm/tools/astc_pack.py "$R" "$D/work" --preset thorough # 1 transcode, about 8 minutes (all cores of a Mac) +python3 dm/tools/casc_overlay.py pack "$R" "$D/pack" "$D/work/repl.tsv" 0-8 # 2 write the data archive, about half a minute +python3 dm/tools/astc_pack.py finalize "$D/pack" # 3 finalize: sizes and checksum +``` + +Afterwards `$D/pack` contains: + +- `Legacy Device Pack/`: **the folder for the phone** (holding `manifest.json` and `data/00-00000008.data`, about 1.0 GB). +- `pack.json`: the size and SHA-256 of this pack; the next step builds it into the App so the phone can verify the pack. + +4. **Build the App with it**: + + ```bash + cd dm/ios && DM_ASTC_PACK="$D/pack" ./run.sh build + ``` + + An App built without this variable only says "Device Not Supported" on older devices. + +5. **Install** as usual (`./run.sh install` or Xcode). + +6. **Put the pack on the phone**: in the Files app open "On My iPhone → D2R Mobile" and copy the **whole** `Legacy Device Pack` folder into it, at the same level as the game resource folder. Finder works too (connect the phone → Files → D2R Mobile). Then open the game. + +## Things to know + +- **The pack and the App are a matched pair.** The App checks the pack on the phone against the SHA-256 in `pack.json`; if you regenerate the pack, rebuild the App with the new `$D/pack`. The same game files, the same astcenc version and the same preset (`--preset thorough`) produce a byte-identical pack, so normally there is nothing to redo. +- If the folder was not copied completely, is in the wrong place, or does not match the App, the App says which it is in the dialog. +- The game resource folder is still needed as usual (see [GAME_FILES.md](GAME_FILES.md)); the pack is an additional folder, not a replacement. +- This route currently needs a Mac and Xcode. The no-Xcode shell does not carry the older-device part in this version yet. + +## What it does (if you are curious) + +- It converts the BC3 textures, about 27,000 of them and the great majority of all textures; each is converted block by block to ASTC 4×4 with the file size unchanged. The game itself understands ASTC, so only the format changes and nothing about how the game reads textures. +- The few other BC formats, small in volume, are not converted here; the program decodes them at run time on these devices. +- Every texture is compared with the original for fidelity during conversion, with the results in `$D/work/quality.tsv`; the median for colour and material textures is about 60 dB, with no visible difference. + +## In practice + +The lowest device we measured is the iPhone 14 Pro Max (A16, 6 GB of RAM), running at 60 fps. During internal testing this route was completed by users on A16 devices. diff --git a/docs/LEGACY_DEVICES.zh-CN.md b/docs/LEGACY_DEVICES.zh-CN.md new file mode 100644 index 0000000..6756cfd --- /dev/null +++ b/docs/LEGACY_DEVICES.zh-CN.md @@ -0,0 +1,75 @@ +# 老机型(A16 及更早的芯片):贴图包怎么做 + +English: [LEGACY_DEVICES.md](LEGACY_DEVICES.md) + +iPhone 14 系列、iPhone 15 / 15 Plus 以及更早的机型可以玩,只是多一步:要用你自己的游戏文件做一份**老机型贴图包**,放进手机。这一页从头讲到尾。 + +## 为什么要多这一步 + +游戏的贴图绝大多数用的是 BC 压缩格式。苹果的显卡从 A17 Pro(iPhone 15 Pro)起才支持这种格式,更早的芯片不认。做法是在电脑上把这些贴图离线转成这些机型支持的 ASTC 格式,画面是同一份画面。贴图是游戏内容,所以这个包不能由我们提供,只能用你自己的游戏文件在你自己的电脑上生成。 + +**哪些机型需要**:App 启动时自己会判断,不用查表。需要的机型会弹「需要老机型补充包」(补充包就是这里说的贴图包);如果弹的是「暂不支持本机型」,说明这个 App 构建时没有带上贴图包的配套部分——照下面第 4 步重新构建即可。 + +## 需要什么 + +- 走「有 Mac」那条路(见首页「开始使用」):`./setup.sh` 已经跑完。 +- 编码器 **astcenc**(ARM 的开源贴图编码器,Apache 2.0 许可)。从源码编一份,约一两分钟: + + ```bash + brew install cmake + git clone https://github.com/ARM-software/astc-encoder + cmake -S astc-encoder -B astc-encoder/b -DASTCENC_ISA_NEON=ON -DCMAKE_BUILD_TYPE=Release + cmake --build astc-encoder/b -j + export ASTCENC=$PWD/astc-encoder/b/Source/astcenc-neon + ``` + + 我们用的是 v5.2.0。 +- 磁盘:约 3 GB(转码的中间文件 1.6 GB,贴图包 1.0 GB)。 + +## 步骤 + +在仓库根目录执行,先进入 setup 准备好的 Python 环境。`D` 是你选的输出目录,`R` 是游戏资源目录: + +```bash +source ~/dm-work/build/cache/dm/venv/bin/activate +R=~/dm-work/data/switch/3.3.94012/Update/RomFS +D=~/dm-work/out/legacy_pack + +python3 dm/tools/astc_pack.py "$R" "$D/work" --preset thorough # 1 转码,约 8 分钟(Mac 全核) +python3 dm/tools/casc_overlay.py pack "$R" "$D/pack" "$D/work/repl.tsv" 0-8 # 2 写成数据档,约半分钟 +python3 dm/tools/astc_pack.py finalize "$D/pack" # 3 收尾:算大小与校验值 +``` + +做完后 `$D/pack` 里有: + +- `Legacy Device Pack/`:**给手机用的文件夹**(里面是 `manifest.json` 和 `data/00-00000008.data`,约 1.0 GB)。 +- `pack.json`:这份贴图包的大小与 SHA-256,下一步构建 App 时会带进去,用来在手机上核对。 + +4. **带着它构建 App**: + + ```bash + cd dm/ios && DM_ASTC_PACK="$D/pack" ./run.sh build + ``` + + 不带这个变量构建出来的 App,在老机型上只会提示「暂不支持本机型」。 + +5. **装机**,和平常一样(`./run.sh install` 或用 Xcode)。 + +6. **把贴图包放进手机**:在「文件」App 里打开「我的 iPhone → D2R Mobile」,把 `Legacy Device Pack` 这个文件夹**整个**拷进去,和游戏资源文件夹放在同一层。用 Finder 也可以(连上手机 → 文件 → D2R Mobile)。然后打开游戏。 + +## 要注意的 + +- **贴图包和 App 是配对的**。App 按 `pack.json` 里的 SHA-256 核对手机上的贴图包;重新生成过贴图包,就要用新的 `$D/pack` 重新构建 App。同一份游戏文件、同一版 astcenc、同一档(`--preset thorough`)生成的包是逐字节相同的,所以平时不需要重做。 +- 文件夹没拷完、拷错了位置、或者和 App 不配套,App 会在弹框里直接说是哪一种。 +- 游戏资源文件夹照常要放(见 [GAME_FILES.zh-CN.md](GAME_FILES.zh-CN.md));贴图包是另外加的一个文件夹,不是替换。 +- 这条路目前要用 Mac 和 Xcode 构建。「不用 Xcode」的壳这一版还不带老机型的配套部分。 + +## 它做了什么(想了解的话) + +- 转的是 BC3 格式的贴图,约 2.7 万张,占全部贴图的绝大多数;每张逐块转成 ASTC 4×4,文件大小不变。游戏本身认得 ASTC,所以只是换了格式,没有改游戏的读取方式。 +- 其余几种量很小的 BC 格式不在这里转,由程序在这些机型上运行时解开。 +- 转码时每张贴图都和原图比过清晰度,结果写在 `$D/work/quality.tsv`;颜色和材质贴图的中位数约 60 dB,肉眼看不出差别。 + +## 实际情况 + +最低实测机型是 iPhone 14 Pro Max(A16,6 GB 内存),60 帧运行。这条路在内测阶段由 A16 机型的用户走通过。