Files
tdkpin/tdkpin-rs/CHANGELOG.md
T
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

19 KiB

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Added

  • Crazy mode: pressing the main-row 0 key during a game drops ten more balls onto the playfield, up to 64 balls in play. High-score entries reached with crazy mode show a red CRAZY label in the table.
  • The high-score service stores a crazy-mode flag per entry; it adds the column to existing databases on startup and treats submissions from older clients as normal scores.

Changed

  • Replace the separate primary and secondary ball slots with one ordered list of identical balls. Every ball runs the same physics, sensors, holes, claw, ball-to-ball contact, and drain rules; the player's ball ends only when the last ball drains. One- and two-ball behavior keeps the recovered slot order.
  • A ball resting on the shooter stop returns to an empty launcher from any slot, and flippers keep kicking balls in play while another ball waits there.
  • The simulator trace now reports every ball in a balls array.

Fixed

  • Free a ball that was settling into a lock hole when another ball filled it, and release a lock hole whose settling ball left the table.

[1.2.1] - 2026-09-01

Fixed

  • Keep a ball captured by the Greifarm during multiball instead of consuming it; latch the two-ball capture rule at each entry, exclude the launcher release while that capture is active, and let later single-ball re-entries use all four original release choices.
  • Preserve that entry decision through the complete pull phase, scope it to the entering slot until that ball exits the capture zone, and migrate Greifarm state when a held secondary ball becomes the primary ball.

[1.2.0] - 2026-08-31

Added

  • Seed new SQLite high-score databases that did not exist before opening with the ten distributed demo scores.

Fixed

  • Deliberately diverge from the original game's multiball contact sentinel so a reserve ball that fills a wheel hole leaves it permanently occupied; the surviving ball can no longer enter and score that visibly filled slot again.
  • Match capture-driven multiball collapse timing so the surviving slot keeps double scoring through the current callback, then returns to normal scoring on the next callback and the returning claw remains paused until that collapse; completing the fifth wheel lock still ends multiball scoring immediately.
  • Derive wheel-lock awards from the original live contact words so two balls settling into different slots at once receive the same accumulated award as the original game.
  • Stage an effect-seven reserve-ball request until ball 1's full substep batch has returned, preventing the new slot from participating in collision and capture rules before the original creates it.
  • Bound high-score server resource usage with 1 KiB route body limits, single-operation database concurrency gating, 503 shedding, and offloading SQLite operations to blocking worker threads.
  • Use a relative path for the web build's high-score API endpoint so deployments under nested URL subpaths route requests correctly.
  • Implement bounded exponential backoff with jitter, initial delay and maximum delay bounds, and Retry-After header support for failed web high-score submissions.

[1.1.0] - 2026-08-29

Added

  • Add a static WebAssembly (WASM) browser build and web shell for TDK Pinball, persisting settings and scores in browser localStorage.
  • Add a standalone Axum and SQLite high-score service (highscore-server) for an optional shared top-ten leaderboard, including an nginx reverse-proxy configuration and API endpoints.
  • Route the browser high-score table through the shared service when available, retaining the local-storage fallback when offline or unconfigured.

Fixed

  • Allow launcher input while tilted so a waiting ball in the shooter lane is not stranded after a tilt, while retaining launch sound suppression.
  • Bundle the official Macroquad browser loader and WASM bootstrap locally so a CSP does not require inline JavaScript or code from not-fl3.github.io.
  • Keep the web canvas centered at the original fixed 640x460 presentation size instead of scaling with the browser viewport.
  • Seed the initial gameplay random stream from the startup clock so the first maximum-power launcher shot is not identical on every run.
  • Require an unconsumed record-148 contact before the effect-seven special respawn, preventing a released reserve ball from being duplicated after both multiball balls drain.
  • Apply type-4 entry latches only inside each target's registered broadphase, preventing an unrelated multiball slot from clearing an upper-left target's latch and causing repeated scoring while the ball remains there.

[1.0.0] - 2026-08-29

Fixed

  • Restore the common response's standard dot-product tangent tv=(vx*nx+vy*ny)/length: tv*0.02*response_tangent updates spin, while the current response opposes its sign with magnitude abs(normal_velocity)*response_tangent (negative when tv==0). Live probes match horizontal drain (-302,-1809), ordinary circle (94,564), bumper (197,3096), relative record 57 (1839,1832) with spin -5.28, and record 72 (-2095,1669) with spin +5.46.
  • Gate dynamic record 174/175 impulse transfer on the other slot's capture age: a held ball remains velocity-stationary and the moving response retains its full normal velocity instead of always subtracting 1,000.
  • Restore 1000:ae6e's required-ball special respawn: armed or completed effect-seven play grants one final (17,23)/(0,3040) ball without consuming a marker, clears required state including record 148's contact word, and suppresses record 148 until the next broadphase-active type-4 record reenables it.
  • Replace the invented post-move y>470 fallback with the original pre-scan prediction bounds x<=0 || x>340000 || y<=0 || y>460000, including one-slot removal during multiball and next-substep handling after a response.
  • Remove the invented 180 ms whole-frame nudge shake; original nudges affect ball-slot velocities, sound, and Tilt state without moving the viewport.
  • Match SndPlaySound(SND_ASYNC|SND_NODEFAULT) playback: stop the previous WAV before every new resource and use full host mixer volume instead of an invented 72 percent attenuation/overlap.
  • Load and draw all DAT400-407 player/effect sprites at (55,79), preserving the original saved 14x14 wheel overlap at (84,77); selected bonuses, collect-bonus, and release-ball states are now visible.
  • Restore display blits from 1008:0996/1008:0b9e: 130x40 score fields at X=478, eight places ending at X=606, exact 139x31 configured-player rows, 11x11 active/status markers, 5x5 remaining-ball markers for every player, and strict signed score-status thresholds independent of media awards.
  • Import exact [Settings] Language, Speed, and singular Sound values from an adjacent/original TDKPIN.INI before creating portable JSON. Fresh installs now inherit the distributed German help setting; F12 is again a silent runtime-only toggle and cannot leak into a later save.
  • Replace modern high-score/name overlays with the reconstructed HighScore child: exact DAT993 360x300 background, heading/row coordinates, unpadded scores, and DIALOG 32514 caption, prompt, 21-character edit, OK, and Cancel. Escape now follows original Cancel semantics and empty names are accepted.
  • Restore the staged loading presentation by blitting original DAT994 over DAT995 at (202,328), height 13 and clipped width (stage-1)*7; correct the previously impossible Pascal-order C interpretation of a 328x202 blit.
  • Restore the original idle/attract timer animation: target and word-quad chases, magnetic flashes, five-record strip, four-point chase, DAT801-809 item progression, and the circular WELCOME TO THE MACHINE BITMAP500 marquee. Each nested phase uses the binary's remainder first: %32/2, %32/4, %40/4, %16/4, and %144/8. Move gameplay item frames to their exact (123,300) destination.
  • Match central score/event side effects: every stored collision candidate clears its ball slot's capture age, Tilt suppresses all score and rule-record mutations, and active multiball doubles points before permanent Double can double them again.
  • Scan static, capture, trigger, magnetic, and dynamic record ranges in exact ID order with a separately tracked prediction. Preserve the raw scanner's first-detected-candidate quirk even when a later record is geometrically nearer, plus type-3 and dynamic-record broadphase behavior.
  • Run type-3/type-4 processing before response and position publication: captures now test the old position, contacted type-3 rims contribute radial candidates, triggers mutate the live motion first, and sensor IDs execute in binary order without Hold/Complete prematurely ending the record scan.
  • Apply the collision table's predicted-position broadphase bounds before type-1/type-2 detection, including the registered five-pixel ball margin, and retain unresolved candidates until the selected response phase.
  • Correct the two relative slingshot initializer chains after records 55 and 70: circles 56/58/71/73 and lines 57/59/72/74 now accumulate from each preceding path endpoint exactly as the 175-record ledger specifies. The flagless TDK companion lines also retain their zero contact/link field rather than carrying unused synthetic head IDs. Record 57 additionally matches the live original's (75530,354765)/(3000,15) to (77369,356597)/(1839,1832) transition; symmetric record 72 matches (235348,356825)/(-3000,15) to (233253,358494)/(-2095,1669).
  • Match rectangular type-4 magnetic gates to raw 1000:9b69: enter only when the previous position is inside, then deactivate when the newly predicted position exits any edge, replacing a swept-intersection approximation.
  • Decay the 16-bit tilt counter once per selected 50/40/30/20/10 ms detail callback, replacing an invented independent 30 ms accumulator.
  • Match the multiball nudge path's saved-slot behavior: consume the active formula's random draws, then add one shared fixed/random impulse to both slot velocity records instead of applying different formulas to each ball.
  • Restore auxiliary response thresholds/kicks for bumpers 51-53 and line records 55, 74, and 107, including weak-hit bumper scoring, WAVE 2019 on kicked unscored rails, and the original tilt suppression.
  • Preserve every collision record's +0x49 layer mask and select upper layer 1 or lower layer 2 from the ball's previous 250,000-millipixel Y boundary.
  • Match the original detail callback's slot-major integration order, stop a slot's remaining 10 ms substeps after its first collision/action, delay a newly requested second ball until the next callback, and retain ball-two identity while a captured/drained ball one is collapsed.
  • Run type-3 captures and type-4 triggers for both live ball slots, including per-slot capture age/contact ownership, exact captured-slot removal, survivor promotion, and the effect-seven ball-number guard against a third ball.
  • Spawn effect-seven ball 2 from record 148 at (17,23) with exact (0,3040) millipixel velocity, instead of launching a guessed second ball upward from the shooter lane.
  • Treat record 148 as the special/multiball hole represented by player item 20; capturing it preserves all five lock-hole items and contacts instead of inventing an immediate wheel reset. Its exact 17x17 overlay-A Word-Quad at (9,14) remains visible until the required contact is consumed.
  • Replace invented bumper outline/cooldown effects with the original per-record 5/20/10 callback countdowns and exact overlay-A render rectangles for bumpers 51-53 and targets 140-147/150-152.
  • Render the five cumulative bumper-value lamps from original player items 1-5 at their recovered Word-Quad bounds as the value rises from 1,000 to 6,000.
  • Render the nine in-bank hit states for record heads 90/93/96/99/102 and 109/112/115/118 from their exact overlay-A bounds until bank completion rearms each three-line group.
  • Replace the free-running wheel animation with the original six-callback 91x90 target rotation, WAVE 2011 start, exact DAT600 frames/target positions, and state-6 rotation of the five per-player contact/item values. It advances only for an active ball, pauses in the launcher, and survives a normal drain.
  • Restore the complete 281-callback DAT600 panel sequence after the fifth lock hole, including physics suspension, contact/item cleanup, all nine image phases, and the original WAVE 2013/2012/stop boundaries. A fifth lock captured during multiball still transfers its capped 160,000-step award but defers the panel until a later single-ball completion. Any subsequent type-3 reset with all five contacts set, including the special hole, also starts the panel as 1000:9e85 does.
  • Remove the invented attract-screen instruction panel and stop assigning the original F2/F3 keys to modern overlays. The idle view is the original table; optional settings/high-score viewers move to F10/F9.
  • Batch physics and flipper publication on the original 50/40/30/20/10-ms detail callbacks with exactly 5/4/3/2/1 internal 10-ms substeps, instead of exposing every substep on host render frames.
  • Separate flipper key flags from rendered/collision position so press/release edges and WAVE 2021 occur only when the detail timer processes them.
  • Add a bit-exact Borland Real48 core and route speed clamps, type-1 circles, type-2 segments, moving flippers, capture pulls, trigger randomization, and magnetic impulses through its original rounding behavior.
  • Preserve per-ball Real48 spin and use it in collision tangent response, so zero-spin C fixtures and retained-spin Wine traces are both represented.
  • Implement dynamic records 174/175 with bidirectional ball impulse transfer and the original post-collision speed clamp instead of a one-sided secondary bounce.
  • Split collision contact state into per-player 16-bit type-3 contact words and transient type-4 entry flags. Type-3 records now use the original deep-inside gate, v*0.9 +/-150 pull, stationary sound/contact publication, 5-step age progression to 300, and 99/2 completion sentinels.
  • Replace the live-fitted flipper transfer polynomials with the reconstructed 1000:7ed9 millipixel geometry gates, penetration, gain, response-record, velocity, and position calculations for both directions and both balls.
  • Preserve every gameplay millipixel across the float-only render projection so exact integer physics results are not changed when stored for drawing.
  • Restore launcher input to the setup scalar: each Down keydown subtracts 750 millipixels, release subtracts 1,500, then applies the recovered -3800 and -2280 clamp/jitter branches and the ten original decoration thresholds.
  • Apply the original independent 1.03 - Random * 0.08 X/Y velocity response after entering radius-bearing type-4 targets, preserving both motion and the subsequent shared PRNG sequence.
  • Check every player against the high-score table when their own last ball is lost, prefill the original TDK Pinball Player name, show the table before resuming the next player, and use the original signed-high/unsigned-low score ordering instead of selecting only the maximum score at whole-game end.
  • Preserve each player's complete rule-record state across turn changes instead of globally clearing wheel holes, top targets, 176 active/contact slots, selected effect, and multiball readiness on every drain.
  • Store lock-hole and effect awards in the original per-player secondary score instead of a global bonus. The fifth hole now transfers 310000 * score_multiplier, clears it, increments the multiplier and ball count, while effect 6 transfers the same display value and drain leaves it intact.
  • Replace the cooldown/float-meter nudge approximation with the original Left-Shift, keypad-3, and Space formulas using scalar 15, the shared Borland random stream, 32-bit velocity wrapping, and the decaying 16-bit +25 tilt counter with its randomized 30..39 threshold.
  • Preserve held flipper keys and raised geometry across ordinary drains. Tilt and a player's final ball now clear the key latch, release a raised flipper through its normal WAVE 2021 timer edge, and require physical key-up before the same key can raise it again.
  • Match the original low-byte keyboard scans: both Ctrl keys operate the left flipper, both Enter keys operate the right, and the physical 0x1b main-keyboard plus/right-bracket position starts or adds players.
  • Dispatch add-player, nudge, and F12 sound-toggle actions on key release through the original 1000:638e timing rather than on their initial key press.
  • Enforce the original auxiliary-window input gate: F1 and F12 are ignored while Help, HighScore, or name-entry UI is open instead of controlling the main game through a child window.
  • Route a single-ball type-3 completion during Tilt through 1000:ae6e instead of granting a free launcher reset: lock holes consume the ball, while record 148 can still take its required-state special-respawn branch.
  • Replace the Xorshift gameplay RNG with the original Borland linear stream and unbiased Random(n) high-word mapping. Launcher variation, effect selection, claw terminals, and magnetic-field impulses now share the recovered sequence.
  • Preserve the Borland seed across game-over/high-score flow so a new game continues the program-global random stream instead of reseeding per game.
  • Restore the magnetic-field response as vx * 0.9 and a randomized -3800 * (1 - Random * 0.3) vertical impulse instead of a fixed upward speed.
  • Dispatch the original per-call-site sound sequences instead of assigning one guessed WAV to each logical event. This removes the nonexistent WAV 2022 playback and restores bank, trigger, capture, nudge, tilt, and drain cues. Type-4 WAVE 2004 and bumper WAVE 2006 now precede their score mutations so a simultaneously crossed media marker leaves WAVE 2007 audible, as in the monophonic original. A tilted drain suppresses WAVE 2008 before reset, while a following flipper-release edge may still play WAVE 2021 after reset. Bumper/TDK bank completion WAVE 2017 likewise precedes its 50,000 or 10,000..24,464 award, preserving the marker cue when that award crosses one.
  • Advance media/extra-ball thresholds only from score additions, preserve 32-bit score wrapping, and restore the ninth-diamond ordering: its 24,464 award remains single, then ball-scoped double scoring and all three magnetic fields activate before the collision's static score. Further completed banks during that ball add 100,000 to the secondary score; a normal ball end clears the multiplier, while effect seven's special respawn preserves it. Marker comparisons retain the binary's signed-high/unsigned-low 32-bit ordering after score wrap.
  • Match the original 640x460 window, native 16x28 score glyphs, and TDK Pinball Machine 1.00 title so the recovered artwork is presented one-for-one instead of enlarged or resampled.