Files
tdkpin/tdkpin-rs
ddidderr a8cc0fc5fc feat(divergence): make every ball identical and bind crazy mode to 0
Crazy mode first shipped as a side list of "crazy balls" with reduced
physics (walls, bumpers, flippers only) next to the original primary and
secondary slots. That is not what was wanted: a ball in the machine is a
ball, with no main/second/extra distinction. This replaces the two-slot
engine with one ordered list and moves the shortcut to a single key.

Ball model (src/game.rs)
- Game::balls: Vec<Ball> replaces `ball`, `secondary_ball`, and
  `crazy_balls`. The list is never empty while the game runs; a waiting
  ball is simply a ball with in_launcher set.
- advance_ball_slots runs one timer callback: every ball, in slot order,
  integrates up to `substeps` steps through the single integrator
  step_ball (record scan, ball-to-ball contact, rule dispatch, drain) and
  stops after its first collision, exactly like the original slot pass.
- BallPass carries the ball's current index plus the slot number and
  ball count from the start of the callback. The original keeps slot two
  numbered 2 for the rest of a callback even after slot one drained, and
  type-three contact records publish that number as their owner; keeping
  it per pass preserves that.
- Effect seven's ball goes to `spawned_balls` and joins after all slot
  passes, as the original publishes slot two only after slot one's pass.
- lose_ball removes a drained ball while others remain (Drain event,
  normal scoring once one ball is left) and only the last ball takes the
  special respawn or ends the player's ball. remove_ball keeps the claw's
  captured/entry indices and the claw and lock-hole contact owners
  pointing at the same physical ball when an earlier slot leaves.
- The claw stores a ball index instead of a Primary/Secondary enum.
- Nudge, flipper kicks, multiball scoring, and the "no third ball from
  effect seven" guard are expressed over the list. With one or two balls
  the original order, random draws, and ownership rules are unchanged;
  all existing parity and multiball tests pass after a mechanical port
  (test-only shims fixed_update, advance_secondary_ball, drain,
  secondary/set_secondary/take_secondary keep them readable).
- Crazy mode adds ten ordinary balls (capped at MAX_BALLS = 64 because
  contact records reserve 99 as a sentinel) and marks the player.

Deliberate differences from the original (also in PARITY_AUDIT.md),
mostly because there is no longer a special slot one:
- A ball resting on the shooter stop returns to an empty launcher from
  any slot; the original deleted a slot-two ball there. If the launcher
  is occupied the ball leaves the table without costing a ball.
- Flipper kicks, record countdowns, and target rotation keep running for
  balls in play while another ball waits in the launcher.
- Ball-to-ball contact skips only the claw-held ball; every ball's hit
  is published as last_collision_id.
- Stress runs with 10-64 balls showed balls trapped forever: two balls
  settle into one lock hole, one fills it (contact 99), and the rim then
  reflects the other from the inside. A filled hole's rim now only
  repels balls moving towards its center. Lock-hole owners of a removed
  ball are cleared/renumbered like the claw owner.

Input (src/app.rs)
- Crazy mode is the bare main-row 0 key. It overlaps no original or
  modern binding and has no browser default action, so the WASM build
  receives it. The Ctrl+Shift+0 combo and its Shift-release nudge
  suppression are gone.
- Rendering draws every ball not held by the claw.

Simulator: snapshots report `balls: [...]` instead of `ball` and
`secondary_ball`; autoplay flips for any ball near a flipper.

Test Plan:
- cargo test (160 tests), including new ones:
  a_ball_moves_the_same_in_any_slot (same ball in slot one vs. behind a
  waiting ball follows the identical trajectory),
  crazy_mode_adds_ten_ordinary_balls_and_marks_the_player,
  the_turn_ends_only_when_the_last_ball_drains,
  shooter_stop_rearms_a_returning_ball_from_any_slot,
  crazy_mode_is_capped_and_rejected_after_the_game.
- A temporary release-mode stress test (not committed) ran 12 seeded
  two-player games with crazy mode, autoplay flippers, and nudges to
  completion, and 4 seeds at the 64-ball cap for 30k frames, asserting
  finite state, a non-empty ball list, and valid claw indices.
- Manual: during a game press 0 (also in the browser build); ten balls
  appear, each can be captured by the claw, lock holes, and targets, and
  the turn ends only after the last ball drains.
2026-10-10 11:15:11 +02:00
..
2026-09-01 05:22:59 +02:00
2026-09-01 05:22:59 +02:00
2026-08-22 15:52:52 +02:00
2026-08-22 15:52:52 +02:00
2026-08-22 15:52:52 +02:00

TDK Pinball Machine for modern PCs

This is a native Rust reconstruction of the 1995 Windows game TDK Pinball Machine. It uses the extracted original artwork and sound, recreates the playfield as a fixed-step simulation, and runs from the same source on Linux, macOS, and Windows.

The game opens at the original 640x460 canvas size and presents every artwork pixel one-for-one. The fixed, non-high-DPI client prevents desktop scaling from distorting or vertically offsetting the pixel-art presentation.

The original program is not required at runtime. All required game assets are embedded in the executable at build time.

Run

Install a current stable Rust toolchain, then run:

cargo run

For a distributable optimized binary:

cargo build --profile production

The binary is written below target/production/. On Linux, Macroquad's native development packages are also required (X11, OpenGL, and ALSA). Windows needs no extra runtime installation; macOS builds with the normal Apple developer command-line tools.

Browser version

Build and serve the WASM website locally with:

just web-serve

Then open http://127.0.0.1:8000/. The browser build keeps the original 640x460 presentation centered on a black page and stores settings and a local fallback table in browser storage unless the optional same-origin /api/highscores service is deployed. See web/README.md and highscore-server/README.md for deployment details.

Deterministic mechanics validation

Named scenarios can be advanced without waiting in real time. The simulator uses exact 120 Hz steps, prints its final state as JSON, and can write both the complete step trace and the original-size 640x460 framebuffer:

cargo run -- --simulate claw-6 --at 0.15 \
  --trace /tmp/claw-6.json \
  --screenshot /tmp/claw-6.png

Use --step N instead of --at SECONDS to reproduce one exact update. The available scenarios are loading, attract, highscores, name-entry, effect-7, autoplay, launcher, flippers, panel, targets, claw-1, claw-6, claw-7, claw-18, and crazy; --seed N fixes random choices. autoplay charges each ball and operates the flippers from live ball position for long end-to-end validation runs.

Original and modern controls

Action Original key Additional modern key
Start game / add up to 4 players Keypad + or the main +/] position = is also accepted
Charge launcher Hold Down arrow, release to launch -
Left flipper Ctrl (left or right) A or Left arrow
Right flipper Enter (main or keypad) D or Right arrow
Nudge Space, Left Shift, keypad 3 Right Shift aliases keypad 3
Help F1 Enter/Escape returns
Settings TDKPIN.INI before launch F10 opens the portable settings screen
High scores Automatic when a player finishes F9 opens the portable table viewer
Sound F12 -
Crazy mode: drop 10 more balls - 0 (main row)

Crazy mode is a modern addition. Each press drops ten balls at fixed points on the playfield, up to 64 balls in play. They are ordinary balls: every ball runs the same physics, sensors, holes, claw, and scoring, and the player's ball ends only when the last one drains. A player who used crazy mode still enters the high-score table, with their entry labelled CRAZY.

The five original speed choices remain available in settings. Physics now uses the original invariant 100 Hz millipixel substep, batched as 5/4/3/2/1 steps on the recovered 50/40/30/20/10 ms callbacks. Claw animation, flipper edges, and visible state publication follow the same selected callback cadence.

The help screen is the original artwork in English, German, French, Italian, or Spanish. As instructed on that screen, double-clicking its upper-left exit box closes the program.

Saved data

Native settings and the ten-entry high-score table are stored as save.json in the platform's normal per-user application-data directory. Browser settings and the fallback table use localStorage; a deployed browser build uses the same-origin high-score service as its shared table when available. On first run, native settings are imported from an adjacent original INI (or the embedded distributed TDKPIN.INI), and the table is imported from the original HISCORES.DAT.

Reconstruction status

This repository distinguishes exact recovered material from behavioral reimplementation. See RECONSTRUCTION.md for the evidence ledger, known inference boundaries, and validation performed.