feat: rebuild TDK Pinball Machine in Rust

Replace the empty Rust scaffold with a playable native reconstruction of the
1995 Win16 game. Embed the complete decoded asset set, retain the original
640x460 presentation and localized help, and implement a resizable letterboxed
Macroquad frontend for Linux, macOS, and Windows.

Recreate the multiplayer ball flow, flippers, nudging, target banks, wheel,
robot, lock, magnets, bumper progression, TDK diamond multiplier, media extra
balls, sound dispatch, settings, and high-score entry. The physics engine uses
a fixed time step and 101 static collision segments transcribed from the
original 175-object table. Portable JSON persistence imports and decodes the
original XOR-obfuscated high-score file on first run.

Document the evidence boundary explicitly: artwork and PCM samples are exact,
static geometry is recovered, and several numeric scoring/impulse values remain
best-evidence behavioral tuning rather than bit-identical Win16 arithmetic.
Add a native three-OS CI matrix and retain every decoded resource for future
fidelity work.

Test Plan:
- `diff -qr original/assets/decoded tdkpin-rs/assets/original` with the two
  intentionally added legacy root files excluded -- passed
- `cargo fmt --all -- --check` -- passed
- `cargo check --all-targets` -- passed
- `cargo test --all-targets` -- passed, 8 tests
- `cargo clippy --all-targets -- -D warnings` -- passed
- `cargo build --profile production` -- passed
- `cargo check --all-targets --target x86_64-pc-windows-gnu` -- passed
- `cargo check --all-targets --target x86_64-apple-darwin` -- passed
- `cargo run` graphical start, launch, collision, and score smoke test -- passed;
  audible output was unavailable because the host has no ALSA device
This commit is contained in:
2026-08-22 16:12:11 +02:00
parent 54061f1eb7
commit f817b63683
81 changed files with 3653 additions and 2 deletions
+69
View File
@@ -0,0 +1,69 @@
# Reconstruction ledger
## Source artifacts
The reconstruction was derived from the preserved files under `../original/`.
The primary program fingerprint is:
```text
a9022f1894e3e6e21fc42e8f6c932f7c549ca77f63aaa0c488bb9d55d9d0174c TDKPIN.EXE
f1d9ac980c7bfba5dc53eaa9e7cb2c3cd9b82f879ee8962ad40bf863d641bb49 MMTIMER.DLL
```
The Ghidra recovery covers all 301 named NE exports plus 62 internal function
entries. Its raw output and coverage tables remain beside the binary, so later
work can be checked against the same evidence rather than against this Rust
implementation.
## Coverage by subsystem
| Subsystem | Rust status | Evidence and boundary |
| --- | --- | --- |
| Artwork | Exact | All 34 custom DIB images, three standard bitmaps, icon, and palette derivatives are preserved in `assets/original/`. The game uses the original 640x460 table, loading, help, media, and diamond frames. |
| Audio | Exact samples | All 16 mono PCM WAV resources are embedded unchanged. Their trigger roles were recovered from resource use and gameplay context. |
| Help and languages | Exact | Original resource images 1001-1005 are displayed directly. |
| Playfield collision layout | Recovered | 101 active static line segments are transcribed from the original 175-object registration table. The original sideways coordinates are transformed with `screen = (y, 478 - x)`. Moving flippers and round bumpers use equivalent native Rust bodies. |
| Physics arithmetic | Reimplemented | The Win16 fixed-point/timer engine is replaced by deterministic fixed-step floating-point integration. Restitution and impulses are tuned to the recovered table but are not instruction-for-instruction equivalents. |
| Rules | Behaviorally recovered | Player count, controls, wheel holes, magnetic saves, robot grip, four-position ball lock, target banks, increasing bumper value, nine-part TDK diamond, permanent double scoring for a completed diamond, KByte media progression, and media extra balls follow the original help and code paths. |
| Numeric scoring | Partly inferred | Visible 2000-6000 target values and recovered registration values are preserved. Some bumper, bank-completion, robot, wheel, lock, and media thresholds are best-evidence reconstructions because the decompiler did not recover meaningful names or a clean rule table. |
| High scores | Compatible import | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names, sorted, then migrated to portable JSON. |
| Configuration | Behaviorally compatible | Sound, language, and five detail levels are retained. Storage moves from a local Win16 INI file to the platform user-data directory. |
| Windows UI shell | Deliberately modernized | Win16 menus, modal dialogs, GDI blitting, and multimedia timers are replaced by a resizable, letterboxed native window with keyboard overlays. The visible game and original help remain at 640x460 logical pixels. |
## Extracted asset inventory
`assets/original/` contains 69 files used or preserved by the modern project:
- 40 image files, including all gameplay frames and five localized help pages;
- 16 original WAV resources;
- six decoded dialog descriptions;
- the original icon in ICO and PNG form;
- palette and version metadata;
- the original high-score table and INI configuration sample.
The parent `original/assets/` directory remains the lossless extraction record,
including raw resource blobs and the extraction manifest. The Rust copy is the
decoded, build-ready subset; it does not replace that evidence archive.
## Validation levels
- Static coverage: all intended decoded visual/audio resources are preserved;
the 101 recovered static collision segments are represented in Rust.
- Build coverage: `cargo check`, unit tests, and strict Clippy complete on the
host. Cross-target checks pass for `x86_64-pc-windows-gnu` and
`x86_64-apple-darwin`; CI is configured to build and test natively on Linux,
macOS, and Windows.
- Runtime coverage: the Linux executable was launched through the real window
backend, the attract screen was inspected, a game was started, a ball was
launched, collision scoring was observed, and a rendered frame was captured.
- Semantic boundary: no claim is made that every trajectory or score tick is
bit-identical to the 16-bit executable. Remaining numeric inference is listed
above instead of being presented as proven parity.
## Architecture
- `app.rs`: screen flow, controls, rendering, audio dispatch, and overlays;
- `assets.rs`: compile-time original asset embedding;
- `game.rs`: fixed-step game state, recovered walls, rules, and scoring;
- `geometry.rs`: segment/circle collision primitives;
- `persistence.rs`: platform paths, settings, high scores, and legacy import.