Android port (Adreno): Vulkan backend, GameActivity app, touch HUD, lifecycle, minimap quest goals

- host/android: Vulkan replay backend (nvn_vk.c) with pipeline/descriptor caching, ADPF,
  AChoreographer present link; Linux compat layer; Makefile.android (headless dmhost + APK lib)
- android/app: GameActivity shell without Gradle (build_apk.sh), AAudio output, touch HUD port
  (touch_app.c + TouchOverlay.java, three layers: body / joystick / minimap goals),
  lifecycle save-on-background like iOS, art_from_ipa.py for touch / HUD / mapgoal art
- touch: shared touch controls moved from ios/Sources to dm/touch
- patch_nso.py Android ruleset, dmsh_vk.py shader pack, DM_TOUCH_PRODUCT defaults
- hle_audio: AAudio resume waits through STARTING and reopens once on failure
- .gitignore: local resources/ (original game data) never committed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-10-14 14:55:05 +09:00
co-authored by Claude Opus 5.5
parent 5bc5a01087
commit 4d91f80bae
106 changed files with 7009 additions and 181 deletions
+1 -1
View File
@@ -8,7 +8,7 @@
set -uo pipefail
I="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"; W="$(cd "$I/../.." && pwd)"
BAD=$(git -C "$W" ls-files -- dm/ios/NativeHUD/v4 dm/ios/NativeHUD/mapgoal dm/ios/NativeHUD/widestash dm/ios/NativeHUD/pouch dm/ios/NativeHUD/touch/fe_rightpanel.* \
'dm/ios/Sources/TouchArt/dm_native_*' dm/ios/Sources/dm_touch_native_art.c dm/host/dm_vault_tab.h dm/host/dm_hud_exp.h dm/host/dm_bright_levels.inc dm/ios/tools/touchrectv1_HUDPanelHD.json dm/ios/tools/native_art/skills.txt dm/ios/tools/native_art/skilldesc.txt)
'dm/ios/Sources/TouchArt/dm_native_*' dm/touch/dm_touch_native_art.c dm/host/dm_vault_tab.h dm/host/dm_hud_exp.h dm/host/dm_bright_levels.inc dm/ios/tools/touchrectv1_HUDPanelHD.json dm/ios/tools/native_art/skills.txt dm/ios/tools/native_art/skilldesc.txt)
[ -z "$BAD" ] || { echo "HUDGEN 红:原版衍生的生成物进了仓库(应该构建时从游戏文件生成):"; echo "$BAD" | sed 's/^/ /'; exit 1; }
R=${DM_ROMFS_SRC:-${DM_ROOT:-$HOME/dm-work}/data/switch/3.3.94012/Update/RomFS}
[ -f "$R/data/build_manifest.psv" ] || { echo "HUDGEN OK(入库检查);生成检查跳过:这台机器没有游戏文件 $R"; exit 0; }
+3 -3
View File
@@ -3,7 +3,7 @@
输入:Switch 版 3.3.94012 的 Update/RomFS(参数或环境变量 DM_ROMFS_SRC);可选 PC 版 D2R 的解包目录(DM_PC_DATA,底栏出原版 2 倍图用,没有就用 Switch 素材放大)。
产物(不进 git):
Gen/assets/NativeHUD/{widestash, pouch, touch, mapgoal, v4} 加宽储藏箱 / 编年史盖板 / 百宝囊框 / 选角右侧面板 / 小地图终点 / 底部 UI v4
Sources/TouchArt/dm_native_*.png、Sources/dm_touch_native_art.c 原版技能图集与技能索引(生成在原位置,dm/ios/.gitignore 忽略)
Sources/TouchArt/dm_native_*.png、../touch/dm_touch_native_art.c 原版技能图集与技能索引(生成在原位置,dm/ios/.gitignore 忽略)
宿主的三张表(dm_vault_tab.h、dm_hud_exp.h、dm_bright_levels.inc)由 dm/host/Makefile 生成。
用法:gen_assets.py [<原版 RomFS(Update)>]
输入没变就不重出(指纹 = 游戏文件清单 + dm/ios/tools 下全部文件 + PC 素材开关;写在产物根目录 .stamp);同一棵树里同时只许一个进程在生成(锁目录 .gen_lock)——
@@ -12,7 +12,7 @@ Generate the assets derived from the original game that the App uses, from the p
Input: Update/RomFS of Switch version 3.3.94012 (argument or environment variable DM_ROMFS_SRC); optionally the unpacked directory of PC D2R (DM_PC_DATA, used to produce the original game's 2x art for the bottom bar; without it, Switch art is upscaled).
Build output (not in git):
Gen/assets/NativeHUD/{widestash, pouch, touch, mapgoal, v4} widened stash / chronicle cover plate / pouch frame / character select right panel / minimap goal / bottom UI v4
Sources/TouchArt/dm_native_*.png, Sources/dm_touch_native_art.c the original game's skill atlas and skill index (generated in place, ignored by dm/ios/.gitignore)
Sources/TouchArt/dm_native_*.png, ../touch/dm_touch_native_art.c the original game's skill atlas and skill index (generated in place, ignored by dm/ios/.gitignore)
The host's three tables (dm_vault_tab.h, dm_hud_exp.h, dm_bright_levels.inc) are generated by dm/host/Makefile.
Usage: gen_assets.py [<original game RomFS (Update)>]
Nothing is regenerated when the input is unchanged (fingerprint = game file list + all files under dm/ios/tools + the PC art switch; written to .stamp in the build output root); only one process may generate at a time in the same tree (lock directory .gen_lock) --
@@ -39,7 +39,7 @@ def stamp(R):
def ensure(R):
"""产物齐、指纹没变就直接返回;否则拿锁生成。返回 True = 这次重出了。 | If the build output is complete and the fingerprint unchanged, return directly; otherwise take the lock and generate. Returns True = regenerated this time."""
root = gen_paths.gen_dir(); st = os.path.join(root, '.stamp'); lock = os.path.join(root, '.gen_lock')
outs = [os.path.join(root, 'NativeHUD', 'v4', 'base.png'), os.path.join(HERE, '..', 'Sources', 'TouchArt', 'dm_native_skill_0.png'), os.path.join(HERE, '..', 'Sources', 'dm_touch_native_art.c')]
outs = [os.path.join(root, 'NativeHUD', 'v4', 'base.png'), os.path.join(HERE, '..', 'Sources', 'TouchArt', 'dm_native_skill_0.png'), os.path.join(HERE, '..', '..', 'touch', 'dm_touch_native_art.c')]
want = stamp(R); fresh = lambda: all(map(os.path.isfile, outs)) and os.path.isfile(st) and open(st).read() == want
if fresh(): return False
t0 = time.time()
+1 -1
View File
@@ -33,7 +33,7 @@ for s in srcs:
if d not in dirs: dirs.append(d)
b = os.path.basename(s)
if os.path.splitext(b)[0].endswith('_mac'): continue # Mac 专用源按 _mac 命名约定不进 iOS(front_mac.m 由 front_ios.m 实现 front.h;touch_mac.c 是 Mac 触点脚本) | Mac-only sources are kept out of iOS by the _mac naming convention (for front_mac.m, front_ios.m implements front.h; touch_mac.c is the Mac touch point script)
if os.path.dirname(s) == os.path.normpath(os.path.join(host, '../ios/Sources')): continue # 宿主借用的 iOS 源(如触屏模块)iOS 工程本身已编,再收一份会重复链接 | iOS sources borrowed by the host (e.g. the touch module) are already compiled by the iOS project itself; collecting another copy would link them twice
if os.path.dirname(s) == os.path.normpath(os.path.join(host, '../touch')): continue # 跨平台触控模块(dm/touch)iOS 工程按目录整体编,再收一份会重复链接 | The cross-platform touch module (dm/touch) is compiled as a whole directory by the iOS project; collecting another copy would link it twice
if s == os.path.join(host, 'main.c'): os.symlink(s, f'{gen}/main/main.c'); continue
flat = os.path.relpath(s, os.path.dirname(host)).replace('/', '__') # 不同目录同名文件不冲突 | Same-named files in different directories do not collide
os.symlink(s, f'{gen}/src/{flat}')
+1
View File
@@ -20,6 +20,7 @@ asm = ['// 由 dm/ios/tools/gen_embed.py 生成,勿手改']
flags = []
for n in names:
hdr = dict(l[2:].split() for l in open(f'{out}/{n}.fixups.tsv'))
assert hdr.get('ABI', 'apple') == 'apple', f'{n}: 非苹果 ABI 产物({hdr["ABI"]}),不能打进苹果包 | non-Apple ABI build output, cannot go into an Apple package'
te, po = int(hdr['TEXT_END'], 16), int(hdr['PATCH_OFF'], 16)
ko, ks = int(hdr['KEY_PAGE_OFF'], 16), int(hdr['KEY_PAGE_SIZE'], 16)
bin_ = os.path.abspath(f'{out}/{n}.patched.bin'); sz = os.path.getsize(bin_)
+4 -4
View File
@@ -2,12 +2,12 @@
"""原版技能图集 / HUD 小图 → TouchArt PNG,原版 Skills / Skilldesc → 纯 C 索引 dm_touch_native_art.c。构建时从玩家自己的游戏文件生成,不进仓库。
来源与指纹冻结在仓库里的 Sources/TouchArt/native_art_manifest.json(只有原版路径与哈希):读包后先核原件 SHA-256 / MD5 与两张表的 SHA-256,
解码后核 PNG 的 SHA-256(解码只解块、不重绘像素);对不上就报错(游戏版本不对)。
用法:generate.py <原版 RomFS(Update)> 产物生成在原位置、git 忽略(dm/ios/.gitignore):Sources/TouchArt/dm_native_*.png、Sources/dm_touch_native_art.c
用法:generate.py <原版 RomFS(Update)> 产物生成在原位置、git 忽略(dm/ios/.gitignore):Sources/TouchArt/dm_native_*.png、../touch/dm_touch_native_art.c
(.c 里按 Sources/ 写了相对 include,PNG 由 DmTouchOverlay.m / 工程 / 测试按 Sources/TouchArt 引用,所以不挪目录)
Original game skill atlas / HUD small images → TouchArt PNG, original game Skills / Skilldesc → pure C index dm_touch_native_art.c. Generated at build time from the player's own game files, not kept in the repository.
Sources and fingerprints are frozen in Sources/TouchArt/native_art_manifest.json in the repository (only original game paths and hashes): after reading the package, first verify the SHA-256 / MD5 of the original files and the SHA-256 of the two tables,
after decoding verify the SHA-256 of the PNGs (decoding only decodes blocks, it does not redraw pixels); on a mismatch report an error (wrong game version).
Usage: generate.py <original game RomFS (Update)> The build output is generated in place and git-ignored (dm/ios/.gitignore): Sources/TouchArt/dm_native_*.png, Sources/dm_touch_native_art.c
Usage: generate.py <original game RomFS (Update)> The build output is generated in place and git-ignored (dm/ios/.gitignore): Sources/TouchArt/dm_native_*.png, ../touch/dm_touch_native_art.c
(the .c has a relative include written against Sources/, and the PNGs are referenced by DmTouchOverlay.m / the project / the tests via Sources/TouchArt, so the directory is not moved)"""
import csv, hashlib, io, json, sys
from pathlib import Path
@@ -52,14 +52,14 @@ def main(romfs):
assert len({r[0] for r in rows}) == len(rows)
if sha(canonical(rows)) != man['descriptor_index_sha256']: raise SystemExit('native_art:技能索引和冻结的不一致')
gpath = IOS / 'docs/native_art_v1_geometry.json'; binding = IOS / 'docs/touch_layout_spec_native_binding_v5.json'
out = ['/* Generated from frozen official Skills/Skilldesc; do not hand-edit rows. */', '#include "dm_touch_native_art.h"', '#include "../../host/dm_input.h"', '#include <stddef.h>',
out = ['/* Generated from frozen official Skills/Skilldesc; do not hand-edit rows. */', '#include "dm_touch_native_art.h"', '#include "../host/dm_input.h"', '#include <stddef.h>',
'const dm_ta_atlas dm_ta_atlases[DM_TA_ATLASES]={']
for a in atl: out.append(' {"%s",%d,%d,%d,%d,%d},' % (a['asset'][:-4], *a['atlas_px'], a['frame_width'], a['frame_pitch'], a['frame_count']))
out += ['};', f'const char dm_ta_manifest_sha[]="{sha(mpath.read_bytes())}";', f'const char dm_ta_geometry_sha[]="{sha(gpath.read_bytes())}";',
f'const char dm_ta_binding_sha[]="{sha(binding.read_bytes())}";', 'static const struct { uint32_t id; int atlas,frame; } rows[]={']
out += [' {%d,%d,%d},' % tuple(row) for row in rows]; out += ['};']
out += [(HERE / 'implementation.c.inc').read_text()]
(IOS / 'Sources/dm_touch_native_art.c').write_text('\n'.join(out) + '\n')
(IOS.parent / 'touch' / 'dm_touch_native_art.c').write_text('\n'.join(out) + '\n')
print(f'native_art:{len(rows)} 条技能索引、{len(atlases)} 张 PNG(原件 SHA256 + MD5、PNG SHA256 都核过)→ {art}')
+21 -7
View File
@@ -6,6 +6,7 @@
# 表的条数会写进替身(数组大小):条数随游戏版本固定,不是游戏内容。
# 用法:shell_stubs.py data <dm 目录> <输出 derived.tsv> 读真实的三份生成文件,写数据(d2rm_pack.py 与 shell_build.sh 都用)
# shell_stubs.py stubs <dm 目录> 把三份生成文件原地换成替身(只在 shell_build.sh 的临时副本里做)
# shell_stubs.py host-stubs <dm 目录> <derived.tsv> 只写宿主的两份替身(经验 / 仓库),条数取自 derived.tsv(Android 无界面宿主,不需要 RomFS)
# For the shell: split the three files "generated from the game files and compiled into the code" into two halves --
# data → one derived.tsv (generated from the user's own game files, placed in dm/ of the install package)
# stubs → three source files of the same names, with no data inside, only fixed-size empty tables and the few lines that fill the tables from derived.tsv at startup (host/dm_derived_rt.h)
@@ -13,6 +14,7 @@
# The entry counts of the tables are written into the stubs (array sizes): the counts are fixed by the game version and are not game content.
# Usage: shell_stubs.py data <dm directory> <output derived.tsv> read the three real generated files and write the data (used by both d2rm_pack.py and shell_build.sh)
# shell_stubs.py stubs <dm directory> replace the three generated files in place with stubs (done only in shell_build.sh's temporary copy)
# shell_stubs.py host-stubs <dm directory> <derived.tsv> write only the host's two stubs (experience / vault), counts taken from derived.tsv (Android headless host, no RomFS)
import os, re, sys
CSTR = r'"((?:[^"\\]|\\.)*)"'
@@ -22,7 +24,7 @@ def unq(s): return bytes(s, 'utf-8').decode('unicode_escape').encode('latin-1').
def paths(dm):
return (os.path.join(dm, 'host', 'dm_hud_exp.h'), os.path.join(dm, 'host', 'dm_vault_tab.h'), os.path.join(dm, 'ios', 'Sources', 'dm_touch_native_art.c'))
return (os.path.join(dm, 'host', 'dm_hud_exp.h'), os.path.join(dm, 'host', 'dm_vault_tab.h'), os.path.join(dm, 'touch', 'dm_touch_native_art.c'))
def parse(dm):
@@ -52,9 +54,8 @@ def data(dm, dst):
return len(exp), len(parts), len(rows), len(sets), len(trows)
def stubs(dm):
exp, parts, rows, sets, trows, (hud, vault, art, m) = parse(dm)
p_hud, p_vault, p_art = paths(dm)
def host_stubs(dm, nparts, nrows, nsets):
p_hud, p_vault, _ = paths(dm)
open(p_hud, 'w', encoding='utf-8').write('''// 壳的替身(ios/tools/shell_stubs.py 生成):经验表不编进代码,启动时从安装包的 dm/derived.tsv 读(标签 EXP,每行 10 个)
#pragma once
#include <stdint.h>
@@ -82,14 +83,20 @@ __attribute__((constructor)) static void vt_load(void) { int a = 0, b = 0, c = 0
for (int i = a; i < VT_NPART; i++) vt_part_name[i] = ""; for (int i = c; i < VT_NSET; i++) vt_set_key[i] = "";
for (int i = b; i < VT_NROW; i++) vt_rows[i] = (vt_row){ .set = -1, .key = "", .icon = "" };
if (a != VT_NPART || b != VT_NROW || c != VT_NSET) fprintf(stderr, "[dm] 【红】编年史仓库表没读全:部位 %%d / %%d、条目 %%d / %%d、套装 %%d / %%d\\n", a, VT_NPART, b, VT_NROW, c, VT_NSET); }
''' % (len(parts), len(rows), len(sets)))
''' % (nparts, nrows, nsets))
def stubs(dm):
exp, parts, rows, sets, trows, (hud, vault, art, m) = parse(dm)
p_hud, p_vault, p_art = paths(dm)
host_stubs(dm, len(parts), len(rows), len(sets))
stub = art[:m.start()] + '''static struct { uint32_t id; int atlas,frame; } rows[%d]; /* 壳的替身:技能索引不编进代码,启动时从安装包的 dm/derived.tsv 读(标签 TAROW) */
static void ta_row_cb(char **f, int n, void *ctx) { int *i = ctx; if (n < 3 || *i >= (int)(sizeof rows / sizeof rows[0])) return;
rows[*i].id = (uint32_t)strtoul(f[0], NULL, 10); rows[*i].atlas = atoi(f[1]); rows[*i].frame = atoi(f[2]); (*i)++; }
__attribute__((constructor)) static void ta_load(void) { int i = 0; dm_derived_each("TAROW", ta_row_cb, &i);
for (int k = i; k < (int)(sizeof rows / sizeof rows[0]); k++) { rows[k].id = UINT32_MAX - 1; rows[k].atlas = rows[k].frame = -1; }
if (i != (int)(sizeof rows / sizeof rows[0])) fprintf(stderr, "[dm] 【红】技能图标索引没读全:%%d / %%d\\n", i, (int)(sizeof rows / sizeof rows[0])); }''' % len(trows) + art[m.end():]
stub = stub.replace('#include <stddef.h>', '#include <stddef.h>\n#include "../../host/dm_derived_rt.h"', 1); assert 'dm_derived_rt.h' in stub
stub = stub.replace('#include <stddef.h>', '#include <stddef.h>\n#include "../host/dm_derived_rt.h"', 1); assert 'dm_derived_rt.h' in stub
open(p_art, 'w', encoding='utf-8').write(stub)
return len(parts), len(rows), len(sets), len(trows)
@@ -97,4 +104,11 @@ __attribute__((constructor)) static void ta_load(void) { int i = 0; dm_derived_e
if __name__ == '__main__':
if len(sys.argv) == 4 and sys.argv[1] == 'data': print('derived.tsv:经验 %d、部位 %d、仓库条目 %d、套装 %d、技能索引 %d' % data(sys.argv[2], sys.argv[3]))
elif len(sys.argv) == 3 and sys.argv[1] == 'stubs': print('替身已写:部位 %d、仓库条目 %d、套装 %d、技能索引 %d' % stubs(sys.argv[2]))
else: sys.exit('用法:shell_stubs.py data <dm 目录> <输出 derived.tsv> | shell_stubs.py stubs <dm 目录>')
elif len(sys.argv) == 4 and sys.argv[1] == 'host-stubs':
# 只写宿主用的两份替身(经验表、编年史仓库表),条数取自现成的 derived.tsv(如安装包里的 dm/derived.tsv):没有原版 RomFS 也能编宿主(Android 无界面宿主)
# Write only the two stubs the host uses (experience table, chronicle vault table), with counts taken from an existing derived.tsv (e.g. dm/derived.tsv in an install package): the host builds without the original RomFS (Android headless host)
tags = [l.split('\t', 1)[0] for l in open(sys.argv[3], encoding='utf-8')]
assert tags.count('EXP') == 10, '经验表应是 10 行'
n = tags.count('VTPART'), tags.count('VTROW'), tags.count('VTSET'); assert all(n), n
host_stubs(sys.argv[2], *n); print('宿主替身已写:部位 %d、仓库条目 %d、套装 %d' % n)
else: sys.exit('用法:shell_stubs.py data <dm 目录> <输出 derived.tsv> | shell_stubs.py stubs <dm 目录> | shell_stubs.py host-stubs <dm 目录> <derived.tsv>')
+2 -2
View File
@@ -40,7 +40,7 @@ TABLE = {
'ui.json': {
# 通知里不写怎么操作(界面更简洁;十字按钮变红已表达)
# Notifications do not say how to operate (the UI is cleaner; the cross button turning red already conveys it)
'LevelUpStatsNotificationController': ('7854f598', '你升级了。'),
'LevelUpStatsNotificationController': ('7854f598', '有新的属性点和技能点可以分配。'), # 与下一句同时弹出,写成同一句会显示两遍 | Pops up together with the next one; identical text would show twice
'LevelUpNotificationController': ('7ba311c9', '你升级了。'),
'QuestLogNotificationController': ('7b65d87d', '任务已更新。'),
'MoviePlaybackHoldToSkip': ('f3a05873', ''),
@@ -85,7 +85,7 @@ EN = {
'MoviePlaybackHoldToSkip_switch': ('dab56a9e', ''),
},
'ui.json': {
'LevelUpStatsNotificationController': ('525fb31a', "You've leveled up."),
'LevelUpStatsNotificationController': ('525fb31a', 'You have new Stat and Skill Points to spend.'),
'LevelUpNotificationController': ('1e4882b2', "You've leveled up."),
'QuestLogNotificationController': ('94d110a8', 'Quest has been updated.'),
'MoviePlaybackHoldToSkip': ('dab56a9e', ''),