fix(physics): restore type-four trigger response

The rewrite scored type-four targets but left ball velocity unchanged. The
reconstructed collision loop consumes two Borland random values after each
entered radius-bearing trigger and scales X and Y independently by
1.03 - Random * 0.08.

Apply that response to targets 140 through 152 and effect record 149 after their
ordered rule handling. This restores both the immediate trajectory and the
shared random-stream position used by later launcher, claw, nudge, and mechanism
choices.

Test Plan:
- `cargo test --all-targets` -- passed, 60 tests
- `cargo clippy --all-targets -- -D warnings` -- passed
- `rumdl check tdkpin-rs/CHANGELOG.md tdkpin-rs/RECONSTRUCTION.md` -- passed
- `git diff --cached --check` -- passed
This commit is contained in:
2026-08-23 17:01:44 +02:00
parent 3fa3e29ad3
commit 2f7e29b6a4
3 changed files with 22 additions and 2 deletions
+3
View File
@@ -10,6 +10,9 @@ and this project adheres to
### Fixed ### Fixed
- 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 - 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 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 resuming the next player, and use the original signed-high/unsigned-low score
+1 -1
View File
@@ -24,7 +24,7 @@ implementation.
| Help and languages | Exact | Original resource images 1001-1005 are displayed directly. | | Help and languages | Exact | Original resource images 1001-1005 are displayed directly. |
| Playfield collision layout | Recovered | All 109 active type-2 line objects and 40 static active type-1 circles are transcribed from the original 175-object registration table. The registration routine converts its sideways inputs with `screen = (y, x - 20)` and accumulates explicitly relative objects. Type-2 records retain every recovered Real48 normal/tangent response pair and registered one-sided orientation. Type-1 records retain their swept-circle radius, radial rebound, tangent coupling, and bumper kick. Each flipper uses its exact two line records plus moving tip circle in both positions. The upward edge transfer matches three live probes and the downstroke matches its live position-preserving `(3519,6302)` transfer; both are mirrored on the right. Object 174 is omitted because the original overwrites it with the live ball every frame. | | Playfield collision layout | Recovered | All 109 active type-2 line objects and 40 static active type-1 circles are transcribed from the original 175-object registration table. The registration routine converts its sideways inputs with `screen = (y, x - 20)` and accumulates explicitly relative objects. Type-2 records retain every recovered Real48 normal/tangent response pair and registered one-sided orientation. Type-1 records retain their swept-circle radius, radial rebound, tangent coupling, and bumper kick. Each flipper uses its exact two line records plus moving tip circle in both positions. The upward edge transfer matches three live probes and the downstroke matches its live position-preserving `(3519,6302)` transfer; both are mirrored on the right. Object 174 is omitted because the original overwrites it with the live ball every frame. |
| Ball launcher and nudge input | Recovered | The initial 32-bit fixed-point coordinates decode to `(325, 413)` in the right shooter lane. The port reproduces the initial `-375` millipixel Down event, 650 ms repeat delay, 40 ms repeats, release impulse, and randomized clamp below the original `-3800` maximum. Left Shift and keypad 3 apply their directional `(50-Random(20))*15` impulses; Space uses the recovered Real48 horizontal factor and `(60-Random(20))*15` vertical impulse. Each nudge adds 25 to the wrapping 16-bit tilt counter, compares it with `30+Random(10)`, and the detail timer decrements a nonzero counter once per callback. | | Ball launcher and nudge input | Recovered | The initial 32-bit fixed-point coordinates decode to `(325, 413)` in the right shooter lane. The port reproduces the initial `-375` millipixel Down event, 650 ms repeat delay, 40 ms repeats, release impulse, and randomized clamp below the original `-3800` maximum. Left Shift and keypad 3 apply their directional `(50-Random(20))*15` impulses; Space uses the recovered Real48 horizontal factor and `(60-Random(20))*15` vertical impulse. Each nudge adds 25 to the wrapping 16-bit tilt counter, compares it with `30+Random(10)`, and the detail timer decrements a nonzero counter once per callback. |
| Physics arithmetic | Recovered gameplay behavior | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, `3800` speed bound, point-path type-2 intersection, one-sided line response, swept type-1 circle response, and swept non-physical sensor contacts. It evaluates all records and applies the earliest contact along the substep. The original Borland seed update and high-word `Random(n)` mapping drive launcher variation, effects, claw terminals, and the recovered randomized magnetic-field impulse. Live probes cover ordinary rails, ordinary circles, a kicked bumper, lock holes, magnetic fields, all claw exits, and both flipper directions. Rust represents the original per-ball contact words as path-entry/inside latches; this is a source-structure difference rather than a missing collision route. | | Physics arithmetic | Recovered gameplay behavior | Production movement uses the original 10 ms millipixel substep, `+15` vertical acceleration, `3800` speed bound, point-path type-2 intersection, one-sided line response, swept type-1 circle response, and swept non-physical sensor contacts. It evaluates all records and applies the earliest contact along the substep. The original Borland seed update and high-word `Random(n)` mapping drive launcher variation, effects, claw terminals, and the recovered randomized magnetic-field impulse. Radius-bearing type-4 triggers independently scale X and Y by `1.03-Random*0.08` after their event path. Live probes cover ordinary rails, ordinary circles, a kicked bumper, lock holes, magnetic fields, all claw exits, and both flipper directions. Rust represents the original per-ball contact words as path-entry/inside latches; this is a source-structure difference rather than a missing collision route. |
| Rules | Recovered gameplay paths | Player count, controls, the five three-line bumper-value groups, four three-line TDK-diamond groups, five doubling-value lock holes, wheel-reset target, seven-way effect selector/consumer including multiball, permanent double scoring, and four exact media/extra-ball thresholds follow original help/code paths, globals, and object flags. The ninth diamond pays the original 24,464 completion value; the following completed bank enables double scoring, and later completions add 100,000 to the per-player secondary score. Turn changes mirror the original save/load of all 175 collision record states: wheel/top targets, active/contact slots, selected effect, and multiball readiness remain attached to their player. Claw contact and all initially active type-4 targets use recovered records. The top three targets score 500 each and independently enable the left, center, or right magnetic field record; each field pulls the ball upward until it exits and then deactivates. The claw state machine and release table have live differential coverage for all four random terminals. Remaining timing uncertainty is presentation batching at non-default detail settings, not gameplay routing. | | Rules | Recovered gameplay paths | Player count, controls, the five three-line bumper-value groups, four three-line TDK-diamond groups, five doubling-value lock holes, wheel-reset target, seven-way effect selector/consumer including multiball, permanent double scoring, and four exact media/extra-ball thresholds follow original help/code paths, globals, and object flags. The ninth diamond pays the original 24,464 completion value; the following completed bank enables double scoring, and later completions add 100,000 to the per-player secondary score. Turn changes mirror the original save/load of all 175 collision record states: wheel/top targets, active/contact slots, selected effect, and multiball readiness remain attached to their player. Claw contact and all initially active type-4 targets use recovered records. The top three targets score 500 each and independently enable the left, center, or right magnetic field record; each field pulls the ball upward until it exits and then deactivates. The claw state machine and release table have live differential coverage for all four random terminals. Remaining timing uncertainty is presentation batching at non-default detail settings, not gameplay routing. |
| Numeric scoring | Recovered gameplay values | Static scores come from the initialized 175-object ledger. Dynamic bumper progression, target-bank completion, diamond awards, 10k-160k lock bonuses, 310k transfer, six effect values, multiball mode, and all four media thresholds are transcribed from `1000:b476`, `1000:c4e1`, `1000:bc36`, and live state probes. Lock and effect awards share the original per-player secondary score and display multiplier; the fifth hole transfers and clears it, increments the multiplier, and grants the recovered ball award. Score mutation uses the original 32-bit wrapping behavior, and each add operation can advance at most one media threshold. | | Numeric scoring | Recovered gameplay values | Static scores come from the initialized 175-object ledger. Dynamic bumper progression, target-bank completion, diamond awards, 10k-160k lock bonuses, 310k transfer, six effect values, multiball mode, and all four media thresholds are transcribed from `1000:b476`, `1000:c4e1`, `1000:bc36`, and live state probes. Lock and effect awards share the original per-player secondary score and display multiplier; the fifth hole transfers and clears it, increments the multiplier, and grants the recovered ball award. Score mutation uses the original 32-bit wrapping behavior, and each add operation can advance at most one media threshold. |
| High scores | Recovered visible flow; portable storage | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names. Each player is checked immediately when their own last ball is lost; qualifying scores use the original signed-high/unsigned-low comparison and a `TDK Pinball Player`-prefilled name screen before the table is shown and play resumes. Persisted updates use portable JSON rather than rewriting the Win16 file. | | High scores | Recovered visible flow; portable storage | The original 276-byte table is decoded as ten `IWIK`-XOR-obfuscated little-endian scores plus ten 22-byte names. Each player is checked immediately when their own last ball is lost; qualifying scores use the original signed-high/unsigned-low comparison and a `TDK Pinball Player`-prefilled name screen before the table is shown and play resumes. Persisted updates use portable JSON rather than rewriting the Win16 file. |
+18 -1
View File
@@ -965,6 +965,7 @@ impl Game {
self.object_active[effect_index] = false; self.object_active[effect_index] = false;
events.push(Event::Target); events.push(Event::Target);
events.push(Event::Sound(2004)); events.push(Event::Sound(2004));
self.randomize_trigger_velocity();
} }
} }
} }
@@ -1002,9 +1003,20 @@ impl Game {
let field_id = [153, 6, 154][usize::from(sensor.id - 150)]; let field_id = [153, 6, 154][usize::from(sensor.id - 150)];
self.object_active[field_id] = true; self.object_active[field_id] = true;
} }
self.randomize_trigger_velocity();
} }
} }
#[allow(clippy::cast_possible_truncation)]
fn randomize_trigger_velocity(&mut self) {
let mut velocity = MilliVec::from_velocity_per_second(self.ball.velocity);
let x_factor = 1.03 - self.random.unit_interval() * 0.08;
let y_factor = 1.03 - self.random.unit_interval() * 0.08;
velocity.x = (f64::from(velocity.x) * x_factor).round() as i32;
velocity.y = (f64::from(velocity.y) * y_factor).round() as i32;
self.ball.velocity = velocity.to_velocity_per_second();
}
fn reset_ball_to_launcher(&mut self) { fn reset_ball_to_launcher(&mut self) {
self.ball = Ball::default(); self.ball = Ball::default();
self.launcher_charge = 0.0; self.launcher_charge = 0.0;
@@ -2053,6 +2065,7 @@ mod tests {
let mut game = Game::new_with_seed(1, 7); let mut game = Game::new_with_seed(1, 7);
game.ball.in_launcher = false; game.ball.in_launcher = false;
game.ball.position = vec2(205.0, 55.0); game.ball.position = vec2(205.0, 55.0);
game.ball.velocity = vec2(100.0, 200.0);
let mut events = Vec::new(); let mut events = Vec::new();
game.check_sensor_objects( game.check_sensor_objects(
@@ -2065,6 +2078,10 @@ mod tests {
assert!(game.object_active[153]); assert!(game.object_active[153]);
assert!(!game.object_active[6]); assert!(!game.object_active[6]);
assert!(!game.object_active[154]); assert!(!game.object_active[154]);
assert_eq!(
MilliVec::from_velocity_per_second(game.ball.velocity),
MilliVec { x: 1_012, y: 1_926 }
);
let mut field_velocity = MilliVec { x: 0, y: 2_015 }; let mut field_velocity = MilliVec { x: 0, y: 2_015 };
game.apply_magnetic_fields( game.apply_magnetic_fields(
@@ -2074,7 +2091,7 @@ mod tests {
}, },
&mut field_velocity, &mut field_velocity,
); );
assert_eq!(field_velocity, MilliVec { x: 0, y: -3_550 }); assert_eq!(field_velocity, MilliVec { x: 0, y: -3_513 });
game.apply_magnetic_fields( game.apply_magnetic_fields(
MilliVec { MilliVec {
x: 15_000, x: 15_000,