Initial public release
This commit is contained in:
@@ -0,0 +1 @@
|
||||
!*.bin
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
# native_binding — test fixtures for skill binding parsing
|
||||
|
||||
中文:[README.zh-CN.md](README.zh-CN.md)
|
||||
|
||||
For unit tests only. The app does not read these two files at run time, and the tests do not modify them.
|
||||
|
||||
**The public repository does not ship these two fixtures**: they are two tables captured from the memory of the running game. Without them, the three tests below that read the fixtures are skipped automatically with a one-line notice, and the other tests run as usual. To run those three tests you have to capture the two tables from the running game yourself and put them in this directory under the file names below; the assertions in the tests are written against the contents of the snapshot described below, so with different contents the assertions have to be changed accordingly.
|
||||
|
||||
## Background
|
||||
|
||||
The skill buttons on the right need to show "which skill this button is bound to right now". In the memory of the running game this information is two tables, which the shell fetches read-only and then parses (`../../../Sources/dm_touch_game_bridge.c` does the fetching, and `dm_tg_parse` in `../../../Sources/dm_touch_game_state.c` does the parsing):
|
||||
|
||||
- **Button mapping table**: for each of the six gamepad buttons (B, A, Y, X, R, ZR), which normal skill slot and which alternate skill slot it corresponds to. The alternate slots are the set used while ZL is held.
|
||||
- **Binding table**: the skill ID bound in each skill slot; an empty slot is `0xFFFFFFFF`.
|
||||
|
||||
## Files
|
||||
|
||||
| File | Size | Contents |
|
||||
|---|---|---|
|
||||
| `mapping.bin` | 114 bytes | A snapshot of the button mapping table. Parsing uses only the first 72 bytes: 6 entries, each of 3 32-bit little-endian integers (logical button, normal slot, alternate slot) |
|
||||
| `bindings.bin` | 896 bytes | A snapshot of the binding table: 32 entries of 28 bytes each; the 32-bit little-endian integer at the start of each entry is the skill ID |
|
||||
|
||||
The contents of this snapshot, which the assertions in the tests are written against:
|
||||
|
||||
- Button mapping: B → normal slot 1 / alternate slot 7, A → 0 / 6, Y → 2 / 8, X → 3 / 9, R → 4 / 10, ZR → 5 / 11.
|
||||
- Bindings: slots 0, 2 and 7 of the first group have skills, the rest are empty; the second group, starting from entry 16, is entirely empty. Slot 7 is the town portal skill, so in the parse result the way to press town portal is ZL + B.
|
||||
|
||||
Checksums (SHA-256):
|
||||
|
||||
```
|
||||
b9777515f225f235ac1223dd04bf15db250f1240f893511737ceecf357367362 mapping.bin
|
||||
4d4f4cde5d08f35f9a988ac61aff54913499d32322ac95fa3ce7763c16a11262 bindings.bin
|
||||
```
|
||||
|
||||
## Who uses them
|
||||
|
||||
The `test` target of `dm/ios/tests/Makefile` passes these two files as arguments to three tests (when the files are absent, these three tests are skipped):
|
||||
|
||||
| Test | What it verifies with them |
|
||||
|---|---|
|
||||
| `t_native_binding` | Parsing: in the normal case it reads out the button mapping and the town portal button combination above; when the length is too short, a slot number is out of range, a button is duplicated, or the observed skill ID does not match, it rejects in every case |
|
||||
| `t_game_bridge` | Puts the two tables into a block of simulated game memory and verifies the whole path from reading memory to producing a snapshot: reading does not modify registers or the tables; no snapshot is produced when not in a game |
|
||||
| `t_native_hud_bridge` | Same as above, and additionally verifies that a snapshot is produced only after confirming that the call comes from the HUD of the current game, and that after switching to another game it has to be confirmed again |
|
||||
|
||||
To run: `make -C dm/ios/tests test`.
|
||||
@@ -0,0 +1,45 @@
|
||||
# native_binding — 技能绑定解析的测试夹具
|
||||
|
||||
English: [README.md](README.md)
|
||||
|
||||
只给单元测试用。App 运行时不读这两个文件,测试也不会改它们。
|
||||
|
||||
**公开仓库不带这两份夹具**:它们是从运行中的游戏内存抓下来的两张表。缺了它们,下面三个要读夹具的测试自动跳过并打印一行说明,其余测试照常。要跑这三个测试,得自己从运行中的游戏抓这两张表,照下面的文件名放到本目录;测试里的断言是按下面这份快照的内容写的,内容不同就要相应改断言。
|
||||
|
||||
## 背景
|
||||
|
||||
右侧技能钮上要显示「这个键现在绑着哪个技能」。这份信息在运行中的游戏内存里是两张表,外壳只读地取出来再解析(`../../../Sources/dm_touch_game_bridge.c` 负责取,`../../../Sources/dm_touch_game_state.c` 的 `dm_tg_parse` 负责解析):
|
||||
|
||||
- **键位表**:六个手柄键(B、A、Y、X、R、ZR)各对应哪个普通技能槽、哪个替代技能槽。替代槽是按住 ZL 时用的那一套。
|
||||
- **绑定表**:每个技能槽里绑着的技能编号,空槽是 `0xFFFFFFFF`。
|
||||
|
||||
## 文件
|
||||
|
||||
| 文件 | 大小 | 内容 |
|
||||
|---|---|---|
|
||||
| `mapping.bin` | 114 字节 | 键位表的一份快照。解析只用前 72 字节:6 项,每项 3 个 32 位小端整数(逻辑键、普通槽、替代槽) |
|
||||
| `bindings.bin` | 896 字节 | 绑定表的一份快照:32 项,每项 28 字节,每项开头的 32 位小端整数是技能编号 |
|
||||
|
||||
这份快照里的内容,测试里的断言按它写:
|
||||
|
||||
- 键位:B → 普通槽 1 / 替代槽 7,A → 0 / 6,Y → 2 / 8,X → 3 / 9,R → 4 / 10,ZR → 5 / 11。
|
||||
- 绑定:第一组的 0、2、7 号槽有技能,其余为空;从第 16 项起的第二组全空。7 号槽是回城技能,所以解析结果里回城的按法是 ZL + B。
|
||||
|
||||
校验值(SHA-256):
|
||||
|
||||
```
|
||||
b9777515f225f235ac1223dd04bf15db250f1240f893511737ceecf357367362 mapping.bin
|
||||
4d4f4cde5d08f35f9a988ac61aff54913499d32322ac95fa3ce7763c16a11262 bindings.bin
|
||||
```
|
||||
|
||||
## 谁在用
|
||||
|
||||
`dm/ios/tests/Makefile` 的 `test` 目标把这两个文件作为参数传给三个测试(文件不在时这三个测试跳过):
|
||||
|
||||
| 测试 | 用它验什么 |
|
||||
|---|---|
|
||||
| `t_native_binding` | 解析:正常情况读出上面的键位与回城按法;长度不够、槽号越界、键位重复、观察到的技能编号对不上时一律拒绝 |
|
||||
| `t_game_bridge` | 把两张表放进一块模拟的游戏内存,验从内存读取到产出快照的整条通路:读取不改寄存器、不改表;不在局内时不出快照 |
|
||||
| `t_native_hud_bridge` | 同上,另验要先确认调用来自当前这一局的 HUD 才出快照,换了一局要重新确认 |
|
||||
|
||||
运行:`make -C dm/ios/tests test`。
|
||||
Reference in New Issue
Block a user