Files
kdm-re/game-internals.md
ulw-execute 3910630c25 docs: mark release-difference facts verified; fix doc inconsistencies
Owner confirmed the differing sizes/export counts/RVAs are just a different
release of the same official game. Remove the "pending re-check against
clean-release binary" / "contaminated install" caveats throughout and state
those numbers (module sizes, export counts, gameMain RVA 0x9e20) as verified
facts. Drop the stale 3,369,104-byte gamekdm figure in favor of the
consistent 3.19 MB. Genuine format/behavior UNVERIFIED markers (undecoded
.arc/.ifs/.ttc/etc. formats, Kinect dispatch/sync) are preserved.
2026-11-28 21:01:37 -05:00

112 lines
5.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# DanceEvolution Arcade (DEA / `gamekdm.dll`) — game internals & RE jumpstart
Everything reverse-engineered about how DEA consumes the Microsoft NUI runtime, plus a
jump‑start so another agent can continue a full RE/decompilation **without
redoing this work**. All gamekdm addresses use image base `0x10000000`.
Scope is the nine Konami modules in `contents/modules/` and the official
assets/configuration in `contents/`, as listed in
[docs/companion-inventory.md](docs/companion-inventory.md).
`Kinect10.dll` is only an external Microsoft NUI v1 runtime dependency of
`gamekdm.dll`, supplied by the platform.
The addresses, layouts, constants, and disassembly observations below concern
`contents/modules/gamekdm.dll` and `contents/modules/libafp-win32.dll`.
---
## 1. How DEA consumes the Kinect
- `gamekdm.dll` imports the external Microsoft `Kinect10.dll` NUI v1 API.
The game runs skeleton selection/validation and a Flash menu cursor (below).
- The historical live-manager address is `*(gamekdm+0x3cf1b4)`.
## 2. Skeleton rendering & the selection/validity gate *(solved)*
For the in‑game skeleton to render, a candidate skeleton must pass the game's
orientation/validity gate, decoded from `gamekdm`:
- `FUN_10018570` builds a gravity/floor‑relative transform `M`. If the gravity
vector at `manager+0x2c` is the sentinel, `M` is derived from the skeleton's
TRACKED joints (weighted ratio of tracked joints must exceed `0.85`, weights
`DAT_102a49e8`; then 5 limb‑direction dot‑products must each exceed `0.9`).
Feeding `vNormalToGravity = (0,1,0)` populates `manager+0x2c` and takes the
simpler gravity branch instead.
- `FUN_100e4140 → FUN_101ab6d0` is the candidate‑validity filter: it computes
`P1 = (-px, py + m13, -pz + m14)` (no perspective divide) and accepts only if
`P1` is within `0.05` of the box `[A-B, A+B]` where `A = DAT_103d3230 =
(0,1,0)`, `B = (1.22, 1, 0.675)` → box x∈[-1.22,1.22], y∈[0,2], z∈[-0.675,
0.675]. `m13` is taken straight from
the skeleton frame's `vFloorClipPlane.w`.
## 3. The menu hand‑cursor (Flash/`afp` PhIZ) *(solved)*
This one is *not* in any DLL — it lives in the game's Flash runtime:
- `afp` is a **Flash/ActionScript runtime** (`libafp-win32.dll` exports
`flash.display.InteractiveObject`, `flash.ui.MouseCursor`, `useHandCursor`).
Menu UI (incl. the cursor sprite) is compiled Flash packed in the `.ifs`
archives under `contents/data/bm2d/*.ifs`.
- The moving cursor is the controller's own movie clip. gamekdm global
**`DAT_103d2bb8`** is the cursor‑controller object pointer; the live 1P cursor
is at `(*DAT_103d2bb8)+0x108/+0x10c` and 2P at `+0x110/+0x114`, in **screen
pixels (1280×720)**. `FUN_1007fbf0` reads it via `afp_mc_get_param(ctrl+8,
0x1008)` and snaps to the OK buttons (`_but_ok_1p/2p_usr`) when `dist² <
0x1fa4` (~90 UI units). The `_icon_1p/2p/only_usr` strings are the **OK‑button
icons**, *not* the cursor.
- **No gamekdm code writes the cursor from the hand** (no `afp_mc_set_param`
with `0x1008`; 53 decompiled menu AS scripts reference no hand/cursor/natal).
The hand→cursor PhIZ is inside the Flash/Natal runtime — a body‑relative,
reach‑normalised mapping.
## 4. Two‑player
- **The game supports 2P**: dual cursor slots (`CUR1`/`CUR2` above),
`NuiSkeletonSetTrackedSkeletons([id0, id1])`, and NUI's 6 skeleton slots.
## 6. RE / decompilation jump‑start (for a fresh agent)
Everything you need to continue without redoing the groundwork:
### Ghidra (gamekdm.dll)
- Analyse **once** into a persistent project, then reuse it (re‑analysing per run
wasted 3–5 min each):
```
analyzeHeadless /home/athapa/ghidra gkproj -import gamekdm.dll # once, NO -deleteProject
analyzeHeadless /home/athapa/ghidra gkproj -process gamekdm.dll -noanalysis -postScript <script.py>
```
JDK21 at `/home/athapa/jdk`; scripts in `/home/athapa/ghidra/scripts/`
(`getFunctionContaining` + `decompileFunction`). Full objdump at `/tmp/gk.asm`.
- Key functions/globals (base `0x10000000`): cursor controller global
`DAT_103d2bb8`; cursor read `FUN_101d84c0`→`afp_mc_get_param(_,0x1008)`;
button‑hit `FUN_1007fbf0`; cursor state machine `FUN_1007e330`; icon‑reader
`FUN_10080360`; validity transform `FUN_10018570`; candidate filter
`FUN_100e4140`/`FUN_101ab6d0`; validity box `DAT_103d3230`, matrix
`DAT_103d4a80`; manager pointer `*(gamekdm+0x3cf1b4)`.
### afp / Flash data (the cursor PhIZ lives here)
- `ifstools` (pip, pure‑Python) extracts `data/bm2d/*.ifs` → `afp/<name>` (Flash)
+ `afp/bsi/<name>` (bytecode) + `geo/` + `tex/`.
- **bemaniutils** has the AFP ActionScript decompiler, but it is **not on PyPI**
and needs **Python 3.12** (not 3.14) — install from git and import only the afp
parser (its `mysqlclient`/server deps fail but aren't needed):
```
git clone --depth 1 https://github.com/DragonMinded/bemaniutils /tmp/bemaniutils
python3.12 -m pip install --break-system-packages Pillow pycryptodome cython
PYTHONPATH=/tmp/bemaniutils python3.12 -c "from bemani.format.afp import SWF, ByteCodeDecompiler"
```
Decompile a clip: `SWF("<name>", open(afp,'rb').read(), open(bsi,'rb').read())`,
`.parse()`, then walk `AP2DoActionTag.bytecode.decompile()` (see
`bemani/utils/afputils.py decompile_and_write_bytecode`). The menu scripts do
**not** contain the hand→cursor map — it's in the Flash/Natal runtime —
so next step is `libafp-win32.dll` (Ghidra project `afpproj`, already analysed)
around its `flash.ui.MouseCursor` / pointer handling.
### Can't run the game here
Wine is not installed and the real cabinet/original-binary runtime needs
DirectX + a real camera — iterate with the build→deploy→playtest loop, not an
emulator. Deep‑low RE subagents repeatedly failed on this (armed a monitor and
exited, then hit a 429 at ~2.1M tokens) — do the game RE directly with the local
Ghidra setup.